Skip to content

Commit

Permalink
Update side_menu_widget
Browse files Browse the repository at this point in the history
1. Change image and account details of drawerHeader
2. Remove Activity History and Help from side menu
3. Create prompt when logging out

Let me know if you all have any other things you all wanna change thanks
  • Loading branch information
Lim-Shi-Han committed Oct 28, 2021
1 parent 9d3f1e2 commit a62b680
Showing 1 changed file with 49 additions and 49 deletions.
98 changes: 49 additions & 49 deletions lib/screens/widgets/side_menu_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,28 @@ class SideMenu extends StatelessWidget {
// The menu follows this order.
_drawerHeader(),
_homeOption(context),
_activityHistoryOption(context),
_aboutOption(context),
_helpOption(context),
_settingsOption(context),
_logoutOption(context)
]),
);
}

// _drawerHeader : Contains the user's name, email, and avatar
// TODO: Might not be possible to get such info using the provided SDK,
// so might need to change to show other information.
UserAccountsDrawerHeader _drawerHeader() {
return UserAccountsDrawerHeader(
accountName: Text(
'Tan Ah Kow',
'Catch My Cadence',
),
accountEmail: Text(
'tanahkow@gmail.com',
),
currentAccountPicture: CircleAvatar(
backgroundColor: Colors.transparent,
child: Image.asset("assets/images/Spotify_Icon_RGB_Green.png"),
'Run to the Beat',
),
decoration: BoxDecoration(
color: Colors.blue,
image: DecorationImage(
image:
AssetImage("assets/images/splash_screen_without_words.png"),
fit: BoxFit.scaleDown)),
);
}

Expand All @@ -65,21 +63,6 @@ class SideMenu extends StatelessWidget {
});
}

// _activityHistoryOption : Routes the user to ActivityHistoryScreen.
ListTile _activityHistoryOption(BuildContext context) {
return ListTile(
title: Text(
'Activity History',
),
leading: Icon(
Icons.history,
),
// onTap:(){
// TODO: Link to ActivityHistory screen
// }
);
}

// _aboutOption : Routes the user to AboutScreen to learn more about the app.
ListTile _aboutOption(BuildContext context) {
return ListTile(
Expand All @@ -96,22 +79,6 @@ class SideMenu extends StatelessWidget {
});
}

// _helpOption: Routes the user to HelpScreen where they can access
// website(if applicable) or seek assistance.
ListTile _helpOption(BuildContext context) {
return ListTile(
title: Text(
'Help',
),
leading: Icon(
Icons.help,
),
// onTap:(){
// TODO: Link to Help screen
// }
);
}

// _settingsOption : Routes user to SettingsScreen.
ListTile _settingsOption(BuildContext context) {
return ListTile(
Expand All @@ -138,14 +105,47 @@ class SideMenu extends StatelessWidget {
Icons.logout,
),
onTap: () {
// Sets firstRunFlag to true.
Config.firstRunFlag = true;
log("Logging Out");
// "Restart" app by removing all screens from the stack
// and loading the LoadingScreen again.
Navigator.of(context).pushNamedAndRemoveUntil(
RouteDelegator.LOADING_SCREEN_ROUTE,
(Route<dynamic> route) => false);
showLogoutDialog(context);
});
}
}

showLogoutDialog(BuildContext context) {
// set up the button
Widget cancelButton = TextButton(
child: Text("CANCEL"),
onPressed: () {
Navigator.of(context).pop();
},
);
Widget okButton = TextButton(
child: Text("OK"),
onPressed: () {
// Sets firstRunFlag to true.
Config.firstRunFlag = true;
log("Logging Out");
// "Restart" app by removing all screens from the stack
// and loading the LoadingScreen again.
Navigator.of(context).pushNamedAndRemoveUntil(
RouteDelegator.LOADING_SCREEN_ROUTE, (Route<dynamic> route) => false);
},
);

// set up the AlertDialog
AlertDialog alert = AlertDialog(
title: Text("Catch My Cadence"),
content: Text("Are you sure you want to logout?"),
actions: [
cancelButton,
okButton,
],
);

// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}

0 comments on commit a62b680

Please sign in to comment.