61 lines
2.1 KiB
Dart
61 lines
2.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import './src/models/models.exports.dart';
|
|
export './src/models/models.exports.dart';
|
|
|
|
class AstromicDialogHelper {
|
|
/// Show a dialog.
|
|
static Future<T?> show<T>(
|
|
BuildContext context, {
|
|
required Widget contentSection,
|
|
Widget? stackedCloseWidget,
|
|
AstromicDialogConfiguration configuration = const AstromicDialogConfiguration(),
|
|
AstromicDialogStyle style = const AstromicDialogStyle(),
|
|
void Function(T?)? onClose,
|
|
}) async {
|
|
//
|
|
return await showDialog<T>(
|
|
context: context,
|
|
useSafeArea: configuration.safeAreaAware,
|
|
builder: (BuildContext _) {
|
|
return Container(
|
|
margin: style.placement,
|
|
//
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
Stack(
|
|
children: [
|
|
Container(
|
|
width: (style.width ?? 0) - ((style.placement?.start ?? 0) + (style.placement?.start ?? 0)),
|
|
//
|
|
padding: style.contentPadding,
|
|
decoration: BoxDecoration(
|
|
color: style.backgroundColor,
|
|
borderRadius: style.radius,
|
|
),
|
|
child: contentSection,
|
|
),
|
|
if (stackedCloseWidget != null)
|
|
Positioned.directional(
|
|
textDirection: style.textDirection,
|
|
start: style.closeWidgetPlacement?.start,
|
|
end: style.closeWidgetPlacement?.end,
|
|
top: style.closeWidgetPlacement?.top,
|
|
//
|
|
child: stackedCloseWidget,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
});
|
|
//
|
|
}
|
|
}
|