-
Notifications
You must be signed in to change notification settings - Fork 32
/
yaru_simple_dialog.dart
79 lines (70 loc) · 2.37 KB
/
yaru_simple_dialog.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import 'package:flutter/material.dart';
import '../constants.dart';
import 'yaru_dialog_title.dart';
class YaruSimpleDialog extends StatelessWidget {
/// Create a [SimpleDialog] with a close button
const YaruSimpleDialog({
super.key,
required this.title,
required this.closeIconData,
required this.children,
this.semanticLabel,
this.alignment,
required this.width,
this.titleTextAlign = TextAlign.center,
});
/// The title of the dialog, displayed in a large font at the top of the [YaruDialogTitle].
final String title;
/// The icon used inside the close button
final IconData closeIconData;
/// The content of the dialog, displayed underneath the title.
final List<Widget> children;
/// The semantic label of the dialog used by accessibility frameworks to
/// announce screen transitions when the dialog is opened and closed.
///
/// If this label is not provided, a semantic label will be inferred from the
/// [title] if it is not null. If there is no title, the label will be taken
/// from [MaterialLocalizations.dialogLabel].
///
/// See also:
///
/// * [SemanticsConfiguration.namesRoute], for a description of how this
/// value is used.
final String? semanticLabel;
/// How to align the [Dialog] on the Screen.
///
/// If null, then [DialogTheme.alignment] is used. If that is also null, the
/// default is [Alignment.center].
final AlignmentGeometry? alignment;
/// The width of the dialog which must be provided and constraints all children with the same width.
///
final double width;
/// Optional [TextAlign] used for the [YaruDialogTitle]
final TextAlign? titleTextAlign;
@override
Widget build(BuildContext context) {
return SizedBox(
width: width,
child: SimpleDialog(
titlePadding: EdgeInsets.zero,
title: YaruDialogTitle(
title: title,
closeIconData: closeIconData,
textAlign: titleTextAlign,
mainAxisAlignment: MainAxisAlignment.center,
),
contentPadding: const EdgeInsets.fromLTRB(
kYaruPagePadding,
kYaruPagePadding,
kYaruPagePadding,
kYaruPagePadding,
),
children: [
for (var child in children) SizedBox(child: child, width: width)
],
semanticLabel: semanticLabel,
alignment: alignment,
),
);
}
}