Skip to content

Commit

Permalink
v.0.15.0
Browse files Browse the repository at this point in the history
- adds functionality to edit existing items #6
- code optimisations

#22 #23 #24 #25
  • Loading branch information
pablo03v authored Mar 24, 2024
1 parent de6c348 commit 57d53e4
Show file tree
Hide file tree
Showing 29 changed files with 2,331 additions and 1,212 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId = "cloud.pablos.overload"
minSdk = 26
targetSdk = 34
versionCode = 141
versionName = "0.14.1"
versionCode = 150
versionName = "0.15.0"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 141,
"versionName": "0.14.1",
"versionCode": 150,
"versionName": "0.15.0",
"outputFile": "app-release.apk"
}
],
Expand Down
38 changes: 22 additions & 16 deletions app/src/main/java/cloud/pablos/overload/data/item/ItemDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ interface ItemDao {
@Upsert
suspend fun upsertItem(item: Item)

@Upsert
suspend fun upsertItems(items: List<Item>)
/*@Upsert
suspend fun upsertItems(items: List<Item>)*/

@Delete
suspend fun deleteItem(item: Item)
/*@Delete
suspend fun deleteItem(item: Item)*/

@Delete
suspend fun deleteItems(items: List<Item>)
Expand All @@ -41,27 +41,33 @@ fun backupItemsToCsv(state: ItemState): String {
}*/

val csvHeader = "id,startTime,endTime,ongoing,pause\n"
val csvData = items.joinToString("\n") { item ->
"${item.id},${item.startTime},${item.endTime},${item.ongoing},${item.pause}"
}
val csvData =
items.joinToString("\n") { item ->
"${item.id},${item.startTime},${item.endTime},${item.ongoing},${item.pause}"
}

return csvHeader + csvData
}

fun startOrStopPause(state: ItemState, onEvent: (ItemEvent) -> Unit) {
fun startOrStopPause(
state: ItemState,
onEvent: (ItemEvent) -> Unit,
) {
val date = LocalDate.now()

val itemsForToday = state.items.filter { item ->
val startTime = parseToLocalDateTime(item.startTime)
extractDate(startTime) == date
}
val itemsForToday =
state.items.filter { item ->
val startTime = parseToLocalDateTime(item.startTime)
extractDate(startTime) == date
}
val isFirstToday = itemsForToday.isEmpty()
val isOngoingToday = itemsForToday.isNotEmpty() && itemsForToday.last().ongoing

val itemsNotToday = state.items.filter { item ->
val startTime = parseToLocalDateTime(item.startTime)
extractDate(startTime) != date
}
val itemsNotToday =
state.items.filter { item ->
val startTime = parseToLocalDateTime(item.startTime)
extractDate(startTime) != date
}
val isOngoingNotToday = itemsNotToday.isNotEmpty() && itemsNotToday.any { it.ongoing }

if (isOngoingNotToday) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ fun CalendarTab(
}

YearView(
state = state,
onEvent = onEvent,
year = state.selectedYearCalendar,
bottomPadding = 0.dp,
Expand Down Expand Up @@ -176,7 +175,6 @@ fun CalendarTab(
}

YearView(
state = state,
onEvent = onEvent,
year = state.selectedYearCalendar,
onNavigate = onNavigate,
Expand Down
Loading

0 comments on commit 57d53e4

Please sign in to comment.