You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.3 KiB
Dart
65 lines
2.3 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
import 'package:flare_flutter/flare_actor.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:test_sa/controllers/notification/notification_manger.dart';
|
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
|
import 'package:test_sa/models/app_notification.dart';
|
|
import 'package:test_sa/new_views/pages/login_page.dart';
|
|
|
|
import '../../models/size_config.dart';
|
|
import 'land_page/land_page.dart';
|
|
|
|
class SplashPage extends StatefulWidget {
|
|
static const String routeName = '/splash_page';
|
|
const SplashPage({Key key}) : super(key: key);
|
|
|
|
@override
|
|
State<SplashPage> createState() => _SplashPageState();
|
|
}
|
|
|
|
class _SplashPageState extends State<SplashPage> {
|
|
SettingProvider _settingProvider;
|
|
UserProvider _userProvider;
|
|
|
|
@override
|
|
void initState() {
|
|
Firebase.initializeApp();
|
|
NotificationManger.initialisation((notificationDetails) {
|
|
AppNotification notification = AppNotification.fromJson(json.decode(notificationDetails.payload));
|
|
if (notification.path == null || notification.path.isEmpty) return;
|
|
Navigator.pushNamed(context, notification.path, arguments: notification.requestId);
|
|
}, (id, title, body, payload) async {});
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
SizeConfig.init(context);
|
|
_settingProvider = Provider.of<SettingProvider>(context, listen: false);
|
|
_userProvider = Provider.of<UserProvider>(context, listen: false);
|
|
return Scaffold(
|
|
body: Center(
|
|
child: SizedBox(
|
|
width: MediaQuery.of(context).size.width / 1.1,
|
|
child: FlareActor(
|
|
"assets/rives/atoms_splash.flr",
|
|
fit: BoxFit.contain,
|
|
animation: "splash",
|
|
callback: (animation) async {
|
|
Navigator.of(context).pushNamedAndRemoveUntil(LoginPage.routeName, (routes) => true);
|
|
if (_settingProvider.isLoaded && (_settingProvider.user?.isLiveToken ?? false)) {
|
|
_userProvider.user = _settingProvider.user;
|
|
Navigator.of(context).pushNamedAndRemoveUntil(LandPage.routeName, (routes) => true);
|
|
}
|
|
},
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|