Commit 7f183f40 authored by Izol's avatar Izol

adjust splash screen

parent 5f80d00b
......@@ -57,20 +57,52 @@ class _SplashPageState extends State<SplashPage> with TickerProviderStateMixin{
curve: Curves.easeIn
);
void navigationToGetOutlet() {
Navigator.of(context)
.restorablePopAndPushNamed('/set-merchant', arguments: kIsTap);
@override
void initState() {
super.initState();
checkPermissionAndStartService();
}
void navigationToAktivation() {
// Navigator.of(context).pushReplacementNamed('/tap-card-aktivasi');
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
const TapCardAktivasi(isTap: true)));
void checkPermissionAndStartService() async {
var storageStatus = await Permission.storage.request();
var phoneStatus = await Permission.phone.request();
while (!(storageStatus.isGranted && phoneStatus.isGranted)) {
bool shouldRequestStorage = storageStatus.isDenied || storageStatus.isPermanentlyDenied;
bool shouldRequestPhone = phoneStatus.isDenied || phoneStatus.isPermanentlyDenied;
if (shouldRequestStorage) {
storageStatus = await Permission.storage.request();
}
if (shouldRequestPhone) {
phoneStatus = await Permission.phone.request();
}
if (!(shouldRequestStorage || shouldRequestPhone)) {
// Handle the case when user declines the permission request permanently
break;
}
}
if (storageStatus.isGranted && phoneStatus.isGranted) {
await initService();
checkActivationAfterDelay();
} else {
// Handle the case when user declines the permission request
}
}
Future<void> initService() async {
await StartService.initLibrary();
}
void checkActivationAfterDelay() {
Future.delayed(Duration(seconds: 3), () {
checkActivation();
});
}
void navigationToSetConfig() {
Navigator.pushReplacement(
context,
......@@ -79,66 +111,22 @@ class _SplashPageState extends State<SplashPage> with TickerProviderStateMixin{
const SetMerchant(isConfig: true)));
}
@override
void initState() {
super.initState();
permissionState();
}
void permissionState() async {
if (await Permission.storage.request().isGranted &&
await Permission.phone.request().isGranted) {
StartService.initLibrary().then((value) {
Future.delayed(Duration(seconds: 3), () {
checkAktivation();
});
});
// Future.delayed(Duration(seconds: 10), () {
// showDialog(
// context: context,
// builder: (BuildContext context) {
// return AlertDialog(
// title: Text("Error"),
// content: Text("The app is taking too long to start. Please try again."),
// actions: <Widget>[
// TextButton(
// child: Text("Try Again"),
// onPressed: () {
// Navigator.of(context).pop();
// permissionState();
// },
// ),
// TextButton(
// child: Text("Cancel"),
// onPressed: () {
// Navigator.of(context).pop();
// },
// ),
// ],
// );
// },
// );
// });
void navigationToGetOutlet() {
Navigator.of(context)
.restorablePopAndPushNamed('/set-merchant', arguments: kIsTap);
}
// You can request multiple permissions at once.
Map<Permission, PermissionStatus> statuses = await [
Permission.phone,
Permission.storage,
].request();
print("phone : ${statuses[Permission.phone]}");
print("storage : ${statuses[Permission.storage]}");
void navigationToAktivation() {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
const TapCardAktivasi(isTap: true)));
}
void checkAktivation() {
void checkActivation() {
bool isDoneConfig = PreferencesHelper.getBool(kIsDoneConfig);
bool isTapConfig = PreferencesHelper.getBool(kIsTap);
// bool isHashOutlet = PreferencesHelper.getBool(kTap);
// bool isHashOutlet = PreferencesHelper.getString('multioutletname',"false") ;
print('ini pesan:$isDoneConfig');
print("ini pesan $isTapConfig");
if (isDoneConfig) {
if (isTapConfig && isDoneConfig) {
......@@ -151,7 +139,6 @@ class _SplashPageState extends State<SplashPage> with TickerProviderStateMixin{
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
......@@ -189,3 +176,5 @@ class _SplashPageState extends State<SplashPage> with TickerProviderStateMixin{
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment