From bcb08750ebe95d3b45f936f05f7f7903929610bf Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sun, 26 Nov 2023 21:30:57 +0800 Subject: [PATCH] Gallery sort now always available in popup menu Fix some pages change settings via popup seems not works Fix home pages themeMode not follow latest settings --- lib/galleries.dart | 17 +++++------------ lib/globals.dart | 12 ++++++++++-- lib/home.dart | 1 + 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/galleries.dart b/lib/galleries.dart index 6a9f444..f406048 100644 --- a/lib/galleries.dart +++ b/lib/galleries.dart @@ -105,10 +105,7 @@ class _GalleriesPage extends State queryParameters: queryParameters); } }, - label: Text(i18n.sortByGid, - style: MediaQuery.of(context).size.width > 810 - ? Theme.of(context).textTheme.labelMedium - : Theme.of(context).textTheme.labelLarge), + label: Text(i18n.sortByGid), dropdownMenuEntries: [ DropdownMenuEntry(value: SortByGid.none, label: i18n.none), DropdownMenuEntry(value: SortByGid.asc, label: i18n.asc), @@ -137,14 +134,10 @@ class _GalleriesPage extends State ), title: Text(title), actions: [ - MediaQuery.of(context).size.width > 810 - ? Padding( - padding: const EdgeInsets.only(top: 4.0), - child: sortByGidMenu) - : PopupMenuButton( - icon: const Icon(Icons.sort), - itemBuilder: (context) => - [PopupMenuItem(child: sortByGidMenu)]), + PopupMenuButton( + icon: const Icon(Icons.sort), + itemBuilder: (context) => + [PopupMenuItem(child: sortByGidMenu)]), buildThemeModeIcon(context), buildMoreVertSettingsButon(context), ]), diff --git a/lib/globals.dart b/lib/globals.dart index a9424fb..e105345 100644 --- a/lib/globals.dart +++ b/lib/globals.dart @@ -183,7 +183,11 @@ List> buildMoreVertSettings( onChanged: (value) { if (value != null) { prefs.setBool("showNsfw", value); - listener.emit("showNsfwChanged", null); + try { + listener.emit("showNsfwChanged", null); + } catch (e) { + // Do nothing. + } setState(() { showNsfw = value; }); @@ -201,7 +205,11 @@ List> buildMoreVertSettings( onChanged: (value) { if (value != null) { prefs.setBool("displayAd", value); - listener.emit("displayAdChanged", null); + try { + listener.emit("displayAdChanged", null); + } catch (e) { + // Do nothing. + } setState(() { displayAd = value; }); diff --git a/lib/home.dart b/lib/home.dart index 7b5e40a..1498442 100644 --- a/lib/home.dart +++ b/lib/home.dart @@ -17,6 +17,7 @@ class HomePage extends HookWidget { Widget build(BuildContext context) { tryInitApi(context); var mode = useState(MainApp.of(context).themeMode); + mode.value = MainApp.of(context).themeMode; setCurrentTitle("", Theme.of(context).primaryColor.value, usePrefix: true); return Scaffold( appBar: AppBar(