Skip to content

Commit

Permalink
multiple bug fixes and new features added (#112)
Browse files Browse the repository at this point in the history
* add tooltip

* fix colour schemes in auth

* update destinations and corresponding icons

* fixed a major message screen bug

* fix leave group button bug

* group leave button fixed

* small fix

* added option to change email after registration

* fix ordering in dashboard

* confirm password field added on registration page

* fix user profile UI

* Report bug button added in settings

* fixed FAB which showed before inGroup was fetched

* deleting the group if last member leaves

* end trip added and saving previous groups too

* fixed saving array of users in group document

* fix ProgressBar

* fix renderflex overflow bug
  • Loading branch information
kshitijalwadhi committed Jun 19, 2020
1 parent 452fd8b commit 0ceebb9
Show file tree
Hide file tree
Showing 7 changed files with 318 additions and 187 deletions.
31 changes: 31 additions & 0 deletions lib/screens/authenticate/register.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class _RegisterState extends State<Register> {

String email = '';
String password = '';
String confirmpass = '';
String name = '';
String mobileNum = '';
String hostel;
Expand Down Expand Up @@ -144,6 +145,36 @@ class _RegisterState extends State<Register> {
},
),
SizedBox(height: 20.0),
TextFormField(
decoration: textInputDecoration.copyWith(
hintText: 'Confirm Password',
suffixIcon: IconButton(
icon: Icon(
passwordHide ? Icons.visibility_off : Icons.visibility,
color: Theme.of(context).accentColor,
),
onPressed: () {
setState(() {
passwordHide = !passwordHide;
});
},
),
),
validator: (val) {
if (val.length < 6) {
return 'Enter a password greater than 6 characters.';
}
if (val != password) {
return 'Password not matching';
}
return null;
},
obscureText: passwordHide,
onChanged: (val) {
setState(() => confirmpass = val);
},
),
SizedBox(height: 20.0),
TextFormField(
decoration: textInputDecoration.copyWith(hintText: 'Name'),
validator: (val) => val.isEmpty ? 'Enter a valid Name' : null,
Expand Down
59 changes: 32 additions & 27 deletions lib/screens/dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,20 @@ class _DashboardState extends State<Dashboard> {
return null;
}

var inGroupFetch = false;
@override
Widget build(BuildContext context) {
final currentuser = Provider.of<FirebaseUser>(context);
Firestore.instance.collection('userdetails').document(currentuser.uid).get().then((value) {
if (value.data['currentGroup'] != null) {
setState(() {
inGroup = true;
inGroupFetch = true;
});
} else {
setState(() {
inGroup = false;
inGroupFetch = true;
});
}
});
Expand Down Expand Up @@ -135,33 +138,35 @@ class _DashboardState extends State<Dashboard> {
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
floatingActionButton: !inGroup
? Padding(
padding: const EdgeInsets.fromLTRB(0, 20, 0, 60),
child: FloatingActionButton(
splashColor: Theme.of(context).primaryColor,
onPressed: () => _startCreatingTrip(context),
child: Tooltip(
message: 'Create Group',
verticalOffset: -60,
child: Icon(Icons.add),
),
),
)
: Padding(
padding: const EdgeInsets.fromLTRB(0, 20, 0, 60),
child: FloatingActionButton(
splashColor: Theme.of(context).primaryColor,
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => GroupPage()));
},
child: Tooltip(
message: 'Group Details',
verticalOffset: -60,
child: Icon(Icons.group),
),
),
),
floatingActionButton: inGroupFetch
? !inGroup
? Padding(
padding: const EdgeInsets.fromLTRB(0, 20, 0, 60),
child: FloatingActionButton(
splashColor: Theme.of(context).primaryColor,
onPressed: () => _startCreatingTrip(context),
child: Tooltip(
message: 'Create Group',
verticalOffset: -60,
child: Icon(Icons.add),
),
),
)
: Padding(
padding: const EdgeInsets.fromLTRB(0, 20, 0, 60),
child: FloatingActionButton(
splashColor: Theme.of(context).primaryColor,
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => GroupPage()));
},
child: Tooltip(
message: 'Group Details',
verticalOffset: -60,
child: Icon(Icons.group),
),
),
)
: null,
);
}
}
112 changes: 82 additions & 30 deletions lib/screens/groupscreen/group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class _GroupPageState extends State<GroupPage> with AutomaticKeepAliveClientMixi
}

bool buttonEnabled = true;
Timestamp endTimeStamp = Timestamp.now();
bool timestampFlag = false;

@override
bool get wantKeepAlive => true;
Expand All @@ -65,46 +67,96 @@ class _GroupPageState extends State<GroupPage> with AutomaticKeepAliveClientMixi
end = DateFormat('dd.MM.yyyy - kk:mm a').format(value.data['end'].toDate());
grpOwner = value.data['owner'];
presentNum = value.data['numberOfMembers'].toString();
endTimeStamp = value.data['end'];
loading = false;
});
if (endTimeStamp.compareTo(Timestamp.now()) < 0) {
setState(() {
timestampFlag = true;
});
}
}
});

