From 4250f7da43b6a1f024ed0f5623c8d314a5757719 Mon Sep 17 00:00:00 2001
From: Super12138 <70494801+Super12138@users.noreply.github.com>
Date: Tue, 11 Feb 2025 22:53:14 +0800
Subject: [PATCH] =?UTF-8?q?feat(editor):=20=E6=94=AF=E6=8C=81=E8=87=AA?=
=?UTF-8?q?=E5=B7=B1=E6=A0=87=E8=AE=B0=E5=BE=85=E5=8A=9E=E5=AE=8C=E6=88=90?=
=?UTF-8?q?=E6=83=85=E5=86=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../todo/ui/pages/editor/TodoEditorPage.kt | 37 ++++++++++++++++++-
app/src/main/res/values-zh-rCN/strings.xml | 1 +
app/src/main/res/values/strings.xml | 1 +
3 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/app/src/main/kotlin/cn/super12138/todo/ui/pages/editor/TodoEditorPage.kt b/app/src/main/kotlin/cn/super12138/todo/ui/pages/editor/TodoEditorPage.kt
index 6083b3c..b784ac9 100644
--- a/app/src/main/kotlin/cn/super12138/todo/ui/pages/editor/TodoEditorPage.kt
+++ b/app/src/main/kotlin/cn/super12138/todo/ui/pages/editor/TodoEditorPage.kt
@@ -29,6 +29,7 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.PlainTooltip
import androidx.compose.material3.Slider
import androidx.compose.material3.SliderDefaults
+import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.material3.TopAppBarDefaults
@@ -40,6 +41,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
@@ -81,12 +83,14 @@ fun TodoEditorPage(
var isError by rememberSaveable { mutableStateOf(false) }
var selectedSubjectIndex by rememberSaveable { mutableIntStateOf(toDo?.subject ?: 0) }
var priorityState by rememberSaveable { mutableFloatStateOf(toDo?.priority ?: 0f) }
+ var completedSwitchState by rememberSaveable { mutableStateOf(toDo?.isCompleted ?: false) }
fun checkModifiedBeforeBack() {
var isModified = false
if ((toDo?.content ?: "") != toDoContent) isModified = true
if ((toDo?.subject ?: 0) != selectedSubjectIndex) isModified = true
if ((toDo?.priority ?: 0f) != priorityState) isModified = true
+ if ((toDo?.isCompleted == true) != completedSwitchState) isModified = true
if (isModified) {
showExitConfirmDialog = true
} else {
@@ -128,7 +132,7 @@ fun TodoEditorPage(
TodoEntity(
content = toDoContent,
subject = selectedSubjectIndex,
- isCompleted = toDo?.isCompleted ?: false,
+ isCompleted = completedSwitchState,
priority = priorityState,
id = toDo?.id ?: 0
)
@@ -239,7 +243,36 @@ fun TodoEditorPage(
}
)
- Spacer(Modifier.size(40.dp))
+ Spacer(Modifier.size(10.dp))
+
+ if (toDo != null) {
+ Text(
+ text = stringResource(R.string.label_priority),
+ style = MaterialTheme.typography.titleMedium
+ )
+
+ Spacer(Modifier.size(5.dp))
+
+ Row(
+ verticalAlignment = Alignment.CenterVertically,
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Text(
+ text = stringResource(R.string.label_more),
+ style = MaterialTheme.typography.labelLarge,
+ modifier = Modifier.padding(end = 5.dp)
+ )
+ Switch(
+ checked = completedSwitchState,
+ onCheckedChange = {
+ completedSwitchState = it
+ VibrationUtils.performHapticFeedback(view)
+ }
+ )
+ }
+ }
+
+ Spacer(Modifier.size(20.dp))
}
}
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 22a5788..cfcaf6d 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -106,4 +106,5 @@
恢复失败
安全模式
阻止截屏并保护后台预览图
+ 更多
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f1da624..038d86d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -107,4 +107,5 @@
Restore failed
Secure Mode
Prevent screenshots and protect the background preview image
+ More
\ No newline at end of file