Skip to content

Commit

Permalink
renaming snackbar to message updates
Browse files Browse the repository at this point in the history
no more snacks!
  • Loading branch information
mariobodemann committed Apr 17, 2024
1 parent cee2958 commit 45d4b0c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ import androidx.compose.material.icons.filled.Send
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Snackbar
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.TopAppBarDefaults.topAppBarColors
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
Expand Down Expand Up @@ -495,13 +493,13 @@ private fun SelectedEditor(
config = config,
dismissed = { vm.slotConfigured(editor.slot, null) },
accepted = { newConfig -> vm.slotConfigured(editor.slot, newConfig) },
snackbarMessage = vm::showMessage,
updateMessage = vm::showMessage,
)

is ZeConfiguration.Picture -> PictureEditorDialog(
dismissed = { vm.slotConfigured(null, null) },
accepted = { newConfig -> vm.slotConfigured(editor.slot, newConfig) },
snackbarMessage = vm::showMessage,
updateMessage = vm::showMessage,
)

is ZeConfiguration.ImageGen -> ImageGenerationEditorDialog(
Expand All @@ -519,20 +517,20 @@ private fun SelectedEditor(
config = config,
dismissed = { vm.slotConfigured(null, null) },
accepted = { newConfig -> vm.slotConfigured(editor.slot, newConfig) },
snackbarMessage = vm::showMessage,
updateMessage = vm::showMessage,
)

is ZeConfiguration.Quote -> RandomQuotesEditorDialog(
accepted = { vm.slotConfigured(editor.slot, it) },
dismissed = { vm.slotConfigured(null, null) },
config = config,
snackbarMessage = vm::showMessage,
updateMessage = vm::showMessage,
)

is ZeConfiguration.QRCode -> QRCodeEditorDialog(
config = config,
dismissed = { vm.slotConfigured(editor.slot, null) },
snackbarMessage = vm::showMessage,
updateMessage = vm::showMessage,
accepted = { newConfig -> vm.slotConfigured(editor.slot, newConfig) },
)

Expand All @@ -559,7 +557,7 @@ private fun SelectedEditor(
is ZeConfiguration.CustomPhrase -> CustomPhraseEditorDialog(
config = config,
dismissed = { vm.slotConfigured(editor.slot, null) },
snackbarMessage = vm::showMessage,
udpateMessage = vm::showMessage,
accepted = { newConfig -> vm.slotConfigured(editor.slot, newConfig) },
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fun CustomPhraseEditorDialog(
config: ZeConfiguration.CustomPhrase,
dismissed: () -> Unit,
accepted: (ZeConfiguration.CustomPhrase) -> Unit,
snackbarMessage: (String) -> Unit = {},
udpateMessage: (String) -> Unit = {},
) {
val activity = LocalContext.current as Activity

Expand All @@ -51,7 +51,7 @@ fun CustomPhraseEditorDialog(
if (image.isBinary()) {
accepted(ZeConfiguration.CustomPhrase(randomPhrase, image))
} else {
snackbarMessage(activity.resources.getString(R.string.binary_image_needed))
udpateMessage(activity.resources.getString(R.string.binary_image_needed))
}
},
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ const val MaxCharacters: Int = 20
* @param config configuration of the slot, containing details to be displayed
* @param dismissed callback called when dialog is dismissed / cancelled
* @param accepted callback called with the new configuration configured.
* @param snackbarMessage callback to display a snackbar message
* @param updateMessage callback to display a message
*/
@Composable
fun NameEditorDialog(
config: ZeConfiguration.Name,
dismissed: () -> Unit = {},
accepted: (config: ZeConfiguration.Name) -> Unit,
snackbarMessage: (String) -> Unit,
updateMessage: (String) -> Unit,
) {
val activity = LocalContext.current as Activity

Expand All @@ -72,7 +72,7 @@ fun NameEditorDialog(
if (image.isBinary()) {
accepted(ZeConfiguration.Name(name, contact, image))
} else {
snackbarMessage(activity.resources.getString(R.string.binary_image_needed))
updateMessage(activity.resources.getString(R.string.binary_image_needed))
}
},
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ private const val ROTATE_CLOCKWISE = 90f
*
* @param dismissed callback called when dismissed or cancelled
* @param accepted callback called when user wants to take the selected image.
* @param updateMessage callback to show a message upon error or success.
*/
@Composable
fun PictureEditorDialog(
dismissed: () -> Unit = {},
accepted: (config: ZeConfiguration.Picture) -> Unit,
snackbarMessage: (String) -> Unit,
updateMessage: (String) -> Unit,
) {
val context = LocalContext.current

Expand Down Expand Up @@ -78,7 +79,7 @@ fun PictureEditorDialog(
if (bitmap.isBinary()) {
accepted(ZeConfiguration.Picture(bitmap))
} else {
snackbarMessage(context.getString(R.string.not_binary_image))
updateMessage(context.getString(R.string.not_binary_image))
}
},) {
Text(stringResource(id = android.R.string.ok))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ import de.berlindroid.zeapp.zemodels.ZeConfiguration
* @param config configuration of the slot, containing details to be displayed
* @param dismissed callback called when dialog is dismissed / cancelled
* @param accepted callback called with the new configuration configured.
* @param snackbarMessage callback to display a snackbar message
* @param updateMessage callback to display a message
*/
@Composable
fun QRCodeEditorDialog(
config: ZeConfiguration.QRCode,
dismissed: () -> Unit = {},
accepted: (config: ZeConfiguration.QRCode) -> Unit,
snackbarMessage: (String) -> Unit,
updateMessage: (String) -> Unit,
) {
val activity = LocalContext.current as Activity

Expand Down Expand Up @@ -101,7 +101,7 @@ fun QRCodeEditorDialog(
),
)
} else {
snackbarMessage(activity.getString(R.string.image_needed))
updateMessage(activity.getString(R.string.image_needed))
}
},
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ import kotlin.random.Random
* @param config configuration of the slot, containing details to be displayed
* @param dismissed callback called when dialog is dismissed / cancelled
* @param accepted callback called with the new configuration configured.
* @param updateMessage show a new message to the user.
*/
@Composable
fun RandomQuotesEditorDialog(
config: ZeConfiguration.Quote,
dismissed: () -> Unit = {},
accepted: (config: ZeConfiguration.Quote) -> Unit,
snackbarMessage: (String) -> Unit,
updateMessage: (String) -> Unit,
) {
val activity = LocalContext.current as Activity

Expand All @@ -62,7 +63,7 @@ fun RandomQuotesEditorDialog(
if (image.isBinary()) {
accepted(ZeConfiguration.Quote(message, author, image))
} else {
snackbarMessage(activity.resources.getString(R.string.binary_image_needed))
updateMessage(activity.resources.getString(R.string.binary_image_needed))
}
},
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ import java.time.format.DateTimeFormatter
* @param config configuration of the slot, containing details to be displayed
* @param dismissed callback called when dialog is dismissed / cancelled
* @param accepted callback called with the new configuration configured.
* @param updateMessage update the message displayed to the user.
*/
@Suppress("LongMethod")
@Composable
fun WeatherEditorDialog(
config: ZeConfiguration.Weather,
dismissed: () -> Unit = {},
accepted: (config: ZeConfiguration.Weather) -> Unit,
snackbarMessage: (String) -> Unit,
updateMessage: (String) -> Unit,
) {
val activity = LocalContext.current as Activity

Expand Down Expand Up @@ -91,7 +92,7 @@ fun WeatherEditorDialog(
if (image.isBinary()) {
accepted(ZeConfiguration.Weather(date, temperature, image))
} else {
snackbarMessage(activity.resources.getString(R.string.binary_image_needed))
updateMessage(activity.resources.getString(R.string.binary_image_needed))
}
},
) {
Expand Down

0 comments on commit 45d4b0c

Please sign in to comment.