Skip to content

Commit

Permalink
feat: 修改设置页面
Browse files Browse the repository at this point in the history
  • Loading branch information
Greatwallcorner committed Jun 22, 2024
1 parent 3caa186 commit f142994
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
31 changes: 23 additions & 8 deletions composeApp/src/commonMain/kotlin/com/corner/ui/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import com.corner.catvodcore.util.Paths
import com.corner.database.Db
import com.corner.init.initConfig
import com.corner.ui.decompose.component.DefaultSettingComponent
import com.corner.ui.decompose.component.getSetting
import com.corner.ui.scene.BackRow
import com.corner.ui.scene.Dialog
import com.corner.ui.scene.HoverableText
Expand All @@ -51,22 +52,22 @@ import java.awt.Desktop
import java.net.URI

@Composable
fun SettingItem(modifier: Modifier, label: String, value: String?, onClick: () -> Unit) {
fun SettingItem(modifier: Modifier, setting: Setting, onClick: (Setting) -> Unit) {
Row(
modifier
.clickable {
onClick()
onClick(setting)
}.shadow(3.dp)
.background(MaterialTheme.colorScheme.background, shape = RoundedCornerShape(4.dp))
.padding(start = 20.dp, end = 20.dp)
) {
Text(
label,
setting.label,
modifier = Modifier.padding(vertical = 8.dp, horizontal = 15.dp),
color = MaterialTheme.colorScheme.onBackground
)
Text(
text = if (StringUtil.isBlank(value)) "" else value ?: "",
text = if (StringUtil.isBlank(setting.value)) "" else setting.value ?: "",
modifier = Modifier.padding(vertical = 8.dp, horizontal = 15.dp)
.weight(0.5f),
color = MaterialTheme.colorScheme.onBackground
Expand Down Expand Up @@ -113,10 +114,24 @@ fun SettingScene(component: DefaultSettingComponent, onClickBack: () -> Unit) {
// IconButton(modifier = Modifier.align(Alignment.End), onClick = {showAboutDialog = true}){ Icon(Icons.Default.Info, "About", tint = MaterialTheme.colorScheme.onSecondary) }
}
LazyColumn {
items(model.value.settingList) {
SettingItem(
Modifier, it.label, it.value
) {
// items(model.value.settingList) {
// SettingItem(
// Modifier, it.label, it.value
// ) {
// showEditDialog = true
// currentChoose = it
// }
// }
item {
val setting = model.value.settingList.getSetting(SettingType.VOD)
SettingItem(Modifier, setting!!){
showEditDialog = true
currentChoose = it
}
}
item {
val setting = model.value.settingList.getSetting(SettingType.LOG)
SettingItem(Modifier, setting!!){
showEditDialog = true
currentChoose = it
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package com.corner.ui.decompose.component
import com.arkivanov.decompose.ComponentContext
import com.arkivanov.decompose.value.MutableValue
import com.arkivanov.decompose.value.update
import com.corner.bean.Setting
import com.corner.bean.SettingStore
import com.corner.bean.SettingType
import com.corner.ui.decompose.SettingComponent

class DefaultSettingComponent(componentContext: ComponentContext):SettingComponent, ComponentContext by componentContext {
Expand All @@ -13,4 +15,8 @@ class DefaultSettingComponent(componentContext: ComponentContext):SettingCompone
override fun sync() {
_model.update { it.copy(settingList = SettingStore.getSettingList(), version = _model.value.version + 1) }
}
}

fun List<Setting>.getSetting(type:SettingType):Setting?{
return this.find { it.id == type.id }
}

0 comments on commit f142994

Please sign in to comment.