mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
download & view local comics
This commit is contained in:
@@ -165,19 +165,24 @@ class _ButtonState extends State<Button> {
|
||||
if (height != null) {
|
||||
height = height - padding.vertical;
|
||||
}
|
||||
Widget child = DefaultTextStyle(
|
||||
style: TextStyle(
|
||||
Widget child = IconTheme(
|
||||
data: IconThemeData(
|
||||
color: textColor,
|
||||
fontSize: 16,
|
||||
),
|
||||
child: isLoading
|
||||
? CircularProgressIndicator(
|
||||
color: widget.type == ButtonType.filled
|
||||
? context.colorScheme.inversePrimary
|
||||
: context.colorScheme.primary,
|
||||
strokeWidth: 1.8,
|
||||
).fixWidth(16).fixHeight(16)
|
||||
: widget.child,
|
||||
child: DefaultTextStyle(
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontSize: 16,
|
||||
),
|
||||
child: isLoading
|
||||
? CircularProgressIndicator(
|
||||
color: widget.type == ButtonType.filled
|
||||
? context.colorScheme.inversePrimary
|
||||
: context.colorScheme.primary,
|
||||
strokeWidth: 1.8,
|
||||
).fixWidth(16).fixHeight(16)
|
||||
: widget.child,
|
||||
),
|
||||
);
|
||||
if (width != null || height != null) {
|
||||
child = child.toCenter();
|
||||
@@ -255,7 +260,7 @@ class _ButtonState extends State<Button> {
|
||||
|
||||
Color get textColor {
|
||||
if (widget.type == ButtonType.outlined) {
|
||||
return widget.color ?? context.colorScheme.onSurface;
|
||||
return widget.color ?? context.colorScheme.primary;
|
||||
}
|
||||
return widget.type == ButtonType.filled
|
||||
? context.colorScheme.onPrimary
|
||||
|
@@ -7,6 +7,7 @@ class ComicTile extends StatelessWidget {
|
||||
this.enableLongPressed = true,
|
||||
this.badge,
|
||||
this.menuOptions,
|
||||
this.onTap,
|
||||
});
|
||||
|
||||
final Comic comic;
|
||||
@@ -17,7 +18,13 @@ class ComicTile extends StatelessWidget {
|
||||
|
||||
final List<MenuEntry>? menuOptions;
|
||||
|
||||
void onTap() {
|
||||
final VoidCallback? onTap;
|
||||
|
||||
void _onTap() {
|
||||
if(onTap != null) {
|
||||
onTap!();
|
||||
return;
|
||||
}
|
||||
App.mainNavigatorKey?.currentContext
|
||||
?.to(() => ComicPage(id: comic.id, sourceKey: comic.sourceKey));
|
||||
}
|
||||
@@ -43,7 +50,7 @@ class ComicTile extends StatelessWidget {
|
||||
MenuEntry(
|
||||
icon: Icons.chrome_reader_mode_outlined,
|
||||
text: 'Details'.tl,
|
||||
onClick: onTap,
|
||||
onClick: _onTap,
|
||||
),
|
||||
MenuEntry(
|
||||
icon: Icons.copy,
|
||||
@@ -155,7 +162,7 @@ class ComicTile extends StatelessWidget {
|
||||
final height = constrains.maxHeight - 16;
|
||||
return InkWell(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
onTap: onTap,
|
||||
onTap: _onTap,
|
||||
onLongPress: enableLongPressed ? () => onLongPress(context) : null,
|
||||
onSecondaryTapDown: onSecondaryTap,
|
||||
child: Padding(
|
||||
@@ -250,7 +257,7 @@ class ComicTile extends StatelessWidget {
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
onTap: _onTap,
|
||||
onLongPress:
|
||||
enableLongPressed ? () => onLongPress(context) : null,
|
||||
onSecondaryTapDown: onSecondaryTap,
|
||||
@@ -464,6 +471,7 @@ class SliverGridComics extends StatelessWidget {
|
||||
this.onLastItemBuild,
|
||||
this.badgeBuilder,
|
||||
this.menuBuilder,
|
||||
this.onTap,
|
||||
});
|
||||
|
||||
final List<Comic> comics;
|
||||
@@ -474,6 +482,8 @@ class SliverGridComics extends StatelessWidget {
|
||||
|
||||
final List<MenuEntry> Function(Comic)? menuBuilder;
|
||||
|
||||
final void Function(Comic)? onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StateBuilder<SliverGridComicsController>(
|
||||
@@ -490,6 +500,7 @@ class SliverGridComics extends StatelessWidget {
|
||||
onLastItemBuild: onLastItemBuild,
|
||||
badgeBuilder: badgeBuilder,
|
||||
menuBuilder: menuBuilder,
|
||||
onTap: onTap,
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -502,6 +513,7 @@ class _SliverGridComics extends StatelessWidget {
|
||||
this.onLastItemBuild,
|
||||
this.badgeBuilder,
|
||||
this.menuBuilder,
|
||||
this.onTap,
|
||||
});
|
||||
|
||||
final List<Comic> comics;
|
||||
@@ -512,6 +524,8 @@ class _SliverGridComics extends StatelessWidget {
|
||||
|
||||
final List<MenuEntry> Function(Comic)? menuBuilder;
|
||||
|
||||
final void Function(Comic)? onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SliverGrid(
|
||||
@@ -525,6 +539,7 @@ class _SliverGridComics extends StatelessWidget {
|
||||
comic: comics[index],
|
||||
badge: badge,
|
||||
menuOptions: menuBuilder?.call(comics[index]),
|
||||
onTap: onTap != null ? () => onTap!(comics[index]) : null,
|
||||
);
|
||||
},
|
||||
childCount: comics.length,
|
||||
|
@@ -95,7 +95,7 @@ abstract class LoadingState<T extends StatefulWidget, S extends Object>
|
||||
|
||||
Future<Res<S>> loadData();
|
||||
|
||||
void onDataLoaded() {}
|
||||
FutureOr<void> onDataLoaded() {}
|
||||
|
||||
Widget buildContent(BuildContext context, S data);
|
||||
|
||||
@@ -114,13 +114,13 @@ abstract class LoadingState<T extends StatefulWidget, S extends Object>
|
||||
isLoading = true;
|
||||
error = null;
|
||||
});
|
||||
loadData().then((value) {
|
||||
loadData().then((value) async {
|
||||
if (value.success) {
|
||||
await onDataLoaded();
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
data = value.data;
|
||||
});
|
||||
onDataLoaded();
|
||||
} else {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
|
@@ -54,8 +54,8 @@ class _MenuRoute<T> extends PopupRoute<T> {
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: Material(
|
||||
color: context.brightness == Brightness.light
|
||||
? const Color(0xFFFAFAFA).withOpacity(0.72)
|
||||
: const Color(0xFF090909).withOpacity(0.72),
|
||||
? const Color(0xFFFAFAFA).withOpacity(0.82)
|
||||
: const Color(0xFF090909).withOpacity(0.82),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: Container(
|
||||
width: width,
|
||||
|
@@ -86,7 +86,7 @@ class PopupIndicatorWidget extends InheritedWidget {
|
||||
}
|
||||
|
||||
Future<T> showPopUpWidget<T>(BuildContext context, Widget widget) async {
|
||||
return await Navigator.of(context).push(PopUpWidget(widget));
|
||||
return await Navigator.of(context, rootNavigator: true).push(PopUpWidget(widget));
|
||||
}
|
||||
|
||||
class PopUpWidgetScaffold extends StatefulWidget {
|
||||
@@ -124,7 +124,7 @@ class _PopUpWidgetScaffoldState extends State<PopUpWidgetScaffold> {
|
||||
width: 8,
|
||||
),
|
||||
Tooltip(
|
||||
message: "返回".tl,
|
||||
message: "Back".tl,
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.arrow_back_sharp),
|
||||
onPressed: () => context.canPop()
|
||||
|
@@ -203,13 +203,13 @@ class _SidebarBodyState extends State<SidebarBody> {
|
||||
}
|
||||
}
|
||||
|
||||
void showSideBar(BuildContext context, Widget widget,
|
||||
Future<void> showSideBar(BuildContext context, Widget widget,
|
||||
{String? title,
|
||||
bool showBarrier = true,
|
||||
bool useSurfaceTintColor = false,
|
||||
double width = 500,
|
||||
bool addTopPadding = false}) {
|
||||
Navigator.of(context).push(
|
||||
return Navigator.of(context).push(
|
||||
SideBarRoute(
|
||||
title,
|
||||
widget,
|
||||
|
Reference in New Issue
Block a user