diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index e457ab6b..1f76558f 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -46,7 +46,7 @@ const Map localizedValues = { 'doctor': {'en': 'Doctor', 'ar': 'الطبيب'}, 'clinicName': {'en': 'Clinic Name', 'ar': 'اسم العيادة'}, 'doctorName': {'en': 'Doctor Name', 'ar': 'إسم الطبيب'}, - 'nearestAppo': {'en': 'Nearest appointment', 'ar': 'أقرب موعد'}, + 'nearestAppo': {'en': 'Nearest Appointment', 'ar': 'أقرب موعد'}, 'searchByDocText': {'en': 'Type the name of the doctor to help you find him', 'ar': 'اكتب اسم الطبيب لمساعدتك في العثور عليه'}, 'enterDocName': {'en': 'Enter Doctor name', 'ar': 'أدخل إسم الطبيب'}, 'search': {'en': 'Search', 'ar': 'بحث'}, diff --git a/lib/pages/BookAppointment/Search.dart b/lib/pages/BookAppointment/Search.dart index 6dee1076..b4e8d43e 100644 --- a/lib/pages/BookAppointment/Search.dart +++ b/lib/pages/BookAppointment/Search.dart @@ -1,6 +1,7 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/components/SearchByClinic.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/components/SearchByDoctor.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; @@ -22,8 +23,7 @@ class _SearchState extends State with TickerProviderStateMixin { @override void initState() { - _tabController = - new TabController(length: 2, vsync: this, initialIndex: widget.type); + _tabController = new TabController(length: 2, vsync: this, initialIndex: widget.type); super.initState(); } @@ -32,28 +32,22 @@ class _SearchState extends State with TickerProviderStateMixin { Widget build(BuildContext context) { AppGlobal.context = context; return AppScaffold( - isShowAppBar: true, + isShowAppBar: false, isShowDecPage: false, appBarTitle: TranslationBase.of(context).bookAppo, + backgroundColor: Color(0xFFF7F7F7), body: Container( child: Column( children: [ TabBar( tabs: [ + Tab(child: Text(TranslationBase.of(context).clinicName, style: TextStyle(color: Colors.black))), Tab( - child: Text(TranslationBase.of(context).clinicName, - style: TextStyle(color: Colors.black))), - Tab( - child: Text(TranslationBase.of(context).doctorName, - style: TextStyle(color: Colors.black)), + child: Text(TranslationBase.of(context).doctorName, style: TextStyle(color: Colors.black)), ) ], controller: _tabController, ), - Divider( - color: Colors.grey[600], - thickness: 0.5, - ), Expanded( child: new TabBarView( physics: NeverScrollableScrollPhysics(), diff --git a/lib/pages/BookAppointment/components/SearchByClinic.dart b/lib/pages/BookAppointment/components/SearchByClinic.dart index cf562ece..c9f04249 100644 --- a/lib/pages/BookAppointment/components/SearchByClinic.dart +++ b/lib/pages/BookAppointment/components/SearchByClinic.dart @@ -14,6 +14,7 @@ import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/card/rounded_container.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -43,6 +44,7 @@ class _SearchByClinicState extends State { bool isProjectLoaded = false; ListClinicCentralized selectedClinic; + final GlobalKey dropdownKey = GlobalKey(); AuthenticatedUser authUser = new AuthenticatedUser(); AuthProvider authProvider = new AuthProvider(); @@ -56,108 +58,128 @@ class _SearchByClinicState extends State { @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.all(10.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - children: [ - Checkbox( - activeColor: new Color(0xFF40ACC9), - value: nearestAppo, - onChanged: (bool value) { - setState(() { - nearestAppo = value; - print(nearestAppo); - if (nearestAppo) - getProjectsList(); - else - isProjectLoaded = false; - }); - }, - ), - Text(TranslationBase.of(context).nearestAppo, - style: TextStyle(fontSize: 16.0, letterSpacing: 0.9)), - ], + Padding( + padding: const EdgeInsets.only(left: 2,right: 2), + child: Row( + children: [ + Checkbox( + activeColor: new Color(0xFF40ACC9), + value: nearestAppo, + onChanged: (bool value) { + setState(() { + nearestAppo = value; + print(nearestAppo); + if (nearestAppo) + getProjectsList(); + else + isProjectLoaded = false; + }); + }, + ), + Text( + TranslationBase.of(context).nearestAppo, + style: TextStyle(fontSize: 14.0, letterSpacing: -0.56), + ), + ], + ), ), - widget.clnicIds != null && - widget.clnicIds.length > 1 && - isLoaded == true - ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: clinicsList.map((result) { - return RoundedContainer( - child: ListTile( - onTap: () { - // setState(() { - dropdownValue = result.clinicID.toString(); - setState(() { - if (!isDentalSelectedAndSupported()) { - projectDropdownValue = ""; - getDoctorsList(context); - } - }); - }, - title: Text(result.clinicDescription, - style: TextStyle( - fontSize: 14.0, - color: Colors.grey[700], - letterSpacing: 1.0)))); - }).toList()) - : Container( - height: 60.0, - decoration: BoxDecoration( - color: Colors.white, - border: Border.all( - color: Colors.grey[400], - width: 1.0, - ), - borderRadius: BorderRadius.circular(10), - ), - // margin: EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 20.0), - padding: EdgeInsets.all(8.0), - width: MediaQuery.of(context).size.width, - child: DropdownButtonHideUnderline( - child: DropdownButton( - hint: new Text(TranslationBase.of(context).selectClinic), - value: dropdownValue, - items: clinicsList.map((item) { - return new DropdownMenuItem( - value: item.clinicID.toString() + - "-" + - item.isLiveCareClinicAndOnline.toString() + - "-" + - item.liveCareClinicID.toString() + - "-" + - item.liveCareServiceID.toString(), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + widget.clnicIds != null && widget.clnicIds.length > 1 && isLoaded == true + ? Padding( + padding: const EdgeInsets.only(left: 20,right: 20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: clinicsList.map((result) { + return RoundedContainer( + child: ListTile( + onTap: () { + // setState(() { + dropdownValue = result.clinicID.toString(); + setState(() { + if (!isDentalSelectedAndSupported()) { + projectDropdownValue = ""; + getDoctorsList(context); + } + }); + }, + title: Text(result.clinicDescription, style: TextStyle(fontSize: 14.0, color: Colors.grey[700], letterSpacing: 1.0)))); + }).toList()), + ) + : InkWell( + onTap: () { + dropdownKey.currentState; + }, + child: Container( + width: double.infinity, + margin: const EdgeInsets.only(left: 16,right: 16), + decoration: containerRadius(Colors.white, 12), + padding: EdgeInsets.only(left: 12, right: 12, top: 14, bottom: 14), + child: Row( + children: [ + Flexible( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(item.clinicDescription), - item.isLiveCareClinicAndOnline - ? SvgPicture.asset( - 'assets/images/new-design/video_icon_green_right.svg', - height: 15, - width: 15, - fit: BoxFit.cover) - : Container(), - ]), - ); - }).toList(), - onChanged: (newValue) { - setState(() { - print(newValue); - dropdownValue = newValue; - if (!isDentalSelectedAndSupported() && !nearestAppo) { - projectDropdownValue = ""; - getDoctorsList(context); - } - }); - }, - ), - )), - isDentalSelectedAndSupported() == true || - (nearestAppo && isProjectLoaded) + Text( + "Select Clinic", + style: TextStyle( + color: Colors.black, + fontSize: 11, + letterSpacing: -0.44, + fontWeight: FontWeight.w600, + ), + ), + Container( + height: 20, + child: DropdownButtonHideUnderline( + child: DropdownButton( + key: dropdownKey, + hint: new Text(TranslationBase.of(context).selectClinic), + value: dropdownValue, + iconSize: 0, + style: TextStyle( + color: Color(0xFF575757), + fontSize: 14, + letterSpacing: -0.56, + ), + isExpanded: true, + items: clinicsList.map((item) { + return new DropdownMenuItem( + value: item.clinicID.toString() + + "-" + + item.isLiveCareClinicAndOnline.toString() + + "-" + + item.liveCareClinicID.toString() + + "-" + + item.liveCareServiceID.toString(), + child: Text(item.clinicDescription), + ); + }).toList(), + onChanged: (newValue) { + setState(() { + print(newValue); + dropdownValue = newValue; + if (!isDentalSelectedAndSupported() && !nearestAppo) { + projectDropdownValue = ""; + getDoctorsList(context); + } + }); + }, + ), + ), + ), + ], + ), + ), + Icon( + Icons.keyboard_arrow_down_rounded, + ), + ], + )), + ), + isDentalSelectedAndSupported() == true || (nearestAppo && isProjectLoaded) ? Container( height: 60.0, decoration: BoxDecoration( @@ -196,9 +218,7 @@ class _SearchByClinicState extends State { } bool isDentalSelectedAndSupported() { - return dropdownValue != "" && - (dropdownValue == "17") && - isMobileAppDentalAllow; + return dropdownValue != "" && (dropdownValue == "17") && isMobileAppDentalAllow; } getClinicsList() { @@ -258,10 +278,7 @@ class _SearchByClinicState extends State { Navigator.push( context, FadePage( - page: LiveCareBookAppointment( - clinicName: "Family Medicine", - liveCareClinicID: dropdownValue.split("-")[2], - liveCareServiceID: dropdownValue.split("-")[3]), + page: LiveCareBookAppointment(clinicName: "Family Medicine", liveCareClinicID: dropdownValue.split("-")[2], liveCareServiceID: dropdownValue.split("-")[3]), ), ).then((value) { print(value); @@ -285,17 +302,10 @@ class _SearchByClinicState extends State { List arrDistance = []; List result; int numAll; - List _patientDoctorAppointmentListHospital = - List(); + List _patientDoctorAppointmentListHospital = List(); DoctorsListService service = new DoctorsListService(); - service - .getDoctorsList( - int.parse(dropdownValue.split("-")[0]), - projectDropdownValue != "" ? int.parse(projectDropdownValue) : 0, - nearestAppo, - context) - .then((res) { + service.getDoctorsList(int.parse(dropdownValue.split("-")[0]), projectDropdownValue != "" ? int.parse(projectDropdownValue) : 0, nearestAppo, context).then((res) { GifLoaderDialogUtils.hideDialog(context); if (res['MessageStatus'] == 1) { setState(() { @@ -305,27 +315,17 @@ class _SearchByClinicState extends State { doctorsList.add(new DoctorList.fromJson(v)); }); doctorsList.forEach((element) { - List doctorByHospital = - _patientDoctorAppointmentListHospital - .where( - (elementClinic) => - elementClinic.filterName == element.projectName, - ) - .toList(); + List doctorByHospital = _patientDoctorAppointmentListHospital + .where( + (elementClinic) => elementClinic.filterName == element.projectName, + ) + .toList(); if (doctorByHospital.length != 0) { - _patientDoctorAppointmentListHospital[ - _patientDoctorAppointmentListHospital - .indexOf(doctorByHospital[0])] - .patientDoctorAppointmentList - .add(element); + _patientDoctorAppointmentListHospital[_patientDoctorAppointmentListHospital.indexOf(doctorByHospital[0])].patientDoctorAppointmentList.add(element); } else { - _patientDoctorAppointmentListHospital.add( - PatientDoctorAppointmentList( - filterName: element.projectName, - distanceInKMs: - element.projectDistanceInKiloMeters.toString(), - patientDoctorAppointment: element)); + _patientDoctorAppointmentListHospital + .add(PatientDoctorAppointmentList(filterName: element.projectName, distanceInKMs: element.projectDistanceInKiloMeters.toString(), patientDoctorAppointment: element)); } }); } else {} @@ -333,8 +333,7 @@ class _SearchByClinicState extends State { result = LinkedHashSet.from(arr).toList(); numAll = result.length; - navigateToSearchResults( - context, doctorsList, _patientDoctorAppointmentListHospital); + navigateToSearchResults(context, doctorsList, _patientDoctorAppointmentListHospital); } else { AppToast.showErrorToast(message: res['ErrorEndUserMessage']); } @@ -345,8 +344,7 @@ class _SearchByClinicState extends State { }); } - Future navigateToDentalComplaints( - BuildContext context, SearchInfo searchInfo) async { + Future navigateToDentalComplaints(BuildContext context, SearchInfo searchInfo) async { Navigator.push( context, FadePage( @@ -355,20 +353,9 @@ class _SearchByClinicState extends State { ); } - Future navigateToSearchResults( - context, - List docList, - List - patientDoctorAppointmentListHospital) async { + Future navigateToSearchResults(context, List docList, List patientDoctorAppointmentListHospital) async { isProjectLoaded = false; - Navigator.push( - context, - FadePage( - page: SearchResults( - isLiveCareAppointment: false, - doctorsList: docList, - patientDoctorAppointmentListHospital: - patientDoctorAppointmentListHospital))) + Navigator.push(context, FadePage(page: SearchResults(isLiveCareAppointment: false, doctorsList: docList, patientDoctorAppointmentListHospital: patientDoctorAppointmentListHospital))) .then((value) { getProjectsList(); }); @@ -377,9 +364,7 @@ class _SearchByClinicState extends State { filterClinic() { setState(() { if (widget.clnicIds != null && widget.clnicIds.length > 0) { - clinicsList = clinicsList - .where((i) => widget.clnicIds.indexOf(i.clinicID) > -1) - .toList(); + clinicsList = clinicsList.where((i) => widget.clnicIds.indexOf(i.clinicID) > -1).toList(); isLoaded = true; } }); diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index c84d5422..819ce389 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -11,6 +11,7 @@ import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.da import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart'; import 'package:diplomaticquarterapp/models/LiveCare/IncomingCallData.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/BookingOptions.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/Search.dart'; import 'package:diplomaticquarterapp/pages/DrawerPages/family/my-family.dart'; import 'package:diplomaticquarterapp/pages/ToDoList/ToDo.dart'; import 'package:diplomaticquarterapp/pages/landing/home_page_2.dart'; @@ -613,7 +614,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { }, ), MedicalProfilePageNew(), - BookingOptions(), + Search(), MyFamily(isAppbarVisible: false), ToDo(isShowAppBar: false), ], // Please do not remove the BookingOptions from this array diff --git a/lib/uitl/location_util.dart b/lib/uitl/location_util.dart index e2edb2a1..b42f19ae 100644 --- a/lib/uitl/location_util.dart +++ b/lib/uitl/location_util.dart @@ -20,7 +20,6 @@ import 'package:huawei_location/location/location_availability.dart'; import 'package:permission_handler/permission_handler.dart'; class LocationUtils { - AppSharedPreferences sharedPref = new AppSharedPreferences(); bool isShowConfirmDialog; @@ -30,24 +29,20 @@ class LocationUtils { void getCurrentLocation({Function(LatLng) callBack}) async { print("current location"); - if(Platform.isAndroid && (await FlutterHmsGmsAvailability.isHmsAvailable)) { + if (Platform.isAndroid && (await FlutterHmsGmsAvailability.isHmsAvailable)) { _getHMSCurrentLocation(callBack); - }else{ + } else { Geolocator.isLocationServiceEnabled().then((value) { if (value) { Geolocator.checkPermission().then((permission) { - if (permission == LocationPermission.always || - permission == LocationPermission.whileInUse) { - Geolocator.getLastKnownPosition() - .then((value){ - setLocation(value); - if(callBack != null) - callBack(LatLng(value.latitude, value.longitude)); + if (permission == LocationPermission.always || permission == LocationPermission.whileInUse) { + Geolocator.getLastKnownPosition().then((value) { + setLocation(value); + if (callBack != null) callBack(LatLng(value.latitude, value.longitude)); }); } - if (permission == LocationPermission.denied || - permission == LocationPermission.deniedForever) { + if (permission == LocationPermission.denied || permission == LocationPermission.deniedForever) { setZeroLocation(); if (isShowConfirmDialog) showErrorLocationDialog(false); } @@ -64,11 +59,12 @@ class LocationUtils { } LocationCallback _locationCallback; - _getHMSCurrentLocation(Function(LatLng) callBack) async{ + + _getHMSCurrentLocation(Function(LatLng) callBack) async { PermissionHandler permissionHandler = PermissionHandler(); int _locationUpdateCbId = 0; - doIt(){ + doIt() { FusedLocationProviderClient locationService = FusedLocationProviderClient(); LocationRequest locationRequest = LocationRequest(); locationRequest.priority = LocationRequest.PRIORITY_HIGH_ACCURACY; @@ -76,37 +72,31 @@ class LocationUtils { List locationRequestList = [locationRequest]; LocationSettingsRequest locationSettingsRequest = LocationSettingsRequest(requests: locationRequestList); - locationService.checkLocationSettings(locationSettingsRequest).then((settings) async{ - - _locationUpdateCbId = await locationService.requestLocationUpdatesCb(locationRequest, LocationCallback(onLocationResult: (locationResult){ - Location location = locationResult.lastLocation; - locationService.removeLocationUpdatesCb(_locationUpdateCbId); - callBack(LatLng(location.latitude, location.longitude)); - setLocation(Position(latitude: location.latitude, longitude: location.longitude, altitude: location.altitude)); - }, onLocationAvailability: (locationAvailability){ - debugPrint("onLocationAvailability: $locationAvailability"); - })); - - }).catchError((error){ - - if(error.code == "LOCATION_SETTINGS_NOT_AVAILABLE"){ + locationService.checkLocationSettings(locationSettingsRequest).then((settings) async { + _locationUpdateCbId = await locationService.requestLocationUpdatesCb( + locationRequest, + LocationCallback(onLocationResult: (locationResult) { + Location location = locationResult.lastLocation; + locationService.removeLocationUpdatesCb(_locationUpdateCbId); + callBack(LatLng(location.latitude, location.longitude)); + setLocation(Position(latitude: location.latitude, longitude: location.longitude, altitude: location.altitude)); + }, onLocationAvailability: (locationAvailability) { + debugPrint("onLocationAvailability: $locationAvailability"); + })); + }).catchError((error) { + if (error.code == "LOCATION_SETTINGS_NOT_AVAILABLE") { // Location service not enabled. } - }); - } - - if(await permissionHandler.hasLocationPermission()){ + if (await permissionHandler.hasLocationPermission()) { doIt(); - }else{ + } else { bool has = await requestPermissions(); - if(has) + if (has) doIt(); - else if(isShowConfirmDialog) - showErrorLocationDialog(false); - + else if (isShowConfirmDialog) showErrorLocationDialog(false); } } @@ -116,24 +106,14 @@ class LocationUtils { confirmMessage: TranslationBase.of(context).locationDialogMessage, okText: TranslationBase.of(context).confirm, cancelText: TranslationBase.of(context).cancel_nocaps, - okFunction: () => { - ConfirmDialog.closeAlertDialog(context), - if (isPermissionError) - Geolocator.openAppSettings() - else - Geolocator.openLocationSettings() - }, + okFunction: () => {ConfirmDialog.closeAlertDialog(context), if (isPermissionError) Geolocator.openAppSettings() else Geolocator.openLocationSettings()}, cancelFunction: () => {}); return dialog.showAlertDialog(context); } void setLocation(Position position) { - this - .sharedPref - .setDouble(USER_LAT, position != null ? position.latitude : 0.0); - this - .sharedPref - .setDouble(USER_LONG, position != null ? position.longitude : 0.0); + this.sharedPref.setDouble(USER_LAT, position != null ? position.latitude : 0.0); + this.sharedPref.setDouble(USER_LONG, position != null ? position.longitude : 0.0); } void setZeroLocation() { @@ -141,7 +121,6 @@ class LocationUtils { this.sharedPref.setDouble(USER_LONG, 0.0); } - Future requestPermissions() async { var result = await [ Permission.location, diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index 46d21fae..22d56539 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -564,6 +564,8 @@ class _AppDrawerState extends State { Provider.of(context, listen: false).user = authenticatedUserObject.user; Provider.of(context, listen: false).setUser(authenticatedUserObject.user); await pharmacyModuleViewModel.generatePharmacyToken(); + _vitalSignService.heightCm = ""; + _vitalSignService.weightKg = ""; if (pharmacyModuleViewModel.error.isNotEmpty) await pharmacyModuleViewModel.createUser();