majro update
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lensai/extensions/nullable.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
void showErrorMessage(BuildContext context, String message) {
|
||||
@@ -9,6 +10,60 @@ void showErrorMessage(BuildContext context, String message) {
|
||||
),
|
||||
backgroundColor: Theme.of(context).colorScheme.onError,
|
||||
);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
}
|
||||
|
||||
void showTabBackButtonMessage(BuildContext context, int tabCount) {
|
||||
final snackbar = SnackBar(
|
||||
content:
|
||||
(tabCount > 1)
|
||||
? const Text('Please click BACK again to close current tab')
|
||||
: const Text('Please click BACK again to exit app'),
|
||||
);
|
||||
|
||||
ScaffoldMessenger.of(context)
|
||||
..clearSnackBars()
|
||||
..showSnackBar(snackbar);
|
||||
}
|
||||
|
||||
void showTabOpenedMessage(
|
||||
BuildContext context, {
|
||||
String? tabName,
|
||||
void Function()? onShow,
|
||||
}) {
|
||||
final message = switch (tabName.whenNotEmpty) {
|
||||
String() => "New tab '$tabName' opened in background",
|
||||
null => 'New tab opened in background',
|
||||
};
|
||||
|
||||
final snackBar = SnackBar(
|
||||
content: Text(message),
|
||||
action: onShow.mapNotNull(
|
||||
(onPressed) => SnackBarAction(label: 'Show', onPressed: onPressed),
|
||||
),
|
||||
);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
}
|
||||
|
||||
void showTabSwitchMessage(
|
||||
BuildContext context, {
|
||||
String? tabName,
|
||||
void Function()? onSwitch,
|
||||
}) {
|
||||
final message = switch (tabName.whenNotEmpty) {
|
||||
String() => "New tab '$tabName' opened",
|
||||
null => 'New tab opened',
|
||||
};
|
||||
|
||||
final snackBar = SnackBar(
|
||||
content: Text(message),
|
||||
action: onSwitch.mapNotNull(
|
||||
(onPressed) => SnackBarAction(label: 'Switch', onPressed: onPressed),
|
||||
),
|
||||
);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
}
|
||||
|
||||
@@ -29,16 +84,3 @@ Future<void> launchUrlFeedback(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void showTabBackButtonMessage(BuildContext context, int tabCount) {
|
||||
ScaffoldMessenger.of(context)
|
||||
..clearSnackBars()
|
||||
..showSnackBar(
|
||||
SnackBar(
|
||||
content:
|
||||
(tabCount > 1)
|
||||
? const Text('Please click BACK again to close current tab')
|
||||
: const Text('Please click BACK again to exit app'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user