1+ import 'dart:math' as math;
2+
13import 'package:flutter/material.dart' ;
24import 'package:mix_annotations/mix_annotations.dart' ;
35import 'package:remix/remix.dart' ;
@@ -9,10 +11,32 @@ part 'dialog.g.dart';
911/// Fortal dialog size presets matching Radix Themes 3.3.0.
1012enum FortalDialogSize { size1, size2, size3, size4 }
1113
14+ /// Fortal dialog vertical alignment matching Radix Themes 3.3.0.
15+ enum FortalDialogAlign { start, center }
16+
17+ final _dialogViewportInsets = ContextToken <EdgeInsetsGeometry >((context) {
18+ final safeArea = MediaQuery .paddingOf (context);
19+ final viewportHeight = MediaQuery .sizeOf (context).height;
20+ final horizontal = FortalTokens .space4.resolve (context);
21+ final vertical = FortalTokens .space6.resolve (context);
22+
23+ return EdgeInsets .fromLTRB (
24+ math.max (safeArea.left, horizontal),
25+ math.max (safeArea.top, vertical),
26+ math.max (safeArea.right, horizontal),
27+ math.max (safeArea.bottom, math.max (vertical, viewportHeight * 0.06 )),
28+ );
29+ });
30+
1231/// Fortal-themed preset for [RemixDialog] .
32+ ///
33+ /// The generated [FortalDialog] defaults to [FortalDialogSize.size3] ,
34+ /// [FortalDialogAlign.center] , fills up to 600 logical pixels, preserves safe
35+ /// viewport insets, and is modal.
1336@MixWidget (target: RemixDialog .new )
1437DialogStyler fortalDialogStyle ({
1538 FortalDialogSize size = FortalDialogSize .size3,
39+ FortalDialogAlign align = FortalDialogAlign .center,
1640}) {
1741 final radius = switch (size) {
1842 FortalDialogSize .size1 || FortalDialogSize .size2 => FortalTokens .radius4 (),
@@ -24,8 +48,20 @@ DialogStyler fortalDialogStyle({
2448 FortalDialogSize .size3 => FortalTokens .space5 (),
2549 FortalDialogSize .size4 => FortalTokens .space6 (),
2650 };
51+ final alignment = switch (align) {
52+ FortalDialogAlign .start => Alignment .topCenter,
53+ FortalDialogAlign .center => Alignment .center,
54+ };
2755
2856 return DialogStyler ()
57+ .wrap (
58+ .modifier (
59+ PaddingModifierMix .create (padding: Prop .token (_dialogViewportInsets)),
60+ ).align (alignment: alignment).orderOfModifiers ([
61+ PaddingModifier ,
62+ AlignModifier ,
63+ ]),
64+ )
2965 .title (
3066 .style (FortalTokens .text5.mix ())
3167 .fontWeight (FortalTokens .fontWeightBold ())
@@ -46,6 +82,7 @@ DialogStyler fortalDialogStyle({
4682 .spacing (FortalTokens .space3 ())
4783 .marginTop (FortalTokens .space5 ()),
4884 )
85+ .width (600 )
4986 .padding (.all (padding))
5087 .borderRadius (.all (radius))
5188 .color (FortalTokens .colorPanel ())
0 commit comments