init
This commit is contained in:
@@ -1,24 +1,64 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tdesign_flutter/tdesign_flutter.dart';
|
||||
|
||||
import 'splash_state.dart';
|
||||
|
||||
class SplashLogic extends GetxController {
|
||||
import '../../utils/utils.dart';
|
||||
|
||||
class SplashLogic extends GetxController with GetTickerProviderStateMixin {
|
||||
final SplashState state = SplashState();
|
||||
|
||||
late AnimationController animationController;
|
||||
late Animation<Offset> animation;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
initAnimation();
|
||||
|
||||
animationController.forward();
|
||||
|
||||
isLoginFn();
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
debugPrint('onReady');
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
animationController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
void showText(context) {
|
||||
TDToast.showText('轻提示文字内容', context: context);
|
||||
void initAnimation() {
|
||||
animationController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(seconds: 1),
|
||||
);
|
||||
|
||||
animation = Tween<Offset>(
|
||||
begin: const Offset(0.0, 1.0),
|
||||
end: Offset.zero,
|
||||
).animate(CurvedAnimation(
|
||||
parent: animationController,
|
||||
curve: Curves.easeInOut,
|
||||
));
|
||||
}
|
||||
|
||||
Future<void> isLoginFn() async {
|
||||
// 倒计时3秒
|
||||
await Future.delayed(const Duration(seconds: 3), () {
|
||||
final token = StorageUtil().getString("token");
|
||||
if (!ToolFn.isBlank(token)) {
|
||||
Get.offAllNamed('/home');
|
||||
} else {
|
||||
Get.offAllNamed('/login');
|
||||
// Get.toNamed('/login');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tdesign_flutter/tdesign_flutter.dart';
|
||||
import 'splash_logic.dart';
|
||||
|
||||
class SplashPage extends StatefulWidget {
|
||||
@@ -18,19 +17,30 @@ class _SplashPageState extends State<SplashPage> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text("Splash"),
|
||||
TDButton(
|
||||
theme: TDButtonTheme.primary,
|
||||
text: "立即登录",
|
||||
onTap: () {
|
||||
logic.showText(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
child: SlideTransition(
|
||||
position: logic.animation,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Image.asset(
|
||||
"assets/images/logo.png",
|
||||
width: 120,
|
||||
),
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
),
|
||||
const Text(
|
||||
"捷兑通-商家版",
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user