From 3992c0e89af0703c6c0a4aaf11e9e70b4a85cc7f Mon Sep 17 00:00:00 2001 From: lifegpc Date: Tue, 5 Sep 2023 20:59:16 +0800 Subject: [PATCH] Make gallery page appbar floating --- lib/components/gallery_info.dart | 18 +++++++++++++++++- lib/gallery.dart | 32 ++++++++++++++++---------------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/lib/components/gallery_info.dart b/lib/components/gallery_info.dart index 67fbd4b..b86d541 100644 --- a/lib/components/gallery_info.dart +++ b/lib/components/gallery_info.dart @@ -1,5 +1,6 @@ import 'package:eh_downloader_flutter/globals.dart'; import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; import '../api/file.dart'; import '../api/gallery.dart'; import 'gallery_basic_info.dart'; @@ -15,7 +16,7 @@ class GalleryInfo extends StatefulWidget { State createState() => _GalleryInfo(); } -class _GalleryInfo extends State { +class _GalleryInfo extends State with ThemeModeWidget { final ScrollController controller = ScrollController(); void showNsfwChanged(dynamic _) { setState(() {}); @@ -37,6 +38,21 @@ class _GalleryInfo extends State { return CustomScrollView( controller: controller, slivers: [ + SliverAppBar( + leading: IconButton( + icon: const Icon(Icons.arrow_back), + onPressed: () { + context.canPop() ? context.pop() : context.go("/"); + }, + ), + title: SelectableText( + maxLines: 2, minLines: 1, widget.gData.meta.preferredTitle), + actions: [ + buildThemeModeIcon(context), + buildMoreVertSettingsButon(context), + ], + floating: true, + ), useMobile ? SliverList( delegate: SliverChildListDelegate([ diff --git a/lib/gallery.dart b/lib/gallery.dart index 4ae67a4..e8247b7 100644 --- a/lib/gallery.dart +++ b/lib/gallery.dart @@ -66,24 +66,24 @@ class _GalleryPage extends State with ThemeModeWidget { final title = isLoading ? AppLocalizations.of(context)!.loading : _data != null - ? _data!.meta.preferredTitle + ? "" : AppLocalizations.of(context)!.gallery; return Scaffold( - appBar: AppBar( - leading: IconButton( - icon: const Icon(Icons.arrow_back), - onPressed: () { - context.canPop() ? context.pop() : context.go("/"); - }, - ), - title: _data != null - ? SelectableText(maxLines: 2, minLines: 1, title) - : Text(title), - actions: [ - buildThemeModeIcon(context), - buildMoreVertSettingsButon(context), - ], - ), + appBar: _data == null + ? AppBar( + leading: IconButton( + icon: const Icon(Icons.arrow_back), + onPressed: () { + context.canPop() ? context.pop() : context.go("/"); + }, + ), + title: Text(title), + actions: [ + buildThemeModeIcon(context), + buildMoreVertSettingsButon(context), + ], + ) + : null, body: isLoading ? const Center(child: CircularProgressIndicator()) : _data != null