From 4c6fe7e924781ba12f75add48d67ef6adac19ee2 Mon Sep 17 00:00:00 2001 From: Scott Clampet Date: Sat, 18 May 2019 09:13:05 -0600 Subject: [PATCH] feat(jar_edit/add forms): remove relevant validation so that a jar can have no categories re #128 --- fude_app/ios/Podfile.lock | 4 ++-- fude_app/ios/Runner.xcodeproj/project.pbxproj | 2 +- fude_app/lib/pages/jars/jar_edit.dart | 8 +------- .../widgets/form-inputs/add_jar_category_input.dart | 5 +---- fude_app/lib/widgets/forms/add_jar.dart | 1 - fude_app/lib/widgets/forms/edit_jar.dart | 10 ---------- 6 files changed, 5 insertions(+), 25 deletions(-) diff --git a/fude_app/ios/Podfile.lock b/fude_app/ios/Podfile.lock index 3a8b091..4d70d85 100644 --- a/fude_app/ios/Podfile.lock +++ b/fude_app/ios/Podfile.lock @@ -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`) @@ -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: diff --git a/fude_app/ios/Runner.xcodeproj/project.pbxproj b/fude_app/ios/Runner.xcodeproj/project.pbxproj index d01fc9e..d17ecb0 100644 --- a/fude_app/ios/Runner.xcodeproj/project.pbxproj +++ b/fude_app/ios/Runner.xcodeproj/project.pbxproj @@ -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 = ( diff --git a/fude_app/lib/pages/jars/jar_edit.dart b/fude_app/lib/pages/jars/jar_edit.dart index a77a4d0..491880c 100644 --- a/fude_app/lib/pages/jars/jar_edit.dart +++ b/fude_app/lib/pages/jars/jar_edit.dart @@ -25,7 +25,6 @@ class _JarPageState extends State { final GlobalKey formKey = GlobalKey(); final GlobalKey addUserFormKey = GlobalKey(); int categoryCount = 0; - bool needsAtLeastOneCategory = false; List currentCategories = []; bool userHasBeenAdded = false; bool needToInviteThisUser = false; @@ -48,7 +47,7 @@ class _JarPageState extends State { void updateJar(MainModel model) { //validate form. - if (!this.formKey.currentState.validate() || needsAtLeastOneCategory) { + if (!this.formKey.currentState.validate()) { return; } else { formKey.currentState.save(); @@ -80,16 +79,12 @@ class _JarPageState extends State { 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); }); } @@ -191,7 +186,6 @@ class _JarPageState extends State { jar: model.selectedJar, addCategoryToRemoveList: addCategoryToRemoveList, categories: currentCategories, - needsAtLeastOneCategory: needsAtLeastOneCategory, updateCategory: updateCategory, updateTitle: updateTitle, updateImage: updateImage, diff --git a/fude_app/lib/widgets/form-inputs/add_jar_category_input.dart b/fude_app/lib/widgets/form-inputs/add_jar_category_input.dart index 35601c8..b5d8f02 100644 --- a/fude_app/lib/widgets/form-inputs/add_jar_category_input.dart +++ b/fude_app/lib/widgets/form-inputs/add_jar_category_input.dart @@ -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; @@ -14,7 +13,6 @@ class AddJarCategoryField extends StatelessWidget { AddJarCategoryField( {this.hint, this.enabled, - this.needsAtLeastOneCategory, this.updateCategory, this.addCategoryToRemoveList, this.model, @@ -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'; } }, diff --git a/fude_app/lib/widgets/forms/add_jar.dart b/fude_app/lib/widgets/forms/add_jar.dart index d5bd7b8..ea0c4cd 100644 --- a/fude_app/lib/widgets/forms/add_jar.dart +++ b/fude_app/lib/widgets/forms/add_jar.dart @@ -72,7 +72,6 @@ class AddJarForm extends StatelessWidget { model: model, enabled: true, categories: categories, - needsAtLeastOneCategory: needsAtLeastOneCategory ), ], ), diff --git a/fude_app/lib/widgets/forms/edit_jar.dart b/fude_app/lib/widgets/forms/edit_jar.dart index 088548f..ae9e361 100644 --- a/fude_app/lib/widgets/forms/edit_jar.dart +++ b/fude_app/lib/widgets/forms/edit_jar.dart @@ -11,7 +11,6 @@ class EditJarForm extends StatelessWidget { final MainModel model; final List categories; final int categoryCount; - final bool needsAtLeastOneCategory; final Function updateTitle; final Function updateCategory; final Function updateImage; @@ -25,7 +24,6 @@ class EditJarForm extends StatelessWidget { this.categories, this.jar, this.categoryCount, - this.needsAtLeastOneCategory, this.updateTitle, this.updateCategory, this.addCategoryToRemoveList, @@ -74,7 +72,6 @@ class EditJarForm extends StatelessWidget { updateCategory: updateCategory, enabled: false, addCategoryToRemoveList: addCategoryToRemoveList, - needsAtLeastOneCategory: needsAtLeastOneCategory, ), Text( 'Tap and hold to delete', @@ -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(