2021-02-15 18:58:29 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2021-09-15 14:37:22 +00:00
|
|
|
import 'package:selfprivacy/config/brand_colors.dart';
|
|
|
|
import 'package:selfprivacy/config/text_themes.dart';
|
2021-02-15 18:58:29 +00:00
|
|
|
|
|
|
|
class NavigationService {
|
2021-08-29 09:50:24 +00:00
|
|
|
final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey =
|
|
|
|
GlobalKey<ScaffoldMessengerState>();
|
2021-02-15 18:58:29 +00:00
|
|
|
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
2021-08-29 09:50:24 +00:00
|
|
|
|
2021-03-15 15:39:44 +00:00
|
|
|
NavigatorState? get navigator => navigatorKey.currentState;
|
2021-02-15 18:58:29 +00:00
|
|
|
|
2022-06-05 19:36:32 +00:00
|
|
|
void showPopUpDialog(final AlertDialog dialog) {
|
|
|
|
final BuildContext context = navigatorKey.currentState!.overlay!.context;
|
2021-02-15 18:58:29 +00:00
|
|
|
|
|
|
|
showDialog(
|
|
|
|
context: context,
|
2022-06-05 19:36:32 +00:00
|
|
|
builder: (final _) => dialog,
|
2021-02-15 18:58:29 +00:00
|
|
|
);
|
|
|
|
}
|
2021-08-29 09:50:24 +00:00
|
|
|
|
2022-06-05 19:36:32 +00:00
|
|
|
void showSnackBar(final String text) {
|
|
|
|
final ScaffoldMessengerState state = scaffoldMessengerKey.currentState!;
|
|
|
|
final SnackBar snack = SnackBar(
|
2021-09-15 14:37:22 +00:00
|
|
|
backgroundColor: BrandColors.black.withOpacity(0.8),
|
|
|
|
content: Text(text, style: buttonTitleText),
|
|
|
|
duration: const Duration(seconds: 2),
|
|
|
|
);
|
|
|
|
state.showSnackBar(snack);
|
2021-08-29 09:50:24 +00:00
|
|
|
}
|
2021-02-15 18:58:29 +00:00
|
|
|
}
|