@@ -7,12 +7,16 @@ import '../utils/colors.dart';
77import '../utils/icons.dart' ;
88import '../utils/launch_url.dart' ;
99import 'create_control.dart' ;
10+ import 'cupertino_button.dart' ;
11+ import 'cupertino_dialog_action.dart' ;
12+ import 'flet_store_mixin.dart' ;
1013
1114class OutlinedButtonControl extends StatefulWidget {
1215 final Control ? parent;
1316 final Control control;
1417 final List <Control > children;
1518 final bool parentDisabled;
19+ final bool ? parentAdaptive;
1620 final FletControlBackend backend;
1721
1822 const OutlinedButtonControl (
@@ -21,13 +25,15 @@ class OutlinedButtonControl extends StatefulWidget {
2125 required this .control,
2226 required this .children,
2327 required this .parentDisabled,
28+ required this .parentAdaptive,
2429 required this .backend});
2530
2631 @override
2732 State <OutlinedButtonControl > createState () => _OutlinedButtonControlState ();
2833}
2934
30- class _OutlinedButtonControlState extends State <OutlinedButtonControl > {
35+ class _OutlinedButtonControlState extends State <OutlinedButtonControl >
36+ with FletStoreMixin {
3137 late final FocusNode _focusNode;
3238 String ? _lastFocusValue;
3339
@@ -92,62 +98,86 @@ class _OutlinedButtonControlState extends State<OutlinedButtonControl> {
9298 }
9399 : null ;
94100
95- OutlinedButton ? button;
96-
97- var theme = Theme .of (context);
98-
99- var style = parseButtonStyle (Theme .of (context), widget.control, "style" ,
100- defaultForegroundColor: theme.colorScheme.primary,
101- defaultBackgroundColor: Colors .transparent,
102- defaultOverlayColor: Colors .transparent,
103- defaultShadowColor: Colors .transparent,
104- defaultSurfaceTintColor: Colors .transparent,
105- defaultElevation: 0 ,
106- defaultPadding: const EdgeInsets .all (8 ),
107- defaultBorderSide: BorderSide (color: theme.colorScheme.outline),
108- defaultShape: theme.useMaterial3
109- ? const StadiumBorder ()
110- : RoundedRectangleBorder (borderRadius: BorderRadius .circular (4 )));
111-
112- if (icon != null ) {
113- button = OutlinedButton .icon (
114- autofocus: autofocus,
115- focusNode: _focusNode,
116- onPressed: onPressed,
117- onLongPress: onLongPressHandler,
118- style: style,
119- icon: Icon (
120- icon,
121- color: iconColor,
122- ),
123- label: Text (text));
124- } else if (contentCtrls.isNotEmpty) {
125- button = OutlinedButton (
126- autofocus: autofocus,
127- focusNode: _focusNode,
128- onPressed: onPressed,
129- onLongPress: onLongPressHandler,
130- onHover: onHoverHandler,
131- style: style,
132- child:
133- createControl (widget.control, contentCtrls.first.id, disabled));
134- } else {
135- button = OutlinedButton (
136- autofocus: autofocus,
137- focusNode: _focusNode,
138- style: style,
139- onPressed: onPressed,
140- onLongPress: onLongPressHandler,
141- onHover: onHoverHandler,
142- child: Text (text));
143- }
144-
145- var focusValue = widget.control.attrString ("focus" );
146- if (focusValue != null && focusValue != _lastFocusValue) {
147- _lastFocusValue = focusValue;
148- _focusNode.requestFocus ();
149- }
150-
151- return constrainedControl (context, button, widget.parent, widget.control);
101+ return withPagePlatform ((context, platform) {
102+ bool ? adaptive =
103+ widget.control.attrBool ("adaptive" ) ?? widget.parentAdaptive;
104+ if (adaptive == true &&
105+ (platform == TargetPlatform .iOS ||
106+ platform == TargetPlatform .macOS)) {
107+ return widget.control.name == "action" &&
108+ (widget.parent? .type == "alertdialog" ||
109+ widget.parent? .type == "cupertinoalertdialog" )
110+ ? CupertinoDialogActionControl (
111+ control: widget.control,
112+ parentDisabled: widget.parentDisabled,
113+ parentAdaptive: adaptive,
114+ children: widget.children,
115+ backend: widget.backend)
116+ : CupertinoButtonControl (
117+ control: widget.control,
118+ parentDisabled: widget.parentDisabled,
119+ parentAdaptive: adaptive,
120+ children: widget.children,
121+ backend: widget.backend);
122+ }
123+
124+ OutlinedButton ? button;
125+
126+ var theme = Theme .of (context);
127+
128+ var style = parseButtonStyle (Theme .of (context), widget.control, "style" ,
129+ defaultForegroundColor: theme.colorScheme.primary,
130+ defaultBackgroundColor: Colors .transparent,
131+ defaultOverlayColor: Colors .transparent,
132+ defaultShadowColor: Colors .transparent,
133+ defaultSurfaceTintColor: Colors .transparent,
134+ defaultElevation: 0 ,
135+ defaultPadding: const EdgeInsets .all (8 ),
136+ defaultBorderSide: BorderSide (color: theme.colorScheme.outline),
137+ defaultShape: theme.useMaterial3
138+ ? const StadiumBorder ()
139+ : RoundedRectangleBorder (borderRadius: BorderRadius .circular (4 )));
140+
141+ if (icon != null ) {
142+ button = OutlinedButton .icon (
143+ autofocus: autofocus,
144+ focusNode: _focusNode,
145+ onPressed: onPressed,
146+ onLongPress: onLongPressHandler,
147+ style: style,
148+ icon: Icon (
149+ icon,
150+ color: iconColor,
151+ ),
152+ label: Text (text));
153+ } else if (contentCtrls.isNotEmpty) {
154+ button = OutlinedButton (
155+ autofocus: autofocus,
156+ focusNode: _focusNode,
157+ onPressed: onPressed,
158+ onLongPress: onLongPressHandler,
159+ onHover: onHoverHandler,
160+ style: style,
161+ child:
162+ createControl (widget.control, contentCtrls.first.id, disabled));
163+ } else {
164+ button = OutlinedButton (
165+ autofocus: autofocus,
166+ focusNode: _focusNode,
167+ style: style,
168+ onPressed: onPressed,
169+ onLongPress: onLongPressHandler,
170+ onHover: onHoverHandler,
171+ child: Text (text));
172+ }
173+
174+ var focusValue = widget.control.attrString ("focus" );
175+ if (focusValue != null && focusValue != _lastFocusValue) {
176+ _lastFocusValue = focusValue;
177+ _focusNode.requestFocus ();
178+ }
179+
180+ return constrainedControl (context, button, widget.parent, widget.control);
181+ });
152182 }
153183}
0 commit comments