return loading
? Loading()
: Scaffold(
appBar: AppBar(
title: Text('Group Details'),
actions: <Widget>[
FlatButton.icon(
textColor: getVisibleColorOnPrimaryColor(context),
icon: Icon(FontAwesomeIcons.signOutAlt),
onPressed: () async {
ProgressDialog pr;
pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false);
pr.style(
message: 'Leaving Group...',
backgroundColor: Theme.of(context).backgroundColor,
messageTextStyle: TextStyle(color: Theme.of(context).accentColor),
);
await pr.show();
await Future.delayed(Duration(seconds: 1)); // sudden logout will show ProgressDialog for a very short time making it not very nice to see :p
try {
setState(() {
buttonEnabled = false;
});
await _request.exitGroup();
Navigator.pop(context);
await pr.hide();
} catch (err) {
// show e.message
await pr.hide();
String errStr = err.message ?? err.toString();
final snackBar = SnackBar(content: Text(errStr), duration: Duration(seconds: 3));
scaffoldKey.currentState.showSnackBar(snackBar);
}
},
label: Text('Leave Group'),
)
buttonEnabled
? timestampFlag
? FlatButton.icon(
textColor: getVisibleColorOnPrimaryColor(context),
icon: Icon(FontAwesomeIcons.signOutAlt),
onPressed: () async {
ProgressDialog pr;
pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false);
pr.style(
message: 'Ending Trip...',
backgroundColor: Theme.of(context).backgroundColor,
messageTextStyle: TextStyle(color: Theme.of(context).accentColor),
);
await pr.show();
await Future.delayed(Duration(seconds: 1));
try {
setState(() {
buttonEnabled = false;
});
await _request.exitGroup();
Navigator.pop(context);
await pr.hide();
} catch (e) {
await pr.hide();
String errStr = e.message ?? e.toString();
final snackBar = SnackBar(content: Text(errStr), duration: Duration(seconds: 3));
scaffoldKey.currentState.showSnackBar(snackBar);
}
},
label: Text('End Trip'),
)
: FlatButton.icon(
textColor: getVisibleColorOnPrimaryColor(context),
icon: Icon(FontAwesomeIcons.signOutAlt),
onPressed: () async {
ProgressDialog pr;
pr = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false, showLogs: false);
pr.style(
message: 'Leaving Group...',
backgroundColor: Theme.of(context).backgroundColor,
messageTextStyle: TextStyle(color: Theme.of(context).accentColor),
);
await pr.show();
await Future.delayed(Duration(seconds: 1));
try {
setState(() {
buttonEnabled = false;
});
await _request.exitGroup();
Navigator.pop(context);
await pr.hide();
} catch (e) {
await pr.hide();
String errStr = e.message ?? e.toString();
final snackBar = SnackBar(content: Text(errStr), duration: Duration(seconds: 3));
scaffoldKey.currentState.showSnackBar(snackBar);
}
},
label: Text('Leave Group'),
)
: timestampFlag
? FlatButton.icon(
textColor: getVisibleColorOnPrimaryColor(context),
icon: Icon(FontAwesomeIcons.signOutAlt),
onPressed: null,
label: Text('End Trip'),
)
: FlatButton.icon(
textColor: getVisibleColorOnPrimaryColor(context),
icon: Icon(FontAwesomeIcons.signOutAlt),
onPressed: null,
label: Text('Leave Group'),
)
],
),
body: Container(
Expand Down
6 changes: 5 additions & 1 deletion lib/screens/profile/userprofile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class _MyProfileState extends State<MyProfile> {
onTap: () {},
title: Center(
child: Text(
'Gender',
'GENDER',
style: TextStyle(fontWeight: FontWeight.w700, fontSize: 20),
),
),
Expand All @@ -220,6 +220,7 @@ class _MyProfileState extends State<MyProfile> {
title: Center(
child: Text(
'TOTAL RIDES',
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18),
),
),
Expand All @@ -237,6 +238,7 @@ class _MyProfileState extends State<MyProfile> {
title: Center(
child: Text(
'CANCELLED TRIPS',
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18),
),
),
Expand Down Expand Up @@ -292,6 +294,7 @@ class _MyProfileState extends State<MyProfile> {
title: Center(
child: Text(
'MOBILE NUMBER',
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18),
),
),
Expand All @@ -308,6 +311,7 @@ class _MyProfileState extends State<MyProfile> {
title: Center(
child: Text(
'USER RATING',
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18),
),
),
Expand Down
23 changes: 23 additions & 0 deletions lib/screens/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:shareacab/main.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:shareacab/services/auth.dart';
import 'package:progress_dialog/progress_dialog.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
Expand Down Expand Up @@ -81,6 +82,28 @@ class _SettingsState extends State<Settings> {
),
),
),
ListTile(
title: Text(
'Bug Report',
style: TextStyle(fontSize: 28.0),
),
contentPadding: EdgeInsets.all(26.0),
subtitle: Text('Found a bug, report here:'),
trailing: Tooltip(
message: 'Report Bug',
verticalOffset: -60,
child: IconButton(
icon: Icon(
Icons.bug_report,
size: 40.0,
color: Theme.of(context).accentColor,
),
onPressed: () {
launch('https://github.com/devclub-iitd/ShareACab/issues/new?assignees=&labels=bug&template=bug_report.md&title=Issue+Title+%40AssignedUser');
},
),
),
),
],
));
}
Expand Down

0 comments on commit 0ceebb9

Please sign in to comment.