Skip to content

Commit

Permalink
add loding indicator to splash page
Browse files Browse the repository at this point in the history
  • Loading branch information
fremartini committed Sep 28, 2023
1 parent facb451 commit 59e85c4
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions lib/core/widgets/pages/splash/splash_loading_page.dart
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,
),
],
),
);
}
}

0 comments on commit 59e85c4

Please sign in to comment.