2024-04-05 22:03:04 -04:00
|
|
|
import 'package:awesome_extensions/awesome_extensions.dart';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2024-04-12 20:55:05 -04:00
|
|
|
import '../theme.dart';
|
2024-04-05 22:03:04 -04:00
|
|
|
|
|
|
|
class StyledDialog extends StatelessWidget {
|
|
|
|
const StyledDialog({required this.title, required this.child, super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final theme = Theme.of(context);
|
|
|
|
final scale = theme.extension<ScaleScheme>()!;
|
|
|
|
final textTheme = theme.textTheme;
|
|
|
|
|
|
|
|
return AlertDialog(
|
|
|
|
elevation: 0,
|
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(16)),
|
|
|
|
),
|
|
|
|
contentPadding: const EdgeInsets.all(4),
|
2024-04-12 20:55:05 -04:00
|
|
|
backgroundColor: scale.primaryScale.dialogBorder,
|
2024-04-05 22:03:04 -04:00
|
|
|
title: Text(
|
|
|
|
title,
|
2024-04-12 20:55:05 -04:00
|
|
|
style: textTheme.titleMedium!
|
|
|
|
.copyWith(color: scale.primaryScale.borderText),
|
2024-04-05 22:03:04 -04:00
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
titlePadding: const EdgeInsets.fromLTRB(4, 4, 4, 4),
|
|
|
|
content: DecoratedBox(
|
|
|
|
decoration: ShapeDecoration(
|
|
|
|
color: scale.primaryScale.border,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(16))),
|
|
|
|
child: DecoratedBox(
|
|
|
|
decoration: ShapeDecoration(
|
|
|
|
color: scale.primaryScale.appBackground,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(12))),
|
|
|
|
child: child.paddingAll(0))));
|
|
|
|
}
|
|
|
|
|
|
|
|
static Future<T?> show<T>(
|
|
|
|
{required BuildContext context,
|
|
|
|
required String title,
|
|
|
|
required Widget child}) async =>
|
|
|
|
showDialog<T>(
|
|
|
|
context: context,
|
|
|
|
builder: (context) => StyledDialog(title: title, child: child));
|
|
|
|
|
|
|
|
final String title;
|
|
|
|
final Widget child;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
|
|
|
super.debugFillProperties(properties);
|
|
|
|
properties.add(StringProperty('title', title));
|
|
|
|
}
|
|
|
|
}
|