mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-10 16:00:28 -07:00
Init repo
This commit is contained in:
commit
764b6034e3
566 changed files with 212335 additions and 0 deletions
71
lib/screens/shared/default_alert_dialog.dart
Normal file
71
lib/screens/shared/default_alert_dialog.dart
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<void> showDefaultAlertDialog(
|
||||
BuildContext context,
|
||||
String title,
|
||||
String? content,
|
||||
FutureOr Function(BuildContext context)? accept,
|
||||
String? acceptTitle,
|
||||
FutureOr Function(BuildContext context)? decline,
|
||||
String declineTitle,
|
||||
) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog.adaptive(
|
||||
title: Text(title),
|
||||
content: content != null ? Text(content) : null,
|
||||
actions: [
|
||||
if (decline != null)
|
||||
ElevatedButton(
|
||||
onPressed: () => decline.call(context),
|
||||
child: Text(declineTitle),
|
||||
),
|
||||
if (accept != null)
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.errorContainer,
|
||||
foregroundColor: Theme.of(context).colorScheme.onErrorContainer,
|
||||
),
|
||||
onPressed: () => accept.call(context),
|
||||
child: Text(acceptTitle ?? "Accept"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> showDefaultActionDialog(
|
||||
BuildContext context,
|
||||
String title,
|
||||
String? content,
|
||||
FutureOr Function(BuildContext context)? accept,
|
||||
String? acceptTitle,
|
||||
FutureOr Function(BuildContext context)? decline,
|
||||
String declineTitle,
|
||||
) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog.adaptive(
|
||||
title: Text(title),
|
||||
content: content != null ? Text(content) : null,
|
||||
actions: [
|
||||
if (decline != null)
|
||||
ElevatedButton(
|
||||
onPressed: () => decline.call(context),
|
||||
child: Text(declineTitle),
|
||||
),
|
||||
if (accept != null)
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
|
||||
foregroundColor: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
),
|
||||
onPressed: () => accept.call(context),
|
||||
child: Text(acceptTitle ?? "Accept"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue