Skip to content

Commit

Permalink
Update version
Browse files Browse the repository at this point in the history
  • Loading branch information
ismartcoding committed Apr 6, 2024
1 parent af931b4 commit dd32ed9
Show file tree
Hide file tree
Showing 82 changed files with 101 additions and 89 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ android {
else -> 0
}

val vCode = 262
val vCode = 265
versionCode = vCode - singleAbiNum
versionName = "1.2.43"
versionName = "1.2.44"

ndk {
//noinspection ChromeOsAbiSupport
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ismartcoding.plain.ui.base.mdeditor

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.background
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Box
Expand Down Expand Up @@ -41,14 +42,14 @@ import kotlinx.coroutines.flow.debounce
@Composable
fun MdEditor(
viewModel: MdEditorViewModel,
scrollState: ScrollState,
focusRequester: FocusRequester,
) {
val textFieldScrollState = rememberScrollState()
val lineNumberState = rememberScrollState()
var lineCount by remember { mutableIntStateOf(0) }

LaunchedEffect(Unit) {
snapshotFlow { textFieldScrollState.value }
snapshotFlow { scrollState.value }
.debounce(10)
.collectLatest { value ->
lineNumberState.scrollTo(value)
Expand Down Expand Up @@ -96,7 +97,7 @@ fun MdEditor(
.fillMaxSize()
.focusRequester(focusRequester),
state = viewModel.textFieldState,
scrollState = textFieldScrollState,
scrollState = scrollState,
textStyle = MaterialTheme.typography.bodyLarge.copy(color = MaterialTheme.colorScheme.onSurface),
cursorBrush = SolidColor(MaterialTheme.colorScheme.primary),
onTextLayout = { result ->
Expand Down
17 changes: 14 additions & 3 deletions app/src/main/java/com/ismartcoding/plain/ui/page/notes/NotePage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text2.input.textAsFlow
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.Redo
Expand Down Expand Up @@ -78,6 +80,12 @@ fun NotePage(
val v = navController.currentBackStackEntry?.arguments?.getString("id") ?: ""
mutableStateOf(if (v == "create") "" else v)
}
val mdListState = rememberLazyListState()
val editorScrollState = rememberScrollState()
var shouldRequestFocus by remember {
mutableStateOf(true)
}

LaunchedEffect(Unit) {
viewModel.editMode = id.isEmpty()
mdEditorViewModel.load(context)
Expand Down Expand Up @@ -129,7 +137,10 @@ fun NotePage(
delay(500)
coMain {
insetsController.hide(WindowInsetsCompat.Type.navigationBars())
focusRequester.requestFocus()
if (shouldRequestFocus) {
focusRequester.requestFocus()
shouldRequestFocus = false
}
}
}
} else {
Expand Down Expand Up @@ -181,9 +192,9 @@ fun NotePage(
},
content = {
if (viewModel.editMode) {
MdEditor(viewModel = mdEditorViewModel, focusRequester = focusRequester)
MdEditor(viewModel = mdEditorViewModel, editorScrollState, focusRequester = focusRequester)
} else {
LazyColumn {
LazyColumn(state = mdListState) {
item {
TopSpace()
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dd32ed9

Please sign in to comment.