only-bible-app v3.7.2+24
git clone https://git.pyrossh.dev/only-bible-app
The only bible app you will ever need. No ads. No in-app purchases. No distractions.
lib/dialogs.dart
| 0228ae8 | 1 | import "package:flutter/material.dart"; |
| 0228ae8 | 2 | |
| 0228ae8 | 3 | void showAlert(BuildContext context, String title, String message) { |
| 0228ae8 | 4 | showDialog( |
| 0228ae8 | 5 | context: context, |
| 0228ae8 | 6 | barrierColor: Colors.black54, |
| 0228ae8 | 7 | builder: (_) { |
| 0228ae8 | 8 | return AlertDialog( |
| 0228ae8 | 9 | title: Text(title), |
| 0228ae8 | 10 | content: Text(message), |
| 0228ae8 | 11 | actionsAlignment: MainAxisAlignment.center, |
| 0228ae8 | 12 | actionsOverflowButtonSpacing: 8.0, |
| 0228ae8 | 13 | actions: [ |
| 0228ae8 | 14 | TextButton( |
| 0228ae8 | 15 | onPressed: () { |
| 0228ae8 | 16 | Navigator.of(context).pop(); |
| 0228ae8 | 17 | }, |
| 0228ae8 | 18 | child: const Text("OK"), |
| 0228ae8 | 19 | ), |
| 0228ae8 | 20 | ], |
| 0228ae8 | 21 | ); |
| 0228ae8 | 22 | }, |
| 0228ae8 | 23 | ); |
| 0228ae8 | 24 | } |
| 0228ae8 | 25 | |
| 0228ae8 | 26 | void showError(BuildContext context, String message) { |
| 0228ae8 | 27 | showAlert(context, "Error", message); |
| 0228ae8 | 28 | } |
| 0228ae8 | 29 | |
| 0228ae8 | 30 | Future<bool> showConfirm( |
| 0228ae8 | 31 | BuildContext context, |
| 0228ae8 | 32 | String title, |
| 0228ae8 | 33 | String message, |
| 0228ae8 | 34 | ) async { |
| 0228ae8 | 35 | const buttonStyle = ButtonStyle( |
| 0228ae8 | 36 | padding: WidgetStatePropertyAll( |
| 0228ae8 | 37 | EdgeInsets.symmetric(horizontal: 20, vertical: 10), |
| 0228ae8 | 38 | ), |
| 0228ae8 | 39 | textStyle: WidgetStatePropertyAll(TextStyle(fontSize: 13)), |
| 0228ae8 | 40 | ); |
| 0228ae8 | 41 | final result = await showDialog<bool>( |
| 0228ae8 | 42 | context: context, |
| 0228ae8 | 43 | barrierColor: Colors.black54, |
| 0228ae8 | 44 | builder: (dialogContext) { |
| 0228ae8 | 45 | return AlertDialog( |
| 0228ae8 | 46 | title: Text(title), |
| 0228ae8 | 47 | content: Text(message), |
| 0228ae8 | 48 | actionsAlignment: MainAxisAlignment.center, |
| 0228ae8 | 49 | actionsOverflowButtonSpacing: 8.0, |
| 0228ae8 | 50 | actions: [ |
| 0228ae8 | 51 | TextButton( |
| 0228ae8 | 52 | style: buttonStyle, |
| 0228ae8 | 53 | onPressed: () => Navigator.of(dialogContext).pop(false), |
| 0228ae8 | 54 | child: const Text("Cancel"), |
| 0228ae8 | 55 | ), |
| 0228ae8 | 56 | FilledButton( |
| 0228ae8 | 57 | style: buttonStyle, |
| 0228ae8 | 58 | onPressed: () => Navigator.of(dialogContext).pop(true), |
| 0228ae8 | 59 | child: const Text("Continue"), |
| 0228ae8 | 60 | ), |
| 0228ae8 | 61 | ], |
| 0228ae8 | 62 | ); |
| 0228ae8 | 63 | }, |
| 0228ae8 | 64 | ); |
| 0228ae8 | 65 | return result ?? false; |
| 0228ae8 | 66 | } |