From 054604370b9944dc4dd132e6830657c2f9508682 Mon Sep 17 00:00:00 2001 From: ItsAdityaKSingh Date: Sat, 15 Jan 2022 16:15:44 +0530 Subject: [PATCH 1/3] constant_identifier_names --- lib/config/environment_config.dart | 16 ++--- lib/constants.dart | 39 ++++++------ lib/enums/auth_type.dart | 10 +-- lib/enums/view_state.dart | 2 + lib/models/cv_contributors.dart | 6 +- lib/services/API/assignments_api.dart | 48 +++++++------- lib/services/API/collaborators_api.dart | 18 +++--- lib/services/API/contributors_api.dart | 4 +- lib/services/API/country_institute_api.dart | 12 ++-- lib/services/API/fcm_api.dart | 6 +- lib/services/API/grades_api.dart | 22 +++---- lib/services/API/group_members_api.dart | 18 +++--- lib/services/API/groups_api.dart | 30 ++++----- lib/services/API/ib_api.dart | 14 ++--- lib/services/API/projects_api.dart | 52 ++++++++-------- lib/services/API/users_api.dart | 62 +++++++++---------- lib/services/database_service.dart | 7 ++- lib/services/ib_engine_service.dart | 5 +- lib/services/local_storage_service.dart | 26 ++++---- lib/ui/components/cv_typeahead_field.dart | 5 +- lib/ui/views/about/about_view.dart | 2 +- .../views/groups/assignment_details_view.dart | 4 +- lib/ui/views/ib/ib_page_view.dart | 6 +- .../views/ib/syntaxes/ib_liquid_syntax.dart | 2 +- lib/ui/views/profile/edit_profile_view.dart | 2 +- .../components/featured_project_card.dart | 4 +- .../projects/components/project_card.dart | 4 +- .../views/projects/project_details_view.dart | 4 +- .../project_preview_fullscreen_view.dart | 4 +- lib/utils/api_utils.dart | 20 +++--- .../auth_options_viewmodel.dart | 12 ++-- lib/viewmodels/cv_landing_viewmodel.dart | 4 +- test/model_tests/cv_contributors_test.dart | 2 +- test/service_tests/ib_engine_test.dart | 2 +- test/ui_tests/about/about_view_test.dart | 2 +- 35 files changed, 241 insertions(+), 235 deletions(-) diff --git a/lib/config/environment_config.dart b/lib/config/environment_config.dart index 5fcba99d..dd98a3eb 100644 --- a/lib/config/environment_config.dart +++ b/lib/config/environment_config.dart @@ -1,32 +1,32 @@ class EnvironmentConfig { - static const String CV_API_BASE_URL = String.fromEnvironment( + static const String cvAPIBASEURL = String.fromEnvironment( 'CV_API_BASE_URL', defaultValue: 'https://circuitverse.org/api/v1', ); - static const String IB_API_BASE_URL = String.fromEnvironment( + static const String ibAPIBASEURL = String.fromEnvironment( 'IB_API_BASE_URL', defaultValue: 'https://learn.circuitverse.org/_api/pages', ); - static const String IB_BASE_URL = String.fromEnvironment( + static const String ibBASEURL = String.fromEnvironment( 'IB_BASE_URL', defaultValue: 'https://learn.circuitverse.org', ); // GITHUB OAUTH ENV VARIABLES - static const String GITHUB_OAUTH_CLIENT_ID = String.fromEnvironment( + static const String githubOAUTHCLIENTID = String.fromEnvironment( 'GITHUB_OAUTH_CLIENT_ID', ); - static const String GITHUB_OAUTH_CLIENT_SECRET = String.fromEnvironment( + static const String githubOAUTHCLIENTSECRET = String.fromEnvironment( 'GITHUB_OAUTH_CLIENT_SECRET', ); - static const String GITHUB_OAUTH_REDIRECT_URI = String.fromEnvironment( + static const String githubOAUTHREDIRECTURI = String.fromEnvironment( 'GITHUB_OAUTH_REDIRECT_URI', defaultValue: 'circuitverse://auth/callback/github', ); // FB OAUTH ENV VARIABLES - static const String FB_APP_NAME = String.fromEnvironment('FB_APP_NAME'); - static const String FB_APP_ID = String.fromEnvironment('FB_APP_ID'); + static const String fbAPPNAME = String.fromEnvironment('FB_APP_NAME'); + static const String fbAPPID = String.fromEnvironment('FB_APP_ID'); } diff --git a/lib/constants.dart b/lib/constants.dart index e4d94fe1..e47ea65c 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -1,47 +1,48 @@ class Constants { /// USER CONSTANTS - static const String USER_AUTH_WRONG_CREDENTIALS = + static const String userAUTHWRONGCREDENTIALS = 'Invalid credentials, please check'; - static const String USER_AUTH_USER_NOT_FOUND = - 'User not found, try signing up'; - static const String USER_AUTH_USER_ALREADY_EXISTS = + static const String userAUTHUSERNOTFOUND = 'User not found, try signing up'; + static const String userAUTHUSERALREADYEXISTS = 'User already exists, try login'; - static const String USER_NOT_AUTHORIZED_TO_FETCH_USER = + static const String userNOTAUTHORIZEDTOFETCHUSER = 'You are not authorized to fetch this user'; - static const String USER_NOT_FOUND = 'User not found'; + static const String userNOTFOUND = 'User not found'; /// PROJECT CONSTANTS - static const String PROJECT_NOT_FOUND = 'No project was found'; - static const String PROJECT_FORK_CONFLICT = 'Cannot fork your own project'; + static const String projectNOTFOUND = 'No project was found'; + static const String projectFORKCONFLICT = 'Cannot fork your own project'; /// COLLABORATOR CONSTANTS - static const String COLLABORATOR_NOT_FOUND = + static const String collaboratorNOTFOUND = 'The requested collaborator does not exists'; /// GROUP RELATED CONSTANTS - static const String GROUP_NOT_FOUND = 'The requested group does not exists'; + static const String groupNOTFOUND = 'The requested group does not exists'; /// GROUP MEMBERS CONSTANTS - static const String GROUP_MEMBER_NOT_FOUND = + static const String groupMEMBERNOTFOUND = 'The requested group member does not exists'; /// ASSIGNMENTS CONSTANTS - static const String ASSIGNMENT_ALREADY_OPENED = + static const String assignmentALREADYOPENED = 'The assignment is already opened'; - static const String ASSIGNMENT_NOT_FOUND = + static const String assignmentNOTFOUND = 'The requested assignment does not exists'; /// GRADE CONSTANTS - static const String GRADE_NOT_FOUND = 'Grade not found'; + static const String gradeNOTFOUND = 'Grade not found'; /// GENERIC FAILURE CONSTANTS - static const String BAD_RESPONSE_FORMAT = 'Bad response format'; - static const String INVALID_PARAMETERS = 'Invalid parameters, retry!'; - static const String GENERIC_FAILURE = + static const String badRESPONSEFORMAT = 'Bad response format'; + static const String invalidPARAMETERS = 'Invalid parameters, retry!'; + static const String genericFAILURE = 'Something wrong occurred! please try again'; - static const String NO_INTERNET_CONNECTION = 'No internet connection'; - static const String HTTP_EXCEPTION = 'Unable to fetch response'; + static const String noINTERNETCONNECTION = 'No internet connection'; + static const String httpEXCEPTION = 'Unable to fetch response'; + // ignore: constant_identifier_names static const String UNAUTHENTICATED = 'Unauthenticated to perform this action'; + // ignore: constant_identifier_names static const String UNAUTHORIZED = 'Unauthorized to perform this action'; } diff --git a/lib/enums/auth_type.dart b/lib/enums/auth_type.dart index 7a53e90b..fdaf971b 100644 --- a/lib/enums/auth_type.dart +++ b/lib/enums/auth_type.dart @@ -1,10 +1,10 @@ import 'package:mobile_app/utils/enum_values.dart'; -enum AuthType { EMAIL, FACEBOOK, GOOGLE, GITHUB } +enum AuthType { email, facebook, google, github } final authTypeValues = EnumValues({ - 'email': AuthType.EMAIL, - 'facebook': AuthType.FACEBOOK, - 'google': AuthType.GOOGLE, - 'github': AuthType.GITHUB, + 'email': AuthType.email, + 'facebook': AuthType.facebook, + 'google': AuthType.google, + 'github': AuthType.github, }); diff --git a/lib/enums/view_state.dart b/lib/enums/view_state.dart index a1f871a9..c9e9c86f 100644 --- a/lib/enums/view_state.dart +++ b/lib/enums/view_state.dart @@ -1 +1,3 @@ +// ignore_for_file: constant_identifier_names + enum ViewState { Idle, Busy, Error, Success } diff --git a/lib/models/cv_contributors.dart b/lib/models/cv_contributors.dart index dbbc6f5f..4fa863e7 100644 --- a/lib/models/cv_contributors.dart +++ b/lib/models/cv_contributors.dart @@ -72,9 +72,9 @@ class CircuitVerseContributor { int contributions; } -enum Type { USER, BOT } +enum Type { user, bot } final typeValues = EnumValues({ - 'Bot': Type.BOT, - 'User': Type.USER, + 'Bot': Type.bot, + 'User': Type.user, }); diff --git a/lib/services/API/assignments_api.dart b/lib/services/API/assignments_api.dart index c6d1a780..f0c605d7 100644 --- a/lib/services/API/assignments_api.dart +++ b/lib/services/API/assignments_api.dart @@ -40,7 +40,7 @@ class HttpAssignmentsApi implements AssignmentsApi { @override Future fetchAssignments(String groupId, {int page = 1}) async { var endpoint = '/groups/$groupId/assignments?page[number]=$page'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -52,16 +52,16 @@ class HttpAssignmentsApi implements AssignmentsApi { } on ForbiddenException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.GROUP_NOT_FOUND); + throw Failure(Constants.groupNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future fetchAssignmentDetails(String assignmentId) async { var endpoint = '/assignments/$assignmentId?include=grades,projects'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -74,9 +74,9 @@ class HttpAssignmentsApi implements AssignmentsApi { } on ForbiddenException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.ASSIGNMENT_NOT_FOUND); + throw Failure(Constants.assignmentNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @@ -90,7 +90,7 @@ class HttpAssignmentsApi implements AssignmentsApi { String restrictions, ) async { var endpoint = '/groups/$groupId/assignments'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; var json = { 'name': name, 'deadline': deadline, @@ -108,13 +108,13 @@ class HttpAssignmentsApi implements AssignmentsApi { ); return Assignment.fromJson(jsonResponse['data']); } on BadRequestException { - throw Failure(Constants.INVALID_PARAMETERS); + throw Failure(Constants.invalidPARAMETERS); } on ForbiddenException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.GROUP_NOT_FOUND); + throw Failure(Constants.groupNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @@ -127,7 +127,7 @@ class HttpAssignmentsApi implements AssignmentsApi { String restrictions, ) async { var endpoint = '/assignments/$assignmentId'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; var json = { 'name': name, 'deadline': deadline, @@ -145,20 +145,20 @@ class HttpAssignmentsApi implements AssignmentsApi { var assignment = Assignment.fromJson(jsonResponse['data']); return assignment; } on BadRequestException { - throw Failure(Constants.INVALID_PARAMETERS); + throw Failure(Constants.invalidPARAMETERS); } on ForbiddenException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.ASSIGNMENT_NOT_FOUND); + throw Failure(Constants.assignmentNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future deleteAssignment(String assignmentId) async { var endpoint = '/assignments/$assignmentId'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -170,16 +170,16 @@ class HttpAssignmentsApi implements AssignmentsApi { } on ForbiddenException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.ASSIGNMENT_NOT_FOUND); + throw Failure(Constants.assignmentNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future reopenAssignment(String assignmentId) async { var endpoint = '/assignments/$assignmentId/reopen'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -188,18 +188,18 @@ class HttpAssignmentsApi implements AssignmentsApi { } on ForbiddenException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.ASSIGNMENT_NOT_FOUND); + throw Failure(Constants.assignmentNOTFOUND); } on ConflictException { - throw Failure(Constants.ASSIGNMENT_ALREADY_OPENED); + throw Failure(Constants.assignmentALREADYOPENED); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future startAssignment(String assignmentId) async { var endpoint = '/assignments/$assignmentId/start'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -208,9 +208,9 @@ class HttpAssignmentsApi implements AssignmentsApi { } on ForbiddenException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.ASSIGNMENT_NOT_FOUND); + throw Failure(Constants.assignmentNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } } diff --git a/lib/services/API/collaborators_api.dart b/lib/services/API/collaborators_api.dart index 6a054444..b8d16090 100644 --- a/lib/services/API/collaborators_api.dart +++ b/lib/services/API/collaborators_api.dart @@ -26,7 +26,7 @@ class HttpCollaboratorsApi implements CollaboratorsApi { @override Future fetchProjectCollaborators(String projectId) async { var endpoint = '/projects/$projectId/collaborators'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -38,9 +38,9 @@ class HttpCollaboratorsApi implements CollaboratorsApi { } on UnauthorizedException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.PROJECT_NOT_FOUND); + throw Failure(Constants.projectNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @@ -50,7 +50,7 @@ class HttpCollaboratorsApi implements CollaboratorsApi { String listOfMails, ) async { var endpoint = '/projects/$projectId/collaborators'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; var json = {'emails': listOfMails}; try { @@ -65,9 +65,9 @@ class HttpCollaboratorsApi implements CollaboratorsApi { } on UnauthorizedException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.PROJECT_NOT_FOUND); + throw Failure(Constants.projectNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @@ -77,7 +77,7 @@ class HttpCollaboratorsApi implements CollaboratorsApi { String collaboratorId, ) async { var endpoint = '/projects/$projectId/collaborators/$collaboratorId'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -89,9 +89,9 @@ class HttpCollaboratorsApi implements CollaboratorsApi { } on UnauthorizedException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.COLLABORATOR_NOT_FOUND); + throw Failure(Constants.collaboratorNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } } diff --git a/lib/services/API/contributors_api.dart b/lib/services/API/contributors_api.dart index c6f3b163..0695949e 100644 --- a/lib/services/API/contributors_api.dart +++ b/lib/services/API/contributors_api.dart @@ -21,9 +21,9 @@ class HttpContributorsApi implements ContributorsApi { var _jsonResponse = await ApiUtils.get(_url, headers: headers); return circuitVerseContributorsFromJson(jsonEncode(_jsonResponse)); } on FormatException { - throw Failure(Constants.BAD_RESPONSE_FORMAT); + throw Failure(Constants.badRESPONSEFORMAT); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } } diff --git a/lib/services/API/country_institute_api.dart b/lib/services/API/country_institute_api.dart index 598c503e..9a06feb8 100644 --- a/lib/services/API/country_institute_api.dart +++ b/lib/services/API/country_institute_api.dart @@ -30,9 +30,9 @@ class HttpCountryInstituteAPI implements CountryInstituteAPI { return matches; } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } catch (e) { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @@ -42,9 +42,9 @@ class HttpCountryInstituteAPI implements CountryInstituteAPI { try { return _fetchAPI(query, url); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } catch (e) { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @@ -54,9 +54,9 @@ class HttpCountryInstituteAPI implements CountryInstituteAPI { try { return _fetchAPI(query, url); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } catch (e) { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } } diff --git a/lib/services/API/fcm_api.dart b/lib/services/API/fcm_api.dart index fc56d1fd..4ee0b9cc 100644 --- a/lib/services/API/fcm_api.dart +++ b/lib/services/API/fcm_api.dart @@ -14,7 +14,7 @@ class HttpFCMApi implements FCMApi { @override Future sendToken(String fcmToken) async { var endpoint = '/fcm/token'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; var json = {'token': fcmToken}; try { @@ -28,9 +28,9 @@ class HttpFCMApi implements FCMApi { } on UnauthorizedException { throw Failure(Constants.UNAUTHENTICATED); } on UnprocessableIdentityException { - throw Failure(Constants.INVALID_PARAMETERS); + throw Failure(Constants.invalidPARAMETERS); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } } diff --git a/lib/services/API/grades_api.dart b/lib/services/API/grades_api.dart index fdc88720..bafe2a7c 100644 --- a/lib/services/API/grades_api.dart +++ b/lib/services/API/grades_api.dart @@ -33,7 +33,7 @@ class HttpGradesApi implements GradesApi { String remarks, ) async { var endpoint = '/assignments/$assignmentId/projects/$projectId/grades'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; var json = { 'grade': { 'grade': grade, @@ -52,11 +52,11 @@ class HttpGradesApi implements GradesApi { } on ForbiddenException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.ASSIGNMENT_NOT_FOUND); + throw Failure(Constants.assignmentNOTFOUND); } on UnprocessableIdentityException { - throw Failure(Constants.INVALID_PARAMETERS); + throw Failure(Constants.invalidPARAMETERS); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @@ -67,7 +67,7 @@ class HttpGradesApi implements GradesApi { String remarks, ) async { var endpoint = '/grades/$gradeId'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; var json = { 'grade': { 'grade': grade, @@ -87,18 +87,18 @@ class HttpGradesApi implements GradesApi { } on ForbiddenException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.ASSIGNMENT_NOT_FOUND); + throw Failure(Constants.assignmentNOTFOUND); } on UnprocessableIdentityException { - throw Failure(Constants.INVALID_PARAMETERS); + throw Failure(Constants.invalidPARAMETERS); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future deleteGrade(String gradeId) async { var endpoint = '/grades/$gradeId'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -110,9 +110,9 @@ class HttpGradesApi implements GradesApi { } on ForbiddenException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.GRADE_NOT_FOUND); + throw Failure(Constants.gradeNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } } diff --git a/lib/services/API/group_members_api.dart b/lib/services/API/group_members_api.dart index f67df4cf..590e2f6d 100644 --- a/lib/services/API/group_members_api.dart +++ b/lib/services/API/group_members_api.dart @@ -21,7 +21,7 @@ class HttpGroupMembersApi implements GroupMembersApi { @override Future fetchGroupMembers(String groupId) async { var endpoint = '/groups/$groupId/members'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -33,9 +33,9 @@ class HttpGroupMembersApi implements GroupMembersApi { } on UnauthorizedException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.GROUP_NOT_FOUND); + throw Failure(Constants.groupNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @@ -43,7 +43,7 @@ class HttpGroupMembersApi implements GroupMembersApi { Future addGroupMembers( String groupId, String listOfMails) async { var endpoint = '/groups/$groupId/members'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; var json = {'emails': listOfMails}; try { @@ -58,16 +58,16 @@ class HttpGroupMembersApi implements GroupMembersApi { } on UnauthorizedException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.GROUP_NOT_FOUND); + throw Failure(Constants.groupNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future deleteGroupMember(String groupMemberId) async { var endpoint = '/group/members/$groupMemberId'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -79,9 +79,9 @@ class HttpGroupMembersApi implements GroupMembersApi { } on UnauthorizedException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.GROUP_MEMBER_NOT_FOUND); + throw Failure(Constants.groupMEMBERNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } } diff --git a/lib/services/API/groups_api.dart b/lib/services/API/groups_api.dart index 1b51f7f1..68942c03 100644 --- a/lib/services/API/groups_api.dart +++ b/lib/services/API/groups_api.dart @@ -25,7 +25,7 @@ class HttpGroupsApi implements GroupsApi { @override Future fetchMemberGroups({int page = 1}) async { var endpoint = '/groups?page[number]=$page'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -37,14 +37,14 @@ class HttpGroupsApi implements GroupsApi { } on UnauthorizedException { throw Failure(Constants.UNAUTHORIZED); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future fetchMentoringGroups({int page = 1}) async { var endpoint = '/groups/mentored?page[number]=$page'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -56,14 +56,14 @@ class HttpGroupsApi implements GroupsApi { } on UnauthorizedException { throw Failure(Constants.UNAUTHORIZED); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future fetchGroupDetails(String groupId) async { var endpoint = '/groups/$groupId?include=group_members,assignments'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -77,16 +77,16 @@ class HttpGroupsApi implements GroupsApi { } on ForbiddenException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.GROUP_NOT_FOUND); + throw Failure(Constants.groupNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future addGroup(String name) async { var endpoint = '/groups'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; var json = {'name': name}; try { @@ -100,14 +100,14 @@ class HttpGroupsApi implements GroupsApi { } on UnauthorizedException { throw Failure(Constants.UNAUTHENTICATED); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future updateGroup(String groupId, String name) async { var endpoint = '/groups/$groupId?include=group_members,assignments'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; var json = {'name': name}; try { @@ -123,16 +123,16 @@ class HttpGroupsApi implements GroupsApi { } on ForbiddenException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.GROUP_NOT_FOUND); + throw Failure(Constants.groupNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future deleteGroup(String groupId) async { var endpoint = '/groups/$groupId'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -146,9 +146,9 @@ class HttpGroupsApi implements GroupsApi { } on ForbiddenException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.GROUP_NOT_FOUND); + throw Failure(Constants.groupNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } } diff --git a/lib/services/API/ib_api.dart b/lib/services/API/ib_api.dart index 576ecffc..95b9d686 100644 --- a/lib/services/API/ib_api.dart +++ b/lib/services/API/ib_api.dart @@ -18,8 +18,8 @@ class HttpIbApi implements IbApi { @override Future>> fetchApiPage({String id = ''}) async { var _url = id == '' - ? '${EnvironmentConfig.IB_API_BASE_URL}.json' - : '${EnvironmentConfig.IB_API_BASE_URL}/$id.json'; + ? '${EnvironmentConfig.ibAPIBASEURL}.json' + : '${EnvironmentConfig.ibAPIBASEURL}/$id.json'; try { if (await _db.isExpired(_url)) { @@ -37,23 +37,23 @@ class HttpIbApi implements IbApi { return data.map((e) => Map.from(e))?.toList(); } } on FormatException { - throw Failure(Constants.BAD_RESPONSE_FORMAT); + throw Failure(Constants.badRESPONSEFORMAT); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future fetchRawPageData({String id = 'index.md'}) async { - var _url = '${EnvironmentConfig.IB_API_BASE_URL}/$id'; + var _url = '${EnvironmentConfig.ibAPIBASEURL}/$id'; try { var _jsonResponse = await ApiUtils.get(_url, utfDecoder: true); return IbRawPageData.fromJson(_jsonResponse); } on FormatException { - throw Failure(Constants.BAD_RESPONSE_FORMAT); + throw Failure(Constants.badRESPONSEFORMAT); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } } diff --git a/lib/services/API/projects_api.dart b/lib/services/API/projects_api.dart index f8ed0b29..f5b8539b 100644 --- a/lib/services/API/projects_api.dart +++ b/lib/services/API/projects_api.dart @@ -62,7 +62,7 @@ class HttpProjectsApi implements ProjectsApi { var endpoint = '/projects?page[number]=$page'; if (filterByTag != null) endpoint += '&filter[tag]=$filterByTag'; if (sortBy != null) endpoint += '&sort=$sortBy'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { var jsonResponse = await ApiUtils.get( @@ -71,7 +71,7 @@ class HttpProjectsApi implements ProjectsApi { ); return Projects.fromJson(jsonResponse); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @@ -85,7 +85,7 @@ class HttpProjectsApi implements ProjectsApi { var endpoint = '/users/$userId/projects?page[number]=$page'; if (filterByTag != null) endpoint += '&filter[tag]=$filterByTag'; if (sortBy != null) endpoint += '&sort=$sortBy'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -97,9 +97,9 @@ class HttpProjectsApi implements ProjectsApi { } on UnauthorizedException { throw Failure(Constants.UNAUTHENTICATED); } on NotFoundException { - throw Failure(Constants.USER_NOT_FOUND); + throw Failure(Constants.userNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @@ -113,7 +113,7 @@ class HttpProjectsApi implements ProjectsApi { var endpoint = '/projects/featured?page[number]=$page&page[size]=$size'; if (filterByTag != null) endpoint += '&filter[tag]=$filterByTag'; if (sortBy != null) endpoint += '&sort=$sortBy'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -125,7 +125,7 @@ class HttpProjectsApi implements ProjectsApi { } on UnauthorizedException { throw Failure(Constants.UNAUTHENTICATED); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @@ -139,7 +139,7 @@ class HttpProjectsApi implements ProjectsApi { var endpoint = '/users/$userId/favourites?page[number]=$page'; if (filterByTag != null) endpoint += '&filter[tag]=$filterByTag'; if (sortBy != null) endpoint += '&sort=$sortBy'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -151,14 +151,14 @@ class HttpProjectsApi implements ProjectsApi { } on UnauthorizedException { throw Failure(Constants.UNAUTHENTICATED); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future getProjectDetails(String id) async { var endpoint = '/projects/$id?include=collaborators'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -172,9 +172,9 @@ class HttpProjectsApi implements ProjectsApi { } on ForbiddenException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.PROJECT_NOT_FOUND); + throw Failure(Constants.projectNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @@ -187,7 +187,7 @@ class HttpProjectsApi implements ProjectsApi { List tagsList, }) async { var endpoint = '/projects/$id'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; var json = { 'name': name, 'project_access_type': projectAccessType, @@ -204,22 +204,22 @@ class HttpProjectsApi implements ProjectsApi { ); return Project.fromJson(jsonResponse['data']); } on BadRequestException { - throw Failure(Constants.INVALID_PARAMETERS); + throw Failure(Constants.invalidPARAMETERS); } on UnauthorizedException { throw Failure(Constants.UNAUTHENTICATED); } on ForbiddenException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.PROJECT_NOT_FOUND); + throw Failure(Constants.projectNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future deleteProject(String projectId) async { var endpoint = '/projects/$projectId'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -233,16 +233,16 @@ class HttpProjectsApi implements ProjectsApi { } on ForbiddenException { throw Failure(Constants.UNAUTHORIZED); } on NotFoundException { - throw Failure(Constants.PROJECT_NOT_FOUND); + throw Failure(Constants.projectNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future toggleStarProject(String projectId) async { var endpoint = '/projects/$projectId/toggle-star'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -254,16 +254,16 @@ class HttpProjectsApi implements ProjectsApi { } on UnauthorizedException { throw Failure(Constants.UNAUTHENTICATED); } on NotFoundException { - throw Failure(Constants.PROJECT_NOT_FOUND); + throw Failure(Constants.projectNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future forkProject(String toBeForkedProjectId) async { var endpoint = '/projects/$toBeForkedProjectId/fork'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); @@ -275,11 +275,11 @@ class HttpProjectsApi implements ProjectsApi { } on UnauthorizedException { throw Failure(Constants.UNAUTHENTICATED); } on NotFoundException { - throw Failure(Constants.PROJECT_NOT_FOUND); + throw Failure(Constants.projectNOTFOUND); } on ConflictException { - throw Failure(Constants.PROJECT_FORK_CONFLICT); + throw Failure(Constants.projectFORKCONFLICT); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } } diff --git a/lib/services/API/users_api.dart b/lib/services/API/users_api.dart index fda38863..5c60b787 100644 --- a/lib/services/API/users_api.dart +++ b/lib/services/API/users_api.dart @@ -34,7 +34,7 @@ class HttpUsersApi implements UsersApi { @override Future login(String email, String password) async { var endpoint = '/auth/login'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; var json = { 'email': email, 'password': password, @@ -48,20 +48,20 @@ class HttpUsersApi implements UsersApi { String token = jsonResponse['token']; return token; } on UnauthorizedException { - throw Failure(Constants.USER_AUTH_WRONG_CREDENTIALS); + throw Failure(Constants.userAUTHWRONGCREDENTIALS); } on NotFoundException { - throw Failure(Constants.USER_AUTH_USER_NOT_FOUND); + throw Failure(Constants.userAUTHUSERNOTFOUND); } on FormatException { - throw Failure(Constants.BAD_RESPONSE_FORMAT); + throw Failure(Constants.badRESPONSEFORMAT); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future signup(String name, String email, String password) async { var endpoint = '/auth/signup'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; var json = { 'name': name, 'email': email, @@ -75,18 +75,18 @@ class HttpUsersApi implements UsersApi { ); return jsonResponse['token']; } on ConflictException { - throw Failure(Constants.USER_AUTH_USER_ALREADY_EXISTS); + throw Failure(Constants.userAUTHUSERALREADYEXISTS); } on FormatException { - throw Failure(Constants.BAD_RESPONSE_FORMAT); + throw Failure(Constants.badRESPONSEFORMAT); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future oauthLogin({String accessToken, String provider}) async { var endpoint = '/oauth/login'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; var json = { 'access_token': accessToken, 'provider': provider, @@ -100,18 +100,18 @@ class HttpUsersApi implements UsersApi { ); return jsonResponse['token']; } on NotFoundException { - throw Failure(Constants.USER_AUTH_USER_NOT_FOUND); + throw Failure(Constants.userAUTHUSERNOTFOUND); } on FormatException { - throw Failure(Constants.BAD_RESPONSE_FORMAT); + throw Failure(Constants.badRESPONSEFORMAT); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future oauthSignup({String accessToken, String provider}) async { var endpoint = '/oauth/signup'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; var json = { 'access_token': accessToken, 'provider': provider, @@ -125,18 +125,18 @@ class HttpUsersApi implements UsersApi { ); return jsonResponse['token']; } on ConflictException { - throw Failure(Constants.USER_AUTH_USER_ALREADY_EXISTS); + throw Failure(Constants.userAUTHUSERALREADYEXISTS); } on FormatException { - throw Failure(Constants.BAD_RESPONSE_FORMAT); + throw Failure(Constants.badRESPONSEFORMAT); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future fetchUser(String userId) async { var endpoint = '/users/$userId'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); var jsonResponse = await ApiUtils.get( @@ -145,18 +145,18 @@ class HttpUsersApi implements UsersApi { ); return User.fromJson(jsonResponse); } on FormatException { - throw Failure(Constants.BAD_RESPONSE_FORMAT); + throw Failure(Constants.badRESPONSEFORMAT); } on NotFoundException { - throw Failure(Constants.USER_NOT_FOUND); + throw Failure(Constants.userNOTFOUND); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future fetchCurrentUser() async { var endpoint = '/me/'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; try { ApiUtils.addTokenToHeaders(headers); var jsonResponse = await ApiUtils.get( @@ -165,9 +165,9 @@ class HttpUsersApi implements UsersApi { ); return User.fromJson(jsonResponse); } on FormatException { - throw Failure(Constants.BAD_RESPONSE_FORMAT); + throw Failure(Constants.badRESPONSEFORMAT); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @@ -175,7 +175,7 @@ class HttpUsersApi implements UsersApi { Future updateProfile(String name, String educationalInstitute, String country, bool isSubscribed) async { var endpoint = '/users/${_storage.currentUser.data.id}'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; var json = { 'name': name, 'educational_institute': educationalInstitute, @@ -191,16 +191,16 @@ class HttpUsersApi implements UsersApi { ); return User.fromJson(jsonResponse); } on FormatException { - throw Failure(Constants.BAD_RESPONSE_FORMAT); + throw Failure(Constants.badRESPONSEFORMAT); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } @override Future sendResetPasswordInstructions(String email) async { var endpoint = '/password/forgot'; - var uri = EnvironmentConfig.CV_API_BASE_URL + endpoint; + var uri = EnvironmentConfig.cvAPIBASEURL + endpoint; var json = {'email': email}; try { var jsonResponse = await ApiUtils.post( @@ -210,11 +210,11 @@ class HttpUsersApi implements UsersApi { ); return jsonResponse['message'] is String; } on NotFoundException { - throw Failure(Constants.USER_NOT_FOUND); + throw Failure(Constants.userNOTFOUND); } on FormatException { - throw Failure(Constants.BAD_RESPONSE_FORMAT); + throw Failure(Constants.badRESPONSEFORMAT); } on Exception { - throw Failure(Constants.GENERIC_FAILURE); + throw Failure(Constants.genericFAILURE); } } } diff --git a/lib/services/database_service.dart b/lib/services/database_service.dart index c644de5e..9f1dca7e 100644 --- a/lib/services/database_service.dart +++ b/lib/services/database_service.dart @@ -3,7 +3,8 @@ import 'package:hive_flutter/hive_flutter.dart'; import 'package:mobile_app/models/ib/ib_raw_page_data.dart'; enum DatabaseBox { - Metadata, + metaData, + // ignore: constant_identifier_names IB, } @@ -52,7 +53,7 @@ class DatabaseServiceImpl implements DatabaseService { @override Future isExpired(String key) async { - var data = await getData(DatabaseBox.Metadata, key); + var data = await getData(DatabaseBox.metaData, key); return data == null || data.isBefore( @@ -75,7 +76,7 @@ class DatabaseServiceImpl implements DatabaseService { var openedBox = await _openBox(box); if (expireData) { - await setData(DatabaseBox.Metadata, key, DateTime.now()); + await setData(DatabaseBox.metaData, key, DateTime.now()); } await openedBox.put(key, value); diff --git a/lib/services/ib_engine_service.dart b/lib/services/ib_engine_service.dart index 72e8acaf..51ec5a62 100644 --- a/lib/services/ib_engine_service.dart +++ b/lib/services/ib_engine_service.dart @@ -37,8 +37,7 @@ class IbEngineServiceImpl implements IbEngineService { List _ibChapters = []; /// module.js URL for interaction - final _intModuleJsUrl = - '${EnvironmentConfig.IB_BASE_URL}/assets/js/module.js'; + final _intModuleJsUrl = '${EnvironmentConfig.ibBASEURL}/assets/js/module.js'; /// Base path for interactions final _intBaseUrl = @@ -281,7 +280,7 @@ class IbEngineServiceImpl implements IbEngineService { // Replace local URLs with absolute return result = result.replaceAll( RegExp(r'(\.\.(\/\.\.)?)?(? getInstance() async { _preferences ??= await SharedPreferences.getInstance(); @@ -54,16 +56,16 @@ class LocalStorageService { _saveToDisk(TOKEN, _token); } - bool get isLoggedIn => _getFromDisk(IS_LOGGED_IN) ?? false; + bool get isLoggedIn => _getFromDisk(isLOGGEDIN) ?? false; set isLoggedIn(bool isLoggedIn) { - _saveToDisk(IS_LOGGED_IN, isLoggedIn); + _saveToDisk(isLOGGEDIN, isLoggedIn); } - bool get isFirstTimeLogin => _getFromDisk(IS_FIRST_TIME_LOGIN) ?? true; + bool get isFirstTimeLogin => _getFromDisk(isFIRSTTIMELOGIN) ?? true; set isFirstTimeLogin(bool isLoggedIn) { - _saveToDisk(IS_FIRST_TIME_LOGIN, isLoggedIn); + _saveToDisk(isFIRSTTIMELOGIN, isLoggedIn); } User get currentUser { @@ -80,23 +82,23 @@ class LocalStorageService { } AuthType get authType { - var _authType = _getFromDisk(AUTH_TYPE); + var _authType = _getFromDisk(authTYPE); return authTypeValues.map[_authType]; } set authType(AuthType authType) { - _saveToDisk(AUTH_TYPE, authTypeValues.reverse[authType]); + _saveToDisk(authTYPE, authTypeValues.reverse[authType]); } Map get getShowcaseState { final Map result = Map.castFrom( - json.decode(_getFromDisk(IB_SHOWCASE_STATE) ?? '{}') + json.decode(_getFromDisk(ibSHOWCASESTATE) ?? '{}') as Map); return result; } set setShowcaseState(String state) { - _saveToDisk(IB_SHOWCASE_STATE, state); + _saveToDisk(ibSHOWCASESTATE, state); } } diff --git a/lib/ui/components/cv_typeahead_field.dart b/lib/ui/components/cv_typeahead_field.dart index 2cf2cc44..a2126be1 100644 --- a/lib/ui/components/cv_typeahead_field.dart +++ b/lib/ui/components/cv_typeahead_field.dart @@ -41,8 +41,9 @@ class CVTypeAheadField extends StatelessWidget { final CountryInstituteAPI countryInstituteObject; final String toggle; + // ignore: constant_identifier_names static const String COUNTRY = 'country'; - static const String EDUCATIONAL_INSTITUTE = 'educational institute'; + static const String educationalINSTITUTE = 'educational institute'; @override Widget build(BuildContext context) { @@ -81,7 +82,7 @@ class CVTypeAheadField extends StatelessWidget { pattern, ); } - if (toggle == EDUCATIONAL_INSTITUTE) { + if (toggle == educationalINSTITUTE) { return await countryInstituteObject.getInstitutes( pattern, ); diff --git a/lib/ui/views/about/about_view.dart b/lib/ui/views/about/about_view.dart index dfc0d3c8..5807e49a 100644 --- a/lib/ui/views/about/about_view.dart +++ b/lib/ui/views/about/about_view.dart @@ -54,7 +54,7 @@ class _AboutViewState extends State { case ViewState.Success: var _contributorsAvatars = []; for (var contributor in _model.cvContributors) { - if (contributor.type == Type.USER) { + if (contributor.type == Type.user) { _contributorsAvatars.add( ContributorAvatar(contributor: contributor), ); diff --git a/lib/ui/views/groups/assignment_details_view.dart b/lib/ui/views/groups/assignment_details_view.dart index 997d8991..0d654215 100644 --- a/lib/ui/views/groups/assignment_details_view.dart +++ b/lib/ui/views/groups/assignment_details_view.dart @@ -235,8 +235,8 @@ class _AssignmentDetailsViewState extends State { child: FadeInImage.memoryNetwork( fit: BoxFit.cover, placeholder: kTransparentImage, - image: EnvironmentConfig.CV_API_BASE_URL.substring( - 0, EnvironmentConfig.CV_API_BASE_URL.length - 7) + + image: EnvironmentConfig.cvAPIBASEURL.substring( + 0, EnvironmentConfig.cvAPIBASEURL.length - 7) + _model.focussedProject.attributes.imagePreview.url, ), ), diff --git a/lib/ui/views/ib/ib_page_view.dart b/lib/ui/views/ib/ib_page_view.dart index a92b15ac..9100a1e2 100644 --- a/lib/ui/views/ib/ib_page_view.dart +++ b/lib/ui/views/ib/ib_page_view.dart @@ -111,7 +111,7 @@ class _IbPageViewState extends State { Future _onTapLink(String text, String href, String title) async { // If Absolute Interactive Book link - if (href.startsWith(EnvironmentConfig.IB_BASE_URL)) { + if (href.startsWith(EnvironmentConfig.ibBASEURL)) { // If URI is same as the current page if (_model.pageData.pageUrl.startsWith(href)) { // It's local link @@ -142,7 +142,7 @@ class _IbPageViewState extends State { var url = uri.toString(); if (uri.toString().startsWith('/assets')) { - url = EnvironmentConfig.IB_BASE_URL + url; + url = EnvironmentConfig.ibBASEURL + url; } widgets.add(SvgPicture.network(url)); @@ -178,7 +178,7 @@ class _IbPageViewState extends State { return MarkdownBody( data: data.content, selectable: _selectable, - imageDirectory: EnvironmentConfig.IB_BASE_URL, + imageDirectory: EnvironmentConfig.ibBASEURL, imageBuilder: _buildMarkdownImage, onTapLink: _onTapLink, blockBuilders: { diff --git a/lib/ui/views/ib/syntaxes/ib_liquid_syntax.dart b/lib/ui/views/ib/syntaxes/ib_liquid_syntax.dart index 90ae68e6..693b298d 100644 --- a/lib/ui/views/ib/syntaxes/ib_liquid_syntax.dart +++ b/lib/ui/views/ib/syntaxes/ib_liquid_syntax.dart @@ -23,7 +23,7 @@ class IbLiquidSyntax extends md.BlockSyntax { .firstMatch(match[1])[2]; node = md.Element.withTag('img'); - node.attributes['src'] = '${EnvironmentConfig.IB_BASE_URL}$url'; + node.attributes['src'] = '${EnvironmentConfig.ibBASEURL}$url'; node.attributes['alt'] = alt; } else { // Interactions using html diff --git a/lib/ui/views/profile/edit_profile_view.dart b/lib/ui/views/profile/edit_profile_view.dart index 0a6b35a1..382f3e3b 100644 --- a/lib/ui/views/profile/edit_profile_view.dart +++ b/lib/ui/views/profile/edit_profile_view.dart @@ -81,7 +81,7 @@ class _EditProfileViewState extends State { controller: TextEditingController(text: _educationalInstitute), onSaved: (value) => _educationalInstitute = (value != '') ? value.trim() : '', - toggle: CVTypeAheadField.EDUCATIONAL_INSTITUTE, + toggle: CVTypeAheadField.educationalINSTITUTE, action: TextInputAction.done, countryInstituteObject: locator(), ); diff --git a/lib/ui/views/projects/components/featured_project_card.dart b/lib/ui/views/projects/components/featured_project_card.dart index 1efae7eb..c954fcd0 100644 --- a/lib/ui/views/projects/components/featured_project_card.dart +++ b/lib/ui/views/projects/components/featured_project_card.dart @@ -37,8 +37,8 @@ class _FeaturedProjectCardState extends State { child: FadeInImage.memoryNetwork( fit: BoxFit.cover, placeholder: kTransparentImage, - image: EnvironmentConfig.CV_API_BASE_URL.substring( - 0, EnvironmentConfig.CV_API_BASE_URL.length - 7) + + image: EnvironmentConfig.cvAPIBASEURL + .substring(0, EnvironmentConfig.cvAPIBASEURL.length - 7) + widget.project.attributes.imagePreview.url, ), ), diff --git a/lib/ui/views/projects/components/project_card.dart b/lib/ui/views/projects/components/project_card.dart index d99685b3..ee1a4cce 100644 --- a/lib/ui/views/projects/components/project_card.dart +++ b/lib/ui/views/projects/components/project_card.dart @@ -90,8 +90,8 @@ class _ProjectCardState extends State { child: FadeInImage.memoryNetwork( fit: BoxFit.cover, placeholder: kTransparentImage, - image: EnvironmentConfig.CV_API_BASE_URL.substring( - 0, EnvironmentConfig.CV_API_BASE_URL.length - 7) + + image: EnvironmentConfig.cvAPIBASEURL + .substring(0, EnvironmentConfig.cvAPIBASEURL.length - 7) + widget.project.attributes.imagePreview.url, ), ), diff --git a/lib/ui/views/projects/project_details_view.dart b/lib/ui/views/projects/project_details_view.dart index 97b51bcb..4b0480af 100644 --- a/lib/ui/views/projects/project_details_view.dart +++ b/lib/ui/views/projects/project_details_view.dart @@ -87,8 +87,8 @@ class _ProjectDetailsViewState extends State { height: 100, width: 50, placeholder: kTransparentImage, - image: EnvironmentConfig.CV_API_BASE_URL.substring( - 0, EnvironmentConfig.CV_API_BASE_URL.length - 7) + + image: EnvironmentConfig.cvAPIBASEURL.substring( + 0, EnvironmentConfig.cvAPIBASEURL.length - 7) + _recievedProject.attributes.imagePreview.url, ), ), diff --git a/lib/ui/views/projects/project_preview_fullscreen_view.dart b/lib/ui/views/projects/project_preview_fullscreen_view.dart index 9d89ec2a..771c18d3 100644 --- a/lib/ui/views/projects/project_preview_fullscreen_view.dart +++ b/lib/ui/views/projects/project_preview_fullscreen_view.dart @@ -26,8 +26,8 @@ class ProjectPreviewFullScreen extends StatelessWidget { height: 100, width: 50, placeholder: kTransparentImage, - image: EnvironmentConfig.CV_API_BASE_URL.substring( - 0, EnvironmentConfig.CV_API_BASE_URL.length - 7) + + image: EnvironmentConfig.cvAPIBASEURL + .substring(0, EnvironmentConfig.cvAPIBASEURL.length - 7) + project.attributes.imagePreview.url, ), ), diff --git a/lib/utils/api_utils.dart b/lib/utils/api_utils.dart index 221804b3..02c4ca2e 100644 --- a/lib/utils/api_utils.dart +++ b/lib/utils/api_utils.dart @@ -27,9 +27,9 @@ class ApiUtils { return ApiUtils.jsonResponse(response, utfDecoder: utfDecoder); } on SocketException { - throw Failure(Constants.NO_INTERNET_CONNECTION); + throw Failure(Constants.noINTERNETCONNECTION); } on HttpException { - throw Failure(Constants.HTTP_EXCEPTION); + throw Failure(Constants.httpEXCEPTION); } } @@ -41,9 +41,9 @@ class ApiUtils { headers: headers, body: jsonEncode(body)); return ApiUtils.jsonResponse(response); } on SocketException { - throw Failure(Constants.NO_INTERNET_CONNECTION); + throw Failure(Constants.noINTERNETCONNECTION); } on HttpException { - throw Failure(Constants.HTTP_EXCEPTION); + throw Failure(Constants.httpEXCEPTION); } } @@ -58,9 +58,9 @@ class ApiUtils { ); return ApiUtils.jsonResponse(response); } on SocketException { - throw Failure(Constants.NO_INTERNET_CONNECTION); + throw Failure(Constants.noINTERNETCONNECTION); } on HttpException { - throw Failure(Constants.HTTP_EXCEPTION); + throw Failure(Constants.httpEXCEPTION); } } @@ -75,9 +75,9 @@ class ApiUtils { ); return ApiUtils.jsonResponse(response); } on SocketException { - throw Failure(Constants.NO_INTERNET_CONNECTION); + throw Failure(Constants.noINTERNETCONNECTION); } on HttpException { - throw Failure(Constants.HTTP_EXCEPTION); + throw Failure(Constants.httpEXCEPTION); } } @@ -91,9 +91,9 @@ class ApiUtils { ); return ApiUtils.jsonResponse(response); } on SocketException { - throw Failure(Constants.NO_INTERNET_CONNECTION); + throw Failure(Constants.noINTERNETCONNECTION); } on HttpException { - throw Failure(Constants.HTTP_EXCEPTION); + throw Failure(Constants.httpEXCEPTION); } } diff --git a/lib/viewmodels/authentication/auth_options_viewmodel.dart b/lib/viewmodels/authentication/auth_options_viewmodel.dart index 8ba3f476..ac9c187f 100644 --- a/lib/viewmodels/authentication/auth_options_viewmodel.dart +++ b/lib/viewmodels/authentication/auth_options_viewmodel.dart @@ -48,7 +48,7 @@ class AuthOptionsViewModel extends BaseModel { _storage.isLoggedIn = true; // save authentication type to local storage.. - _storage.authType = AuthType.FACEBOOK; + _storage.authType = AuthType.facebook; setStateFor(FB_OAUTH, ViewState.Success); } on Failure catch (f) { @@ -98,7 +98,7 @@ class AuthOptionsViewModel extends BaseModel { _storage.isLoggedIn = true; // save authentication type to local storage.. - _storage.authType = AuthType.GOOGLE; + _storage.authType = AuthType.google; setStateFor(GOOGLE_OAUTH, ViewState.Success); } on Failure catch (f) { @@ -112,14 +112,14 @@ class AuthOptionsViewModel extends BaseModel { Future githubAuth({bool isSignUp = false}) async { OAuth2Client _client = GitHubOAuth2Client( - redirectUri: EnvironmentConfig.GITHUB_OAUTH_REDIRECT_URI, + redirectUri: EnvironmentConfig.githubOAUTHREDIRECTURI, customUriScheme: 'circuitverse', ); var _oauthHelper = OAuth2Helper( _client, - clientId: EnvironmentConfig.GITHUB_OAUTH_CLIENT_ID, - clientSecret: EnvironmentConfig.GITHUB_OAUTH_CLIENT_SECRET, + clientId: EnvironmentConfig.githubOAUTHCLIENTID, + clientSecret: EnvironmentConfig.githubOAUTHCLIENTSECRET, scopes: ['read:user'], ); @@ -147,7 +147,7 @@ class AuthOptionsViewModel extends BaseModel { _storage.isLoggedIn = true; // save authentication type to local storage.. - _storage.authType = AuthType.GITHUB; + _storage.authType = AuthType.github; setStateFor(GITHUB_OAUTH, ViewState.Success); } on Failure catch (f) { diff --git a/lib/viewmodels/cv_landing_viewmodel.dart b/lib/viewmodels/cv_landing_viewmodel.dart index 9b66261e..87f2e3f3 100644 --- a/lib/viewmodels/cv_landing_viewmodel.dart +++ b/lib/viewmodels/cv_landing_viewmodel.dart @@ -20,12 +20,12 @@ class CVLandingViewModel extends BaseModel { _storage.token = null; // Perform facebook logout if auth type is facebook.. - if (_storage.authType == AuthType.FACEBOOK) { + if (_storage.authType == AuthType.facebook) { await FacebookAuth.instance.logOut(); } // Perform google signout if auth type is google.. - if (_storage.authType == AuthType.GOOGLE) { + if (_storage.authType == AuthType.google) { await _googleSignIn.signOut(); } diff --git a/test/model_tests/cv_contributors_test.dart b/test/model_tests/cv_contributors_test.dart index 94164cd2..b7330c97 100644 --- a/test/model_tests/cv_contributors_test.dart +++ b/test/model_tests/cv_contributors_test.dart @@ -42,7 +42,7 @@ void main() { 'https://api.github.com/users/test/events{/privacy}'); expect(_contributor.receivedEventsUrl, 'https://api.github.com/users/test/received_events'); - expect(_contributor.type, Type.USER); + expect(_contributor.type, Type.user); expect(_contributor.siteAdmin, false); expect(_contributor.contributions, 114); }); diff --git a/test/service_tests/ib_engine_test.dart b/test/service_tests/ib_engine_test.dart index 24adbcf5..c46da422 100644 --- a/test/service_tests/ib_engine_test.dart +++ b/test/service_tests/ib_engine_test.dart @@ -302,7 +302,7 @@ void main() { '\n$_mockHtml'; _expectedResult = _expectedResult.replaceAll( RegExp(r'(\.\.(\/\.\.)?)?(? Date: Sat, 15 Jan 2022 19:21:20 +0530 Subject: [PATCH 2/3] changed analysis_options --- analysis_options.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 718e36d6..39844e08 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -9,5 +9,4 @@ linter: avoid_classes_with_only_static_members: false non_constant_identifier_names: false - - constant_identifier_names: false + From 0538085aa6c115a323986539626f40c27975297e Mon Sep 17 00:00:00 2001 From: ItsAdityaKSingh Date: Sat, 15 Jan 2022 19:23:34 +0530 Subject: [PATCH 3/3] checked --- analysis_options.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 39844e08..2c38a24a 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -9,4 +9,3 @@ linter: avoid_classes_with_only_static_members: false non_constant_identifier_names: false -