-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
facb451
commit 59e85c4
Showing
1 changed file
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,54 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:coffeecard/core/styles/app_colors.dart'; | ||
import 'package:coffeecard/core/widgets/images/analog_logo.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:gap/gap.dart'; | ||
|
||
class SplashLoadingPage extends StatelessWidget { | ||
class SplashLoadingPage extends StatefulWidget { | ||
const SplashLoadingPage(); | ||
|
||
@override | ||
State<SplashLoadingPage> createState() => _SplashLoadingPageState(); | ||
} | ||
|
||
class _SplashLoadingPageState extends State<SplashLoadingPage> { | ||
Timer? countdownTimer; | ||
bool show = false; | ||
final timeBeforeShowLoadingIndicator = const Duration(seconds: 3); | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
startTimer(); | ||
} | ||
|
||
void startTimer() { | ||
countdownTimer = | ||
Timer.periodic(timeBeforeShowLoadingIndicator, (_) => stopTimer()); | ||
} | ||
|
||
void stopTimer() { | ||
setState(() { | ||
countdownTimer!.cancel(); | ||
show = true; | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const ColoredBox( | ||
return ColoredBox( | ||
color: AppColors.primary, | ||
child: Center(child: AnalogLogo()), | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
const AnalogLogo(), | ||
const Gap(32), | ||
CircularProgressIndicator( | ||
color: show ? AppColors.white : AppColors.primary, | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |