Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add loading indicator to splash page after duration #512

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
marfavi marked this conversation as resolved.
Show resolved Hide resolved
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,
),
],
),
);
}
}
Loading