更新登录

This commit is contained in:
wyf
2025-06-09 15:31:18 +08:00
parent 71a4504f78
commit 8dfc522a69
31 changed files with 1737 additions and 1662 deletions

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:get/get.dart';
import 'package:vbvs_app/common/color/AppGlobal.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
@@ -31,11 +32,42 @@ class TopSlideNotification extends StatefulWidget {
Color? textColor,
double slideOffset = 300.0,
Duration duration = const Duration(seconds: 2),
}) {
_showInternal(
context: context,
text: text,
fontSize: fontSize,
textColor: textColor,
slideOffset: slideOffset,
duration: duration,
);
}
// Internal implementation used by both methods
static void _showInternal({
BuildContext? context,
required String text,
required double fontSize,
Color? textColor,
required double slideOffset,
required Duration duration,
}) {
// 如果已有弹窗,先移除
_removeCurrentEntry();
final overlay = Overlay.of(context);
// 获取有效的context优先使用传入的context没有则使用navigatorKey的context
final effectiveContext = context ?? AppGlobal.navigatorKey.currentContext;
if (effectiveContext == null) {
debugPrint('TopSlideNotification: No valid context available');
return;
}
final overlay = Overlay.of(effectiveContext);
if (overlay == null) {
debugPrint('TopSlideNotification: Could not find Overlay');
return;
}
final entry = OverlayEntry(
builder: (_) => TopSlideNotification(
text: text,
@@ -164,30 +196,4 @@ class _TopSlideNotificationState extends State<TopSlideNotification>
_isAnimating = false; // 动画完成后,标记动画结束
}
}
// 工具方法:调用时直接加进 Overlay 上
static void show(
BuildContext context, {
String text = '操作成功!',
double fontSize = 16,
Color? textColor,
double slideOffset = 300.0,
Duration duration = const Duration(seconds: 2),
}) {
final overlay = Overlay.of(context);
final entry = OverlayEntry(
builder: (_) => TopSlideNotification(
text: text,
fontSize: fontSize,
textColor: textColor,
slideOffset: slideOffset,
duration: duration,
),
);
overlay.insert(entry);
Future.delayed(duration + const Duration(milliseconds: 500), () {
entry.remove();
});
}
}