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
This commit is contained in:
2023-11-26 21:30:57 +08:00
parent 424e2f81b7
commit bcb08750eb
3 changed files with 16 additions and 14 deletions

View File

@@ -105,10 +105,7 @@ class _GalleriesPage extends State<GalleriesPage>
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<GalleriesPage>
),
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),
]),

View File

@@ -183,7 +183,11 @@ List<PopupMenuEntry<MoreVertSettings>> 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<PopupMenuEntry<MoreVertSettings>> 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;
});

View File

@@ -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(