2022-08-29 20:38:28 -06:00
|
|
|
import 'package:wonders/common_libs.dart';
|
|
|
|
import 'package:wonders/ui/common/themed_text.dart';
|
|
|
|
|
|
|
|
Future<bool?> showModal(BuildContext context, {required Widget child}) async {
|
2022-11-29 22:49:25 -07:00
|
|
|
return await showModalBottomSheet(
|
2022-08-29 20:38:28 -06:00
|
|
|
context: context,
|
|
|
|
backgroundColor: $styles.colors.greyStrong,
|
|
|
|
builder: (_) => child,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
}
|
|
|
|
|
|
|
|
class LoadingModal extends StatelessWidget {
|
2024-02-20 13:56:39 -08:00
|
|
|
const LoadingModal({super.key, this.title, this.msg, this.child});
|
2022-08-29 20:38:28 -06:00
|
|
|
final String? title;
|
|
|
|
final String? msg;
|
|
|
|
final Widget? child;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return _BaseContentModal(
|
|
|
|
title: title,
|
|
|
|
msg: msg,
|
|
|
|
buttons: const [],
|
|
|
|
child: child,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class OkModal extends StatelessWidget {
|
2024-02-20 13:56:39 -08:00
|
|
|
const OkModal({super.key, this.title, this.msg, this.child});
|
2022-08-29 20:38:28 -06:00
|
|
|
final String? title;
|
|
|
|
final String? msg;
|
|
|
|
final Widget? child;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return _BaseContentModal(
|
|
|
|
title: title,
|
|
|
|
msg: msg,
|
|
|
|
buttons: [
|
2022-11-29 22:49:25 -07:00
|
|
|
AppBtn.from(
|
|
|
|
text: $strings.appModalsButtonOk,
|
|
|
|
expand: true,
|
|
|
|
isSecondary: true,
|
|
|
|
onPressed: () => Navigator.of(context).pop(true)),
|
2022-08-29 20:38:28 -06:00
|
|
|
],
|
|
|
|
child: child,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class OkCancelModal extends StatelessWidget {
|
2024-02-20 13:56:39 -08:00
|
|
|
const OkCancelModal({super.key, this.title, this.msg, this.child});
|
2022-08-29 20:38:28 -06:00
|
|
|
final String? title;
|
|
|
|
final String? msg;
|
|
|
|
final Widget? child;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return _BaseContentModal(
|
|
|
|
title: title,
|
|
|
|
msg: msg,
|
|
|
|
buttons: [
|
2022-11-29 22:49:25 -07:00
|
|
|
AppBtn.from(
|
|
|
|
text: $strings.appModalsButtonOk,
|
|
|
|
expand: true,
|
|
|
|
isSecondary: true,
|
|
|
|
onPressed: () => Navigator.of(context).pop(true)),
|
2022-08-29 20:38:28 -06:00
|
|
|
Gap($styles.insets.xs),
|
2022-11-29 22:49:25 -07:00
|
|
|
AppBtn.from(
|
|
|
|
text: $strings.appModalsButtonCancel, expand: true, onPressed: () => Navigator.of(context).pop(false)),
|
2022-08-29 20:38:28 -06:00
|
|
|
],
|
|
|
|
child: child,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Allows for a title, msg and body widget
|
|
|
|
class _BaseContentModal extends StatelessWidget {
|
|
|
|
final String? title;
|
|
|
|
final String? msg;
|
|
|
|
final Widget? child;
|
|
|
|
final List<Widget> buttons;
|
|
|
|
|
2024-02-20 13:56:39 -08:00
|
|
|
const _BaseContentModal({this.title, this.msg, required this.buttons, this.child});
|
2022-08-29 20:38:28 -06:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-12-19 14:13:25 -07:00
|
|
|
return IntrinsicHeight(
|
|
|
|
child: Center(
|
|
|
|
child: SizedBox(
|
|
|
|
width: $styles.sizes.maxContentWidth3,
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.all($styles.insets.lg),
|
|
|
|
child: LightText(
|
|
|
|
child: SeparatedColumn(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
separatorBuilder: () => Gap($styles.insets.md),
|
|
|
|
children: [
|
|
|
|
if (title != null) Text(title!, style: $styles.text.h2),
|
|
|
|
if (child != null) child!,
|
|
|
|
if (msg != null) Text(msg!, style: $styles.text.body),
|
|
|
|
Gap($styles.insets.md),
|
|
|
|
Column(children: buttons.map((e) => e).toList())
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-08-29 20:38:28 -06:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|