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"
|
||||
minSdk = 24
|
||||
targetSdk = 36
|
||||
versionCode = 998
|
||||
versionName = "3.0.0"
|
||||
versionCode = 999
|
||||
versionName = "3.0.1"
|
||||
|
||||
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.ui.VerveDoDefaults
|
||||
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.VerveDoDestinations
|
||||
import cn.super12138.todo.ui.theme.VerveDoTheme
|
||||
import cn.super12138.todo.ui.viewmodels.MainViewModel
|
||||
import cn.super12138.todo.utils.VibrationUtils
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package cn.super12138.todo.ui.components
|
||||
|
||||
import androidx.annotation.FloatRange
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
|
|
@ -10,7 +9,7 @@ import androidx.compose.runtime.setValue
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
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.OnParticleSystemUpdateListener
|
||||
import nl.dionsegijn.konfetti.core.Angle
|
||||
|
|
@ -98,8 +97,3 @@ private fun particles(primary: Int) = listOf(
|
|||
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 pressed by interactionSource.collectIsPressedAsState()
|
||||
val animatedShape = shapeByInteraction(shapes, pressed, VerveDoDefaults.shapesDefaultAnimationSpec)
|
||||
val animatedShape =
|
||||
shapeByInteraction(shapes, pressed, VerveDoDefaults.shapesDefaultAnimationSpec)
|
||||
|
||||
val cardColors = CardDefaults.cardColors(containerColor = containerColor)
|
||||
Card(
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ import cn.super12138.todo.ui.VerveDoDefaults
|
|||
import cn.super12138.todo.ui.theme.shapeByInteraction
|
||||
import cn.super12138.todo.utils.VibrationUtils
|
||||
|
||||
//TODO: MaterialTheme.colorscheme.surfaceContainer.blend(Color.Red, 0.7) 作为新的leading图标后背景色
|
||||
|
||||
// Leading icon as drawable resource
|
||||
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
||||
@Composable
|
||||
|
|
@ -213,7 +215,8 @@ fun SettingsItem(
|
|||
val view = LocalView.current
|
||||
val userInteractionSource = interactionSource ?: remember { MutableInteractionSource() }
|
||||
val pressed by userInteractionSource.collectIsPressedAsState()
|
||||
val animatedShape = shapeByInteraction(shapes, pressed, VerveDoDefaults.shapesDefaultAnimationSpec)
|
||||
val animatedShape =
|
||||
shapeByInteraction(shapes, pressed, VerveDoDefaults.shapesDefaultAnimationSpec)
|
||||
|
||||
Row(
|
||||
modifier = modifier
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ fun DarkModeItem(
|
|||
|
||||
val interactionSource = remember { MutableInteractionSource() }
|
||||
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)
|
||||
Column(
|
||||
|
|
|
|||
|
|
@ -55,7 +55,8 @@ fun PaletteItem(
|
|||
val view = LocalView.current
|
||||
val interactionSource = remember { MutableInteractionSource() }
|
||||
val pressed by interactionSource.collectIsPressedAsState()
|
||||
val animatedShape = shapeByInteraction(shapes, pressed, VerveDoDefaults.shapesDefaultAnimationSpec)
|
||||
val animatedShape =
|
||||
shapeByInteraction(shapes, pressed, VerveDoDefaults.shapesDefaultAnimationSpec)
|
||||
|
||||
Column(
|
||||
modifier = modifier
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ import cn.super12138.todo.logic.Repository
|
|||
import cn.super12138.todo.logic.database.TodoEntity
|
||||
import cn.super12138.todo.logic.datastore.DataStoreManager
|
||||
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.VerveDoScreen
|
||||
import cn.super12138.todo.utils.FileUtils
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
|
|
@ -55,41 +55,34 @@ class MainViewModel : ViewModel() {
|
|||
|
||||
SortingMethod.Category -> list.sortedWith(
|
||||
comparator = compareBy<TodoEntity> { it.isCompleted }
|
||||
.thenByDescending { it.priority }
|
||||
.thenBy { it.category }
|
||||
)
|
||||
|
||||
SortingMethod.Priority -> list.sortedWith(
|
||||
comparator = compareBy<TodoEntity> { it.isCompleted }
|
||||
.thenByDescending { it.priority }
|
||||
.thenBy { it.category }
|
||||
) // 优先级高的在前
|
||||
|
||||
SortingMethod.Completion -> list.sortedWith(
|
||||
comparator = compareBy<TodoEntity> { it.isCompleted }
|
||||
.thenBy { it.category }
|
||||
.thenBy { it.content }
|
||||
.thenByDescending { it.priority }
|
||||
) // 未完成的在前
|
||||
SortingMethod.AlphabeticalAscending -> list.sortedWith(
|
||||
comparator = compareBy<TodoEntity> { it.isCompleted }
|
||||
.thenBy { it.category }
|
||||
.thenBy { it.content }
|
||||
.thenByDescending { it.priority }
|
||||
)
|
||||
|
||||
SortingMethod.AlphabeticalDescending -> list.sortedWith(
|
||||
comparator = compareBy<TodoEntity> { it.isCompleted }
|
||||
.thenByDescending { it.category }
|
||||
.thenByDescending { it.content }
|
||||
.thenByDescending { it.priority }
|
||||
)
|
||||
|
||||
SortingMethod.DueDate -> list.sortedWith(
|
||||
comparator = compareBy<TodoEntity> { it.isCompleted }
|
||||
.thenBy { it.category }
|
||||
.thenBy { it.dueDate }
|
||||
.thenByDescending { it.priority }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package cn.super12138.todo.utils
|
||||
|
||||
import android.content.Context
|
||||
import androidx.annotation.FloatRange
|
||||
import androidx.compose.foundation.shape.CornerBasedShape
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
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.drawscope.ContentDrawScope
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import cn.super12138.todo.R
|
||||
import cn.super12138.todo.logic.model.Priority
|
||||
import java.text.SimpleDateFormat
|
||||
|
|
@ -20,6 +22,11 @@ import java.util.Locale
|
|||
import kotlin.time.Duration.Companion.days
|
||||
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
|
||||
@Stable
|
||||
fun Priority.containerColor(): Color =
|
||||
Loading…
Reference in a new issue