Skip to content

Commit 204c9f6

Browse files
authored
Misc improvements (#599)
* Refactor InstrinicWidth widget to instrinicWidth property * Rename prefixIcon & suffixIcon to prefix & suffix * Make FButton more customizable * Make FSelectMenuTile auto hide by default * Prepare samples for review * Prepare Forui for review --------- Co-authored-by: Pante <[email protected]>
1 parent a1c9e71 commit 204c9f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+599
-577
lines changed

docs/app/docs/form/button/page.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ dart run forui style create button
4040
```dart copy
4141
FButton(
4242
style: FButtonStyle(...),
43-
intrinsicWidth:true,
43+
mainAxisSize: MainAxisSize.min,
4444
onPress: () {},
4545
child: const Text('Button'),
4646
);
@@ -183,7 +183,7 @@ FButton.raw(
183183

184184
<Tabs items={['Preview', 'Code']}>
185185
<Tabs.Tab>
186-
<Widget name='button' variant='spinner' query={{}}/>
186+
<Widget name='button' variant='circular-progress' query={{}}/>
187187
</Tabs.Tab>
188188
<Tabs.Tab>
189189
```dart {2} copy

docs/app/docs/overlay/dialog/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ A modal dialog interrupts the user with important content and expects a response
2121
mainAxisAlignment: MainAxisAlignment.center,
2222
children: [
2323
FButton(
24-
intrinsicWidth: true,
24+
mainAxisSize: MainAxisSize.min,
2525
onPress: () => showFDialog(
2626
context: context,
2727
builder: (context, style, animation) => FDialog(

docs/app/docs/overlay/popover-menu/page.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ A popover menu displays a menu in a portal aligned to a child.
2828
menu: [
2929
FTileGroup(
3030
children: [
31-
FTile(prefixIcon: const Icon(FIcons.user), title: const Text('Personalization'), onPress: () {}),
32-
FTile(prefixIcon: const Icon(FIcons.paperclip), title: const Text('Add attachments'), onPress: () {}),
33-
FTile(prefixIcon: const Icon(FIcons.qrCode), title: const Text('Scan Document'), onPress: () {}),
31+
FTile(prefix: const Icon(FIcons.user), title: const Text('Personalization'), onPress: () {}),
32+
FTile(prefix: const Icon(FIcons.paperclip), title: const Text('Add attachments'), onPress: () {}),
33+
FTile(prefix: const Icon(FIcons.qrCode), title: const Text('Scan Document'), onPress: () {}),
3434
],
3535
),
3636
FTileGroup(
3737
children: [
38-
FTile(prefixIcon: const Icon(FIcons.list), title: const Text('List View'), onPress: () {}),
39-
FTile(prefixIcon: const Icon(FIcons.layoutGrid), title: const Text('Grid View'), onPress: () {}),
38+
FTile(prefix: const Icon(FIcons.list), title: const Text('List View'), onPress: () {}),
39+
FTile(prefix: const Icon(FIcons.layoutGrid), title: const Text('Grid View'), onPress: () {}),
4040
],
4141
),
4242
],

docs/app/docs/overlay/popover/page.mdx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,11 @@ The popover can be flipped along the overflowing axis to stay within the viewpor
358358
),
359359
),
360360
),
361-
builder: (context, controller, child) => IntrinsicWidth(
362-
child: FButton(style: FButtonStyle.outline(), onPress: controller.toggle, child: const Text('Open popover')),
361+
builder: (context, controller, child) => FButton(
362+
style: FButtonStyle.outline(),
363+
mainAxisSize: MainAxisSize.min,
364+
onPress: controller.toggle,
365+
child: const Text('Open popover'),
363366
),
364367
);
365368
}
@@ -419,8 +422,11 @@ The popover can be shifted along the overflowing axis to stay within the viewpor
419422
),
420423
),
421424
),
422-
builder: (context, controller, child) => IntrinsicWidth(
423-
child: FButton(style: FButtonStyle.outline(), onPress: controller.toggle, child: const Text('Open popover')),
425+
builder: (context, controller, child) => FButton(
426+
style: FButtonStyle.outline(),
427+
mainAxisSize: MainAxisSize.min,
428+
onPress: controller.toggle,
429+
child: const Text('Open popover'),
424430
),
425431
);
426432
}
@@ -480,8 +486,11 @@ The popover is not shifted to stay within the viewport boundaries, even if it ov
480486
),
481487
),
482488
),
483-
builder: (context, controller, child) => IntrinsicWidth(
484-
child: FButton(style: FButtonStyle.outline(), onPress: controller.toggle, child: const Text('Open popover')),
489+
builder: (context, controller, child) => FButton(
490+
style: FButtonStyle.outline(),
491+
mainAxisSize: MainAxisSize.min,
492+
onPress: controller.toggle,
493+
child: const Text('Open popover'),
485494
),
486495
);
487496
}

