Adapted more modals

This commit is contained in:
Juan Gilsanz Polo 2023-10-08 00:19:32 +02:00
parent 24dc69d084
commit 95aec4b3a5
2 changed files with 51 additions and 45 deletions

View file

@ -56,27 +56,30 @@ class AddFiltersButton extends StatelessWidget {
} }
void openAddCustomRule() { void openAddCustomRule() {
if (width > 700 || !(Platform.isAndroid || Platform.isIOS)) { showGeneralDialog(
showDialog(
context: context, context: context,
builder: (context) => AddCustomRule( barrierColor: !(width > 700 || !(Platform.isAndroid || Platform.isIOS))
onConfirm: confirmAddRule, ?Colors.transparent
dialog: true, : Colors.black54,
), transitionBuilder: (context, anim1, anim2, child) {
barrierDismissible: false return SlideTransition(
); position: Tween(
} begin: const Offset(0, 1),
else { end: const Offset(0, 0)
Navigator.of(context).push( ).animate(
MaterialPageRoute( CurvedAnimation(
fullscreenDialog: true, parent: anim1,
builder: (context) => AddCustomRule( curve: Curves.easeInOutCubicEmphasized
onConfirm: confirmAddRule,
dialog: false,
),
) )
),
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 { void confirmAddList({required String name, required String url, required String type}) async {

View file

@ -6,12 +6,12 @@ import 'package:adguard_home_manager/constants/urls.dart';
class AddCustomRule extends StatefulWidget { class AddCustomRule extends StatefulWidget {
final void Function(String) onConfirm; final void Function(String) onConfirm;
final bool dialog; final bool fullScreen;
const AddCustomRule({ const AddCustomRule({
Key? key, Key? key,
required this.onConfirm, required this.onConfirm,
required this.dialog required this.fullScreen
}) : super(key: key); }) : super(key: key);
@override @override
@ -328,7 +328,32 @@ class _AddCustomRuleState extends State<AddCustomRule> {
]; ];
} }
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( return Dialog(
child: ConstrainedBox( child: ConstrainedBox(
constraints: const BoxConstraints( constraints: const BoxConstraints(
@ -383,27 +408,5 @@ class _AddCustomRuleState extends State<AddCustomRule> {
), ),
); );
} }
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(),
)
);
}
} }
} }