Skip to content

Commit

Permalink
Add global showDialog method using non-root navigator (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dohmanlechx authored Sep 13, 2023
1 parent 3b09617 commit 117245b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
11 changes: 11 additions & 0 deletions lib/src/widgets/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,14 @@ double sideBarSizeProperties(BuildContext context) {
final factor = isLargeScreen(context) ? 0.5 : 1;
return screenWidth * factor;
}

Future<void> showPopup({
required BuildContext context,
required WidgetBuilder builder,
}) async {
return showDialog<void>(
context: context,
builder: builder,
useRootNavigator: false,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class _BorderRadiusPropertyState extends State<BorderRadiusProperty> {
}
}

Future<void> show() => showDialog<void>(
Future<void> show() => showPopup(
context: context,
builder: (_) => FourIntegerForm(
_confirmEdition,
Expand Down
3 changes: 2 additions & 1 deletion lib/src/widgets/property_widgets/color_property.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:dashbook/dashbook.dart';
import 'package:dashbook/src/widgets/helpers.dart';
import 'package:dashbook/src/widgets/property_widgets/widgets/property_dialog.dart';
import 'package:flutter/material.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
Expand Down Expand Up @@ -29,7 +30,7 @@ class ColorPropertyState extends State<ColorProperty> {
}

// raise the [showDialog] widget
Future<void> show() => showDialog<void>(
Future<void> show() => showPopup(
context: context,
builder: (_) => PropertyDialog(
title: 'Pick a color!',
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/property_widgets/edge_insets_property.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class _EdgeInsetsPropertyState extends State<EdgeInsetsProperty> {
}
}

Future<void> show() => showDialog<void>(
Future<void> show() => showPopup(
context: context,
builder: (_) => FourIntegerForm(
_confirmEdition,
Expand Down
5 changes: 2 additions & 3 deletions lib/src/widgets/widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ class _DashbookState extends State<Dashbook> {
tooltip: 'Instructions',
icon: Icons.info,
onClick: () {
showDialog<void>(
showPopup(
context: context,
builder: (_) {
return InstructionsDialog(
Expand Down Expand Up @@ -347,9 +347,8 @@ class _DashbookState extends State<Dashbook> {
tooltip: 'Choose theme',
icon: Icons.palette,
onClick: () {
showDialog<void>(
showPopup(
context: context,
useRootNavigator: false,
builder: (_) => AlertDialog(
title: const Text('Theme chooser'),
content: DropdownButton<ThemeData>(
Expand Down

0 comments on commit 117245b

Please sign in to comment.