-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- handle cases when fab is pressed after all categories have been del…
…eted
- Loading branch information
Showing
13 changed files
with
196 additions
and
112 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
app/src/main/java/cloud/pablos/overload/data/category/CategoryState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
app/src/main/java/cloud/pablos/overload/ui/views/ChangeCategoryButton.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package cloud.pablos.overload.ui.views | ||
|
||
import android.os.Build | ||
import androidx.annotation.RequiresApi | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.ButtonDefaults | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import cloud.pablos.overload.data.Helpers | ||
import cloud.pablos.overload.data.category.CategoryEvent | ||
import cloud.pablos.overload.data.category.CategoryState | ||
import cloud.pablos.overload.ui.tabs.calendar.CalendarTabCategoryDialog | ||
|
||
@RequiresApi(Build.VERSION_CODES.S) | ||
@Composable | ||
fun ChangeCategoryButton( | ||
categoryState: CategoryState, | ||
categoryEvent: (CategoryEvent) -> Unit, | ||
) { | ||
val categoryDialogState = remember { mutableStateOf(false) } | ||
|
||
val categoriesCount = categoryState.categories.count() | ||
val selectedCategory = categoryState.categories.find { it.id == categoryState.selectedCategory } | ||
|
||
if (categoriesCount > 1 && selectedCategory != null) { | ||
val backgroundColor = Helpers.decideBackground(categoryState) | ||
val foregroundColor = Helpers.decideForeground(backgroundColor) | ||
|
||
Button( | ||
onClick = { categoryDialogState.value = true }, | ||
modifier = Modifier.padding(horizontal = 8.dp), | ||
colors = | ||
ButtonDefaults.buttonColors( | ||
containerColor = backgroundColor, | ||
contentColor = foregroundColor, | ||
), | ||
) { | ||
TextView(selectedCategory.emoji) | ||
} | ||
if (categoryDialogState.value) { | ||
CalendarTabCategoryDialog( | ||
categoryState, | ||
categoryEvent, | ||
onClose = { categoryDialogState.value = false }, | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.