Skip to content

Commit 2f209b5

Browse files
committed
Conforming to Lint; changed gradle version back to 8.0
1 parent f525dcf commit 2f209b5

File tree

9 files changed

+35
-34
lines changed

9 files changed

+35
-34
lines changed

.idea/kotlinc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ android {
3737
compose true
3838
}
3939
composeOptions {
40-
kotlinCompilerExtensionVersion = "1.5.1"
40+
kotlinCompilerExtensionVersion = "1.5.4"
4141
}
4242
packagingOptions {
4343
resources {

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ buildscript {
33
core_ktx_version = '1.10.1'
44
lifecycle_ktx_version = '2.6.1'
55
activity_compose_version = '1.7.2'
6-
compose_ui_version = '1.5.0'
6+
compose_ui_version = '1.5.4'
77
kotest_version = '5.6.2'
88
}
99
}
1010

1111
plugins {
12-
id 'com.android.application' version '7.4.2' apply false
13-
id 'com.android.library' version '7.4.2' apply false
14-
id 'org.jetbrains.kotlin.android' version '1.9.0' apply false
12+
id 'com.android.application' version '8.1.2' apply false
13+
id 'com.android.library' version '8.1.2' apply false
14+
id 'org.jetbrains.kotlin.android' version '1.9.20' apply false
1515
id 'org.jlleitschuh.gradle.ktlint' version '10.3.0'
1616
}
1717

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

texteditor/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ android {
4545
}
4646

4747
composeOptions {
48-
kotlinCompilerExtensionVersion '1.5.1'
48+
kotlinCompilerExtensionVersion '1.5.4'
49+
}
50+
publishing{
51+
singleVariant('release') {
52+
withSourcesJar()
53+
withJavadocJar()
54+
}
4955
}
5056
}
5157

texteditor/src/main/java/jp/kaleidot725/texteditor/controller/EditorController.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ internal class EditorController(
303303
}
304304

