mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-19 07:15:25 +02:00
feat: Show snackbar on save folder change
This commit is contained in:
parent
de72f88953
commit
fa72ee096e
@ -28,6 +28,8 @@ import androidx.compose.material3.ExperimentalMaterial3Api
|
|||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.ModalBottomSheet
|
import androidx.compose.material3.ModalBottomSheet
|
||||||
|
import androidx.compose.material3.SnackbarDuration
|
||||||
|
import androidx.compose.material3.SnackbarHostState
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.rememberModalBottomSheetState
|
import androidx.compose.material3.rememberModalBottomSheetState
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@ -65,11 +67,13 @@ import java.net.URLDecoder
|
|||||||
@Composable
|
@Composable
|
||||||
fun SaveFolderTile(
|
fun SaveFolderTile(
|
||||||
settings: AppSettings,
|
settings: AppSettings,
|
||||||
|
snackbarHostState: SnackbarHostState,
|
||||||
) {
|
) {
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val dataStore = context.dataStore
|
val dataStore = context.dataStore
|
||||||
|
|
||||||
|
val successMessage = stringResource(R.string.ui_settings_option_saveFolder_success)
|
||||||
fun updateValue(path: String?) {
|
fun updateValue(path: String?) {
|
||||||
if (settings.saveFolder != null && settings.saveFolder != RECORDER_MEDIA_SELECTED_VALUE) {
|
if (settings.saveFolder != null && settings.saveFolder != RECORDER_MEDIA_SELECTED_VALUE) {
|
||||||
runCatching {
|
runCatching {
|
||||||
@ -91,6 +95,10 @@ fun SaveFolderTile(
|
|||||||
dataStore.updateData {
|
dataStore.updateData {
|
||||||
it.setSaveFolder(path)
|
it.setSaveFolder(path)
|
||||||
}
|
}
|
||||||
|
snackbarHostState.showSnackbar(
|
||||||
|
message = successMessage,
|
||||||
|
duration = SnackbarDuration.Short,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,10 @@ fun SettingsScreen(
|
|||||||
verticalArrangement = Arrangement.spacedBy(32.dp),
|
verticalArrangement = Arrangement.spacedBy(32.dp),
|
||||||
) {
|
) {
|
||||||
Column {
|
Column {
|
||||||
SaveFolderTile(settings = settings)
|
SaveFolderTile(
|
||||||
|
settings = settings,
|
||||||
|
snackbarHostState = snackbarHostState,
|
||||||
|
)
|
||||||
|
|
||||||
DividerTitle(
|
DividerTitle(
|
||||||
title = stringResource(R.string.ui_settings_sections_audio_title),
|
title = stringResource(R.string.ui_settings_sections_audio_title),
|
||||||
|
@ -172,4 +172,5 @@
|
|||||||
<string name="ui_settings_option_saveFolder_action_custom_label">Select a custom location</string>
|
<string name="ui_settings_option_saveFolder_action_custom_label">Select a custom location</string>
|
||||||
<string name="ui_settings_option_saveFolder_action_dcim_label">Use the DCIM folder</string>
|
<string name="ui_settings_option_saveFolder_action_dcim_label">Use the DCIM folder</string>
|
||||||
<string name="ui_settings_option_saveFolder_dcimValue">DCIM Folder</string>
|
<string name="ui_settings_option_saveFolder_dcimValue">DCIM Folder</string>
|
||||||
|
<string name="ui_settings_option_saveFolder_success">Batches Folder has been changed successfully</string>
|
||||||
</resources>
|
</resources>
|
Loading…
x
Reference in New Issue
Block a user