Skip to content

Commit 0b3726e

Browse files
committed
refactor: Simplify TtsEditContainerScreen save logic and update SaveCallBack usage
- Replaced the use of a list iterator with a for-each loop in `TtsEditContainerScreen` for iterating through save callbacks, making the code more concise. - Changed `LocalSaveCallBack` from `staticCompositionLocalOf` to `compositionLocalOf` for better handling of missing providers. - Remove `immersionbar` and `immersionbar.ktx` from the project dependencies. - Add `AndroidFilePicker` dependency.
1 parent fa3d526 commit 0b3726e

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

app/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@ dependencies {
190190
implementation 'me.rosuh:AndroidFilePicker:1.0.1'
191191

192192
implementation(libs.hanlp)
193-
implementation(libs.immersionbar)
194-
implementation(libs.immersionbar.ktx)
195193

196194

197195
implementation(libs.bundles.about)

app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/ui/widgets/SaveHandler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package com.github.jing332.tts_server_android.compose.systts.list.ui.widgets
22

33
import androidx.compose.runtime.Composable
44
import androidx.compose.runtime.DisposableEffect
5+
import androidx.compose.runtime.compositionLocalOf
56
import androidx.compose.runtime.remember
6-
import androidx.compose.runtime.staticCompositionLocalOf
77

88
internal val LocalSaveCallBack =
9-
staticCompositionLocalOf<MutableList<SaveCallBack>> { mutableListOf() }
9+
compositionLocalOf<MutableList<SaveCallBack>> { error("No save callbacks") }
1010

1111
internal fun interface SaveCallBack {
1212
suspend fun onSave(): Boolean

app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/ui/widgets/TtsEditContainerScreen.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,8 @@ fun TtsEditContainerScreen(
5858
onSystemTtsChange = onSysttsChange,
5959
onSave = {
6060
scope.launch {
61-
val iterator = callbacks.listIterator(callbacks.size)
62-
while (iterator.hasPrevious()) {
63-
val element = iterator.previous()
64-
if (!element.onSave()) return@launch
61+
for (callBack in callbacks) {
62+
if (!callBack.onSave()) return@launch
6563
}
6664

6765
onSave()

0 commit comments

Comments
 (0)