selfprivacy.org.app/lib/ui/helpers/modals.dart
NaiJi cdc47ecdb3 refactor(ui): Move all pop up dialogs into general utils function
To not import get_it everywhere and encapsulate all the related dirt into utils.
2022-11-09 22:43:05 +04:00

46 lines
1.5 KiB
Dart

import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
import 'package:selfprivacy/config/get_it_config.dart';
import 'package:selfprivacy/ui/components/action_button/action_button.dart';
import 'package:selfprivacy/ui/components/brand_alert/brand_alert.dart';
Future<T?> showBrandBottomSheet<T>({
required final BuildContext context,
required final WidgetBuilder builder,
}) =>
showCupertinoModalBottomSheet<T>(
builder: builder,
barrierColor: Colors.black45,
context: context,
shadow: const BoxShadow(color: Colors.transparent),
backgroundColor: Colors.transparent,
);
void showPopUpAlert({
required final String description,
required final String actionButtonTitle,
required final void Function() actionButtonOnPressed,
final void Function()? cancelButtonOnPressed,
final String? alertTitle,
final String? cancelButtonTitle,
}) {
getIt.get<NavigationService>().showPopUpDialog(
BrandAlert(
title: alertTitle ?? 'basis.alert'.tr(),
contentText: description,
actions: [
ActionButton(
text: actionButtonTitle,
isRed: true,
onPressed: actionButtonOnPressed,
),
ActionButton(
text: cancelButtonTitle ?? 'basis.cancel'.tr(),
onPressed: cancelButtonOnPressed,
),
],
),
);
}