mod: update error widget

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-23 16:16:51 +08:00
parent e0fe16fd14
commit 65eecb8dcf
54 changed files with 106 additions and 115 deletions

View File

@@ -5,17 +5,15 @@ class HttpError extends StatelessWidget {
const HttpError({
this.isSliver = true,
this.errMsg,
this.callback,
this.onReload,
this.btnText,
this.extraWidget,
super.key,
});
final bool isSliver;
final String? errMsg;
final Function()? callback;
final VoidCallback? onReload;
final String? btnText;
final Widget? extraWidget;
@override
Widget build(BuildContext context) {
@@ -46,15 +44,9 @@ class HttpError extends StatelessWidget {
style: Theme.of(context).textTheme.titleSmall,
),
),
if (extraWidget != null) ...[
const SizedBox(height: 10),
extraWidget!,
const SizedBox(height: 5),
],
if (callback != null) ...[
if (extraWidget == null) const SizedBox(height: 20),
if (onReload != null)
FilledButton.tonal(
onPressed: callback,
onPressed: onReload,
style: ButtonStyle(
backgroundColor: WidgetStateProperty.resolveWith((states) {
return Theme.of(context).colorScheme.primary.withAlpha(20);
@@ -65,7 +57,6 @@ class HttpError extends StatelessWidget {
style: TextStyle(color: Theme.of(context).colorScheme.primary),
),
),
],
SizedBox(height: 40 + MediaQuery.paddingOf(context).bottom),
],
);

View File

@@ -3,17 +3,17 @@ import 'package:flutter/material.dart';
Widget get loadingWidget => Center(child: CircularProgressIndicator());
Widget errorWidget({errMsg, callback}) => HttpError(
Widget errorWidget({errMsg, onReload}) => HttpError(
isSliver: false,
errMsg: errMsg,
callback: callback,
onReload: onReload,
);
Widget scrollErrorWidget({errMsg, callback}) => CustomScrollView(
Widget scrollErrorWidget({errMsg, onReload}) => CustomScrollView(
slivers: [
HttpError(
errMsg: errMsg,
callback: callback,
onReload: onReload,
)
],
);