feat: add basic text editor

This commit is contained in:
Matthieu Bessat 2024-01-29 09:54:28 +01:00
parent bbea101acd
commit a29ebe422f
6 changed files with 58 additions and 2 deletions

View file

@ -2,6 +2,7 @@
plugins { plugins {
alias(libs.plugins.androidApplication) alias(libs.plugins.androidApplication)
alias(libs.plugins.kotlinAndroid) alias(libs.plugins.kotlinAndroid)
//id("org.mozilla.rust-android-gradle.rust-android") version "0.9.3" apply false
} }
android { android {
@ -54,4 +55,5 @@ dependencies {
implementation(libs.androidx.ui.tooling.preview) implementation(libs.androidx.ui.tooling.preview)
runtimeOnly(libs.androidx.ui.tooling) runtimeOnly(libs.androidx.ui.tooling)
implementation(libs.org.eclipse.jgit) implementation(libs.org.eclipse.jgit)
implementation("com.meetup:twain:0.2.2")
} }

View file

@ -0,0 +1,24 @@
package net.mbess.popequer.ui
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.Card
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.TextFieldValue
import com.meetup.twain.MarkdownEditor
@Composable
fun Editor() {
val textFieldValue = rememberSaveable(stateSaver = TextFieldValue.Saver) {
mutableStateOf(TextFieldValue("THe quick brown fox jump"))
}
Card {
MarkdownEditor(
value = textFieldValue.value,
onValueChange = { value -> textFieldValue.value = value.copy(text = value.text) },
modifier = Modifier.fillMaxWidth()
)
}
}

View file

@ -54,7 +54,7 @@ fun NoteContainer(
Surface( Surface(
modifier = Modifier.padding(padding) modifier = Modifier.padding(padding)
){ ){
Text(text = "Hello, world!") Editor()
} }
} }
} }

View file

@ -3,5 +3,28 @@
plugins { plugins {
alias(libs.plugins.androidApplication) apply false alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.kotlinAndroid) apply false alias(libs.plugins.kotlinAndroid) apply false
//id("org.mozilla.rust-android-gradle.rust-android") version "0.9.3"
} }
true // Needed to make the Suppress annotation work for the plugins block
//Cargo {
// module = "../rust-sandbox" // Or whatever directory contains your Cargo.toml
// libname = "rust-sandbox" // Or whatever matches Cargo.toml's [package] name.
// targets = listOf("arm") // See bellow for a longer list of options
//}
//project.afterEvaluate {
// tasks.withType(com.nishtahir.CargoBuildTask::class)
// .forEach { buildTask ->
// tasks.withType(com.android.build.gradle.tasks.MergeSourceSetFolders::class)
// .configureEach {
// this.inputs.dir(
// layout.buildDirectory.dir("rustJniLibs" + File.separatorChar + buildTask.toolchain!!.folder)
// )
// this.dependsOn(buildTask)
// }
// }
//}
true // Needed to make the Suppress annotation work for the plugins block

View file

@ -1,5 +1,6 @@
[versions] [versions]
agp = "8.2.0" agp = "8.2.0"
compose-markdown = "0.3.7"
kotlin = "1.9.21" kotlin = "1.9.21"
kotlinx-coroutines-android = "1.7.3" kotlinx-coroutines-android = "1.7.3"
compose-compiler = "1.5.6" compose-compiler = "1.5.6"
@ -11,6 +12,7 @@ navigation-compose = "2.7.6"
compose-bom = "2023.10.01" compose-bom = "2023.10.01"
material3 = "1.1.2" material3 = "1.1.2"
org-eclipse-jgit = "6.8.0.202311291450-r" org-eclipse-jgit = "6.8.0.202311291450-r"
twain = "0.2.2"
[libraries] [libraries]
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" } androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
@ -21,8 +23,10 @@ androidx-material-ripple = { module = "androidx.compose.material:material-ripple
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigation-compose" } androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigation-compose" }
androidx-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } androidx-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
androidx-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } androidx-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
compose-markdown = { module = "com.github.jeziellago:compose-markdown", version.ref = "compose-markdown" }
kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinx-coroutines-android" } kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinx-coroutines-android" }
org-eclipse-jgit = { module = "org.eclipse.jgit:org.eclipse.jgit", version.ref = "org-eclipse-jgit" } org-eclipse-jgit = { module = "org.eclipse.jgit:org.eclipse.jgit", version.ref = "org-eclipse-jgit" }
twain = { module = "com.meetup:twain", version.ref = "twain" }
[plugins] [plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" } androidApplication = { id = "com.android.application", version.ref = "agp" }

View file

@ -1,3 +1,5 @@
import java.net.URI
pluginManagement { pluginManagement {
repositories { repositories {
google { google {
@ -16,6 +18,7 @@ dependencyResolutionManagement {
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
maven { url = URI("https://jitpack.io") }
} }
} }