Skip to content

Commit

Permalink
Improve dialogs
Browse files Browse the repository at this point in the history
Signed-off-by: starry-shivam <[email protected]>
  • Loading branch information
starry-shivam committed Mar 27, 2024
1 parent aa74d32 commit 50c6dfc
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ package com.starry.greenstash.ui.screens.home.composables
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Delete
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand All @@ -53,10 +55,16 @@ fun HomeDialogs(
color = MaterialTheme.colorScheme.onSurface,
)
}, confirmButton = {
TextButton(onClick = {
openDeleteDialog.value = false
onDeleteConfirmed()
}) {
FilledTonalButton(
onClick = {
openDeleteDialog.value = false
onDeleteConfirmed()
},
colors = ButtonDefaults.filledTonalButtonColors(
containerColor = MaterialTheme.colorScheme.errorContainer,
contentColor = MaterialTheme.colorScheme.onErrorContainer
)
) {
Text(stringResource(id = R.string.confirm))
}
}, dismissButton = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LargeTopAppBar
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.surfaceColorAtElevation
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
Expand All @@ -53,7 +51,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.starry.greenstash.BuildConfig
import com.starry.greenstash.R
Expand All @@ -76,24 +73,23 @@ fun AboutScreen(navController: NavController) {

Scaffold(modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
LargeTopAppBar(title = {
Text(
stringResource(id = R.string.about_screen_header),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}, navigationIcon = {
IconButton(onClick = { navController.navigateUp() }) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = null
LargeTopAppBar(
title = {
Text(
stringResource(id = R.string.about_screen_header),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
}, scrollBehavior = scrollBehavior, colors = TopAppBarDefaults.largeTopAppBarColors(
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(
4.dp
)
)
},
navigationIcon = {
IconButton(onClick = { navController.navigateUp() }) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = null
)
}
},
scrollBehavior = scrollBehavior,
)
}) {
LazyColumn(modifier = Modifier.padding(it)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,10 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.surfaceColorAtElevation
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.mikepenz.aboutlibraries.ui.compose.LibrariesContainer
import com.mikepenz.aboutlibraries.ui.compose.LibraryDefaults
Expand All @@ -53,22 +50,21 @@ import com.starry.greenstash.R
@Composable
fun OSLScreen(navController: NavController) {
Scaffold(modifier = Modifier.fillMaxSize(), topBar = {
TopAppBar(modifier = Modifier.fillMaxWidth(), title = {
Text(
text = stringResource(id = R.string.osl_screen_header),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}, navigationIcon = {
IconButton(onClick = { navController.navigateUp() }) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null
TopAppBar(
modifier = Modifier.fillMaxWidth(),
title = {
Text(
text = stringResource(id = R.string.osl_screen_header),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
}, colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(4.dp)
)
)
}, navigationIcon = {
IconButton(onClick = { navController.navigateUp() }) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null
)
}
})
}) {
LibrariesContainer(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LargeTopAppBar
Expand Down Expand Up @@ -226,23 +228,28 @@ fun SettingsScreen(navController: NavController) {
}
}
}, confirmButton = {
TextButton(onClick = {
themeDialog.value = false

when (selectedThemeOption) {
"Light" -> {
viewModel.setTheme(ThemeMode.Light)
}
FilledTonalButton(
onClick = {
themeDialog.value = false
when (selectedThemeOption) {
"Light" -> {
viewModel.setTheme(ThemeMode.Light)
}

"Dark" -> {
viewModel.setTheme(ThemeMode.Dark)
}
"Dark" -> {
viewModel.setTheme(ThemeMode.Dark)
}

"System" -> {
viewModel.setTheme(ThemeMode.Auto)
"System" -> {
viewModel.setTheme(ThemeMode.Auto)
}
}
}
}) {
},
colors = ButtonDefaults.filledTonalButtonColors(
containerColor = MaterialTheme.colorScheme.primary,
contentColor = MaterialTheme.colorScheme.onPrimary
)
) {
Text(stringResource(id = R.string.theme_dialog_apply_button))
}
}, dismissButton = {
Expand Down Expand Up @@ -340,19 +347,24 @@ fun SettingsScreen(navController: NavController) {
}
}
}, confirmButton = {
TextButton(onClick = {
dateDialog.value = false

when (selectedDateOption) {
"DD/MM/YYYY" -> {
viewModel.setDateStyle(DateStyle.DateMonthYear.pattern)
}
FilledTonalButton(
onClick = {
dateDialog.value = false
when (selectedDateOption) {
"DD/MM/YYYY" -> {
viewModel.setDateStyle(DateStyle.DateMonthYear.pattern)
}

"YYYY/MM/DD" -> {
viewModel.setDateStyle(DateStyle.YearMonthDate.pattern)
"YYYY/MM/DD" -> {
viewModel.setDateStyle(DateStyle.YearMonthDate.pattern)
}
}
}
}) {
},
colors = ButtonDefaults.filledTonalButtonColors(
containerColor = MaterialTheme.colorScheme.primary,
contentColor = MaterialTheme.colorScheme.onPrimary
)
) {
Text(stringResource(id = R.string.confirm))
}
}, dismissButton = {
Expand Down Expand Up @@ -412,14 +424,20 @@ fun SettingsScreen(navController: NavController) {
}
}
}, confirmButton = {
TextButton(onClick = {
currencyDialog.value = false
val choice =
currencyValues[currencyEntries.indexOf(
selectedCurrencyOption
)]
viewModel.setDefaultCurrency(choice)
}) {
FilledTonalButton(
onClick = {
currencyDialog.value = false
val choice =
currencyValues[currencyEntries.indexOf(
selectedCurrencyOption
)]
viewModel.setDefaultCurrency(choice)
},
colors = ButtonDefaults.filledTonalButtonColors(
containerColor = MaterialTheme.colorScheme.primary,
contentColor = MaterialTheme.colorScheme.onPrimary
)
) {
Text(stringResource(id = R.string.confirm))
}
}, dismissButton = {
Expand Down

0 comments on commit 50c6dfc

Please sign in to comment.