diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 390ee63..922eb2f 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -15,7 +15,9 @@ android:authorities = "${applicationId}.fileprovider" android:exported = "false" android:grantUriPermissions = "true" -android:name = "androidx.core.content.FileProvider"> +android:name = "androidx.core.content.FileProvider" +android:usesCleartextTraffic="true"> + diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index cb24abd..ee64223 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +android.enableDexingArtifactTransform=false distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/assets/fail.mp3 b/assets/fail.mp3 new file mode 100644 index 0000000..6ad9241 Binary files /dev/null and b/assets/fail.mp3 differ diff --git a/assets/invalid.mp3 b/assets/invalid.mp3 new file mode 100644 index 0000000..b7c5d31 Binary files /dev/null and b/assets/invalid.mp3 differ diff --git a/assets/sounds/ScanFailed.mp3 b/assets/sounds/ScanFailed.mp3 new file mode 100644 index 0000000..7309226 Binary files /dev/null and b/assets/sounds/ScanFailed.mp3 differ diff --git a/assets/sounds/Successful.mp3 b/assets/sounds/Successful.mp3 new file mode 100644 index 0000000..5fe691d Binary files /dev/null and b/assets/sounds/Successful.mp3 differ diff --git a/assets/success.mp3 b/assets/success.mp3 new file mode 100644 index 0000000..7b8174a Binary files /dev/null and b/assets/success.mp3 differ diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 0f8d01a..cdf552e 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,4 +1,10 @@ PODS: + - assets_audio_player (0.0.1): + - Flutter + - assets_audio_player_web (0.0.1): + - Flutter + - audioplayers_darwin (0.0.1): + - Flutter - barcode_scan2 (0.0.1): - Flutter - MTBBarcodeScanner @@ -24,20 +30,25 @@ PODS: - path_provider_foundation (0.0.1): - Flutter - FlutterMacOS - - permission_handler_apple (9.0.4): + - permission_handler_apple (9.1.0): - Flutter - platform_device_id (0.0.1): - Flutter + - rive_common (0.0.1): + - Flutter - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS - - sqflite (0.0.2): + - sqflite (0.0.3): - Flutter - FMDB (>= 2.7.5) - SwiftProtobuf (1.20.3) - Toast (4.0.0) DEPENDENCIES: + - assets_audio_player (from `.symlinks/plugins/assets_audio_player/ios`) + - assets_audio_player_web (from `.symlinks/plugins/assets_audio_player_web/ios`) + - audioplayers_darwin (from `.symlinks/plugins/audioplayers_darwin/ios`) - barcode_scan2 (from `.symlinks/plugins/barcode_scan2/ios`) - device_info (from `.symlinks/plugins/device_info/ios`) - easy_app_installer (from `.symlinks/plugins/easy_app_installer/ios`) @@ -49,6 +60,7 @@ DEPENDENCIES: - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - platform_device_id (from `.symlinks/plugins/platform_device_id/ios`) + - rive_common (from `.symlinks/plugins/rive_common/ios`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`) - sqflite (from `.symlinks/plugins/sqflite/ios`) @@ -60,6 +72,12 @@ SPEC REPOS: - Toast EXTERNAL SOURCES: + assets_audio_player: + :path: ".symlinks/plugins/assets_audio_player/ios" + assets_audio_player_web: + :path: ".symlinks/plugins/assets_audio_player_web/ios" + audioplayers_darwin: + :path: ".symlinks/plugins/audioplayers_darwin/ios" barcode_scan2: :path: ".symlinks/plugins/barcode_scan2/ios" device_info: @@ -82,27 +100,33 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/permission_handler_apple/ios" platform_device_id: :path: ".symlinks/plugins/platform_device_id/ios" + rive_common: + :path: ".symlinks/plugins/rive_common/ios" shared_preferences_foundation: :path: ".symlinks/plugins/shared_preferences_foundation/ios" sqflite: :path: ".symlinks/plugins/sqflite/ios" SPEC CHECKSUMS: + assets_audio_player: edee322b9cb625571b830b35872ead1a295fd917 + assets_audio_player_web: 19826380c44375761aa0b9053665c1e3fbc3b86b + audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40 barcode_scan2: 0af2bb63c81b4565aab6cd78278e4c0fa136dbb0 device_info: d7d233b645a32c40dfdc212de5cf646ca482f175 easy_app_installer: 29abe397da7d86721fee853281202f414373f45c Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 - fluttertoast: eb263d302cc92e04176c053d2385237e9f43fad0 + fluttertoast: fafc4fa4d01a6a9e4f772ecd190ffa525e9e2d9c FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a location: 3a2eed4dd2fab25e7b7baf2a9efefe82b512d740 modal_progress_hud_nsn: f6fb744cd060653d66ed8f325360ef3650eb2fde MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e - path_provider_foundation: c68054786f1b4f3343858c1e1d0caaded73f0be9 - permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce + path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8 + permission_handler_apple: 8f116445eff3c0e7c65ad60f5fef5490aa94b4e4 platform_device_id: 81b3e2993881f87d0c82ef151dc274df4869aef5 - shared_preferences_foundation: 986fc17f3d3251412d18b0265f9c64113a8c2472 - sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 + rive_common: 60ae7896ab40f9513974f36f015de33f70d2c5c5 + shared_preferences_foundation: e2dae3258e06f44cc55f49d42024fd8dd03c590c + sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a SwiftProtobuf: b02b5075dcf60c9f5f403000b3b0c202a11b6ae1 Toast: 91b396c56ee72a5790816f40d3a94dd357abc196 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index db5f9c0..1372ea9 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -323,6 +323,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -341,7 +342,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -362,7 +363,7 @@ DEVELOPMENT_TEAM = 2WLSMMLG6W; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -404,6 +405,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -428,7 +430,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -459,6 +461,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -477,7 +480,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -500,7 +503,7 @@ DEVELOPMENT_TEAM = 2WLSMMLG6W; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -532,7 +535,7 @@ DEVELOPMENT_TEAM = 2WLSMMLG6W; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 06ce33a..67bed1a 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -2,6 +2,8 @@ +NSCameraUsageDescription + Camera permission is required for barcode scanning. CADisableMinimumFrameDurationOnPhone CFBundleDevelopmentRegion diff --git a/lib/bloc/profile/family/family_bloc.dart b/lib/bloc/profile/family/family_bloc.dart index f948ab6..96b13f8 100644 --- a/lib/bloc/profile/family/family_bloc.dart +++ b/lib/bloc/profile/family/family_bloc.dart @@ -120,5 +120,8 @@ class FamilyBloc extends Bloc { emit(FamilyErrorState(message: e.toString())); } }); + on((event,emit){ + emit(FamilyErrorState(message: state.toString())); + }); } } diff --git a/lib/bloc/profile/family/family_event.dart b/lib/bloc/profile/family/family_event.dart index ba6ff31..a9fb8c5 100644 --- a/lib/bloc/profile/family/family_event.dart +++ b/lib/bloc/profile/family/family_event.dart @@ -64,3 +64,8 @@ class AddEmergencyEvent extends FamilyEvent{ @override List get props => [profileId,token,relatedPersonId]; } + +class CallErrorState extends FamilyEvent{ + final String message; + const CallErrorState({required this.message}); +} diff --git a/lib/bloc/profile/learningDevelopment/learning_development_bloc.dart b/lib/bloc/profile/learningDevelopment/learning_development_bloc.dart index 1857b85..6ef27c0 100644 --- a/lib/bloc/profile/learningDevelopment/learning_development_bloc.dart +++ b/lib/bloc/profile/learningDevelopment/learning_development_bloc.dart @@ -1,14 +1,8 @@ import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; -import 'package:flutter/material.dart'; import 'package:unit2/model/location/country.dart'; import 'package:unit2/model/location/region.dart'; -import 'package:unit2/screens/profile/components/other_information/org_membership/add_modal.dart'; -import 'package:unit2/screens/unit2/login/components/update_required.dart'; import 'package:unit2/sevices/profile/learningDevelopment_service.dart'; -import 'package:unit2/test_data.dart'; -import 'package:unit2/utils/text_container.dart'; - import '../../../model/location/barangay.dart'; import '../../../model/location/city.dart'; import '../../../model/location/provinces.dart'; @@ -17,7 +11,6 @@ import '../../../model/utils/agency.dart'; import '../../../model/utils/category.dart'; import '../../../utils/location_utilities.dart'; import '../../../utils/profile_utilities.dart'; - part 'learning_development_event.dart'; part 'learning_development_state.dart'; @@ -40,17 +33,16 @@ class LearningDevelopmentBloc Province? currentProvince; CityMunicipality? currentCity; Barangay? currentBarangay; - - on((event, emit) async { - emit(LearningDevelopmentLoadingState()); - try { - List learnings = await LearningDevelopmentServices - .instance - .getLearningDevelopments(event.profileId, event.token); - learningsAndDevelopments = learnings; - emit(LearningDevelopmentLoadedState( - learningsAndDevelopment: learningsAndDevelopments)); + on((event, emit) async { + emit(LearningDevelopmentLoadingState()); + try { + List learnings = await LearningDevelopmentServices + .instance + .getLearningDevelopments(event.profileId, event.token); + learningsAndDevelopments = learnings; + emit(LearningDevelopmentLoadedState( + learningsAndDevelopment: learningsAndDevelopments)); } catch (e) { emit(LearningDevelopmentErrorState(message: e.toString())); } @@ -93,7 +85,6 @@ class LearningDevelopmentBloc await ProfileUtilities.instance.agencyCategory(); agencyCategory = categoryAgencies; } - emit(LearningDevelopmentAddingState( types: types, topics: topics, @@ -103,102 +94,103 @@ class LearningDevelopmentBloc sponsorAgencies: agencies, agencyCategory: agencyCategory)); } catch (e) { - emit(LeaningDevelopmentErrorState(message: e.toString())); + emit(LearningDevelopmentErrorState(message: e.toString())); } }); ////Show edit form on((event, emit) async { - try{ - if (globalRegions.isEmpty) { - List regions = await LocationUtils.instance.getRegions(); - globalRegions = regions; - } - if (globalCountries.isEmpty) { - List countries = await LocationUtils.instance.getCountries(); - globalCountries = countries; - } - currentCountry = globalCountries.firstWhere((Country country) => - event.learningDevelopment.conductedTraining!.venue!.country!.code == - country.code); - if (!event.isOverseas) { - //// if not overseas - currentRegion = globalRegions.firstWhere((Region region) => - event.learningDevelopment.conductedTraining!.venue! - .cityMunicipality!.province!.region!.code == - region.code); - - globalProvinces = await LocationUtils.instance - .getProvinces(regionCode: currentRegion!.code.toString()); - currentProvince = globalProvinces.firstWhere((Province province) => - event.learningDevelopment.conductedTraining!.venue! - .cityMunicipality!.province!.code == - province.code); - - globalCities = await LocationUtils.instance - .getCities(code: currentProvince!.code.toString()); - - currentCity = globalCities.firstWhere( - (CityMunicipality cityMunicipality) => - event.learningDevelopment.conductedTraining!.venue! - .cityMunicipality!.code == - cityMunicipality.code); - globalBarangay = await LocationUtils.instance - .getBarangay(code: currentCity!.code.toString()); - - if (event.learningDevelopment.conductedTraining?.venue?.barangay?.cityMunicipality != - null) { - currentBarangay = globalBarangay.firstWhere((Barangay barangay) => - event.learningDevelopment.conductedTraining!.venue!.barangay! - .code == - barangay.code); - } else { - currentBarangay = null; + try { + if (globalRegions.isEmpty) { + List regions = await LocationUtils.instance.getRegions(); + globalRegions = regions; } - } - if (topics.isEmpty) { - List newTopics = - await LearningDevelopmentServices.instance.getTrainingTopics(); - topics = newTopics; - } - if (types.isEmpty) { - List newTypes = - await LearningDevelopmentServices.instance - .getLearningDevelopmentType(); - types = newTypes; - } - if (agencies.isEmpty) { - List newAgencies = await ProfileUtilities.instance.getAgecies(); - agencies = newAgencies; - } - if (agencyCategory.isEmpty) { - List categoryAgencies = - await ProfileUtilities.instance.agencyCategory(); - agencyCategory = categoryAgencies; - } - emit(LearningDevelopmentUpdatingState( - cities: globalCities, - currentBarangay: currentBarangay, - barangay: globalBarangay, + if (globalCountries.isEmpty) { + List countries = await LocationUtils.instance.getCountries(); + globalCountries = countries; + } + currentCountry = globalCountries.firstWhere((Country country) => + event.learningDevelopment.conductedTraining!.venue!.country!.code == + country.code); + if (!event.isOverseas) { + //// if not overseas + currentRegion = globalRegions.firstWhere((Region region) => + event.learningDevelopment.conductedTraining!.venue! + .cityMunicipality!.province!.region!.code == + region.code); - provinces: globalProvinces, - types: types, - topics: topics, - training: event.learningDevelopment.conductedTraining!.title!, - learningDevelopement: event.learningDevelopment, - currentConductedBy: - event.learningDevelopment.conductedTraining!.conductedBy!, - currentSponsor: event.learningDevelopment.sponsoredBy, - conductedBy: agencies, - sponsorAgencies: agencies, - agencyCategory: agencyCategory, - countries: globalCountries, - regions: globalRegions, - currentRegion: currentRegion, - currentCountry: currentCountry!, - currentProvince: currentProvince, - currentCity: currentCity, - overseas: event.isOverseas)); - }catch(e){ + globalProvinces = await LocationUtils.instance + .getProvinces(regionCode: currentRegion!.code.toString()); + currentProvince = globalProvinces.firstWhere((Province province) => + event.learningDevelopment.conductedTraining!.venue! + .cityMunicipality!.province!.code == + province.code); + + globalCities = await LocationUtils.instance + .getCities(code: currentProvince!.code.toString()); + + currentCity = globalCities.firstWhere( + (CityMunicipality cityMunicipality) => + event.learningDevelopment.conductedTraining!.venue! + .cityMunicipality!.code == + cityMunicipality.code); + globalBarangay = await LocationUtils.instance + .getBarangay(code: currentCity!.code.toString()); + + if (event.learningDevelopment.conductedTraining?.venue?.barangay + ?.cityMunicipality != + null) { + currentBarangay = globalBarangay.firstWhere((Barangay barangay) => + event.learningDevelopment.conductedTraining!.venue!.barangay! + .code == + barangay.code); + } else { + currentBarangay = null; + } + } + if (topics.isEmpty) { + List newTopics = + await LearningDevelopmentServices.instance.getTrainingTopics(); + topics = newTopics; + } + if (types.isEmpty) { + List newTypes = + await LearningDevelopmentServices.instance + .getLearningDevelopmentType(); + types = newTypes; + } + if (agencies.isEmpty) { + List newAgencies = + await ProfileUtilities.instance.getAgecies(); + agencies = newAgencies; + } + if (agencyCategory.isEmpty) { + List categoryAgencies = + await ProfileUtilities.instance.agencyCategory(); + agencyCategory = categoryAgencies; + } + emit(LearningDevelopmentUpdatingState( + cities: globalCities, + currentBarangay: currentBarangay, + barangay: globalBarangay, + provinces: globalProvinces, + types: types, + topics: topics, + training: event.learningDevelopment.conductedTraining!.title!, + learningDevelopement: event.learningDevelopment, + currentConductedBy: + event.learningDevelopment.conductedTraining!.conductedBy!, + currentSponsor: event.learningDevelopment.sponsoredBy, + conductedBy: agencies, + sponsorAgencies: agencies, + agencyCategory: agencyCategory, + countries: globalCountries, + regions: globalRegions, + currentRegion: currentRegion, + currentCountry: currentCountry!, + currentProvince: currentProvince, + currentCity: currentCity, + overseas: event.isOverseas)); + } catch (e) { emit(LearningDevelopmentErrorState(message: e.toString())); } }); @@ -223,7 +215,7 @@ class LearningDevelopmentBloc emit(LearningDevelopmentErrorState(message: e.toString())); } }); - + ////Update on((event, emit) async { try { @@ -233,9 +225,11 @@ class LearningDevelopmentBloc token: event.token, profileId: event.profileId); if (status['success']) { - learningsAndDevelopments.removeWhere((LearningDevelopement element) => - element.conductedTraining!.id == event.learningDevelopement.conductedTraining!.id && - element.conductedTraining!.totalHours == event.learningDevelopement.conductedTraining!.totalHours); + learningsAndDevelopments.removeWhere((LearningDevelopement element) => + element.conductedTraining!.id == + event.learningDevelopement.conductedTraining!.id && + element.conductedTraining!.totalHours == + event.learningDevelopement.conductedTraining!.totalHours); LearningDevelopement learningDevelopement = LearningDevelopement.fromJson(status['data']); learningsAndDevelopments.add(learningDevelopement); @@ -270,7 +264,7 @@ class LearningDevelopmentBloc }); //// call errror on((event, emit) { - emit(LeaningDevelopmentErrorState(message: event.message)); + emit(LearningDevelopmentErrorState(message: event.message)); }); } } diff --git a/lib/bloc/profile/learningDevelopment/learning_development_state.dart b/lib/bloc/profile/learningDevelopment/learning_development_state.dart index bf0276b..e498dc9 100644 --- a/lib/bloc/profile/learningDevelopment/learning_development_state.dart +++ b/lib/bloc/profile/learningDevelopment/learning_development_state.dart @@ -16,13 +16,6 @@ class LearningDevelopmentLoadedState extends LearningDevelopmentState { List get props => [learningsAndDevelopment]; } -class LeaningDevelopmentErrorState extends LearningDevelopmentState { - final String message; - const LeaningDevelopmentErrorState({required this.message}); - @override - List get props => [message]; -} - class LearningDevelopmentLoadingState extends LearningDevelopmentState {} ////added State diff --git a/lib/bloc/profile/primary_information/contact/contact_bloc.dart b/lib/bloc/profile/primary_information/contact/contact_bloc.dart index 5753c70..e2e1ba2 100644 --- a/lib/bloc/profile/primary_information/contact/contact_bloc.dart +++ b/lib/bloc/profile/primary_information/contact/contact_bloc.dart @@ -107,11 +107,11 @@ class ContactBloc extends Bloc { ContactInfo contactInfo = ContactInfo.fromJson(responseStatus['data']['contact_info']); contactInformations.add(contactInfo); - emit(ContactEditedState( + emit(ContactAddedState( response: responseStatus)); } else { - emit(ContactEditedState( + emit(ContactAddedState( response: responseStatus)); } diff --git a/lib/bloc/profile/voluntary_works/voluntary_work_bloc.dart b/lib/bloc/profile/voluntary_works/voluntary_work_bloc.dart index b9e68e3..9d519eb 100644 --- a/lib/bloc/profile/voluntary_works/voluntary_work_bloc.dart +++ b/lib/bloc/profile/voluntary_works/voluntary_work_bloc.dart @@ -1,6 +1,5 @@ import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; -import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:unit2/sevices/profile/volunatary_services.dart'; import 'package:unit2/utils/profile_utilities.dart'; diff --git a/lib/bloc/role/pass_check/pass_check_bloc.dart b/lib/bloc/role/pass_check/pass_check_bloc.dart new file mode 100644 index 0000000..c1d157a --- /dev/null +++ b/lib/bloc/role/pass_check/pass_check_bloc.dart @@ -0,0 +1,180 @@ + +import 'package:barcode_scan2/model/scan_result.dart'; +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:unit2/model/roles/pass_check/passer_info.dart'; +import 'package:unit2/sevices/roles/pass_check_services.dart'; +import '../../../utils/scanner.dart'; +part 'pass_check_event.dart'; +part 'pass_check_state.dart'; + +class PassCheckBloc extends Bloc { + PassCheckBloc() : super(PassCheckInitial()) { + int? roleId; + String? uuid; + bool? otherInputs; + String? io; + dynamic assignedArea; + int? checkerId; + String? token; + int? stationId; + String? cpId; + on((event, emit) async { + try { + emit(PassCheckLoadingState()); + List response = await PassCheckServices.instance + .getPassCheckArea(roleId: event.roleId, userId: event.userId); + roleId = event.roleId; + emit(AssignAreaLoaded(assignedArea: response, roleId: roleId!)); + } catch (e) { + emit(PassCheckErrorState(message: e.toString())); + } + }); + on((event, emit) { + otherInputs = event.includeOtherInputs; + checkerId = event.checkerId; + io = event.entranceExit; + token = event.token; + roleId = event.roleId; + assignedArea = event.assignedArea; + emit(SettingSaved( + assignedArea: assignedArea, + checker: checkerId!, + io: io!, + otherInputs: otherInputs!, + roleId: roleId!, + token: token!)); + }); + on((event, emit) { + emit(SettingSaved( + assignedArea: assignedArea, + checker: checkerId!, + io: io!, + otherInputs: otherInputs!, + roleId: roleId!, + token: token!)); + }); + on((event, emit) { + add(PerformPostLogs( + checkerId: checkerId!, + cpId: cpId, + destination: null, + io: io!.toLowerCase() == "incoming" ? "i" : "o", + otherInputs: otherInputs!, + passerId: uuid!, + roleId: roleId!, + stationId: stationId, + temp: event.temp)); + }); + + on((event, emit) { + add(PerformPostLogs( + checkerId: checkerId!, + cpId: cpId, + destination: event.destination, + io: io!.toLowerCase() == "incoming" ? "i" : "o", + otherInputs: otherInputs!, + passerId: uuid!, + roleId: roleId!, + stationId: stationId, + temp: null)); + }); + on((event, emit) async { + ScanResult result = await QRCodeBarCodeScanner.instance.scanner(); + if (result.rawContent.toString().isNotEmpty) { + uuid = result.rawContent.toString(); + emit(PassCheckLoadingState()); + try { + PasserInfo? passerInfo = await PassCheckServices.instance + .getPasserInfo(uuid: uuid!, token: event.token); + if (roleId == 41 || roleId == 13 || roleId == 17 || roleId == 22) { + stationId = assignedArea.id; + } else if (roleId == 7) { + cpId = assignedArea.brgycode; + } else if (roleId == 10) { + cpId = assignedArea.purokdesc; + } else if (roleId == 16) { + cpId = assignedArea.id; + } + if (passerInfo == null) { + Fluttertoast.showToast( + msg: "QR CODE IS INVALID", + fontSize: 24, + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.CENTER, + backgroundColor: Colors.black, + textColor: Colors.white); + emit(QRInvalid(token: token!)); + } else { + if (otherInputs!) { + if (io?.toLowerCase() == 'incoming') { + emit(IncomingScanState()); + } else { + emit(OutGoingScanState()); + } + } else { + add(PerformPostLogs( + checkerId: checkerId!, + cpId: cpId, + destination: null, + io: io!.toLowerCase() == "incoming" ? "i" : "o", + otherInputs: otherInputs!, + passerId: uuid!, + roleId: roleId!, + stationId: stationId, + temp: null)); + } + } + } catch (e) { + emit(PassCheckErrorState(message: e.toString())); + } + } else { + emit(SettingSaved( + assignedArea: assignedArea, + checker: checkerId!, + io: io!, + otherInputs: otherInputs!, + roleId: roleId!, + token: token!)); + } + }); + on((event, emit) async { + emit(PassCheckLoadingState()); + try { + final bool success = await PassCheckServices.instance.performPostLogs( + passerId: event.passerId, + chekerId: event.checkerId, + temp: event.temp, + destination: event.destination, + io: event.io, + stationId: event.stationId, + cpId: event.cpId, + otherInputs: event.otherInputs, + roleid: event.roleId); + if (success) { + Fluttertoast.showToast( + msg: "SUCCESSFULLY SAVED", + fontSize: 24, + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.CENTER, + backgroundColor: Colors.black, + textColor: Colors.white); + emit(ScanSuccess(token: token!)); + } else { + Fluttertoast.showToast( + msg: "SCAN FAILED", + fontSize: 24, + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.CENTER, + backgroundColor: Colors.black, + textColor: Colors.white); + emit(ScanFailed(token: token!)); + } + } catch (e) { + emit(PassCheckErrorState(message: e.toString())); + } + }); + } +} diff --git a/lib/bloc/role/pass_check/pass_check_event.dart b/lib/bloc/role/pass_check/pass_check_event.dart new file mode 100644 index 0000000..0cfe95b --- /dev/null +++ b/lib/bloc/role/pass_check/pass_check_event.dart @@ -0,0 +1,70 @@ +part of 'pass_check_bloc.dart'; + +abstract class PassCheckEvent extends Equatable { + const PassCheckEvent(); + + @override + List get props => []; +} + +class GetPassCheckAreas extends PassCheckEvent { + final int roleId; + final int userId; + const GetPassCheckAreas({required this.roleId, required this.userId}); +} + +class SetScannerSettings extends PassCheckEvent { + final int roleId; + final String token; + final dynamic assignedArea; + final bool includeOtherInputs; + final String entranceExit; + final int checkerId; + const SetScannerSettings( + {required this.assignedArea, + required this.checkerId, + required this.entranceExit, + required this.includeOtherInputs, + required this.roleId, + required this.token}); +} + +class ScanQr extends PassCheckEvent { + final String token; + + const ScanQr({required this.token}); +} + +class PerformPostLogs extends PassCheckEvent { + final String passerId; + final int checkerId; + final String io; + final bool otherInputs; + final String? cpId; + final int? stationId; + final String? destination; + final double? temp; + final int roleId; + const PerformPostLogs( + {required this.checkerId, + required this.cpId, + required this.destination, + required this.io, + required this.otherInputs, + required this.passerId, + required this.roleId, + required this.stationId, + required this.temp}); +} + +class PerformIncomingPostLog extends PassCheckEvent{ + final double temp; + const PerformIncomingPostLog({required this.temp}); +} +class PerformOutgoingPostLog extends PassCheckEvent{ + final String destination; + const PerformOutgoingPostLog({required this.destination}); +} +class ScanError extends PassCheckEvent{ + +} \ No newline at end of file diff --git a/lib/bloc/role/pass_check/pass_check_state.dart b/lib/bloc/role/pass_check/pass_check_state.dart new file mode 100644 index 0000000..fe93067 --- /dev/null +++ b/lib/bloc/role/pass_check/pass_check_state.dart @@ -0,0 +1,67 @@ +part of 'pass_check_bloc.dart'; + +abstract class PassCheckState extends Equatable { + const PassCheckState(); + + @override + List get props => []; +} + +class PassCheckInitial extends PassCheckState {} + +class PassCheckErrorState extends PassCheckState { + final String message; + const PassCheckErrorState({required this.message}); +} + +class QRInvalid extends PassCheckState{ + final String token; + const QRInvalid({required this.token}); +} + +class PassCheckLoadingState extends PassCheckState {} + +class AssignAreaLoaded extends PassCheckState { + final List assignedArea; + final int roleId; + const AssignAreaLoaded({required this.assignedArea, required this.roleId}); +} + +class SettingSaved extends PassCheckState { + final dynamic assignedArea; + final String token; + final String io; + final int checker; + final bool otherInputs; + final int roleId; + const SettingSaved( + {required this.assignedArea, + required this.checker, + required this.io, + required this.otherInputs, + required this.roleId, + required this.token}); +} + +class IncomingScanState extends PassCheckState { + +} + +class OutGoingScanState extends PassCheckState { + +} + +class ScanSuccess extends PassCheckState{ + final String token; +const ScanSuccess({required this.token}); +} + +class ScanFailed extends PassCheckState{ + final String token; +const ScanFailed({required this.token}); +} + +class QRCodeInvalid extends PassCheckState{ + final String token; + const QRCodeInvalid({required this.token}); +} diff --git a/lib/bloc/user/user_bloc.dart b/lib/bloc/user/user_bloc.dart index 801930b..9fb227e 100644 --- a/lib/bloc/user/user_bloc.dart +++ b/lib/bloc/user/user_bloc.dart @@ -85,6 +85,8 @@ class UserBloc extends Bloc { emit(InternetTimeout(message: timeoutError)); } on SocketException catch (_) { emit(InternetTimeout(message: timeoutError)); + }on Error catch(e){ +emit(LoginErrorState(message: e.toString())); } }); on((event, emit) async { @@ -110,8 +112,8 @@ class UserBloc extends Bloc { emit(InternetTimeout(message: timeoutError)); } on SocketException catch (_) { emit(InternetTimeout(message: timeoutError)); - } on Error catch (_) { - emit(InvalidCredentials(message: "Invalid username or password")); + } on Error catch(e){ +emit(LoginErrorState(message: e.toString())); } }); on((event, emit) { diff --git a/lib/bloc/user/user_state.dart b/lib/bloc/user/user_state.dart index ab21f7f..3bb0873 100644 --- a/lib/bloc/user/user_state.dart +++ b/lib/bloc/user/user_state.dart @@ -66,3 +66,7 @@ class InvalidCredentials extends UserState{ final String message ; InvalidCredentials ({required this.message}); } +class LoginErrorState extends UserState{ + final String message; + LoginErrorState({required this.message}); +} diff --git a/lib/model/roles/pass_check/agency_area_type.dart b/lib/model/roles/pass_check/agency_area_type.dart new file mode 100644 index 0000000..260a7c9 --- /dev/null +++ b/lib/model/roles/pass_check/agency_area_type.dart @@ -0,0 +1,96 @@ + +class AgencyAssignedArea { + final bool? isactive; + final Area? area; + + AgencyAssignedArea({ + required this.isactive, + required this.area, + }); + + factory AgencyAssignedArea.fromJson(Map json) => AgencyAssignedArea( + isactive: json["isactive"], + area: json["area"] == null? null:Area.fromJson(json["area"]), + ); + + Map toJson() => { + "isactive": isactive, + "area": area?.toJson(), + }; +} + +class Area { + final int? id; + final String? name; + final Category? category; + final bool? privateEntity; + final String? contactInfo; + + Area({ + required this.id, + required this.name, + required this.category, + required this.privateEntity, + required this.contactInfo, + }); + + factory Area.fromJson(Map json) => Area( + id: json["id"], + name: json["name"], + category: json["category"]==null?null:Category.fromJson(json["category"]), + privateEntity: json["private_entity"], + contactInfo: json["contact_info"], + ); + + Map toJson() => { + "id": id, + "name": name, + "category": category?.toJson(), + "private_entity": privateEntity, + "contact_info": contactInfo, + }; +} + +class Category { + final int? id; + final IndustryClass? industryClass; + + Category({ + required this.id, + required this.industryClass, + }); + + factory Category.fromJson(Map json) => Category( + id: json["id"], + industryClass: json["industry_class"] == null?null:IndustryClass.fromJson(json["industry_class"]), + ); + + Map toJson() => { + "id": id, + "industry_class": industryClass?.toJson(), + }; +} + +class IndustryClass { + final int? id; + final String? name; + final String? description; + + IndustryClass({ + required this.id, + required this.name, + required this.description, + }); + + factory IndustryClass.fromJson(Map json) => IndustryClass( + id: json["id"], + name: json["name"], + description: json["description"], + ); + + Map toJson() => { + "id": id, + "name": name, + "description": description, + }; +} diff --git a/lib/model/roles/pass_check/assign_role_area_type.dart b/lib/model/roles/pass_check/assign_role_area_type.dart new file mode 100644 index 0000000..3b2df3e --- /dev/null +++ b/lib/model/roles/pass_check/assign_role_area_type.dart @@ -0,0 +1,52 @@ +// To parse this JSON data, do +// +// final assignRoleAreaType = assignRoleAreaTypeFromJson(jsonString); + + +class AssignRoleAreaType { + final String areaTypeName; + final Details details; + + AssignRoleAreaType({ + required this.areaTypeName, + required this.details, + }); + + factory AssignRoleAreaType.fromJson(Map json) => AssignRoleAreaType( + areaTypeName: json["area_type_name"], + details: Details.fromJson(json["details"]), + ); + + Map toJson() => { + "area_type_name": areaTypeName, + "details": details.toJson(), + }; +} + +class Details { + final String? table; + final String? schema; + final String? dataType; + final String? idColumn; + + Details({ + required this.table, + required this.schema, + required this.dataType, + required this.idColumn, + }); + + factory Details.fromJson(Map json) => Details( + table: json["table"], + schema: json["schema"], + dataType: json["data_type"], + idColumn: json["id_column"], + ); + + Map toJson() => { + "table": table, + "schema": schema, + "data_type": dataType, + "id_column": idColumn, + }; +} diff --git a/lib/model/roles/pass_check/barangay_assign_area.dart b/lib/model/roles/pass_check/barangay_assign_area.dart new file mode 100644 index 0000000..f86ddd5 --- /dev/null +++ b/lib/model/roles/pass_check/barangay_assign_area.dart @@ -0,0 +1,24 @@ + +class BaragayAssignArea { + final String? brgycode; + final String? brgydesc; + final String? citymuncode; + + BaragayAssignArea({ + required this.brgycode, + required this.brgydesc, + required this.citymuncode, + }); + + factory BaragayAssignArea.fromJson(Map json) => BaragayAssignArea( + brgycode: json["brgycode"], + brgydesc: json["brgydesc"], + citymuncode: json["citymuncode"], + ); + + Map toJson() => { + "brgycode": brgycode, + "brgydesc": brgydesc, + "citymuncode": citymuncode, + }; +} diff --git a/lib/model/roles/pass_check/passer_info.dart b/lib/model/roles/pass_check/passer_info.dart new file mode 100644 index 0000000..b841783 --- /dev/null +++ b/lib/model/roles/pass_check/passer_info.dart @@ -0,0 +1,120 @@ + +class PasserInfo { + final int personid; + final String familyname; + final String givenname; + final String? middlename; + final String sex; + final DateTime? birthdate; + final String? extension; + final String? civilstatus; + final double? heightM; + final double weightKg; + final String? bloodtype; + final String? photoPath; + final String? uuid; + final String? encryptionKey; + final bool? deceased; + final dynamic encryptedProfile; + final String? addedby; + final DateTime? addedat; + final String? updateby; + final DateTime? updatedat; + final String? deletedby; + final DateTime? deletedat; + final String? encryptSignature; + final String? esigPath; + final String? titlePrefix; + final String? titleSuffix; + final bool? showTitleId; + + PasserInfo({ + required this.personid, + required this.familyname, + required this.givenname, + required this.middlename, + required this.sex, + required this.birthdate, + required this.extension, + required this.civilstatus, + required this.heightM, + required this.weightKg, + required this.bloodtype, + required this.photoPath, + required this.uuid, + required this.encryptionKey, + required this.deceased, + required this.encryptedProfile, + required this.addedby, + required this.addedat, + required this.updateby, + required this.updatedat, + required this.deletedby, + required this.deletedat, + required this.encryptSignature, + required this.esigPath, + required this.titlePrefix, + required this.titleSuffix, + required this.showTitleId, + }); + + factory PasserInfo.fromJson(Map json) => PasserInfo( + personid: json["personid"], + familyname: json["familyname"], + givenname: json["givenname"], + middlename: json["middlename"], + sex: json["sex"], + birthdate: json['birthdate'] == null?null: DateTime.parse(json["birthdate"]), + extension: json["extension"], + civilstatus: json["civilstatus"], + heightM: json["height_m"]?.toDouble(), + weightKg: json["weight_kg"]?.toDouble(), + bloodtype: json["bloodtype"], + photoPath: json["photo_path"], + uuid: json["uuid"], + encryptionKey: json["encryption_key"], + deceased: json["deceased"], + encryptedProfile: json["encrypted_profile"], + addedby: json["addedby"], + addedat: json["addedat"] == null? null:DateTime.tryParse(json["addedat"]), + updateby:json["updateby"], + updatedat:json["updatedat"]==null?null: DateTime.tryParse(json["updatedat"]), + deletedby: json["deletedby"], + deletedat: json['deletedat'] == null?null:DateTime.tryParse(json["deletedat"]), + encryptSignature: json["encrypt_signature"], + esigPath: json["esig_path"], + titlePrefix: json["title_prefix"], + titleSuffix: json["title_suffix"], + showTitleId: json["show_title_id"], + ); + + Map toJson() => { + "personid": personid, + "familyname": familyname, + "givenname": givenname, + "middlename": middlename, + "sex": sex, + "birthdate": "${birthdate?.year.toString().padLeft(4, '0')}-${birthdate?.month.toString().padLeft(2, '0')}-${birthdate?.day.toString().padLeft(2, '0')}", + "extension": extension, + "civilstatus": civilstatus, + "height_m": heightM, + "weight_kg": weightKg, + "bloodtype": bloodtype, + "photo_path": photoPath, + "uuid": uuid, + "encryption_key": encryptionKey, + "deceased": deceased, + "encrypted_profile": encryptedProfile, + "addedby": addedby, + "addedat": addedat?.toIso8601String(), + "updateby": updateby, + "updatedat": updatedat?.toIso8601String(), + "deletedby": deletedby, + "deletedat": deletedat, + "encrypt_signature": encryptSignature, + "esig_path": esigPath, + "title_prefix": titlePrefix, + "title_suffix": titleSuffix, + "show_title_id": showTitleId, + }; +} diff --git a/lib/model/roles/pass_check/purok_assign_area.dart b/lib/model/roles/pass_check/purok_assign_area.dart new file mode 100644 index 0000000..883086f --- /dev/null +++ b/lib/model/roles/pass_check/purok_assign_area.dart @@ -0,0 +1,42 @@ + + +import 'barangay_assign_area.dart'; + +class Purok { + final String? purokid; + final String? purokdesc; + final BaragayAssignArea? brgy; + final dynamic purokLeader; + final bool? writelock; + final dynamic recordsignature; + + Purok({ + required this.purokid, + required this.purokdesc, + required this.brgy, + required this.purokLeader, + required this.writelock, + required this.recordsignature, + }); + + factory Purok.fromJson(Map json) => Purok( + purokid: json["purokid"], + purokdesc: json["purokdesc"], + brgy: json["brgy"]==null?null:BaragayAssignArea.fromJson(json["brgy"]), + purokLeader: json["purok_leader"], + writelock: json["writelock"], + recordsignature: json["recordsignature"], + ); + + Map toJson() => { + "purokid": purokid, + "purokdesc": purokdesc, + "brgy": brgy?.toJson(), + "purok_leader": purokLeader, + "writelock": writelock, + "recordsignature": recordsignature, + }; +} + + + diff --git a/lib/model/roles/pass_check/station_assign_area.dart b/lib/model/roles/pass_check/station_assign_area.dart new file mode 100644 index 0000000..4251403 --- /dev/null +++ b/lib/model/roles/pass_check/station_assign_area.dart @@ -0,0 +1,182 @@ +// To parse this JSON data, do +// +// final assignArea = assignAreaFromJson(jsonString); + +class StationAssignArea { + final bool? isactive; + final Area? area; + + StationAssignArea({ + required this.isactive, + required this.area, + }); + + factory StationAssignArea.fromJson(Map json) => StationAssignArea( + isactive: json["isactive"], + area: json["area"] == null?null: Area.fromJson(json["area"]), + ); + + Map toJson() => { + "isactive": isactive, + "area": area?.toJson(), + }; +} + +class Area { + final int? id; + final String? stationName; + final StationType? stationType; + final int? hierarchyOrderNo; + final String? headPosition; + final GovernmentAgency? governmentAgency; + final String? acronym; + final int? parentStation; + final String? code; + final String? fullcode; + final List? childStationInfo; + final bool? islocationUnderParent; + final int? mainParentStation; + final String? description; + final bool? ishospital; + final bool? isactive; + final bool? sellingStation; + + Area({ + required this.id, + required this.stationName, + required this.stationType, + required this.hierarchyOrderNo, + required this.headPosition, + required this.governmentAgency, + required this.acronym, + required this.parentStation, + required this.code, + required this.fullcode, + required this.childStationInfo, + required this.islocationUnderParent, + required this.mainParentStation, + required this.description, + required this.ishospital, + required this.isactive, + required this.sellingStation, + }); + + factory Area.fromJson(Map json) => Area( + id: json["id"], + stationName: json["station_name"], + stationType:json["station_type"] ==null?null: StationType.fromJson(json["station_type"]), + hierarchyOrderNo: json["hierarchy_order_no"], + headPosition: json["head_position"], + governmentAgency: json["government_agency"] == null?null:GovernmentAgency.fromJson(json["government_agency"]), + acronym: json["acronym"], + parentStation: json["parent_station"], + code: json["code"], + fullcode: json["fullcode"], + childStationInfo: json['child_station_info']==null?[]:List.from(json["child_station_info"].map((x) => ChildStationInfo.fromJson(x))), + islocationUnderParent: json["islocation_under_parent"], + mainParentStation: json["main_parent_station"], + description: json["description"], + ishospital: json["ishospital"], + isactive: json["isactive"], + sellingStation: json["selling_station"], + ); + + Map toJson() => { + "id": id, + "station_name": stationName, + "station_type": stationType?.toJson(), + "hierarchy_order_no": hierarchyOrderNo, + "head_position": headPosition, + "government_agency": governmentAgency?.toJson(), + "acronym": acronym, + "parent_station": parentStation, + "code": code, + "fullcode": fullcode, + "child_station_info": List.from(childStationInfo!.map((x) => x.toJson())), + "islocation_under_parent": islocationUnderParent, + "main_parent_station": mainParentStation, + "description": description, + "ishospital": ishospital, + "isactive": isactive, + "selling_station": sellingStation, + }; +} + +class ChildStationInfo { + final int? id; + final String? stationName; + final String? acroym; + bool? motherStation; + + ChildStationInfo({ + required this.id, + required this.stationName, + required this.acroym, + this.motherStation + }); + + factory ChildStationInfo.fromJson(Map json) => ChildStationInfo( + id: json["id"], + stationName: json["station_name"], + acroym: json["acroym"], + + ); + + Map toJson() => { + "id": id, + "station_name": stationName, + "acroym": acroym, + }; +} + +class GovernmentAgency { + final int? agencyid; + final String? agencyname; + final int? agencycatid; + final bool? privateEntity; + final int? contactinfoid; + + GovernmentAgency({ + required this.agencyid, + required this.agencyname, + required this.agencycatid, + required this.privateEntity, + required this.contactinfoid, + }); + + factory GovernmentAgency.fromJson(Map json) => GovernmentAgency( + agencyid: json["agencyid"], + agencyname: json["agencyname"], + agencycatid: json["agencycatid"], + privateEntity: json["private_entity"], + contactinfoid: json["contactinfoid"], + ); + + Map toJson() => { + "agencyid": agencyid, + "agencyname": agencyname, + "agencycatid": agencycatid, + "private_entity": privateEntity, + "contactinfoid": contactinfoid, + }; +} + +class StationType { + final int? id; + final String? typeName; + + StationType({ + required this.id, + required this.typeName, + }); + + factory StationType.fromJson(Map json) => StationType( + id: json["id"], + typeName: json["type_name"], + ); + + Map toJson() => { + "id": id, + "type_name": typeName, + }; +} diff --git a/lib/screens/profile/components/basic_information/address/edit_modal.dart b/lib/screens/profile/components/basic_information/address/edit_modal.dart index 29b3325..83901b5 100644 --- a/lib/screens/profile/components/basic_information/address/edit_modal.dart +++ b/lib/screens/profile/components/basic_information/address/edit_modal.dart @@ -8,6 +8,7 @@ import 'package:unit2/bloc/profile/primary_information/address/address_bloc.dart import 'package:unit2/model/location/address_category.dart'; import 'package:unit2/model/profile/basic_information/adress.dart'; import 'package:unit2/utils/global.dart'; +import 'package:unit2/utils/global_context.dart'; import '../../../../../model/location/barangay.dart'; import '../../../../../model/location/city.dart'; import '../../../../../model/location/country.dart'; @@ -281,12 +282,16 @@ class _EditAddressScreenState extends State { }); selectedRegion = region; //// GET PROVINCES + try{ provinces = await LocationUtils .instance .getProvinces( regionCode: selectedRegion!.code .toString()); + }catch(e){ + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } selectedProvince = provinces![0]; setState(() { @@ -294,11 +299,15 @@ class _EditAddressScreenState extends State { cityCall = true; }); //// GET CITIES + try{ citymuns = await LocationUtils .instance .getCities( code: selectedProvince! .code!); + }catch(e){ + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } selectedMunicipality = citymuns![0]; setState(() { @@ -306,23 +315,31 @@ class _EditAddressScreenState extends State { barangayCall = true; }); //// GET BARANGAY + try{ barangays = await LocationUtils .instance .getBarangay( code: selectedMunicipality! .code!); + }catch(e){ + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } selectedBarangay = barangays![0]; setState(() { barangayCall = false; }); ////GET CITY MUNICIPALITY + try{ citymuns = await LocationUtils .instance .getCities( code: selectedProvince! .code!); + }catch(e){ + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } selectedMunicipality = citymuns![0]; setState(() { @@ -330,12 +347,16 @@ class _EditAddressScreenState extends State { barangayCall = true; }); //// GET BARANGAYS + try{ barangays = await LocationUtils .instance .getBarangay( code: selectedMunicipality! .code!); + }catch(e){ + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } selectedBarangay = barangays![0]; setState(() { @@ -385,12 +406,16 @@ class _EditAddressScreenState extends State { }); //// GET CITIES + try{ citymuns = await LocationUtils .instance .getCities( code: selectedProvince! .code!); + }catch(e){ + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } selectedMunicipality = citymuns![0]; setState(() { @@ -398,12 +423,16 @@ class _EditAddressScreenState extends State { barangayCall = true; }); //// GET BARANGAY + try{ barangays = await LocationUtils .instance .getBarangay( code: selectedMunicipality! .code!); + }catch(e){ + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } selectedBarangay = barangays![0]; setState(() { @@ -453,12 +482,16 @@ class _EditAddressScreenState extends State { selectedMunicipality = city; selectedMunicipality = city; //// GET BARANGAYS + try{ barangays = await LocationUtils .instance .getBarangay( code: selectedMunicipality! .code!); + }catch(e){ + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } selectedBarangay = barangays![0]; setState(() { diff --git a/lib/screens/profile/components/basic_information/contact_information_screen.dart b/lib/screens/profile/components/basic_information/contact_information_screen.dart index 4f4e8bd..3e0f4d2 100644 --- a/lib/screens/profile/components/basic_information/contact_information_screen.dart +++ b/lib/screens/profile/components/basic_information/contact_information_screen.dart @@ -90,7 +90,7 @@ class ContactInformationScreen extends StatelessWidget { .add(LoadContacts()); }); } else { - errorAlert(context, "Update Failed", + errorAlert(context, "Adding Failed", "Something went wrong. Please try again.", () { Navigator.of(context).pop(); @@ -331,7 +331,7 @@ class ContactInformationScreen extends StatelessWidget { ); }); } else { - const EmptyData( + return const EmptyData( message: "You don't have contact information added. Please click + to add"); } diff --git a/lib/screens/profile/components/basic_information/edit_basic_info_modal.dart b/lib/screens/profile/components/basic_information/edit_basic_info_modal.dart index 6d33c67..253ea7d 100644 --- a/lib/screens/profile/components/basic_information/edit_basic_info_modal.dart +++ b/lib/screens/profile/components/basic_information/edit_basic_info_modal.dart @@ -157,7 +157,7 @@ class _EditBasicProfileInfoScreenState UpperCaseTextFormatter() ], name: "middlename", - initialValue: state.primaryInformation.middleName!, + initialValue: state.primaryInformation.middleName??'', decoration: normalTextFieldStyle("Middle name", ""), ), ), diff --git a/lib/screens/profile/components/basic_information/family/spouse_edit_modal.dart b/lib/screens/profile/components/basic_information/family/spouse_edit_modal.dart index 30012e4..df5e3d3 100644 --- a/lib/screens/profile/components/basic_information/family/spouse_edit_modal.dart +++ b/lib/screens/profile/components/basic_information/family/spouse_edit_modal.dart @@ -1,10 +1,8 @@ import 'package:date_time_picker/date_time_picker.dart'; import 'package:flutter/material.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; -import 'package:fluttericon/font_awesome_icons.dart'; import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:searchfield/searchfield.dart'; - import '../../../../../bloc/profile/family/family_bloc.dart'; import '../../../../../model/profile/family_backround.dart'; import '../../../../../model/utils/agency.dart'; @@ -17,7 +15,6 @@ import '../../../../../theme-data.dart/form-style.dart'; import '../../../../../utils/formatters.dart'; import '../../../../../utils/global.dart'; import '../../../../../utils/text_container.dart'; -import '../../../../../utils/validators.dart'; import '../../../shared/add_for_empty_search.dart'; class SpouseEditAlert extends StatefulWidget { diff --git a/lib/screens/profile/components/basic_information/identification/edit_modal.dart b/lib/screens/profile/components/basic_information/identification/edit_modal.dart index eb6a8c9..626458a 100644 --- a/lib/screens/profile/components/basic_information/identification/edit_modal.dart +++ b/lib/screens/profile/components/basic_information/identification/edit_modal.dart @@ -146,17 +146,17 @@ class _EditIdentificationScreenState extends State { }); }, selectableDayPredicate: (date) { - if (expDate != null && - DateTime.parse(expDate!) + if ((expDate != "null" && expDate != null) && + DateTime.tryParse(expDate!)! .microsecondsSinceEpoch <= date.microsecondsSinceEpoch) { return false; } return true; }, - initialDate: expDate != null + initialDate: expDate == "null" || expDate == null ? DateTime.now() - : DateTime.parse(expDate!).subtract( + : DateTime.tryParse(expDate!)?.subtract( const Duration(days: 1)), )), @@ -187,17 +187,17 @@ class _EditIdentificationScreenState extends State { color: Colors.black87, )), selectableDayPredicate: (date) { - if (issuedDate != null && - DateTime.parse(issuedDate!) + if ((issuedDate != "null" && issuedDate != null) && + DateTime.tryParse(issuedDate!)! .microsecondsSinceEpoch >= date.microsecondsSinceEpoch) { return false; } return true; }, - initialDate: issuedDate != null + initialDate: issuedDate == null && issuedDate == "null" ? DateTime.now() - : DateTime.parse(issuedDate!).add( + : DateTime.tryParse(issuedDate!)?.add( const Duration(days: 1)), )), ], @@ -259,6 +259,14 @@ class _EditIdentificationScreenState extends State { selectedRegion! .code .toString()); + } catch (e) { + context + .read< + IdentificationBloc>() + .add(ShowErrorState( + message: + e.toString())); + } selectedProvince = provinces![0]; setState(() { @@ -287,14 +295,7 @@ class _EditIdentificationScreenState extends State { message: e .toString())); } - } catch (e) { - context - .read< - IdentificationBloc>() - .add(ShowErrorState( - message: - e.toString())); - } + } }, value: selectedRegion, diff --git a/lib/screens/profile/components/basic_information/identification_information_screen.dart b/lib/screens/profile/components/basic_information/identification_information_screen.dart index cd9836e..315189a 100644 --- a/lib/screens/profile/components/basic_information/identification_information_screen.dart +++ b/lib/screens/profile/components/basic_information/identification_information_screen.dart @@ -219,7 +219,7 @@ class IdentificationsScreen extends StatelessWidget { const SizedBox(height: 8,), Badge( backgroundColor: - success2, + government != true?success2:second, label: Text( government == true ? privateText diff --git a/lib/screens/profile/components/basic_information/primary_information_screen.dart b/lib/screens/profile/components/basic_information/primary_information_screen.dart index 875ca64..f574e08 100644 --- a/lib/screens/profile/components/basic_information/primary_information_screen.dart +++ b/lib/screens/profile/components/basic_information/primary_information_screen.dart @@ -1,15 +1,12 @@ -import 'package:date_time_picker/date_time_picker.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; -import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:intl/intl.dart'; import 'package:unit2/bloc/profile/profile_bloc.dart'; -import 'package:unit2/model/profile/basic_information/primary-information.dart'; import 'package:unit2/screens/profile/components/basic_information/edit_basic_info_modal.dart'; -import 'package:unit2/theme-data.dart/btn-style.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/theme-data.dart/form-style.dart'; import 'package:unit2/utils/global.dart'; @@ -132,8 +129,8 @@ class _PrimaryInfoState extends State { child: FormBuilderTextField( enabled: enabled, name: middlename, - initialValue: - state.primaryBasicInformation.middleName!, + initialValue: state.primaryBasicInformation.middleName??'' + , decoration: normalTextFieldStyle("Middle name", ""), ), diff --git a/lib/screens/profile/components/eligibility/edit_modal.dart b/lib/screens/profile/components/eligibility/edit_modal.dart index ca4dadc..d161084 100644 --- a/lib/screens/profile/components/eligibility/edit_modal.dart +++ b/lib/screens/profile/components/eligibility/edit_modal.dart @@ -9,6 +9,7 @@ import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart'; import 'package:unit2/model/location/city.dart'; import 'package:unit2/model/profile/eligibility.dart'; import 'package:unit2/model/utils/eligibility.dart'; +import 'package:unit2/utils/global_context.dart'; import 'package:unit2/utils/location_utilities.dart'; import '../../../../bloc/profile/eligibility/eligibility_bloc.dart'; import '../../../../model/location/country.dart'; @@ -315,22 +316,30 @@ class _EditEligibilityScreenState extends State { provinceCall = true; }); selectedRegion = region; + try{ provinces = await LocationUtils .instance .getProvinces( regionCode: selectedRegion!.code .toString()); + }catch(e){ + context.read().add(CallErrorState()); + } selectedProvince = provinces![0]; setState(() { provinceCall = false; cityCall = true; }); + try{ citymuns = await LocationUtils .instance .getCities( code: selectedProvince! .code!); + }catch(e){ + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } selectedMunicipality = citymuns![0]; setState(() { @@ -376,6 +385,9 @@ class _EditEligibilityScreenState extends State { cityCall = true; }); selectedProvince = province; + try{ + + citymuns = await LocationUtils .instance .getCities( @@ -383,6 +395,9 @@ class _EditEligibilityScreenState extends State { selectedProvince! .code .toString()); + }catch(e){ + context.read().add(CallErrorState()); + } selectedMunicipality = citymuns![0]; setState(() { diff --git a/lib/screens/profile/components/family_background_screen.dart b/lib/screens/profile/components/family_background_screen.dart index c0c6368..e680896 100644 --- a/lib/screens/profile/components/family_background_screen.dart +++ b/lib/screens/profile/components/family_background_screen.dart @@ -328,7 +328,7 @@ class _FamilyBackgroundScreenState extends State { vertical: -4), title: Text( - "${father?.relatedPerson?.firstName} ${father?.relatedPerson?.middleName??''} ${father?.relatedPerson!.lastName} ${father?.relatedPerson?.nameExtension ?? ''}", + "${father?.relatedPerson?.firstName} ${father?.relatedPerson?.middleName ?? ''} ${father?.relatedPerson!.lastName} ${father?.relatedPerson?.nameExtension ?? ''}", style: Theme.of( context) .textTheme @@ -612,7 +612,7 @@ class _FamilyBackgroundScreenState extends State { vertical: -4), title: Text( - "${mother?.relatedPerson?.firstName} ${mother?.relatedPerson?.middleName??''} ${mother?.relatedPerson?.lastName} ${mother?.relatedPerson?.nameExtension ?? ''}", + "${mother?.relatedPerson?.firstName} ${mother?.relatedPerson?.middleName ?? ''} ${mother?.relatedPerson?.lastName} ${mother?.relatedPerson?.nameExtension ?? ''}", style: Theme.of( context) .textTheme @@ -860,25 +860,38 @@ class _FamilyBackgroundScreenState extends State { context); progress!.showWithText( "Loading..."); - if (positions.isEmpty) { - positions = - await ProfileUtilities - .instance - .getAgencyPosition(); - } + try { + if (positions + .isEmpty) { + positions = + await ProfileUtilities + .instance + .getAgencyPosition(); + } - if (agencices.isEmpty) { - agencices = - await ProfileUtilities - .instance - .getAgecies(); - } - if (categories - .isEmpty) { - categories = - await ProfileUtilities - .instance - .agencyCategory(); + if (agencices + .isEmpty) { + agencices = + await ProfileUtilities + .instance + .getAgecies(); + } + if (categories + .isEmpty) { + categories = + await ProfileUtilities + .instance + .agencyCategory(); + } + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + FamilyBloc>() + .add(CallErrorState( + message: e + .toString())); } progress.dismiss(); showDialog( @@ -938,7 +951,7 @@ class _FamilyBackgroundScreenState extends State { vertical: -4), title: Text( - "${spouse?.relatedPerson?.firstName} ${spouse?.relatedPerson?.middleName??''} ${spouse?.relatedPerson!.lastName} ${spouse?.relatedPerson?.nameExtension ?? ''}", + "${spouse?.relatedPerson?.firstName} ${spouse?.relatedPerson?.middleName ?? ''} ${spouse?.relatedPerson!.lastName} ${spouse?.relatedPerson?.nameExtension ?? ''}", style: Theme.of( context) .textTheme @@ -1356,7 +1369,7 @@ class _FamilyBackgroundScreenState extends State { horizontal: -4, vertical: -4), title: Text( - "${child.relatedPerson?.firstName} ${child.relatedPerson?.middleName??''} ${child.relatedPerson?.lastName} ${child.relatedPerson?.nameExtension ?? ''}", + "${child.relatedPerson?.firstName} ${child.relatedPerson?.middleName ?? ''} ${child.relatedPerson?.lastName} ${child.relatedPerson?.nameExtension ?? ''}", style: Theme.of(context).textTheme.titleMedium!.copyWith(fontWeight: FontWeight.w500)), subtitle: const Text("fullname"), @@ -1859,9 +1872,15 @@ class _FamilyBackgroundScreenState extends State { ), ), ]); - }if(state is FamilyErrorState){ - return SomethingWentWrong(message: state.message, onpressed: (){context.read().add(GetFamilies(profileId: profileId!, token: token!));}); - } + } + if (state is FamilyErrorState) { + return SomethingWentWrong( + message: state.message, + onpressed: () { + context.read().add(GetFamilies( + profileId: profileId!, token: token!)); + }); + } return Container(); }, ); diff --git a/lib/screens/profile/components/learning_and_development_screen.dart b/lib/screens/profile/components/learning_and_development_screen.dart index 1ca5d34..fc8df3b 100644 --- a/lib/screens/profile/components/learning_and_development_screen.dart +++ b/lib/screens/profile/components/learning_and_development_screen.dart @@ -35,19 +35,39 @@ class LearningAndDevelopmentScreen extends StatelessWidget { DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); return Scaffold( appBar: AppBar( - title: context.watch().state is LearningDevelopmentAddingState? const FittedBox(child: Text("Add $learningAndDevelopmentScreenTitle")):context.watch().state is LearningDevelopmentUpdatingState?const FittedBox(child: Text("Edit $learningAndDevelopmentScreenTitle")):const FittedBox(child: Text(learningAndDevelopmentScreenTitle)), - centerTitle: true, - backgroundColor: primary, - actions: (context.watch().state is LearningDevelopmentLoadedState)?[ - AddLeading(onPressed: () { - context.read().add(ShowAddLearningDevelopmentForm()); - }) - ]:(context.watch().state is LearningDevelopmentAddingState || context.watch().state is LearningDevelopmentUpdatingState)?[ - CloseLeading(onPressed:() { - context.read().add(LoadLearniningDevelopment()); - }) - ]:[] - ), + title: context.watch().state + is LearningDevelopmentAddingState + ? const FittedBox( + child: Text("Add $learningAndDevelopmentScreenTitle")) + : context.watch().state + is LearningDevelopmentUpdatingState + ? const FittedBox( + child: Text("Edit $learningAndDevelopmentScreenTitle")) + : const FittedBox( + child: Text(learningAndDevelopmentScreenTitle)), + centerTitle: true, + backgroundColor: primary, + actions: (context.watch().state + is LearningDevelopmentLoadedState) + ? [ + AddLeading(onPressed: () { + context + .read() + .add(ShowAddLearningDevelopmentForm()); + }) + ] + : (context.watch().state + is LearningDevelopmentAddingState || + context.watch().state + is LearningDevelopmentUpdatingState) + ? [ + CloseLeading(onPressed: () { + context + .read() + .add(LoadLearniningDevelopment()); + }) + ] + : []), body: ProgressHUD( padding: const EdgeInsets.all(24), indicatorWidget: const SpinKitFadingCircle( @@ -56,11 +76,13 @@ class LearningAndDevelopmentScreen extends StatelessWidget { backgroundColor: Colors.black87, child: BlocBuilder( builder: (context, state) { + if (state is UserLoggedIn) { token = state.userData!.user!.login!.token!; profileId = state.userData!.user!.login!.user!.profileId!; return BlocBuilder( builder: (context, state) { + if (state is ProfileLoaded) { return BlocConsumer( @@ -73,7 +95,8 @@ class LearningAndDevelopmentScreen extends StatelessWidget { state is LearningDevelopmentErrorState || state is LearningDevelopmentAddingState || state is LearningDevelopmentAddedState || - state is LearningDevelopmentUpdatingState) { + state is LearningDevelopmentUpdatingState || + state is LearningDevelopmentUpdatedState) { final progress = ProgressHUD.of(context); progress!.dismiss(); } @@ -99,7 +122,7 @@ class LearningAndDevelopmentScreen extends StatelessWidget { } } ////Updated State - if (state is LearningDevelopmentUpdatedState) { + if (state is LearningDevelopmentUpdatedState) { if (state.response['success']) { successAlert(context, "Update Successfull!", state.response['message'], () { @@ -123,7 +146,8 @@ class LearningAndDevelopmentScreen extends StatelessWidget { if (state is DeleteLearningDevelopmentState) { if (state.success) { successAlert(context, "Deletion Successfull!", - "Learning Development Has Been Deleted Successfully", () { + "Learning Development Has Been Deleted Successfully", + () { Navigator.of(context).pop(); context .read() @@ -143,7 +167,9 @@ class LearningAndDevelopmentScreen extends StatelessWidget { // TODO: implement listener }, builder: (context, state) { + print(state); if (state is LearningDevelopmentLoadedState) { + if (state.learningsAndDevelopment.isNotEmpty) { return ListView.builder( padding: const EdgeInsets.symmetric( @@ -200,9 +226,9 @@ class LearningAndDevelopmentScreen extends StatelessWidget { .copyWith( fontWeight: FontWeight - .w600,color: primary), + .w600, + color: primary), ), - const SizedBox( height: 8, ), @@ -296,7 +322,7 @@ class LearningAndDevelopmentScreen extends StatelessWidget { isOverseas)); } }, - menuItems: [ + menuItems: [ popMenuItem( text: "Update", value: 1, @@ -305,11 +331,10 @@ class LearningAndDevelopmentScreen extends StatelessWidget { text: "Remove", value: 2, icon: Icons.delete), - popMenuItem( + popMenuItem( text: "Attach", value: 2, icon: Icons.attach_file), - ], icon: const Icon( Icons.more_vert, @@ -334,7 +359,12 @@ class LearningAndDevelopmentScreen extends StatelessWidget { } if (state is LearningDevelopmentErrorState) { return (SomethingWentWrong( - message: state.message, onpressed: () {context.read().add(GetLearningDevelopments(profileId: profileId, token: token));})); + message: state.message, + onpressed: () { + context.read().add( + GetLearningDevelopments( + profileId: profileId, token: token)); + })); } if (state is LearningDevelopmentAddingState) { return AddLearningAndDevelopmentScreen( diff --git a/lib/screens/profile/components/learning_development/add_modal.dart b/lib/screens/profile/components/learning_development/add_modal.dart index 14a945d..5a0e4f7 100644 --- a/lib/screens/profile/components/learning_development/add_modal.dart +++ b/lib/screens/profile/components/learning_development/add_modal.dart @@ -1,6 +1,5 @@ import 'package:date_time_picker/date_time_picker.dart'; import 'package:flutter/material.dart'; - import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart'; diff --git a/lib/screens/profile/components/learning_development/edit_modal.dart b/lib/screens/profile/components/learning_development/edit_modal.dart index 7951297..ea5e04e 100644 --- a/lib/screens/profile/components/learning_development/edit_modal.dart +++ b/lib/screens/profile/components/learning_development/edit_modal.dart @@ -1,6 +1,5 @@ import 'package:date_time_picker/date_time_picker.dart'; import 'package:flutter/material.dart'; - import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart'; @@ -11,6 +10,7 @@ import 'package:searchfield/searchfield.dart'; import 'package:unit2/bloc/profile/learningDevelopment/learning_development_bloc.dart'; import 'package:unit2/model/profile/learning_development.dart'; import 'package:unit2/theme-data.dart/btn-style.dart'; +import 'package:unit2/utils/global_context.dart'; import 'package:unit2/utils/text_container.dart'; import 'package:unit2/utils/validators.dart'; import '../../../../model/location/barangay.dart'; @@ -379,7 +379,7 @@ class _EditLearningAndDevelopmentScreenState selectableDayPredicate: (date) { if (to != null && - to!.microsecondsSinceEpoch <= + to!.microsecondsSinceEpoch < date.microsecondsSinceEpoch) { return false; } @@ -388,14 +388,10 @@ class _EditLearningAndDevelopmentScreenState onChanged: (value) { setState(() { from = - DateTime.parse(value); + DateTime.tryParse(value); }); }, - initialDate: to == null - ? DateTime.now() - : to!.subtract( - const Duration( - days: 1)), + initialDate: to??=DateTime.now(), timeHintText: "Date of Examination/Conferment", decoration: @@ -442,7 +438,7 @@ class _EditLearningAndDevelopmentScreenState ), selectableDayPredicate: (date) { if (from != null && - from!.microsecondsSinceEpoch >= + from!.microsecondsSinceEpoch > date.microsecondsSinceEpoch) { return false; } @@ -450,13 +446,10 @@ class _EditLearningAndDevelopmentScreenState }, onChanged: (value) { setState(() { - to = DateTime.parse(value); + to = DateTime.tryParse(value); }); }, - initialDate: from == null - ? DateTime.now() - : from!.add(const Duration( - days: 1)), + initialDate: from??=DateTime.now() ), ), ], @@ -545,12 +538,21 @@ class _EditLearningAndDevelopmentScreenState selectedRegion = region; //// GET PROVINCES - provinces = await LocationUtils - .instance - .getProvinces( - regionCode: selectedRegion! - .code - .toString()); + try { + provinces = await LocationUtils + .instance + .getProvinces( + regionCode: selectedRegion! + .code + .toString()); + } catch (e) { + context + .read< + LearningDevelopmentBloc>() + .add(CallErrorState( + message: + e.toString())); + } selectedProvince = provinces![0]; setState(() { @@ -559,11 +561,22 @@ class _EditLearningAndDevelopmentScreenState cityCall = true; }); //// GET CITIES - citymuns = await LocationUtils - .instance - .getCities( - code: selectedProvince! - .code!); + try { + citymuns = await LocationUtils + .instance + .getCities( + code: selectedProvince! + .code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + LearningDevelopmentBloc>() + .add(CallErrorState( + message: + e.toString())); + } selectedMunicipality = citymuns![0]; setState(() { @@ -573,11 +586,22 @@ class _EditLearningAndDevelopmentScreenState true; }); //// GET BARANGAY - barangays = await LocationUtils - .instance - .getBarangay( - code: selectedMunicipality! - .code!); + try { + barangays = await LocationUtils + .instance + .getBarangay( + code: selectedMunicipality! + .code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + LearningDevelopmentBloc>() + .add(CallErrorState( + message: + e.toString())); + } selectedBarangay = barangays![0]; setState(() { @@ -585,11 +609,22 @@ class _EditLearningAndDevelopmentScreenState false; }); ////GET CITY MUNICIPALITY - citymuns = await LocationUtils - .instance - .getCities( - code: selectedProvince! - .code!); + try { + citymuns = await LocationUtils + .instance + .getCities( + code: selectedProvince! + .code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + LearningDevelopmentBloc>() + .add(CallErrorState( + message: + e.toString())); + } selectedMunicipality = citymuns![0]; setState(() { @@ -599,11 +634,22 @@ class _EditLearningAndDevelopmentScreenState true; }); //// GET BARANGAYS - barangays = await LocationUtils - .instance - .getBarangay( - code: selectedMunicipality! - .code!); + try { + barangays = await LocationUtils + .instance + .getBarangay( + code: selectedMunicipality! + .code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + LearningDevelopmentBloc>() + .add(CallErrorState( + message: + e.toString())); + } selectedBarangay = barangays![0]; setState(() { @@ -645,70 +691,79 @@ class _EditLearningAndDevelopmentScreenState .transparent, inAsyncCall: provinceCall, - child: DropdownButtonFormField< - Province?>( - autovalidateMode: - AutovalidateMode - .onUserInteraction, - validator: (value) => - value == null + child: + DropdownButtonFormField< + Province?>( + autovalidateMode: + AutovalidateMode + .onUserInteraction, + validator: (value) => value == null ? 'required' : null, - isExpanded: - true, - value: - selectedProvince, - onChanged: - (Province? - province) async { - if (selectedProvince != - province) { - selectedProvince = - province; - setState( - () { - cityCall = - true; - }); + isExpanded: + true, + value: + selectedProvince, + onChanged: + (Province? + province) async { + if (selectedProvince != + province) { + selectedProvince = + province; + setState( + () { + cityCall = + true; + }); - //// GET CITIES - citymuns = await LocationUtils - .instance - .getCities( - code: - selectedProvince!.code!); - selectedMunicipality = - citymuns![ - 0]; - setState( - () { - cityCall = - false; - barangayCall = - true; - }); - //// GET BARANGAY - barangays = await LocationUtils - .instance - .getBarangay( - code: - selectedMunicipality!.code!); - selectedBarangay = - barangays![ - 0]; - setState( - () { - barangayCall = - false; - }); - } - }, - items: - provinces == + //// GET CITIES + try { + citymuns = await LocationUtils + .instance + .getCities(code: selectedProvince!.code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read() + .add(CallErrorState(message: e.toString())); + } + selectedMunicipality = + citymuns![0]; + setState( + () { + cityCall = + false; + barangayCall = + true; + }); + //// GET BARANGAY + try { + barangays = await LocationUtils + .instance + .getBarangay(code: selectedMunicipality!.code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read() + .add(CallErrorState(message: e.toString())); + } + selectedBarangay = + barangays![0]; + setState( + () { + barangayCall = + false; + }); + } + }, + items: provinces == null ? [] - : provinces! - .map>((Province province) { + : provinces!.map>((Province + province) { return DropdownMenuItem( enabled: !enabled ? overseas : true, value: province, @@ -716,7 +771,13 @@ class _EditLearningAndDevelopmentScreenState child: Text(province.description!), )); }).toList(), - decoration: normalTextFieldStyle("Province*", "Province").copyWith(filled: !enabled ? !overseas : false, fillColor: Colors.grey.shade300)), + decoration: normalTextFieldStyle("Province*", "Province").copyWith( + filled: !enabled + ? !overseas + : false, + fillColor: Colors + .grey + .shade300)), ), ), ////CITY MUNICIPALITY @@ -729,7 +790,6 @@ class _EditLearningAndDevelopmentScreenState cityCall, child: DropdownButtonFormField< CityMunicipality>( - validator: FormBuilderValidators .required( errorText: @@ -746,13 +806,24 @@ class _EditLearningAndDevelopmentScreenState }); selectedMunicipality = city; - + //// GET BARANGAYS - barangays = await LocationUtils - .instance - .getBarangay( - code: - selectedMunicipality!.code!); + try { + barangays = await LocationUtils + .instance + .getBarangay( + code: + selectedMunicipality!.code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + LearningDevelopmentBloc>() + .add(CallErrorState( + message: + e.toString())); + } selectedBarangay = barangays![ 0]; @@ -805,7 +876,7 @@ class _EditLearningAndDevelopmentScreenState child: DropdownButtonFormField< Barangay>( - isExpanded: true, + isExpanded: true, onChanged: (Barangay? baragay) { diff --git a/lib/screens/profile/components/reference/add_modal.dart b/lib/screens/profile/components/reference/add_modal.dart index 5883898..cfd8ca3 100644 --- a/lib/screens/profile/components/reference/add_modal.dart +++ b/lib/screens/profile/components/reference/add_modal.dart @@ -110,7 +110,6 @@ class _AddReferenceScreenState extends State { inputFormatters: [ UpperCaseTextFormatter() ], - decoration: normalTextFieldStyle( "Middle name ", ""), name: "middlename", diff --git a/lib/screens/profile/components/reference/edit_modal.dart b/lib/screens/profile/components/reference/edit_modal.dart index 803d7cb..479bed8 100644 --- a/lib/screens/profile/components/reference/edit_modal.dart +++ b/lib/screens/profile/components/reference/edit_modal.dart @@ -4,6 +4,7 @@ import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart'; +import 'package:unit2/utils/global_context.dart'; import '../../../../bloc/profile/references/references_bloc.dart'; import '../../../../model/location/address_category.dart'; import '../../../../model/location/barangay.dart'; @@ -72,7 +73,7 @@ class _EditReferenceScreenState extends State { return FormBuilder( key: formKey, child: SizedBox( - height: screenHeight * .90, + height: screenHeight * .90, child: Padding( padding: const EdgeInsets.all(28), child: Column( @@ -87,9 +88,7 @@ class _EditReferenceScreenState extends State { Flexible( flex: 1, child: FormBuilderTextField( - inputFormatters: [ - UpperCaseTextFormatter() - ], + inputFormatters: [UpperCaseTextFormatter()], initialValue: state.ref.lastName, decoration: normalTextFieldStyle( "Last name *", "Last name *"), @@ -105,10 +104,7 @@ class _EditReferenceScreenState extends State { Flexible( flex: 1, child: FormBuilderTextField( - inputFormatters: [ - UpperCaseTextFormatter() - ], - + inputFormatters: [UpperCaseTextFormatter()], initialValue: state.ref.firstName, decoration: normalTextFieldStyle( "First name *", "First name *"), @@ -127,15 +123,11 @@ class _EditReferenceScreenState extends State { Flexible( flex: 1, child: FormBuilderTextField( - inputFormatters: [ - UpperCaseTextFormatter() - ], - + inputFormatters: [UpperCaseTextFormatter()], initialValue: state.ref.middleName, decoration: normalTextFieldStyle( "Middle name *", "Midlle name *"), name: "middlename", - ), ), const SizedBox( @@ -160,8 +152,8 @@ class _EditReferenceScreenState extends State { ), FormBuilderDropdown( name: 'category', - validator: - FormBuilderValidators.required(errorText: "This field is required"), + validator: FormBuilderValidators.required( + errorText: "This field is required"), decoration: normalTextFieldStyle( "Address Category", "Address Category"), items: state.categories @@ -209,62 +201,95 @@ class _EditReferenceScreenState extends State { ////REGION DROPDOWN DropdownButtonFormField( isExpanded: true, - autovalidateMode: AutovalidateMode - .onUserInteraction, - validator: - FormBuilderValidators.required( + autovalidateMode: + AutovalidateMode + .onUserInteraction, + validator: FormBuilderValidators + .required( errorText: "This field is required"), - onChanged: (Region? region) async { + onChanged: + (Region? region) async { setState(() { provinceCall = true; - + selectedRegion = region; }); //// GET PROVINCES - provinces = await LocationUtils - .instance - .getProvinces( - regionCode: selectedRegion! - .code - .toString()); - selectedProvince = provinces![0]; + try { + provinces = await LocationUtils + .instance + .getProvinces( + regionCode: + selectedRegion! + .code + .toString()); + } catch (e) { + context + .read() + .add(CallErrorState()); + } + selectedProvince = + provinces![0]; setState(() { provinceCall = false; cityCall = true; }); ////GET CITY MUNICIPALITY - citymuns = await LocationUtils - .instance - .getCities( - code: selectedProvince! - .code!); - selectedMunicipality = citymuns![0]; + try { + citymuns = await LocationUtils + .instance + .getCities( + code: + selectedProvince! + .code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read() + .add(CallErrorState()); + } + selectedMunicipality = + citymuns![0]; setState(() { cityCall = false; barangayCall = true; }); //// GET BARANGAYS - barangays = await LocationUtils - .instance - .getBarangay( - code: selectedMunicipality! - .code!); - selectedBarangay = barangays![0]; + try { + barangays = await LocationUtils + .instance + .getBarangay( + code: + selectedMunicipality! + .code!); + selectedBarangay = + barangays![0]; + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read() + .add(CallErrorState()); + } setState(() { barangayCall = false; }); }, value: selectedRegion, - decoration: normalTextFieldStyle( - "Region*", "Region"), - items: state.regions - .map>( - (Region region) { - return DropdownMenuItem( + decoration: + normalTextFieldStyle( + "Region*", "Region"), + items: state.regions.map< + DropdownMenuItem< + Region>>( + (Region region) { + return DropdownMenuItem< + Region>( value: region, - child: - Text(region.description!)); + child: Text( + region.description!)); }).toList(), ), const SizedBox( @@ -286,19 +311,30 @@ class _EditReferenceScreenState extends State { ? 'required' : null, isExpanded: true, - onChanged: - (Province? province) async { - selectedProvince = province; + onChanged: (Province? + province) async { + selectedProvince = + province; setState(() { cityCall = true; }); //// GET CITIES - citymuns = await LocationUtils - .instance - .getCities( - code: - selectedProvince! - .code!); + try { + citymuns = + await LocationUtils + .instance + .getCities( + code: selectedProvince! + .code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + ReferencesBloc>() + .add( + CallErrorState()); + } selectedMunicipality = citymuns![0]; setState(() { @@ -306,12 +342,22 @@ class _EditReferenceScreenState extends State { barangayCall = true; }); //// GET BARANGAY - barangays = await LocationUtils - .instance - .getBarangay( - code: - selectedMunicipality! - .code!); + try { + barangays = + await LocationUtils + .instance + .getBarangay( + code: selectedMunicipality! + .code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + ReferencesBloc>() + .add( + CallErrorState()); + } selectedBarangay = barangays![0]; setState(() { @@ -324,12 +370,16 @@ class _EditReferenceScreenState extends State { : provinces!.map< DropdownMenuItem< Province>>( - (Province province) { + (Province + province) { return DropdownMenuItem( - value: province, - child: FittedBox( - child: Text(province - .description!), + value: + province, + child: + FittedBox( + child: Text( + province + .description!), )); }).toList(), decoration: @@ -344,46 +394,61 @@ class _EditReferenceScreenState extends State { child: ModalProgressHUD( color: Colors.white, inAsyncCall: cityCall, - child: DropdownButtonFormField< - CityMunicipality>( + child: + DropdownButtonFormField< + CityMunicipality>( validator: FormBuilderValidators .required( errorText: "This field is required"), isExpanded: true, - onChanged: (CityMunicipality? - city) async { + onChanged: + (CityMunicipality? + city) async { setState(() { barangayCall = true; }); - selectedMunicipality = city; + selectedMunicipality = + city; //// GET BARANGAYS - barangays = await LocationUtils - .instance - .getBarangay( - code: - selectedMunicipality! - .code!); + try { + barangays = + await LocationUtils + .instance + .getBarangay( + code: selectedMunicipality! + .code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + ReferencesBloc>() + .add( + CallErrorState()); + } selectedBarangay = barangays![0]; setState(() { barangayCall = false; }); }, - decoration: normalTextFieldStyle( - "Municipality*", - "Municipality"), + decoration: + normalTextFieldStyle( + "Municipality*", + "Municipality"), value: selectedMunicipality, items: citymuns == null ? [] : citymuns!.map< DropdownMenuItem< CityMunicipality>>( - (CityMunicipality c) { + (CityMunicipality + c) { return DropdownMenuItem( value: c, - child: Text( - c.description!)); + child: Text(c + .description!)); }).toList(), ), ), @@ -394,25 +459,31 @@ class _EditReferenceScreenState extends State { child: ModalProgressHUD( color: Colors.white, inAsyncCall: barangayCall, - child: DropdownButtonFormField< - Barangay>( + child: + DropdownButtonFormField< + Barangay>( validator: FormBuilderValidators .required( errorText: "This field is required"), isExpanded: true, - onChanged: (Barangay? baragay) { - selectedBarangay = baragay; + onChanged: + (Barangay? baragay) { + selectedBarangay = + baragay; }, - decoration: normalTextFieldStyle( - "Barangay*", "Barangay"), + decoration: + normalTextFieldStyle( + "Barangay*", + "Barangay"), value: selectedBarangay, items: barangays == null ? [] : barangays!.map< DropdownMenuItem< Barangay>>( - (Barangay barangay) { + (Barangay + barangay) { return DropdownMenuItem( value: barangay, child: Text(barangay @@ -426,22 +497,28 @@ class _EditReferenceScreenState extends State { //// COUNTRY DROPDOWN : SizedBox( height: 60, - child: DropdownButtonFormField( + child: DropdownButtonFormField< + Country>( isExpanded: true, - value: selectedCountry?.id==175?null:selectedCountry, - validator: - FormBuilderValidators.required( + value: selectedCountry?.id == 175 + ? null + : selectedCountry, + validator: FormBuilderValidators + .required( errorText: "This field is required"), - items: state.countries - .map>( - (Country country) { - return DropdownMenuItem( + items: state.countries.map< + DropdownMenuItem< + Country>>( + (Country country) { + return DropdownMenuItem< + Country>( value: country, child: FittedBox( - child: Text(country.name!))); + child: Text( + country.name!))); }).toList(), - + decoration: normalTextFieldStyle( "Country*", "Country"), //// country dropdown @@ -454,93 +531,91 @@ class _EditReferenceScreenState extends State { ], ); }), - - - + const SizedBox( height: 20, ), ], ), ), - SizedBox( - width: double.infinity, - height: 60, - child: ElevatedButton( - style: - mainBtnStyle(primary, Colors.transparent, second), - child: const Text(submit), - onPressed: () { - PersonalReference? personalReference; - if (formKey.currentState!.saveAndValidate()) { - final progress = ProgressHUD.of(context); - progress!.showWithText("Please wait..."); - String lastname = - formKey.currentState!.value['lastname']; - String firstname = - formKey.currentState!.value['firstname']; - String? middlename = - formKey.currentState?.value['middlename']; - String mobile = - formKey.currentState!.value['mobile']; - - Region? region = selectedRegion; - Province? province = Province( - code: selectedProvince?.code, - description: selectedProvince?.description, - region: region, - psgcCode: selectedProvince?.psgcCode, - shortname: selectedProvince?.shortname); - CityMunicipality? city = CityMunicipality( - code: selectedMunicipality?.code, - description: - selectedMunicipality?.description, - province: province, - psgcCode: selectedMunicipality?.psgcCode, - zipcode: selectedMunicipality?.zipcode); - - ////IF IS OVERSEAS - if (overseas) { - personalReference = PersonalReference( - id: state.ref.id, - address: Address( - id: state.ref.address!.id, - addressCategory: selectedCategory, - country: selectedCountry, - barangay: null, - cityMunicipality: null, - addressClass: null), - lastName: lastname, - contactNo: mobile, - firstName: firstname, - middleName: middlename); - } else { - //// IF NOT OVERSEAS - personalReference = PersonalReference( - id: state.ref.id, - address: Address( - id: state.ref.address!.id, - addressCategory: selectedCategory, - country: Country( - id: 175, code: null, name: null), - barangay: selectedBarangay, - cityMunicipality: city, - addressClass: - state.ref.address?.addressClass), - lastName: lastname, - contactNo: mobile, - firstName: firstname, - middleName: middlename); - } - - context.read().add(EditReference( - profileId: widget.profileId, - reference: personalReference, - token: widget.token)); - } - }, - ), - ), + SizedBox( + width: double.infinity, + height: 60, + child: ElevatedButton( + style: + mainBtnStyle(primary, Colors.transparent, second), + child: const Text(submit), + onPressed: () { + PersonalReference? personalReference; + if (formKey.currentState!.saveAndValidate()) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + String lastname = + formKey.currentState!.value['lastname']; + String firstname = + formKey.currentState!.value['firstname']; + String? middlename = + formKey.currentState?.value['middlename']; + String mobile = + formKey.currentState!.value['mobile']; + + Region? region = selectedRegion; + Province? province = Province( + code: selectedProvince?.code, + description: selectedProvince?.description, + region: region, + psgcCode: selectedProvince?.psgcCode, + shortname: selectedProvince?.shortname); + CityMunicipality? city = CityMunicipality( + code: selectedMunicipality?.code, + description: + selectedMunicipality?.description, + province: province, + psgcCode: selectedMunicipality?.psgcCode, + zipcode: selectedMunicipality?.zipcode); + + ////IF IS OVERSEAS + if (overseas) { + personalReference = PersonalReference( + id: state.ref.id, + address: Address( + id: state.ref.address!.id, + addressCategory: selectedCategory, + country: selectedCountry, + barangay: null, + cityMunicipality: null, + addressClass: null), + lastName: lastname, + contactNo: mobile, + firstName: firstname, + middleName: middlename); + } else { + //// IF NOT OVERSEAS + personalReference = PersonalReference( + id: state.ref.id, + address: Address( + id: state.ref.address!.id, + addressCategory: selectedCategory, + country: Country( + id: 175, code: null, name: null), + barangay: selectedBarangay, + cityMunicipality: city, + addressClass: + state.ref.address?.addressClass), + lastName: lastname, + contactNo: mobile, + firstName: firstname, + middleName: middlename); + } + + context.read().add(EditReference( + profileId: widget.profileId, + reference: personalReference, + token: widget.token)); + } + }, + ), + ), ], ), ), diff --git a/lib/screens/profile/components/references_screen.dart b/lib/screens/profile/components/references_screen.dart index 1f53c27..a9731fe 100644 --- a/lib/screens/profile/components/references_screen.dart +++ b/lib/screens/profile/components/references_screen.dart @@ -71,6 +71,7 @@ class ReferencesScreen extends StatelessWidget { return BlocConsumer( //listener listener: (context, state) { + print(state); if (state is ReferencesLoadingState) { final progress = ProgressHUD.of(context); progress!.showWithText("Please wait..."); diff --git a/lib/screens/profile/components/voluntary_works/edit_modal.dart b/lib/screens/profile/components/voluntary_works/edit_modal.dart index 4ea1a6a..b841bda 100644 --- a/lib/screens/profile/components/voluntary_works/edit_modal.dart +++ b/lib/screens/profile/components/voluntary_works/edit_modal.dart @@ -578,6 +578,11 @@ class _EditVoluntaryWorkScreenState extends State { selectedRegion! .code .toString()); + }catch(e){ + context + .read() + .add(ShowErrorState(message: e.toString())); + } selectedProvince = provinces![0]; setState(() { @@ -606,14 +611,7 @@ class _EditVoluntaryWorkScreenState extends State { message: e .toString())); } - } catch (e) { - context - .read< - VoluntaryWorkBloc>() - .add(ShowErrorState( - message: e - .toString())); - } + } }, value: selectedRegion, diff --git a/lib/screens/profile/components/voluntary_works_screen.dart b/lib/screens/profile/components/voluntary_works_screen.dart index 4544fe5..c52dece 100644 --- a/lib/screens/profile/components/voluntary_works_screen.dart +++ b/lib/screens/profile/components/voluntary_works_screen.dart @@ -268,7 +268,8 @@ class VolunataryWorkScreen extends StatelessWidget { icon: Icons.edit), popMenuItem( text: "Remove", - value: 2,) + value: 2, + icon: Icons.delete) ], diff --git a/lib/screens/sos/components/add_mobile.dart b/lib/screens/sos/components/add_mobile.dart index 3025e92..cb2ec9b 100644 --- a/lib/screens/sos/components/add_mobile.dart +++ b/lib/screens/sos/components/add_mobile.dart @@ -36,16 +36,13 @@ class AddMobile extends StatelessWidget { Container( height: screenHeight, padding: isMobile() - ? const EdgeInsets.symmetric(horizontal: 24) + ? const EdgeInsets.symmetric(horizontal: 60) : const EdgeInsets.symmetric(horizontal: 60), width: double.infinity, child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - SizedBox( - height: isMobile() - ? screenHeight * .12 - : screenHeight * .20), + const SizedBox(height: 100,), SvgPicture.asset( 'assets/svgs/add_mobile.svg', height: isMobile() @@ -56,13 +53,13 @@ class AddMobile extends StatelessWidget { const SizedBox( height: 24, ), - Text(addMobile, style: titleTextStyle()), + Text(addMobile,textAlign: TextAlign.center, style: titleTextStyle()), const SizedBox( height: 8, ), Text(addMobileCaption, textAlign: TextAlign.center, - style: Theme.of(context).textTheme.caption), + style: Theme.of(context).textTheme.bodySmall), const SizedBox( height: 24, ), @@ -78,9 +75,7 @@ class AddMobile extends StatelessWidget { maxLength: 11, decoration: normalTextFieldStyle(mobile1, "09")), - const SizedBox( - height: 12, - ), + //// Mobile number 2 FormBuilderTextField( autovalidateMode: AutovalidateMode.onUserInteraction, @@ -89,10 +84,7 @@ class AddMobile extends StatelessWidget { decoration: normalTextFieldStyle(mobile2, "09")), - SizedBox( - height: isMobile() - ? blockSizeVertical * 3 - : blockSizeHorizontal * 5), + const SizedBox(height: 30,), SizedBox( width: double.infinity, height: screenHeight * .06, diff --git a/lib/screens/sos/components/request_sos.dart b/lib/screens/sos/components/request_sos.dart index 990de3e..a7510a6 100644 --- a/lib/screens/sos/components/request_sos.dart +++ b/lib/screens/sos/components/request_sos.dart @@ -40,7 +40,7 @@ class _RequestSOSState extends State { return SingleChildScrollView( child: Container( height: screenHeight * .82, - padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 10), + padding: const EdgeInsets.symmetric(horizontal: 42, vertical: 10), child: FormBuilder( key: formKey, child: Column( diff --git a/lib/screens/sos/index.dart b/lib/screens/sos/index.dart index f3bdb90..cb9dbcc 100644 --- a/lib/screens/sos/index.dart +++ b/lib/screens/sos/index.dart @@ -47,7 +47,7 @@ class _SosScreenState extends State { Widget build(BuildContext context) { return SafeArea( child: Scaffold( - appBar: AppBar(backgroundColor: primary), + appBar: AppBar(title:const Text("SOS"),backgroundColor: primary,centerTitle: true,), resizeToAvoidBottomInset: true, body: ProgressHUD( padding: const EdgeInsets.all(32), diff --git a/lib/screens/unit2/basic-info/basic-info.dart b/lib/screens/unit2/basic-info/basic-info.dart index c16824a..2194b21 100644 --- a/lib/screens/unit2/basic-info/basic-info.dart +++ b/lib/screens/unit2/basic-info/basic-info.dart @@ -42,7 +42,7 @@ class BasicInfo extends StatelessWidget { children: [ const CoverImage(), Positioned( - top: blockSizeVertical * 17.5, + top: blockSizeVertical * 15.5, child: Stack( alignment: Alignment.center, children: [ @@ -115,8 +115,8 @@ class BuildInformation extends StatelessWidget { final String firstName = userData.user!.login!.user!.firstName!.toUpperCase(); final String lastname = userData.user!.login!.user!.lastName!.toUpperCase(); - final String middlename = - userData.employeeInfo!.profile!.middleName!.toUpperCase(); + final String? middlename = userData.employeeInfo == null?'': + userData.employeeInfo!.profile?.middleName?.toUpperCase(); final String sex = userData.employeeInfo!.profile!.sex!.toUpperCase(); final DateTime? bday = userData.employeeInfo!.profile!.birthdate; final uuid = userData.employeeInfo!.uuid; @@ -129,11 +129,11 @@ class BuildInformation extends StatelessWidget { height: 25, ), Text( - "$firstName $middlename $lastname", + "$firstName ${middlename??''} $lastname", textAlign: TextAlign.center, style: Theme.of(context) .textTheme - .headline5! + .headlineSmall! .copyWith(fontWeight: FontWeight.bold), ), const SizedBox( @@ -141,7 +141,7 @@ class BuildInformation extends StatelessWidget { ), Text( "${dteFormat2.format(bday!)} | $sex", - style: Theme.of(context).textTheme.caption!.copyWith(fontSize: 18), + style: Theme.of(context).textTheme.bodySmall!.copyWith(fontSize: 18), ), const SizedBox( height: 15, @@ -162,7 +162,7 @@ class BuildInformation extends StatelessWidget { mainBtnStyle(third, Colors.transparent, Colors.white54), onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){ - return SignaturePad(); + return const SignaturePad(); })); }, icon: const Icon( diff --git a/lib/screens/unit2/homepage.dart/components/dashboard.dart b/lib/screens/unit2/homepage.dart/components/dashboard.dart index 13bec9e..e1056ac 100644 --- a/lib/screens/unit2/homepage.dart/components/dashboard.dart +++ b/lib/screens/unit2/homepage.dart/components/dashboard.dart @@ -1,20 +1,18 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:fluttericon/font_awesome5_icons.dart'; -import 'package:unit2/screens/docsms/components/request_receipt.dart'; import 'package:unit2/screens/docsms/index.dart'; import 'package:unit2/screens/unit2/homepage.dart/module-screen.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/utils/global.dart'; import 'package:unit2/utils/global_context.dart'; import 'package:unit2/utils/qr_scanner.dart'; -import 'package:unit2/utils/text_container.dart'; - import '../../../../bloc/docsms/docsms_bloc.dart'; class DashBoard extends StatelessWidget { final List roles; - const DashBoard({super.key, required this.roles}); + final int userId; + const DashBoard({super.key, required this.roles,required this.userId}); @override Widget build(BuildContext context) { List finishRoles = []; @@ -27,6 +25,7 @@ class DashBoard extends StatelessWidget { shrinkWrap: true, itemCount: roles.length, itemBuilder: (BuildContext context, int index) { + //// gridview.count return roles[index].roles.isNotEmpty ? SizedBox( @@ -53,25 +52,21 @@ class DashBoard extends StatelessWidget { padding: const EdgeInsets.symmetric( vertical: 5, horizontal: 5), children: roles[index].roles.map((role) { - //// if role name is qr code && finishRoles not contain security - //// this card will visible if the user has qr code scanner or security roleπurls if (role.role.name!.toLowerCase() == 'qr code scanner' && !finishRoles.contains("security")) { + print("1 true"); finishRoles.add('scanner'); - //// loop thru module to find unit module exist for (var element in role.role.modules!) { if (element!.name!.toLowerCase() == 'unit2') { for (var element in element.objects!) { - //// loop thru objects to find pass check exist - if (element!.id == 9 && - //// check if operations contains read and write + if (element!.id == 9 && element.operations! .contains("read")) { - //// if all conditions are true return card return CardLabel( ontap: () { - Navigator.pushNamed(context, '/pass-check'); + PassCheckArguments passCheckArguments = PassCheckArguments(roleId: role.role.id!, userId: userId); + Navigator.pushNamed(context, '/pass-check',arguments: passCheckArguments); }, icon: role.icon, title: "Pass Check", @@ -81,11 +76,10 @@ class DashBoard extends StatelessWidget { } } return Container(); - //// if role name is security - //// this card will visible if the user has qr code scanner or security role } else if (role.role.name!.toLowerCase() == 'security guard' && !finishRoles.contains('scanner')) { + print("2 true"); finishRoles.add('security'); for (var element in role.role.modules!) { if (element!.name!.toLowerCase() == 'unit2') { @@ -102,10 +96,10 @@ class DashBoard extends StatelessWidget { } } } - return Container(); - //// if role name is field surveyor + return Container(color: Colors.red,); } else if (role.role.name!.toLowerCase() == 'field surveyor') { + print("3 true"); for (var element in role.role.modules!) { if (element!.name!.toLowerCase() == 'rpass') { for (var element in element.objects!) { @@ -122,9 +116,9 @@ class DashBoard extends StatelessWidget { } } return Container(); - //// if role name is process server } else if (role.role.name!.toLowerCase() == 'process server') { + print("4 true"); for (var element in role.role.modules!) { if (element!.name!.toLowerCase() == 'document management') { @@ -158,15 +152,16 @@ class DashBoard extends StatelessWidget { } return Container(); } else if (role.role.name!.toLowerCase() == - 'establishment point person' && + 'establishment point-person' && !finishRoles.contains('superadmin')) { - finishRoles.add('establishment point person'); + finishRoles.add('establishment point-person'); for (var element in role.role.modules!) { + print("5 true"); if (element!.name!.toLowerCase() == 'unit2') { for (var element in element.objects!) { - if (element!.id == 9 && + if (element!.id == 7 && element.operations! - .contains("read")) { + .contains("upload")) { return CardLabel( ontap: () {}, icon: FontAwesome5.building, @@ -177,13 +172,33 @@ class DashBoard extends StatelessWidget { } } return Container(); - //// if role name is field surveyor - } - - - else { + + } else if (role.role.name!.toLowerCase() == + 'establishment point-person' && + !finishRoles.contains('superadmin')) { + finishRoles.add('establishment point-person'); + for (var element in role.role.modules!) { + if (element!.name!.toLowerCase() == 'unit2') { + for (var element in element.objects!) { + if (element!.id == 7 && + element.operations! + .contains("upload")) { + return CardLabel( + ontap: () {}, + icon: FontAwesome5.building, + title: "Establishment", + ); + } + } + } + } return Container(); + + } else{ + return Wrap(); } + + }).toList()), const SizedBox( height: 8, @@ -197,6 +212,12 @@ class DashBoard extends StatelessWidget { } } +class PassCheckArguments{ + final int roleId; + final int userId; + const PassCheckArguments({required this.roleId, required this.userId}); +} + // ignore: must_be_immutable class CardLabel extends StatelessWidget { final String title; diff --git a/lib/screens/unit2/homepage.dart/components/menu-screen.dart b/lib/screens/unit2/homepage.dart/components/menu-screen.dart index b9cedc2..0b712e3 100644 --- a/lib/screens/unit2/homepage.dart/components/menu-screen.dart +++ b/lib/screens/unit2/homepage.dart/components/menu-screen.dart @@ -27,50 +27,50 @@ class _MenuScreenState extends State { child: Column( mainAxisSize: MainAxisSize.max, children: [ - Flexible( - child: ListView( - // ignore: prefer_const_literals_to_create_immutables - children: [ - UserAccountsDrawerHeader( - decoration: const BoxDecoration( - color: primary, - image: DecorationImage( - image: AssetImage('assets/pngs/bg.png'), - fit: BoxFit.cover)), - accountName: Text("$firstName $lastname"), - accountEmail: null, - currentAccountPicture: CircleAvatar( - radius: 40, - backgroundColor: fifth, - child: CircleAvatar( - radius: 33, - backgroundColor: third, - child: //Icon(Icons.person, size: 40, color: fifth), - Text( - firstName[0].toUpperCase(), - style: const TextStyle(fontSize: 45.0, color: fifth), - ), + Column( + // ignore: prefer_const_literals_to_create_immutables + children: [ + UserAccountsDrawerHeader( + decoration: const BoxDecoration( + color: primary, + image: DecorationImage( + image: AssetImage('assets/pngs/bg.png'), + fit: BoxFit.cover)), + accountName: Text("$firstName $lastname"), + accountEmail: null, + currentAccountPicture: CircleAvatar( + radius: 40, + backgroundColor: fifth, + child: CircleAvatar( + radius: 33, + backgroundColor: third, + child: //Icon(Icons.person, size: 40, color: fifth), + Text( + firstName[0].toUpperCase(), + style: const TextStyle(fontSize: 45.0, color: fifth), ), ), ), - getTile(FontAwesome5.user, "Basic Info", '/basic-info', context, - widget.userData!), - const Divider(), - getTile(FontAwesome5.user_circle, "Profile", - '/profile', context, widget.userData!), - const Divider(), - getTile(FontAwesome5.life_ring, "Request SOS", '/sos', - context, widget.userData!), - - ], - ), + ), + getTile(FontAwesome5.user, "Basic Info", '/basic-info', context, + widget.userData!), + const Divider(), + getTile(FontAwesome5.user_circle, "Profile", + '/profile', context, widget.userData!), + const Divider(), + getTile(FontAwesome5.life_ring, "Request SOS", '/sos', + context, widget.userData!), + + ], ), + const Expanded(child: SizedBox()), const Divider(), Align( alignment: FractionalOffset.bottomLeft, child: getTile(WebSymbols.logout, "Logout", '/', context, widget.userData!), ), + const SizedBox(height: 10,), ], ), ), diff --git a/lib/screens/unit2/homepage.dart/components/menu.dart b/lib/screens/unit2/homepage.dart/components/menu.dart index 6288a3f..abb12bc 100644 --- a/lib/screens/unit2/homepage.dart/components/menu.dart +++ b/lib/screens/unit2/homepage.dart/components/menu.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:unit2/model/login_data/employee_info/employee_info.dart'; import 'package:unit2/model/login_data/user_info/user_data.dart'; import 'package:unit2/utils/alerts.dart'; -import '../../../../model/profile/basic_information/primary-information.dart'; +import 'package:unit2/utils/global_context.dart'; import '../../../../theme-data.dart/colors.dart'; import '../../../../utils/global.dart'; @@ -23,7 +22,7 @@ Widget getTile( confirmAlert(context, () async{ await CREDENTIALS!.clear(); await CREDENTIALS!.deleteAll(['username','password','saved']); - Navigator.pushReplacementNamed (context,"/"); + Navigator.pushReplacementNamed (NavigationService.navigatorKey.currentContext!,"/"); },"Logout","Are You sure you want to logout?"); }if(title.toLowerCase() == 'profile'){ ProfileArguments profileArguments = ProfileArguments(token: userData.user!.login!.token!, userID:userData.user!.login!.user!.profileId!); diff --git a/lib/screens/unit2/homepage.dart/module-screen.dart b/lib/screens/unit2/homepage.dart/module-screen.dart index aef990f..e8a9585 100644 --- a/lib/screens/unit2/homepage.dart/module-screen.dart +++ b/lib/screens/unit2/homepage.dart/module-screen.dart @@ -25,6 +25,7 @@ class _MainScreenState extends State { Module(name: 'DocSms module operations', roles: []), Module(name: "RPAss module operations",roles:[] ) ]; + int? userId; @override Widget build(BuildContext context) { return WillPopScope( @@ -33,6 +34,7 @@ class _MainScreenState extends State { }, child: BlocBuilder(builder: (context, state) { if (state is UserLoggedIn) { + userId = state.userData!.user!.login!.user!.id; for (var element in roles) { element.roles.clear(); } @@ -78,6 +80,7 @@ class _MainScreenState extends State { ), body: state.userData!.user!.login!.user!.roles!.isNotEmpty ? DashBoard( + userId: userId!, roles: roles, ) : const NoModule(), diff --git a/lib/screens/unit2/login/login.dart b/lib/screens/unit2/login/login.dart index 164a5c3..c0a0c03 100644 --- a/lib/screens/unit2/login/login.dart +++ b/lib/screens/unit2/login/login.dart @@ -273,7 +273,7 @@ class _UniT2LoginState extends State { SizedBox( height: blockSizeVertical * 1.5, ), - +//// Login via Scan QR SizedBox( height: blockSizeVertical * 7, child: SizedBox( @@ -367,6 +367,16 @@ class _UniT2LoginState extends State { if (state is SplashScreen) { return const UniTSplashScreen(); } + if(state is LoginErrorState){ + return SomethingWentWrong(message: state.message, onpressed: () { + BlocProvider.of( + NavigationService.navigatorKey.currentContext!) + .add(GetApkVersion()); + return MaterialPageRoute(builder: (_) { + return const UniT2Login(); + }); + },); + } return Container(); }), ), diff --git a/lib/screens/unit2/login/qr_login.dart b/lib/screens/unit2/login/qr_login.dart index 344b2bd..9fd52c5 100644 --- a/lib/screens/unit2/login/qr_login.dart +++ b/lib/screens/unit2/login/qr_login.dart @@ -15,8 +15,10 @@ import '../../../theme-data.dart/colors.dart'; import '../../../theme-data.dart/form-style.dart'; import '../../../utils/alerts.dart'; import '../../../utils/global.dart'; +import '../../../utils/internet_time_out.dart'; import '../../../utils/text_container.dart'; import '../../../utils/validators.dart'; +import '../../../widgets/error_state.dart'; class QRLogin extends StatefulWidget { const QRLogin({super.key}); @@ -96,7 +98,7 @@ class _QRLoginState extends State { bottom: 0, child: WaveReverse(height: blockSizeVertical * 8)), Container( - height: screenHeight * .90, + height: screenHeight * .87, padding: const EdgeInsets.symmetric(horizontal: 32), child: FormBuilder( key: _formKey, @@ -221,7 +223,23 @@ class _QRLoginState extends State { ], ), ); - } + } if (state is InternetTimeout) { + return SomethingWentWrong(message: state.message, onpressed: () { + context + .read() + .add(LoadUuid()); + Navigator.of(context).pop(); + },); + } + + if(state is LoginErrorState){ + return SomethingWentWrong(message: state.message, onpressed: () { + context + .read() + .add(LoadUuid()); + Navigator.of(context).pop(); + },); + } return Container(); }, ), diff --git a/lib/screens/unit2/roles/qr_code_scanner.dart/scan.dart b/lib/screens/unit2/roles/qr_code_scanner.dart/scan.dart index 8a26cb8..5e25ab4 100644 --- a/lib/screens/unit2/roles/qr_code_scanner.dart/scan.dart +++ b/lib/screens/unit2/roles/qr_code_scanner.dart/scan.dart @@ -1,148 +1,360 @@ +import 'package:assets_audio_player/assets_audio_player.dart'; +import 'package:audioplayers/audioplayers.dart'; +import 'package:cool_alert/cool_alert.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:fluttericon/entypo_icons.dart'; +import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:unit2/bloc/role/pass_check/pass_check_bloc.dart'; +import 'package:unit2/theme-data.dart/btn-style.dart'; +import 'package:unit2/theme-data.dart/form-style.dart'; import 'package:unit2/utils/text_container.dart'; - +import 'package:unit2/utils/validators.dart'; +import 'package:unit2/widgets/error_state.dart'; import '../../../../theme-data.dart/colors.dart'; import '../../../../utils/global.dart'; import 'components/save_settings.dart'; -class QRCodeScanner extends StatelessWidget { +class QRCodeScanner extends StatefulWidget { const QRCodeScanner({super.key}); + @override + State createState() => _QRCodeScannerState(); +} + +final GlobalKey scaffoldKey = GlobalKey(); +final formKey = GlobalKey(); +AudioPlayer? player; + +class _QRCodeScannerState extends State { + @override + void initState() { + player = AudioPlayer(); + super.initState(); + } + @override + void dispose() { + player?.dispose(); + super.dispose(); + } + + @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: const Text(qrScannerTitle), - centerTitle: true, - backgroundColor: primary, + key: scaffoldKey, + appBar: AppBar( + title: const Text(qrScannerTitle), + centerTitle: true, + backgroundColor: primary, + ), + body: ProgressHUD( + padding: const EdgeInsets.all(24), + indicatorWidget: const SpinKitFadingCircle( + color: Colors.white, ), - body: SizedBox( - height: screenHeight * 100, - width: double.infinity, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - const SizedBox( - height: 40, - ), - GestureDetector( - onTap: () {}, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - height: 160, - child: Image.asset('assets/pngs/qr-scan.png')), - const SizedBox( - height: 8, - ), - Text( - tapToScanQR, - textAlign: TextAlign.center, - style: Theme.of(context) - .textTheme - .displayMedium! - .copyWith( - fontSize: 22, - color: primary, - fontWeight: FontWeight.bold), - ), - const SizedBox( - height: 8, - ), - //TODO add API data - "INCOMING" == "INCOMING" - ? SizedBox( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - incoming, - textAlign: TextAlign.center, - style: Theme.of(context) - .textTheme - .displayMedium! - .copyWith( - fontSize: 20, - color: success2, - fontWeight: FontWeight.bold), - ), - const Icon( - Entypo.down_bold, - color: success2, - ) - ], + backgroundColor: Colors.black87, + child: BlocConsumer( + listener: (context, state) { + if (state is PassCheckLoadingState) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is SettingSaved || + state is IncomingScanState || + state is OutGoingScanState || + state is ScanSuccess || + state is ScanFailed || + state is PassCheckErrorState) { + final progress = ProgressHUD.of(context); + progress!.dismiss(); + } + if (state is ScanSuccess) { + Future.delayed(const Duration(seconds: 1), () async{ + await player?.play(AssetSource("success.mp3")); + }); + context.read().add(ScanQr(token: state.token)); + } + if (state is QRInvalid) { + Future.delayed(const Duration(seconds: 1), ()async { + await player?.play(AssetSource("invalid.mp3")); + }); + context.read().add(ScanQr(token: state.token)); + } + if (state is ScanFailed) { + Future.delayed(const Duration(seconds: 1), ()async { + await player?.play(AssetSource("fail.mp3")); + }); + + context.read().add(ScanQr(token: state.token)); + } + if (state is IncomingScanState) { + CoolAlert.show( + barrierDismissible: false, + context: context, + type: CoolAlertType.loading, + text: "Enter Temperature", + widget: Padding( + padding: const EdgeInsets.symmetric(horizontal: 24), + child: FormBuilder( + key: formKey, + child: Column( + children: [ + const SizedBox( + height: 24, ), - ) - : SizedBox( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - //TODO add API data - "INCOMING", - textAlign: TextAlign.center, - style: Theme.of(context) - .textTheme - .displayMedium! - .copyWith( - fontSize: 20, - color: second, - fontWeight: FontWeight.bold), - ), - const Icon( - Entypo.up_bold, - color: second, - ) - ], + FormBuilderTextField( + keyboardType: TextInputType.number, + name: "temp", + decoration: + normalTextFieldStyle("Temperature", ""), + validator: numericRequired), + const SizedBox( + height: 12, ), - ) - ], - ), - ), - Container( - padding: const EdgeInsets.only(top: 12), - decoration: const BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.black38, - blurRadius: 30, - offset: Offset(-5, 0), - ), - ], - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(15), - topRight: Radius.circular(15))), + SizedBox( + height: 50, + width: double.infinity, + child: ElevatedButton( + style: mainBtnStyle( + primary, Colors.transparent, second), + child: const Text(submit), + onPressed: () { + if (formKey.currentState!.saveAndValidate()) { + double temperature = double.parse( + formKey.currentState!.value['temp']); + context.read().add( + PerformIncomingPostLog( + temp: temperature)); + Navigator.of(context).pop(); + } + }, + ), + ) + ], + )), + )); + } + if (state is OutGoingScanState) { + CoolAlert.show( + barrierDismissible: false, + context: context, + type: CoolAlertType.loading, + text: "Enter Destination", + widget: Padding( + padding: const EdgeInsets.symmetric(horizontal: 24), + child: FormBuilder( + key: formKey, + child: Column( + children: [ + const SizedBox( + height: 24, + ), + FormBuilderTextField( + textCapitalization: + TextCapitalization.sentences, + name: "destination", + decoration: + normalTextFieldStyle("Destination", ""), + validator: FormBuilderValidators.required( + errorText: "This field is required")), + const SizedBox( + height: 12, + ), + SizedBox( + height: 50, + width: double.infinity, + child: ElevatedButton( + style: mainBtnStyle( + primary, Colors.transparent, second), + child: const Text(submit), + onPressed: () { + if (formKey.currentState!.saveAndValidate()) { + String destination = formKey + .currentState!.value['destination']; + context.read().add( + PerformOutgoingPostLog( + destination: destination)); + Navigator.of(context).pop(); + } + }, + ), + ) + ], + )), + )); + } + }, + builder: (context, state) { + if (state is SettingSaved) { + return SizedBox( + height: screenHeight * 100, width: double.infinity, child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: const [ - SelectedState( - //TODO add api data - - title: "Provincial Government of ADN", - subtitle: establishment, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const SizedBox( + height: 40, ), - Center( - child: SelectedState( - //TODO add api data - title: "Agusan Up", - subtitle: checkpointArea, + GestureDetector( + onTap: () {}, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + height: 160, + child: GestureDetector( + child: Image.asset('assets/pngs/qr-scan.png'), + onTap: () { + context + .read() + .add(ScanQr(token: state.token)); + })), + const SizedBox( + height: 8, + ), + Text( + tapToScanQR, + textAlign: TextAlign.center, + style: Theme.of(context) + .textTheme + .displayMedium! + .copyWith( + fontSize: 22, + color: primary, + fontWeight: FontWeight.bold), + ), + const SizedBox( + height: 8, + ), + //TODO add API data + state.io == "INCOMING" + ? SizedBox( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + incoming, + textAlign: TextAlign.center, + style: Theme.of(context) + .textTheme + .displayMedium! + .copyWith( + fontSize: 20, + color: success2, + fontWeight: FontWeight.bold), + ), + const Icon( + Entypo.down_bold, + color: success2, + ) + ], + ), + ) + : SizedBox( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "OUTGOING", + textAlign: TextAlign.center, + style: Theme.of(context) + .textTheme + .displayMedium! + .copyWith( + fontSize: 20, + color: second, + fontWeight: FontWeight.bold), + ), + const Icon( + Entypo.up_bold, + color: second, + ) + ], + ), + ) + ], ), ), - SelectedState( - //TODO add api data - title: "INCOMING", - subtitle: scanMode, - ), + Container( + padding: const EdgeInsets.only(top: 12), + decoration: const BoxDecoration( + boxShadow: [ + BoxShadow( + color: Colors.black38, + blurRadius: 30, + offset: Offset(-5, 0), + ), + ], + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(15), + topRight: Radius.circular(15))), + width: double.infinity, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SelectedState( + //TODO add api data + title: state.roleId == 41 || + state.roleId == 13 || + state.roleId == 17 || + state.roleId == 22 + ? state.assignedArea.stationName + : state.roleId == 7 + ? state.assignedArea.brgydesc + : state.roleId == 10 + ? state.assignedArea.purokdesc + : state.roleId == 16 + ? "Agency" + : "", + subtitle: state.roleId == 41 || + state.roleId == 13 || + state.roleId == 17 || + state.roleId == 22 + ? "Station" + : state.roleId == 7 + ? "Barangay" + : state.roleId == 10 + ? "Purok" + : state.roleId == 16 + ? "Agency" + : "", + ), + SelectedState( + //TODO add api data + + title: state.otherInputs ? "YES" : "NO", + subtitle: "Include other inputs", + ), + const SizedBox( + height: 54, + ), + ], + ), + ), + ) ], ), - ) - ], - ), - )); + ); + } + if (state is PassCheckErrorState) { + return SomethingWentWrong( + message: state.message, + onpressed: () { + context.read().add(ScanError()); + }); + } + return Container(); + }, + ), + ), + ); } } diff --git a/lib/screens/unit2/roles/qr_code_scanner.dart/settings_screen.dart b/lib/screens/unit2/roles/qr_code_scanner.dart/settings_screen.dart index 3610217..19df2b5 100644 --- a/lib/screens/unit2/roles/qr_code_scanner.dart/settings_screen.dart +++ b/lib/screens/unit2/roles/qr_code_scanner.dart/settings_screen.dart @@ -1,19 +1,28 @@ import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_svg/svg.dart'; import 'package:fluttericon/entypo_icons.dart'; import 'package:fluttericon/modern_pictograms_icons.dart'; import 'package:form_builder_validators/form_builder_validators.dart'; +import 'package:unit2/bloc/role/pass_check/pass_check_bloc.dart'; +import 'package:unit2/bloc/user/user_bloc.dart'; +import 'package:unit2/screens/unit2/homepage.dart/components/dashboard.dart'; import 'package:unit2/screens/unit2/roles/qr_code_scanner.dart/components/custom_switch.dart'; -import 'package:unit2/test_data.dart'; +import 'package:unit2/screens/unit2/roles/qr_code_scanner.dart/scan.dart'; import 'package:unit2/utils/text_container.dart'; +import 'package:unit2/widgets/error_state.dart'; import '../../../../theme-data.dart/btn-style.dart'; import '../../../../theme-data.dart/colors.dart'; import '../../../../theme-data.dart/form-style.dart'; import '../../../../utils/global.dart'; class QRCodeScannerSettings extends StatefulWidget { - const QRCodeScannerSettings({super.key}); + final int roleId; + final int userId; + const QRCodeScannerSettings({super.key, required this.roleId, required this.userId}); @override State createState() => _QRCodeScannerSettingsState(); @@ -25,6 +34,9 @@ class _QRCodeScannerSettingsState extends State { String selectedLevel = ''; String selectedEstablishment = ''; String selectedArea = ''; + dynamic assignedArea; + int? checkerId; + String? token; final _formKey = GlobalKey(); @override Widget build(BuildContext context) { @@ -35,171 +47,584 @@ class _QRCodeScannerSettingsState extends State { centerTitle: true, backgroundColor: primary, ), - body: SingleChildScrollView( - child: Container( - height: screenHeight * .84, - padding: const EdgeInsets.symmetric(horizontal: 30,vertical: 10), - child: FormBuilder( - key: _formKey, - child: Column( - children: [ - const SizedBox( - height:24, - ), - SvgPicture.asset( - 'assets/svgs/switch.svg', - height: blockSizeVertical * 14, - allowDrawingOutsideViewBox: true, - ), - ListTile( - title: Text( - setQRScannerSettings, - style: Theme.of(context) - .textTheme - .titleLarge! - .copyWith(color: third), - textAlign: TextAlign.center, - ), - ), - Text(includeOtherInputs, - style: Theme.of(context).textTheme.titleMedium), - Text( - includeOtherInputsSubTitle, - style: Theme.of(context).textTheme.bodySmall, - ), - SizedBox( - child: FittedBox( - child: CostumToggleSwitch( - activeBGColors: [ - Colors.green[800]!, - Colors.red[800]! - ], - initialLabelIndex: _includeOtherInputs ? 0 : 1, - icons: const [Entypo.check, ModernPictograms.cancel], - labels: const ['YES', 'NO'], - onToggle: (value) { - value == 0 - ? _includeOtherInputs = true - : _includeOtherInputs = false; - }, - ), - ), - ), - // Incoming or outgoing - Text(incomingORoutgoing, - style: Theme.of(context).textTheme.titleMedium), - Text( - incomingORoutgoingSubTitle, - style: Theme.of(context).textTheme.bodySmall, - ), - FittedBox( - child: CostumToggleSwitch( - activeBGColors: [ Colors.red[800]!,Colors.green[800]!], - initialLabelIndex: scanMode == 'INCOMING' ? 0 : 1, - icons: const [ - Entypo.down_bold, - Entypo.up_bold, - ], - labels: const ['INCOMING', 'OUTGOING'], - onToggle: (value) { - value == 0 - ? scanMode = 'INCOMING' - : scanMode = 'OUTGOING'; - }, - ), - ), - const SizedBox( - height: 10, - ), + body: ProgressHUD( + padding: const EdgeInsets.all(24), + indicatorWidget: const SpinKitFadingCircle( + color: Colors.white, + ), + backgroundColor: Colors.black87, + child: BlocBuilder( + builder: (context, state) { + if (state is UserLoggedIn) { + token = state.userData!.user!.login!.token; + checkerId = state.userData!.user!.login!.user!.id; + return BlocConsumer( + listener: (context, state) { + if (state is PassCheckLoadingState) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is AssignAreaLoaded || + state is PassCheckErrorState) { + final progress = ProgressHUD.of(context); + progress!.dismiss(); + } + }, + builder: (context, state) { + if (state is AssignAreaLoaded) { + return Container( + height: screenHeight * .90, + padding: const EdgeInsets.symmetric( + horizontal: 42, vertical: 10), + child: FormBuilder( + key: _formKey, + child: Column( + children: [ + Flexible( + child: ListView( + children: [ + const SizedBox( + height: 32, + ), + SvgPicture.asset( + 'assets/svgs/switch.svg', + height: blockSizeVertical * 14, + allowDrawingOutsideViewBox: true, + ), + ListTile( + title: Text( + setQRScannerSettings, + style: Theme.of(context) + .textTheme + .titleLarge! + .copyWith(color: third), + textAlign: TextAlign.center, + ), + ), + Text(includeOtherInputs, + style: Theme.of(context) + .textTheme + .titleMedium), + Text( + includeOtherInputsSubTitle, + style: Theme.of(context) + .textTheme + .bodySmall, + ), + SizedBox( + child: FittedBox( + child: CostumToggleSwitch( + activeBGColors: [ + Colors.green[800]!, + Colors.red[800]! + ], + initialLabelIndex: + _includeOtherInputs ? 0 : 1, + icons: const [ + Entypo.check, + ModernPictograms.cancel + ], + labels: const ['YES', 'NO'], + onToggle: (value) { + value == 0 + ? _includeOtherInputs = true + : _includeOtherInputs = false; + }, + ), + ), + ), + // Incoming or outgoing + Text(incomingORoutgoing, + style: Theme.of(context) + .textTheme + .titleMedium), + Text( + incomingORoutgoingSubTitle, + style: Theme.of(context) + .textTheme + .bodySmall, + ), + FittedBox( + child: CostumToggleSwitch( + activeBGColors: [ + Colors.red[800]!, + Colors.green[800]! + ], + initialLabelIndex: + scanMode == 'INCOMING' ? 0 : 1, + icons: const [ + Entypo.down_bold, + Entypo.up_bold, + ], + labels: const [ + 'INCOMING', + 'OUTGOING' + ], + onToggle: (value) { + value == 0 + ? scanMode = 'INCOMING' + : scanMode = 'OUTGOING'; + }, + ), + ), + const SizedBox( + height: 24, + ), - //SELECT LEVEL - - FormBuilderDropdown( - name: 'level', - validator: FormBuilderValidators.required( - errorText: fieldIsRequired), - decoration: normalTextFieldStyle(selectLevel, "level"), - items: levels - .map((level) => DropdownMenuItem( - value: level, - child: Text(level), - )) - .toList(), - // value: selectedLevel, - onChanged: (value) async { - selectedLevel = value!; - }, - ), - - const SizedBox( - height: 8, - ), - - FormBuilderDropdown( - name: 'establishment', - decoration: normalTextFieldStyle( - selectedEstablishment, "establishments"), - isExpanded: true, - validator: FormBuilderValidators.required( - errorText: fieldIsRequired), - items: establishments - .map((est) => DropdownMenuItem( - value: est, - child: Text(est), - )) - .toList(), - // value: selectedArea, - onChanged: (value) async { - selectedArea = value!; - }), - const SizedBox( - height: 8, - ), - DropdownButtonFormField( - decoration: normalTextFieldStyle( - selectEstablishment, "establishments"), - isExpanded: true, - items: establishments - .map((est) => DropdownMenuItem( - value: est, - child: Text(est), - )) - .toList(), - // value: selectedArea, - onChanged: (value) async { - selectedArea = value!; - }), - const Expanded( - child: SizedBox(), - ), - SizedBox( - width: double.infinity, - height: 60, - child: ElevatedButton( - style: mainBtnStyle( - primary, Colors.transparent, Colors.white54), - child: const Text( - submit, - style: TextStyle(color: Colors.white), - ), - onPressed: () { - // if (_formKey.currentState.validate()) { - // _formKey.currentState.save(); - // BlocProvider.of(context) - // .add(UserWebLogin( - // password: password, - // username: username)); - // } - }, - ), - ), - - const SizedBox( - height: 8, - ), - ], - ), - ), + ////STATION + Container( + child: state.roleId == 41 + ? DropdownButtonFormField( + isExpanded: true, + validator: FormBuilderValidators + .required( + errorText: + fieldIsRequired), + decoration: + normalTextFieldStyle( + "station", "station"), + items: state.assignedArea + .map((station) { + if (station.motherStation) { + return DropdownMenuItem< + dynamic>( + enabled: false, + value: station, + child: Text( + station.stationName + .toUpperCase(), + style: + const TextStyle( + color: Colors + .grey), + ), + ); + } else { + return DropdownMenuItem< + dynamic>( + value: station, + child: Padding( + padding: + const EdgeInsets + .only( + left: 10), + child: Text(station + .stationName), + ), + ); + } + }).toList(), + // value: selectedLevel, + onChanged: (value) async { + assignedArea = value; + }, + ////BARANGAY + ) + : state.roleId == 7 + ? Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text( + "Select Barangay", + textAlign: + TextAlign.start, + style: + Theme.of(context) + .textTheme + .titleMedium, + ), + const SizedBox( + height: 12, + ), + DropdownButtonFormField( + isExpanded: true, + decoration: + normalTextFieldStyle( + "Barangay", + "Barangay"), + items: state + .assignedArea + .map((barangay) { + return DropdownMenuItem< + dynamic>( + value: barangay, + child: Padding( + padding: + const EdgeInsets + .only( + left: + 5), + child: Text( + barangay + .brgydesc), + ), + ); + }).toList(), + onChanged: (value) { + assignedArea = + value; + }, + ), + ], + ) + : + ////PUROK + state.roleId == 10 + ? Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text( + "Select Purok", + textAlign: + TextAlign + .start, + style: Theme.of( + context) + .textTheme + .titleMedium, + ), + const SizedBox( + height: 12, + ), + DropdownButtonFormField( + isExpanded: true, + decoration: + normalTextFieldStyle( + "Purok", + "Purok"), + items: state + .assignedArea + .map((purok) { + return DropdownMenuItem< + dynamic>( + value: purok, + child: + Padding( + padding: const EdgeInsets + .only( + left: + 5), + child: Text( + purok + .purokdesc), + ), + ); + }).toList(), + onChanged: + (value) { + assignedArea = + value; + }, + ), + ], + ) + : + ////Registration InCharge + state.roleId == 22 + ? Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text( + "Select Station", + textAlign: + TextAlign + .start, + style: Theme.of( + context) + .textTheme + .titleMedium, + ), + const SizedBox( + height: 12, + ), + DropdownButtonFormField( + isExpanded: + true, + validator: FormBuilderValidators + .required( + errorText: + fieldIsRequired), + decoration: normalTextFieldStyle( + "station", + "station"), + items: state + .assignedArea + .map( + (station) { + if (station + .motherStation) { + return DropdownMenuItem< + dynamic>( + enabled: + false, + value: + station, + child: + Text( + station + .stationName + .toUpperCase(), + style: + const TextStyle(color: Colors.grey), + ), + ); + } else { + return DropdownMenuItem< + dynamic>( + value: + station, + child: + Padding( + padding: + const EdgeInsets.only(left: 5), + child: + Text(station.stationName), + ), + ); + } + }).toList(), + // value: selectedLevel, + onChanged: + (value) async { + assignedArea = + value; + }, + ), + ], + ) + : ////QR Code Scanner + state.roleId == 13 + ? Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text( + "Select Station", + textAlign: + TextAlign + .start, + style: Theme.of( + context) + .textTheme + .titleMedium, + ), + const SizedBox( + height: + 12, + ), + DropdownButtonFormField( + isExpanded: + true, + validator: + FormBuilderValidators.required( + errorText: fieldIsRequired), + decoration: normalTextFieldStyle( + "station", + "station"), + items: state + .assignedArea + .map( + (station) { + if (station + .motherStation) { + return DropdownMenuItem< + dynamic>( + enabled: + false, + value: + station, + child: + Text( + station.stationName.toUpperCase(), + style: const TextStyle(color: Colors.grey), + ), + ); + } else { + return DropdownMenuItem< + dynamic>( + value: + station, + child: + Padding( + padding: const EdgeInsets.only(left: 5), + child: Text(station.stationName), + ), + ); + } + }).toList(), + // value: selectedLevel, + onChanged: + (value) async { + assignedArea = + value; + }, + ), + ], + ) + : + ////Establishment Point-Person + state.roleId == 16 + ? Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text( + "Select Agency", + textAlign: + TextAlign.start, + style: Theme.of(context) + .textTheme + .titleMedium, + ), + const SizedBox( + height: + 12, + ), + DropdownButtonFormField( + isExpanded: + true, + validator: + FormBuilderValidators.required(errorText: fieldIsRequired), + decoration: normalTextFieldStyle( + "Agency", + "Agency"), + items: state + .assignedArea + .map((agency) { + return DropdownMenuItem( + value: agency, + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Text(agency.area.name), + ), + ); + }).toList(), + // value: selectedLevel, + onChanged: + (value) async { + assignedArea = + value; + }, + ), + ], + ) + : ////Office Branch Chief + state.roleId == + 17 + ? Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + "Select Station", + textAlign: TextAlign.start, + style: Theme.of(context).textTheme.titleMedium, + ), + const SizedBox( + height: 12, + ), + DropdownButtonFormField( + isExpanded: true, + validator: FormBuilderValidators.required(errorText: fieldIsRequired), + decoration: normalTextFieldStyle("station", "station"), + items: state.assignedArea.map((station) { + if (station.motherStation) { + return DropdownMenuItem( + enabled: false, + value: station, + child: Text( + station.stationName.toUpperCase(), + style: const TextStyle(color: Colors.grey), + ), + ); + } else { + return DropdownMenuItem( + value: station, + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Text(station.stationName), + ), + ); + } + }).toList(), + // value: selectedLevel, + onChanged: (value) async { + assignedArea = value; + }, + ), + ], + ) + : Container()) + ], + ), + ), + SizedBox( + width: double.infinity, + height: 60, + child: ElevatedButton( + style: mainBtnStyle(primary, + Colors.transparent, Colors.white54), + child: const Text( + submit, + style: TextStyle(color: Colors.white), + ), + onPressed: () { + if (_formKey.currentState! + .saveAndValidate()) { + print(scanMode); + print(_includeOtherInputs); + print(checkerId); + print(assignedArea); + Navigator.push(context, + MaterialPageRoute(builder: + (BuildContext context) { + return BlocProvider< + PassCheckBloc>.value( + value: PassCheckBloc() + ..add(SetScannerSettings( + token: token!, + assignedArea: assignedArea, + checkerId: checkerId!, + entranceExit: scanMode, + includeOtherInputs: + _includeOtherInputs, + roleId: state.roleId)), + child: const QRCodeScanner(), + ); + })); + } + }, + ), + ), + const SizedBox( + height: 52, + ), + ], + ), + ), + ); + } + if (state is PassCheckErrorState) { + return SomethingWentWrong( + message: state.message, onpressed: () { + + context.read().add(GetPassCheckAreas(roleId: widget.roleId, userId: widget.userId)); + }); + } + return Container(); + }, + ); + } + return Container(); + }, ), )), ); diff --git a/lib/sevices/profile/address_service.dart b/lib/sevices/profile/address_service.dart index 5e0478b..cded751 100644 --- a/lib/sevices/profile/address_service.dart +++ b/lib/sevices/profile/address_service.dart @@ -1,7 +1,5 @@ import 'dart:convert'; -import 'package:unit2/theme-data.dart/colors.dart'; - import '../../model/profile/basic_information/adress.dart'; import '../../utils/request.dart'; import '../../utils/urls.dart'; @@ -123,7 +121,7 @@ class AddressService { try { http.Response response = await http.patch( Uri.parse( - 'http://${Url.instance.host()}${Url.instance.addressPath()}$profileId/'), + 'https://${Url.instance.host()}${Url.instance.addressPath()}$profileId/'), headers: headers, body: jsonEncode({ "id": address.id, diff --git a/lib/sevices/profile/profile_service.dart b/lib/sevices/profile/profile_service.dart index 1ed39fb..af057b1 100644 --- a/lib/sevices/profile/profile_service.dart +++ b/lib/sevices/profile/profile_service.dart @@ -106,7 +106,7 @@ class ProfileService { Map body = { "profile_id": profileId, "first_name": profileInfo.firstName, - "middle_name": profileInfo.middleName, + "middle_name": profileInfo.middleName!.isEmpty?null:profileInfo.middleName, "last_name": profileInfo.lastName, "name_extension": profileInfo.nameExtension, "birthdate": profileInfo.birthdate.toString(), diff --git a/lib/sevices/roles/pass_check_services.dart b/lib/sevices/roles/pass_check_services.dart new file mode 100644 index 0000000..3b076a6 --- /dev/null +++ b/lib/sevices/roles/pass_check_services.dart @@ -0,0 +1,265 @@ +import 'dart:convert'; +import 'dart:io'; +import 'package:audioplayers/audioplayers.dart'; +import 'package:flutter/services.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:unit2/model/location/barangay.dart'; +import 'package:unit2/model/roles/pass_check/agency_area_type.dart'; +import 'package:unit2/model/roles/pass_check/assign_role_area_type.dart'; +import 'package:unit2/model/roles/pass_check/barangay_assign_area.dart'; +import 'package:unit2/model/roles/pass_check/passer_info.dart'; +import 'package:unit2/utils/global.dart'; +import 'package:http/http.dart' as http; +import 'package:unit2/utils/request.dart'; +import '../../model/roles/pass_check/purok_assign_area.dart'; +import '../../model/roles/pass_check/station_assign_area.dart'; +import '../../utils/urls.dart'; + +class PassCheckServices { + static final PassCheckServices _instance = PassCheckServices(); + static PassCheckServices get instance => _instance; + + Future> getPassCheckArea( + {required int roleId, required int userId}) async { + String path = Url.instance.getAssignAreas(); + Map params = { + "assigned_role__role__id": roleId.toString(), + "assigned_role__user__id": userId.toString() + }; + List? statusResponse; + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientSecret + }; + try { + http.Response response = await Request.instance + .getRequest(param: params, headers: headers, path: path); + if (response.statusCode == 200) { + Map data = jsonDecode(response.body); + AssignRoleAreaType assignRoleAreaType = AssignRoleAreaType.fromJson( + data['data'][0]['assigned_role_area_type']); + ////station + if (assignRoleAreaType.areaTypeName.toLowerCase() == "station") { + List assignedArea = []; + data['data'][0]['assigned_area'].forEach((element) { + StationAssignArea stationAssignArea = + StationAssignArea.fromJson(element); + ChildStationInfo headStation = ChildStationInfo( + id: stationAssignArea.area!.id, + stationName: stationAssignArea.area!.stationName, + acroym: stationAssignArea.area!.acronym, + motherStation: true); + ChildStationInfo childStationInfo = ChildStationInfo( + id: stationAssignArea.area!.id, + stationName: stationAssignArea.area!.stationName, + acroym: stationAssignArea.area!.acronym, + motherStation: false); + assignedArea.add(headStation); + assignedArea.add(childStationInfo); + if (stationAssignArea.area?.childStationInfo != null) { + for (var element in stationAssignArea.area!.childStationInfo!) { + ChildStationInfo newStationInfo = ChildStationInfo( + id: element.id, + stationName: element.stationName, + acroym: element.acroym, + motherStation: false); + assignedArea.add(newStationInfo); + } + } + }); + + statusResponse = assignedArea; + } + ////registration in-chage + if (assignRoleAreaType.areaTypeName.toLowerCase() == + "registration in-charge") { + List assignedArea = []; + data['data'][0]['assigned_area'].forEach((element) { + StationAssignArea stationAssignArea = + StationAssignArea.fromJson(element); + ChildStationInfo headStation = ChildStationInfo( + id: stationAssignArea.area!.id, + stationName: stationAssignArea.area!.stationName, + acroym: stationAssignArea.area!.acronym, + motherStation: true); + ChildStationInfo childStationInfo = ChildStationInfo( + id: stationAssignArea.area!.id, + stationName: stationAssignArea.area!.stationName, + acroym: stationAssignArea.area!.acronym, + motherStation: false); + assignedArea.add(headStation); + assignedArea.add(childStationInfo); + if (stationAssignArea.area?.childStationInfo != null) { + for (var element in stationAssignArea.area!.childStationInfo!) { + ChildStationInfo newStationInfo = ChildStationInfo( + id: element.id, + stationName: element.stationName, + acroym: element.acroym, + motherStation: false); + assignedArea.add(newStationInfo); + } + } + }); + statusResponse = assignedArea; + } + ////Barangay + if (assignRoleAreaType.areaTypeName.toLowerCase() == "baranggay") { + List assignedArea = []; + data['data'][0]['assigned_area'].forEach((var element) { + BaragayAssignArea baragayAssignArea = + BaragayAssignArea.fromJson(element['area']); + assignedArea.add(baragayAssignArea); + }); + statusResponse = assignedArea; + } + ////PUROK + if (assignRoleAreaType.areaTypeName.toLowerCase() == 'purok') { + List assignedArea = []; + data['data'][0]['assigned_area'].forEach((var element) { + Purok purok = Purok.fromJson(element['area']); + assignedArea.add(purok); + }); + statusResponse = assignedArea; + } + ////AGENCY + if (assignRoleAreaType.areaTypeName.toLowerCase() == 'agency') { + List assignedArea = []; + data['data'][0]['assigned_area'].forEach((var element) { + AgencyAssignedArea agencyAssignedArea = + AgencyAssignedArea.fromJson(element); + assignedArea.add(agencyAssignedArea); + }); + statusResponse = assignedArea; + } + } + } catch (e) { + throw e.toString(); + } + return statusResponse!; + } + + Future getPasserInfo( + {required String uuid, required String token}) async { + PasserInfo? passerInfo; + String path = Url.instance.getPasserInfo(); + String authtoken = "Token $token"; + Map params = {"uuid": uuid}; + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'Authorization': authtoken + }; + try { + http.Response response = await Request.instance + .getRequest(param: params, path: path, headers: headers); + if (response.statusCode == 200) { + Map body = jsonDecode(response.body); + passerInfo = PasserInfo.fromJson(body['data'][0]); + } + } catch (e) { + throw (e.toString()); + } + return passerInfo; + } + + Future performPostLogs( + {required String passerId, + required int chekerId, + required String io, + required bool otherInputs, + String? destination, + double? temp, + int? stationId, + String? cpId, + required int roleid}) async { + String path = Url.instance.postLogs(); + bool success; + Map headers = { + 'Content-Type': 'application/json; charset=UTF-8', + 'X-Client-Key': xClientKey, + 'X-Client-Secret': xClientSecret + }; + Map body; + if (otherInputs) { + if (roleid == 41 || roleid == 13 || roleid == 17 || roleid == 22) { + if (io == "i") { + print("1"); + body = { + "station_id": stationId, + "temperature": temp, + "passer": passerId, + "checkedby_user_id": chekerId, + "io": io + }; + } else { + print("2"); + body = { + "station_id": stationId, + "destination": destination, + "passer": passerId, + "checkedby_user_id": chekerId, + "io": io + }; + } + } else { + print("3"); + if (io == "i") { + body = { + "cp_id": cpId, + "temperature": temp, + "passer": passerId, + "checkedby_user_id": chekerId, + "io": io + }; + } else { + print("4"); + body = { + "cp_id": cpId, + "destination": destination, + "passer": passerId, + "checkedby_user_id": chekerId, + "io": io + }; + } + } + } else { + print("5"); + if (roleid == 41 || roleid == 13 || roleid == 17 || roleid == 22) { + body = { + "station_id": stationId, + "passer": passerId, + "checkedby_user_id": chekerId, + "io": io + }; + } else { + print("6"); + body = { + "cp_id": cpId, + "temperature": temp, + "passer": passerId, + "checkedby_user_id": chekerId, + "io": io + }; + } + } + try { + http.Response response = await Request.instance + .postRequest(path: path, headers: headers, body: body, param: {}); + if (response.statusCode == 201) { + success = true; + } else { + success = false; + } + } catch (e) { + throw e.toString(); + } + return success; + } +} + +Future setFailedAudio(AudioPlayer audioPlayer) async { + AudioCache player = AudioCache(); + + final url = await player.load("ScanFailed.mp3"); + audioPlayer.play(AssetSource(url.path)); +} diff --git a/lib/utils/app_router.dart b/lib/utils/app_router.dart index efc535b..3bf9c9b 100644 --- a/lib/utils/app_router.dart +++ b/lib/utils/app_router.dart @@ -1,8 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:unit2/bloc/profile/profile_bloc.dart'; +import 'package:unit2/bloc/role/pass_check/pass_check_bloc.dart'; import 'package:unit2/bloc/sos/sos_bloc.dart'; import 'package:unit2/screens/sos/index.dart'; +import 'package:unit2/screens/unit2/homepage.dart/components/dashboard.dart'; import 'package:unit2/screens/unit2/homepage.dart/components/menu.dart'; import 'package:unit2/screens/unit2/login/login.dart'; import 'package:unit2/utils/global_context.dart'; @@ -47,15 +49,19 @@ class AppRouter { }); case '/sos': return MaterialPageRoute(builder: (BuildContext context) { - return BlocProvider( + return BlocProvider( create: (_) => SosBloc()..add(LoadUserLocation()), child: const SosScreen(), ); }); - case '/pass-check': - return MaterialPageRoute(builder: (BuildContext context){ - return const QRCodeScannerSettings(); - }); + case '/pass-check': + PassCheckArguments arguments = routeSettings.arguments as PassCheckArguments; + return MaterialPageRoute(builder: (BuildContext context) { + return BlocProvider( + create: (context) => PassCheckBloc()..add(GetPassCheckAreas(roleId: arguments.roleId, userId: arguments.userId)), + child: QRCodeScannerSettings(roleId: arguments.roleId, userId: arguments.userId,), + ); + }); default: return MaterialPageRoute(builder: (context) { return Container(); diff --git a/lib/utils/global.dart b/lib/utils/global.dart index a58ef4a..0b427f7 100644 --- a/lib/utils/global.dart +++ b/lib/utils/global.dart @@ -9,6 +9,8 @@ double safeAreaVertical = 0; double safeBlockHorizontal = 0; double safeBlockVertical = 0; +const xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; +const xClientSecret = "unitcYqAN7GGalyz"; diff --git a/lib/utils/urls.dart b/lib/utils/urls.dart index 64c4b21..5dea2f3 100644 --- a/lib/utils/urls.dart +++ b/lib/utils/urls.dart @@ -5,10 +5,10 @@ class Url { String host() { // return '192.168.10.183:3000'; - // return 'agusandelnorte.gov.ph'; + return 'agusandelnorte.gov.ph'; // return "192.168.10.219:3000"; // return "192.168.10.241"; - return "192.168.10.221:3004"; + // return "192.168.10.221:3004"; // return "playweb.agusandelnorte.gov.ph"; // return 'devapi.agusandelnorte.gov.ph:3004'; } @@ -190,6 +190,20 @@ String getGenders(){ return "/api/profile_app/gender/"; } +/////ROLES +// pass check +String getAssignAreas(){ + return "/api/account/auth/assigned_role_area/"; +} + +String getPasserInfo(){ + return "/api/profile_app/person_basicinfo/"; +} + +String postLogs(){ + return "/api/unit2_app/monitoring/pass_check/"; +} + //// location utils path String getCounties(){ diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 4b37fe9..41d8796 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,10 +6,14 @@ #include "generated_plugin_registrant.h" +#include #include #include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "AudioplayersLinuxPlugin"); + audioplayers_linux_plugin_register_with_registrar(audioplayers_linux_registrar); g_autoptr(FlPluginRegistrar) modal_progress_hud_nsn_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "ModalProgressHudNsnPlugin"); modal_progress_hud_nsn_plugin_register_with_registrar(modal_progress_hud_nsn_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index f64d1cc..64b5f1f 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + audioplayers_linux modal_progress_hud_nsn platform_device_id_linux ) diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 7a1cdf6..fa11536 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,22 +5,30 @@ import FlutterMacOS import Foundation +import assets_audio_player +import assets_audio_player_web +import audioplayers_darwin import location import modal_progress_hud_nsn import package_info_plus import path_provider_foundation import platform_device_id import platform_device_id_macos +import rive_common import shared_preferences_foundation import sqflite func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + AssetsAudioPlayerPlugin.register(with: registry.registrar(forPlugin: "AssetsAudioPlayerPlugin")) + AssetsAudioPlayerWebPlugin.register(with: registry.registrar(forPlugin: "AssetsAudioPlayerWebPlugin")) + AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin")) LocationPlugin.register(with: registry.registrar(forPlugin: "LocationPlugin")) ModalProgressHudNsnPlugin.register(with: registry.registrar(forPlugin: "ModalProgressHudNsnPlugin")) FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) PlatformDeviceIdMacosPlugin.register(with: registry.registrar(forPlugin: "PlatformDeviceIdMacosPlugin")) PlatformDeviceIdMacosPlugin.register(with: registry.registrar(forPlugin: "PlatformDeviceIdMacosPlugin")) + RivePlugin.register(with: registry.registrar(forPlugin: "RivePlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) } diff --git a/pubspec.lock b/pubspec.lock index b586442..43d40ba 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -45,10 +45,26 @@ packages: dependency: transitive description: name: args - sha256: "4cab82a83ffef80b262ddedf47a0a8e56ee6fbf7fe21e6e768b02792034dd440" + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 url: "https://pub.dev" source: hosted - version: "2.4.0" + version: "2.4.2" + assets_audio_player: + dependency: "direct main" + description: + name: assets_audio_player + sha256: dcea8cd9c11cd9c34586f2446bfcdf099362159c56f97517ba941ac151974ea9 + url: "https://pub.dev" + source: hosted + version: "3.0.6" + assets_audio_player_web: + dependency: transitive + description: + name: assets_audio_player_web + sha256: "4575ec40033d818ff022d48f7d46e24c01bc632bd1cd36a4f8b58b38e9aa4a81" + url: "https://pub.dev" + source: hosted + version: "3.0.6" async: dependency: transitive description: @@ -57,6 +73,62 @@ packages: url: "https://pub.dev" source: hosted version: "2.10.0" + audioplayers: + dependency: "direct main" + description: + name: audioplayers + sha256: "61583554386721772f9309f509e17712865b38565a903c761f96b1115a979282" + url: "https://pub.dev" + source: hosted + version: "4.1.0" + audioplayers_android: + dependency: transitive + description: + name: audioplayers_android + sha256: dbdc9b7f2aa2440314c638aa55aadd45c7705e8340d5eddf2e3fb8da32d4ae2c + url: "https://pub.dev" + source: hosted + version: "3.0.2" + audioplayers_darwin: + dependency: transitive + description: + name: audioplayers_darwin + sha256: "6aea96df1d12f7ad5a71d88c6d1b22a216211a9564219920124c16768e456e9d" + url: "https://pub.dev" + source: hosted + version: "4.1.0" + audioplayers_linux: + dependency: transitive + description: + name: audioplayers_linux + sha256: "396b62ac62c92dd26c3bc5106583747f57a8b325ebd2b41e5576f840cfc61338" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + audioplayers_platform_interface: + dependency: transitive + description: + name: audioplayers_platform_interface + sha256: f7daaed4659143094151ecf6bacd927d29ab8acffba98c110c59f0b81ae51143 + url: "https://pub.dev" + source: hosted + version: "5.0.1" + audioplayers_web: + dependency: transitive + description: + name: audioplayers_web + sha256: ec84fd46eed1577148ed4113f5998a36a18da4fce7170c37ce3e21b631393339 + url: "https://pub.dev" + source: hosted + version: "3.1.0" + audioplayers_windows: + dependency: transitive + description: + name: audioplayers_windows + sha256: "1d3aaac98a192b8488167711ba1e67d8b96333e8d0572ede4e2912e5bbce69a3" + url: "https://pub.dev" + source: hosted + version: "2.0.2" auto_size_text: dependency: "direct main" description: @@ -69,10 +141,10 @@ packages: dependency: "direct main" description: name: awesome_dialog - sha256: ac08268b991f228fc6b8880b68ec030d2941bcc8df8b6a6551fb79f2bd36b7da + sha256: "7da175ea284fa5da0a4d0cbdfe835c5b71d30c7b38c1770c0f27f48272ff5a08" url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "3.1.0" azlistview: dependency: "direct main" description: @@ -85,10 +157,10 @@ packages: dependency: "direct main" description: name: badges - sha256: d33d4e07197d6e61ddc940640f2b4dc303d3c80887011344940e24d7522f8d26 + sha256: "6e7f3ec561ec08f47f912cfe349d4a1707afdc8dda271e17b046aa6d42c89e77" url: "https://pub.dev" source: hosted - version: "3.0.3" + version: "3.1.1" barcode_scan2: dependency: "direct main" description: @@ -101,10 +173,10 @@ packages: dependency: transitive description: name: bloc - sha256: "658a5ae59edcf1e58aac98b000a71c762ad8f46f1394c34a52050cafb3e11a80" + sha256: "3820f15f502372d979121de1f6b97bfcf1630ebff8fe1d52fb2b0bfa49be5b49" url: "https://pub.dev" source: hosted - version: "8.1.1" + version: "8.1.2" boolean_selector: dependency: transitive description: @@ -157,10 +229,10 @@ packages: dependency: transitive description: name: build_runner_core - sha256: "14febe0f5bac5ae474117a36099b4de6f1dbc52df6c5e55534b3da9591bf4292" + sha256: "0671ad4162ed510b70d0eb4ad6354c249f8429cab4ae7a4cec86bbc2886eb76e" url: "https://pub.dev" source: hosted - version: "7.2.7" + version: "7.2.7+1" built_collection: dependency: transitive description: @@ -173,10 +245,10 @@ packages: dependency: transitive description: name: built_value - sha256: "31b7c748fd4b9adf8d25d72a4c4a59ef119f12876cf414f94f8af5131d5fa2b0" + sha256: "598a2a682e2a7a90f08ba39c0aaa9374c5112340f0a2e275f61b59389543d166" url: "https://pub.dev" source: hosted - version: "8.4.4" + version: "8.6.1" cached_network_image: dependency: "direct main" description: @@ -213,10 +285,10 @@ packages: dependency: transitive description: name: checked_yaml - sha256: "3d1505d91afa809d177efd4eed5bb0eb65805097a1463abdd2add076effae311" + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.0.3" clock: dependency: transitive description: @@ -229,10 +301,10 @@ packages: dependency: transitive description: name: code_builder - sha256: "0d43dd1288fd145de1ecc9a3948ad4a6d5a82f0a14c4fdd0892260787d975cbe" + sha256: "4ad01d6e56db961d29661561effde45e519939fdaeb46c351275b182eac70189" url: "https://pub.dev" source: hosted - version: "4.4.0" + version: "4.5.0" collection: dependency: transitive description: @@ -269,10 +341,10 @@ packages: dependency: transitive description: name: crypto - sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "3.0.3" dart_style: dependency: transitive description: @@ -365,10 +437,10 @@ packages: dependency: transitive description: name: ffi - sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 + sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.0.2" file: dependency: transitive description: @@ -418,10 +490,10 @@ packages: dependency: "direct main" description: name: flutter_bloc - sha256: "434951eea948dbe87f737b674281465f610b8259c16c097b8163ce138749a775" + sha256: e74efb89ee6945bcbce74a5b3a5a3376b088e5f21f55c263fc38cbdc6237faae url: "https://pub.dev" source: hosted - version: "8.1.2" + version: "8.1.3" flutter_blurhash: dependency: transitive description: @@ -471,10 +543,10 @@ packages: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: c224ac897bed083dabf11f238dd11a239809b446740be0c2044608c50029ffdf + sha256: "950e77c2bbe1692bc0874fc7fb491b96a4dc340457f4ea1641443d0a6c1ea360" url: "https://pub.dev" source: hosted - version: "2.0.9" + version: "2.0.15" flutter_progress_hud: dependency: "direct main" description: @@ -487,10 +559,10 @@ packages: dependency: "direct main" description: name: flutter_spinkit - sha256: "77a2117c0517ff909221f3160b8eb20052ab5216107581168af574ac1f05dff8" + sha256: b39c753e909d4796906c5696a14daf33639a76e017136c8d82bf3e620ce5bb8e url: "https://pub.dev" source: hosted - version: "5.1.0" + version: "5.2.0" flutter_svg: dependency: "direct main" description: @@ -529,18 +601,18 @@ packages: dependency: "direct main" description: name: fluttertoast - sha256: "2f9c4d3f4836421f7067a28f8939814597b27614e021da9d63e5d3fb6e212d25" + sha256: "474f7d506230897a3cd28c965ec21c5328ae5605fc9c400cd330e9e9d6ac175c" url: "https://pub.dev" source: hosted - version: "8.2.1" + version: "8.2.2" form_builder_validators: dependency: "direct main" description: name: form_builder_validators - sha256: d0a940d77231723fcb203ad6f5319ff30cd0c4412a6e74d29d826957b1f9afe0 + sha256: f2d90439c56345c23ad8d0c2912e4002cd02563d816f4387c9495051c10d3321 url: "https://pub.dev" source: hosted - version: "8.5.0" + version: "8.6.1" freezed_annotation: dependency: transitive description: @@ -561,10 +633,10 @@ packages: dependency: transitive description: name: glob - sha256: "4515b5b6ddb505ebdd242a5f2cc5d22d3d6a80013789debfbda7777f47ea308c" + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" globbing: dependency: transitive description: @@ -577,10 +649,10 @@ packages: dependency: transitive description: name: graphs - sha256: f9e130f3259f52d26f0cfc0e964513796dafed572fa52e45d2f8d6ca14db39b2 + sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.3.1" hive: dependency: "direct main" description: @@ -609,10 +681,10 @@ packages: dependency: transitive description: name: http - sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482" + sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" url: "https://pub.dev" source: hosted - version: "0.13.5" + version: "0.13.6" http_multi_server: dependency: transitive description: @@ -665,10 +737,10 @@ packages: dependency: transitive description: name: json_annotation - sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317 + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 url: "https://pub.dev" source: hosted - version: "4.8.0" + version: "4.8.1" lints: dependency: transitive description: @@ -705,10 +777,10 @@ packages: dependency: transitive description: name: logging - sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d" + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" lottie: dependency: transitive description: @@ -801,10 +873,10 @@ packages: dependency: "direct main" description: name: package_info_plus - sha256: cbff87676c352d97116af6dbea05aa28c4d65eb0f6d5677a520c11a69ca9a24d + sha256: "10259b111176fba5c505b102e3a5b022b51dd97e30522e906d6922c745584745" url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.1.2" package_info_plus_platform_interface: dependency: transitive description: @@ -841,34 +913,34 @@ packages: dependency: "direct main" description: name: path_provider - sha256: c7edf82217d4b2952b2129a61d3ad60f1075b9299e629e149a8d2e39c2e6aad4 + sha256: "3087813781ab814e4157b172f1a11c46be20179fcc9bea043e0fba36bc0acaa2" url: "https://pub.dev" source: hosted - version: "2.0.14" + version: "2.0.15" path_provider_android: dependency: transitive description: name: path_provider_android - sha256: "019f18c9c10ae370b08dce1f3e3b73bc9f58e7f087bb5e921f06529438ac0ae7" + sha256: "2cec049d282c7f13c594b4a73976b0b4f2d7a1838a6dd5aaf7bd9719196bee86" url: "https://pub.dev" source: hosted - version: "2.0.24" + version: "2.0.27" path_provider_foundation: dependency: transitive description: name: path_provider_foundation - sha256: "818b2dc38b0f178e0ea3f7cf3b28146faab11375985d815942a68eee11c2d0f7" + sha256: "1995d88ec2948dac43edf8fe58eb434d35d22a2940ecee1a9fefcd62beee6eb3" url: "https://pub.dev" source: hosted - version: "2.2.1" + version: "2.2.3" path_provider_linux: dependency: transitive description: name: path_provider_linux - sha256: "2ae08f2216225427e64ad224a24354221c2c7907e448e6e0e8b57b1eb9f10ad1" + sha256: ffbb8cc9ed2c9ec0e4b7a541e56fd79b138e8f47d2fb86815f15358a349b3b57 url: "https://pub.dev" source: hosted - version: "2.1.10" + version: "2.1.11" path_provider_platform_interface: dependency: transitive description: @@ -881,10 +953,10 @@ packages: dependency: transitive description: name: path_provider_windows - sha256: f53720498d5a543f9607db4b0e997c4b5438884de25b0f73098cc2671a51b130 + sha256: "1cb68ba4cd3a795033de62ba1b7b4564dace301f952de6bfb3cd91b202b6ee96" url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.1.7" pedantic: dependency: transitive description: @@ -897,34 +969,34 @@ packages: dependency: "direct main" description: name: permission_handler - sha256: "33c6a1253d1f95fd06fa74b65b7ba907ae9811f9d5c1d3150e51417d04b8d6a8" + sha256: "1b6b3e73f0bcbc856548bbdfb1c33084a401c4f143e220629a9055233d76c331" url: "https://pub.dev" source: hosted - version: "10.2.0" + version: "10.3.0" permission_handler_android: dependency: transitive description: name: permission_handler_android - sha256: "8028362b40c4a45298f1cbfccd227c8dd6caf0e27088a69f2ba2ab15464159e2" + sha256: "8f6a95ccbca13766882f95d32684d7c9bfe6c45650c32bedba948ef1c6a4ddf7" url: "https://pub.dev" source: hosted - version: "10.2.0" + version: "10.2.3" permission_handler_apple: dependency: transitive description: name: permission_handler_apple - sha256: ee96ac32f5a8e6f80756e25b25b9f8e535816c8e6665a96b6d70681f8c4f7e85 + sha256: "08dcb6ce628ac0b257e429944b4c652c2a4e6af725bdf12b498daa2c6b2b1edb" url: "https://pub.dev" source: hosted - version: "9.0.8" + version: "9.1.0" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface - sha256: "68abbc472002b5e6dfce47fe9898c6b7d8328d58b5d2524f75e277c07a97eb84" + sha256: de20a5c3269229c1ae2e5a6b822f6cb59578b23e8255c93fbeebfc82116e6b11 url: "https://pub.dev" source: hosted - version: "3.9.0" + version: "3.10.0" permission_handler_windows: dependency: transitive description: @@ -1009,10 +1081,10 @@ packages: dependency: transitive description: name: pointycastle - sha256: c3120a968135aead39699267f4c74bc9a08e4e909e86bc1b0af5bfd78691123c + sha256: "7c1e5f0d23c9016c5bbd8b1473d0d3fb3fc851b876046039509e18e0c7485f2c" url: "https://pub.dev" source: hosted - version: "3.7.2" + version: "3.7.3" pool: dependency: transitive description: @@ -1049,18 +1121,18 @@ packages: dependency: transitive description: name: pub_semver - sha256: "307de764d305289ff24ad257ad5c5793ce56d04947599ad68b3baa124105fc17" + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.4" pubspec_parse: dependency: transitive description: name: pubspec_parse - sha256: ec85d7d55339d85f44ec2b682a82fea340071e8978257e5a43e69f79e98ef50c + sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 url: "https://pub.dev" source: hosted - version: "1.2.2" + version: "1.2.3" qr: dependency: transitive description: @@ -1081,10 +1153,18 @@ packages: dependency: transitive description: name: rive - sha256: "22e3755b75f4ea4492d2fecf4fc2acf1c8d0073df39781d290a20cbfe74c3760" + sha256: bb7a16bc6a88484fe3136890030b71776ffea368edd2a8368fe99d6430e4a802 url: "https://pub.dev" source: hosted - version: "0.9.1" + version: "0.11.2" + rive_common: + dependency: transitive + description: + name: rive_common + sha256: "5a0dbf689527c51ee5430608181d81460c9c45ab6cc3bd52dd9bbb3d8c4455b6" + url: "https://pub.dev" + source: hosted + version: "0.0.9" rxdart: dependency: transitive description: @@ -1113,34 +1193,34 @@ packages: dependency: "direct main" description: name: searchfield - sha256: deb363c95b9e64ea9ffd1a3b69926b0fe0344daedab872fc42014755a8199de9 + sha256: "62b6653d7194de5a7ea724124846b996d0d211cd3eeeec2e5ca84423650f66f8" url: "https://pub.dev" source: hosted - version: "0.7.5" + version: "0.7.8" shared_preferences: dependency: transitive description: name: shared_preferences - sha256: "858aaa72d8f61637d64e776aca82e1c67e6d9ee07979123c5d17115031c1b13b" + sha256: "396f85b8afc6865182610c0a2fc470853d56499f75f7499e2a73a9f0539d23d0" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" shared_preferences_android: dependency: transitive description: name: shared_preferences_android - sha256: "8304d8a1f7d21a429f91dee552792249362b68a331ac5c3c1caf370f658873f6" + sha256: "6478c6bbbecfe9aced34c483171e90d7c078f5883558b30ec3163cf18402c749" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.4" shared_preferences_foundation: dependency: transitive description: name: shared_preferences_foundation - sha256: cf2a42fb20148502022861f71698db12d937c7459345a1bdaa88fc91a91b3603 + sha256: e014107bb79d6d3297196f4f2d0db54b5d1f85b8ea8ff63b8e8b391a02700feb url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.2.2" shared_preferences_linux: dependency: transitive description: @@ -1177,18 +1257,18 @@ packages: dependency: transitive description: name: shelf - sha256: c24a96135a2ccd62c64b69315a14adc5c3419df63b4d7c05832a346fdb73682c + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.4.1" shelf_web_socket: dependency: transitive description: name: shelf_web_socket - sha256: a988c0e8d8ffbdb8a28aa7ec8e449c260f3deb808781fe1284d22c5bba7156e8 + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" url: "https://pub.dev" source: hosted - version: "1.0.3" + version: "1.0.4" signature: dependency: "direct main" description: @@ -1201,10 +1281,10 @@ packages: dependency: "direct main" description: name: simple_chips_input - sha256: "522b2e715fe67f325693e003acfd09fc0b8ab25a2c0c87fb8e5ce5b23a8a2ec1" + sha256: "758c2439c74f9105ebb18407095c028e247631108195c38480ea3fb4967c8f6f" url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.1.0" sky_engine: dependency: transitive description: flutter @@ -1238,18 +1318,18 @@ packages: dependency: transitive description: name: sqflite - sha256: "500d6fec583d2c021f2d25a056d96654f910662c64f836cd2063167b8f1fa758" + sha256: b4d6710e1200e96845747e37338ea8a819a12b51689a3bcf31eff0003b37a0b9 url: "https://pub.dev" source: hosted - version: "2.2.6" + version: "2.2.8+4" sqflite_common: dependency: transitive description: name: sqflite_common - sha256: "963dad8c4aa2f814ce7d2d5b1da2f36f31bd1a439d8f27e3dc189bb9d26bc684" + sha256: e77abf6ff961d69dfef41daccbb66b51e9983cdd5cb35bf30733598057401555 url: "https://pub.dev" source: hosted - version: "2.4.3" + version: "2.4.5" stack_trace: dependency: transitive description: @@ -1286,10 +1366,10 @@ packages: dependency: transitive description: name: synchronized - sha256: "33b31b6beb98100bf9add464a36a8dd03eb10c7a8cf15aeec535e9b054aaf04b" + sha256: "5fcbd27688af6082f5abd611af56ee575342c30e87541d0245f7ff99faa02c60" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.1.0" system_info2: dependency: "direct main" description: @@ -1326,18 +1406,18 @@ packages: dependency: "direct main" description: name: toggle_switch - sha256: "82c778c4bfe93af154a41e346ccd1d5b0cb6a50f8f187941412edd0a9bbf51ee" + sha256: "9e6af1f0c5a97d9de41109dc7b9e1b3bbe73417f89b10e0e44dc834fb493d4cb" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.0" typed_data: dependency: transitive description: name: typed_data - sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.2" uuid: dependency: transitive description: @@ -1366,18 +1446,18 @@ packages: dependency: transitive description: name: web_socket_channel - sha256: ca49c0bc209c687b887f30527fb6a9d80040b072cc2990f34b9bec3e7663101b + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "2.4.0" win32: dependency: transitive description: name: win32 - sha256: a6f0236dbda0f63aa9a25ad1ff9a9d8a4eaaa5012da0dc59d21afdb1dc361ca4 + sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" url: "https://pub.dev" source: hosted - version: "3.1.4" + version: "4.1.4" xdg_directories: dependency: transitive description: @@ -1398,10 +1478,10 @@ packages: dependency: transitive description: name: yaml - sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370" + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "3.1.2" sdks: dart: ">2.19.0 <3.0.0" flutter: ">=3.7.0" diff --git a/pubspec.yaml b/pubspec.yaml index cc3557e..8bdae44 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -80,6 +80,9 @@ dependencies: platform_device_id: ^1.0.1 multi_dropdown: ^1.0.9 searchable_paginated_dropdown: ^1.2.0 + audioplayers: ^4.1.0 + assets_audio_player: ^3.0.6 + dev_dependencies: flutter_test: @@ -110,6 +113,7 @@ flutter: - assets/svgs/ - assets/pngs/ - assets/fonts/ + - assets/ # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 458cc68..362613e 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,15 +6,21 @@ #include "generated_plugin_registrant.h" +#include #include #include #include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + AudioplayersWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin")); ModalProgressHudNsnPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("ModalProgressHudNsnPlugin")); PermissionHandlerWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); PlatformDeviceIdWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("PlatformDeviceIdWindowsPlugin")); + RivePluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("RivePlugin")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 4c970ab..8c00e3e 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,9 +3,11 @@ # list(APPEND FLUTTER_PLUGIN_LIST + audioplayers_windows modal_progress_hud_nsn permission_handler_windows platform_device_id_windows + rive_common ) list(APPEND FLUTTER_FFI_PLUGIN_LIST