From ad42438ce3737f9b5a5460be1f7069253ae5adac Mon Sep 17 00:00:00 2001 From: Juan Gilsanz Polo Date: Wed, 15 Nov 2023 18:28:10 +0100 Subject: [PATCH] Changed list details modal opening --- lib/l10n/app_en.arb | 3 +- lib/l10n/app_es.arb | 3 +- lib/screens/filters/filters.dart | 47 ++++++------ lib/screens/filters/list_details_screen.dart | 79 +++++++++++--------- lib/screens/filters/list_options_menu.dart | 19 ++++- 5 files changed, 87 insertions(+), 64 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index d4962e3..ab0908a 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -669,5 +669,6 @@ "showTopItemsChart": "Show top items chart", "showTopItemsChartDescription": "Shows by default the ring chart on the top items sections. Only affects to the mobile view.", "openMenu": "Open menu", - "closeMenu": "Close menu" + "closeMenu": "Close menu", + "openListUrl": "Open list URL" } \ No newline at end of file diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index 2f202a8..9836280 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -669,5 +669,6 @@ "showTopItemsChart": "Mostrar gráfico en top de items", "showTopItemsChartDescription": "Muestra por defecto el gráfico de anillo en las secciones de top de items. Sólo afecta a la vista móvil.", "openMenu": "Abrir menú", - "closeMenu": "Cerrar menú" + "closeMenu": "Cerrar menú", + "openListUrl": "Abrir URL de lista" } \ No newline at end of file diff --git a/lib/screens/filters/filters.dart b/lib/screens/filters/filters.dart index 5975cf6..cb5cbdb 100644 --- a/lib/screens/filters/filters.dart +++ b/lib/screens/filters/filters.dart @@ -190,28 +190,31 @@ class _FiltersState extends State { } void openListDetails(Filter filter, String type) { - if (width > 900 || !(Platform.isAndroid || Platform.isIOS)) { - showDialog( - context: context, - builder: (context) => ListDetailsScreen( - listId: filter.id, - type: type, - dialog: true, - ), - barrierDismissible: false - ); - } - else { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => ListDetailsScreen( - listId: filter.id, - type: type, - dialog: false, - ) - ) - ); - } + showGeneralDialog( + context: context, + barrierColor: !(width > 900 || !(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) => ListDetailsScreen( + listId: filter.id, + type: type, + dialog: width > 900 || !(Platform.isAndroid | Platform.isIOS), + ), + ); } List actions() { diff --git a/lib/screens/filters/list_details_screen.dart b/lib/screens/filters/list_details_screen.dart index 236ee75..c0c9e2b 100644 --- a/lib/screens/filters/list_details_screen.dart +++ b/lib/screens/filters/list_details_screen.dart @@ -352,47 +352,52 @@ class _ListDetailsScreenState extends State { ); } else { - return Scaffold( - appBar: AppBar( - title: Text(AppLocalizations.of(context)!.listDetails), - actions: list != null ? actions() : null, - ), - body: Stack( - children: [ - if (list != null) ListView( - children: content(), + return Dialog.fullscreen( + child: Scaffold( + appBar: AppBar( + leading: CloseButton( + onPressed: () => Navigator.pop(context), ), - if (list == null) Center( - child: Text( - AppLocalizations.of(context)!.listNotAvailable, - style: const TextStyle( - fontSize: 24, + title: Text(AppLocalizations.of(context)!.listDetails), + actions: list != null ? actions() : null, + ), + body: Stack( + children: [ + if (list != null) ListView( + children: content(), + ), + if (list == null) Center( + child: Text( + AppLocalizations.of(context)!.listNotAvailable, + style: const TextStyle( + fontSize: 24, + ), ), ), - ), - if (list != null) AnimatedPositioned( - duration: const Duration(milliseconds: 100), - curve: Curves.easeInOut, - bottom: fabVisible ? - appConfigProvider.showingSnackbar - ? 70 : (Platform.isIOS ? 40 : 20) - : -70, - right: 20, - child: FloatingActionButton( - onPressed: () => updateList( - action: list!.enabled == true - ? FilteringListActions.disable - : FilteringListActions.enable, - filterList: list + if (list != null) AnimatedPositioned( + duration: const Duration(milliseconds: 100), + curve: Curves.easeInOut, + bottom: fabVisible ? + appConfigProvider.showingSnackbar + ? 70 : (Platform.isIOS ? 40 : 20) + : -70, + right: 20, + child: FloatingActionButton( + onPressed: () => updateList( + action: list!.enabled == true + ? FilteringListActions.disable + : FilteringListActions.enable, + filterList: list + ), + child: Icon( + list.enabled == true + ? Icons.gpp_bad_rounded + : Icons.verified_user_rounded, + ), ), - child: Icon( - list.enabled == true - ? Icons.gpp_bad_rounded - : Icons.verified_user_rounded, - ), - ), - ) - ], + ) + ], + ), ), ); } diff --git a/lib/screens/filters/list_options_menu.dart b/lib/screens/filters/list_options_menu.dart index 1d644a0..91ca07f 100644 --- a/lib/screens/filters/list_options_menu.dart +++ b/lib/screens/filters/list_options_menu.dart @@ -1,6 +1,7 @@ // ignore_for_file: use_build_context_synchronously -import 'package:adguard_home_manager/classes/process_modal.dart'; +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:contextmenu/contextmenu.dart'; import 'package:provider/provider.dart'; @@ -9,6 +10,8 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:adguard_home_manager/widgets/custom_list_tile.dart'; import 'package:adguard_home_manager/widgets/options_modal.dart'; +import 'package:adguard_home_manager/functions/open_url.dart'; +import 'package:adguard_home_manager/classes/process_modal.dart'; import 'package:adguard_home_manager/functions/snackbar.dart'; import 'package:adguard_home_manager/models/filtering.dart'; import 'package:adguard_home_manager/providers/filtering_provider.dart'; @@ -92,11 +95,16 @@ class ListOptionsMenu extends StatelessWidget { ); } ), + CustomListTile( + title: AppLocalizations.of(context)!.openListUrl, + icon: Icons.open_in_browser_rounded, + onTap: () => openUrl(list.url) + ), ], child: Material( color: Colors.transparent, child: InkWell( - onLongPress: () => showDialog( + onLongPress: Platform.isAndroid || Platform.isIOS ? () => showDialog( context: context, builder: (context) => OptionsModal( options: [ @@ -117,9 +125,14 @@ class ListOptionsMenu extends StatelessWidget { successMessage: AppLocalizations.of(context)!.listUrlCopied ) ), + MenuOption( + title: AppLocalizations.of(context)!.openListUrl, + icon: Icons.open_in_browser_rounded, + action: () => openUrl(list.url) + ), ] ) - ), + ) : null, child: child ), ),