Skip to content

Commit

Permalink
fix: fixed snackbar messages
Browse files Browse the repository at this point in the history
  • Loading branch information
hrideshmg committed Apr 12, 2024
1 parent 8581f32 commit 6176895
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 94 deletions.
8 changes: 3 additions & 5 deletions lib/pages/TimeTableEntry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class TimeTableEntry extends StatefulWidget {
State<TimeTableEntry> createState() => TimeTableEntryState();
}


List<IconData> subjectIcons = [
Icons.school,
// Icons.book,
Expand Down Expand Up @@ -193,7 +192,7 @@ class TimeTableEntryState extends State<TimeTableEntry> {
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 {
Expand All @@ -205,7 +204,7 @@ class TimeTableEntryState extends State<TimeTableEntry> {
content: Text("Failed to add Schedule"),
),
);
throw Exception('Failed to add schedule for pre-existing course');
throw Exception('Failed to add schedule');
}
}

Expand All @@ -230,7 +229,7 @@ class TimeTableEntryState extends State<TimeTableEntry> {
statsUpdate = true;
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Course had been added!"),
content: Text("Course has been added!"),
),
);
} else {
Expand Down Expand Up @@ -390,7 +389,6 @@ class TimeTableEntryState extends State<TimeTableEntry> {
}
},
),

],
),
Center(
Expand Down
39 changes: 18 additions & 21 deletions lib/pages/onboarding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<OnBoard> createState() => _OnBoardState();
Expand Down Expand Up @@ -52,28 +51,25 @@ class _OnBoardState extends State<OnBoard> {
}),
);
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");
}
}

Expand All @@ -93,17 +89,17 @@ class _OnBoardState extends State<OnBoard> {
// 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');
}
}

Expand Down Expand Up @@ -136,16 +132,18 @@ class _OnBoardState extends State<OnBoard> {
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],
);

Expand Down Expand Up @@ -211,8 +209,8 @@ class _OnBoardState extends State<OnBoard> {
),
)),
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(
Expand Down Expand Up @@ -372,7 +370,6 @@ class _OnBoardState extends State<OnBoard> {
_timeTableName.isNotEmpty &&
_minAttendence != 0) {
submitTimetable();

} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
Expand Down
5 changes: 3 additions & 2 deletions lib/pages/signin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class _LoginPageState extends State<LoginPage> {
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;
Expand Down Expand Up @@ -190,7 +190,8 @@ class _LoginPageState extends State<LoginPage> {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => const SignupPage()),
builder: (context) =>
const SignupPage()),
);
},
child: const Text("Signup ? ",
Expand Down
21 changes: 10 additions & 11 deletions lib/pages/signup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ class _SignupPageState extends State<SignupPage> {

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"),
));
}
}
Expand Down Expand Up @@ -120,15 +119,15 @@ class _SignupPageState extends State<SignupPage> {
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,
Expand Down
Loading

0 comments on commit 6176895

Please sign in to comment.