mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-09 12:34:55 +08:00
@@ -2,7 +2,7 @@ import 'package:PiliPlus/utils/storage_pref.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class CustomToast extends StatelessWidget {
|
class CustomToast extends StatelessWidget {
|
||||||
const CustomToast({super.key, required this.msg});
|
const CustomToast(this.msg, {super.key});
|
||||||
|
|
||||||
final String msg;
|
final String msg;
|
||||||
|
|
||||||
@@ -12,13 +12,13 @@ class CustomToast extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final colorScheme = ColorScheme.of(context);
|
final colorScheme = ColorScheme.of(context);
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.only(
|
margin: .only(
|
||||||
bottom: MediaQuery.viewPaddingOf(context).bottom + 30,
|
bottom: MediaQuery.viewPaddingOf(context).bottom + 30,
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 10),
|
padding: const .symmetric(horizontal: 17, vertical: 10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: colorScheme.primaryContainer.withValues(alpha: toastOpacity),
|
color: colorScheme.primaryContainer.withValues(alpha: toastOpacity),
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
borderRadius: const .all(.circular(20)),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
msg,
|
msg,
|
||||||
@@ -32,7 +32,7 @@ class CustomToast extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class LoadingWidget extends StatelessWidget {
|
class LoadingWidget extends StatelessWidget {
|
||||||
const LoadingWidget({super.key, required this.msg});
|
const LoadingWidget(this.msg, {super.key});
|
||||||
|
|
||||||
///loading msg
|
///loading msg
|
||||||
final String msg;
|
final String msg;
|
||||||
@@ -42,14 +42,14 @@ class LoadingWidget extends StatelessWidget {
|
|||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
final onSurfaceVariant = theme.colorScheme.onSurfaceVariant;
|
final onSurfaceVariant = theme.colorScheme.onSurfaceVariant;
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 20),
|
padding: const .symmetric(horizontal: 30, vertical: 20),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: theme.dialogTheme.backgroundColor,
|
color: theme.dialogTheme.backgroundColor,
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(15)),
|
borderRadius: const .all(.circular(15)),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
spacing: 20,
|
spacing: 20,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: .min,
|
||||||
children: [
|
children: [
|
||||||
//loading animation
|
//loading animation
|
||||||
CircularProgressIndicator(
|
CircularProgressIndicator(
|
||||||
@@ -63,3 +63,34 @@ class LoadingWidget extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class NotifyWarning extends StatelessWidget {
|
||||||
|
const NotifyWarning(this.msg, {super.key});
|
||||||
|
|
||||||
|
final String msg;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
final onSurfaceVariant = theme.colorScheme.onSurfaceVariant;
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: const .all(.circular(8)),
|
||||||
|
color: theme.dialogTheme.backgroundColor,
|
||||||
|
),
|
||||||
|
padding: const .symmetric(horizontal: 20, vertical: 10),
|
||||||
|
child: Column(
|
||||||
|
spacing: 5,
|
||||||
|
mainAxisSize: .min,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.warning_amber_rounded,
|
||||||
|
size: 22,
|
||||||
|
color: onSurfaceVariant,
|
||||||
|
),
|
||||||
|
Text(msg, style: TextStyle(color: onSurfaceVariant)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -278,8 +278,11 @@ class MyApp extends StatelessWidget {
|
|||||||
getPages: Routes.getPages,
|
getPages: Routes.getPages,
|
||||||
defaultTransition: Pref.pageTransition,
|
defaultTransition: Pref.pageTransition,
|
||||||
builder: FlutterSmartDialog.init(
|
builder: FlutterSmartDialog.init(
|
||||||
toastBuilder: (msg) => CustomToast(msg: msg),
|
toastBuilder: CustomToast.new,
|
||||||
loadingBuilder: (msg) => LoadingWidget(msg: msg),
|
loadingBuilder: LoadingWidget.new,
|
||||||
|
notifyStyle: const FlutterSmartNotifyStyle(
|
||||||
|
warningBuilder: NotifyWarning.new,
|
||||||
|
),
|
||||||
builder: _builder,
|
builder: _builder,
|
||||||
),
|
),
|
||||||
navigatorObservers: [
|
navigatorObservers: [
|
||||||
|
|||||||
@@ -67,11 +67,16 @@ abstract final class LoginUtils {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 获取用户信息失败
|
// 获取用户信息失败
|
||||||
await Accounts.deleteAll({account});
|
final errMsg = res.toString();
|
||||||
SmartDialog.showNotify(
|
if (errMsg == '账号未登录') {
|
||||||
msg: '登录失败,请检查cookie是否正确,${res.toString()}',
|
await Accounts.deleteAll({account});
|
||||||
notifyType: NotifyType.warning,
|
SmartDialog.showNotify(
|
||||||
);
|
msg: '登录失败,请检查cookie是否正确,$errMsg',
|
||||||
|
notifyType: .warning,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(errMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user