Skip to content

Commit cfab41b

Browse files
committed
feat: Fix scrolling in bottom sheet and update select dialog
- Fixed issue where scrolling a LazyColumn inside a BottomSheet would cause the BottomSheet itself to scroll instead. - Modified `SysttsSelectBottomSheet` to display a list of enabled TTS configurations using `LazyColumn`. - Added `HtmlText` to display the description of the TTS configurations. - Added padding to the LazyColumn items for better readability. - Fixed issue where `SysttsSelectBottomSheet` in `ReplaceRuleEditScreen` was commented out.
1 parent fc267bb commit cfab41b

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/edit/ReplaceRuleEditScreen.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import androidx.compose.foundation.layout.Arrangement
88
import androidx.compose.foundation.layout.Column
99
import androidx.compose.foundation.layout.ExperimentalLayoutApi
1010
import androidx.compose.foundation.layout.Row
11+
import androidx.compose.foundation.layout.Spacer
1112
import androidx.compose.foundation.layout.WindowInsets
1213
import androidx.compose.foundation.layout.fillMaxSize
1314
import androidx.compose.foundation.layout.fillMaxWidth
15+
import androidx.compose.foundation.layout.height
16+
import androidx.compose.foundation.layout.heightIn
1417
import androidx.compose.foundation.layout.ime
1518
import androidx.compose.foundation.layout.imePadding
1619
import androidx.compose.foundation.layout.isImeVisible
@@ -358,10 +361,10 @@ private fun Screen(
358361

359362
var showTtsSelectDialog by remember { mutableStateOf(false) }
360363
if (showTtsSelectDialog) {
361-
// SysttsSelectBottomSheet(onDismissRequest = { showTtsSelectDialog = false }) {
362-
// showTtsSelectDialog = false
363-
// showAuditionDialog = it
364-
// }
364+
SysttsSelectBottomSheet(onDismissRequest = { showTtsSelectDialog = false }) {
365+
showTtsSelectDialog = false
366+
showAuditionDialog = it
367+
}
365368
}
366369

367370
AnimatedVisibility(visible = testResult.isNotBlank()) {
@@ -378,6 +381,8 @@ private fun Screen(
378381
SelectionContainer {
379382
Text(text = testResult, style = MaterialTheme.typography.bodyMedium)
380383
}
384+
385+
Spacer(Modifier.height(48.dp))
381386
}
382387
}
383388

app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/edit/TtsConfigSelectDialog.kt

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package com.github.jing332.tts_server_android.compose.systts.replace.edit
22

33
import androidx.compose.foundation.layout.Column
4-
import androidx.compose.foundation.layout.Spacer
54
import androidx.compose.foundation.layout.fillMaxHeight
65
import androidx.compose.foundation.layout.fillMaxWidth
7-
import androidx.compose.foundation.layout.height
86
import androidx.compose.foundation.layout.padding
97
import androidx.compose.foundation.lazy.LazyColumn
108
import androidx.compose.foundation.lazy.itemsIndexed
@@ -20,13 +18,17 @@ import androidx.compose.runtime.setValue
2018
import androidx.compose.ui.Alignment
2119
import androidx.compose.ui.Modifier
2220
import androidx.compose.ui.draw.clip
21+
import androidx.compose.ui.platform.LocalContext
2322
import androidx.compose.ui.res.stringResource
2423
import androidx.compose.ui.tooling.preview.Preview
2524
import androidx.compose.ui.unit.dp
2625
import com.github.jing332.compose.ComposeExtensions.clickableRipple
26+
import com.github.jing332.compose.widgets.HtmlText
2727
import com.github.jing332.database.dbm
2828
import com.github.jing332.database.entities.systts.SystemTtsV2
29+
import com.github.jing332.database.entities.systts.TtsConfigurationDTO
2930
import com.github.jing332.tts_server_android.R
31+
import com.github.jing332.tts_server_android.compose.systts.list.ui.ItemDescriptorFactory
3032
import com.github.jing332.tts_server_android.compose.theme.AppTheme
3133

3234
@Preview
@@ -42,7 +44,8 @@ private fun PreviewTtsConfigSelectDialog() {
4244
@OptIn(ExperimentalMaterial3Api::class)
4345
@Composable
4446
internal fun SysttsSelectBottomSheet(onDismissRequest: () -> Unit, onClick: (SystemTtsV2) -> Unit) {
45-
val items = remember { dbm.systemTtsV2.allEnabled }
47+
val items = remember { dbm.systemTtsV2.allEnabled.filter { it.config is TtsConfigurationDTO } }
48+
val context = LocalContext.current
4649
ModalBottomSheet(onDismissRequest = onDismissRequest) {
4750
Column(
4851
Modifier
@@ -54,25 +57,29 @@ internal fun SysttsSelectBottomSheet(onDismissRequest: () -> Unit, onClick: (Sys
5457
text = stringResource(id = R.string.choice_item, ""),
5558
style = MaterialTheme.typography.titleLarge
5659
)
57-
Spacer(modifier = Modifier.height(8.dp))
58-
LazyColumn(Modifier.weight(1f)) {
60+
LazyColumn(Modifier
61+
.weight(1f)
62+
.padding(8.dp)) {
5963
itemsIndexed(items) { _, systts ->
64+
val descriptor =
65+
remember(systts) { ItemDescriptorFactory.from(context, systts) }
6066
Column(
6167
Modifier
6268
.fillMaxWidth()
6369
.clip(MaterialTheme.shapes.small)
6470
.clickableRipple {
6571
onClick(systts)
6672
}
73+
.padding(4.dp)
6774
) {
6875
Text(
69-
text = systts.displayName ?: "",
76+
text = systts.displayName,
7077
style = MaterialTheme.typography.titleMedium
7178
)
72-
// HtmlText(
73-
// text = systts.tts.getDescription(),
74-
// style = MaterialTheme.typography.bodySmall
75-
// )
79+
HtmlText(
80+
text = descriptor.desc,
81+
style = MaterialTheme.typography.bodySmall
82+
)
7683
}
7784
}
7885
}

0 commit comments

Comments
 (0)