Skip to content

Commit

Permalink
fix: 列表为空提示
Browse files Browse the repository at this point in the history
  • Loading branch information
jing332 committed Jan 29, 2024
1 parent 6ca8d20 commit e27f6f7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.HelpOutline
import androidx.compose.material.icons.automirrored.filled.HelpOutline
import androidx.compose.material.icons.filled.SmartDisplay
import androidx.compose.material.icons.filled.Speed
import androidx.compose.material3.Checkbox
Expand Down Expand Up @@ -211,7 +211,7 @@ fun BasicInfoEditScreen(
Text(stringResource(id = R.string.as_standby))
IconButton(onClick = { showStandbyHelpDialog = true }) {
Icon(
Icons.Default.HelpOutline,
Icons.AutoMirrored.Filled.HelpOutline,
stringResource(id = R.string.systts_as_standby_help)
)
}
Expand Down Expand Up @@ -334,6 +334,7 @@ fun BasicInfoEditScreen(
values = speechRules.map { it.ruleId },
entries = speechRules.map { it.name },
onSelectedChange = { k, v ->
if (systts.speechRule.target != SpeechTarget.CUSTOM_TAG) return@AppSpinner
onSysttsChange(
systts.copy(
speechRule = systts.speechRule.copy(
Expand All @@ -354,6 +355,7 @@ fun BasicInfoEditScreen(
values = speechRule.tags.keys.toList(),
entries = speechRule.tags.values.toList(),
onSelectedChange = { k, _ ->
if (systts.speechRule.target != SpeechTarget.CUSTOM_TAG) return@AppSpinner
onSysttsChange(
systts.copy(
speechRule = systts.speechRule.copy(tag = k as String)
Expand All @@ -368,7 +370,10 @@ fun BasicInfoEditScreen(
speechRule?.let {
CustomTagScreen(
systts = systts,
onSysttsChange = onSysttsChange,
onSysttsChange = {
if (systts.speechRule.target == SpeechTarget.CUSTOM_TAG)
onSysttsChange(it)
},
speechRule = it
)
}
Expand Down Expand Up @@ -430,7 +435,10 @@ private fun CustomTagScreen(
leadingIcon = {
if (hint.isNotEmpty())
IconButton(onClick = { showHelpDialog = label to hint }) {
Icon(Icons.Default.HelpOutline, stringResource(id = R.string.help))
Icon(
Icons.AutoMirrored.Filled.HelpOutline,
stringResource(id = R.string.help)
)
}
},
label = { Text(label) },
Expand Down Expand Up @@ -464,7 +472,10 @@ private fun CustomTagScreen(
leadingIcon = {
if (hint.isNotEmpty())
IconButton(onClick = { showHelpDialog = label to hint }) {
Icon(Icons.Default.HelpOutline, stringResource(id = R.string.help))
Icon(
Icons.AutoMirrored.Filled.HelpOutline,
stringResource(id = R.string.help)
)
}
},
onSelectedChange = { k, _ ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import com.github.jing332.tts_server_android.utils.performLongPress
import com.github.jing332.tts_server_android.utils.toast
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlin.math.max

@Composable
fun AppSelectionDialog(
Expand Down Expand Up @@ -108,10 +107,8 @@ fun AppSelectionDialog(
}
}

val listState = rememberLazyListState()

val isEmpty by remember {
derivedStateOf { listState.layoutInfo.viewportSize == IntSize.Zero }
derivedStateOf { state.layoutInfo.viewportSize == IntSize.Zero }
}

if (searchText.isNotBlank() && isEmpty)
Expand All @@ -132,11 +129,11 @@ fun AppSelectionDialog(
isLoading = isLoading
) {
LazyColumn(state = state) {
itemsIndexed(entries) { i, entry ->
if (searchEnabled && searchText.isNotBlank() &&
!entry.contains(searchText, ignoreCase = true)
) return@itemsIndexed

val items = entries.filterNot {
searchEnabled && searchText.isNotBlank() &&
!it.contains(searchText, ignoreCase = true)
}
itemsIndexed(items) { i, entry ->
val current = values[i]
val isSelected = onValueSame(value, current)
Row(
Expand Down

0 comments on commit e27f6f7

Please sign in to comment.