diff --git a/lib/pages/TimeTableEntry.dart b/lib/pages/TimeTableEntry.dart index 5f10b90..dbdf076 100644 --- a/lib/pages/TimeTableEntry.dart +++ b/lib/pages/TimeTableEntry.dart @@ -24,7 +24,6 @@ class TimeTableEntry extends StatefulWidget { State createState() => TimeTableEntryState(); } - List subjectIcons = [ Icons.school, // Icons.book, @@ -193,7 +192,7 @@ class TimeTableEntryState extends State { statsUpdate = true; ScaffoldMessenger.of(context).showSnackBar( const SnackBar( - content: Text("Schedule has been added for pre-existing course!"), + content: Text("Schedule has been added for existing course!"), ), ); } else { @@ -205,7 +204,7 @@ class TimeTableEntryState extends State { content: Text("Failed to add Schedule"), ), ); - throw Exception('Failed to add schedule for pre-existing course'); + throw Exception('Failed to add schedule'); } } @@ -230,7 +229,7 @@ class TimeTableEntryState extends State { statsUpdate = true; ScaffoldMessenger.of(context).showSnackBar( const SnackBar( - content: Text("Course had been added!"), + content: Text("Course has been added!"), ), ); } else { @@ -390,7 +389,6 @@ class TimeTableEntryState extends State { } }, ), - ], ), Center( diff --git a/lib/pages/onboarding.dart b/lib/pages/onboarding.dart index adb091d..3204734 100644 --- a/lib/pages/onboarding.dart +++ b/lib/pages/onboarding.dart @@ -9,10 +9,9 @@ import 'dart:io'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'dart:convert'; import 'package:attendence1/pages/homepage.dart'; + class OnBoard extends StatefulWidget { - const OnBoard({super.key}); - @override State createState() => _OnBoardState(); @@ -52,28 +51,25 @@ class _OnBoardState extends State { }), ); if (response.statusCode == 201) { - - Navigator.pop(context); + Navigator.pop(context); // Signal updates on navigation - statusUpdate = true ; - Navigator.of(context).pushNamedAndRemoveUntil('/mainPage', (route) => false); + statusUpdate = true; + Navigator.of(context) + .pushNamedAndRemoveUntil('/mainPage', (route) => false); _statsGlobalKey.currentState?.getStats(); ScaffoldMessenger.of(context).showSnackBar( const SnackBar( - content: Text("Timetable details have been updated"), + content: Text("Timetable has been created"), ), ); - - } else { print(response.body); ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text("Could not update timetable details"), + content: Text("Could not create timetable"), ), ); - throw Exception('Failed to add schedule for pre-existing course'); + throw Exception("Could not create timetable"); } } @@ -93,17 +89,17 @@ class _OnBoardState extends State { // getTimeTable(); ScaffoldMessenger.of(context).showSnackBar( const SnackBar( - content: Text("Timetable details have been updated"), + content: Text("Timetable has been updated"), ), ); } else { print(response.body); ScaffoldMessenger.of(context).showSnackBar( const SnackBar( - content: Text("Could not update timetable details"), + content: Text("Could not update timetable"), ), ); - throw Exception('Failed to add new timetable'); + throw Exception('Failed to update timetable'); } } @@ -136,16 +132,18 @@ class _OnBoardState extends State { Widget yesButton = TextButton( child: const Text("Yes"), onPressed: () { - timeTablePresets(); + timeTablePresets(); statusUpdate = true; - Navigator.of(context).pushNamedAndRemoveUntil('/mainPage', (route) => false); + Navigator.of(context) + .pushNamedAndRemoveUntil('/mainPage', (route) => false); }, ); // set up the AlertDialog AlertDialog alert = AlertDialog( title: const Text("Are you sure ? "), - content: const Text("You would lose all your current data if you did this."), + content: + const Text("You would lose all your current data if you did this."), actions: [yesButton], ); @@ -211,8 +209,8 @@ class _OnBoardState extends State { ), )), Padding( - padding: - const EdgeInsets.only(left: 24, right: 24, bottom: 24, top: 24), + padding: const EdgeInsets.only( + left: 24, right: 24, bottom: 24, top: 24), child: DropdownMenuItem( child: Center( child: FutureBuilder( @@ -372,7 +370,6 @@ class _OnBoardState extends State { _timeTableName.isNotEmpty && _minAttendence != 0) { submitTimetable(); - } else { ScaffoldMessenger.of(context).showSnackBar( const SnackBar( diff --git a/lib/pages/signin.dart b/lib/pages/signin.dart index ec6e4b4..917df1e 100644 --- a/lib/pages/signin.dart +++ b/lib/pages/signin.dart @@ -39,7 +39,7 @@ class _LoginPageState extends State { await storage.write(key: 'token', value: token); } else { ScaffoldMessenger.of(context).showSnackBar(const SnackBar( - content: Text("Login failed, please try again"), + content: Text("Sign in, please try again"), )); } return response; @@ -190,7 +190,8 @@ class _LoginPageState extends State { Navigator.pushReplacement( context, MaterialPageRoute( - builder: (context) => const SignupPage()), + builder: (context) => + const SignupPage()), ); }, child: const Text("Signup ? ", diff --git a/lib/pages/signup.dart b/lib/pages/signup.dart index 0bc218f..06da6d5 100644 --- a/lib/pages/signup.dart +++ b/lib/pages/signup.dart @@ -29,12 +29,11 @@ class _SignupPageState extends State { if (response.statusCode == 201) { ScaffoldMessenger.of(context) - .showSnackBar(const SnackBar(content: Text("SignUp Succesfull")) - ); - Navigator.pushNamed(context, '/'); + .showSnackBar(const SnackBar(content: Text("SignUp Succesfull"))); + Navigator.pushNamed(context, '/'); } else { ScaffoldMessenger.of(context).showSnackBar(const SnackBar( - content: Text("Your Password is weak/User already exists"), + content: Text("Your Password is weak/user already exists"), )); } } @@ -120,15 +119,15 @@ class _SignupPageState extends State { padding: const EdgeInsets.all(8.0), child: GestureDetector( onTap: () { - if (PasswordController.text == ConfirmPasswordController.text) { + if (PasswordController.text == + ConfirmPasswordController.text) { sendPostRequest(); + } else { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: + Text("Passwords do not match"))); } - else { - ScaffoldMessenger.of(context) - .showSnackBar(const SnackBar(content: Text("Passwords donot match")) - ); - } - }, child: Container( width: 405, diff --git a/lib/pages/subject.dart b/lib/pages/subject.dart index afedd26..462c9d2 100644 --- a/lib/pages/subject.dart +++ b/lib/pages/subject.dart @@ -16,7 +16,6 @@ late int _day; late int hello; List subjectIcons = [ Icons.school, - ]; Future getStatus() async { @@ -49,7 +48,8 @@ class TimeTableState extends State with RouteAware { super.initState(); getStatus(); } - String color = '' ; + + String color = ''; Future getToken() async { dynamic token = await storage.read(key: 'token'); return token; @@ -127,7 +127,7 @@ class TimeTableState extends State with RouteAware { } } - late Color c1 ; + late Color c1; void addHoliday() async { final response = await http.post( Uri.parse("$apiUrl/schedule_selector"), @@ -136,17 +136,19 @@ class TimeTableState extends State with RouteAware { HttpHeaders.contentTypeHeader: "application/json" }, body: jsonEncode( - {"day_of_week": _day, "date": DateFormat('yyyy-MM-dd').format(selectedDate)}, + { + "day_of_week": _day, + "date": DateFormat('yyyy-MM-dd').format(selectedDate) + }, ), ); if (response.statusCode == 201) { getStatus(date: selectedDate); //_selectDate(context) - - print(_day); + ScaffoldMessenger.of(context).showSnackBar( const SnackBar( - content: Text("TimeTable Selected"), + content: Text("Copied Schedule"), ), ); } else { @@ -155,7 +157,7 @@ class TimeTableState extends State with RouteAware { print(DateFormat('EEEE').format(selectedDate)); ScaffoldMessenger.of(context).showSnackBar( const SnackBar( - content: Text("TimeTable not Selected"), + content: Text("Could not copy schedule"), ), ); throw Exception('Failed to add TimeTable'); @@ -164,7 +166,7 @@ class TimeTableState extends State with RouteAware { DateTime selectedDate = DateTime.now(); - Future _selectDate(BuildContext context) async { + Future _selectDate(BuildContext context) async { final DateTime? picked = await showDatePicker( context: context, initialDate: selectedDate, @@ -187,34 +189,35 @@ class TimeTableState extends State with RouteAware { var randomIndex = Random().nextInt(subjectIcons.length); return subjectIcons[randomIndex]; } + final currentDay = DateFormat('EEEE').format(DateTime.now()); return Scaffold( backgroundColor: Color.fromARGB(255, 7, 9, 15), appBar: AppBar( - toolbarHeight: MediaQuery.of(context).size.height/12, + toolbarHeight: MediaQuery.of(context).size.height / 12, actions: [ Column( children: [ Row( children: [ - Align(alignment: Alignment.topCenter,child: - Padding(padding: EdgeInsets.only(left:MediaQuery.of(context).size.width/25), - child: - Text( - days[selectedDate.weekday].toString(), - - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 32), - ), - - )), + Align( + alignment: Alignment.topCenter, + child: Padding( + padding: EdgeInsets.only( + left: MediaQuery.of(context).size.width / 25), + child: Text( + days[selectedDate.weekday].toString(), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 32), + ), + )), SizedBox( width: 50, ), Padding( - padding: const EdgeInsets.only(right:8), + padding: const EdgeInsets.only(right: 8), child: ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all( @@ -225,12 +228,11 @@ class TimeTableState extends State with RouteAware { }, child: Text("REWIND TIME", style: TextStyle(color: Colors.black))), - ), - ], ), - Divider(color: Colors.white)], + Divider(color: Colors.white) + ], ), ], automaticallyImplyLeading: false, @@ -244,13 +246,11 @@ class TimeTableState extends State with RouteAware { courses[index]["name"].toString().toCapitalized(); String status = courses[index]["status"]; if (status == 'bunked') { - c1 = Colors.red ; - } - else if (status == 'cancelled') { + c1 = Colors.red; + } else if (status == 'cancelled') { c1 = Colors.blue.shade700; - } - else { - c1 = Colors.green ; + } else { + c1 = Colors.green; } if (courses.isEmpty) { return Container( @@ -299,20 +299,20 @@ class TimeTableState extends State with RouteAware { style: TextStyle( color: Colors.white, fontSize: 32), ), - trailing:Container( - width: 100, - height: 40, - decoration: BoxDecoration( - color: c1, - borderRadius: BorderRadius.circular(20), - shape: BoxShape.rectangle - ), - child: Center(child:Text( - "$status", - style: TextStyle( - color: Colors.white, fontSize: 15)), - -)), + trailing: Container( + width: 100, + height: 40, + decoration: BoxDecoration( + color: c1, + borderRadius: + BorderRadius.circular(20), + shape: BoxShape.rectangle), + child: Center( + child: Text("$status", + style: TextStyle( + color: Colors.white, + fontSize: 15)), + )), ), ))), SizedBox( @@ -336,7 +336,8 @@ class TimeTableState extends State with RouteAware { style: TextStyle( color: Colors.white, fontFamily: 'alpha', - fontSize: MediaQuery.of(context).size.width/17, + fontSize: + MediaQuery.of(context).size.width / 17, fontWeight: FontWeight.w100), )), SizedBox( @@ -345,23 +346,20 @@ class TimeTableState extends State with RouteAware { ), DropdownMenu( - width: MediaQuery.of(context).size.width/2, + width: MediaQuery.of(context).size.width / 2, hintText: "Copy Schedule", inputDecorationTheme: InputDecorationTheme( border: OutlineInputBorder( - borderRadius: BorderRadius.circular(20), ), fillColor: const Color.fromARGB(255, 211, 255, 153), filled: true, - enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(20))), dropdownMenuEntries: days.entries.map( (days) { return DropdownMenuEntry( - value: days.key, label: days.value); }, ).toList(), @@ -369,8 +367,6 @@ class TimeTableState extends State with RouteAware { _day = days!; addHoliday(); getStatus(); - - }, ), @@ -385,4 +381,5 @@ class TimeTableState extends State with RouteAware { ), )); } -} \ No newline at end of file +} +