Add AppbarStyle.shadow;

Improve favorites page ui.
This commit is contained in:
2024-11-23 12:12:52 +08:00
parent a1474ca9c3
commit c2b8760d86
6 changed files with 219 additions and 200 deletions

View File

@@ -115,6 +115,11 @@ class _AppbarState extends State<Appbar> {
} }
} }
enum AppbarStyle {
blur,
shadow,
}
class SliverAppbar extends StatelessWidget { class SliverAppbar extends StatelessWidget {
const SliverAppbar({ const SliverAppbar({
super.key, super.key,
@@ -122,6 +127,7 @@ class SliverAppbar extends StatelessWidget {
this.leading, this.leading,
this.actions, this.actions,
this.radius = 0, this.radius = 0,
this.style = AppbarStyle.blur,
}); });
final Widget? leading; final Widget? leading;
@@ -132,6 +138,8 @@ class SliverAppbar extends StatelessWidget {
final double radius; final double radius;
final AppbarStyle style;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SliverPersistentHeader( return SliverPersistentHeader(
@@ -142,6 +150,7 @@ class SliverAppbar extends StatelessWidget {
actions: actions, actions: actions,
topPadding: MediaQuery.of(context).padding.top, topPadding: MediaQuery.of(context).padding.top,
radius: radius, radius: radius,
style: style,
), ),
); );
} }
@@ -160,24 +169,21 @@ class _MySliverAppBarDelegate extends SliverPersistentHeaderDelegate {
final double radius; final double radius;
_MySliverAppBarDelegate( final AppbarStyle style;
{this.leading,
_MySliverAppBarDelegate({
this.leading,
required this.title, required this.title,
this.actions, this.actions,
required this.topPadding, required this.topPadding,
this.radius = 0}); this.radius = 0,
this.style = AppbarStyle.blur,
});
@override @override
Widget build( Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) { BuildContext context, double shrinkOffset, bool overlapsContent) {
return SizedBox.expand( var body = Row(
child: BlurEffect(
blur: 15,
child: Material(
color: context.colorScheme.surface.withOpacity(0.72),
elevation: 0,
borderRadius: BorderRadius.circular(radius),
child: Row(
children: [ children: [
const SizedBox(width: 8), const SizedBox(width: 8),
leading ?? leading ??
@@ -207,10 +213,30 @@ class _MySliverAppBarDelegate extends SliverPersistentHeaderDelegate {
width: 8, width: 8,
) )
], ],
).paddingTop(topPadding), ).paddingTop(topPadding);
if(style == AppbarStyle.blur) {
return SizedBox.expand(
child: BlurEffect(
blur: 15,
child: Material(
color: context.colorScheme.surface.withOpacity(0.72),
elevation: 0,
borderRadius: BorderRadius.circular(radius),
child: body,
), ),
), ),
); );
} else {
return SizedBox.expand(
child: Material(
color: context.colorScheme.surface,
elevation: shrinkOffset == 0 ? 0 : 2,
borderRadius: BorderRadius.circular(radius),
child: body,
),
);
}
} }
@override @override
@@ -224,7 +250,10 @@ class _MySliverAppBarDelegate extends SliverPersistentHeaderDelegate {
return oldDelegate is! _MySliverAppBarDelegate || return oldDelegate is! _MySliverAppBarDelegate ||
leading != oldDelegate.leading || leading != oldDelegate.leading ||
title != oldDelegate.title || title != oldDelegate.title ||
actions != oldDelegate.actions; actions != oldDelegate.actions ||
topPadding != oldDelegate.topPadding ||
radius != oldDelegate.radius ||
style != oldDelegate.style;
} }
} }

View File

@@ -778,7 +778,7 @@ class _SliverGridComics extends StatelessWidget {
duration: const Duration(milliseconds: 150), duration: const Duration(milliseconds: 150),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected color: isSelected
? Theme.of(context).colorScheme.secondaryContainer ? Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.72)
: null, : null,
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
), ),

View File

@@ -9,6 +9,7 @@ import 'package:venera/foundation/app.dart';
import 'package:venera/foundation/appdata.dart'; import 'package:venera/foundation/appdata.dart';
import 'package:venera/foundation/comic_source/comic_source.dart'; import 'package:venera/foundation/comic_source/comic_source.dart';
import 'package:venera/foundation/comic_type.dart'; import 'package:venera/foundation/comic_type.dart';
import 'package:venera/foundation/consts.dart';
import 'package:venera/foundation/favorites.dart'; import 'package:venera/foundation/favorites.dart';
import 'package:venera/foundation/local.dart'; import 'package:venera/foundation/local.dart';
import 'package:venera/foundation/res.dart'; import 'package:venera/foundation/res.dart';

View File

