passo_mobile_app/lib/utils/alerts.dart

161 lines
4.1 KiB
Dart
Raw Permalink Normal View History

2022-12-20 06:26:37 +00:00
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:flutter/material.dart';
2023-02-27 06:26:27 +00:00
import 'package:unit2/theme-data.dart/btn-style.dart';
import 'package:unit2/theme-data.dart/colors.dart';
2022-12-20 06:26:37 +00:00
import 'package:unit2/utils/global.dart';
2024-07-11 01:27:35 +00:00
confirmAlert(context, Function() yes, String title, String subtitle) {
2022-12-20 06:26:37 +00:00
AwesomeDialog(
context: context,
dialogType: DialogType.question,
borderSide: const BorderSide(
color: Colors.green,
width: 0,
),
width: blockSizeHorizontal * 90,
buttonsBorderRadius: const BorderRadius.all(
Radius.circular(2),
),
dismissOnTouchOutside: false,
dismissOnBackKeyPress: false,
// onDismissCallback: (type) {
// ScaffoldMessenger.of(context).showSnackBar(
// SnackBar(
// content: Text('Dismissed by $type'),
// ),
// );
// },
headerAnimationLoop: false,
animType: AnimType.bottomSlide,
2023-02-15 05:23:06 +00:00
title: title,
desc: subtitle,
2022-12-20 06:26:37 +00:00
btnOkText: "Yes",
btnCancelText: "No",
showCloseIcon: false,
btnCancelOnPress: () {},
btnOkOnPress: yes,
).show();
}
2024-07-11 01:27:35 +00:00
confirmAlertWithCancel(
context,
Function() yes,
Function() no,
String title,
String subtitle,
) {
2023-04-05 00:54:24 +00:00
AwesomeDialog(
context: context,
dialogType: DialogType.question,
borderSide: const BorderSide(
color: Colors.green,
width: 0,
),
width: blockSizeHorizontal * 90,
buttonsBorderRadius: const BorderRadius.all(
Radius.circular(2),
),
dismissOnTouchOutside: false,
dismissOnBackKeyPress: false,
// onDismissCallback: (type) {
// ScaffoldMessenger.of(context).showSnackBar(
// SnackBar(
// content: Text('Dismissed by $type'),
// ),
// );
// },
headerAnimationLoop: false,
animType: AnimType.bottomSlide,
title: title,
desc: subtitle,
btnOkText: "Yes",
btnCancelText: "No",
showCloseIcon: false,
btnCancelOnPress: no,
btnOkOnPress: yes,
).show();
}
2024-07-11 01:27:35 +00:00
confirmAlertWithCancelCustom(context, Function() yes, Function() no,
String title, String subtitle, okText, cancelText) {
2022-12-20 06:26:37 +00:00
AwesomeDialog(
context: context,
2024-07-11 01:27:35 +00:00
dialogType: DialogType.question,
borderSide: const BorderSide(
color: Colors.green,
width: 0,
),
width: blockSizeHorizontal * 90,
buttonsBorderRadius: const BorderRadius.all(
Radius.circular(2),
),
dismissOnTouchOutside: false,
dismissOnBackKeyPress: false,
// onDismissCallback: (type) {
// ScaffoldMessenger.of(context).showSnackBar(
// SnackBar(
// content: Text('Dismissed by $type'),
// ),
// );
// },
2022-12-20 06:26:37 +00:00
headerAnimationLoop: false,
2024-07-11 01:27:35 +00:00
animType: AnimType.bottomSlide,
2022-12-20 06:26:37 +00:00
title: title,
2024-07-11 01:27:35 +00:00
desc: subtitle,
btnOkText: okText,
btnCancelText: cancelText,
showCloseIcon: false,
btnCancelOnPress: no,
btnOkOnPress: yes,
2023-02-23 00:53:14 +00:00
).show();
}
2024-07-11 01:27:35 +00:00
errorAlert(context, title, description, Function() func) {
2023-02-23 00:53:14 +00:00
AwesomeDialog(
2024-07-11 01:27:35 +00:00
width: blockSizeHorizontal * 90,
context: context,
dialogType: DialogType.error,
animType: AnimType.scale,
headerAnimationLoop: false,
title: title,
desc: description,
btnOk: SizedBox(
height: 50,
child: ElevatedButton(
onPressed: func,
style: mainBtnStyle(primary, Colors.transparent, second),
child: const Text("OK")),
)).show();
}
2024-07-11 01:27:35 +00:00
successAlert(context, title, description, Function() func) {
AwesomeDialog(
width: blockSizeHorizontal * 90,
context: context,
dialogType: DialogType.success,
animType: AnimType.scale,
headerAnimationLoop: false,
title: title,
desc: description,
btnOk: SizedBox(
height: 50,
child: ElevatedButton(
style: mainBtnStyle(success2, Colors.transparent, success),
onPressed: func,
child: const Text("OK")),
)).show();
}
okAlert(context, title, description) {
AwesomeDialog(
width: blockSizeHorizontal * 90,
context: context,
dialogType: DialogType.error,
animType: AnimType.scale,
headerAnimationLoop: false,
title: title,
desc: description,
btnOkOnPress: () {},
).show();
}