diff --git a/lib/core/widgets/pages/splash/splash_loading_page.dart b/lib/core/widgets/pages/splash/splash_loading_page.dart index a14ad6aa8..0a360f1c1 100644 --- a/lib/core/widgets/pages/splash/splash_loading_page.dart +++ b/lib/core/widgets/pages/splash/splash_loading_page.dart @@ -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 createState() => _SplashLoadingPageState(); +} + +class _SplashLoadingPageState extends State { + 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, + ), + ], + ), ); } }