Skip to content

Commit

Permalink
Dialog long content (bdlukaa#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-hann committed Mar 26, 2022
2 parents 11d5864 + 428c405 commit 29cec32
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 45 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Date format: DD/MM/YYYY
- Implement `CommandBar` with dynamic overflow ([#232](https://github.com/bdlukaa/fluent_ui/pull/232))
- Add `DynamicOverflow` layout widget, for one-run horizontal or vertical layout with an overflow widget
- Add `HorizontalScrollView` helper widget, with mouse wheel horizontal scrolling
- Long `content` widget no longer overflow in `ContentDialog` ([#242](https://github.com/bdlukaa/fluent_ui/issues/242))

## [3.9.1] - Input Update - [25/02/2022]

Expand Down
50 changes: 25 additions & 25 deletions example/lib/screens/inputs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,31 +112,7 @@ class _InputsPageState extends State<InputsPage> {
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Button(
child: const Text('Show Dialog'),
onPressed: disabled
? null
: () {
showDialog(
context: context,
builder: (_) => ContentDialog(
title: const Text('Delete file permanently?'),
content: const Text(
'If you delete this file, you won\'t be able to recover it. Do you want to delete it?',
),
actions: [
Button(
child: const Text('Delete'),
onPressed: () {
// Delete file here
},
),
FilledButton(
child: const Text('Cancel'),
onPressed: () => Navigator.pop(context),
),
],
),
);
},
onPressed: disabled ? null : _showDialog,
),
spacer,
FilledButton(
Expand Down Expand Up @@ -254,4 +230,28 @@ class _InputsPageState extends State<InputsPage> {
),
);
}

void _showDialog() {
showDialog(
context: context,
builder: (_) => ContentDialog(
title: const Text('Delete file permanently?'),
content: const Text(
'If you delete this file, you won\'t be able to recover it. Do you want to delete it?',
),
actions: [
Button(
child: const Text('Delete'),
onPressed: () {
// Delete file here
},
),
FilledButton(
child: const Text('Cancel'),
onPressed: () => Navigator.pop(context),
),
],
),
);
}
}
45 changes: 25 additions & 20 deletions lib/src/controls/surfaces/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,28 +91,33 @@ class ContentDialog extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: style.padding ?? EdgeInsets.zero,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (title != null)
Padding(
padding: style.titlePadding ?? EdgeInsets.zero,
child: DefaultTextStyle(
style: style.titleStyle ?? const TextStyle(),
child: title!,
Flexible(
child: Padding(
padding: style.padding ?? EdgeInsets.zero,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (title != null)
Padding(
padding: style.titlePadding ?? EdgeInsets.zero,
child: DefaultTextStyle(
style: style.titleStyle ?? const TextStyle(),
child: title!,
),
),
),
if (content != null)
Padding(
padding: style.bodyPadding ?? EdgeInsets.zero,
child: DefaultTextStyle(
style: style.bodyStyle ?? const TextStyle(),
child: content!,
if (content != null)
Flexible(
child: Padding(
padding: style.bodyPadding ?? EdgeInsets.zero,
child: DefaultTextStyle(
style: style.bodyStyle ?? const TextStyle(),
child: content!,
),
),
),
),
],
],
),
),
),
if (actions != null)
Expand Down

0 comments on commit 29cec32

Please sign in to comment.