Skip to content

Commit 62aa3fd

Browse files
committed
add compose example to README.md
1 parent 8b5d72e commit 62aa3fd

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,29 @@ dependencies {
3737

3838
in your desired module ```build.gradle``` file.
3939

40+
## Compose
41+
42+
```kotlin
43+
var text by rememberSaveable(stateSaver = TextFieldValue.Saver) {
44+
val initialText = readResourceFileAsText(R.raw.short_sample)
45+
mutableStateOf(TextFieldValue(initialText))
46+
}
47+
48+
KodeEditor(
49+
modifier = Modifier.fillMaxSize(),
50+
languageRuleBook = MarkdownRuleBook(),
51+
colorScheme = DarkBackgroundColorSchemeWithSpanStyle(),
52+
text = text,
53+
onValueChange = { text = it },
54+
colors = KodeEditorDefaults.editorColors()
55+
)
56+
```
57+
4058
## Add to your layout
4159

4260
To use this editor simply add something similar to this to your desired layout xml file:
4361

44-
```
62+
```xml
4563
<de.markusressel.kodeeditor.library.view.CodeEditorLayout
4664
android:id="@+id/codeEditorView"
4765
android:layout_width="match_parent"
@@ -99,7 +117,7 @@ KodeEditor can be styled in multiple ways:
99117

100118
You can either use those attributes directly on the view in your layout like this:
101119

102-
```
120+
```xml
103121
<de.markusressel.kodeeditor.library.view.CodeEditorView
104122
android:id="@+id/codeEditorView"
105123
android:layout_width="match_parent"
@@ -119,7 +137,7 @@ You can either use those attributes directly on the view in your layout like thi
119137

120138
or specify them in your application theme (`styles.xml` in dem app) for to apply a style globally:
121139

122-
```
140+
```xml
123141
<resources>
124142

125143
<!-- Base application theme. -->

0 commit comments

Comments
 (0)