Initial commit
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:forui/forui.dart';
|
||||
|
||||
import '../theme/app_theme_scope.dart';
|
||||
|
||||
Future<T?> showAppRawDialog<T>(
|
||||
BuildContext context, {
|
||||
required WidgetBuilder builder,
|
||||
BoxConstraints constraints = const BoxConstraints(
|
||||
minWidth: 280,
|
||||
maxWidth: 560,
|
||||
),
|
||||
bool useRootNavigator = false,
|
||||
bool barrierDismissible = true,
|
||||
}) {
|
||||
return showFDialog<T>(
|
||||
context: context,
|
||||
useRootNavigator: useRootNavigator,
|
||||
barrierDismissible: barrierDismissible,
|
||||
builder: (dialogContext, _, animation) => AppThemeScope(
|
||||
child: FDialog.raw(
|
||||
animation: animation,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
constraints: constraints,
|
||||
builder: (_, _) => builder(dialogContext),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> showAppConfirmDialog(
|
||||
BuildContext context, {
|
||||
required String title,
|
||||
required Widget body,
|
||||
required String confirmLabel,
|
||||
String cancelLabel = '取消',
|
||||
bool destructive = false,
|
||||
}) async {
|
||||
final confirmed = await showFDialog<bool>(
|
||||
context: context,
|
||||
builder: (ctx, _, animation) => AppThemeScope(
|
||||
child: FDialog.adaptive(
|
||||
animation: animation,
|
||||
title: Text(title),
|
||||
body: body,
|
||||
actions: [
|
||||
FButton(
|
||||
onPress: () => Navigator.of(ctx).pop(true),
|
||||
variant: destructive
|
||||
? FButtonVariant.destructive
|
||||
: FButtonVariant.primary,
|
||||
child: Text(confirmLabel),
|
||||
),
|
||||
FButton(
|
||||
onPress: () => Navigator.of(ctx).pop(false),
|
||||
variant: FButtonVariant.outline,
|
||||
child: Text(cancelLabel),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
return confirmed == true;
|
||||
}
|
||||
Reference in New Issue
Block a user