feat(settings): 支持按学科排序
This commit is contained in:
parent
a0f385e91e
commit
2fbccaf081
4 changed files with 10 additions and 5 deletions
|
|
@ -5,14 +5,16 @@ import cn.super12138.todo.R
|
|||
|
||||
enum class SortingMethod(val id: Int) {
|
||||
Date(1),
|
||||
Priority(2),
|
||||
Completion(3),
|
||||
AlphabeticalAscending(4),
|
||||
AlphabeticalDescending(5);
|
||||
Subject(2),
|
||||
Priority(3),
|
||||
Completion(4),
|
||||
AlphabeticalAscending(5),
|
||||
AlphabeticalDescending(6);
|
||||
|
||||
fun getDisplayName(context: Context): String {
|
||||
val resId = when (this) {
|
||||
Date -> R.string.sorting_date
|
||||
Subject -> R.string.sorting_subject
|
||||
Priority -> R.string.sorting_priority
|
||||
Completion -> R.string.sorting_completion
|
||||
AlphabeticalAscending -> R.string.sorting_alphabetical_ascending
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class MainViewModel : ViewModel() {
|
|||
val sortedTodos: Flow<List<TodoEntity>> = toDos.map { list ->
|
||||
when (appSortingMethod) {
|
||||
SortingMethod.Date -> list.sortedBy { it.id }
|
||||
SortingMethod.Subject -> list.sortedBy { it.subject }
|
||||
SortingMethod.Priority -> list.sortedByDescending { it.priority } // 优先级高的在前
|
||||
SortingMethod.Completion -> list.sortedBy { it.isCompleted } // 未完成的在前
|
||||
SortingMethod.AlphabeticalAscending -> list.sortedBy { it.content }
|
||||
|
|
@ -37,7 +38,7 @@ class MainViewModel : ViewModel() {
|
|||
private set
|
||||
var showCompletedTodos by mutableStateOf(GlobalValues.showCompleted)
|
||||
|
||||
// 深色模式
|
||||
// 主题颜色
|
||||
var appDarkMode by mutableStateOf(DarkMode.fromId(GlobalValues.darkMode))
|
||||
private set
|
||||
var appContrastLevel by mutableStateOf(ContrastLevel.fromFloat(GlobalValues.contrastLevel))
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@
|
|||
<string name="pref_view_on_github_desc">查看源代码、提交错误报告和改进建议</string>
|
||||
<string name="tip_discard_changes">退出编辑后将无法找回你修改过的数据。确定退出编辑吗?</string>
|
||||
<string name="sorting_date">日期</string>
|
||||
<string name="sorting_subject">学科</string>
|
||||
<string name="sorting_priority">优先级</string>
|
||||
<string name="sorting_completion">完成状态</string>
|
||||
<string name="sorting_alphabetical_ascending">首字母(升序)</string>
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@
|
|||
<string name="pref_view_on_github_desc">View source code, submit bug reports, and improvement suggestions</string>
|
||||
<string name="tip_discard_changes">After exiting edit mode, you will not be able to retrieve the data you have modified. Are you sure you want to exit editing?</string>
|
||||
<string name="sorting_date">Date</string>
|
||||
<string name="sorting_subject">Subject</string>
|
||||
<string name="sorting_priority">Priority</string>
|
||||
<string name="sorting_completion">Completion</string>
|
||||
<string name="sorting_alphabetical_ascending">Alphabetical (Ascending)</string>
|
||||
|
|
|
|||
Loading…
Reference in a new issue