From 2f390f32a46f2ce39206187e302a69f1716a9822 Mon Sep 17 00:00:00 2001 From: tornaco Date: Fri, 6 May 2022 21:00:40 +0800 Subject: [PATCH] [app] add DateTimeEngineScreen --- .../common/widget/SingleChoiceDialog.kt | 1 + .../profile/engine/DateTimeEngineScreen.kt | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/android/modules/module_compose_common/src/main/java/github/tornaco/android/thanos/module/compose/common/widget/SingleChoiceDialog.kt b/android/modules/module_compose_common/src/main/java/github/tornaco/android/thanos/module/compose/common/widget/SingleChoiceDialog.kt index be5a8295d..dcb3aa6cf 100644 --- a/android/modules/module_compose_common/src/main/java/github/tornaco/android/thanos/module/compose/common/widget/SingleChoiceDialog.kt +++ b/android/modules/module_compose_common/src/main/java/github/tornaco/android/thanos/module/compose/common/widget/SingleChoiceDialog.kt @@ -82,6 +82,7 @@ fun SingleChoiceDialog(state: SingleChoiceDialogState) { .fillMaxWidth() .clip(RoundedCornerShape(8.dp)) .clickableWithRipple { + state.dismiss() state.onItemClick(it.id) } .padding(16.dp), diff --git a/android/modules/module_profile/src/main/java/github/tornaco/thanos/android/module/profile/engine/DateTimeEngineScreen.kt b/android/modules/module_profile/src/main/java/github/tornaco/thanos/android/module/profile/engine/DateTimeEngineScreen.kt index c2cb35155..738558a79 100644 --- a/android/modules/module_profile/src/main/java/github/tornaco/thanos/android/module/profile/engine/DateTimeEngineScreen.kt +++ b/android/modules/module_profile/src/main/java/github/tornaco/thanos/android/module/profile/engine/DateTimeEngineScreen.kt @@ -20,19 +20,18 @@ package github.tornaco.thanos.android.module.profile.engine import android.app.Activity import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add -import androidx.compose.material.icons.filled.LockClock import androidx.compose.material.icons.filled.Schedule import androidx.compose.material.icons.filled.Timer import androidx.compose.material3.Icon import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember +import androidx.compose.runtime.* import androidx.compose.ui.res.stringResource import github.tornaco.android.thanos.module.compose.common.theme.TypographyDefaults import github.tornaco.android.thanos.module.compose.common.widget.* import github.tornaco.thanos.android.module.profile.R private class UIState { + var showCreateRegularIntervalDialog by mutableStateOf(false) } @Composable @@ -42,10 +41,12 @@ fun Activity.DateTimeEngineScreen() { val dialogState = rememberDialogState(title = stringResource(id = R.string.module_profile_rule_new), items = listOf( - SingleChoiceItem(id = "", icon = Icons.Filled.Schedule, label = "Time of a day"), - SingleChoiceItem(id = "", icon = Icons.Filled.Timer, label = "Regular interval"), + SingleChoiceItem(id = "", icon = Icons.Filled.Schedule, label = "Time of a day (coming soon)"), + SingleChoiceItem(id = "", icon = Icons.Filled.Timer, label = "Regular interval (coming soon)"), ), - onItemClick = {}) + onItemClick = { + uiState.showCreateRegularIntervalDialog = true + }) ThanoxSmallAppBarScaffold(title = { Text( @@ -73,6 +74,15 @@ fun Activity.DateTimeEngineScreen() { } } + +@Composable +private fun CreateRegularIntervalDialog(uiState: UIState) { + if (uiState.showCreateRegularIntervalDialog) { + // TODO Impl. + } +} + + @Composable private fun rememberUIState(): UIState { return remember {