Skip to content

Commit

Permalink
chore: Bump dependencies
Browse files Browse the repository at this point in the history
fix: Disable task groups, they are causing recomposition issues that lead to empty lists sometimes
chore: Switch to short month names to better fit smaller screens
  • Loading branch information
0ffz committed Oct 25, 2024
1 parent 21d3735 commit 6d51dbb
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 91 deletions.
4 changes: 2 additions & 2 deletions app-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ dependencies {
implementation(libs.androidx.activity.compose)
// implementation(libs.androidx.glance.appwidget)
// implementation(libs.androidx.glance.material3)
implementation("androidx.glance:glance-appwidget:1.0.0")
implementation("androidx.glance:glance-material3:1.0.0")
// implementation("androidx.glance:glance-appwidget:1.1.1")
// implementation("androidx.glance:glance-material3:1.1.1")
implementation(libs.kotlin.multiplatform.appdirs)
implementation(libs.koin.android)
implementation(libs.androidx.startup.runtime)
Expand Down
5 changes: 0 additions & 5 deletions app-android/src/main/res/xml/widget_quickadd.xml

This file was deleted.

2 changes: 1 addition & 1 deletion app-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ kotlin {
implementation(libs.uuid)

implementation(libs.ktor.client.core)
implementation(libs.ktor.serialization.json.eap)
implementation(libs.ktor.serialization.json)
implementation(libs.ktor.client.content.negotiation)
implementation(libs.ktor.client.auth)
implementation(libs.multiplatform.settings)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.dvyy.tasks.tasks.ui.elements.list

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.draganddrop.dragAndDropTarget
import androidx.compose.foundation.layout.*
Expand Down Expand Up @@ -76,81 +75,77 @@ fun TaskList(
key = listId,
)
val tasks = tasks.loadedOrNull() ?: return@Column
// println("Loading ${listId.date} with ${tasks.size}")
val scrollState = rememberScrollState()
val scrollModifier =
if (scrollable) Modifier.verticalScroll(scrollState)
else Modifier

// Split into two lists based on filter
// val (shown, incompleteTasks) = tasks.partition { it.state.completed }

fun String.isGroupToggle() = startsWith("--") || startsWith("==")
Column(
modifier = Modifier
) {
Column {
val selectedTask by viewModel.selectedTask.collectAsState()
val groupedTasks = mutableListOf(mutableListOf<TaskWithIDState>())
tasks.forEach { task ->
if (task.state.text.isGroupToggle()) groupedTasks.add(mutableListOf(task))
else groupedTasks.lastOrNull()?.add(task)
}
// val groupedTasks = mutableListOf(mutableListOf<TaskWithIDState>())
// tasks.forEach { task ->
// if (task.state.text.isGroupToggle()) groupedTasks.add(mutableListOf(task))
// else groupedTasks.lastOrNull()?.add(task)
// }
Column(scrollModifier.padding(horizontal = 6.dp)) {
groupedTasks.forEachIndexed { groupIndex, tasksInGroup ->
var isGroupHidden by remember { mutableStateOf(tasksInGroup.firstOrNull()?.state?.completed == true) }
tasksInGroup.forEachIndexed { index, task ->
key(task.uuid) {
val selected = selectedTask?.taskId == task.uuid
val focusRequested = selected && selectedTask?.requestFocus == true
// groupedTasks.forEachIndexed { groupIndex, tasksInGroup ->
// var isGroupHidden by remember { mutableStateOf(tasksInGroup.firstOrNull()?.state?.completed == true) }
tasks.forEachIndexed { index, task ->
key(task.uuid) {
val selected = selectedTask?.taskId == task.uuid
val focusRequested = selected && selectedTask?.requestFocus == true
// val onChange = remember(task) { getInteractions(task) }::onTaskChanged
// cached task is the SSOT in this context, some things like text updates take too long to update in db
CachedUpdate(
key = task.uuid,
value = task.state,
onValueChanged = { viewModel.onTaskChanged(task.uuid, it) }
) { cachedTask, setTask ->
val focusManager = LocalFocusManager.current
val keyboardOpen by keyboardAsState()
val isGroupToggle = index == 0 && cachedTask.text.isGroupToggle()
// cached task is the SSOT in this context, some things like text updates take too long to update in db
CachedUpdate(
key = task.uuid,
value = task.state,
onValueChanged = { viewModel.onTaskChanged(task.uuid, it) }
) { cachedTask, setTask ->
val focusManager = LocalFocusManager.current
val keyboardOpen by keyboardAsState()
val isGroupToggle = index == 0 && cachedTask.text.isGroupToggle()

LaunchedEffect(cachedTask) {
if (isGroupToggle) isGroupHidden = cachedTask.completed
}
// LaunchedEffect(cachedTask) {
// if (isGroupToggle) isGroupHidden = cachedTask.completed
// }

LaunchedEffect(keyboardOpen) {
if (!keyboardOpen) {
focusManager.clearFocus()
}
LaunchedEffect(keyboardOpen) {
if (!keyboardOpen) {
focusManager.clearFocus()
}
}

val taskInteractions = remember(cachedTask) {
viewModel.interactionsFor(task.uuid, listId, cachedTask, setTask)
}
val taskInteractions = remember(cachedTask) {
viewModel.interactionsFor(task.uuid, listId, cachedTask, setTask)
}

AnimatedVisibility(isGroupToggle || !isGroupHidden) {
Column {
ReorderableTask(key = task.uuid, reorderInteractions = reorderInteractions) {
Task(
cachedTask,
setTask,
selected,
taskInteractions,
focusRequested = focusRequested,
forceShowCheckbox = isGroupToggle,
overrideCheckboxIcon = if (isGroupToggle) AppIcons.ArrowDropDown else null,
overrideCheckboxCompletedIcon = if (isGroupToggle) AppIcons.ArrowDropUp else null,
)
}
if (!isGroupToggle) HorizontalDivider()
}
// AnimatedVisibility(isGroupToggle || !isGroupHidden) {
Column {
ReorderableTask(key = task.uuid, reorderInteractions = reorderInteractions) {
Task(
cachedTask,
setTask,
selected,
taskInteractions,
focusRequested = focusRequested,
forceShowCheckbox = isGroupToggle,
overrideCheckboxIcon = if (isGroupToggle) AppIcons.ArrowDropDown else null,
overrideCheckboxCompletedIcon = if (isGroupToggle) AppIcons.ArrowDropUp else null,
)
}

if (isGroupToggle) HorizontalDivider(
thickness = 2.dp,
color = cachedTask.highlight.color
.takeIf { it != Color.Transparent }
?: MaterialTheme.colorScheme.onSurface
)
if (!isGroupToggle) HorizontalDivider()
}
// }

if (isGroupToggle) HorizontalDivider(
thickness = 2.dp,
color = cachedTask.highlight.color
.takeIf { it != Color.Transparent }
?: MaterialTheme.colorScheme.onSurface
)
// }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import me.dvyy.tasks.model.TaskListProperties
import me.dvyy.tasks.tasks.ui.CachedUpdate
import me.dvyy.tasks.utils.Loadable
import me.dvyy.tasks.utils.loadedOrNull
import java.time.format.TextStyle
import java.util.*

@Composable
fun TaskListTitle(
Expand All @@ -46,7 +48,7 @@ fun TaskListTitle(
if (props.date != null) {
val date = props.date!!
Text(
"${date.month.name.lowercase().capitalize()} ${date.dayOfMonth}",
"${date.month.getDisplayName(TextStyle.SHORT, Locale.getDefault()).lowercase().capitalize()} ${date.dayOfMonth}",
Modifier.weight(1f, true),
style = MaterialTheme.typography.headlineMedium,
fontWeight = FontWeight.Bold,
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=me.dvyy
version=1.1.0-alpha.2
version=1.1.0-alpha.3
org.jetbrains.compose.experimental.wasm.enabled=true
kotlin.native.ignoreDisabledTargets=true
kotlin.mpp.stability.nowarn=true
Expand Down
37 changes: 16 additions & 21 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,31 @@ agp = "8.2.0"
android-compileSdk = "34"
android-minSdk = "24"
android-targetSdk = "34"
androidx-activityCompose = "1.9.2"
androidx-activityCompose = "1.9.3"
androidx-appcompat = "1.7.0"
androidx-constraintlayout = "2.1.4"
androidx-core-ktx = "1.13.1"
androidx-espresso-core = "3.6.1"
androidx-material = "1.12.0"
androidx-test-junit = "1.2.1"
androidx-glance = "1.1.0-rc01"
compose = "1.7.0-beta02"
exposed = "0.51.1"
compose = "1.7.0"
exposed = "0.55.0"
h2 = "2.2.224"
hikaricp = "5.1.0"
jdbcDriver = "2.0.2"
jib = "3.4.3"
junit = "4.13.2"
koin = "4.0.0-RC2"
kotlin = "2.0.20"
koin = "4.0.0"
kotlin = "2.0.21"
kotlinMultiplatformAppdirs = "1.2.0"
coroutines = "1.8.1"
coroutines = "1.9.0"
kotest = "5.9.1"
kotlinResult = "2.0.0"
kotlinxDatetime = "0.6.1"
kotlinxSerialization = "1.7.2"
ktor = "2.3.12"
ktor-eap = "3.0.0-rc-1"
lifecycleViewmodelCompose = "2.8.0-beta02"
logback = "1.5.7"
foundationAndroid = "1.7.2"
kotlinxSerialization = "1.7.3"
ktor = "3.0.0"
lifecycleViewmodelCompose = "2.8.0"
logback = "1.5.9"
foundationAndroid = "1.7.4"
material3WindowSizeClassMultiplatform = "0.5.0"
multiplatformSettings = "1.2.0"
postgresql = "42.7.4"
Expand All @@ -39,7 +36,6 @@ uuid = "0.8.4"
navigationCompose = "2.7.0-alpha03"
slf4j = "2.0.9"
sqlDelight = "2.1.0-SNAPSHOT"
oidc = "0.10.0"
colorpicker = "1.1.0"
startupRuntime = "1.2.0"
workRuntimeKtx = "2.9.1"
Expand Down Expand Up @@ -91,12 +87,11 @@ kotest-property = { module = "io.kotest:kotest-property", version.ref = "kotest"
kotest-runner-junit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" }
ktor-server-core = { module = "io.ktor:ktor-server-core-jvm", version.ref = "ktor" }
ktor-server-netty = { module = "io.ktor:ktor-server-netty-jvm", version.ref = "ktor" }
ktor-client-auth = { module = "io.ktor:ktor-client-auth", version.ref = "ktor-eap" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor-eap" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor-eap" }
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor-eap" }
ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor-eap" }
ktor-serialization-json-eap = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor-eap" }
ktor-client-auth = { module = "io.ktor:ktor-client-auth", version.ref = "ktor" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }
ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
ktor-serialization-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
androidx-foundation-android = { group = "androidx.compose.foundation", name = "foundation-android", version.ref = "foundationAndroid" }
material3-window-sizeclass-multiplatform = { module = "dev.chrisbanes.material3:material3-window-size-class-multiplatform", version.ref = "material3WindowSizeClassMultiplatform" }
Expand Down

0 comments on commit 6d51dbb

Please sign in to comment.