Make timing adjustable
On Android, a Toast is often used display temporary messages. The display duration might be too short for people to read or hear the message.
We recommend displaying messages by using an AlertDialog or Snackbar with the duration set to LENGTH_INDEFINITE. Don't forget to add a close button.
Also check whether Executors, Handler or Timer are used somewhere. If there are any time limits, make sure they can be extended.
kotlin
val snackbar = Snackbar
.make(view, "Appt", Snackbar.LENGTH_INDEFINITE)
.setAction("Close") {
// Close
}
snackbar.show() In Jetpack Compose, a Toast is often used display temporary messages. The display duration might be too short for people to read or hear the message.
We recommend displaying messages by using an AlertDialog) or Snackbar with the duration set to SnackbarDuration.Indefinite. Don't forget to add a close button.
Also check whether Executors, Handler or Timer are used somewhere. If there are any time limits, make sure they can be extended.
kotlin
val snackbarHostState = remember { SnackbarHostState() }
val scope = rememberCoroutineScope()
Scaffold(
snackbarHost = { SnackbarHost(snackbarHostState) },
floatingActionButton = {
ExtendedFloatingActionButton(
onClick = {
// show snackbar as a suspend function
scope.launch {
snackbarHostState.showSnackbar(
message = "Snackbar title",
actionLabel = "Appt",
withDismissAction = true,
duration = SnackbarDuration.Indefinite
)
}
}
) {
// FAB content...
}
},
content = { innerPadding ->
// Scaffold content...
}
) On iOS, third-party code libraries are sometimes used to display a temporary message, also known as a Toast. The display duration might be too short for people to read or hear the message.
We recommend showing messages by using an UIAlertController. Don't forget to add a close button.
Also check whether DispatchQueue is used somewhere. If there are time limits, make sure they can be extended.
swift
let alert = UIAlertController(
title: nil,
message: "Appt",
preferredStyle: .alert
)
alert.addAction(UIAlertAction(title: "Close", style: .default, handler: { action in
// Close
}))
present(alert, animated: true) In SwiftUI, third-party code libraries are sometimes used to display a temporary message, also known as a Toast. The display duration might be too short for people to read or hear the message.
We recommend showing messages by using an alert-4rhk6) modifier. Don't forget to add a close button.
Also check whether DispatchQueue or Timer is used somewhere. If there are time limits, make sure they can be extended.
swift
// State to control the visibility of the "Settings Saved" alert
@State private var showSettingsSavedAlert = false
var body: some View {
Button("Save Settings") {
// Perform needed actions
showSettingsSavedAlert = true
}
.alert(isPresented: $showSettingsSavedAlert) {
// Show alert instead of a
Alert(
title: Text("Success"),
message: Text("Your settings have been saved successfully."),
dismissButton: .default(Text("Close"))
)
}
} In Flutter, a SnackBar is often used display temporary messages. The display duration might be too short for people to read or hear the message.
We recommend displaying messages by using an AlertDialog. Or, when using a Snackbar, you can set the duration to "infinite". Don't forget to add a close button for both options.
Also make sure that the use of time limits, e.g. by using Future.delayed(), can be extended.
dart
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
duration: const Duration(days: 1),
content: Text('Appt'),
action: SnackBarAction(
label: 'Close',
onPressed: () {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
},
),
)); In React Native, the react-native-root-toast is often used to display temporary messages. The display duration might be too short for people to read or hear the message.
We recommend use the SnackBar in react-native-paper instead. Set the duration to Number.MAX_SAFE_INTEGER to keep it visible. Don't forget to add a close button.
Also make sure that the use of time limits, e.g. by using setTimeout, can be extended.
jsx
import { Button, Snackbar } from 'react-native-paper';
<Snackbar
visible={visible}
onDismiss={onDismissSnackBar}
duration={Number.MAX_SAFE_INTEGER}
action={{
label: 'Close',
onPress: () => {
// Close
},
}}>
Appt
</Snackbar> In MAUI, the SnackBar view from the MAUI.CommunityToolkit is often used to display temporary messages. However, the display duration might be too short for people to read or hear the message.
When using SnackBar, set the Duration to TimeSpan.MaxValue. Alternatively, use the DisplayAlert method to show an alert instead.
Also, make sure that the use of time limits, such as those set with Timer, can be extended.
csharp
var snackbar = Snackbar.Make("Appt",
() =>
{
//Apply any logic
},
"Close",
TimeSpan.MaxValue);
await snackbar.Show(); In Xamarin, the SnackBar view from the Xamarin.CommunityToolkit is often used to display temporary messages. The display duration might be too short for people to read or hear the message.
When using SnackBar, set the Duration to Int32.MaxValue. Or, use DisplayAlert method to show an alert instead.
Also make sure that the use of time limits, e.g. by using Timer, can be extended.
csharp
var result = await page.DisplaySnackBarAsync("Appt", "Close", async () =>
{ /* Action */ },
Int32.MaxValue
);