fix: 待办排序方式不准确
This commit is contained in:
parent
48a70d12c6
commit
91652aedb9
9 changed files with 22 additions and 22 deletions
|
|
@ -38,8 +38,8 @@ android {
|
||||||
applicationId = "cn.super12138.todo"
|
applicationId = "cn.super12138.todo"
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 998
|
versionCode = 999
|
||||||
versionName = "3.0.0"
|
versionName = "3.0.1"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ import cn.super12138.todo.logic.model.DarkMode
|
||||||
import cn.super12138.todo.logic.model.PaletteStyle
|
import cn.super12138.todo.logic.model.PaletteStyle
|
||||||
import cn.super12138.todo.ui.VerveDoDefaults
|
import cn.super12138.todo.ui.VerveDoDefaults
|
||||||
import cn.super12138.todo.ui.components.Konfetti
|
import cn.super12138.todo.ui.components.Konfetti
|
||||||
import cn.super12138.todo.ui.navigation.VerveDoDestinations
|
|
||||||
import cn.super12138.todo.ui.navigation.TopNavigation
|
import cn.super12138.todo.ui.navigation.TopNavigation
|
||||||
|
import cn.super12138.todo.ui.navigation.VerveDoDestinations
|
||||||
import cn.super12138.todo.ui.theme.VerveDoTheme
|
import cn.super12138.todo.ui.theme.VerveDoTheme
|
||||||
import cn.super12138.todo.ui.viewmodels.MainViewModel
|
import cn.super12138.todo.ui.viewmodels.MainViewModel
|
||||||
import cn.super12138.todo.utils.VibrationUtils
|
import cn.super12138.todo.utils.VibrationUtils
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package cn.super12138.todo.ui.components
|
package cn.super12138.todo.ui.components
|
||||||
|
|
||||||
import androidx.annotation.FloatRange
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
|
|
@ -10,7 +9,7 @@ import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.toArgb
|
import androidx.compose.ui.graphics.toArgb
|
||||||
import androidx.core.graphics.ColorUtils
|
import cn.super12138.todo.utils.blend
|
||||||
import nl.dionsegijn.konfetti.compose.KonfettiView
|
import nl.dionsegijn.konfetti.compose.KonfettiView
|
||||||
import nl.dionsegijn.konfetti.compose.OnParticleSystemUpdateListener
|
import nl.dionsegijn.konfetti.compose.OnParticleSystemUpdateListener
|
||||||
import nl.dionsegijn.konfetti.core.Angle
|
import nl.dionsegijn.konfetti.core.Angle
|
||||||
|
|
@ -98,8 +97,3 @@ private fun particles(primary: Int) = listOf(
|
||||||
position = Position.Relative(1.0, 1.0)
|
position = Position.Relative(1.0, 1.0)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
fun Int.blend(
|
|
||||||
color: Int,
|
|
||||||
@FloatRange(from = 0.0, to = 1.0) fraction: Float = 0.5f,
|
|
||||||
): Int = ColorUtils.blendARGB(this, color, fraction)
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,8 @@ fun RoundedCornerCardLarge(
|
||||||
) {
|
) {
|
||||||
val interactionSource = remember { MutableInteractionSource() }
|
val interactionSource = remember { MutableInteractionSource() }
|
||||||
val pressed by interactionSource.collectIsPressedAsState()
|
val pressed by interactionSource.collectIsPressedAsState()
|
||||||
val animatedShape = shapeByInteraction(shapes, pressed, VerveDoDefaults.shapesDefaultAnimationSpec)
|
val animatedShape =
|
||||||
|
shapeByInteraction(shapes, pressed, VerveDoDefaults.shapesDefaultAnimationSpec)
|
||||||
|
|
||||||
val cardColors = CardDefaults.cardColors(containerColor = containerColor)
|
val cardColors = CardDefaults.cardColors(containerColor = containerColor)
|
||||||
Card(
|
Card(
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ import cn.super12138.todo.ui.VerveDoDefaults
|
||||||
import cn.super12138.todo.ui.theme.shapeByInteraction
|
import cn.super12138.todo.ui.theme.shapeByInteraction
|
||||||
import cn.super12138.todo.utils.VibrationUtils
|
import cn.super12138.todo.utils.VibrationUtils
|
||||||
|
|
||||||
|
//TODO: MaterialTheme.colorscheme.surfaceContainer.blend(Color.Red, 0.7) 作为新的leading图标后背景色
|
||||||
|
|
||||||
// Leading icon as drawable resource
|
// Leading icon as drawable resource
|
||||||
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -213,7 +215,8 @@ fun SettingsItem(
|
||||||
val view = LocalView.current
|
val view = LocalView.current
|
||||||
val userInteractionSource = interactionSource ?: remember { MutableInteractionSource() }
|
val userInteractionSource = interactionSource ?: remember { MutableInteractionSource() }
|
||||||
val pressed by userInteractionSource.collectIsPressedAsState()
|
val pressed by userInteractionSource.collectIsPressedAsState()
|
||||||
val animatedShape = shapeByInteraction(shapes, pressed, VerveDoDefaults.shapesDefaultAnimationSpec)
|
val animatedShape =
|
||||||
|
shapeByInteraction(shapes, pressed, VerveDoDefaults.shapesDefaultAnimationSpec)
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,8 @@ fun DarkModeItem(
|
||||||
|
|
||||||
val interactionSource = remember { MutableInteractionSource() }
|
val interactionSource = remember { MutableInteractionSource() }
|
||||||
val pressed by interactionSource.collectIsPressedAsState()
|
val pressed by interactionSource.collectIsPressedAsState()
|
||||||
val animatedShape = shapeByInteraction(shapes, pressed, VerveDoDefaults.shapesDefaultAnimationSpec)
|
val animatedShape =
|
||||||
|
shapeByInteraction(shapes, pressed, VerveDoDefaults.shapesDefaultAnimationSpec)
|
||||||
|
|
||||||
val borderWidth by animateDpAsState(if (selected) 3.dp else (-1).dp)
|
val borderWidth by animateDpAsState(if (selected) 3.dp else (-1).dp)
|
||||||
Column(
|
Column(
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,8 @@ fun PaletteItem(
|
||||||
val view = LocalView.current
|
val view = LocalView.current
|
||||||
val interactionSource = remember { MutableInteractionSource() }
|
val interactionSource = remember { MutableInteractionSource() }
|
||||||
val pressed by interactionSource.collectIsPressedAsState()
|
val pressed by interactionSource.collectIsPressedAsState()
|
||||||
val animatedShape = shapeByInteraction(shapes, pressed, VerveDoDefaults.shapesDefaultAnimationSpec)
|
val animatedShape =
|
||||||
|
shapeByInteraction(shapes, pressed, VerveDoDefaults.shapesDefaultAnimationSpec)
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ import cn.super12138.todo.logic.Repository
|
||||||
import cn.super12138.todo.logic.database.TodoEntity
|
import cn.super12138.todo.logic.database.TodoEntity
|
||||||
import cn.super12138.todo.logic.datastore.DataStoreManager
|
import cn.super12138.todo.logic.datastore.DataStoreManager
|
||||||
import cn.super12138.todo.logic.model.SortingMethod
|
import cn.super12138.todo.logic.model.SortingMethod
|
||||||
import cn.super12138.todo.ui.navigation.VerveDoScreen
|
|
||||||
import cn.super12138.todo.ui.navigation.TopLevelBackStack
|
import cn.super12138.todo.ui.navigation.TopLevelBackStack
|
||||||
|
import cn.super12138.todo.ui.navigation.VerveDoScreen
|
||||||
import cn.super12138.todo.utils.FileUtils
|
import cn.super12138.todo.utils.FileUtils
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
|
|
@ -55,41 +55,34 @@ class MainViewModel : ViewModel() {
|
||||||
|
|
||||||
SortingMethod.Category -> list.sortedWith(
|
SortingMethod.Category -> list.sortedWith(
|
||||||
comparator = compareBy<TodoEntity> { it.isCompleted }
|
comparator = compareBy<TodoEntity> { it.isCompleted }
|
||||||
.thenByDescending { it.priority }
|
|
||||||
.thenBy { it.category }
|
.thenBy { it.category }
|
||||||
)
|
)
|
||||||
|
|
||||||
SortingMethod.Priority -> list.sortedWith(
|
SortingMethod.Priority -> list.sortedWith(
|
||||||
comparator = compareBy<TodoEntity> { it.isCompleted }
|
comparator = compareBy<TodoEntity> { it.isCompleted }
|
||||||
.thenByDescending { it.priority }
|
.thenByDescending { it.priority }
|
||||||
.thenBy { it.category }
|
|
||||||
) // 优先级高的在前
|
) // 优先级高的在前
|
||||||
|
|
||||||
SortingMethod.Completion -> list.sortedWith(
|
SortingMethod.Completion -> list.sortedWith(
|
||||||
comparator = compareBy<TodoEntity> { it.isCompleted }
|
comparator = compareBy<TodoEntity> { it.isCompleted }
|
||||||
.thenBy { it.category }
|
.thenBy { it.category }
|
||||||
.thenBy { it.content }
|
|
||||||
.thenByDescending { it.priority }
|
.thenByDescending { it.priority }
|
||||||
) // 未完成的在前
|
) // 未完成的在前
|
||||||
SortingMethod.AlphabeticalAscending -> list.sortedWith(
|
SortingMethod.AlphabeticalAscending -> list.sortedWith(
|
||||||
comparator = compareBy<TodoEntity> { it.isCompleted }
|
comparator = compareBy<TodoEntity> { it.isCompleted }
|
||||||
.thenBy { it.category }
|
|
||||||
.thenBy { it.content }
|
.thenBy { it.content }
|
||||||
.thenByDescending { it.priority }
|
.thenByDescending { it.priority }
|
||||||
)
|
)
|
||||||
|
|
||||||
SortingMethod.AlphabeticalDescending -> list.sortedWith(
|
SortingMethod.AlphabeticalDescending -> list.sortedWith(
|
||||||
comparator = compareBy<TodoEntity> { it.isCompleted }
|
comparator = compareBy<TodoEntity> { it.isCompleted }
|
||||||
.thenByDescending { it.category }
|
|
||||||
.thenByDescending { it.content }
|
.thenByDescending { it.content }
|
||||||
.thenByDescending { it.priority }
|
.thenByDescending { it.priority }
|
||||||
)
|
)
|
||||||
|
|
||||||
SortingMethod.DueDate -> list.sortedWith(
|
SortingMethod.DueDate -> list.sortedWith(
|
||||||
comparator = compareBy<TodoEntity> { it.isCompleted }
|
comparator = compareBy<TodoEntity> { it.isCompleted }
|
||||||
.thenBy { it.category }
|
|
||||||
.thenBy { it.dueDate }
|
.thenBy { it.dueDate }
|
||||||
.thenByDescending { it.priority }
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.super12138.todo.utils
|
package cn.super12138.todo.utils
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import androidx.annotation.FloatRange
|
||||||
import androidx.compose.foundation.shape.CornerBasedShape
|
import androidx.compose.foundation.shape.CornerBasedShape
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
|
@ -12,6 +13,7 @@ import androidx.compose.ui.graphics.Brush
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.drawscope.ContentDrawScope
|
import androidx.compose.ui.graphics.drawscope.ContentDrawScope
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
|
import androidx.core.graphics.ColorUtils
|
||||||
import cn.super12138.todo.R
|
import cn.super12138.todo.R
|
||||||
import cn.super12138.todo.logic.model.Priority
|
import cn.super12138.todo.logic.model.Priority
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
|
@ -20,6 +22,11 @@ import java.util.Locale
|
||||||
import kotlin.time.Duration.Companion.days
|
import kotlin.time.Duration.Companion.days
|
||||||
import kotlin.time.Duration.Companion.milliseconds
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
|
||||||
|
fun Int.blend(
|
||||||
|
color: Int,
|
||||||
|
@FloatRange(from = 0.0, to = 1.0) fraction: Float = 0.5f,
|
||||||
|
): Int = ColorUtils.blendARGB(this, color, fraction)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Stable
|
@Stable
|
||||||
fun Priority.containerColor(): Color =
|
fun Priority.containerColor(): Color =
|
||||||
Loading…
Reference in a new issue