Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #106 from theTaoTeam/homepageupdate
Browse files Browse the repository at this point in the history
fix(homepage, addusertojar): refactor add user to jar and make sure h…
  • Loading branch information
Scott Clampet authored Apr 30, 2019
2 parents e39ded9 + 1b36947 commit 5e78f8e
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 70 deletions.
1 change: 1 addition & 0 deletions fude_app/lib/pages/jars/jar_add.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class _JarPageState extends State<AddJarPage> {
updateImage: updateImage,
updateCategoryCount: updateCategoryCount,
categoryCount: categoryCount,
categories: _formData['categories'],
),
SizedBox(height: height * 0.035),
Row(
Expand Down
137 changes: 72 additions & 65 deletions fude_app/lib/pages/jars/jar_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class _JarPageState extends State<EditJarPage> {
} else {
formKey.currentState.save();
model.updateJar(_formData);
model.fetchAllUserJars(model.currUserEmail);
Navigator.pop(context);
}
}
Expand Down Expand Up @@ -171,76 +172,82 @@ class _JarPageState extends State<EditJarPage> {
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
),
child: !loadingJarData ? ListView(
shrinkWrap: true,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(height: height * 0.04),
EditJarForm(
formKey: formKey,
model: model,
jar: model.selectedJar,
addCategoryToRemoveList: addCategoryToRemoveList,
categories: currentCategories,
needsAtLeastOneCategory: needsAtLeastOneCategory,
updateCategory: updateCategory,
updateTitle: updateTitle,
updateImage: updateImage,
updateCategoryCount: updateCategoryCount,
categoryCount: categoryCount,
),
AddUserToJarForm(
addUserFormKey: addUserFormKey,
addUserToJar: addUserToJar,
submitAddUser: submitAddUser,
userHasBeenAdded: userHasBeenAdded,
needToInviteThisUser: needToInviteThisUser,
model: model),
SizedBox(height: height * 0.04),
Container(
padding:
EdgeInsets.fromLTRB(width * 0.045, 0, width * 0.045, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
child: !loadingJarData
? ListView(
shrinkWrap: true,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: Text(
'UPDATE JAR',
style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
fontSize: 15,
letterSpacing: 5,
),
),
elevation: 7,
highlightElevation: 1,
padding: EdgeInsets.all(15),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)),
color: Theme.of(context).secondaryHeaderColor,
splashColor: Colors.transparent,
highlightColor: Theme.of(context).primaryColor,
onPressed: () => updateJar(model),
SizedBox(height: height * 0.04),
EditJarForm(
formKey: formKey,
model: model,
jar: model.selectedJar,
addCategoryToRemoveList: addCategoryToRemoveList,
categories: currentCategories,
needsAtLeastOneCategory: needsAtLeastOneCategory,
updateCategory: updateCategory,
updateTitle: updateTitle,
updateImage: updateImage,
updateCategoryCount: updateCategoryCount,
categoryCount: categoryCount,
),
IconButton(
icon: Icon(Icons.delete),
iconSize: 36,
color: Colors.red,
onPressed: () {
model.deleteJar();
Navigator.pop(context);
})
AddUserToJarForm(
addUserFormKey: addUserFormKey,
addUserToJar: addUserToJar,
submitAddUser: submitAddUser,
userHasBeenAdded: userHasBeenAdded,
needToInviteThisUser: needToInviteThisUser,
model: model),
SizedBox(height: height * 0.04),
Container(
padding: EdgeInsets.fromLTRB(
width * 0.045, 0, width * 0.045, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: Text(
'UPDATE JAR',
style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
fontSize: 15,
letterSpacing: 5,
),
),
elevation: 7,
highlightElevation: 1,
padding: EdgeInsets.all(15),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)),
color: Theme.of(context).secondaryHeaderColor,
splashColor: Colors.transparent,
highlightColor: Theme.of(context).primaryColor,
onPressed: () => updateJar(model),
),
IconButton(
icon: Icon(Icons.delete),
iconSize: 36,
color: Colors.red,
onPressed: () {
model.deleteJar();
model.fetchAllUserJars(model.currUserEmail);

Navigator.pop(context);
})
],
),
)
],
),
)
],
),
],
) : Center(child: CircularProgressIndicator(),),
],
)
: Center(
child: CircularProgressIndicator(),
),
),
);
});
Expand Down
6 changes: 2 additions & 4 deletions fude_app/lib/scoped-models/jar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,8 @@ mixin JarModel on Model {
await _firestore
.collection('jars')
.document(_selJar.documentID)
.updateData({
!_selJar.data['owners'].contains(email)
? 'owners'
: FieldValue.arrayUnion([email]): FieldValue.arrayUnion([])
.updateData({'owners' :
!_selJar.data['owners'].contains(email) ? FieldValue.arrayUnion([email]): FieldValue.arrayUnion([])
});
} catch (e) {
print(e);
Expand Down
7 changes: 6 additions & 1 deletion fude_app/lib/widgets/forms/add_jar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class AddJarForm extends StatelessWidget {
final Function updateImage;
final Function updateCategoryCount;
final DocumentSnapshot jar;
final List<dynamic> categories;

AddJarForm(
{this.formKey,
Expand All @@ -21,7 +22,8 @@ class AddJarForm extends StatelessWidget {
this.updateTitle,
this.updateCategory,
this.updateImage,
this.updateCategoryCount});
this.updateCategoryCount,
this.categories});

Widget _buildFormTitles(String title, BuildContext context) {
return Row(
Expand Down Expand Up @@ -62,6 +64,8 @@ class AddJarForm extends StatelessWidget {
hint: 'Add Category',
updateCategory: updateCategory,
enabled: true,
categories: categories,

),
],
),
Expand Down Expand Up @@ -99,6 +103,7 @@ class AddJarForm extends StatelessWidget {
hint: 'Add Category',
updateCategory: updateCategory,
enabled: true,
categories: categories,
),
categoryCount > 0 ? _addCategoryInputs(context) : Container(),
SizedBox(height: height * 0.035),
Expand Down

0 comments on commit 5e78f8e

Please sign in to comment.