215 lines
7.4 KiB
Dart
215 lines
7.4 KiB
Dart
import 'dart:async';
|
|
import 'dart:developer';
|
|
|
|
import 'package:connectivity_plus/connectivity_plus.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:flutter_svg/svg.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:regroup/Global.dart';
|
|
import 'package:regroup/Utils/Common/NoInternet.dart';
|
|
import 'package:regroup/onboarding/Signup/view_model/getUserprofile.dart';
|
|
import 'package:regroup/resources/routes/route_name.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
// import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
class SplashScreen extends StatefulWidget {
|
|
const SplashScreen({super.key});
|
|
|
|
@override
|
|
State<SplashScreen> createState() => _SplashScreenState();
|
|
}
|
|
|
|
class _SplashScreenState extends State<SplashScreen> {
|
|
// var _connectionStatus;
|
|
final Connectivity _connectivity = Connectivity();
|
|
List<ConnectivityResult> _connectionStatus = [ConnectivityResult.none];
|
|
|
|
// Future<void> checkInternet() async {
|
|
// final connectivityResult = await (Connectivity().checkConnectivity());
|
|
|
|
// if (connectivityResult == ConnectivityResult.wifi ||
|
|
// connectivityResult == ConnectivityResult.mobile) {
|
|
// setState(() {
|
|
// _connectionStatus = connectivityResult;
|
|
// });
|
|
// } else {
|
|
// setState(() {
|
|
// _connectionStatus = connectivityResult;
|
|
|
|
// });
|
|
// }
|
|
// }
|
|
|
|
Future<void> initConnectivity() async {
|
|
late List<ConnectivityResult> result;
|
|
try {
|
|
result = await _connectivity.checkConnectivity();
|
|
} on PlatformException catch (e) {
|
|
log('Couldn\'t check connectivity status', error: e);
|
|
return;
|
|
}
|
|
|
|
if (!mounted) {
|
|
return Future.value(null);
|
|
}
|
|
|
|
return _updateConnectionStatus(result);
|
|
}
|
|
|
|
Future<void> _updateConnectionStatus(List<ConnectivityResult> result) async {
|
|
setState(() {
|
|
_connectionStatus = result;
|
|
});
|
|
|
|
// ignore: avoid_print
|
|
print('Connectivity changed: $_connectionStatus');
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
initConnectivity();
|
|
log(_connectionStatus.toString());
|
|
|
|
// Future.delayed(Duration(seconds: 2), () async {
|
|
// if (_connectionStatus.contains(ConnectivityResult.none)) {
|
|
// var result = await Get.to(NoInternet());
|
|
// if (result != null && result) {
|
|
// Timer(const Duration(seconds: 1), () async {
|
|
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
// token = prefs.getString('access-token');
|
|
// emailid = prefs.getString('email');
|
|
// myusername = prefs.getString('username');
|
|
// fullname = prefs.getString('fullname');
|
|
// phonenumber = prefs.getString('phone');
|
|
|
|
// if (token == null || token!.isEmpty) {
|
|
// Get.toNamed(RouteName.onboarding1);
|
|
// } else {
|
|
// Getuserdetails().Getuser().then((value) {
|
|
// print(getuserobj!.data!.userData!.isProfileUpdated!);
|
|
// // .then((value) {
|
|
// if (getuserobj?.data?.userData?.isProfileUpdated == 0) {
|
|
// String? accountype =
|
|
// getuserobj?.data?.userData?.principalTypeXid.toString();
|
|
|
|
// if (accountype == "1") {
|
|
// Get.toNamed(RouteName.tellusindividualscreen,
|
|
// arguments: {'pageroute': "mainscreen"});
|
|
// } else if (accountype == "2") {
|
|
// Get.toNamed(RouteName.tellusbusinessscreen,
|
|
// arguments: {'pageroute': "mainscreen"});
|
|
// }
|
|
// } else {
|
|
// Get.toNamed(RouteName.mainscreen);
|
|
// }
|
|
// });
|
|
// // print(getuserobj!.data!.userData!.isProfileUpdated!);
|
|
|
|
// // // .then((value) {
|
|
// // if (getuserobj?.data?.userData?.isProfileUpdated == 0) {
|
|
// // String? accountype =
|
|
// // getuserobj?.data?.userData?.principalTypeXid.toString();
|
|
|
|
// // if (accountype == "1") {
|
|
// // Get.toNamed(RouteName.tellusindividualscreen,
|
|
// // arguments: {
|
|
// // 'pageroute' : "mainscreen"
|
|
// // }
|
|
// // );
|
|
// // } else if (accountype == "2") {
|
|
// // Get.toNamed(RouteName.tellusbusinessscreen);
|
|
// // }
|
|
// // } else {
|
|
// // Get.toNamed(RouteName.mainscreen);
|
|
// // }
|
|
// // }
|
|
// // );
|
|
// }
|
|
// });
|
|
// }
|
|
// } else {
|
|
// Timer(const Duration(seconds: 2), () async {
|
|
// print('this is second');
|
|
|
|
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
// token = prefs.getString('access-token');
|
|
// emailid = prefs.getString('email');
|
|
// myusername = prefs.getString('username');
|
|
// fullname = prefs.getString('fullname');
|
|
// phonenumber = prefs.getString('phone');
|
|
|
|
// if (token == null || token!.isEmpty) {
|
|
// Get.toNamed(RouteName.onboarding1);
|
|
// } else {
|
|
// Getuserdetails().Getuser().then((value) {
|
|
// print(getuserobj!.data!.userData!.isProfileUpdated!);
|
|
// // .then((value) {
|
|
// if (getuserobj?.data?.userData?.isProfileUpdated == 0) {
|
|
// String? accountype =
|
|
// getuserobj?.data?.userData?.principalTypeXid.toString();
|
|
|
|
// if (accountype == "1") {
|
|
// Get.toNamed(RouteName.tellusindividualscreen,
|
|
// arguments: {'pageroute': "mainscreen"});
|
|
// } else if (accountype == "2") {
|
|
// Get.toNamed(RouteName.tellusbusinessscreen,
|
|
// arguments: {'pageroute': "mainscreen"});
|
|
// }
|
|
// } else {
|
|
// Get.toNamed(RouteName.mainscreen);
|
|
// }
|
|
// });
|
|
|
|
// // }
|
|
// // );
|
|
// }
|
|
// });
|
|
// }
|
|
// });
|
|
|
|
Future.delayed(Duration(seconds: 2), () async {
|
|
Get.toNamed(RouteName.onboarding1);
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: const Color(0xff222935),
|
|
body: Container(
|
|
width: MediaQuery.of(context).size.width,
|
|
height: MediaQuery.of(context).size.height,
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
colors: [
|
|
Color(0xff009DAB).withOpacity(0.25),
|
|
Color(0xff35798C).withOpacity(0.44),
|
|
Color(0xffD90B2E).withOpacity(0.33),
|
|
Color(0xffD90B2E).withOpacity(0.52),
|
|
Color(0xffD90B2E).withOpacity(0.59),
|
|
],
|
|
)),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
SvgPicture.asset(
|
|
"assets/images/svg/mainsplash.svg",
|
|
width: 211.w,
|
|
height: 211.h,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|