From 2a4ffa879b19feca7b5de431d259ce052215a17e Mon Sep 17 00:00:00 2001 From: Corner Date: Sun, 30 Jun 2024 09:52:37 +0800 Subject: [PATCH] =?UTF-8?q?chore=EF=BC=9A=20code=20clean?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/corner/ui/Settings.kt | 84 +------------------ 1 file changed, 1 insertion(+), 83 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/com/corner/ui/Settings.kt b/composeApp/src/commonMain/kotlin/com/corner/ui/Settings.kt index 89f14ef..bf7cc42 100644 --- a/composeApp/src/commonMain/kotlin/com/corner/ui/Settings.kt +++ b/composeApp/src/commonMain/kotlin/com/corner/ui/Settings.kt @@ -60,35 +60,9 @@ import org.jsoup.internal.StringUtil import java.awt.Desktop import java.net.URI -@Composable -fun SettingItem(modifier: Modifier, setting: Setting, onClick: (Setting) -> Unit) { - Row( - modifier - .clickable { - onClick(setting) - }.shadow(3.dp) - .background(MaterialTheme.colorScheme.background, shape = RoundedCornerShape(4.dp)) - .padding(start = 20.dp, end = 20.dp) - ) { - Text( - setting.label, - modifier = Modifier.padding(vertical = 8.dp, horizontal = 15.dp), - color = MaterialTheme.colorScheme.onBackground - ) - Text( - 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 - ) - } -} - -@OptIn(ExperimentalComposeUiApi::class) @Composable fun SettingScene(component: DefaultSettingComponent, onClickBack: () -> Unit) { val model = component.model.subscribeAsState() -// var showEditDialog by remember { mutableStateOf(false) } var showAboutDialog by remember { mutableStateOf(false) } DisposableEffect("setting") { component.sync() @@ -271,15 +245,12 @@ fun SettingScene(component: DefaultSettingComponent, onClickBack: () -> Unit) { } } AboutDialog(Modifier.fillMaxSize(0.4f), showAboutDialog) { showAboutDialog = false } -// DialogEdit(showEditDialog, onClose = { showEditDialog = false }, currentChoose = currentChoose) { -// component.sync() -// } } } fun SettingStore.getPlayerSetting(): List { - val settingItem = SettingStore.getSettingItem(SettingType.PLAYER.id) + val settingItem = getSettingItem(SettingType.PLAYER.id) val split = settingItem.split("#") return if (split.size == 1) listOf(false, settingItem) else listOf(split[0].toBoolean(), split[1]) } @@ -432,59 +403,6 @@ fun setConfig(textFieldValue: String?) { } } -@Composable -fun DialogEdit( - showEditDialog: Boolean, - onClose: () -> Unit, - currentChoose: Setting?, - onValueChange: (v: String) -> Unit -) { - var textFieldValue by remember { mutableStateOf(currentChoose?.value) } - val focusRequester = remember { FocusRequester() } - if (showEditDialog) { - LaunchedEffect(Unit) { - textFieldValue = currentChoose?.value - focusRequester.requestFocus() - } - } - Dialog( - modifier = Modifier.fillMaxWidth(0.5f), - showEditDialog, - onClose = { - onClose() - } - ) { - Column(modifier = Modifier.padding(horizontal = 15.dp, vertical = 25.dp)) { - Row(modifier = Modifier.fillMaxWidth()) { - Text(currentChoose?.label ?: ""/*, color = MaterialTheme.colors.onBackground*/) - Spacer(modifier = Modifier.size(35.dp)) - TextField( - modifier = Modifier.fillMaxWidth(0.8f).focusRequester(focusRequester), - enabled = true, - value = textFieldValue ?: "", - onValueChange = { text -> textFieldValue = text }, - interactionSource = MutableInteractionSource(), - maxLines = 2 - ) - } - Button(modifier = Modifier.align(Alignment.End), onClick = { - SiteViewModel.viewModelScope.launch { - when (currentChoose!!.id) { - "vod" -> { - setConfig(textFieldValue) - } - } - }.invokeOnCompletion { - onValueChange(textFieldValue ?: "") - onClose() - } - }) { - Text("确认") - } - } - } -} - @Composable fun AboutDialog(modifier: Modifier, showAboutDialog: Boolean, onClose: () -> Unit) { var visible by remember { mutableStateOf(false) }