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

Commit

Permalink
feat(jar_edit/add forms): remove relevant validation so that a jar ca…
Browse files Browse the repository at this point in the history
…n have no categories

re #128
  • Loading branch information
Scott Clampet authored and Scott Clampet committed May 18, 2019
1 parent 442863f commit 4c6fe7e
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 25 deletions.
4 changes: 2 additions & 2 deletions fude_app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ DEPENDENCIES:
- firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
- firebase_storage (from `.symlinks/plugins/firebase_storage/ios`)
- Flutter (from `.symlinks/flutter/ios-release`)
- Flutter (from `.symlinks/flutter/ios`)
- image_picker (from `.symlinks/plugins/image_picker/ios`)
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)
Expand Down Expand Up @@ -186,7 +186,7 @@ EXTERNAL SOURCES:
firebase_storage:
:path: ".symlinks/plugins/firebase_storage/ios"
Flutter:
:path: ".symlinks/flutter/ios-release"
:path: ".symlinks/flutter/ios"
image_picker:
:path: ".symlinks/plugins/image_picker/ios"
shared_preferences:
Expand Down
2 changes: 1 addition & 1 deletion fude_app/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../.symlinks/flutter/ios-release/Flutter.framework",
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
Expand Down
8 changes: 1 addition & 7 deletions fude_app/lib/pages/jars/jar_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class _JarPageState extends State<EditJarPage> {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
final GlobalKey<FormState> addUserFormKey = GlobalKey<FormState>();
int categoryCount = 0;
bool needsAtLeastOneCategory = false;
List<dynamic> currentCategories = [];
bool userHasBeenAdded = false;
bool needToInviteThisUser = false;
Expand All @@ -48,7 +47,7 @@ class _JarPageState extends State<EditJarPage> {

void updateJar(MainModel model) {
//validate form.
if (!this.formKey.currentState.validate() || needsAtLeastOneCategory) {
if (!this.formKey.currentState.validate()) {
return;
} else {
formKey.currentState.save();
Expand Down Expand Up @@ -80,16 +79,12 @@ class _JarPageState extends State<EditJarPage> {
void updateCategoryCount() {
setState(() {
categoryCount += 1;
needsAtLeastOneCategory = false;
});
}

void addCategoryToRemoveList(String category) {
_formData['categoriesToRemove'].add(category);
setState(() {
if (currentCategories.length == 1 && categoryCount == 0) {
needsAtLeastOneCategory = true;
}
currentCategories.removeWhere((val) => val == category);
});
}
Expand Down Expand Up @@ -191,7 +186,6 @@ class _JarPageState extends State<EditJarPage> {
jar: model.selectedJar,
addCategoryToRemoveList: addCategoryToRemoveList,
categories: currentCategories,
needsAtLeastOneCategory: needsAtLeastOneCategory,
updateCategory: updateCategory,
updateTitle: updateTitle,
updateImage: updateImage,
Expand Down
5 changes: 1 addition & 4 deletions fude_app/lib/widgets/form-inputs/add_jar_category_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:fude/scoped-models/main.dart';
class AddJarCategoryField extends StatelessWidget {
final String hint;
final bool enabled;
final bool needsAtLeastOneCategory;
final Function updateCategory;
final Function addCategoryToRemoveList;
final MainModel model;
Expand All @@ -14,7 +13,6 @@ class AddJarCategoryField extends StatelessWidget {
AddJarCategoryField(
{this.hint,
this.enabled,
this.needsAtLeastOneCategory,
this.updateCategory,
this.addCategoryToRemoveList,
this.model,
Expand Down Expand Up @@ -62,8 +60,7 @@ class AddJarCategoryField extends StatelessWidget {
),
validator: (String val) {
String finalVal = val.trim();
if (needsAtLeastOneCategory == true ||
finalVal.isEmpty && categories.length < 1) {
if (finalVal.isEmpty) {
return 'cannot be blank';
}
},
Expand Down
1 change: 0 additions & 1 deletion fude_app/lib/widgets/forms/add_jar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class AddJarForm extends StatelessWidget {
model: model,
enabled: true,
categories: categories,
needsAtLeastOneCategory: needsAtLeastOneCategory
),
],
),
Expand Down
10 changes: 0 additions & 10 deletions fude_app/lib/widgets/forms/edit_jar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class EditJarForm extends StatelessWidget {
final MainModel model;
final List<dynamic> categories;
final int categoryCount;
final bool needsAtLeastOneCategory;
final Function updateTitle;
final Function updateCategory;
final Function updateImage;
Expand All @@ -25,7 +24,6 @@ class EditJarForm extends StatelessWidget {
this.categories,
this.jar,
this.categoryCount,
this.needsAtLeastOneCategory,
this.updateTitle,
this.updateCategory,
this.addCategoryToRemoveList,
Expand Down Expand Up @@ -74,7 +72,6 @@ class EditJarForm extends StatelessWidget {
updateCategory: updateCategory,
enabled: false,
addCategoryToRemoveList: addCategoryToRemoveList,
needsAtLeastOneCategory: needsAtLeastOneCategory,
),
Text(
'Tap and hold to delete',
Expand Down Expand Up @@ -130,13 +127,6 @@ class EditJarForm extends StatelessWidget {
),
SizedBox(height: height * 0.03),
_buildFormTitles("CATEGORIES", context),
needsAtLeastOneCategory
? Text(
'Please keep at least one category',
style: TextStyle(color: Colors.red),
textAlign: TextAlign.start,
)
: Container(),
SizedBox(height: height * 0.01),
_buildExistingCategoryInputs(context),
Column(
Expand Down

0 comments on commit 4c6fe7e

Please sign in to comment.