@@ -74,6 +74,9 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
body: SmoothCustomScrollView(slivers: [ body: SmoothCustomScrollView(slivers: [
if (!searchMode && !multiSelectMode) if (!searchMode && !multiSelectMode)
SliverAppbar( SliverAppbar(
style: context.width < changePoint
? AppbarStyle.shadow
: AppbarStyle.blur,
leading: Tooltip( leading: Tooltip(
message: "Folders".tl, message: "Folders".tl,
child: context.width <= _kTwoPanelChangeWidth child: context.width <= _kTwoPanelChangeWidth
@@ -225,8 +228,7 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
showConfirmDialog( showConfirmDialog(
context: App.rootContext, context: App.rootContext,
title: "Delete".tl, title: "Delete".tl,
content: content: "Delete folder '@f' ?".tlParams({
"Delete folder '@f' ?".tlParams({
"f": widget.folder, "f": widget.folder,
}), }),
btnColor: context.colorScheme.error, btnColor: context.colorScheme.error,
@@ -243,6 +245,9 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
) )
else if (multiSelectMode) else if (multiSelectMode)
SliverAppbar( SliverAppbar(
style: context.width < changePoint
? AppbarStyle.shadow
: AppbarStyle.blur,
leading: Tooltip( leading: Tooltip(
message: "Cancel".tl, message: "Cancel".tl,
child: IconButton( child: IconButton(
@@ -287,8 +292,8 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
showConfirmDialog( showConfirmDialog(
context: context, context: context,
title: "Delete".tl, title: "Delete".tl,
content: content: "Delete @c comics?"
"Delete @c comics?".tlParams({"c": selectedComics.length}), .tlParams({"c": selectedComics.length}),
btnColor: context.colorScheme.error, btnColor: context.colorScheme.error,
onConfirm: () { onConfirm: () {
_deleteComicWithId(); _deleteComicWithId();
@@ -300,6 +305,9 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
) )
else if (searchMode) else if (searchMode)
SliverAppbar( SliverAppbar(
style: context.width < changePoint
? AppbarStyle.shadow
: AppbarStyle.blur,
leading: Tooltip( leading: Tooltip(
message: "Cancel".tl, message: "Cancel".tl,
child: IconButton( child: IconButton(
@@ -407,39 +415,19 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
.where((folder) => folder != favPage.folder) .where((folder) => folder != favPage.folder)
.toList(); .toList();
showDialog( showPopUpWidget(
context: App.rootContext, App.rootContext,
builder: (context) { StatefulBuilder(
return StatefulBuilder(
builder: (context, setState) { builder: (context, setState) {
return Dialog( return PopUpWidgetScaffold(
shape: RoundedRectangleBorder( title: favPage.folder ?? "Unselected".tl,
borderRadius: BorderRadius.circular(12.0), body: Padding(
), padding: EdgeInsets.only(bottom: context.padding.bottom + 16),
child: Padding(
padding: const EdgeInsets.only(bottom: 50),
child: Container( child: Container(
constraints: constraints:
const BoxConstraints(maxHeight: 700, maxWidth: 500), const BoxConstraints(maxHeight: 700, maxWidth: 500),
child: Column( child: Column(
children: [ children: [
Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.vertical(
top: Radius.circular(12.0),
),
),
padding: const EdgeInsets.all(16.0),
child: Center(
child: Text(
favPage.folder ?? "Unselected".tl,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
),
Expanded( Expanded(
child: ListView.builder( child: ListView.builder(
itemCount: targetFolders.length + 1, itemCount: targetFolders.length + 1,
@@ -452,12 +440,10 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
onPressed: () { onPressed: () {
newFolder().then((v) { newFolder().then((v) {
setState(() { setState(() {
targetFolders = targetFolders = LocalFavoritesManager()
LocalFavoritesManager()
.folderNames .folderNames
.where((folder) => .where((folder) =>
folder != folder != favPage.folder)
favPage.folder)
.toList(); .toList();
}); });
}); });
@@ -478,12 +464,10 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
var disabled = false; var disabled = false;
if (selectedLocalFolders.isNotEmpty) { if (selectedLocalFolders.isNotEmpty) {
if (added.contains(folder) && if (added.contains(folder) &&
!added !added.contains(selectedLocalFolders.first)) {
.contains(selectedLocalFolders.first)) {
disabled = true; disabled = true;
} else if (!added.contains(folder) && } else if (!added.contains(folder) &&
added added.contains(selectedLocalFolders.first)) {
.contains(selectedLocalFolders.first)) {
disabled = true; disabled = true;
} }
} }
@@ -545,21 +529,20 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
} }
} }
} }
context.pop(); App.rootContext.pop();
updateComics(); updateComics();
_cancel(); _cancel();
}, },
child: child: Text(option == 'move' ? "Move".tl : "Add".tl),
Text(option == 'move' ? "Move".tl : "Add".tl), ),
).paddingVertical(16),
), ),
], ],
), ),
), ),
)); ),
},
); );
}, },
),
); );
} }

View File

@@ -94,6 +94,9 @@ class _NormalFavoritePageState extends State<_NormalFavoritePage> {
return ComicList( return ComicList(
key: comicListKey, key: comicListKey,
leadingSliver: SliverAppbar( leadingSliver: SliverAppbar(
style: context.width < changePoint
? AppbarStyle.shadow
: AppbarStyle.blur,
leading: Tooltip( leading: Tooltip(
message: "Folders".tl, message: "Folders".tl,
child: context.width <= _kTwoPanelChangeWidth child: context.width <= _kTwoPanelChangeWidth
@@ -211,6 +214,9 @@ class _MultiFolderFavoritesPageState extends State<_MultiFolderFavoritesPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var sliverAppBar = SliverAppbar( var sliverAppBar = SliverAppbar(
style: context.width < changePoint
? AppbarStyle.shadow
: AppbarStyle.blur,
leading: Tooltip( leading: Tooltip(
message: "Folders".tl, message: "Folders".tl,
child: context.width <= _kTwoPanelChangeWidth child: context.width <= _kTwoPanelChangeWidth

View File

@@ -393,8 +393,8 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." path: "."
ref: HEAD ref: "829a566b738a26ea98e523807f49838e21308543"
resolved-ref: "51a27e2ca0e05becfb8ee3a506294dc4460721a8" resolved-ref: "829a566b738a26ea98e523807f49838e21308543"
url: "https://github.com/pkuislm/flutter_saf.git" url: "https://github.com/pkuislm/flutter_saf.git"
source: git source: git
version: "0.0.1" version: "0.0.1"