-
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.
- Loading branch information
Showing
11 changed files
with
174 additions
and
6 deletions.
There are no files selected for viewing
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
113 changes: 113 additions & 0 deletions
113
app/src/main/java/cloud/pablos/overload/ui/tabs/calendar/CalendarTabCategoryDialog.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,113 @@ | ||
package cloud.pablos.overload.ui.tabs.calendar | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.itemsIndexed | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.rounded.Category | ||
import androidx.compose.material3.HorizontalDivider | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.NavigationBarDefaults | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.window.Dialog | ||
import cloud.pablos.overload.R | ||
import cloud.pablos.overload.data.category.Category | ||
import cloud.pablos.overload.data.category.CategoryEvent | ||
import cloud.pablos.overload.data.category.CategoryState | ||
import cloud.pablos.overload.ui.views.TextView | ||
|
||
@Composable | ||
fun CalendarTabCategoryDialog( | ||
categoryState: CategoryState, | ||
categoryEvent: (CategoryEvent) -> Unit, | ||
onClose: () -> Unit, | ||
) { | ||
Dialog( | ||
onDismissRequest = onClose, | ||
content = { | ||
Surface( | ||
shape = MaterialTheme.shapes.large, | ||
tonalElevation = NavigationBarDefaults.Elevation, | ||
color = MaterialTheme.colorScheme.background, | ||
modifier = Modifier.fillMaxWidth(), | ||
) { | ||
CategoryDialogContent(categoryState, categoryEvent, onClose) | ||
} | ||
}, | ||
) | ||
} | ||
|
||
@Composable | ||
private fun CategoryDialogContent( | ||
categoryState: CategoryState, | ||
categoryEvent: (CategoryEvent) -> Unit, | ||
onClose: () -> Unit, | ||
) { | ||
Column( | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
modifier = Modifier.padding(24.dp), | ||
) { | ||
Icon( | ||
imageVector = Icons.Rounded.Category, | ||
contentDescription = stringResource(id = R.string.select_category), | ||
tint = MaterialTheme.colorScheme.primary, | ||
modifier = Modifier.padding(16.dp), | ||
) | ||
|
||
TextView( | ||
text = stringResource(id = R.string.select_category), | ||
fontSize = MaterialTheme.typography.titleLarge.fontSize, | ||
modifier = Modifier.padding(top = 16.dp, bottom = 8.dp), | ||
) | ||
|
||
CategoryListContent(categoryState, categoryEvent, onClose) | ||
} | ||
} | ||
|
||
@Composable | ||
private fun CategoryListContent( | ||
categoryState: CategoryState, | ||
categoryEvent: (CategoryEvent) -> Unit, | ||
onClose: () -> Unit, | ||
) { | ||
LazyColumn { | ||
itemsIndexed(categoryState.categories) { index, category -> | ||
CategoryRow(category, categoryEvent, onClose) | ||
if (index < categoryState.categories.count() - 1) { | ||
HorizontalDivider() | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun CategoryRow( | ||
category: Category, | ||
categoryEvent: (CategoryEvent) -> Unit, | ||
onClose: () -> Unit, | ||
) { | ||
Row( | ||
modifier = | ||
Modifier | ||
.fillMaxWidth() | ||
.clickable { | ||
categoryEvent(CategoryEvent.SetSelectedCategory(category.id)) | ||
onClose() | ||
} | ||
.padding(16.dp), | ||
horizontalArrangement = Arrangement.Center, | ||
) { | ||
TextView(text = category.emoji + " " + category.name) | ||
} | ||
} |
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
Oops, something went wrong.