docs/app/docs/overlay/toast/page.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ showRawFToast(
145145
Widget build(BuildContext context) => FToaster(
146146
child: Center(
147147
child: FButton(
148-
intrinsicWidth: true,
148+
mainAxisSize: MainAxisSize.min,
149149
onPress: () => showFToast(
150150
context: context,
151151
duration: null,
@@ -184,7 +184,7 @@ showRawFToast(
184184
return FToaster(
185185
child: Center(
186186
child: FButton(
187-
intrinsicWidth: true,
187+
mainAxisSize: MainAxisSize.min,
188188
onPress: () => showRawFToast(
189189
context: context,
190190
duration: null,
@@ -228,7 +228,7 @@ showRawFToast(
228228
child: Builder(
229229
builder: (context) => Center(
230230
child: FButton(
231-
intrinsicWidth: true,
231+
mainAxisSize: MainAxisSize.min,
232232
onPress: () => showFToast(context: context, title: const Text('Event has been created')),
233233
child: const Text('Show Toast'),
234234
),
@@ -255,7 +255,7 @@ showRawFToast(
255255
child: Builder(
256256
builder: (context) => Center(
257257
child: FButton(
258-
intrinsicWidth: true,
258+
mainAxisSize: MainAxisSize.min,
259259
onPress: () => showFToast(context: context, title: const Text('Event has been created')),
260260
child: const Text('Show Toast'),
261261
),
@@ -286,7 +286,7 @@ By default, toasts are dismissible by horizontally swiping towards the closest e
286286
child: Builder(
287287
builder: (context) => Center(
288288
child: FButton(
289-
intrinsicWidth: true,
289+
mainAxisSize: MainAxisSize.min,
290290
onPress: () => showFToast(
291291
context: context,
292292
swipeToDismiss: [AxisDirection.down],
@@ -317,7 +317,7 @@ By default, toasts are dismissible by horizontally swiping towards the closest e
317317
child: Builder(
318318
builder: (context) => Center(
319319
child: FButton(
320-
intrinsicWidth: true,
320+
mainAxisSize: MainAxisSize.min,
321321
onPress: () => showFToast(
322322
context: context,
323323
swipeToDismiss: [],

docs/app/docs/overlay/tooltip/page.mdx

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ A tooltip displays information related to a widget when focused, hovered over, o
1818
```dart copy
1919
FTooltip(
2020
tipBuilder: (context, controller) => const Text('Add to library'),
21-
child: IntrinsicWidth(
22-
child: FButton(
23-
style: FButtonStyle.outline(),
24-
onPress: () {},
25-
child: Text('Long press/Hover'),
26-
),
21+
child: FButton(
22+
style: FButtonStyle.outline(),
23+
mainAxisSize: MainAxisSize.min,
24+
onPress: () {},
25+
child: Text('Long press/Hover'),
2726
),
2827
);
2928
```
@@ -73,12 +72,11 @@ You can change how the tooltip is aligned to the button.
7372
tipAnchor: Alignment.topLeft,
7473
childAnchor: Alignment.topRight,
7574
tipBuilder: (context, controller) => const Text('Add to library'),
76-
child: IntrinsicWidth(
77-
child: FButton(
78-
style: FButtonStyle.outline(),
79-
onPress: () {},
80-
child: Text('Long press/Hover'),
81-
),
75+
child: FButton(
76+
style: FButtonStyle.outline(),
77+
mainAxisSize: MainAxisSize.min,
78+
onPress: () {},
79+
child: Text('Long press/Hover'),
8280
),
8381
);
8482
```
@@ -97,12 +95,11 @@ You can change how the tooltip is aligned to the button.
9795
hover: false,
9896
longPress: true,
9997
tipBuilder: (context, controller) => const Text('Add to library'),
100-
child: IntrinsicWidth(
101-
child: FButton(
102-
style: FButtonStyle.outline(),
103-
onPress: () {},
104-
child: Text('Long press'),
105-
),
98+
child: FButton(
99+
style: FButtonStyle.outline(),
100+
mainAxisSize: MainAxisSize.min,
101+
onPress: () {},
102+
child: Text('Long press'),
106103
),
107104
);
108105
```

docs/app/docs/tile/select-menu-tile/page.mdx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ A tile that, when triggered, displays a list of options for the user to pick fro
1818

1919
<Tabs items={['Preview', 'Code']}>
2020
<Tabs.Tab>
21-
<Widget name='select-menu-tile' variant='default' query={{autoHide: 'false'}} height={400}/>
21+
<Widget name='select-menu-tile' variant='default' query={{}} height={400}/>
2222
</Tabs.Tab>
2323
<Tabs.Tab>
2424
```dart copy
@@ -28,9 +28,8 @@ A tile that, when triggered, displays a list of options for the user to pick fro
2828
@override
2929
Widget build(BuildContext context) => FSelectMenuTile(
3030
initialValue: Notification.all,
31-
autoHide: true,
3231
validator: (value) => value == null ? 'Select an item' : null,
33-
prefixIcon: const Icon(FIcons.bell),
32+
prefix: const Icon(FIcons.bell),
3433
title: const Text('Notifications'),
3534
detailsBuilder: (_, values, _) => Text(switch (values.firstOrNull) {
3635
Notification.all => 'All',
@@ -81,12 +80,12 @@ FSelectMenuTile<Value>(
8180
label: const Text('Sidebar'),
8281
description: const Text('Select the items you want to display in the sidebar.'),
8382
errorBuilder: (context, error) => Text(error),
84-
prefixIcon: Icon(FIcons.bell),
83+
prefix: Icon(FIcons.bell),
8584
title: Text('Notifications'),
8685
subtitle: Text('subtitle'),
8786
detailsBuilder: (context, values, child) => Placeholder()m
8887
details: Text('All'),
89-
suffixIcon: Icon(FIcons.chevronsUpDown),
88+
suffix: Icon(FIcons.chevronsUpDown),
9089
onChange: (all) => print(all),
9190
onSelect: (selection) => print(selection),
9291
initialValue: Value.something,
@@ -121,12 +120,12 @@ FSelectMenuTile<Value>.builder(
121120
label: const Text('Sidebar'),
122121
description: const Text('Select the items you want to display in the sidebar.'),
123122
errorBuilder: (context, error) => Text(error),
124-
prefixIcon: Icon(FIcons.bell),
123+
prefix: Icon(FIcons.bell),
125124
title: Text('Notifications'),
126125
subtitle: Text('subtitle'),
127126
detailsBuilder: (context, values, child) => Placeholder()m
128127
details: Text('All'),
129-
suffixIcon: Icon(FIcons.chevronsUpDown),
128+
suffix: Icon(FIcons.chevronsUpDown),
130129
menuBuilder: (context, index) => index < 10 ? FSelectTile(
131130
title: Text('Tile $index'),
132131
value: Value.something,
@@ -140,11 +139,11 @@ FSelectMenuTile<Value>.builder(
140139

141140
## Examples
142141

143-
### Auto Hide
142+
### No Auto Hide
144143

145144
<Tabs items={['Preview', 'Code']}>
146145
<Tabs.Tab>
147-
<Widget name='select-menu-tile' variant='default' query={{autoHide: 'true'}} height={400}/>
146+
<Widget name='select-menu-tile' variant='default' query={{autoHide: 'false'}} height={400}/>
148147
</Tabs.Tab>
149148
<Tabs.Tab>
150149
```dart {6} copy
@@ -154,9 +153,9 @@ FSelectMenuTile<Value>.builder(
154153
@override
155154
Widget build(BuildContext context) => FSelectMenuTile(
156155
initialValue: Notification.all,
157-
autoHide: true,
156+
autoHide: false,
158157
validator: (value) => value == null ? 'Select an item' : null,
159-
prefixIcon: const Icon(FIcons.bell),
158+
prefix: const Icon(FIcons.bell),
160159
title: const Text('Notifications'),
161160
detailsBuilder: (_, values, _) => Text(switch (values.firstOrNull) {
162161
Notification.all => 'All',
@@ -191,7 +190,7 @@ FSelectMenuTile<Value>.builder(
191190
initialValue: Notification.all,
192191
maxHeight: 150,
193192
validator: (value) => value == null ? 'Select an item' : null,
194-
prefixIcon: const Icon(FIcons.bell),
193+
prefix: const Icon(FIcons.bell),
195194
title: const Text('Notifications'),
196195
detailsBuilder: (_, values, _) => Text(switch (values.firstOrNull) {
197196
Notification.all => 'All',
@@ -235,10 +234,9 @@ FSelectMenuTile<Value>.builder(
235234
@override
236235
Widget build(BuildContext context) => FSelectMenuTile.builder(
237236
selectController: controller,
238-
autoHide: true,
239237
maxHeight: 200,
240238
validator: (value) => value == null ? 'Select an item' : null,
241-
prefixIcon: Icon(FIcons.variable),
239+
prefix: Icon(FIcons.variable),
242240
title: const Text('Applicable values'),
243241
menuBuilder: (context, index) => FSelectTile(
244242
title: Text('Tile $index'),
@@ -283,9 +281,8 @@ FSelectMenuTile<Value>.builder(
283281
children: [
284282
FSelectMenuTile(
285283
initialValue: Notification.all,
286-
autoHide: true,
287284
validator: (value) => value == null ? 'Select an item' : null,
288-
prefixIcon: const Icon(FIcons.bell),
285+
prefix: const Icon(FIcons.bell),
289286
title: const Text('Notifications'),
290287
detailsBuilder: (_, values, _) => Text(switch (values.firstOrNull) {
291288
Notification.all => 'All',

0 commit comments

Comments
 (0)