feat(editor): 支持自己标记待办完成情况
This commit is contained in:
parent
3380f8034b
commit
4250f7da43
3 changed files with 37 additions and 2 deletions
|
|
@ -29,6 +29,7 @@ import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.PlainTooltip
|
import androidx.compose.material3.PlainTooltip
|
||||||
import androidx.compose.material3.Slider
|
import androidx.compose.material3.Slider
|
||||||
import androidx.compose.material3.SliderDefaults
|
import androidx.compose.material3.SliderDefaults
|
||||||
|
import androidx.compose.material3.Switch
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TextField
|
import androidx.compose.material3.TextField
|
||||||
import androidx.compose.material3.TopAppBarDefaults
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
|
|
@ -40,6 +41,7 @@ import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalView
|
import androidx.compose.ui.platform.LocalView
|
||||||
|
|
@ -81,12 +83,14 @@ fun TodoEditorPage(
|
||||||
var isError by rememberSaveable { mutableStateOf(false) }
|
var isError by rememberSaveable { mutableStateOf(false) }
|
||||||
var selectedSubjectIndex by rememberSaveable { mutableIntStateOf(toDo?.subject ?: 0) }
|
var selectedSubjectIndex by rememberSaveable { mutableIntStateOf(toDo?.subject ?: 0) }
|
||||||
var priorityState by rememberSaveable { mutableFloatStateOf(toDo?.priority ?: 0f) }
|
var priorityState by rememberSaveable { mutableFloatStateOf(toDo?.priority ?: 0f) }
|
||||||
|
var completedSwitchState by rememberSaveable { mutableStateOf(toDo?.isCompleted ?: false) }
|
||||||
|
|
||||||
fun checkModifiedBeforeBack() {
|
fun checkModifiedBeforeBack() {
|
||||||
var isModified = false
|
var isModified = false
|
||||||
if ((toDo?.content ?: "") != toDoContent) isModified = true
|
if ((toDo?.content ?: "") != toDoContent) isModified = true
|
||||||
if ((toDo?.subject ?: 0) != selectedSubjectIndex) isModified = true
|
if ((toDo?.subject ?: 0) != selectedSubjectIndex) isModified = true
|
||||||
if ((toDo?.priority ?: 0f) != priorityState) isModified = true
|
if ((toDo?.priority ?: 0f) != priorityState) isModified = true
|
||||||
|
if ((toDo?.isCompleted == true) != completedSwitchState) isModified = true
|
||||||
if (isModified) {
|
if (isModified) {
|
||||||
showExitConfirmDialog = true
|
showExitConfirmDialog = true
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -128,7 +132,7 @@ fun TodoEditorPage(
|
||||||
TodoEntity(
|
TodoEntity(
|
||||||
content = toDoContent,
|
content = toDoContent,
|
||||||
subject = selectedSubjectIndex,
|
subject = selectedSubjectIndex,
|
||||||
isCompleted = toDo?.isCompleted ?: false,
|
isCompleted = completedSwitchState,
|
||||||
priority = priorityState,
|
priority = priorityState,
|
||||||
id = toDo?.id ?: 0
|
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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,4 +106,5 @@
|
||||||
<string name="tip_restore_failed">恢复失败</string>
|
<string name="tip_restore_failed">恢复失败</string>
|
||||||
<string name="pref_secure_mode">安全模式</string>
|
<string name="pref_secure_mode">安全模式</string>
|
||||||
<string name="pref_secure_mode_desc">阻止截屏并保护后台预览图</string>
|
<string name="pref_secure_mode_desc">阻止截屏并保护后台预览图</string>
|
||||||
|
<string name="label_more">更多</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -107,4 +107,5 @@
|
||||||
<string name="tip_restore_failed">Restore failed</string>
|
<string name="tip_restore_failed">Restore failed</string>
|
||||||
<string name="pref_secure_mode">Secure Mode</string>
|
<string name="pref_secure_mode">Secure Mode</string>
|
||||||
<string name="pref_secure_mode_desc">Prevent screenshots and protect the background preview image</string>
|
<string name="pref_secure_mode_desc">Prevent screenshots and protect the background preview image</string>
|
||||||
|
<string name="label_more">More</string>
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in a new issue