Skip to content

Commit ab2d057

Browse files
committed
[ADDED] Additional view for demo
1 parent 10ae2fe commit ab2d057

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

example/src/main/java/dev/hossain/ynaash/example/ui/common/SampleSourceCode.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,13 @@ object SampleSourceCode {
5353
| )
5454
|}
5555
""".trimMargin()
56+
57+
val jetpackComposeView = """
58+
|SyntaxHighlighter(
59+
| sourceCode = "data class Student(val name: String, val age: Int)",
60+
| language = "kotlin",
61+
| showLineNumbers = false,
62+
| modifier = Modifier.fillMaxSize()
63+
|)
64+
""".trimMargin()
5665
}

example/src/main/java/dev/hossain/ynaash/example/ui/demoprismjs/PrismJsComposeDemoActivity.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import androidx.appcompat.app.AppCompatActivity
88
import androidx.compose.foundation.isSystemInDarkTheme
99
import androidx.compose.foundation.layout.Arrangement
1010
import androidx.compose.foundation.layout.Column
11+
import androidx.compose.foundation.layout.Spacer
1112
import androidx.compose.foundation.layout.WindowInsets
1213
import androidx.compose.foundation.layout.fillMaxSize
1314
import androidx.compose.foundation.layout.fillMaxWidth
@@ -154,6 +155,25 @@ fun PrismJsComposeDemoScreen() {
154155
modifier = Modifier.fillMaxSize()
155156
)
156157
}
158+
159+
Text(
160+
text = "Compose Example",
161+
style = MaterialTheme.typography.titleMedium
162+
)
163+
164+
Card(
165+
modifier = Modifier
166+
.fillMaxWidth()
167+
.height(200.dp)
168+
) {
169+
SyntaxHighlighter(
170+
sourceCode = SampleSourceCode.jetpackComposeView,
171+
language = "kotlin",
172+
showLineNumbers = false,
173+
modifier = Modifier.fillMaxSize()
174+
)
175+
}
176+
Spacer(modifier = Modifier.height(32.dp))
157177
}
158178
}
159179

example/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@
4141
android:id="@+id/prismjs_compose_demo_button"
4242
android:layout_width="wrap_content"
4343
android:layout_height="wrap_content"
44-
android:text="See PrismJS Compose Demo" />
44+
android:text="See PrismJS Demo - Jetpack Compose" />
4545
</LinearLayout>

0 commit comments

Comments
 (0)