This commit is contained in:
Hamza-Ayed
2024-07-17 17:35:40 +03:00
parent e6305f4ddc
commit 983fb6d0aa
16 changed files with 481 additions and 120 deletions

View File

@@ -0,0 +1,73 @@
import 'package:SEFER/constant/style.dart';
import 'package:flutter/material.dart';
import 'dart:async';
class MyCircularProgressIndicatorWithTimer extends StatelessWidget {
final Color backgroundColor;
final bool isLoading;
MyCircularProgressIndicatorWithTimer({
Key? key,
this.backgroundColor = Colors.transparent,
required this.isLoading,
}) : super(key: key);
final StreamController<int> _streamController = StreamController<int>();
void startTimer() {
int _timeLeft = 60;
Timer.periodic(const Duration(seconds: 1), (timer) {
if (_timeLeft > 0 && isLoading) {
_streamController.add(_timeLeft);
_timeLeft--;
} else {
timer.cancel();
_streamController.close();
}
});
}
@override
Widget build(BuildContext context) {
if (isLoading) {
startTimer();
}
return Center(
child: Container(
width: 200,
height: 200,
decoration: BoxDecoration(
color: backgroundColor,
shape: BoxShape.circle,
),
child: Stack(
children: [
const Center(child: CircularProgressIndicator()),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Align(
alignment: Alignment.center,
child: Image.asset(
'assets/images/logo.gif',
width: 140,
height: 140,
),
),
const SizedBox(height: 10),
StreamBuilder<int>(
stream: _streamController.stream,
initialData: 60,
builder: (context, snapshot) {
return Text('${snapshot.data}', style: AppStyle.title);
},
),
],
),
],
),
),
);
}
}