Skip to content

Commit

Permalink
v.0.17.2
Browse files Browse the repository at this point in the history
- adds fab to the calendar tab
- adds an expandable fab to the home tab
- fixes an issue where creating a category overwrote another
- fixes an issue where deleting a category deleted wrong items
- fixes an issue with categories
- fixes an issue with window padding
- updates Russian translations - thanks!
- optimises code
- bumps libs

You can verify the app signing certificate using [AppVerifier](https://github.com/soupslurpr/AppVerifier):
cloud.pablos.overload
BD:39:CA:B0:CB:22:4D:4A:E0:97:95:11:F3:24:1E:D8:85:8D:1A:F8:69:37:B7:C6:39:7B:E4:BA:7E:C1:A2:B4
  • Loading branch information
pablo03v committed Apr 27, 2024
1 parent cedf94d commit 3a3b701
Show file tree
Hide file tree
Showing 48 changed files with 746 additions and 399 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 = 171
versionName = "0.17.1"
versionCode = 172
versionName = "0.17.2"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
20 changes: 19 additions & 1 deletion app/src/main/java/cloud/pablos/overload/data/Helpers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,28 @@ class Helpers {
categoryState: CategoryState,
itemState: ItemState,
date: LocalDate? = null,
): List<Item> {
val categoryId = categoryState.selectedCategory

return itemState.items.filter { item ->
val startTime = convertStringToLocalDateTime(item.startTime)

if (date != null) {
categoryId == item.categoryId &&
extractDate(startTime) == date
} else {
categoryId == item.categoryId
}
}
}

fun getItems(
categoryId: Int,
itemState: ItemState,
date: LocalDate? = null,
): List<Item> {
return itemState.items.filter { item ->
val startTime = convertStringToLocalDateTime(item.startTime)
val categoryId = categoryState.selectedCategory

if (date != null) {
categoryId == item.categoryId &&
Expand Down
15 changes: 0 additions & 15 deletions app/src/main/java/cloud/pablos/overload/data/OverloadDatabase.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package cloud.pablos.overload.data

import android.content.Context
import androidx.room.AutoMigration
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import cloud.pablos.overload.data.category.Category
import cloud.pablos.overload.data.category.CategoryDao
Expand All @@ -22,17 +20,4 @@ abstract class OverloadDatabase : RoomDatabase() {
abstract fun categoryDao(): CategoryDao

abstract fun itemDao(): ItemDao

companion object {
private const val DATABASE_NAME = "items"

@Volatile private var instance: OverloadDatabase? = null

private fun buildDatabase(context: Context) =
Room.databaseBuilder(
context.applicationContext,
OverloadDatabase::class.java,
DATABASE_NAME,
).build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import cloud.pablos.overload.data.item.Item

@Entity(tableName = "categories")
data class Category(
@PrimaryKey(autoGenerate = true) val id: Int = 1,
@PrimaryKey(autoGenerate = true) val id: Int = 0,
val color: Long,
val emoji: String,
val goal1: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ package cloud.pablos.overload.data.category

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Transaction
import androidx.room.Upsert
import kotlinx.coroutines.flow.Flow

@Dao
interface CategoryDao {
@Insert
suspend fun insertCategory(category: Category)

@Upsert
suspend fun upsertCategory(category: Category)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cloud.pablos.overload.data.category
sealed interface CategoryEvent {
data object SaveCategory : CategoryEvent

data object CreateCategory : CategoryEvent

data class SetId(val id: Int) : CategoryEvent

data class SetColor(val color: Long) : CategoryEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,41 @@ class CategoryViewModel(
}
}

CategoryEvent.CreateCategory -> {
val color = _state.value.color
val emoji = _state.value.emoji
val goal1 = _state.value.goal1
val goal2 = _state.value.goal2
val isDefault = _state.value.isDefault
val name = _state.value.name

val category =
Category(
color = color,
emoji = emoji,
goal1 = goal1,
goal2 = goal2,
isDefault = isDefault,
name = name,
)

viewModelScope.launch {
dao.insertCategory(category)
}

_state.update {
it.copy(
id = 0,
color = convertColorToLong(Color.Unspecified),
emoji = "🕣",
goal1 = 0,
goal2 = 0,
isDefault = false,
name = "",
)
}
}

is CategoryEvent.SetColor -> {
_state.update {
it.copy(
Expand Down
27 changes: 27 additions & 0 deletions app/src/main/java/cloud/pablos/overload/ui/Helpers.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cloud.pablos.overload.ui

import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue

@Composable
fun LazyListState.isScrollingUp(): Boolean {
var previousIndex by remember(this) { mutableIntStateOf(firstVisibleItemIndex) }
var previousScrollOffset by remember(this) { androidx.compose.runtime.mutableIntStateOf(firstVisibleItemScrollOffset) }
return remember(this) {
derivedStateOf {
if (previousIndex != firstVisibleItemIndex) {
previousIndex > firstVisibleItemIndex
} else {
previousScrollOffset >= firstVisibleItemScrollOffset
}.also {
previousIndex = firstVisibleItemIndex
previousScrollOffset = firstVisibleItemScrollOffset
}
}
}.value
}
3 changes: 1 addition & 2 deletions app/src/main/java/cloud/pablos/overload/ui/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cloud.pablos.overload.ui

import android.annotation.SuppressLint
import android.app.Activity
import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.os.Build
Expand Down Expand Up @@ -62,7 +61,7 @@ class MainActivity : ComponentActivity() {

private val filePickerLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
if (result.resultCode == RESULT_OK) {
val uri = result.data?.data
uri?.let {
lifecycleScope.launch {
Expand Down
11 changes: 9 additions & 2 deletions app/src/main/java/cloud/pablos/overload/ui/OverloadApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ fun OverloadAppContent(
Modifier
.weight(1f)
.then(
if (navigationType == OverloadNavigationType.BOTTOM_NAVIGATION && itemState.isDeletingHome.not()) {
if (navigationType == OverloadNavigationType.BOTTOM_NAVIGATION) {
Modifier.consumeWindowInsets(
WindowInsets.systemBars.only(
WindowInsetsSides.Bottom,
Expand Down Expand Up @@ -376,7 +376,14 @@ private fun OverloadNavHost(
HomeTab(navigationType, categoryEvent, categoryState, itemState, itemEvent)
}
composable(OverloadRoute.CALENDAR) {
CalendarTab(contentType, categoryState, categoryEvent, itemState, itemEvent, { navController.navigate(OverloadRoute.DAY) })
CalendarTab(
navigationType,
contentType,
categoryState,
categoryEvent,
itemState,
itemEvent,
) { navController.navigate(OverloadRoute.DAY) }
}
composable(OverloadRoute.CATEGORY) {
CategoryScreen(categoryState, categoryEvent, itemState, itemEvent)
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/java/cloud/pablos/overload/ui/TabItem.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package cloud.pablos.overload.ui

import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.runtime.Composable
import cloud.pablos.overload.data.category.CategoryState
import cloud.pablos.overload.data.item.ItemEvent
import cloud.pablos.overload.data.item.ItemState

data class TabItem(
val titleResId: Int,
val screen: @Composable (categoryState: CategoryState, itemState: ItemState, itemEvent: (ItemEvent) -> Unit) -> Unit,
val screen: @Composable (
categoryState: CategoryState,
itemState: ItemState,
itemEvent: (ItemEvent) -> Unit,
listState: LazyListState,
) -> Unit,
)
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,7 @@ fun OverloadNavigationRail(
)
}

OverloadNavigationFabSmall(
categoryEvent = categoryEvent,
categoryState = categoryState,
itemState = itemState,
itemEvent = itemEvent,
)
OverloadNavigationFabSmall(selectedDestination, categoryEvent, categoryState, itemState, itemEvent)
}
Column(modifier = Modifier.layoutId(LayoutType.CONTENT)) {
when (itemState.isDeletingHome) {
Expand Down Expand Up @@ -482,7 +477,7 @@ fun ModalNavigationDrawerContent(
}
}

OverloadNavigationFab(categoryEvent, categoryState, itemState, itemEvent, onDrawerClicked)
OverloadNavigationFab(selectedDestination, categoryEvent, categoryState, itemState, itemEvent, onDrawerClicked)
}

Column(Modifier.layoutId(LayoutType.CONTENT)) {
Expand Down
Loading

0 comments on commit 3a3b701

Please sign in to comment.