From 95aec4b3a5efe3c004b5db556fd2533bdde1d37d Mon Sep 17 00:00:00 2001 From: Juan Gilsanz Polo Date: Sun, 8 Oct 2023 00:19:32 +0200 Subject: [PATCH] Adapted more modals --- lib/screens/filters/add_button.dart | 43 ++++++++++--------- lib/screens/filters/add_custom_rule.dart | 53 +++++++++++++----------- 2 files changed, 51 insertions(+), 45 deletions(-) diff --git a/lib/screens/filters/add_button.dart b/lib/screens/filters/add_button.dart index 3cbedc9..195d7af 100644 --- a/lib/screens/filters/add_button.dart +++ b/lib/screens/filters/add_button.dart @@ -56,27 +56,30 @@ class AddFiltersButton extends StatelessWidget { } void openAddCustomRule() { - if (width > 700 || !(Platform.isAndroid || Platform.isIOS)) { - showDialog( - context: context, - builder: (context) => AddCustomRule( - onConfirm: confirmAddRule, - dialog: true, - ), - barrierDismissible: false - ); - } - else { - Navigator.of(context).push( - MaterialPageRoute( - fullscreenDialog: true, - builder: (context) => AddCustomRule( - onConfirm: confirmAddRule, - dialog: false, + showGeneralDialog( + context: context, + barrierColor: !(width > 700 || !(Platform.isAndroid || Platform.isIOS)) + ?Colors.transparent + : Colors.black54, + transitionBuilder: (context, anim1, anim2, child) { + return SlideTransition( + position: Tween( + begin: const Offset(0, 1), + end: const Offset(0, 0) + ).animate( + CurvedAnimation( + parent: anim1, + curve: Curves.easeInOutCubicEmphasized + ) ), - ) - ); - } + child: child, + ); + }, + pageBuilder: (context, animation, secondaryAnimation) => AddCustomRule( + fullScreen: !(width > 700 || !(Platform.isAndroid || Platform.isIOS)), + onConfirm: confirmAddRule, + ), + ); } void confirmAddList({required String name, required String url, required String type}) async { diff --git a/lib/screens/filters/add_custom_rule.dart b/lib/screens/filters/add_custom_rule.dart index dfb5753..4b79fc4 100644 --- a/lib/screens/filters/add_custom_rule.dart +++ b/lib/screens/filters/add_custom_rule.dart @@ -6,12 +6,12 @@ import 'package:adguard_home_manager/constants/urls.dart'; class AddCustomRule extends StatefulWidget { final void Function(String) onConfirm; - final bool dialog; + final bool fullScreen; const AddCustomRule({ Key? key, required this.onConfirm, - required this.dialog + required this.fullScreen }) : super(key: key); @override @@ -328,7 +328,32 @@ class _AddCustomRuleState extends State { ]; } - if (widget.dialog == true) { + if (widget.fullScreen == true) { + return Dialog.fullscreen( + child: Scaffold( + appBar: AppBar( + leading: CloseButton(onPressed: () => Navigator.pop(context)), + title: Text(AppLocalizations.of(context)!.addCustomRule), + actions: [ + IconButton( + onPressed: checkValidValues() == true + ? () { + Navigator.pop(context); + widget.onConfirm(buildRule()); + } + : null, + icon: const Icon(Icons.check) + ), + const SizedBox(width: 10) + ], + ), + body: ListView( + children: content(), + ) + ), + ); + } + else { return Dialog( child: ConstrainedBox( constraints: const BoxConstraints( @@ -383,27 +408,5 @@ class _AddCustomRuleState extends State { ), ); } - else { - return Scaffold( - appBar: AppBar( - title: Text(AppLocalizations.of(context)!.addCustomRule), - actions: [ - IconButton( - onPressed: checkValidValues() == true - ? () { - Navigator.pop(context); - widget.onConfirm(buildRule()); - } - : null, - icon: const Icon(Icons.check) - ), - const SizedBox(width: 10) - ], - ), - body: ListView( - children: content(), - ) - ); - } } } \ No newline at end of file