From 9236785edc3e497495a178c6b5054134fe5029e6 Mon Sep 17 00:00:00 2001 From: ItsAdityaKSingh Date: Sat, 15 Jan 2022 23:33:43 +0530 Subject: [PATCH] non_constant_identifier_names --- analysis_options.yaml | 2 - lib/services/database_service.dart | 4 +- lib/services/ib_engine_service.dart | 10 +-- lib/ui/views/about/about_view.dart | 4 +- .../components/auth_options_view.dart | 18 ++--- lib/ui/views/authentication/login_view.dart | 10 +-- lib/ui/views/authentication/signup_view.dart | 12 ++-- lib/ui/views/groups/add_assignment_view.dart | 6 +- .../views/groups/assignment_details_view.dart | 20 +++--- lib/ui/views/groups/edit_group_view.dart | 6 +- lib/ui/views/groups/group_details_view.dart | 32 ++++----- lib/ui/views/groups/my_groups_view.dart | 10 +-- lib/ui/views/groups/new_group_view.dart | 6 +- .../views/groups/update_assignment_view.dart | 6 +- .../ib/builders/ib_subscript_builder.dart | 4 +- .../ib/builders/ib_superscript_builder.dart | 4 +- lib/ui/views/profile/edit_profile_view.dart | 6 +- .../views/profile/user_favourites_view.dart | 2 +- lib/ui/views/profile/user_projects_view.dart | 2 +- lib/ui/views/projects/edit_project_view.dart | 6 +- .../projects/featured_projects_view.dart | 2 +- .../views/projects/project_details_view.dart | 36 +++++----- lib/utils/unicode_map.dart | 2 +- lib/viewmodels/about/about_viewmodel.dart | 10 +-- .../auth_options_viewmodel.dart | 46 ++++++------- .../forgot_password_viewmodel.dart | 1 + .../authentication/login_viewmodel.dart | 10 +-- .../authentication/signup_viewmodel.dart | 10 +-- .../groups/add_assignment_viewmodel.dart | 10 +-- .../groups/assignment_details_viewmodel.dart | 44 ++++++------ .../groups/edit_group_viewmodel.dart | 10 +-- .../groups/group_details_viewmodel.dart | 69 +++++++++---------- .../groups/my_groups_viewmodel.dart | 34 ++++----- .../groups/new_group_viewmodel.dart | 10 +-- .../groups/update_assignment_viewmodel.dart | 10 +-- lib/viewmodels/ib/ib_landing_viewmodel.dart | 1 + lib/viewmodels/ib/ib_page_viewmodel.dart | 2 + .../profile/edit_profile_viewmodel.dart | 10 +-- lib/viewmodels/profile/profile_viewmodel.dart | 10 +-- .../profile/user_favourites_viewmodel.dart | 10 +-- .../profile/user_projects_viewmodel.dart | 10 +-- .../projects/edit_project_viewmodel.dart | 10 +-- .../projects/featured_projects_viewmodel.dart | 10 +-- .../projects/project_details_viewmodel.dart | 68 +++++++++--------- .../ui_tests/groups/edit_group_view_test.dart | 2 +- .../groups/group_details_view_test.dart | 2 +- test/ui_tests/groups/my_groups_view_test.dart | 7 +- test/ui_tests/groups/new_group_view_test.dart | 2 +- .../profile/edit_profile_view_test.dart | 3 +- test/ui_tests/profile/profile_view_test.dart | 4 +- .../profile/user_favourites_view_test.dart | 2 +- .../profile/user_projects_view_test.dart | 2 +- .../projects/featured_projects_view_test.dart | 2 +- .../about/about_viewmodel_test.dart | 4 +- .../authentication/login_viewmodel_test.dart | 4 +- .../authentication/signup_viewmodel_test.dart | 4 +- .../groups/add_assignment_viewmodel_test.dart | 6 +- .../assignment_details_viewmodel_test.dart | 36 +++++----- .../groups/edit_group_viewmodel_test.dart | 8 +-- .../groups/group_details_viewmodel_test.dart | 44 ++++++------ .../groups/my_groups_viewmodel_test.dart | 30 ++++---- .../groups/new_group_viewmodel_test.dart | 7 +- .../update_assignment_viewmodel_test.dart | 6 +- .../profile/edit_profile_viewmodel_test.dart | 6 +- .../profile/profile_viewmodel_test.dart | 6 +- .../user_favourites_viewmodel_test.dart | 13 ++-- .../profile/user_projects_viewmodel_test.dart | 10 +-- .../projects/edit_project_viewmodel_test.dart | 6 +- .../featured_projects_viewmodel_test.dart | 9 ++- .../project_details_viewmodel_test.dart | 41 ++++++----- 70 files changed, 430 insertions(+), 441 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 718e36d6..3ac7e522 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -8,6 +8,4 @@ linter: # Util classes avoid_classes_with_only_static_members: false - non_constant_identifier_names: false - constant_identifier_names: false diff --git a/lib/services/database_service.dart b/lib/services/database_service.dart index c644de5e..00a01e3a 100644 --- a/lib/services/database_service.dart +++ b/lib/services/database_service.dart @@ -7,7 +7,7 @@ enum DatabaseBox { IB, } -List DatabaseAdapters = [ +List databaseAdapters = [ IbRawPageDataAdapter(), ]; @@ -37,7 +37,7 @@ class DatabaseServiceImpl implements DatabaseService { } // Register Adapters for Hive - for (var adapter in DatabaseAdapters) { + for (var adapter in databaseAdapters) { Hive.registerAdapter(adapter); } } diff --git a/lib/services/ib_engine_service.dart b/lib/services/ib_engine_service.dart index 72e8acaf..20ff2ba4 100644 --- a/lib/services/ib_engine_service.dart +++ b/lib/services/ib_engine_service.dart @@ -161,11 +161,11 @@ class IbEngineServiceImpl implements IbEngineService { var toc = []; for (var li in element.children) { - var eff_index = num ? index.toString() : String.fromCharCode(index); + var effIndex = num ? index.toString() : String.fromCharCode(index); if (li.getElementsByTagName('ol').isNotEmpty) { toc.add( IbTocItem( - leading: '$eff_index.', + leading: '$effIndex.', content: li.firstChild.text, items: _parseToc(li.children[1], num: !num), ), @@ -173,7 +173,7 @@ class IbEngineServiceImpl implements IbEngineService { } else { toc.add( IbTocItem( - leading: '$eff_index.', + leading: '$effIndex.', content: li.text, ), ); @@ -191,7 +191,7 @@ class IbEngineServiceImpl implements IbEngineService { var toc = []; for (var li in element.children) { - var eff_index = num ? index.toString() : String.fromCharCode(index); + var effIndex = num ? index.toString() : String.fromCharCode(index); var sublist = []; for (var node in li.nodes) { @@ -206,7 +206,7 @@ class IbEngineServiceImpl implements IbEngineService { toc.add( IbTocItem( - leading: '$eff_index.', + leading: '$effIndex.', content: root ? li.nodes[0].text.trim() : li.text.trim(), items: sublist.isNotEmpty ? sublist : null, ), diff --git a/lib/ui/views/about/about_view.dart b/lib/ui/views/about/about_view.dart index dfc0d3c8..a56e9323 100644 --- a/lib/ui/views/about/about_view.dart +++ b/lib/ui/views/about/about_view.dart @@ -50,7 +50,7 @@ class _AboutViewState extends State { } Widget _buildContributorsList() { - switch (_model.stateFor(_model.FETCH_CONTRIBUTORS)) { + switch (_model.stateFor(_model.fetchCONTRIBUTORS)) { case ViewState.Success: var _contributorsAvatars = []; for (var contributor in _model.cvContributors) { @@ -78,7 +78,7 @@ class _AboutViewState extends State { return Padding( padding: const EdgeInsets.symmetric(vertical: 32), child: Text( - _model.errorMessageFor(_model.FETCH_CONTRIBUTORS), + _model.errorMessageFor(_model.fetchCONTRIBUTORS), textAlign: TextAlign.center, ), ); diff --git a/lib/ui/views/authentication/components/auth_options_view.dart b/lib/ui/views/authentication/components/auth_options_view.dart index 3cc02b27..df7476b1 100644 --- a/lib/ui/views/authentication/components/auth_options_view.dart +++ b/lib/ui/views/authentication/components/auth_options_view.dart @@ -21,12 +21,12 @@ class _AuthOptionsViewState extends State { Future onGoogleAuthPressed() async { await _model.googleAuth(isSignUp: widget.isSignUp); - if (_model.isSuccess(_model.GOOGLE_OAUTH)) { + if (_model.isSuccess(_model.googleOAUTH)) { await Get.offAllNamed(CVLandingView.id); - } else if (_model.isError(_model.GOOGLE_OAUTH)) { + } else if (_model.isError(_model.googleOAUTH)) { SnackBarUtils.showDark( 'Google Authentication Error', - _model.errorMessageFor(_model.GOOGLE_OAUTH), + _model.errorMessageFor(_model.googleOAUTH), ); } } @@ -34,12 +34,12 @@ class _AuthOptionsViewState extends State { Future onFacebookAuthPressed() async { await _model.facebookAuth(isSignUp: widget.isSignUp); - if (_model.isSuccess(_model.FB_OAUTH)) { + if (_model.isSuccess(_model.fbOAUTH)) { await Get.offAllNamed(CVLandingView.id); - } else if (_model.isError(_model.FB_OAUTH)) { + } else if (_model.isError(_model.fbOAUTH)) { SnackBarUtils.showDark( 'Facebook Authentication Error', - _model.errorMessageFor(_model.FB_OAUTH), + _model.errorMessageFor(_model.fbOAUTH), ); } } @@ -47,12 +47,12 @@ class _AuthOptionsViewState extends State { Future onGithubAuthPressed() async { await _model.githubAuth(isSignUp: widget.isSignUp); - if (_model.isSuccess(_model.GITHUB_OAUTH)) { + if (_model.isSuccess(_model.githubOAUTH)) { await Get.offAllNamed(CVLandingView.id); - } else if (_model.isError(_model.GITHUB_OAUTH)) { + } else if (_model.isError(_model.githubOAUTH)) { SnackBarUtils.showDark( 'GitHub Authentication Error', - _model.errorMessageFor(_model.GITHUB_OAUTH), + _model.errorMessageFor(_model.githubOAUTH), ); } } diff --git a/lib/ui/views/authentication/login_view.dart b/lib/ui/views/authentication/login_view.dart index 9908e361..0562c467 100644 --- a/lib/ui/views/authentication/login_view.dart +++ b/lib/ui/views/authentication/login_view.dart @@ -89,7 +89,7 @@ class _LoginViewState extends State { padding: const EdgeInsets.symmetric(horizontal: 16), width: double.infinity, child: CVPrimaryButton( - title: _model.isBusy(_model.LOGIN) ? 'Authenticating..' : 'LOGIN', + title: _model.isBusy(_model.logIN) ? 'Authenticating..' : 'LOGIN', onPressed: _validateAndSubmit, ), ); @@ -118,10 +118,10 @@ class _LoginViewState extends State { Future _validateAndSubmit() async { if (Validators.validateAndSaveForm(_formKey) && - !_model.isBusy(_model.LOGIN)) { + !_model.isBusy(_model.logIN)) { FocusScope.of(context).requestFocus(FocusNode()); await _model.login(_email, _password); - if (_model.isSuccess(_model.LOGIN)) { + if (_model.isSuccess(_model.logIN)) { // show login successful snackbar.. SnackBarUtils.showDark( 'Login Successful', @@ -130,11 +130,11 @@ class _LoginViewState extends State { // move to home view on successful login.. await Future.delayed(const Duration(seconds: 1)); await Get.offAllNamed(CVLandingView.id); - } else if (_model.isError(_model.LOGIN)) { + } else if (_model.isError(_model.logIN)) { // show failure snackbar.. SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.LOGIN), + _model.errorMessageFor(_model.logIN), ); _formKey.currentState.reset(); } diff --git a/lib/ui/views/authentication/signup_view.dart b/lib/ui/views/authentication/signup_view.dart index 2d3a46a3..9ff3d680 100644 --- a/lib/ui/views/authentication/signup_view.dart +++ b/lib/ui/views/authentication/signup_view.dart @@ -91,7 +91,7 @@ class _SignupViewState extends State { padding: const EdgeInsets.symmetric(horizontal: 16), width: double.infinity, child: CVPrimaryButton( - title: _signUpModel.isBusy(_signUpModel.SIGNUP) + title: _signUpModel.isBusy(_signUpModel.signUP) ? 'Authenticating..' : 'REGISTER', onPressed: _validateAndSubmit, @@ -122,15 +122,15 @@ class _SignupViewState extends State { Future _validateAndSubmit() async { if (Validators.validateAndSaveForm(_formKey) && - !_signUpModel.isBusy(_signUpModel.SIGNUP)) { + !_signUpModel.isBusy(_signUpModel.signUP)) { FocusScope.of(context).requestFocus(FocusNode()); await _signUpModel.signup(_name, _email, _password); - if (_signUpModel.isSuccess(_signUpModel.SIGNUP)) { + if (_signUpModel.isSuccess(_signUpModel.signUP)) { // show signup successful snackbar.. SnackBarUtils.showDark( - 'Signup Successful', + 'signup Successful', 'Welcome to CircuitVerse!', ); @@ -139,11 +139,11 @@ class _SignupViewState extends State { const Duration(seconds: 1), ); await Get.offAllNamed(CVLandingView.id); - } else if (_signUpModel.isError(_signUpModel.SIGNUP)) { + } else if (_signUpModel.isError(_signUpModel.signUP)) { // show failure snackbar.. SnackBarUtils.showDark( 'Error', - _signUpModel.errorMessageFor(_signUpModel.SIGNUP), + _signUpModel.errorMessageFor(_signUpModel.signUP), ); _formKey.currentState.reset(); } diff --git a/lib/ui/views/groups/add_assignment_view.dart b/lib/ui/views/groups/add_assignment_view.dart index 4c7cc6c8..c1d7d4cc 100644 --- a/lib/ui/views/groups/add_assignment_view.dart +++ b/lib/ui/views/groups/add_assignment_view.dart @@ -228,7 +228,7 @@ class _AddAssignmentViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.ADD_ASSIGNMENT)) { + if (_model.isSuccess(_model.addASSIGNMENT)) { await Future.delayed(const Duration(seconds: 1)); // returns the added assignment.. @@ -239,11 +239,11 @@ class _AddAssignmentViewState extends State { 'Assignment Added', 'New assignment was successfully added.', ); - } else if (_model.isError(_model.ADD_ASSIGNMENT)) { + } else if (_model.isError(_model.addASSIGNMENT)) { // Show failure snackbar SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.ADD_ASSIGNMENT), + _model.errorMessageFor(_model.addASSIGNMENT), ); _formKey.currentState.reset(); } diff --git a/lib/ui/views/groups/assignment_details_view.dart b/lib/ui/views/groups/assignment_details_view.dart index 997d8991..7d3a6b35 100644 --- a/lib/ui/views/groups/assignment_details_view.dart +++ b/lib/ui/views/groups/assignment_details_view.dart @@ -259,15 +259,15 @@ class _AssignmentDetailsViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.ADD_GRADE)) { + if (_model.isSuccess(_model.addGRADE)) { SnackBarUtils.showDark( 'Project Graded Successfully', 'You have graded the project.', ); - } else if (_model.isError(_model.ADD_GRADE)) { + } else if (_model.isError(_model.addGRADE)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.ADD_GRADE), + _model.errorMessageFor(_model.addGRADE), ); } } @@ -283,15 +283,15 @@ class _AssignmentDetailsViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.UPDATE_GRADE)) { + if (_model.isSuccess(_model.updateGRADE)) { SnackBarUtils.showDark( 'Grade updated Successfully', 'Grade has been updated successfully.', ); - } else if (_model.isError(_model.UPDATE_GRADE)) { + } else if (_model.isError(_model.updateGRADE)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.UPDATE_GRADE), + _model.errorMessageFor(_model.updateGRADE), ); } } @@ -310,17 +310,17 @@ class _AssignmentDetailsViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.DELETE_GRADE)) { + if (_model.isSuccess(_model.deleteGRADE)) { SnackBarUtils.showDark( 'Grade Deleted', 'Grade has been removed successfully.', ); _gradesController.clear(); _remarksController.clear(); - } else if (_model.isError(_model.DELETE_GRADE)) { + } else if (_model.isError(_model.deleteGRADE)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.DELETE_GRADE), + _model.errorMessageFor(_model.deleteGRADE), ); } } @@ -455,7 +455,7 @@ class _AssignmentDetailsViewState extends State { json.decode(_attrs.restrictions).join(' , '), ), const Divider(height: 32), - if (_model.isSuccess(_model.FETCH_ASSIGNMENT_DETAILS)) + if (_model.isSuccess(_model.fetchASSIGNMENTDETAILS)) Column( children: [ _buildSubmissions(), diff --git a/lib/ui/views/groups/edit_group_view.dart b/lib/ui/views/groups/edit_group_view.dart index b64beb71..5a5699f2 100644 --- a/lib/ui/views/groups/edit_group_view.dart +++ b/lib/ui/views/groups/edit_group_view.dart @@ -38,17 +38,17 @@ class _EditGroupViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.UPDATE_GROUP)) { + if (_model.isSuccess(_model.updateGROUP)) { await Future.delayed(const Duration(seconds: 1)); Get.back(result: _model.updatedGroup); SnackBarUtils.showDark( 'Group Updated', 'Group has been successfully updated.', ); - } else if (_model.isError(_model.UPDATE_GROUP)) { + } else if (_model.isError(_model.updateGROUP)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.UPDATE_GROUP), + _model.errorMessageFor(_model.updateGROUP), ); } } diff --git a/lib/ui/views/groups/group_details_view.dart b/lib/ui/views/groups/group_details_view.dart index f04cf0e6..5284f019 100644 --- a/lib/ui/views/groups/group_details_view.dart +++ b/lib/ui/views/groups/group_details_view.dart @@ -125,16 +125,16 @@ class _GroupDetailsViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.ADD_GROUP_MEMBERS) && + if (_model.isSuccess(_model.addGROUPMEMBERS) && _model.addedMembersSuccessMessage.isNotEmpty) { SnackBarUtils.showDark( 'Group Members Added', _model.addedMembersSuccessMessage, ); - } else if (_model.isError(_model.ADD_GROUP_MEMBERS)) { + } else if (_model.isError(_model.addGROUPMEMBERS)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.ADD_GROUP_MEMBERS), + _model.errorMessageFor(_model.addGROUPMEMBERS), ); } } @@ -209,15 +209,15 @@ class _GroupDetailsViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.DELETE_GROUP_MEMBER)) { + if (_model.isSuccess(_model.deleteGROUPMEMBER)) { SnackBarUtils.showDark( 'Group Member Removed', 'Successfully removed group member.', ); - } else if (_model.isError(_model.DELETE_GROUP_MEMBER)) { + } else if (_model.isError(_model.deleteGROUPMEMBER)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.DELETE_GROUP_MEMBER), + _model.errorMessageFor(_model.deleteGROUPMEMBER), ); } } @@ -269,15 +269,15 @@ class _GroupDetailsViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.DELETE_ASSIGNMENT)) { + if (_model.isSuccess(_model.deleteASSIGNMENT)) { SnackBarUtils.showDark( 'Assignment Deleted', 'The assignment was successfully deleted.', ); - } else if (_model.isError(_model.DELETE_ASSIGNMENT)) { + } else if (_model.isError(_model.deleteASSIGNMENT)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.DELETE_ASSIGNMENT), + _model.errorMessageFor(_model.deleteASSIGNMENT), ); } } @@ -306,15 +306,15 @@ class _GroupDetailsViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.REOPEN_ASSIGNMENT)) { + if (_model.isSuccess(_model.reopenASSIGNMENT)) { SnackBarUtils.showDark( 'Assignment Reopened', 'The assignment is reopened now.', ); - } else if (_model.isError(_model.REOPEN_ASSIGNMENT)) { + } else if (_model.isError(_model.reopenASSIGNMENT)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.REOPEN_ASSIGNMENT), + _model.errorMessageFor(_model.reopenASSIGNMENT), ); } } @@ -334,7 +334,7 @@ class _GroupDetailsViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.START_ASSIGNMENT)) { + if (_model.isSuccess(_model.startASSIGNMENT)) { SnackBarUtils.showDark( 'Project Created', 'Project is successfully created.', @@ -342,7 +342,7 @@ class _GroupDetailsViewState extends State { } else { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.START_ASSIGNMENT), + _model.errorMessageFor(_model.startASSIGNMENT), ); } } @@ -371,7 +371,7 @@ class _GroupDetailsViewState extends State { ), ); - if (_model.isSuccess(_model.FETCH_GROUP_DETAILS)) { + if (_model.isSuccess(_model.fetchGROUPDETAILS)) { for (var member in _model.groupMembers) { _items.add( MemberCard( @@ -392,7 +392,7 @@ class _GroupDetailsViewState extends State { ), ); - if (_model.isSuccess(_model.FETCH_GROUP_DETAILS)) { + if (_model.isSuccess(_model.fetchGROUPDETAILS)) { for (var assignment in _model.assignments) { _items.add( AssignmentCard( diff --git a/lib/ui/views/groups/my_groups_view.dart b/lib/ui/views/groups/my_groups_view.dart index 1c2cd4c4..ac08da9e 100644 --- a/lib/ui/views/groups/my_groups_view.dart +++ b/lib/ui/views/groups/my_groups_view.dart @@ -83,15 +83,15 @@ class _MyGroupsViewState extends State _dialogService.popDialog(); - if (_model.isSuccess(_model.DELETE_GROUP)) { + if (_model.isSuccess(_model.deleteGROUP)) { SnackBarUtils.showDark( 'Group Deleted', 'Group was successfully deleted.', ); - } else if (_model.isError(_model.DELETE_GROUP)) { + } else if (_model.isError(_model.deleteGROUP)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.DELETE_GROUP), + _model.errorMessageFor(_model.deleteGROUP), ); } } @@ -132,7 +132,7 @@ class _MyGroupsViewState extends State var _mentoredGroups = []; var _joinedGroups = []; - if (_model.isSuccess(_model.FETCH_MENTORED_GROUPS)) { + if (_model.isSuccess(_model.fetchMENTOREDGROUPS)) { // creates GroupMentorCard corresponding to each mentor group for (var group in _model.mentoredGroups) { _mentoredGroups.add( @@ -150,7 +150,7 @@ class _MyGroupsViewState extends State ); } } - if (_model.isSuccess(_model.FETCH_MEMBER_GROUPS)) { + if (_model.isSuccess(_model.fetchMEMBERGROUPS)) { // creates GroupMemberCard corresponding to each member group for (var group in _model.memberGroups) { _joinedGroups.add(GroupMemberCard(group: group)); diff --git a/lib/ui/views/groups/new_group_view.dart b/lib/ui/views/groups/new_group_view.dart index ec1e64e4..fdc530d3 100644 --- a/lib/ui/views/groups/new_group_view.dart +++ b/lib/ui/views/groups/new_group_view.dart @@ -36,17 +36,17 @@ class _NewGroupViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.ADD_GROUP)) { + if (_model.isSuccess(_model.addGROUP)) { await Future.delayed(const Duration(seconds: 1)); Get.back(result: _model.newGroup); SnackBarUtils.showDark( 'Group Created', 'New group was created successfully.', ); - } else if (_model.isError(_model.ADD_GROUP)) { + } else if (_model.isError(_model.addGROUP)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.ADD_GROUP), + _model.errorMessageFor(_model.addGROUP), ); } } diff --git a/lib/ui/views/groups/update_assignment_view.dart b/lib/ui/views/groups/update_assignment_view.dart index 828b9117..5423954f 100644 --- a/lib/ui/views/groups/update_assignment_view.dart +++ b/lib/ui/views/groups/update_assignment_view.dart @@ -206,17 +206,17 @@ class _UpdateAssignmentViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.UPDATE_ASSIGNMENT)) { + if (_model.isSuccess(_model.updateASSIGNMENT)) { await Future.delayed(const Duration(seconds: 1)); Get.back(result: _model.updatedAssignment); SnackBarUtils.showDark( 'Assignment Updated', 'Assignment was updated successfully', ); - } else if (_model.isError(_model.UPDATE_ASSIGNMENT)) { + } else if (_model.isError(_model.updateASSIGNMENT)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.UPDATE_ASSIGNMENT), + _model.errorMessageFor(_model.updateASSIGNMENT), ); } } diff --git a/lib/ui/views/ib/builders/ib_subscript_builder.dart b/lib/ui/views/ib/builders/ib_subscript_builder.dart index c03e32f9..0d827441 100644 --- a/lib/ui/views/ib/builders/ib_subscript_builder.dart +++ b/lib/ui/views/ib/builders/ib_subscript_builder.dart @@ -18,8 +18,8 @@ class IbSubscriptBuilder extends MarkdownElementBuilder { var text = ''; for (var i = 0; i < textContent.length; i++) { - if (UnicodeMap.containsKey(textContent[i])) { - text += UnicodeMap[textContent[i]][1]; + if (unicodeMap.containsKey(textContent[i])) { + text += unicodeMap[textContent[i]][1]; } } diff --git a/lib/ui/views/ib/builders/ib_superscript_builder.dart b/lib/ui/views/ib/builders/ib_superscript_builder.dart index bfb7c2fc..007b47e2 100644 --- a/lib/ui/views/ib/builders/ib_superscript_builder.dart +++ b/lib/ui/views/ib/builders/ib_superscript_builder.dart @@ -18,8 +18,8 @@ class IbSuperscriptBuilder extends MarkdownElementBuilder { var text = ''; for (var i = 0; i < textContent.length; i++) { - if (UnicodeMap.containsKey(textContent[i])) { - text += UnicodeMap[textContent[i]][0]; + if (unicodeMap.containsKey(textContent[i])) { + text += unicodeMap[textContent[i]][0]; } } diff --git a/lib/ui/views/profile/edit_profile_view.dart b/lib/ui/views/profile/edit_profile_view.dart index 0a6b35a1..ac2839f6 100644 --- a/lib/ui/views/profile/edit_profile_view.dart +++ b/lib/ui/views/profile/edit_profile_view.dart @@ -108,17 +108,17 @@ class _EditProfileViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.UPDATE_PROFILE)) { + if (_model.isSuccess(_model.updatePROFILE)) { await Future.delayed(const Duration(seconds: 1)); Get.back(result: _model.updatedUser); SnackBarUtils.showDark( 'Profile Updated', 'Your profile was successfully updated.', ); - } else if (_model.isError(_model.UPDATE_PROFILE)) { + } else if (_model.isError(_model.updatePROFILE)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.UPDATE_PROFILE), + _model.errorMessageFor(_model.updatePROFILE), ); } } diff --git a/lib/ui/views/profile/user_favourites_view.dart b/lib/ui/views/profile/user_favourites_view.dart index 20923535..1acba500 100644 --- a/lib/ui/views/profile/user_favourites_view.dart +++ b/lib/ui/views/profile/user_favourites_view.dart @@ -31,7 +31,7 @@ class _UserFavouritesViewState extends State builder: (context, model, child) { final _items = []; - if (model.isSuccess(model.FETCH_USER_FAVOURITES)) { + if (model.isSuccess(model.fetchUSERFAVOURITES)) { for (var project in model.userFavourites) { _items.add( ProjectCard( diff --git a/lib/ui/views/profile/user_projects_view.dart b/lib/ui/views/profile/user_projects_view.dart index fa7e2997..db7744eb 100644 --- a/lib/ui/views/profile/user_projects_view.dart +++ b/lib/ui/views/profile/user_projects_view.dart @@ -28,7 +28,7 @@ class _UserProjectsViewState extends State builder: (context, model, child) { final _items = []; - if (model.isSuccess(model.FETCH_USER_PROJECTS)) { + if (model.isSuccess(model.fetchUSERPROJECTS)) { for (var project in model.userProjects) { _items.add( ProjectCard( diff --git a/lib/ui/views/projects/edit_project_view.dart b/lib/ui/views/projects/edit_project_view.dart index 695dbbb3..89dc40c2 100644 --- a/lib/ui/views/projects/edit_project_view.dart +++ b/lib/ui/views/projects/edit_project_view.dart @@ -127,17 +127,17 @@ class _EditProjectViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.UPDATE_PROJECT)) { + if (_model.isSuccess(_model.updatePROJECT)) { await Future.delayed(const Duration(seconds: 1)); Get.back(result: _model.updatedProject); SnackBarUtils.showDark( 'Project Updated', 'The project was successfully updated.', ); - } else if (_model.isError(_model.UPDATE_PROJECT)) { + } else if (_model.isError(_model.updatePROJECT)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.UPDATE_PROJECT), + _model.errorMessageFor(_model.updatePROJECT), ); } } diff --git a/lib/ui/views/projects/featured_projects_view.dart b/lib/ui/views/projects/featured_projects_view.dart index e2241213..62ff297e 100644 --- a/lib/ui/views/projects/featured_projects_view.dart +++ b/lib/ui/views/projects/featured_projects_view.dart @@ -30,7 +30,7 @@ class _FeaturedProjectsViewState extends State { builder: (context, model, child) { final _items = []; - if (model.isSuccess(model.FETCH_FEATURED_PROJECTS)) { + if (model.isSuccess(model.fetchFEATUREDPROJECTS)) { for (var project in model.featuredProjects) { _items.add( FeaturedProjectCard( diff --git a/lib/ui/views/projects/project_details_view.dart b/lib/ui/views/projects/project_details_view.dart index 97b51bcb..4d0a1eba 100644 --- a/lib/ui/views/projects/project_details_view.dart +++ b/lib/ui/views/projects/project_details_view.dart @@ -50,9 +50,9 @@ class _ProjectDetailsViewState extends State { void onShareButtonPressed() { final RenderBox box = context.findRenderObject(); - var URL = + var url = 'https://circuitverse.org/users/${widget.project.relationships.author.data.id}/projects/${widget.project.id}'; - Share.share(URL, + Share.share(url, sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size); } @@ -252,13 +252,13 @@ class _ProjectDetailsViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.FORK_PROJECT)) { + if (_model.isSuccess(_model.forkPROJECT)) { await Get.toNamed(ProjectDetailsView.id, arguments: _model.forkedProject); - } else if (_model.isError(_model.FORK_PROJECT)) { + } else if (_model.isError(_model.forkPROJECT)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.FORK_PROJECT), + _model.errorMessageFor(_model.forkPROJECT), ); } } @@ -293,15 +293,15 @@ class _ProjectDetailsViewState extends State { Future onStarProjectPressed() async { await _model.toggleStarForProject(_recievedProject.id); - if (_model.isSuccess(_model.TOGGLE_STAR)) { + if (_model.isSuccess(_model.toggleSTAR)) { SnackBarUtils.showDark( 'Project ${_model.isProjectStarred ? 'Starred' : 'Unstarred'}', 'You have successfully ${_model.isProjectStarred ? 'stared' : 'unstarred'} the project', ); - } else if (_model.isError(_model.TOGGLE_STAR)) { + } else if (_model.isError(_model.toggleSTAR)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.TOGGLE_STAR), + _model.errorMessageFor(_model.toggleSTAR), ); } } @@ -334,16 +334,16 @@ class _ProjectDetailsViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.ADD_COLLABORATORS) && + if (_model.isSuccess(_model.addCOLLABORATORS) && _model.addedCollaboratorsSuccessMessage.isNotEmpty) { SnackBarUtils.showDark( 'Collaborators Added', _model.addedCollaboratorsSuccessMessage, ); - } else if (_model.isError(_model.ADD_COLLABORATORS)) { + } else if (_model.isError(_model.addCOLLABORATORS)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.ADD_COLLABORATORS), + _model.errorMessageFor(_model.addCOLLABORATORS), ); } } @@ -465,16 +465,16 @@ class _ProjectDetailsViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.DELETE_PROJECT)) { + if (_model.isSuccess(_model.deletePROJECT)) { Get.back(result: true); SnackBarUtils.showDark( 'Project Deleted', 'Project is successfully deleted.', ); - } else if (_model.isError(_model.DELETE_PROJECT)) { + } else if (_model.isError(_model.deletePROJECT)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.DELETE_PROJECT), + _model.errorMessageFor(_model.deletePROJECT), ); } } @@ -515,15 +515,15 @@ class _ProjectDetailsViewState extends State { _dialogService.popDialog(); - if (_model.isSuccess(_model.DELETE_COLLABORATORS)) { + if (_model.isSuccess(_model.deleteCOLLABORATORS)) { SnackBarUtils.showDark( 'Collaborator Deleted', 'Collaborator was successfully deleted.', ); - } else if (_model.isError(_model.DELETE_COLLABORATORS)) { + } else if (_model.isError(_model.deleteCOLLABORATORS)) { SnackBarUtils.showDark( 'Error', - _model.errorMessageFor(_model.DELETE_COLLABORATORS), + _model.errorMessageFor(_model.deleteCOLLABORATORS), ); } } @@ -633,7 +633,7 @@ class _ProjectDetailsViewState extends State { ), ); - if (_model.isSuccess(_model.FETCH_PROJECT_DETAILS) && + if (_model.isSuccess(_model.fetchPROJECTDETAILS) && _model.collaborators.isNotEmpty) { _items.add(const Divider()); diff --git a/lib/utils/unicode_map.dart b/lib/utils/unicode_map.dart index 4d29684b..7cd77f13 100644 --- a/lib/utils/unicode_map.dart +++ b/lib/utils/unicode_map.dart @@ -1,5 +1,5 @@ /// Unicode Map for Subscript and Subscript character -var UnicodeMap = { +var unicodeMap = { ' ': [' ', ' '], '0': ['\u2070', '\u2080'], '1': ['\u00B9', '\u2081'], diff --git a/lib/viewmodels/about/about_viewmodel.dart b/lib/viewmodels/about/about_viewmodel.dart index d981a73c..331a1a3d 100644 --- a/lib/viewmodels/about/about_viewmodel.dart +++ b/lib/viewmodels/about/about_viewmodel.dart @@ -7,7 +7,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class AboutViewModel extends BaseModel { // ViewState Keys - final String FETCH_CONTRIBUTORS = 'fetch_contributors'; + final String fetchCONTRIBUTORS = 'fetch_contributors'; final _contributorsApi = locator(); @@ -21,14 +21,14 @@ class AboutViewModel extends BaseModel { } Future fetchContributors() async { - setStateFor(FETCH_CONTRIBUTORS, ViewState.Busy); + setStateFor(fetchCONTRIBUTORS, ViewState.Busy); try { cvContributors = await _contributorsApi.fetchContributors(); - setStateFor(FETCH_CONTRIBUTORS, ViewState.Success); + setStateFor(fetchCONTRIBUTORS, ViewState.Success); } on Failure catch (f) { - setStateFor(FETCH_CONTRIBUTORS, ViewState.Error); - setErrorMessageFor(FETCH_CONTRIBUTORS, f.message); + setStateFor(fetchCONTRIBUTORS, ViewState.Error); + setErrorMessageFor(fetchCONTRIBUTORS, f.message); } } } diff --git a/lib/viewmodels/authentication/auth_options_viewmodel.dart b/lib/viewmodels/authentication/auth_options_viewmodel.dart index 8ba3f476..c09479b1 100644 --- a/lib/viewmodels/authentication/auth_options_viewmodel.dart +++ b/lib/viewmodels/authentication/auth_options_viewmodel.dart @@ -14,9 +14,9 @@ import 'package:oauth2_client/oauth2_helper.dart'; class AuthOptionsViewModel extends BaseModel { // ViewState Keys - final String FB_OAUTH = 'fb_oauth'; - final String GOOGLE_OAUTH = 'google_oauth'; - final String GITHUB_OAUTH = 'github_oauth'; + final String fbOAUTH = 'fb_oauth'; + final String googleOAUTH = 'google_oauth'; + final String githubOAUTH = 'github_oauth'; final UsersApi _userApi = locator(); final LocalStorageService _storage = locator(); @@ -26,7 +26,7 @@ class AuthOptionsViewModel extends BaseModel { switch (result.status) { case LoginStatus.success: - setStateFor(FB_OAUTH, ViewState.Busy); + setStateFor(fbOAUTH, ViewState.Busy); try { // save token & current user to local storage.. @@ -50,19 +50,19 @@ class AuthOptionsViewModel extends BaseModel { // save authentication type to local storage.. _storage.authType = AuthType.FACEBOOK; - setStateFor(FB_OAUTH, ViewState.Success); + setStateFor(fbOAUTH, ViewState.Success); } on Failure catch (f) { - setStateFor(FB_OAUTH, ViewState.Error); - setErrorMessageFor(FB_OAUTH, f.message); + setStateFor(fbOAUTH, ViewState.Error); + setErrorMessageFor(fbOAUTH, f.message); } break; case LoginStatus.cancelled: - setStateFor(FB_OAUTH, ViewState.Error); - setErrorMessageFor(FB_OAUTH, 'Login Cancelled By User!'); + setStateFor(fbOAUTH, ViewState.Error); + setErrorMessageFor(fbOAUTH, 'Login Cancelled By User!'); break; case LoginStatus.failed: - setStateFor(FB_OAUTH, ViewState.Error); - setErrorMessageFor(FB_OAUTH, 'Unable to authenticate!'); + setStateFor(fbOAUTH, ViewState.Error); + setErrorMessageFor(fbOAUTH, 'Unable to authenticate!'); break; case LoginStatus.operationInProgress: break; @@ -77,7 +77,7 @@ class AuthOptionsViewModel extends BaseModel { var _googleSignInAuthentication = await _googleSignIn.currentUser.authentication; - setStateFor(GOOGLE_OAUTH, ViewState.Busy); + setStateFor(googleOAUTH, ViewState.Busy); // save token & current user to local storage.. if (isSignUp) { @@ -100,13 +100,13 @@ class AuthOptionsViewModel extends BaseModel { // save authentication type to local storage.. _storage.authType = AuthType.GOOGLE; - setStateFor(GOOGLE_OAUTH, ViewState.Success); + setStateFor(googleOAUTH, ViewState.Success); } on Failure catch (f) { - setStateFor(GOOGLE_OAUTH, ViewState.Error); - setErrorMessageFor(GOOGLE_OAUTH, f.message); + setStateFor(googleOAUTH, ViewState.Error); + setErrorMessageFor(googleOAUTH, f.message); } catch (e) { - setStateFor(GOOGLE_OAUTH, ViewState.Error); - setErrorMessageFor(GOOGLE_OAUTH, 'Unable to authenticate!'); + setStateFor(googleOAUTH, ViewState.Error); + setErrorMessageFor(googleOAUTH, 'Unable to authenticate!'); } } @@ -126,7 +126,7 @@ class AuthOptionsViewModel extends BaseModel { try { var _accessTokenResponse = await _oauthHelper.getToken(); - setStateFor(GITHUB_OAUTH, ViewState.Busy); + setStateFor(githubOAUTH, ViewState.Busy); // save token & current user to local storage.. if (isSignUp) { @@ -149,13 +149,13 @@ class AuthOptionsViewModel extends BaseModel { // save authentication type to local storage.. _storage.authType = AuthType.GITHUB; - setStateFor(GITHUB_OAUTH, ViewState.Success); + setStateFor(githubOAUTH, ViewState.Success); } on Failure catch (f) { - setStateFor(GITHUB_OAUTH, ViewState.Error); - setErrorMessageFor(GITHUB_OAUTH, f.message); + setStateFor(githubOAUTH, ViewState.Error); + setErrorMessageFor(githubOAUTH, f.message); } catch (e) { - setStateFor(GITHUB_OAUTH, ViewState.Error); - setErrorMessageFor(GITHUB_OAUTH, 'Unable to authenticate!'); + setStateFor(githubOAUTH, ViewState.Error); + setErrorMessageFor(githubOAUTH, 'Unable to authenticate!'); } } } diff --git a/lib/viewmodels/authentication/forgot_password_viewmodel.dart b/lib/viewmodels/authentication/forgot_password_viewmodel.dart index 4d973969..6b4ad8ee 100644 --- a/lib/viewmodels/authentication/forgot_password_viewmodel.dart +++ b/lib/viewmodels/authentication/forgot_password_viewmodel.dart @@ -6,6 +6,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class ForgotPasswordViewModel extends BaseModel { // ViewState Keys + // ignore: non_constant_identifier_names final String SEND_RESET_INSTRUCTIONS = 'send_reset_instructions'; final UsersApi _usersApi = locator(); diff --git a/lib/viewmodels/authentication/login_viewmodel.dart b/lib/viewmodels/authentication/login_viewmodel.dart index 2d81347a..a7b84c83 100644 --- a/lib/viewmodels/authentication/login_viewmodel.dart +++ b/lib/viewmodels/authentication/login_viewmodel.dart @@ -7,13 +7,13 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class LoginViewModel extends BaseModel { // ViewState Keys - final String LOGIN = 'login'; + final String logIN = 'login'; final UsersApi _userApi = locator(); final LocalStorageService _storage = locator(); Future login(String email, String password) async { - setStateFor(LOGIN, ViewState.Busy); + setStateFor(logIN, ViewState.Busy); try { var token = await _userApi.login(email, password); @@ -26,10 +26,10 @@ class LoginViewModel extends BaseModel { // save current user to local storage.. _storage.currentUser = await _userApi.fetchCurrentUser(); - setStateFor(LOGIN, ViewState.Success); + setStateFor(logIN, ViewState.Success); } on Failure catch (f) { - setStateFor(LOGIN, ViewState.Error); - setErrorMessageFor(LOGIN, f.message); + setStateFor(logIN, ViewState.Error); + setErrorMessageFor(logIN, f.message); } } } diff --git a/lib/viewmodels/authentication/signup_viewmodel.dart b/lib/viewmodels/authentication/signup_viewmodel.dart index 9f8ab580..a67ab905 100644 --- a/lib/viewmodels/authentication/signup_viewmodel.dart +++ b/lib/viewmodels/authentication/signup_viewmodel.dart @@ -7,13 +7,13 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class SignupViewModel extends BaseModel { // ViewState Keys - final String SIGNUP = 'signup'; + final String signUP = 'signup'; final UsersApi _userApi = locator(); final LocalStorageService _storage = locator(); Future signup(String name, String email, String password) async { - setStateFor(SIGNUP, ViewState.Busy); + setStateFor(signUP, ViewState.Busy); try { var token = await _userApi.signup(name, email, password); @@ -26,10 +26,10 @@ class SignupViewModel extends BaseModel { // save current user to local storage.. _storage.currentUser = await _userApi.fetchCurrentUser(); - setStateFor(SIGNUP, ViewState.Success); + setStateFor(signUP, ViewState.Success); } on Failure catch (f) { - setStateFor(SIGNUP, ViewState.Error); - setErrorMessageFor(SIGNUP, f.message); + setStateFor(signUP, ViewState.Error); + setErrorMessageFor(signUP, f.message); } } } diff --git a/lib/viewmodels/groups/add_assignment_viewmodel.dart b/lib/viewmodels/groups/add_assignment_viewmodel.dart index d4dc5d58..a44572c9 100644 --- a/lib/viewmodels/groups/add_assignment_viewmodel.dart +++ b/lib/viewmodels/groups/add_assignment_viewmodel.dart @@ -10,7 +10,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class AddAssignmentViewModel extends BaseModel { // ViewState Keys - final String ADD_ASSIGNMENT = 'add_assignment'; + final String addASSIGNMENT = 'add_assignment'; final AssignmentsApi _assignmentsApi = locator(); @@ -31,7 +31,7 @@ class AddAssignmentViewModel extends BaseModel { String description, List restrictionsList, ) async { - setStateFor(ADD_ASSIGNMENT, ViewState.Busy); + setStateFor(addASSIGNMENT, ViewState.Busy); try { // deadline format.. var deadlineFormat = DateFormat('yyyy-MM-dd HH:mm:ss'); @@ -49,10 +49,10 @@ class AddAssignmentViewModel extends BaseModel { jsonEncode(restrictionsList), ); - setStateFor(ADD_ASSIGNMENT, ViewState.Success); + setStateFor(addASSIGNMENT, ViewState.Success); } on Failure catch (f) { - setStateFor(ADD_ASSIGNMENT, ViewState.Error); - setErrorMessageFor(ADD_ASSIGNMENT, f.message); + setStateFor(addASSIGNMENT, ViewState.Error); + setErrorMessageFor(addASSIGNMENT, f.message); } } } diff --git a/lib/viewmodels/groups/assignment_details_viewmodel.dart b/lib/viewmodels/groups/assignment_details_viewmodel.dart index a2abe38a..2e9867cb 100644 --- a/lib/viewmodels/groups/assignment_details_viewmodel.dart +++ b/lib/viewmodels/groups/assignment_details_viewmodel.dart @@ -10,10 +10,10 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class AssignmentDetailsViewModel extends BaseModel { // ViewState Keys - String FETCH_ASSIGNMENT_DETAILS = 'fetch_assignment_details'; - String ADD_GRADE = 'add_grade'; - String UPDATE_GRADE = 'update_grade'; - String DELETE_GRADE = 'delete_grade'; + String fetchASSIGNMENTDETAILS = 'fetch_assignment_details'; + String addGRADE = 'add_grade'; + String updateGRADE = 'update_grade'; + String deleteGRADE = 'delete_grade'; final AssignmentsApi _assignmentsApi = locator(); final GradesApi _gradesApi = locator(); @@ -55,21 +55,21 @@ class AssignmentDetailsViewModel extends BaseModel { } Future fetchAssignmentDetails(String assignmentId) async { - setStateFor(FETCH_ASSIGNMENT_DETAILS, ViewState.Busy); + setStateFor(fetchASSIGNMENTDETAILS, ViewState.Busy); try { assignment = await _assignmentsApi.fetchAssignmentDetails(assignmentId); projects = _assignment.projects ?? []; grades = _assignment.grades ?? []; - setStateFor(FETCH_ASSIGNMENT_DETAILS, ViewState.Success); + setStateFor(fetchASSIGNMENTDETAILS, ViewState.Success); } on Failure catch (f) { - setStateFor(FETCH_ASSIGNMENT_DETAILS, ViewState.Error); - setErrorMessageFor(FETCH_ASSIGNMENT_DETAILS, f.message); + setStateFor(fetchASSIGNMENTDETAILS, ViewState.Error); + setErrorMessageFor(fetchASSIGNMENTDETAILS, f.message); } } Future addGrade(String assignmentId, dynamic grade, String remarks) async { - setStateFor(ADD_GRADE, ViewState.Busy); + setStateFor(addGRADE, ViewState.Busy); try { var _addedGrade = await _gradesApi.addGrade( assignmentId, _focussedProject.id, grade, remarks); @@ -77,15 +77,15 @@ class AssignmentDetailsViewModel extends BaseModel { _grades.add(_addedGrade); notifyListeners(); - setStateFor(ADD_GRADE, ViewState.Success); + setStateFor(addGRADE, ViewState.Success); } on Failure catch (f) { - setStateFor(ADD_GRADE, ViewState.Error); - setErrorMessageFor(ADD_GRADE, f.message); + setStateFor(addGRADE, ViewState.Error); + setErrorMessageFor(addGRADE, f.message); } } Future updateGrade(String gradeId, dynamic grade, String remarks) async { - setStateFor(UPDATE_GRADE, ViewState.Busy); + setStateFor(updateGRADE, ViewState.Busy); try { var _updatedGrade = await _gradesApi.updateGrade(gradeId, grade, remarks); @@ -93,15 +93,15 @@ class AssignmentDetailsViewModel extends BaseModel { _grades.add(_updatedGrade); notifyListeners(); - setStateFor(UPDATE_GRADE, ViewState.Success); + setStateFor(updateGRADE, ViewState.Success); } on Failure catch (f) { - setStateFor(UPDATE_GRADE, ViewState.Error); - setErrorMessageFor(UPDATE_GRADE, f.message); + setStateFor(updateGRADE, ViewState.Error); + setErrorMessageFor(updateGRADE, f.message); } } Future deleteGrade(String gradeId) async { - setStateFor(DELETE_GRADE, ViewState.Busy); + setStateFor(deleteGRADE, ViewState.Busy); try { var _isDeleted = await _gradesApi.deleteGrade(gradeId); @@ -109,14 +109,14 @@ class AssignmentDetailsViewModel extends BaseModel { if (_isDeleted) { // Remove Grade from the list.. _grades.removeWhere((grade) => grade.id == gradeId); - setStateFor(DELETE_GRADE, ViewState.Success); + setStateFor(deleteGRADE, ViewState.Success); } else { - setStateFor(DELETE_GRADE, ViewState.Error); - setErrorMessageFor(DELETE_GRADE, 'Grade can\'t be deleted'); + setStateFor(deleteGRADE, ViewState.Error); + setErrorMessageFor(deleteGRADE, 'Grade can\'t be deleted'); } } on Failure catch (f) { - setStateFor(DELETE_GRADE, ViewState.Error); - setErrorMessageFor(DELETE_GRADE, f.message); + setStateFor(deleteGRADE, ViewState.Error); + setErrorMessageFor(deleteGRADE, f.message); } } } diff --git a/lib/viewmodels/groups/edit_group_viewmodel.dart b/lib/viewmodels/groups/edit_group_viewmodel.dart index 32b8ba5a..3c47f647 100644 --- a/lib/viewmodels/groups/edit_group_viewmodel.dart +++ b/lib/viewmodels/groups/edit_group_viewmodel.dart @@ -7,7 +7,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class EditGroupViewModel extends BaseModel { // ViewState Keys - String UPDATE_GROUP = 'update_group'; + String updateGROUP = 'update_group'; final GroupsApi _groupsApi = locator(); @@ -21,14 +21,14 @@ class EditGroupViewModel extends BaseModel { } Future updateGroup(String groupId, String name) async { - setStateFor(UPDATE_GROUP, ViewState.Busy); + setStateFor(updateGROUP, ViewState.Busy); try { updatedGroup = await _groupsApi.updateGroup(groupId, name); - setStateFor(UPDATE_GROUP, ViewState.Success); + setStateFor(updateGROUP, ViewState.Success); } on Failure catch (f) { - setStateFor(UPDATE_GROUP, ViewState.Error); - setErrorMessageFor(UPDATE_GROUP, f.message); + setStateFor(updateGROUP, ViewState.Error); + setErrorMessageFor(updateGROUP, f.message); } } } diff --git a/lib/viewmodels/groups/group_details_viewmodel.dart b/lib/viewmodels/groups/group_details_viewmodel.dart index a3778251..70c67a05 100644 --- a/lib/viewmodels/groups/group_details_viewmodel.dart +++ b/lib/viewmodels/groups/group_details_viewmodel.dart @@ -11,12 +11,12 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class GroupDetailsViewModel extends BaseModel { // ViewState Keys - String FETCH_GROUP_DETAILS = 'fetch_group_details'; - String ADD_GROUP_MEMBERS = 'add_group_members'; - String DELETE_GROUP_MEMBER = 'delete_group_member'; - String REOPEN_ASSIGNMENT = 'reopen_assignment'; - String START_ASSIGNMENT = 'start_assignment'; - String DELETE_ASSIGNMENT = 'delete_assignment'; + String fetchGROUPDETAILS = 'fetch_group_details'; + String addGROUPMEMBERS = 'add_group_members'; + String deleteGROUPMEMBER = 'delete_group_member'; + String reopenASSIGNMENT = 'reopen_assignment'; + String startASSIGNMENT = 'start_assignment'; + String deleteASSIGNMENT = 'delete_assignment'; final GroupsApi _groupsApi = locator(); final GroupMembersApi _groupMembersApi = locator(); @@ -59,21 +59,21 @@ class GroupDetailsViewModel extends BaseModel { } Future fetchGroupDetails(String groupId) async { - setStateFor(FETCH_GROUP_DETAILS, ViewState.Busy); + setStateFor(fetchGROUPDETAILS, ViewState.Busy); try { group = await _groupsApi.fetchGroupDetails(groupId); groupMembers = _group.groupMembers; assignments = _group.assignments; - setStateFor(FETCH_GROUP_DETAILS, ViewState.Success); + setStateFor(fetchGROUPDETAILS, ViewState.Success); } on Failure catch (f) { - setStateFor(FETCH_GROUP_DETAILS, ViewState.Error); - setErrorMessageFor(FETCH_GROUP_DETAILS, f.message); + setStateFor(fetchGROUPDETAILS, ViewState.Error); + setErrorMessageFor(fetchGROUPDETAILS, f.message); } } Future addMembers(String groupId, String emails) async { - setStateFor(ADD_GROUP_MEMBERS, ViewState.Busy); + setStateFor(addGROUPMEMBERS, ViewState.Busy); try { var addGroupMembers = await _groupMembersApi.addGroupMembers(groupId, emails); @@ -94,30 +94,29 @@ class GroupDetailsViewModel extends BaseModel { var _members = await _groupMembersApi.fetchGroupMembers(groupId); groupMembers = _members.data; - setStateFor(ADD_GROUP_MEMBERS, ViewState.Success); + setStateFor(addGROUPMEMBERS, ViewState.Success); } on Failure catch (f) { - setStateFor(ADD_GROUP_MEMBERS, ViewState.Error); - setErrorMessageFor(ADD_GROUP_MEMBERS, f.message); + setStateFor(addGROUPMEMBERS, ViewState.Error); + setErrorMessageFor(addGROUPMEMBERS, f.message); } } Future deleteGroupMember(String groupMemberId) async { - setStateFor(DELETE_GROUP_MEMBER, ViewState.Busy); + setStateFor(deleteGROUPMEMBER, ViewState.Busy); try { var _isDeleted = await _groupMembersApi.deleteGroupMember(groupMemberId); if (_isDeleted) { // Remove Group Member from the list.. groupMembers.removeWhere((member) => member.id == groupMemberId); - setStateFor(DELETE_GROUP_MEMBER, ViewState.Success); + setStateFor(deleteGROUPMEMBER, ViewState.Success); } else { - setStateFor(DELETE_GROUP_MEMBER, ViewState.Error); - setErrorMessageFor( - DELETE_GROUP_MEMBER, 'Group Member can\'t be deleted'); + setStateFor(deleteGROUPMEMBER, ViewState.Error); + setErrorMessageFor(deleteGROUPMEMBER, 'Group Member can\'t be deleted'); } } on Failure catch (f) { - setStateFor(DELETE_GROUP_MEMBER, ViewState.Error); - setErrorMessageFor(DELETE_GROUP_MEMBER, f.message); + setStateFor(deleteGROUPMEMBER, ViewState.Error); + setErrorMessageFor(deleteGROUPMEMBER, f.message); } } @@ -135,7 +134,7 @@ class GroupDetailsViewModel extends BaseModel { } Future reopenAssignment(String assignmentId) async { - setStateFor(REOPEN_ASSIGNMENT, ViewState.Busy); + setStateFor(reopenASSIGNMENT, ViewState.Busy); try { await _assignmentsApi.reopenAssignment(assignmentId); @@ -146,15 +145,15 @@ class GroupDetailsViewModel extends BaseModel { .status = 'open'; notifyListeners(); - setStateFor(REOPEN_ASSIGNMENT, ViewState.Success); + setStateFor(reopenASSIGNMENT, ViewState.Success); } on Failure catch (f) { - setStateFor(REOPEN_ASSIGNMENT, ViewState.Error); - setErrorMessageFor(REOPEN_ASSIGNMENT, f.message); + setStateFor(reopenASSIGNMENT, ViewState.Error); + setErrorMessageFor(reopenASSIGNMENT, f.message); } } Future startAssignment(String assignmentId) async { - setStateFor(START_ASSIGNMENT, ViewState.Busy); + setStateFor(startASSIGNMENT, ViewState.Busy); try { await _assignmentsApi.startAssignment(assignmentId); _group = await _groupsApi.fetchGroupDetails(_group.id); @@ -163,29 +162,29 @@ class GroupDetailsViewModel extends BaseModel { groupMembers = _group.groupMembers; assignments = _group.assignments; - setStateFor(START_ASSIGNMENT, ViewState.Success); + setStateFor(startASSIGNMENT, ViewState.Success); } on Failure catch (f) { - setStateFor(START_ASSIGNMENT, ViewState.Error); - setErrorMessageFor(START_ASSIGNMENT, f.message); + setStateFor(startASSIGNMENT, ViewState.Error); + setErrorMessageFor(startASSIGNMENT, f.message); } } Future deleteAssignment(String assignmentId) async { - setStateFor(DELETE_ASSIGNMENT, ViewState.Busy); + setStateFor(deleteASSIGNMENT, ViewState.Busy); try { var _isDeleted = await _assignmentsApi.deleteAssignment(assignmentId); if (_isDeleted) { // Remove Assignment from the list.. assignments.removeWhere((assignment) => assignment.id == assignmentId); - setStateFor(DELETE_ASSIGNMENT, ViewState.Success); + setStateFor(deleteASSIGNMENT, ViewState.Success); } else { - setStateFor(DELETE_ASSIGNMENT, ViewState.Error); - setErrorMessageFor(DELETE_ASSIGNMENT, 'Assignment can\'t be deleted'); + setStateFor(deleteASSIGNMENT, ViewState.Error); + setErrorMessageFor(deleteASSIGNMENT, 'Assignment can\'t be deleted'); } } on Failure catch (f) { - setStateFor(DELETE_ASSIGNMENT, ViewState.Error); - setErrorMessageFor(DELETE_ASSIGNMENT, f.message); + setStateFor(deleteASSIGNMENT, ViewState.Error); + setErrorMessageFor(deleteASSIGNMENT, f.message); } } } diff --git a/lib/viewmodels/groups/my_groups_viewmodel.dart b/lib/viewmodels/groups/my_groups_viewmodel.dart index 30bb957e..809a8187 100644 --- a/lib/viewmodels/groups/my_groups_viewmodel.dart +++ b/lib/viewmodels/groups/my_groups_viewmodel.dart @@ -7,9 +7,9 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class MyGroupsViewModel extends BaseModel { // ViewState Keys - String FETCH_MENTORED_GROUPS = 'fetch_mentored_groups'; - String FETCH_MEMBER_GROUPS = 'fetch_member_groups'; - String DELETE_GROUP = 'delete_group'; + String fetchMENTOREDGROUPS = 'fetch_mentored_groups'; + String fetchMEMBERGROUPS = 'fetch_member_groups'; + String deleteGROUP = 'delete_group'; final GroupsApi _groupsApi = locator(); @@ -67,17 +67,17 @@ class MyGroupsViewModel extends BaseModel { ); } else { // Set State as busy only very first time.. - setStateFor(FETCH_MENTORED_GROUPS, ViewState.Busy); + setStateFor(fetchMENTOREDGROUPS, ViewState.Busy); // fetch mentoring groups for the very first time.. previousMentoredGroupsBatch = await _groupsApi.fetchMentoringGroups(); } mentoredGroups.addAll(previousMentoredGroupsBatch.data); - setStateFor(FETCH_MENTORED_GROUPS, ViewState.Success); + setStateFor(fetchMENTOREDGROUPS, ViewState.Success); } on Failure catch (f) { - setStateFor(FETCH_MENTORED_GROUPS, ViewState.Error); - setErrorMessageFor(FETCH_MENTORED_GROUPS, f.message); + setStateFor(fetchMENTOREDGROUPS, ViewState.Error); + setErrorMessageFor(fetchMENTOREDGROUPS, f.message); } } @@ -94,36 +94,36 @@ class MyGroupsViewModel extends BaseModel { ); } else { // Set State as busy only very first time.. - setStateFor(FETCH_MEMBER_GROUPS, ViewState.Busy); + setStateFor(fetchMEMBERGROUPS, ViewState.Busy); // fetch mentoring groups for the very first time.. previousMemberGroupsBatch = await _groupsApi.fetchMemberGroups(); } memberGroups.addAll(previousMemberGroupsBatch.data); - setStateFor(FETCH_MEMBER_GROUPS, ViewState.Success); + setStateFor(fetchMEMBERGROUPS, ViewState.Success); } on Failure catch (f) { - setStateFor(FETCH_MEMBER_GROUPS, ViewState.Error); - setErrorMessageFor(FETCH_MEMBER_GROUPS, f.message); + setStateFor(fetchMEMBERGROUPS, ViewState.Error); + setErrorMessageFor(fetchMEMBERGROUPS, f.message); } } Future deleteGroup(String groupId) async { - setStateFor(DELETE_GROUP, ViewState.Busy); + setStateFor(deleteGROUP, ViewState.Busy); try { var _isDeleted = await _groupsApi.deleteGroup(groupId); if (_isDeleted) { // remove the group from the list of groups.. mentoredGroups.removeWhere((group) => group.id == groupId); - setStateFor(DELETE_GROUP, ViewState.Success); + setStateFor(deleteGROUP, ViewState.Success); } else { - setStateFor(DELETE_GROUP, ViewState.Error); - setErrorMessageFor(DELETE_GROUP, 'Group can\'t be deleted'); + setStateFor(deleteGROUP, ViewState.Error); + setErrorMessageFor(deleteGROUP, 'Group can\'t be deleted'); } } on Failure catch (f) { - setStateFor(DELETE_GROUP, ViewState.Error); - setErrorMessageFor(DELETE_GROUP, f.message); + setStateFor(deleteGROUP, ViewState.Error); + setErrorMessageFor(deleteGROUP, f.message); } } } diff --git a/lib/viewmodels/groups/new_group_viewmodel.dart b/lib/viewmodels/groups/new_group_viewmodel.dart index 73ba832f..1b39c189 100644 --- a/lib/viewmodels/groups/new_group_viewmodel.dart +++ b/lib/viewmodels/groups/new_group_viewmodel.dart @@ -7,7 +7,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class NewGroupViewModel extends BaseModel { // ViewState Keys - String ADD_GROUP = 'add_group'; + String addGROUP = 'add_group'; final GroupsApi _groupsApi = locator(); @@ -21,14 +21,14 @@ class NewGroupViewModel extends BaseModel { } Future addGroup(String name) async { - setStateFor(ADD_GROUP, ViewState.Busy); + setStateFor(addGROUP, ViewState.Busy); try { newGroup = await _groupsApi.addGroup(name); - setStateFor(ADD_GROUP, ViewState.Success); + setStateFor(addGROUP, ViewState.Success); } on Failure catch (f) { - setStateFor(ADD_GROUP, ViewState.Error); - setErrorMessageFor(ADD_GROUP, f.message); + setStateFor(addGROUP, ViewState.Error); + setErrorMessageFor(addGROUP, f.message); } } } diff --git a/lib/viewmodels/groups/update_assignment_viewmodel.dart b/lib/viewmodels/groups/update_assignment_viewmodel.dart index 58dec761..89c07bb4 100644 --- a/lib/viewmodels/groups/update_assignment_viewmodel.dart +++ b/lib/viewmodels/groups/update_assignment_viewmodel.dart @@ -10,7 +10,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class UpdateAssignmentViewModel extends BaseModel { // ViewState Keys - String UPDATE_ASSIGNMENT = 'update_assignment'; + String updateASSIGNMENT = 'update_assignment'; final AssignmentsApi _assignmentsApi = locator(); @@ -30,7 +30,7 @@ class UpdateAssignmentViewModel extends BaseModel { String description, List restrictionsList, ) async { - setStateFor(UPDATE_ASSIGNMENT, ViewState.Busy); + setStateFor(updateASSIGNMENT, ViewState.Busy); try { // deadline format.. var deadlineFormat = DateFormat('yyyy-MM-dd HH:mm:ss'); @@ -44,10 +44,10 @@ class UpdateAssignmentViewModel extends BaseModel { jsonEncode(restrictionsList), ); - setStateFor(UPDATE_ASSIGNMENT, ViewState.Success); + setStateFor(updateASSIGNMENT, ViewState.Success); } on Failure catch (f) { - setStateFor(UPDATE_ASSIGNMENT, ViewState.Error); - setErrorMessageFor(UPDATE_ASSIGNMENT, f.message); + setStateFor(updateASSIGNMENT, ViewState.Error); + setErrorMessageFor(updateASSIGNMENT, f.message); } } } diff --git a/lib/viewmodels/ib/ib_landing_viewmodel.dart b/lib/viewmodels/ib/ib_landing_viewmodel.dart index a9f873b2..32c32fdd 100644 --- a/lib/viewmodels/ib/ib_landing_viewmodel.dart +++ b/lib/viewmodels/ib/ib_landing_viewmodel.dart @@ -10,6 +10,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class IbLandingViewModel extends BaseModel { // ViewState Keys + // ignore: non_constant_identifier_names String IB_FETCH_CHAPTERS = 'ib_fetch_chapters'; final IbEngineService _ibEngineService = locator(); diff --git a/lib/viewmodels/ib/ib_page_viewmodel.dart b/lib/viewmodels/ib/ib_page_viewmodel.dart index 49ecb575..e96aa739 100644 --- a/lib/viewmodels/ib/ib_page_viewmodel.dart +++ b/lib/viewmodels/ib/ib_page_viewmodel.dart @@ -1,3 +1,5 @@ +// ignore_for_file: non_constant_identifier_names + import 'package:flutter/material.dart'; import 'package:mobile_app/enums/view_state.dart'; import 'package:mobile_app/locator.dart'; diff --git a/lib/viewmodels/profile/edit_profile_viewmodel.dart b/lib/viewmodels/profile/edit_profile_viewmodel.dart index 4fe9954c..4d371a70 100644 --- a/lib/viewmodels/profile/edit_profile_viewmodel.dart +++ b/lib/viewmodels/profile/edit_profile_viewmodel.dart @@ -8,7 +8,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class EditProfileViewModel extends BaseModel { // ViewState Keys - String UPDATE_PROFILE = 'update_profile'; + String updatePROFILE = 'update_profile'; final UsersApi _userApi = locator(); final LocalStorageService _storage = locator(); @@ -24,16 +24,16 @@ class EditProfileViewModel extends BaseModel { Future updateProfile(String name, String educationalInstitute, String country, bool subscribed) async { - setStateFor(UPDATE_PROFILE, ViewState.Busy); + setStateFor(updatePROFILE, ViewState.Busy); try { updatedUser = await _userApi.updateProfile( name, educationalInstitute, country, subscribed); _storage.currentUser = _updatedUser; - setStateFor(UPDATE_PROFILE, ViewState.Success); + setStateFor(updatePROFILE, ViewState.Success); } on Failure catch (f) { - setStateFor(UPDATE_PROFILE, ViewState.Error); - setErrorMessageFor(UPDATE_PROFILE, f.message); + setStateFor(updatePROFILE, ViewState.Error); + setErrorMessageFor(updatePROFILE, f.message); } } } diff --git a/lib/viewmodels/profile/profile_viewmodel.dart b/lib/viewmodels/profile/profile_viewmodel.dart index 08654565..8c4fc283 100644 --- a/lib/viewmodels/profile/profile_viewmodel.dart +++ b/lib/viewmodels/profile/profile_viewmodel.dart @@ -7,7 +7,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class ProfileViewModel extends BaseModel { // ViewState Keys - String FETCH_USER_PROFILE = 'fetch_user_profile'; + String fetchUSERPROFILE = 'fetch_user_profile'; final UsersApi _usersApi = locator(); @@ -21,14 +21,14 @@ class ProfileViewModel extends BaseModel { } Future fetchUserProfile(String userId) async { - setStateFor(FETCH_USER_PROFILE, ViewState.Busy); + setStateFor(fetchUSERPROFILE, ViewState.Busy); try { user = await _usersApi.fetchUser(userId); - setStateFor(FETCH_USER_PROFILE, ViewState.Success); + setStateFor(fetchUSERPROFILE, ViewState.Success); } on Failure catch (f) { - setStateFor(FETCH_USER_PROFILE, ViewState.Error); - setErrorMessageFor(FETCH_USER_PROFILE, f.message); + setStateFor(fetchUSERPROFILE, ViewState.Error); + setErrorMessageFor(fetchUSERPROFILE, f.message); } } } diff --git a/lib/viewmodels/profile/user_favourites_viewmodel.dart b/lib/viewmodels/profile/user_favourites_viewmodel.dart index b3d8f67b..09d6ddc3 100644 --- a/lib/viewmodels/profile/user_favourites_viewmodel.dart +++ b/lib/viewmodels/profile/user_favourites_viewmodel.dart @@ -8,7 +8,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class UserFavouritesViewModel extends BaseModel { // ViewState Keys - String FETCH_USER_FAVOURITES = 'fetch_user_favourites'; + String fetchUSERFAVOURITES = 'fetch_user_favourites'; final ProjectsApi _projectsApi = locator(); final LocalStorageService _localStorageService = @@ -48,7 +48,7 @@ class UserFavouritesViewModel extends BaseModel { ); } else { // Set State as busy only very first time.. - setStateFor(FETCH_USER_FAVOURITES, ViewState.Busy); + setStateFor(fetchUSERFAVOURITES, ViewState.Busy); // fetch projects for the very first time.. previousUserFavouritesBatch = await _projectsApi.getUserFavourites( userId ?? _localStorageService.currentUser.data.id); @@ -56,10 +56,10 @@ class UserFavouritesViewModel extends BaseModel { userFavourites.addAll(previousUserFavouritesBatch.data); - setStateFor(FETCH_USER_FAVOURITES, ViewState.Success); + setStateFor(fetchUSERFAVOURITES, ViewState.Success); } on Failure catch (f) { - setStateFor(FETCH_USER_FAVOURITES, ViewState.Error); - setErrorMessageFor(FETCH_USER_FAVOURITES, f.message); + setStateFor(fetchUSERFAVOURITES, ViewState.Error); + setErrorMessageFor(fetchUSERFAVOURITES, f.message); } } } diff --git a/lib/viewmodels/profile/user_projects_viewmodel.dart b/lib/viewmodels/profile/user_projects_viewmodel.dart index ddce81b7..954d3c80 100644 --- a/lib/viewmodels/profile/user_projects_viewmodel.dart +++ b/lib/viewmodels/profile/user_projects_viewmodel.dart @@ -8,7 +8,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class UserProjectsViewModel extends BaseModel { // ViewState Keys - String FETCH_USER_PROJECTS = 'fetch_user_projects'; + String fetchUSERPROJECTS = 'fetch_user_projects'; final ProjectsApi _projectsApi = locator(); final LocalStorageService _localStorageService = @@ -48,16 +48,16 @@ class UserProjectsViewModel extends BaseModel { ); } else { // Set State as busy only very first time.. - setStateFor(FETCH_USER_PROJECTS, ViewState.Busy); + setStateFor(fetchUSERPROJECTS, ViewState.Busy); // fetch projects for the very first time.. previousUserProjectsBatch = await _projectsApi.getUserProjects( userId ?? _localStorageService.currentUser.data.id); } userProjects.addAll(previousUserProjectsBatch.data); - setStateFor(FETCH_USER_PROJECTS, ViewState.Success); + setStateFor(fetchUSERPROJECTS, ViewState.Success); } on Failure catch (f) { - setStateFor(FETCH_USER_PROJECTS, ViewState.Error); - setErrorMessageFor(FETCH_USER_PROJECTS, f.message); + setStateFor(fetchUSERPROJECTS, ViewState.Error); + setErrorMessageFor(fetchUSERPROJECTS, f.message); } } } diff --git a/lib/viewmodels/projects/edit_project_viewmodel.dart b/lib/viewmodels/projects/edit_project_viewmodel.dart index 3e70167e..98e7b1bd 100644 --- a/lib/viewmodels/projects/edit_project_viewmodel.dart +++ b/lib/viewmodels/projects/edit_project_viewmodel.dart @@ -7,7 +7,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class EditProjectViewModel extends BaseModel { // ViewState Keys - String UPDATE_PROJECT = 'update_project'; + String updatePROJECT = 'update_project'; final ProjectsApi _projectsApi = locator(); @@ -27,7 +27,7 @@ class EditProjectViewModel extends BaseModel { String description, List tagsList, }) async { - setStateFor(UPDATE_PROJECT, ViewState.Busy); + setStateFor(updatePROJECT, ViewState.Busy); try { updatedProject = await _projectsApi.updateProject( id, @@ -37,10 +37,10 @@ class EditProjectViewModel extends BaseModel { tagsList: tagsList, ); - setStateFor(UPDATE_PROJECT, ViewState.Success); + setStateFor(updatePROJECT, ViewState.Success); } on Failure catch (f) { - setStateFor(UPDATE_PROJECT, ViewState.Error); - setErrorMessageFor(UPDATE_PROJECT, f.message); + setStateFor(updatePROJECT, ViewState.Error); + setErrorMessageFor(updatePROJECT, f.message); } } } diff --git a/lib/viewmodels/projects/featured_projects_viewmodel.dart b/lib/viewmodels/projects/featured_projects_viewmodel.dart index 1a141f48..28206556 100644 --- a/lib/viewmodels/projects/featured_projects_viewmodel.dart +++ b/lib/viewmodels/projects/featured_projects_viewmodel.dart @@ -7,7 +7,7 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class FeaturedProjectsViewModel extends BaseModel { // ViewState Keys - String FETCH_FEATURED_PROJECTS = 'fetch_featured_projects'; + String fetchFEATUREDPROJECTS = 'fetch_featured_projects'; final ProjectsApi _projectsApi = locator(); @@ -40,17 +40,17 @@ class FeaturedProjectsViewModel extends BaseModel { ); } else { // Set State as busy only very first time.. - setStateFor(FETCH_FEATURED_PROJECTS, ViewState.Busy); + setStateFor(fetchFEATUREDPROJECTS, ViewState.Busy); // fetch projects for the very first time.. previousFeaturedProjectsBatch = await _projectsApi.getFeaturedProjects( size: size, ); } featuredProjects.addAll(previousFeaturedProjectsBatch.data); - setStateFor(FETCH_FEATURED_PROJECTS, ViewState.Success); + setStateFor(fetchFEATUREDPROJECTS, ViewState.Success); } on Failure catch (f) { - setStateFor(FETCH_FEATURED_PROJECTS, ViewState.Error); - setErrorMessageFor(FETCH_FEATURED_PROJECTS, f.message); + setStateFor(fetchFEATUREDPROJECTS, ViewState.Error); + setErrorMessageFor(fetchFEATUREDPROJECTS, f.message); } } } diff --git a/lib/viewmodels/projects/project_details_viewmodel.dart b/lib/viewmodels/projects/project_details_viewmodel.dart index cdc95eba..86cf9084 100644 --- a/lib/viewmodels/projects/project_details_viewmodel.dart +++ b/lib/viewmodels/projects/project_details_viewmodel.dart @@ -9,12 +9,12 @@ import 'package:mobile_app/viewmodels/base_viewmodel.dart'; class ProjectDetailsViewModel extends BaseModel { // ViewState Keys - String FETCH_PROJECT_DETAILS = 'fetch_project_details'; - String FORK_PROJECT = 'fork_project'; - String TOGGLE_STAR = 'toggle_star'; - String DELETE_PROJECT = 'delete_project'; - String ADD_COLLABORATORS = 'add_collaborators'; - String DELETE_COLLABORATORS = 'delete_collaborators'; + String fetchPROJECTDETAILS = 'fetch_project_details'; + String forkPROJECT = 'fork_project'; + String toggleSTAR = 'toggle_star'; + String deletePROJECT = 'delete_project'; + String addCOLLABORATORS = 'add_collaborators'; + String deleteCOLLABORATORS = 'delete_collaborators'; final ProjectsApi _projectsApi = locator(); final CollaboratorsApi _collaboratorsApi = locator(); @@ -76,20 +76,20 @@ class ProjectDetailsViewModel extends BaseModel { } Future fetchProjectDetails(String projectId) async { - setStateFor(FETCH_PROJECT_DETAILS, ViewState.Busy); + setStateFor(fetchPROJECTDETAILS, ViewState.Busy); try { project = await _projectsApi.getProjectDetails(projectId); collaborators = _project.collaborators; - setStateFor(FETCH_PROJECT_DETAILS, ViewState.Success); + setStateFor(fetchPROJECTDETAILS, ViewState.Success); } on Failure catch (f) { - setStateFor(FETCH_PROJECT_DETAILS, ViewState.Error); - setErrorMessageFor(FETCH_PROJECT_DETAILS, f.message); + setStateFor(fetchPROJECTDETAILS, ViewState.Error); + setErrorMessageFor(fetchPROJECTDETAILS, f.message); } } Future addCollaborators(String projectId, String emails) async { - setStateFor(ADD_COLLABORATORS, ViewState.Busy); + setStateFor(addCOLLABORATORS, ViewState.Busy); try { var addedCollaborators = await _collaboratorsApi.addCollaborators(projectId, emails); @@ -111,15 +111,15 @@ class ProjectDetailsViewModel extends BaseModel { await _collaboratorsApi.fetchProjectCollaborators(projectId); collaborators = _collaborators.data; - setStateFor(ADD_COLLABORATORS, ViewState.Success); + setStateFor(addCOLLABORATORS, ViewState.Success); } on Failure catch (f) { - setStateFor(ADD_COLLABORATORS, ViewState.Error); - setErrorMessageFor(ADD_COLLABORATORS, f.message); + setStateFor(addCOLLABORATORS, ViewState.Error); + setErrorMessageFor(addCOLLABORATORS, f.message); } } Future deleteCollaborator(String projectId, String collaboratorId) async { - setStateFor(DELETE_COLLABORATORS, ViewState.Busy); + setStateFor(deleteCOLLABORATORS, ViewState.Busy); try { var _isDeleted = await _collaboratorsApi.deleteCollaborator(projectId, collaboratorId); @@ -130,58 +130,58 @@ class ProjectDetailsViewModel extends BaseModel { notifyListeners(); if (_isDeleted) { - setStateFor(DELETE_COLLABORATORS, ViewState.Success); + setStateFor(deleteCOLLABORATORS, ViewState.Success); } else { - setStateFor(DELETE_COLLABORATORS, ViewState.Error); + setStateFor(deleteCOLLABORATORS, ViewState.Error); setErrorMessageFor( - DELETE_COLLABORATORS, 'Collaborator can\'t be deleted'); + deleteCOLLABORATORS, 'Collaborator can\'t be deleted'); } } on Failure catch (f) { - setStateFor(DELETE_COLLABORATORS, ViewState.Error); - setErrorMessageFor(DELETE_COLLABORATORS, f.message); + setStateFor(deleteCOLLABORATORS, ViewState.Error); + setErrorMessageFor(deleteCOLLABORATORS, f.message); } } Future forkProject(String toBeForkedProjectId) async { - setStateFor(FORK_PROJECT, ViewState.Busy); + setStateFor(forkPROJECT, ViewState.Busy); try { forkedProject = await _projectsApi.forkProject(toBeForkedProjectId); - setStateFor(FORK_PROJECT, ViewState.Success); + setStateFor(forkPROJECT, ViewState.Success); } on Failure catch (f) { - setStateFor(FORK_PROJECT, ViewState.Error); - setErrorMessageFor(FORK_PROJECT, f.message); + setStateFor(forkPROJECT, ViewState.Error); + setErrorMessageFor(forkPROJECT, f.message); } } Future toggleStarForProject(String projectId) async { - setStateFor(TOGGLE_STAR, ViewState.Busy); + setStateFor(toggleSTAR, ViewState.Busy); try { var _toggleMessage = await _projectsApi.toggleStarProject(projectId); isProjectStarred = _toggleMessage.contains('Starred') ? true : false; isProjectStarred ? starCount++ : starCount--; - setStateFor(TOGGLE_STAR, ViewState.Success); + setStateFor(toggleSTAR, ViewState.Success); } on Failure catch (f) { - setStateFor(TOGGLE_STAR, ViewState.Error); - setErrorMessageFor(TOGGLE_STAR, f.message); + setStateFor(toggleSTAR, ViewState.Error); + setErrorMessageFor(toggleSTAR, f.message); } } Future deleteProject(String projectId) async { - setStateFor(DELETE_PROJECT, ViewState.Busy); + setStateFor(deletePROJECT, ViewState.Busy); try { var _isDeleted = await _projectsApi.deleteProject(projectId); if (_isDeleted) { - setStateFor(DELETE_PROJECT, ViewState.Success); + setStateFor(deletePROJECT, ViewState.Success); } else { - setStateFor(DELETE_PROJECT, ViewState.Error); - setErrorMessageFor(DELETE_PROJECT, 'Project cannot be deleted'); + setStateFor(deletePROJECT, ViewState.Error); + setErrorMessageFor(deletePROJECT, 'Project cannot be deleted'); } } on Failure catch (f) { - setStateFor(DELETE_PROJECT, ViewState.Error); - setErrorMessageFor(DELETE_PROJECT, f.message); + setStateFor(deletePROJECT, ViewState.Error); + setErrorMessageFor(deletePROJECT, f.message); } } } diff --git a/test/ui_tests/groups/edit_group_view_test.dart b/test/ui_tests/groups/edit_group_view_test.dart index 016ea75e..989c6dcb 100644 --- a/test/ui_tests/groups/edit_group_view_test.dart +++ b/test/ui_tests/groups/edit_group_view_test.dart @@ -73,7 +73,7 @@ void main() { locator.registerSingleton(_editGroupViewModel); when(_editGroupViewModel.updateGroup(any, any)).thenReturn(null); - when(_editGroupViewModel.isSuccess(_editGroupViewModel.UPDATE_GROUP)) + when(_editGroupViewModel.isSuccess(_editGroupViewModel.updateGROUP)) .thenReturn(true); // Pump New Group View diff --git a/test/ui_tests/groups/group_details_view_test.dart b/test/ui_tests/groups/group_details_view_test.dart index f9504f31..6dccf8a0 100644 --- a/test/ui_tests/groups/group_details_view_test.dart +++ b/test/ui_tests/groups/group_details_view_test.dart @@ -51,7 +51,7 @@ void main() { when(_groupDetailsViewModel.groupMembers).thenReturn(group.groupMembers); when(_groupDetailsViewModel.assignments).thenReturn([assignments]); when(_groupDetailsViewModel - .isSuccess(_groupDetailsViewModel.FETCH_GROUP_DETAILS)) + .isSuccess(_groupDetailsViewModel.fetchGROUPDETAILS)) .thenAnswer((_) => true); await tester.pumpWidget( diff --git a/test/ui_tests/groups/my_groups_view_test.dart b/test/ui_tests/groups/my_groups_view_test.dart index 584163f2..944a0599 100644 --- a/test/ui_tests/groups/my_groups_view_test.dart +++ b/test/ui_tests/groups/my_groups_view_test.dart @@ -45,9 +45,8 @@ void main() { when(model.fetchMentoredGroups()).thenReturn(null); when(model.fetchMemberGroups()).thenReturn(null); - when(model.isSuccess(model.FETCH_MENTORED_GROUPS)) - .thenAnswer((_) => true); - when(model.isSuccess(model.FETCH_MEMBER_GROUPS)).thenAnswer((_) => true); + when(model.isSuccess(model.fetchMENTOREDGROUPS)).thenAnswer((_) => true); + when(model.isSuccess(model.fetchMEMBERGROUPS)).thenAnswer((_) => true); when(model.mentoredGroups).thenAnswer((_) => groups); when(model.memberGroups).thenAnswer((_) => groups); @@ -138,7 +137,7 @@ void main() { when(_groupDetailsViewModel.fetchGroupDetails(any)).thenReturn(null); when(_groupDetailsViewModel - .isSuccess(_groupDetailsViewModel.FETCH_GROUP_DETAILS)) + .isSuccess(_groupDetailsViewModel.fetchGROUPDETAILS)) .thenAnswer((_) => false); await tester.tap(find.widgetWithText(CardButton, 'View').first); diff --git a/test/ui_tests/groups/new_group_view_test.dart b/test/ui_tests/groups/new_group_view_test.dart index 2fabf86a..e951000b 100644 --- a/test/ui_tests/groups/new_group_view_test.dart +++ b/test/ui_tests/groups/new_group_view_test.dart @@ -69,7 +69,7 @@ void main() { locator.registerSingleton(_newGroupViewModel); when(_newGroupViewModel.addGroup(any)).thenReturn(null); - when(_newGroupViewModel.isSuccess(_newGroupViewModel.ADD_GROUP)) + when(_newGroupViewModel.isSuccess(_newGroupViewModel.addGROUP)) .thenReturn(true); // Pump New Group View diff --git a/test/ui_tests/profile/edit_profile_view_test.dart b/test/ui_tests/profile/edit_profile_view_test.dart index 16b75da5..0d1e8cf9 100644 --- a/test/ui_tests/profile/edit_profile_view_test.dart +++ b/test/ui_tests/profile/edit_profile_view_test.dart @@ -89,8 +89,7 @@ void main() { when(_editProfileViewModel.updateProfile(any, any, any, any)) .thenReturn(null); - when(_editProfileViewModel - .isSuccess(_editProfileViewModel.UPDATE_PROFILE)) + when(_editProfileViewModel.isSuccess(_editProfileViewModel.updatePROFILE)) .thenReturn(true); // Pump Edit Profile View diff --git a/test/ui_tests/profile/profile_view_test.dart b/test/ui_tests/profile/profile_view_test.dart index c60eb9c2..d3899bbd 100644 --- a/test/ui_tests/profile/profile_view_test.dart +++ b/test/ui_tests/profile/profile_view_test.dart @@ -40,7 +40,7 @@ void main() { when(_profileViewModel.fetchUserProfile(any)).thenReturn(null); - when(_profileViewModel.isSuccess(_profileViewModel.FETCH_USER_PROFILE)) + when(_profileViewModel.isSuccess(_profileViewModel.fetchUSERPROFILE)) .thenReturn(true); when(_profileViewModel.user).thenReturn(user); @@ -50,7 +50,7 @@ void main() { when(_userProjectsViewModel.fetchUserProjects()).thenReturn(null); when(_userProjectsViewModel - .isSuccess(_userProjectsViewModel.FETCH_USER_PROJECTS)) + .isSuccess(_userProjectsViewModel.fetchUSERPROJECTS)) .thenReturn(false); await tester.pumpWidget( diff --git a/test/ui_tests/profile/user_favourites_view_test.dart b/test/ui_tests/profile/user_favourites_view_test.dart index 225408e9..867f3728 100644 --- a/test/ui_tests/profile/user_favourites_view_test.dart +++ b/test/ui_tests/profile/user_favourites_view_test.dart @@ -39,7 +39,7 @@ void main() { when(_userFavoritesViewModel.fetchUserFavourites()).thenReturn(null); when(_userFavoritesViewModel - .isSuccess(_userFavoritesViewModel.FETCH_USER_FAVOURITES)) + .isSuccess(_userFavoritesViewModel.fetchUSERFAVOURITES)) .thenReturn(true); when(_userFavoritesViewModel.userFavourites).thenAnswer((_) => projects); diff --git a/test/ui_tests/profile/user_projects_view_test.dart b/test/ui_tests/profile/user_projects_view_test.dart index 1cf2751a..47ac84ea 100644 --- a/test/ui_tests/profile/user_projects_view_test.dart +++ b/test/ui_tests/profile/user_projects_view_test.dart @@ -38,7 +38,7 @@ void main() { when(_userProjectsViewModel.fetchUserProjects()).thenReturn(null); when(_userProjectsViewModel - .isSuccess(_userProjectsViewModel.FETCH_USER_PROJECTS)) + .isSuccess(_userProjectsViewModel.fetchUSERPROJECTS)) .thenReturn(true); when(_userProjectsViewModel.userProjects).thenAnswer((_) => projects); diff --git a/test/ui_tests/projects/featured_projects_view_test.dart b/test/ui_tests/projects/featured_projects_view_test.dart index b49775a6..0b17e442 100644 --- a/test/ui_tests/projects/featured_projects_view_test.dart +++ b/test/ui_tests/projects/featured_projects_view_test.dart @@ -39,7 +39,7 @@ void main() { when(model.fetchFeaturedProjects()).thenReturn(null); - when(model.isSuccess(model.FETCH_FEATURED_PROJECTS)) + when(model.isSuccess(model.fetchFEATUREDPROJECTS)) .thenAnswer((_) => true); when(model.featuredProjects).thenAnswer((_) => projects); diff --git a/test/viewmodel_tests/about/about_viewmodel_test.dart b/test/viewmodel_tests/about/about_viewmodel_test.dart index 7e15cd77..6f921834 100644 --- a/test/viewmodel_tests/about/about_viewmodel_test.dart +++ b/test/viewmodel_tests/about/about_viewmodel_test.dart @@ -29,7 +29,7 @@ void main() { // verify call to fetchContributors was made verify(_mockContributorsApi.fetchContributors()); - expect(_model.stateFor(_model.FETCH_CONTRIBUTORS), ViewState.Success); + expect(_model.stateFor(_model.fetchCONTRIBUTORS), ViewState.Success); // cvContributors was populated expect(_model.cvContributors.length, 3); @@ -45,7 +45,7 @@ void main() { // verify call to fetchContributors was made verify(_mockContributorsApi.fetchContributors()); - expect(_model.stateFor(_model.FETCH_CONTRIBUTORS), ViewState.Error); + expect(_model.stateFor(_model.fetchCONTRIBUTORS), ViewState.Error); }); }); }); diff --git a/test/viewmodel_tests/authentication/login_viewmodel_test.dart b/test/viewmodel_tests/authentication/login_viewmodel_test.dart index 276f3ece..6db916ba 100644 --- a/test/viewmodel_tests/authentication/login_viewmodel_test.dart +++ b/test/viewmodel_tests/authentication/login_viewmodel_test.dart @@ -23,7 +23,7 @@ void main() { // should call login with expected variables verify(_usersApiMock.login('test@test.com', 'password')); - expect(_model.stateFor(_model.LOGIN), ViewState.Success); + expect(_model.stateFor(_model.logIN), ViewState.Success); }); test('When called & service throws error', () async { @@ -37,7 +37,7 @@ void main() { // should call login with expected variables verify(_mockUsersApi.login('test@test.com', 'password')); - expect(_model.stateFor(_model.LOGIN), ViewState.Error); + expect(_model.stateFor(_model.logIN), ViewState.Error); }); }); }); diff --git a/test/viewmodel_tests/authentication/signup_viewmodel_test.dart b/test/viewmodel_tests/authentication/signup_viewmodel_test.dart index bac5e4ad..8e99d60a 100644 --- a/test/viewmodel_tests/authentication/signup_viewmodel_test.dart +++ b/test/viewmodel_tests/authentication/signup_viewmodel_test.dart @@ -23,7 +23,7 @@ void main() { // should call login with expected variables verify(_usersApiMock.signup('test', 'test@test.com', 'password')); - expect(_model.stateFor(_model.SIGNUP), ViewState.Success); + expect(_model.stateFor(_model.signUP), ViewState.Success); }); test('When called & service throws error', () async { @@ -37,7 +37,7 @@ void main() { // should call login with expected variables verify(_mockUsersApi.signup('test', 'test@test.com', 'password')); - expect(_model.stateFor(_model.SIGNUP), ViewState.Error); + expect(_model.stateFor(_model.signUP), ViewState.Error); }); }); }); diff --git a/test/viewmodel_tests/groups/add_assignment_viewmodel_test.dart b/test/viewmodel_tests/groups/add_assignment_viewmodel_test.dart index beb8e2e4..a608ac3b 100644 --- a/test/viewmodel_tests/groups/add_assignment_viewmodel_test.dart +++ b/test/viewmodel_tests/groups/add_assignment_viewmodel_test.dart @@ -52,7 +52,7 @@ void main() { ), ); - expect(_model.stateFor(_model.ADD_ASSIGNMENT), ViewState.Success); + expect(_model.stateFor(_model.addASSIGNMENT), ViewState.Success); // addedAssignment was populated expect(_model.addedAssignment, _assignment); @@ -75,8 +75,8 @@ void main() { await _model.addAssignment( '1', 'Test', _localDeadline, 'letter', 'description', []); - expect(_model.stateFor(_model.ADD_ASSIGNMENT), ViewState.Error); - expect(_model.errorMessageFor(_model.ADD_ASSIGNMENT), + expect(_model.stateFor(_model.addASSIGNMENT), ViewState.Error); + expect(_model.errorMessageFor(_model.addASSIGNMENT), 'Some Error Occurred!'); }); }); diff --git a/test/viewmodel_tests/groups/assignment_details_viewmodel_test.dart b/test/viewmodel_tests/groups/assignment_details_viewmodel_test.dart index fd915581..79571d10 100644 --- a/test/viewmodel_tests/groups/assignment_details_viewmodel_test.dart +++ b/test/viewmodel_tests/groups/assignment_details_viewmodel_test.dart @@ -32,8 +32,8 @@ void main() { // verify API call is made.. verify(_mockAssignmentsApi.fetchAssignmentDetails('1')); - expect(_model.stateFor(_model.FETCH_ASSIGNMENT_DETAILS), - ViewState.Success); + expect( + _model.stateFor(_model.fetchASSIGNMENTDETAILS), ViewState.Success); // verify assignment data is populated.. expect(_model.assignment, _assignment); @@ -50,9 +50,8 @@ void main() { await _model.fetchAssignmentDetails('1'); // verify Error ViewState with proper error message.. - expect( - _model.stateFor(_model.FETCH_ASSIGNMENT_DETAILS), ViewState.Error); - expect(_model.errorMessageFor(_model.FETCH_ASSIGNMENT_DETAILS), + expect(_model.stateFor(_model.fetchASSIGNMENTDETAILS), ViewState.Error); + expect(_model.errorMessageFor(_model.fetchASSIGNMENTDETAILS), 'Some Error Occurred!'); }); }); @@ -71,7 +70,7 @@ void main() { // verify API call is made.. verify(_mockGradesApi.addGrade('1', '1', 'A', 'Good')); - expect(_model.stateFor(_model.ADD_GRADE), ViewState.Success); + expect(_model.stateFor(_model.addGRADE), ViewState.Success); // expect grade to be appended to the end of list.. expect(_model.grades.last, _grade); @@ -87,9 +86,8 @@ void main() { await _model.addGrade('1', 'A', 'Good'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.ADD_GRADE), ViewState.Error); - expect( - _model.errorMessageFor(_model.ADD_GRADE), 'Some Error Occurred!'); + expect(_model.stateFor(_model.addGRADE), ViewState.Error); + expect(_model.errorMessageFor(_model.addGRADE), 'Some Error Occurred!'); }); }); @@ -107,7 +105,7 @@ void main() { // verify API call is made.. verify(_mockGradesApi.updateGrade('1', 'A', 'Very Good')); - expect(_model.stateFor(_model.UPDATE_GRADE), ViewState.Success); + expect(_model.stateFor(_model.updateGRADE), ViewState.Success); // expect grade to be updated.. expect(_model.grades.firstWhere((grade) => grade.id == _grade.id), @@ -123,9 +121,9 @@ void main() { await _model.updateGrade('1', 'A', 'Very Good'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.UPDATE_GRADE), ViewState.Error); - expect(_model.errorMessageFor(_model.UPDATE_GRADE), - 'Some Error Occurred!'); + expect(_model.stateFor(_model.updateGRADE), ViewState.Error); + expect( + _model.errorMessageFor(_model.updateGRADE), 'Some Error Occurred!'); }); }); @@ -141,7 +139,7 @@ void main() { // verify API call is made.. verify(_mockGradesApi.deleteGrade('1')); - expect(_model.stateFor(_model.DELETE_GRADE), ViewState.Success); + expect(_model.stateFor(_model.deleteGRADE), ViewState.Success); // expect grade to be deleted.. expect(_model.grades.where((grade) => grade.id == _grade.id).isEmpty, @@ -157,8 +155,8 @@ void main() { await _model.deleteGrade('1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.DELETE_GRADE), ViewState.Error); - expect(_model.errorMessageFor(_model.DELETE_GRADE), + expect(_model.stateFor(_model.deleteGRADE), ViewState.Error); + expect(_model.errorMessageFor(_model.deleteGRADE), 'Grade can\'t be deleted'); }); @@ -171,9 +169,9 @@ void main() { await _model.deleteGrade('1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.DELETE_GRADE), ViewState.Error); - expect(_model.errorMessageFor(_model.DELETE_GRADE), - 'Some Error Occurred!'); + expect(_model.stateFor(_model.deleteGRADE), ViewState.Error); + expect( + _model.errorMessageFor(_model.deleteGRADE), 'Some Error Occurred!'); }); }); }); diff --git a/test/viewmodel_tests/groups/edit_group_viewmodel_test.dart b/test/viewmodel_tests/groups/edit_group_viewmodel_test.dart index f72af43f..a99ab948 100644 --- a/test/viewmodel_tests/groups/edit_group_viewmodel_test.dart +++ b/test/viewmodel_tests/groups/edit_group_viewmodel_test.dart @@ -26,7 +26,7 @@ void main() { // verify API call is made.. verify(_mockGroupsApi.updateGroup('1', 'Test')); - expect(_model.stateFor(_model.UPDATE_GROUP), ViewState.Success); + expect(_model.stateFor(_model.updateGROUP), ViewState.Success); // verify group is updated.. expect(_model.updatedGroup, _group); @@ -41,9 +41,9 @@ void main() { await _model.updateGroup('1', 'Test'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.UPDATE_GROUP), ViewState.Error); - expect(_model.errorMessageFor(_model.UPDATE_GROUP), - 'Some Error Occurred!'); + expect(_model.stateFor(_model.updateGROUP), ViewState.Error); + expect( + _model.errorMessageFor(_model.updateGROUP), 'Some Error Occurred!'); // verify group is not populated on failure expect(_model.updatedGroup, null); diff --git a/test/viewmodel_tests/groups/group_details_viewmodel_test.dart b/test/viewmodel_tests/groups/group_details_viewmodel_test.dart index 9deab377..0eb7b1e9 100644 --- a/test/viewmodel_tests/groups/group_details_viewmodel_test.dart +++ b/test/viewmodel_tests/groups/group_details_viewmodel_test.dart @@ -37,7 +37,7 @@ void main() { // verify API call is made.. verify(_mockGroupsApi.fetchGroupDetails('1')); - expect(_model.stateFor(_model.FETCH_GROUP_DETAILS), ViewState.Success); + expect(_model.stateFor(_model.fetchGROUPDETAILS), ViewState.Success); // verify group data is populated.. expect(_model.group, _group); @@ -54,8 +54,8 @@ void main() { await _model.fetchGroupDetails('1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.FETCH_GROUP_DETAILS), ViewState.Error); - expect(_model.errorMessageFor(_model.FETCH_GROUP_DETAILS), + expect(_model.stateFor(_model.fetchGROUPDETAILS), ViewState.Error); + expect(_model.errorMessageFor(_model.fetchGROUPDETAILS), 'Some Error Occurred!'); }); }); @@ -78,7 +78,7 @@ void main() { verify(_mockGroupMembersApi.addGroupMembers( '1', 'test@test.com,pending@test.com,invalid@test.com')); verify(_mockGroupMembersApi.fetchGroupMembers('1')); - expect(_model.stateFor(_model.ADD_GROUP_MEMBERS), ViewState.Success); + expect(_model.stateFor(_model.addGROUPMEMBERS), ViewState.Success); expect(_model.addedMembersSuccessMessage, 'test@test.com was/were added pending@test.com is/are pending invalid@test.com is/are invalid'); @@ -96,8 +96,8 @@ void main() { '1', 'test@test.com,pending@test.com,invalid@test.com'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.ADD_GROUP_MEMBERS), ViewState.Error); - expect(_model.errorMessageFor(_model.ADD_GROUP_MEMBERS), + expect(_model.stateFor(_model.addGROUPMEMBERS), ViewState.Error); + expect(_model.errorMessageFor(_model.addGROUPMEMBERS), 'Some Error Occurred!'); }); }); @@ -114,7 +114,7 @@ void main() { // verify API call is made.. verify(_mockGroupMembersApi.deleteGroupMember('1')); - expect(_model.stateFor(_model.DELETE_GROUP_MEMBER), ViewState.Success); + expect(_model.stateFor(_model.deleteGROUPMEMBER), ViewState.Success); // verify group member is deleted.. expect( @@ -134,8 +134,8 @@ void main() { await _model.deleteGroupMember('1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.DELETE_GROUP_MEMBER), ViewState.Error); - expect(_model.errorMessageFor(_model.DELETE_GROUP_MEMBER), + expect(_model.stateFor(_model.deleteGROUPMEMBER), ViewState.Error); + expect(_model.errorMessageFor(_model.deleteGROUPMEMBER), 'Group Member can\'t be deleted'); }); @@ -149,8 +149,8 @@ void main() { await _model.deleteGroupMember('1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.DELETE_GROUP_MEMBER), ViewState.Error); - expect(_model.errorMessageFor(_model.DELETE_GROUP_MEMBER), + expect(_model.stateFor(_model.deleteGROUPMEMBER), ViewState.Error); + expect(_model.errorMessageFor(_model.deleteGROUPMEMBER), 'Some Error Occurred!'); }); }); @@ -192,7 +192,7 @@ void main() { // verify API call is made.. verify(_mockAssignmentsApi.reopenAssignment('1')); - expect(_model.stateFor(_model.REOPEN_ASSIGNMENT), ViewState.Success); + expect(_model.stateFor(_model.reopenASSIGNMENT), ViewState.Success); // verify status of assignment to be "open".. expect( @@ -213,8 +213,8 @@ void main() { await _model.reopenAssignment('1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.REOPEN_ASSIGNMENT), ViewState.Error); - expect(_model.errorMessageFor(_model.REOPEN_ASSIGNMENT), + expect(_model.stateFor(_model.reopenASSIGNMENT), ViewState.Error); + expect(_model.errorMessageFor(_model.reopenASSIGNMENT), 'Some Error Occurred!'); }); }); @@ -240,7 +240,7 @@ void main() { // verify API call is made.. verify(_mockAssignmentsApi.startAssignment('1')); - expect(_model.stateFor(_model.START_ASSIGNMENT), ViewState.Success); + expect(_model.stateFor(_model.startASSIGNMENT), ViewState.Success); // verify status of assignment to be "open".. expect( @@ -262,8 +262,8 @@ void main() { await _model.startAssignment('1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.START_ASSIGNMENT), ViewState.Error); - expect(_model.errorMessageFor(_model.START_ASSIGNMENT), + expect(_model.stateFor(_model.startASSIGNMENT), ViewState.Error); + expect(_model.errorMessageFor(_model.startASSIGNMENT), 'Some Error Occurred!'); }); }); @@ -280,7 +280,7 @@ void main() { // verify API call is made.. verify(_mockAssignmentsApi.deleteAssignment('1')); - expect(_model.stateFor(_model.DELETE_ASSIGNMENT), ViewState.Success); + expect(_model.stateFor(_model.deleteASSIGNMENT), ViewState.Success); // expect assignment to be deleted.. expect( @@ -300,8 +300,8 @@ void main() { await _model.deleteAssignment('1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.DELETE_ASSIGNMENT), ViewState.Error); - expect(_model.errorMessageFor(_model.DELETE_ASSIGNMENT), + expect(_model.stateFor(_model.deleteASSIGNMENT), ViewState.Error); + expect(_model.errorMessageFor(_model.deleteASSIGNMENT), 'Assignment can\'t be deleted'); }); @@ -315,8 +315,8 @@ void main() { await _model.deleteAssignment('1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.DELETE_ASSIGNMENT), ViewState.Error); - expect(_model.errorMessageFor(_model.DELETE_ASSIGNMENT), + expect(_model.stateFor(_model.deleteASSIGNMENT), ViewState.Error); + expect(_model.errorMessageFor(_model.deleteASSIGNMENT), 'Some Error Occurred!'); }); }); diff --git a/test/viewmodel_tests/groups/my_groups_viewmodel_test.dart b/test/viewmodel_tests/groups/my_groups_viewmodel_test.dart index 2e8aa060..42bc067f 100644 --- a/test/viewmodel_tests/groups/my_groups_viewmodel_test.dart +++ b/test/viewmodel_tests/groups/my_groups_viewmodel_test.dart @@ -52,8 +52,7 @@ void main() { await _model.fetchMentoredGroups(); verify(_mockGroupsApi.fetchMentoringGroups()); - expect( - _model.stateFor(_model.FETCH_MENTORED_GROUPS), ViewState.Success); + expect(_model.stateFor(_model.fetchMENTOREDGROUPS), ViewState.Success); expect(_model.previousMentoredGroupsBatch, _groups); expect(deepEq(_model.mentoredGroups, _groups.data), true); }); @@ -69,8 +68,7 @@ void main() { await _model.fetchMentoredGroups(); verify(_mockGroupsApi.fetchMentoringGroups(page: 2)); - expect( - _model.stateFor(_model.FETCH_MENTORED_GROUPS), ViewState.Success); + expect(_model.stateFor(_model.fetchMENTOREDGROUPS), ViewState.Success); expect(_model.previousMentoredGroupsBatch, _groups); }); @@ -84,8 +82,8 @@ void main() { await _model.fetchMentoredGroups(); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.FETCH_MENTORED_GROUPS), ViewState.Error); - expect(_model.errorMessageFor(_model.FETCH_MENTORED_GROUPS), + expect(_model.stateFor(_model.fetchMENTOREDGROUPS), ViewState.Error); + expect(_model.errorMessageFor(_model.fetchMENTOREDGROUPS), 'Some Error Occurred!'); }); }); @@ -101,7 +99,7 @@ void main() { await _model.fetchMemberGroups(); verify(_mockGroupsApi.fetchMemberGroups()); - expect(_model.stateFor(_model.FETCH_MEMBER_GROUPS), ViewState.Success); + expect(_model.stateFor(_model.fetchMEMBERGROUPS), ViewState.Success); expect(_model.previousMemberGroupsBatch, _groups); expect(deepEq(_model.memberGroups, _groups.data), true); }); @@ -117,7 +115,7 @@ void main() { await _model.fetchMemberGroups(); verify(_mockGroupsApi.fetchMemberGroups(page: 2)); - expect(_model.stateFor(_model.FETCH_MEMBER_GROUPS), ViewState.Success); + expect(_model.stateFor(_model.fetchMEMBERGROUPS), ViewState.Success); expect(_model.previousMemberGroupsBatch, _groups); }); @@ -131,8 +129,8 @@ void main() { await _model.fetchMemberGroups(); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.FETCH_MEMBER_GROUPS), ViewState.Error); - expect(_model.errorMessageFor(_model.FETCH_MEMBER_GROUPS), + expect(_model.stateFor(_model.fetchMEMBERGROUPS), ViewState.Error); + expect(_model.errorMessageFor(_model.fetchMEMBERGROUPS), 'Some Error Occurred!'); }); }); @@ -149,7 +147,7 @@ void main() { // verify API call is made.. verify(_mockGroupsApi.deleteGroup('1')); - expect(_model.stateFor(_model.DELETE_GROUP), ViewState.Success); + expect(_model.stateFor(_model.deleteGROUP), ViewState.Success); // verify group member is deleted.. expect( @@ -169,8 +167,8 @@ void main() { await _model.deleteGroup('1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.DELETE_GROUP), ViewState.Error); - expect(_model.errorMessageFor(_model.DELETE_GROUP), + expect(_model.stateFor(_model.deleteGROUP), ViewState.Error); + expect(_model.errorMessageFor(_model.deleteGROUP), 'Group can\'t be deleted'); }); @@ -184,9 +182,9 @@ void main() { await _model.deleteGroup('1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.DELETE_GROUP), ViewState.Error); - expect(_model.errorMessageFor(_model.DELETE_GROUP), - 'Some Error Occurred!'); + expect(_model.stateFor(_model.deleteGROUP), ViewState.Error); + expect( + _model.errorMessageFor(_model.deleteGROUP), 'Some Error Occurred!'); }); }); }); diff --git a/test/viewmodel_tests/groups/new_group_viewmodel_test.dart b/test/viewmodel_tests/groups/new_group_viewmodel_test.dart index 769aedcb..d29a9b82 100644 --- a/test/viewmodel_tests/groups/new_group_viewmodel_test.dart +++ b/test/viewmodel_tests/groups/new_group_viewmodel_test.dart @@ -25,7 +25,7 @@ void main() { await _model.addGroup('Test Group'); verify(_mockGroupsApi.addGroup('Test Group')); - expect(_model.stateFor(_model.ADD_GROUP), ViewState.Success); + expect(_model.stateFor(_model.addGROUP), ViewState.Success); expect(_model.newGroup, _group); }); @@ -38,9 +38,8 @@ void main() { await _model.addGroup('Test Group'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.ADD_GROUP), ViewState.Error); - expect( - _model.errorMessageFor(_model.ADD_GROUP), 'Some Error Occurred!'); + expect(_model.stateFor(_model.addGROUP), ViewState.Error); + expect(_model.errorMessageFor(_model.addGROUP), 'Some Error Occurred!'); }); }); }); diff --git a/test/viewmodel_tests/groups/update_assignment_viewmodel_test.dart b/test/viewmodel_tests/groups/update_assignment_viewmodel_test.dart index e3a12c69..92066aa4 100644 --- a/test/viewmodel_tests/groups/update_assignment_viewmodel_test.dart +++ b/test/viewmodel_tests/groups/update_assignment_viewmodel_test.dart @@ -50,7 +50,7 @@ void main() { ), ); - expect(_model.stateFor(_model.UPDATE_ASSIGNMENT), ViewState.Success); + expect(_model.stateFor(_model.updateASSIGNMENT), ViewState.Success); // updatedAssignment was populated expect(_model.updatedAssignment, _assignment); @@ -72,8 +72,8 @@ void main() { await _model .updateAssignment('1', 'Test', _localDeadline, 'description', []); - expect(_model.stateFor(_model.UPDATE_ASSIGNMENT), ViewState.Error); - expect(_model.errorMessageFor(_model.UPDATE_ASSIGNMENT), + expect(_model.stateFor(_model.updateASSIGNMENT), ViewState.Error); + expect(_model.errorMessageFor(_model.updateASSIGNMENT), 'Some Error Occurred!'); }); }); diff --git a/test/viewmodel_tests/profile/edit_profile_viewmodel_test.dart b/test/viewmodel_tests/profile/edit_profile_viewmodel_test.dart index f65350ec..56a1555f 100644 --- a/test/viewmodel_tests/profile/edit_profile_viewmodel_test.dart +++ b/test/viewmodel_tests/profile/edit_profile_viewmodel_test.dart @@ -31,7 +31,7 @@ void main() { // verify _user is stored in localStorage.. verify(_mockLocalStorageService.currentUser = _user); - expect(_model.stateFor(_model.UPDATE_PROFILE), ViewState.Success); + expect(_model.stateFor(_model.updatePROFILE), ViewState.Success); // verify profile is updated.. expect(_model.updatedUser, _user); @@ -47,8 +47,8 @@ void main() { await _model.updateProfile('Test User', 'Gurukul', 'India', true); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.UPDATE_PROFILE), ViewState.Error); - expect(_model.errorMessageFor(_model.UPDATE_PROFILE), + expect(_model.stateFor(_model.updatePROFILE), ViewState.Error); + expect(_model.errorMessageFor(_model.updatePROFILE), 'Some Error Occurred!'); // verify user is not populated on failure diff --git a/test/viewmodel_tests/profile/profile_viewmodel_test.dart b/test/viewmodel_tests/profile/profile_viewmodel_test.dart index 94e03cea..7781d5fd 100644 --- a/test/viewmodel_tests/profile/profile_viewmodel_test.dart +++ b/test/viewmodel_tests/profile/profile_viewmodel_test.dart @@ -26,7 +26,7 @@ void main() { // verify API call is made.. verify(_mockUsersApi.fetchUser('1')); - expect(_model.stateFor(_model.FETCH_USER_PROFILE), ViewState.Success); + expect(_model.stateFor(_model.fetchUSERPROFILE), ViewState.Success); // verify profile/user is populated.. expect(_model.user, _user); @@ -41,8 +41,8 @@ void main() { await _model.fetchUserProfile('1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.FETCH_USER_PROFILE), ViewState.Error); - expect(_model.errorMessageFor(_model.FETCH_USER_PROFILE), + expect(_model.stateFor(_model.fetchUSERPROFILE), ViewState.Error); + expect(_model.errorMessageFor(_model.fetchUSERPROFILE), 'Some Error Occurred!'); // verify user is not populated on failure diff --git a/test/viewmodel_tests/profile/user_favourites_viewmodel_test.dart b/test/viewmodel_tests/profile/user_favourites_viewmodel_test.dart index 60de14a2..9d22c05d 100644 --- a/test/viewmodel_tests/profile/user_favourites_viewmodel_test.dart +++ b/test/viewmodel_tests/profile/user_favourites_viewmodel_test.dart @@ -44,8 +44,7 @@ void main() { await _model.fetchUserFavourites(userId: '1'); verify(_mockProjectsApi.getUserFavourites('1')); - expect( - _model.stateFor(_model.FETCH_USER_FAVOURITES), ViewState.Success); + expect(_model.stateFor(_model.fetchUSERFAVOURITES), ViewState.Success); expect(_model.previousUserFavouritesBatch, _projects); expect(deepEq(_model.userFavourites, _projects.data), true); }); @@ -62,8 +61,7 @@ void main() { // verify API call to page 2 is made verify(_mockProjectsApi.getUserFavourites('1', page: 2)); - expect( - _model.stateFor(_model.FETCH_USER_FAVOURITES), ViewState.Success); + expect(_model.stateFor(_model.fetchUSERFAVOURITES), ViewState.Success); expect(_model.previousUserFavouritesBatch, _projects); }); @@ -81,8 +79,7 @@ void main() { // verify API call is made with _currentUser.data.id i.e '1'.. verify(_mockProjectsApi.getUserFavourites('1')); - expect( - _model.stateFor(_model.FETCH_USER_FAVOURITES), ViewState.Success); + expect(_model.stateFor(_model.fetchUSERFAVOURITES), ViewState.Success); expect(_model.previousUserFavouritesBatch, _projects); expect(deepEq(_model.userFavourites, _projects.data), true); }); @@ -96,8 +93,8 @@ void main() { await _model.fetchUserFavourites(userId: '1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.FETCH_USER_FAVOURITES), ViewState.Error); - expect(_model.errorMessageFor(_model.FETCH_USER_FAVOURITES), + expect(_model.stateFor(_model.fetchUSERFAVOURITES), ViewState.Error); + expect(_model.errorMessageFor(_model.fetchUSERFAVOURITES), 'Some Error Occurred!'); }); }); diff --git a/test/viewmodel_tests/profile/user_projects_viewmodel_test.dart b/test/viewmodel_tests/profile/user_projects_viewmodel_test.dart index fcda1306..0d5fb2eb 100644 --- a/test/viewmodel_tests/profile/user_projects_viewmodel_test.dart +++ b/test/viewmodel_tests/profile/user_projects_viewmodel_test.dart @@ -44,7 +44,7 @@ void main() { await _model.fetchUserProjects(userId: '1'); verify(_mockProjectsApi.getUserProjects('1')); - expect(_model.stateFor(_model.FETCH_USER_PROJECTS), ViewState.Success); + expect(_model.stateFor(_model.fetchUSERPROJECTS), ViewState.Success); expect(_model.previousUserProjectsBatch, _projects); expect(deepEq(_model.userProjects, _projects.data), true); }); @@ -61,7 +61,7 @@ void main() { // verify API call to page 2 is made verify(_mockProjectsApi.getUserProjects('1', page: 2)); - expect(_model.stateFor(_model.FETCH_USER_PROJECTS), ViewState.Success); + expect(_model.stateFor(_model.fetchUSERPROJECTS), ViewState.Success); expect(_model.previousUserProjectsBatch, _projects); }); @@ -79,7 +79,7 @@ void main() { // verify API call is made with _currentUser.data.id i.e '1'.. verify(_mockProjectsApi.getUserProjects('1')); - expect(_model.stateFor(_model.FETCH_USER_PROJECTS), ViewState.Success); + expect(_model.stateFor(_model.fetchUSERPROJECTS), ViewState.Success); expect(_model.previousUserProjectsBatch, _projects); expect(deepEq(_model.userProjects, _projects.data), true); }); @@ -93,8 +93,8 @@ void main() { await _model.fetchUserProjects(userId: '1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.FETCH_USER_PROJECTS), ViewState.Error); - expect(_model.errorMessageFor(_model.FETCH_USER_PROJECTS), + expect(_model.stateFor(_model.fetchUSERPROJECTS), ViewState.Error); + expect(_model.errorMessageFor(_model.fetchUSERPROJECTS), 'Some Error Occurred!'); }); }); diff --git a/test/viewmodel_tests/projects/edit_project_viewmodel_test.dart b/test/viewmodel_tests/projects/edit_project_viewmodel_test.dart index fa45edb6..e06ff13f 100644 --- a/test/viewmodel_tests/projects/edit_project_viewmodel_test.dart +++ b/test/viewmodel_tests/projects/edit_project_viewmodel_test.dart @@ -37,7 +37,7 @@ void main() { projectAccessType: 'Public', description: 'description', tagsList: [])); - expect(_model.stateFor(_model.UPDATE_PROJECT), ViewState.Success); + expect(_model.stateFor(_model.updatePROJECT), ViewState.Success); // verify project is updated.. expect(_model.updatedProject, _project); @@ -59,8 +59,8 @@ void main() { tagsList: []); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.UPDATE_PROJECT), ViewState.Error); - expect(_model.errorMessageFor(_model.UPDATE_PROJECT), + expect(_model.stateFor(_model.updatePROJECT), ViewState.Error); + expect(_model.errorMessageFor(_model.updatePROJECT), 'Some Error Occurred!'); // verify project is not populated on failure diff --git a/test/viewmodel_tests/projects/featured_projects_viewmodel_test.dart b/test/viewmodel_tests/projects/featured_projects_viewmodel_test.dart index 4c84abbc..51f46a96 100644 --- a/test/viewmodel_tests/projects/featured_projects_viewmodel_test.dart +++ b/test/viewmodel_tests/projects/featured_projects_viewmodel_test.dart @@ -27,7 +27,7 @@ void main() { verify(_mockProjectsApi.getFeaturedProjects()); expect( - _model.stateFor(_model.FETCH_FEATURED_PROJECTS), ViewState.Success); + _model.stateFor(_model.fetchFEATUREDPROJECTS), ViewState.Success); expect(_model.previousFeaturedProjectsBatch, _projects); expect(deepEq(_model.featuredProjects, _projects.data), true); }); @@ -45,7 +45,7 @@ void main() { // verify API call to page 2 is made verify(_mockProjectsApi.getFeaturedProjects(page: 2)); expect( - _model.stateFor(_model.FETCH_FEATURED_PROJECTS), ViewState.Success); + _model.stateFor(_model.fetchFEATUREDPROJECTS), ViewState.Success); expect(_model.previousFeaturedProjectsBatch, _projects); }); @@ -58,9 +58,8 @@ void main() { await _model.fetchFeaturedProjects(); // verify Error ViewState with proper error message.. - expect( - _model.stateFor(_model.FETCH_FEATURED_PROJECTS), ViewState.Error); - expect(_model.errorMessageFor(_model.FETCH_FEATURED_PROJECTS), + expect(_model.stateFor(_model.fetchFEATUREDPROJECTS), ViewState.Error); + expect(_model.errorMessageFor(_model.fetchFEATUREDPROJECTS), 'Some Error Occurred!'); }); }); diff --git a/test/viewmodel_tests/projects/project_details_viewmodel_test.dart b/test/viewmodel_tests/projects/project_details_viewmodel_test.dart index 427fa866..544ff247 100644 --- a/test/viewmodel_tests/projects/project_details_viewmodel_test.dart +++ b/test/viewmodel_tests/projects/project_details_viewmodel_test.dart @@ -34,8 +34,7 @@ void main() { // verify API call is made.. verify(_mockProjectsApi.getProjectDetails('1')); - expect( - _model.stateFor(_model.FETCH_PROJECT_DETAILS), ViewState.Success); + expect(_model.stateFor(_model.fetchPROJECTDETAILS), ViewState.Success); // verify project data is populated.. expect(_model.project, _project); @@ -51,8 +50,8 @@ void main() { await _model.fetchProjectDetails('1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.FETCH_PROJECT_DETAILS), ViewState.Error); - expect(_model.errorMessageFor(_model.FETCH_PROJECT_DETAILS), + expect(_model.stateFor(_model.fetchPROJECTDETAILS), ViewState.Error); + expect(_model.errorMessageFor(_model.fetchPROJECTDETAILS), 'Some Error Occurred!'); }); }); @@ -75,7 +74,7 @@ void main() { verify(_mockCollaboratorsApi.addCollaborators( '1', 'test@test.com,existing@test.com,invalid@test.com')); verify(_mockCollaboratorsApi.fetchProjectCollaborators('1')); - expect(_model.stateFor(_model.ADD_COLLABORATORS), ViewState.Success); + expect(_model.stateFor(_model.addCOLLABORATORS), ViewState.Success); expect(_model.addedCollaboratorsSuccessMessage, 'test@test.com was/were added existing@test.com is/are existing invalid@test.com is/are invalid'); @@ -93,8 +92,8 @@ void main() { '1', 'test@test.com,existing@test.com,invalid@test.com'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.ADD_COLLABORATORS), ViewState.Error); - expect(_model.errorMessageFor(_model.ADD_COLLABORATORS), + expect(_model.stateFor(_model.addCOLLABORATORS), ViewState.Error); + expect(_model.errorMessageFor(_model.addCOLLABORATORS), 'Some Error Occurred!'); }); }); @@ -111,7 +110,7 @@ void main() { // verify API call is made.. verify(_mockCollaboratorsApi.deleteCollaborator('1', '1')); - expect(_model.stateFor(_model.DELETE_COLLABORATORS), ViewState.Success); + expect(_model.stateFor(_model.deleteCOLLABORATORS), ViewState.Success); // verify collaborator is deleted.. expect( @@ -131,8 +130,8 @@ void main() { await _model.deleteCollaborator('1', '1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.DELETE_COLLABORATORS), ViewState.Error); - expect(_model.errorMessageFor(_model.DELETE_COLLABORATORS), + expect(_model.stateFor(_model.deleteCOLLABORATORS), ViewState.Error); + expect(_model.errorMessageFor(_model.deleteCOLLABORATORS), 'Some Error Occurred!'); }); }); @@ -148,7 +147,7 @@ void main() { // verify API call is made.. verify(_mockProjectsApi.forkProject('1')); - expect(_model.stateFor(_model.FORK_PROJECT), ViewState.Success); + expect(_model.stateFor(_model.forkPROJECT), ViewState.Success); // verify forkedProject data is populated.. expect(_model.forkedProject, _project); @@ -163,9 +162,9 @@ void main() { await _model.forkProject('1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.FORK_PROJECT), ViewState.Error); - expect(_model.errorMessageFor(_model.FORK_PROJECT), - 'Some Error Occurred!'); + expect(_model.stateFor(_model.forkPROJECT), ViewState.Error); + expect( + _model.errorMessageFor(_model.forkPROJECT), 'Some Error Occurred!'); }); }); @@ -180,7 +179,7 @@ void main() { // verify API call is made.. verify(_mockProjectsApi.toggleStarProject('1')); - expect(_model.stateFor(_model.TOGGLE_STAR), ViewState.Success); + expect(_model.stateFor(_model.toggleSTAR), ViewState.Success); // verify starCount to increment by 1.. expect(_model.starCount, 1); @@ -196,7 +195,7 @@ void main() { // verify API call is made.. verify(_mockProjectsApi.toggleStarProject('1')); - expect(_model.stateFor(_model.TOGGLE_STAR), ViewState.Success); + expect(_model.stateFor(_model.toggleSTAR), ViewState.Success); // verify starCount to decrement by 1.. expect(_model.starCount, -1); @@ -211,9 +210,9 @@ void main() { await _model.toggleStarForProject('1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.TOGGLE_STAR), ViewState.Error); + expect(_model.stateFor(_model.toggleSTAR), ViewState.Error); expect( - _model.errorMessageFor(_model.TOGGLE_STAR), 'Some Error Occurred!'); + _model.errorMessageFor(_model.toggleSTAR), 'Some Error Occurred!'); }); }); @@ -229,7 +228,7 @@ void main() { // verify API call is made.. verify(_mockProjectsApi.deleteProject('1')); - expect(_model.stateFor(_model.DELETE_PROJECT), ViewState.Success); + expect(_model.stateFor(_model.deletePROJECT), ViewState.Success); }); test('When called & service returns error', () async { @@ -242,8 +241,8 @@ void main() { await _model.deleteProject('1'); // verify Error ViewState with proper error message.. - expect(_model.stateFor(_model.DELETE_PROJECT), ViewState.Error); - expect(_model.errorMessageFor(_model.DELETE_PROJECT), + expect(_model.stateFor(_model.deletePROJECT), ViewState.Error); + expect(_model.errorMessageFor(_model.deletePROJECT), 'Some Error Occurred!'); }); });