mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
fix: Improve snackbar & add import success message
This commit is contained in:
parent
5e9f46d979
commit
54b2e9bee5
@ -14,6 +14,9 @@ import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.SnackbarDuration
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.SnackbarVisuals
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
@ -35,7 +38,9 @@ import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
|
||||
@Composable
|
||||
fun ImportExport() {
|
||||
fun ImportExport(
|
||||
snackbarHostState: SnackbarHostState,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
|
||||
val scope = rememberCoroutineScope()
|
||||
@ -60,6 +65,8 @@ fun ImportExport() {
|
||||
}
|
||||
|
||||
if (settingsToBeImported != null) {
|
||||
val successMessage = stringResource(R.string.ui_settings_option_import_success)
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = {
|
||||
settingsToBeImported = null
|
||||
@ -84,7 +91,14 @@ fun ImportExport() {
|
||||
settingsToBeImported!!
|
||||
}
|
||||
settingsToBeImported = null
|
||||
|
||||
snackbarHostState.showSnackbar(
|
||||
message = successMessage,
|
||||
withDismissAction = true,
|
||||
duration = SnackbarDuration.Short,
|
||||
)
|
||||
}
|
||||
|
||||
},
|
||||
) {
|
||||
Icon(
|
||||
|
@ -16,7 +16,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.Snackbar
|
||||
import androidx.compose.material3.SnackbarHost
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.Text
|
||||
@ -65,7 +67,21 @@ fun SettingsScreen(
|
||||
)
|
||||
|
||||
Scaffold(
|
||||
snackbarHost = { SnackbarHost(hostState = snackbarHostState) },
|
||||
snackbarHost = {
|
||||
SnackbarHost(
|
||||
hostState = snackbarHostState,
|
||||
snackbar = {
|
||||
Snackbar(
|
||||
snackbarData = it,
|
||||
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
||||
contentColor = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||
actionColor = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||
actionContentColor = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||
dismissActionContentColor = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||
)
|
||||
}
|
||||
)
|
||||
},
|
||||
topBar = {
|
||||
LargeTopAppBar(
|
||||
title = {
|
||||
@ -149,7 +165,7 @@ fun SettingsScreen(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(0.5f)
|
||||
)
|
||||
ImportExport()
|
||||
ImportExport(snackbarHostState = snackbarHostState)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,4 +67,5 @@
|
||||
<string name="ui_settings_option_export_label">Export Settings</string>
|
||||
<string name="ui_settings_option_import_dialog_text">Are you sure you want to import these settings? Your current settings will be overwritten!</string>
|
||||
<string name="ui_settings_option_import_dialog_confirm">Import settings</string>
|
||||
<string name="ui_settings_option_import_success">Settings have been imported successfully!</string>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user