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

Added Maintainance Screen #226

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions assets/animation/maintainance.json

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions lib/new_ui/screens/Maintainance_Screen/maintainance_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:go_router/go_router.dart';
import 'package:lottie/lottie.dart';

class MaintainanceScreen extends StatefulWidget {

@override
State<MaintainanceScreen> createState() => _MaintainanceScreenState();
}

class _MaintainanceScreenState extends State<MaintainanceScreen> {


@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
body:Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children:[
Container(
height: size.height*0.3,
width:size.width*0.8,
child: Lottie.asset("assets/animation/maintainance.json",fit: BoxFit.fill),
),
RichText(
text: TextSpan(children: [
TextSpan(text:"Sorry App Under Maintainance ",style: TextStyle(color: Colors.white),),
WidgetSpan(child: Icon(Icons.warning,color: Colors.yellow,),),
],
),
),
],
),
),
);
}
}
4 changes: 3 additions & 1 deletion lib/new_ui/screens/launch_screen/launch_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:async';
import 'package:bcrypt/bcrypt.dart';
import 'package:go_router/go_router.dart';
import 'package:tsec_app/new_ui/colors.dart';
import 'package:tsec_app/new_ui/screens/Maintainance_Screen/maintainance_screen.dart';
// import 'package:tsec_app/new_ui/screens/login_screen/login_screen.dart';

class LaunchScreen extends StatefulWidget {
Expand Down Expand Up @@ -57,7 +58,8 @@ class _LaunchScreenState extends State<LaunchScreen> {

void _navigateToLogin() {
print('Navigating to LoginScreen');
context.go('/login');
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context)=>MaintainanceScreen(),),);
/*context.go('/login');*/
}

Future<void> _checkAnswer() async {
Expand Down
17 changes: 17 additions & 0 deletions lib/new_ui/screens/splash_screen/splash_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:tsec_app/models/student_model/student_model.dart';
import 'package:tsec_app/new_ui/screens/Maintainance_Screen/maintainance_screen.dart';
import 'package:tsec_app/new_ui/screens/main_screen/main_screen.dart';
import 'package:tsec_app/new_ui/screens/profile_screen/profile_screen.dart';
import 'package:tsec_app/new_ui/screens/launch_screen/launch_screen.dart';
Expand Down Expand Up @@ -56,6 +57,7 @@ class _SplashScreenState extends ConsumerState<SplashScreen> {
void initState() {
super.initState();
_fetchLaunchDate();
fetchMaintainanceStatus();
}

//check permissions
Expand All @@ -70,6 +72,17 @@ class _SplashScreenState extends ConsumerState<SplashScreen> {
}
}

bool navigateToMaintainance = false;
//MaintainanceScreen
final doc = FirebaseFirestore.instance.collection("Maintainance").doc("Maintainance");
fetchMaintainanceStatus()async{
final get = await doc.get();
final data = get.data() as Map<String,dynamic>;
setState(() {
navigateToMaintainance = data['underBreak'];
});
}

@override
Widget build(BuildContext context) {
if (!_isLaunchDateFetched) {
Expand All @@ -79,6 +92,10 @@ class _SplashScreenState extends ConsumerState<SplashScreen> {
),
);
}
print("Executed Build");
if(navigateToMaintainance){
return MaintainanceScreen();
}

if (_launchDate != null && DateTime.now().isBefore(_launchDate!)) {
return LaunchScreen();
Expand Down
Loading