Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dialog long text #246

Merged
merged 2 commits into from
Mar 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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