305305
companion object {
306-
fun List<String>.createInitTextFieldStates(textStyle:TextStyle,textSelectedStyle:TextStyle): List<TextFieldState> {
307-
if (this.isEmpty()) return listOf(TextFieldState(isSelected = false,textStyle = textStyle, textSelectedStyle = textSelectedStyle))
306+
fun List<String>.createInitTextFieldStates(textStyle: TextStyle, textSelectedStyle: TextStyle): List<TextFieldState> {
307+
if (this.isEmpty()) return listOf(TextFieldState(isSelected = false, textStyle = textStyle, textSelectedStyle = textSelectedStyle))
308308
return this.mapIndexed { _, s ->
309309
TextFieldState(
310310
value = TextFieldValue(s, TextRange.Zero),

texteditor/src/main/java/jp/kaleidot725/texteditor/state/TextEditorState.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ data class TextEditorState(
2929
companion object {
3030
fun create(text: String, textStyle: TextStyle = TextStyle(), textSelectedStyle: TextStyle = TextStyle()): TextEditorState {
3131
return TextEditorState(
32-
fields = text.lines().createInitTextFieldStates(textStyle,textSelectedStyle),
32+
fields = text.lines().createInitTextFieldStates(textStyle, textSelectedStyle),
3333
selectedIndices = listOf(-1),
3434
isMultipleSelectionMode = false,
3535
textStyle = textStyle,
@@ -39,7 +39,7 @@ data class TextEditorState(
3939

4040
fun create(lines: List<String>, textStyle: TextStyle = TextStyle(), textSelectedStyle: TextStyle = TextStyle()): TextEditorState {
4141
return TextEditorState(
42-
fields = lines.createInitTextFieldStates(textStyle,textSelectedStyle),
42+
fields = lines.createInitTextFieldStates(textStyle, textSelectedStyle),
4343
selectedIndices = listOf(-1),
4444
isMultipleSelectionMode = false,
4545
textStyle = textStyle,

texteditor/src/main/java/jp/kaleidot725/texteditor/view/TextEditor.kt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import androidx.compose.runtime.CompositionLocalProvider
1616
import androidx.compose.runtime.DisposableEffect
1717
import androidx.compose.runtime.LaunchedEffect
1818
import androidx.compose.runtime.getValue
19+
import androidx.compose.runtime.mutableStateMapOf
1920
import androidx.compose.runtime.mutableStateOf
2021
import androidx.compose.runtime.remember
2122
import androidx.compose.runtime.rememberUpdatedState
@@ -47,15 +48,16 @@ fun TextEditor(
4748
contentPaddingValues: PaddingValues = PaddingValues(),
4849
decorationBox: DecorationBoxComposable = { _, _, innerTextField -> innerTextField(Modifier) },
4950
) {
50-
val textEditorState by rememberUpdatedState(newValue = textEditorState)
51+
val textEditorStateM by rememberUpdatedState(newValue = textEditorState)
5152
val editableController by rememberTextEditorController(
52-
textEditorState,
53-
onChanged = { onChanged(it) })
53+
textEditorStateM,
54+
onChanged = { onChanged(it) }
55+
)
5456
var lastScrollEvent by remember { mutableStateOf(null as ScrollEvent?) }
5557
val lazyColumnState = rememberLazyListState()
56-
val focusRequesters by remember { mutableStateOf(mutableMapOf<Int, FocusRequester>()) }
58+
val focusRequesters = remember { mutableStateMapOf<Int, FocusRequester>() }
5759

58-
editableController.syncState(textEditorState)
60+
editableController.syncState(textEditorStateM)
5961

6062
LaunchedEffect(lastScrollEvent) {
6163
lastScrollEvent?.consume()
@@ -77,7 +79,7 @@ fun TextEditor(
7779
contentPadding = contentPaddingValues
7880
) {
7981
itemsIndexed(
80-
items = textEditorState.fields,
82+
items = textEditorStateM.fields,
8183
key = { _, item -> item.id }
8284
) { index, textFieldState ->
8385
val focusRequester by remember { mutableStateOf(FocusRequester()) }
@@ -99,13 +101,13 @@ fun TextEditor(
99101
interactionSource = remember { MutableInteractionSource() },
100102
indication = null
101103
) {
102-
if (!textEditorState.isMultipleSelectionMode) return@clickable
104+
if (!textEditorStateM.isMultipleSelectionMode) return@clickable
103105
editableController.selectField(targetIndex = index)
104106
}
105107
) {
106108
TextField(
107109
textFieldState = textFieldState,
108-
enabled = !textEditorState.isMultipleSelectionMode,
110+
enabled = !textEditorStateM.isMultipleSelectionMode,
109111
focusRequester = focusRequester,
110112
onUpdateText = { newText ->
111113
editableController.updateField(
@@ -145,7 +147,7 @@ fun TextEditor(
145147
onDownFocus = {
146148
if (lastScrollEvent != null && lastScrollEvent?.isConsumed != true) return@TextField
147149
editableController.selectNextField()
148-
if (index != textEditorState.fields.lastIndex) lastScrollEvent =
150+
if (index != textEditorStateM.fields.lastIndex) lastScrollEvent =
149151
ScrollEvent(index + 1)
150152
}
151153
)

texteditor/src/main/java/jp/kaleidot725/texteditor/view/TextField.kt

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,22 @@ import android.view.KeyEvent.KEYCODE_TAB
88
import androidx.compose.foundation.layout.fillMaxWidth
99
import androidx.compose.foundation.layout.wrapContentHeight
1010
import androidx.compose.foundation.text.BasicTextField
11-
import androidx.compose.foundation.text.selection.LocalTextSelectionColors
12-
import androidx.compose.foundation.text.selection.TextSelectionColors
13-
import androidx.compose.material.TextFieldDefaults
1411
import androidx.compose.runtime.Composable
15-
import androidx.compose.runtime.CompositionLocalProvider
1612
import androidx.compose.runtime.LaunchedEffect
1713
import androidx.compose.runtime.derivedStateOf
1814
import androidx.compose.runtime.getValue
19-
import androidx.compose.runtime.mutableStateOf
2015
import androidx.compose.runtime.remember
2116
import androidx.compose.runtime.rememberUpdatedState
2217
import androidx.compose.ui.Modifier
2318
import androidx.compose.ui.focus.FocusRequester
2419
import androidx.compose.ui.focus.focusRequester
2520
import androidx.compose.ui.focus.focusTarget
2621
import androidx.compose.ui.focus.onFocusChanged
27-
import androidx.compose.ui.graphics.Color
28-
import androidx.compose.ui.graphics.Color.Companion.Transparent
2922
import androidx.compose.ui.input.key.KeyEvent
3023
import androidx.compose.ui.input.key.KeyEventType
3124
import androidx.compose.ui.input.key.onPreviewKeyEvent
3225
import androidx.compose.ui.input.key.type
3326
import androidx.compose.ui.text.TextRange
34-
import androidx.compose.ui.text.TextStyle
3527
import androidx.compose.ui.text.input.TextFieldValue
3628
import jp.kaleidot725.texteditor.state.TextFieldState
3729

@@ -50,11 +42,12 @@ internal fun TextField(
5042
modifier: Modifier = Modifier,
5143
) {
5244
val currentTextField by rememberUpdatedState(newValue = textFieldState.value)
53-
val textStyle by remember(textFieldState.isSelected){
54-
derivedStateOf{
55-
if(textFieldState.isSelected) textFieldState.textSelectedStyle
56-
else textFieldState.textStyle
57-
}}
45+
val textStyle by remember(textFieldState.isSelected) {
46+
derivedStateOf {
47+
if (textFieldState.isSelected) textFieldState.textSelectedStyle
48+
else textFieldState.textStyle
49+
}
50+
}
5851

5952
LaunchedEffect(textFieldState.isSelected) {
6053
if (textFieldState.isSelected) {

0 commit comments

Comments
 (0)