From e3bf988df5393cdee3d3a57899708da669ca1442 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 1 Dec 2021 17:20:28 +0300 Subject: [PATCH] map picker, firebase improvement and changes for v2.5 --- .../cloud/diplomaticquarterapp/Application.kt | 6 +- .../FirebaseCloudMessagingPluginRegistrant.kt | 4 +- lib/core/service/client/base_app_client.dart | 18 +- lib/main.dart | 17 +- .../NewCMC/new_cmc_page.dart | 4 +- .../NewCMC/new_cmc_step_one_page.dart | 16 +- .../NewCMC/new_cmc_step_tow_page.dart | 2 +- .../orders_log_details_page.dart | 2 +- .../new_e_referral_step_one_page.dart | 2 +- .../new_e_referral_step_three_page.dart | 2 +- .../new_e_referral_step_two_page.dart | 4 +- .../E-Referral/search_for_referrals_page.dart | 4 +- .../NewHomeHealthCare/location_page.dart | 159 ++- .../new_Home_health_care_step_tow_page.dart | 2 +- .../new_home_health_care_page.dart | 33 +- .../orders_log_details_page.dart | 2 +- .../h2o/h20_setting.dart | 4 +- .../AlHabibMedicalService/h2o/today_page.dart | 2 +- lib/pages/Blood/blood_donation.dart | 6 +- lib/pages/Blood/confirm_payment_page.dart | 2 +- lib/pages/Blood/new_text_Field.dart | 2 +- .../widgets/reminder_dialog.dart | 8 +- .../ChildVaccines/add_newchild_page.dart | 2 +- .../ChildVaccines/vaccinationtable_page.dart | 2 +- lib/pages/DrawerPages/family/my-family.dart | 2 +- .../notification_details_page.dart | 106 +- .../notifications/notifications_page.dart | 90 +- .../AmbulanceRequestIndex.dart | 2 +- .../PickupLocation.dart | 4 +- lib/pages/ErService/OrderLogPage.dart | 2 +- .../rrt-pickup-address-page.dart | 2 +- lib/pages/conference/conference_page.dart | 780 ++++++------ lib/pages/conference/conference_room.dart | 1059 ++++++++--------- lib/pages/feedback/send_feedback_page.dart | 2 +- lib/pages/feedback/status_feedback_page.dart | 2 +- .../insurance_card_update_details.dart | 2 +- lib/pages/landing/landing_page.dart | 263 ++-- lib/pages/livecare/incoming_call.dart | 14 +- .../livecare/widgets/LiveCareHistoryCard.dart | 2 +- .../widgets/LiveCarePendingRequest.dart | 2 +- lib/pages/login/confirm-login.dart | 2 +- lib/pages/login/login-type.dart | 2 +- .../active_medications/reminder_page.dart | 2 +- .../medical/balance/advance_payment_page.dart | 8 +- lib/pages/medical/balance/new_text_Field.dart | 2 +- lib/pages/medical/eye/ClassesPage.dart | 2 +- lib/pages/medical/eye/ContactLensPage.dart | 2 +- lib/pages/medical/eye/EyeHomePage.dart | 2 +- .../my_trackers/Weight/AddWeightPage.dart | 6 +- .../my_trackers/Weight/WeightHomePage.dart | 2 +- .../blood_pressure/AddBloodPressurePage.dart | 2 +- .../blood_pressure/BloodPressureHomePage.dart | 2 +- .../blood_suger/AddBloodSugarPage.dart | 6 +- .../blood_suger/blood_sugar_home_page.dart | 2 +- .../widget/CurvedChartBloodPressure.dart | 43 +- .../my_trackers/widget/LineChartCurved.dart | 6 +- .../widget/MonthCurvedChartBloodPressure.dart | 6 +- .../widget/MonthLineChartCurved.dart | 6 +- .../medical/patient_sick_leave_page.dart | 2 +- .../PrescriptionIDeliveryAddressPage.dart | 299 +++-- .../PrescriptionOrderOverveiw.dart | 4 +- .../pharmacy_for_prescriptions_page.dart | 8 +- .../prescription_details_inp.dart | 482 ++++---- .../prescription_details_page.dart | 33 +- .../prescription_items_page.dart | 3 +- .../radiology/radiology_details_page.dart | 2 +- .../medical/reports/report_list_widget.dart | 2 +- lib/pages/medical/reports/reports_page.dart | 2 +- .../medical/vital_sign/LineChartCurved.dart | 6 +- .../LineChartCurvedBloodPressure.dart | 6 +- .../OfferAndPackagesCartPage.dart | 2 +- .../packages_offers/OfferAndPackagesPage.dart | 2 +- lib/pages/pharmacy/order/TrackDriver.dart | 682 +++++------ lib/pages/pharmacy/profile/profile.dart | 2 +- lib/pages/vaccine/my_vaccines_screen.dart | 2 +- lib/pages/webRTC/call_page.dart | 37 +- lib/uitl/LocalNotification.dart | 17 +- lib/uitl/gif_loader_dialog_utils.dart | 6 +- lib/widgets/bottom_options/BottomSheet.dart | 4 +- lib/widgets/charts/custom_line_chart.dart | 7 +- lib/widgets/charts/show_chart.dart | 8 +- .../medical/LabResult/LabResultWidget.dart | 2 +- .../medical/LabResult/LineChartCurved.dart | 6 +- .../dialogs/radio_selection_dialog.dart | 53 +- lib/widgets/in_app_browser/InAppBrowser.dart | 53 +- lib/widgets/new_design/doctor_header.dart | 2 +- .../offers_packages/offers_packages.dart | 2 +- .../others/floating_button_search.dart | 2 +- lib/widgets/others/not_auh_page.dart | 2 +- lib/widgets/otp/sms-popup.dart | 12 +- pubspec.yaml | 137 ++- speech_to_text/pubspec.yaml | 10 +- 92 files changed, 2308 insertions(+), 2333 deletions(-) diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/Application.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/Application.kt index a9c5ea88..e179bc6a 100644 --- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/Application.kt +++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/Application.kt @@ -5,12 +5,12 @@ import com.facebook.stetho.Stetho import io.flutter.app.FlutterApplication import io.flutter.plugin.common.PluginRegistry import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback -import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService +//import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService class Application : FlutterApplication(), PluginRegistrantCallback { override fun onCreate() { super.onCreate() - FlutterFirebaseMessagingService.setPluginRegistrant(this) + // FlutterFirebaseMessagingService.setPluginRegistrant(this) // Stetho.initializeWithDefaults(this); // Create an InitializerBuilder @@ -38,7 +38,7 @@ class Application : FlutterApplication(), PluginRegistrantCallback { } override fun registerWith(registry: PluginRegistry) { - io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin")); + // io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin")); } } diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/FirebaseCloudMessagingPluginRegistrant.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/FirebaseCloudMessagingPluginRegistrant.kt index 9ac064cb..4e9e8ce1 100644 --- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/FirebaseCloudMessagingPluginRegistrant.kt +++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/FirebaseCloudMessagingPluginRegistrant.kt @@ -2,14 +2,14 @@ package com.ejada.hmg import io.flutter.plugin.common.PluginRegistry -import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin +//import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin object FirebaseCloudMessagingPluginRegistrant { fun registerWith(registry: PluginRegistry?) { if (alreadyRegisteredWith(registry)) { return } - FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin")) + // FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin")) } private fun alreadyRegisteredWith(registry: PluginRegistry?): Boolean { diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index f9361e90..ced7eb9c 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -134,7 +134,7 @@ class BaseAppClient { print(jsonBody); if (await Utils.checkConnection()) { - final response = await http.post(url.trim(), body: json.encode(body), headers: headers); + final response = await http.post(Uri.parse(url.trim()), body: json.encode(body), headers: headers); final int statusCode = response.statusCode; print("statusCode :$statusCode"); if (statusCode < 200 || statusCode >= 400 || json == null) { @@ -307,7 +307,7 @@ class BaseAppClient { print("Body : ${json.encode(body)}"); if (await Utils.checkConnection()) { - final response = await http.post(url.trim(), body: json.encode(body), headers: headers); + final response = await http.post(Uri.parse(url.trim()), body: json.encode(body), headers: headers); final int statusCode = response.statusCode; print("statusCode :$statusCode"); if (statusCode < 200 || statusCode >= 400 || json == null) { @@ -408,7 +408,7 @@ class BaseAppClient { if (await Utils.checkConnection()) { final response = await http.get( - url.trim(), + Uri.parse(url.trim()), headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}, ); final int statusCode = response.statusCode; @@ -450,7 +450,7 @@ class BaseAppClient { var ss = json.encode(queryParams); if (await Utils.checkConnection()) { - final response = await http.get(url.trim(), headers: { + final response = await http.get(Uri.parse(url.trim()), headers: { 'Content-Type': 'text/html; charset=utf-8', 'Accept': 'application/json', 'Authorization': token ?? '', @@ -494,7 +494,7 @@ class BaseAppClient { if (await Utils.checkConnection()) { headers.addAll({'Content-Type': 'application/json', 'Accept': 'application/json'}); final response = await http.post( - url.trim(), + Uri.parse(url.trim()), body: json.encode(body), headers: headers, ); @@ -526,7 +526,7 @@ class BaseAppClient { if (await Utils.checkConnection()) { headers.addAll({'Content-Type': 'application/json', 'Accept': 'application/json'}); final response = await http.get( - url.trim(), + Uri.parse(url.trim()), headers: headers, ); @@ -551,7 +551,7 @@ class BaseAppClient { if (await Utils.checkConnection()) { headers.addAll({'Content-Type': 'application/json', 'Accept': 'application/json'}); final response = await http.put( - url.trim(), + Uri.parse(url.trim()), body: json.encode(body), headers: headers, ); @@ -585,7 +585,7 @@ class BaseAppClient { if (await Utils.checkConnection()) { headers.addAll({'Content-Type': 'application/json', 'Accept': 'application/json'}); final response = await http.delete( - url.trim(), + Uri.parse(url.trim()), headers: headers, ); @@ -726,7 +726,7 @@ class BaseAppClient { var ss = json.encode(body); if (await Utils.checkConnection()) { - final response = await http.post(url.trim(), body: json.encode(body), headers: { + final response = await http.post(Uri.parse(url.trim()), body: json.encode(body), headers: { // 'Content-Type': 'application/json', // 'Accept': 'application/json', // 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', diff --git a/lib/main.dart b/lib/main.dart index 15e91291..9bb465f8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -11,6 +11,7 @@ import 'package:diplomaticquarterapp/uitl/PlatformBridge.dart'; import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:firebase_core/firebase_core.dart'; +import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; @@ -23,11 +24,17 @@ import 'core/viewModels/project_view_model.dart'; import 'locator.dart'; import 'pages/pharmacies/compare-list.dart'; + +Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async { + await Firebase.initializeApp(); + print("Handling a background message: ${message.messageId}"); +} + void main() async { WidgetsFlutterBinding.ensureInitialized(); - FirebaseApp defaultApp = await Firebase.initializeApp(); - - await setupLocator(); + // FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler); + await Firebase.initializeApp(); + setupLocator(); runApp(MyApp()); } @@ -41,9 +48,9 @@ class _MyApp extends State { final GlobalKey navigatorKey = GlobalKey(); - Future checkForUpdate() async { + Future checkForUpdate() async { // todo need to verify 'imp' InAppUpdate.checkForUpdate().then((info) { - if (info.updateAvailable) { + if (info.immediateUpdateAllowed) { InAppUpdate.performImmediateUpdate().then((value) {}).catchError((e) => print(e.toString())); } }).catchError((e) { diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_page.dart index 5ef5089c..4a7f33f0 100644 --- a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_page.dart +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_page.dart @@ -63,7 +63,7 @@ class _NewCMCPageState extends State with TickerProviderStateMixin { } _getCurrentLocation() async { - await getLastKnownPosition().then((value) { + await Geolocator.getLastKnownPosition().then((value) { _latitude = value.latitude; _longitude = value.longitude; }).catchError((e) { @@ -89,7 +89,7 @@ class _NewCMCPageState extends State with TickerProviderStateMixin { void showConfirmMessage(CMCViewModel model, GetCMCAllOrdersResponseModel order) { showDialog( context: context, - child: ConfirmWithMessageDialog( + builder: (cxt) => ConfirmWithMessageDialog( message: TranslationBase.of(context).cancelOrderMsg, onTap: () async { UpdatePresOrderRequestModel updatePresOrderRequestModel = UpdatePresOrderRequestModel(presOrderID: order.iD, rejectionReason: "", presOrderStatus: 4, editedBy: 3); diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_one_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_one_page.dart index 5e2b0498..e6eefefe 100644 --- a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_one_page.dart +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_one_page.dart @@ -1,14 +1,11 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; -import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_get_items_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/dragable_sheet.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/photo_view_page.dart'; @@ -125,7 +122,10 @@ class _NewCMCStepOnePageState extends State { ), margin: EdgeInsets.all(12), child: IconButton( - icon: SvgPicture.asset("assets/images/new/ic_zoom.svg",color: Colors.white,), + icon: SvgPicture.asset( + "assets/images/new/ic_zoom.svg", + color: Colors.white, + ), padding: EdgeInsets.all(12), onPressed: () { showDraggableDialog(context, PhotoViewPage(projectViewModel.isArabic ? "assets/images/cc_ar.png" : "assets/images/cc_en.png")); @@ -162,9 +162,9 @@ class _NewCMCStepOnePageState extends State { widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList = [patientERCMCInsertServicesList]; await widget.model.getCustomerInfo(); - // if (widget.model.state == ViewState.ErrorLocal) { - // Utils.showErrorToast(); - // } else { + if (widget.model.state == ViewState.ErrorLocal) { + Utils.showErrorToast(); + } else { navigateTo( context, NewCMCStepTowPage( @@ -174,7 +174,7 @@ class _NewCMCStepOnePageState extends State { model: widget.model, ), ); - // } + } } }, ), diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart index 4a3f8447..42c8186a 100644 --- a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart @@ -284,7 +284,7 @@ class _NewCMCStepTowPageState extends State { void confirmSelectLocationDialog(List addresses) { showDialog( context: context, - child: SelectLocationDialog( + builder: (cxt) => SelectLocationDialog( addresses: addresses, selectedAddress: _selectedAddress, onValueSelected: (value) { diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/orders_log_details_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/orders_log_details_page.dart index 48b904aa..78c1d140 100644 --- a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/orders_log_details_page.dart +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/orders_log_details_page.dart @@ -32,7 +32,7 @@ class OrdersLogDetailsPage extends StatelessWidget { void showConfirmMessage(CMCViewModel model, GetCMCAllOrdersResponseModel order) { showDialog( context: context, - child: ConfirmWithMessageDialog( + builder: (cxt) => ConfirmWithMessageDialog( message: TranslationBase.of(context).cancelOrderMsg, onTap: () { UpdatePresOrderRequestModel updatePresOrderRequestModel = UpdatePresOrderRequestModel(presOrderID: order.iD, rejectionReason: "", presOrderStatus: 4, editedBy: 3); diff --git a/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_one_page.dart b/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_one_page.dart index 25efb016..363b46e2 100644 --- a/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_one_page.dart +++ b/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_one_page.dart @@ -238,7 +238,7 @@ class _NewEReferralStepOnePageState extends State { void confirmSelectRelationTypeDialog(List relations) { showDialog( context: context, - child: SelectRelationTypeDialog( + builder: (cxt) => SelectRelationTypeDialog( relationTypes: relations, selectedRelation: _selectedRelation, onValueSelected: (value) { diff --git a/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_three_page.dart b/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_three_page.dart index 439a9ec7..cf6428c8 100644 --- a/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_three_page.dart +++ b/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_three_page.dart @@ -459,7 +459,7 @@ class _NewEReferralStepThreePageState extends State { void confirmSelectCityDialog(List cities) { showDialog( context: context, - child: SelectCityDialog( + builder: (cxt) => SelectCityDialog( cities: cities, selectedCity: _selectedCity, onValueSelected: (value) { diff --git a/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_two_page.dart b/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_two_page.dart index 57341838..a953705e 100644 --- a/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_two_page.dart +++ b/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_two_page.dart @@ -270,7 +270,7 @@ class _NewEReferralStepTowPageState extends State { void confirmSelectCityDialog(List cities) { showDialog( context: context, - child: SelectCityDialog( + builder: (cxt) => SelectCityDialog( cities: cities, selectedCity: _selectedCity, onValueSelected: (value) { @@ -285,7 +285,7 @@ class _NewEReferralStepTowPageState extends State { void confirmSelectCountryTypeDialog() { showDialog( context: context, - child: SelectCountryDialog( + builder: (cxt) => SelectCountryDialog( selectedCountry: _selectedCountry, onValueSelected: (value) { setState(() { diff --git a/lib/pages/AlHabibMedicalService/E-Referral/search_for_referrals_page.dart b/lib/pages/AlHabibMedicalService/E-Referral/search_for_referrals_page.dart index 5751dcfe..b2277560 100644 --- a/lib/pages/AlHabibMedicalService/E-Referral/search_for_referrals_page.dart +++ b/lib/pages/AlHabibMedicalService/E-Referral/search_for_referrals_page.dart @@ -89,7 +89,7 @@ class _SearchForReferralsPageState extends State { } showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: selectedCriteria.value, onValueSelected: (index) { @@ -229,7 +229,7 @@ class _SearchForReferralsPageState extends State { void confirmSelectCountryTypeDialog() { showDialog( context: context, - child: SelectCountryDialog( + builder: (cxt) => SelectCountryDialog( selectedCountry: _selectedCountry, onValueSelected: (value) { setState(() { diff --git a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart index 58d66b3d..7a4c02a4 100644 --- a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart +++ b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart @@ -7,7 +7,7 @@ import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -46,90 +46,81 @@ class _LocationPageState extends State { Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( - onModelReady: (model) {}, - builder: (_, model, widget) => AppScaffold( - appBarTitle: TranslationBase.of(context).addAddress, - isShowDecPage: false, - isShowAppBar: true, - baseViewModel: model, - showNewAppBarTitle: true, - showNewAppBar: true, - body: PlacePicker( - apiKey: GOOGLE_API_KEY, - enableMyLocationButton: true, - automaticallyImplyAppBarLeading: false, - autocompleteOnTrailingWhitespace: true, - selectInitialPosition: true, - autocompleteLanguage: projectViewModel.currentLanguage, - enableMapTypeButton: true, - searchForInitialValue: false, - onPlacePicked: (PickResult result) { - print(result.adrAddress); - }, - selectedPlaceWidgetBuilder: (_, selectedPlace, state, isSearchBarFocused) { - print("state: $state, isSearchBarFocused: $isSearchBarFocused"); - return isSearchBarFocused - ? Container() - : FloatingCard( - bottomPosition: 0.0, - leftPosition: 0.0, - rightPosition: 0.0, - width: 500, - borderRadius: BorderRadius.circular(12.0), - child: state == SearchingState.Searching - ? Center(child: CircularProgressIndicator()) - : Container( - margin: EdgeInsets.all(12), - child: Column( - children: [ - SecondaryButton( - color: Colors.grey[800], - textColor: Colors.white, - onTap: () async { - AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel( - customer: Customer(addresses: [ - Addresses( - address1: selectedPlace.formattedAddress, - address2: selectedPlace.formattedAddress, - customerAttributes: "", - city: "", - createdOnUtc: "", - id: 0, - latLong: "$latitude,$longitude", - email: "") - ]), - ); + onModelReady: (model) {}, + builder: (_, model, widget) => AppScaffold( + appBarTitle: TranslationBase.of(context).addAddress, + isShowDecPage: false, + isShowAppBar: true, + baseViewModel: model, + showNewAppBarTitle: true, + showNewAppBar: true, + body: PlacePicker( + apiKey: GOOGLE_API_KEY, + enableMyLocationButton: true, + automaticallyImplyAppBarLeading: false, + autocompleteOnTrailingWhitespace: true, + selectInitialPosition: true, + autocompleteLanguage: projectViewModel.currentLanguage, + enableMapTypeButton: true, + searchForInitialValue: false, + onPlacePicked: (PickResult result) { + print("onPlacePickedonPlacePickedonPlacePickedonPlacePicked"); + print(result.adrAddress); + }, + selectedPlaceWidgetBuilder: (_, selectedPlace, state, isSearchBarFocused) { + return isSearchBarFocused + ? Container() + : FloatingCard( + bottomPosition: 0.0, + leftPosition: 0.0, + rightPosition: 0.0, + width: 500, + borderRadius: BorderRadius.circular(0.0), + child: state == SearchingState.Searching + ? SizedBox(height: 43,child: Center(child: CircularProgressIndicator())).insideContainer + : DefaultButton(TranslationBase.of(context).addNewAddress, () async { - selectedPlace.addressComponents.forEach((e) { - if (e.types.contains("country")) { - addNewAddressRequestModel.customer.addresses[0].country = e.longName; - } - if (e.types.contains("postal_code")) { - addNewAddressRequestModel.customer.addresses[0].zipPostalCode = e.longName; - } - if (e.types.contains("locality")) { - addNewAddressRequestModel.customer.addresses[0].city = e.longName; - } - }); + // print(); + AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel( + customer: Customer(addresses: [ + Addresses( + address1: selectedPlace.formattedAddress, + address2: selectedPlace.formattedAddress, + customerAttributes: "", + city: "", + createdOnUtc: "", + id: 0, + latLong: "${selectedPlace.geometry.location}", + email: "") + ]), + ); - await model.addAddressInfo(addNewAddressRequestModel: addNewAddressRequestModel); - if (model.state == ViewState.ErrorLocal) { - Utils.showErrorToast(model.error); - } else { - AppToast.showSuccessToast(message: "Address Added Successfully"); - } - Navigator.of(context).pop(addNewAddressRequestModel); - }, - label: TranslationBase.of(context).addNewAddress, - ), - ], - ), - ), - ); - }, - initialPosition: LatLng(latitude, longitude), - useCurrentLocation: showCurrentLocation, - ), - )); + selectedPlace.addressComponents.forEach((e) { + if (e.types.contains("country")) { + addNewAddressRequestModel.customer.addresses[0].country = e.longName; + } + if (e.types.contains("postal_code")) { + addNewAddressRequestModel.customer.addresses[0].zipPostalCode = e.longName; + } + if (e.types.contains("locality")) { + addNewAddressRequestModel.customer.addresses[0].city = e.longName; + } + }); + + await model.addAddressInfo(addNewAddressRequestModel: addNewAddressRequestModel); + if (model.state == ViewState.ErrorLocal) { + Utils.showErrorToast(model.error); + } else { + AppToast.showSuccessToast(message: "Address Added Successfully"); + } + Navigator.of(context).pop(addNewAddressRequestModel); + }).insideContainer + ); + }, + initialPosition: LatLng(latitude, longitude), + useCurrentLocation: showCurrentLocation, + ), + ), + ); } } diff --git a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_tow_page.dart b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_tow_page.dart index 31518f61..10418bc2 100644 --- a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_tow_page.dart +++ b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_tow_page.dart @@ -279,7 +279,7 @@ class _NewHomeHealthCareStepTowPageState extends State addresses) { showDialog( context: context, - child: SelectLocationDialog( + builder: (cxt) => SelectLocationDialog( addresses: addresses, selectedAddress: _selectedAddress, onValueSelected: (value) { diff --git a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_home_health_care_page.dart b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_home_health_care_page.dart index 82f91cff..fce9c4b0 100644 --- a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_home_health_care_page.dart +++ b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_home_health_care_page.dart @@ -8,7 +8,6 @@ import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/ConfirmWithMessageDialog.dart'; import 'package:flutter/material.dart'; import 'package:geolocator/geolocator.dart'; @@ -41,7 +40,7 @@ class _NewHomeHealthCarePageState extends State with Tick } _getCurrentLocation() async { - await getLastKnownPosition().then((value) { + await Geolocator.getLastKnownPosition().then((value) { _latitude = value.latitude; _longitude = value.longitude; }).catchError((e) { @@ -67,22 +66,22 @@ class _NewHomeHealthCarePageState extends State with Tick void showConfirmMessage(HomeHealthCareViewModel model, GetCMCAllOrdersResponseModel order) { showDialog( context: context, - child: ConfirmWithMessageDialog( - message: TranslationBase.of(context).cancelOrderMsg, - onTap: () async { - model.setState(ViewState.Busy); - UpdatePresOrderRequestModel updatePresOrderRequestModel = UpdatePresOrderRequestModel(presOrderID: order.iD, rejectionReason: "", presOrderStatus: 4, editedBy: 3); + builder: (cxt) => ConfirmWithMessageDialog( + message: TranslationBase.of(context).cancelOrderMsg, + onTap: () async { + model.setState(ViewState.Busy); + UpdatePresOrderRequestModel updatePresOrderRequestModel = UpdatePresOrderRequestModel(presOrderID: order.iD, rejectionReason: "", presOrderStatus: 4, editedBy: 3); - await model.updateHHCPresOrder(updatePresOrderRequestModel); - if (model.state == ViewState.ErrorLocal) { - Utils.showErrorToast(model.error); - } else { - AppToast.showSuccessToast(message: TranslationBase.of(context).processDoneSuccessfully); - await model.getHHCAllPresOrders(); - // await model.getHHCAllServices(); - } - }, - )); + await model.updateHHCPresOrder(updatePresOrderRequestModel); + if (model.state == ViewState.ErrorLocal) { + Utils.showErrorToast(model.error); + } else { + AppToast.showSuccessToast(message: TranslationBase.of(context).processDoneSuccessfully); + await model.getHHCAllPresOrders(); + // await model.getHHCAllServices(); + } + }, + )); } ProjectViewModel projectViewModel = Provider.of(context); diff --git a/lib/pages/AlHabibMedicalService/HomeHealthCare/orders_log_details_page.dart b/lib/pages/AlHabibMedicalService/HomeHealthCare/orders_log_details_page.dart index e14d07e8..620920de 100644 --- a/lib/pages/AlHabibMedicalService/HomeHealthCare/orders_log_details_page.dart +++ b/lib/pages/AlHabibMedicalService/HomeHealthCare/orders_log_details_page.dart @@ -28,7 +28,7 @@ class OrdersLogDetailsPage extends StatelessWidget { void showConfirmMessage(HomeHealthCareViewModel model, GetCMCAllOrdersResponseModel order) { showDialog( context: context, - child: ConfirmWithMessageDialog( + builder: (cxt) => ConfirmWithMessageDialog( message: TranslationBase.of(context).cancelOrderMsg, onTap: () async { UpdatePresOrderRequestModel updatePresOrderRequestModel = UpdatePresOrderRequestModel(presOrderID: order.iD, rejectionReason: "", presOrderStatus: 4, editedBy: 3); diff --git a/lib/pages/AlHabibMedicalService/h2o/h20_setting.dart b/lib/pages/AlHabibMedicalService/h2o/h20_setting.dart index edc82034..38d7a568 100644 --- a/lib/pages/AlHabibMedicalService/h2o/h20_setting.dart +++ b/lib/pages/AlHabibMedicalService/h2o/h20_setting.dart @@ -271,7 +271,7 @@ class _H2oSettingState extends State { showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: _selectedActiveLevel, onValueSelected: (index) { @@ -300,7 +300,7 @@ class _H2oSettingState extends State { showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: _selectedRemindedTime, onValueSelected: (index) { diff --git a/lib/pages/AlHabibMedicalService/h2o/today_page.dart b/lib/pages/AlHabibMedicalService/h2o/today_page.dart index 984d0680..7b10078b 100644 --- a/lib/pages/AlHabibMedicalService/h2o/today_page.dart +++ b/lib/pages/AlHabibMedicalService/h2o/today_page.dart @@ -341,7 +341,7 @@ class _TodayPageState extends State { String title = "${TranslationBase.of(context).areyousure} $amount ${(isUnitML ? TranslationBase.of(context).ml : TranslationBase.of(context).l).toLowerCase()} ?"; await showDialog( context: context, - child: ConfirmWithMessageDialog( + builder: (cxt) => ConfirmWithMessageDialog( message: title, onTap: () async { GifLoaderDialogUtils.showMyDialog(context); diff --git a/lib/pages/Blood/blood_donation.dart b/lib/pages/Blood/blood_donation.dart index b61cd4fc..717be242 100644 --- a/lib/pages/Blood/blood_donation.dart +++ b/lib/pages/Blood/blood_donation.dart @@ -149,7 +149,7 @@ class _BloodDonationPageState extends State { showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: _selectedHospitalIndex, isScrollable: true, @@ -170,7 +170,7 @@ class _BloodDonationPageState extends State { showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: _selectedGenderIndex, onValueSelected: (index) { @@ -195,7 +195,7 @@ class _BloodDonationPageState extends State { showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: _selectedBloodTypeIndex, isScrollable: true, diff --git a/lib/pages/Blood/confirm_payment_page.dart b/lib/pages/Blood/confirm_payment_page.dart index 96e8d593..51142817 100644 --- a/lib/pages/Blood/confirm_payment_page.dart +++ b/lib/pages/Blood/confirm_payment_page.dart @@ -44,7 +44,7 @@ class ConfirmPaymentPage extends StatelessWidget { showDialog( context: context, barrierDismissible: false, - child: ConfirmSMSDialog( + builder: (cxt) => ConfirmSMSDialog( phoneNumber: patientInfoAndMobileNumber.mobileNumber, ), ).then((value) { diff --git a/lib/pages/Blood/new_text_Field.dart b/lib/pages/Blood/new_text_Field.dart index 8506ac6a..643e1a93 100644 --- a/lib/pages/Blood/new_text_Field.dart +++ b/lib/pages/Blood/new_text_Field.dart @@ -192,7 +192,7 @@ class _NewTextFieldsState extends State { style: Theme.of(context) .textTheme - .body2 + .bodyText2 .copyWith(fontSize: widget.fontSize, fontWeight: widget.fontWeight), inputFormatters: widget.keyboardType == TextInputType.phone ? [ diff --git a/lib/pages/BookAppointment/widgets/reminder_dialog.dart b/lib/pages/BookAppointment/widgets/reminder_dialog.dart index 723bf538..6fcab59a 100644 --- a/lib/pages/BookAppointment/widgets/reminder_dialog.dart +++ b/lib/pages/BookAppointment/widgets/reminder_dialog.dart @@ -43,20 +43,20 @@ Future _showReminderDialog(BuildContext context, DateTime dateTime, String onClick: (int i) async { if (i == 0) { // Before 30 mints - dateTime = Jiffy(dateTime).subtract(minutes: 30); + dateTime = Jiffy(dateTime).subtract(minutes: 30).dateTime; // dateTime.add(new Duration(minutes: -30)); } else if (i == 1) { // Before 1 hour // dateTime.add(new Duration(minutes: -60)); - dateTime = Jiffy(dateTime).subtract(hours: 1); + dateTime = Jiffy(dateTime).subtract(hours: 1).dateTime; } else if (i == 2) { // Before 1 hour and 30 mints // dateTime.add(new Duration(minutes: -90)); - dateTime = Jiffy(dateTime).subtract(hours: 1, minutes: 30); + dateTime = Jiffy(dateTime).subtract(hours: 1, minutes: 30).dateTime; } else if (i == 3) { // Before 2 hours // dateTime.add(new Duration(minutes: -120)); - dateTime = Jiffy(dateTime).subtract(hours: 2); + dateTime = Jiffy(dateTime).subtract(hours: 2).dateTime; } if (onMultiDateSuccess == null) { CalendarUtils calendarUtils = await CalendarUtils.getInstance(); diff --git a/lib/pages/ChildVaccines/add_newchild_page.dart b/lib/pages/ChildVaccines/add_newchild_page.dart index fa526360..0711fa85 100644 --- a/lib/pages/ChildVaccines/add_newchild_page.dart +++ b/lib/pages/ChildVaccines/add_newchild_page.dart @@ -300,7 +300,7 @@ class _AddNewChildPageState extends State { void confirmSelectDayDialog() { showDialog( context: context, - child: DayCheckBoxDialog( + builder: (cxt) => DayCheckBoxDialog( title: 'Select Day', selectedDaysOfWeek: widget.daysOfWeek, onValueSelected: (value) { diff --git a/lib/pages/ChildVaccines/vaccinationtable_page.dart b/lib/pages/ChildVaccines/vaccinationtable_page.dart index 45a63414..9aa7b6c0 100644 --- a/lib/pages/ChildVaccines/vaccinationtable_page.dart +++ b/lib/pages/ChildVaccines/vaccinationtable_page.dart @@ -145,7 +145,7 @@ class VaccinationTablePage extends StatelessWidget { //=============== showDialog( context: context, - child: SelectGenderDialog( + builder: (cxt) => SelectGenderDialog( okFunction: () async { await model.getCreateVaccinationTable(babyInfo, true); if (model.state == ViewState.Idle) { diff --git a/lib/pages/DrawerPages/family/my-family.dart b/lib/pages/DrawerPages/family/my-family.dart index f3658fae..54ca8ce7 100644 --- a/lib/pages/DrawerPages/family/my-family.dart +++ b/lib/pages/DrawerPages/family/my-family.dart @@ -595,7 +595,7 @@ class _MyFamily extends State with TickerProviderStateMixin { deleteFamily(family, context) { showDialog( context: context, - child: ConfirmWithMessageDialog( + builder: (cxt) => ConfirmWithMessageDialog( message: TranslationBase.of(context).removeFamilyMember, onTap: () { removeFamily(family, context); diff --git a/lib/pages/DrawerPages/notifications/notification_details_page.dart b/lib/pages/DrawerPages/notifications/notification_details_page.dart index 4e249e53..ed31b3fc 100644 --- a/lib/pages/DrawerPages/notifications/notification_details_page.dart +++ b/lib/pages/DrawerPages/notifications/notification_details_page.dart @@ -1,9 +1,6 @@ import 'package:diplomaticquarterapp/core/model/notifications/get_notifications_response_model.dart'; -import 'package:diplomaticquarterapp/core/viewModels/notifications_view_model.dart'; -import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; import 'package:flutter/material.dart'; @@ -17,9 +14,7 @@ class NotificationsDetailsPage extends StatelessWidget { DateTime d = DateUtil.convertStringToDate(date); String monthName = DateUtil.getMonth(d.month).toString(); TimeOfDay timeOfDay = TimeOfDay(hour: d.hour, minute: d.minute); - String minute = timeOfDay.minute < 10 - ? timeOfDay.minute.toString().padLeft(2, '0') - : timeOfDay.minute.toString(); + String minute = timeOfDay.minute < 10 ? timeOfDay.minute.toString().padLeft(2, '0') : timeOfDay.minute.toString(); String hour = '${timeOfDay.hourOfPeriod}:$minute'; if (timeOfDay.period == DayPeriod.am) { @@ -39,67 +34,50 @@ class NotificationsDetailsPage extends StatelessWidget { showNewAppBar: true, showNewAppBarTitle: true, appBarTitle: TranslationBase.of(context).notificationDetails, - body: SingleChildScrollView( - child: Center( - child: FractionallySizedBox( - widthFactor: 0.9, - child: Column( - children: [ - SizedBox( - height: 25, - ), - Container( - width: double.infinity, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(notification.createdOn)) + " " + DateUtil.formatDateToTimeLang(DateUtil.convertStringToDate(notification.createdOn), false), - style: TextStyle( - fontSize: 18.0, - color: Colors.black, - fontWeight: FontWeight.w600 - ), - ), - ), - ), - SizedBox( - height: 15, - ), - if (notification.messageTypeData.length != 0) - FractionallySizedBox( - widthFactor: 0.9, - child: Image.network(notification.messageTypeData, - loadingBuilder: (BuildContext context, Widget child, - ImageChunkEvent loadingProgress) { - if (loadingProgress == null) return child; - return Center( - child: SizedBox( - width: 40.0, - height: 40.0, - child: AppCircularProgressIndicator(), - ), - ); - }, - fit: BoxFit - .fill) //Image.network(notification.messageTypeData), - ), - SizedBox( - height: 15, - ), - Row( - children: [ - Expanded( - child: Center( - child: Text(notification.message), - ), - ), - ], + body: ListView( + physics: BouncingScrollPhysics(), + padding: EdgeInsets.all(21), + children: [ + Text( + DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(notification.createdOn)) + + " " + + DateUtil.formatDateToTimeLang(DateUtil.convertStringToDate(notification.createdOn), false), + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: Color(0xff2E303A), + letterSpacing: -0.64, + ), + ), + + if (notification.messageTypeData.length != 0) + Padding( + padding: const EdgeInsets.only(top: 18), + child: Image.network(notification.messageTypeData, loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent loadingProgress) { + if (loadingProgress == null) return child; + return Center( + child: SizedBox( + width: 40.0, + height: 40.0, + child: AppCircularProgressIndicator(), ), - ], - ), + ); + }, fit: BoxFit.fill), + ), + + SizedBox(height: 18), + Text( + notification.message.trim(), + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff575757), + letterSpacing: -0.48, ), ), - ), + + ], + ), ); } } diff --git a/lib/pages/DrawerPages/notifications/notifications_page.dart b/lib/pages/DrawerPages/notifications/notifications_page.dart index fc34dbfe..7c86ebf5 100644 --- a/lib/pages/DrawerPages/notifications/notifications_page.dart +++ b/lib/pages/DrawerPages/notifications/notifications_page.dart @@ -8,7 +8,6 @@ import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -36,6 +35,7 @@ class NotificationsPage extends StatelessWidget { appBarTitle: TranslationBase.of(context).notifications, baseViewModel: model, body: ListView.separated( + physics: BouncingScrollPhysics(), itemBuilder: (context, index) { if (index == model.notifications.length) { return InkWell( @@ -47,87 +47,90 @@ class NotificationsPage extends StatelessWidget { await model.getNotifications(getNotificationsRequestModel, context); GifLoaderDialogUtils.hideDialog(context); }, - child: Center( + child: Padding( + padding: const EdgeInsets.only(top: 12, bottom: 12), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - // Image.asset('assets/images/notf.png'), Icon( Icons.notifications_active, color: CustomColors.accentColor, - size: 40, - ), - Padding( - padding: const EdgeInsets.only(left: 10.0, right: 10.0), - child: Text(TranslationBase.of(context).moreNotifications, - style: TextStyle(color: CustomColors.accentColor, fontWeight: FontWeight.w600, letterSpacing: -0.64, decoration: TextDecoration.underline)), + size: 24, ), + SizedBox(width: 8), + Text(TranslationBase.of(context).moreNotifications, + style: TextStyle(color: CustomColors.accentColor, fontWeight: FontWeight.w600, letterSpacing: -0.42, decoration: TextDecoration.underline)), ], ), ), ); } - return InkWell( onTap: () async { if (!model.notifications[index].isRead) { model.markAsRead(model.notifications[index].id); } Navigator.push( - context, - FadePage( - page: NotificationsDetailsPage( + context, + FadePage( + page: NotificationsDetailsPage( notification: model.notifications[index], - ))); + ), + ), + ); }, child: Container( width: double.infinity, - padding: EdgeInsets.all(8.0), + padding: EdgeInsets.fromLTRB(15.0, 14, 21, 12), decoration: BoxDecoration( color: model.notifications[index].isRead ? Theme.of(context).scaffoldBackgroundColor : CustomColors.accentColor.withOpacity(0.05), border: projectViewModel.isArabic ? Border( right: BorderSide( color: model.notifications[index].isRead ? Theme.of(context).scaffoldBackgroundColor : CustomColors.accentColor, - width: 5.0, + width: 6.0, ), ) : Border( left: BorderSide( color: model.notifications[index].isRead ? Theme.of(context).scaffoldBackgroundColor : CustomColors.accentColor, - width: 5.0, + width: 6.0, ), ), ), - child: Row( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts(DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(model.notifications[index].createdOn)) + + Row( + children: [ + Expanded( + child: Text( + DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(model.notifications[index].createdOn)) + " " + - DateUtil.formatDateToTimeLang(DateUtil.convertStringToDate(model.notifications[index].createdOn), false)), - SizedBox( - height: 5, + DateUtil.formatDateToTimeLang(DateUtil.convertStringToDate(model.notifications[index].createdOn), false), + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: Color(0xff2E303A), + letterSpacing: -0.64, ), - Row( - children: [ - Expanded(child: Texts(model.notifications[index].message)), - if (model.notifications[index].messageType == "image") - Icon( - FontAwesomeIcons.images, - color: CustomColors.grey, - ) - ], - ), - SizedBox( - height: 5, - ), - ], + ), ), + if (model.notifications[index].messageType == "image") + Icon( + FontAwesomeIcons.image, + color: Color(0xffC9C9C9), + ) + ], + ), + SizedBox(height: 4), + Text( + model.notifications[index].message.trim(), + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff575757), + letterSpacing: -0.48, ), ), ], @@ -139,8 +142,9 @@ class NotificationsPage extends StatelessWidget { return Column( children: [ Divider( - color: Colors.grey[300], + color: Color(0xffEFEFEF), thickness: 2.0, + height: 1, ), ], ); diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart index f9b2b190..aaba5d2a 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart @@ -376,7 +376,7 @@ class _AmbulanceRequestIndexPageState extends State { void showConfirmMessage(AmRequestViewModel model, int presOrderID, BuildContext context) { showDialog( context: context, - child: ConfirmWithMessageDialog( + builder: (cxt) => ConfirmWithMessageDialog( message: TranslationBase.of(context).cancelOrderMsg, onTap: () { Future.delayed(new Duration(milliseconds: 300)).then((value) async { diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart index 0e63bf76..67d2f979 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart @@ -54,7 +54,7 @@ class _PickupLocationState extends State { } _getCurrentLocation() async { - await getLastKnownPosition().then((value) { + await Geolocator.getLastKnownPosition().then((value) { _latitude = value.latitude; _longitude = value.longitude; }).catchError((e) { @@ -561,7 +561,7 @@ class _PickupLocationState extends State { ]; showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: _selectedHospitalIndex, isScrollable: true, diff --git a/lib/pages/ErService/OrderLogPage.dart b/lib/pages/ErService/OrderLogPage.dart index fb8de6d9..e98b41c0 100644 --- a/lib/pages/ErService/OrderLogPage.dart +++ b/lib/pages/ErService/OrderLogPage.dart @@ -26,7 +26,7 @@ class OrderLogPage extends StatelessWidget { void showConfirmMessage(AmRequestViewModel model, int presOrderID, BuildContext context) { showDialog( context: context, - child: ConfirmWithMessageDialog( + builder: (cxt) => ConfirmWithMessageDialog( message: TranslationBase.of(context).cancelOrderMsg, onTap: () { Future.delayed(new Duration(milliseconds: 300)).then((value) async { diff --git a/lib/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart b/lib/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart index 9d9ca428..b64c0fbf 100644 --- a/lib/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart +++ b/lib/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart @@ -267,7 +267,7 @@ class RRTRequestPickupAddressPageState extends State addresses) { showDialog( context: context, - child: SelectLocationDialog( + builder: (cxt) => SelectLocationDialog( addresses: addresses, selectedAddress: selectedAddress, onValueSelected: (value) { diff --git a/lib/pages/conference/conference_page.dart b/lib/pages/conference/conference_page.dart index c30e7cdf..3e5ebe41 100644 --- a/lib/pages/conference/conference_page.dart +++ b/lib/pages/conference/conference_page.dart @@ -1,390 +1,390 @@ -import 'dart:async'; - -import 'package:diplomaticquarterapp/models/LiveCare/room_model.dart'; -import 'package:diplomaticquarterapp/pages/conference/conference_button_bar.dart'; -import 'package:diplomaticquarterapp/pages/conference/conference_room.dart'; -import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; -import 'package:diplomaticquarterapp/pages/conference/draggable_publisher.dart'; -import 'package:diplomaticquarterapp/pages/conference/participant_widget.dart'; -import 'package:diplomaticquarterapp/pages/conference/widgets/noise_box.dart'; -import 'package:diplomaticquarterapp/pages/conference/widgets/platform_alert_dialog.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:wakelock/wakelock.dart'; - -class ConferencePage extends StatefulWidget { - final RoomModel roomModel; - - const ConferencePage({Key key, this.roomModel}) : super(key: key); - - @override - _ConferencePageState createState() => _ConferencePageState(); -} - -class _ConferencePageState extends State { - final StreamController _onButtonBarVisibleStreamController = StreamController.broadcast(); - final StreamController _onButtonBarHeightStreamController = StreamController.broadcast(); - ConferenceRoom _conferenceRoom; - StreamSubscription _onConferenceRoomException; - - @override - void initState() { - super.initState(); - _lockInPortrait(); - _connectToRoom(); - _wakeLock(true); - } - - void _connectToRoom() async { - try { - final conferenceRoom = ConferenceRoom( - name: widget.roomModel.name, - token: widget.roomModel.token, - identity: widget.roomModel.identity, - ); - await conferenceRoom.connect(); - setState(() { - _conferenceRoom = conferenceRoom; - _onConferenceRoomException = _conferenceRoom.onException.listen((err) async { - await PlatformAlertDialog( - title: err is PlatformException ? err.message : 'An error occured', - content: err is PlatformException ? err.details : err.toString(), - defaultActionText: 'OK', - ).show(context); - }); - _conferenceRoom.addListener(_conferenceRoomUpdated); - }); - } catch (err) { - print(err); - await PlatformAlertDialog( - title: err is PlatformException ? err.message : 'An error occured', - content: err is PlatformException ? err.details : err.toString(), - defaultActionText: 'OK', - ).show(context); - - Navigator.of(context).pop(); - } - } - - Future _lockInPortrait() async { - await SystemChrome.setPreferredOrientations([ - DeviceOrientation.portraitUp, - DeviceOrientation.portraitDown, - ]); - } - - @override - void dispose() { - _freePortraitLock(); - _wakeLock(false); - _disposeStreamsAndSubscriptions(); - if (_conferenceRoom != null) _conferenceRoom.removeListener(_conferenceRoomUpdated); - super.dispose(); - } - - Future _freePortraitLock() async { - await SystemChrome.setPreferredOrientations([ - DeviceOrientation.landscapeRight, - DeviceOrientation.landscapeLeft, - DeviceOrientation.portraitUp, - DeviceOrientation.portraitDown, - ]); - } - - Future _disposeStreamsAndSubscriptions() async { - if (_onButtonBarVisibleStreamController != null) await _onButtonBarVisibleStreamController.close(); - if (_onButtonBarHeightStreamController != null) await _onButtonBarHeightStreamController.close(); - if (_onConferenceRoomException != null) await _onConferenceRoomException.cancel(); - } - - @override - Widget build(BuildContext context) { - return WillPopScope( - onWillPop: () async => false, - child: Scaffold( - backgroundColor: Colors.white, - body: _conferenceRoom == null ? showProgress() : buildLayout(), - ), - ); - } - - LayoutBuilder buildLayout() { - return LayoutBuilder( - builder: (BuildContext context, BoxConstraints constraints) { - return Stack( - children: [ - _buildParticipants(context, constraints.biggest, _conferenceRoom), - ConferenceButtonBar( - audioEnabled: _conferenceRoom.onAudioEnabled, - videoEnabled: _conferenceRoom.onVideoEnabled, - onAudioEnabled: _conferenceRoom.toggleAudioEnabled, - onVideoEnabled: _conferenceRoom.toggleVideoEnabled, - onHangup: _onHangup, - onSwitchCamera: _conferenceRoom.switchCamera, - onPersonAdd: _onPersonAdd, - onPersonRemove: _onPersonRemove, - onHeight: _onHeightBar, - onShow: _onShowBar, - onHide: _onHideBar, - ), - ], - ); - }, - ); - } - - Widget showProgress() { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Center(child: CircularProgressIndicator()), - SizedBox( - height: 10, - ), - Text( - 'Connecting to the call...', - style: TextStyle(color: Colors.white), - ), - ], - ); - } - - Future _onHangup() async { - print('onHangup'); - await _conferenceRoom.disconnect(); - LandingPage.isOpenCallPage = false; - Navigator.of(context).pop(); - } - - void _onPersonAdd() { - print('onPersonAdd'); - try { - _conferenceRoom.addDummy( - child: Stack( - children: [ - const Placeholder(), - Center( - child: Text( - (_conferenceRoom.participants.length + 1).toString(), - style: const TextStyle( - shadows: [ - Shadow( - blurRadius: 3.0, - color: Color.fromARGB(255, 0, 0, 0), - ), - Shadow( - blurRadius: 8.0, - color: Color.fromARGB(255, 255, 255, 255), - ), - ], - fontSize: 80, - ), - ), - ), - ], - ), - ); - } on PlatformException catch (err) { - PlatformAlertDialog( - title: err.message, - content: err.details, - defaultActionText: 'OK', - ).show(context); - } - } - - void _onPersonRemove() { - print('onPersonRemove'); - _conferenceRoom.removeDummy(); - } - - Widget _buildParticipants(BuildContext context, Size size, ConferenceRoom conferenceRoom) { - final children = []; - final length = conferenceRoom.participants.length; - - if (length <= 2) { - _buildOverlayLayout(context, size, children); - return Stack(children: children); - } - - void buildInCols(bool removeLocalBeforeChunking, bool moveLastOfEachRowToNextRow, int columns) { - _buildLayoutInGrid( - context, - size, - children, - removeLocalBeforeChunking: removeLocalBeforeChunking, - moveLastOfEachRowToNextRow: moveLastOfEachRowToNextRow, - columns: columns, - ); - } - -// if (length <= 3) { -// buildInCols(true, false, 1); -// } else if (length == 5) { -// buildInCols(false, true, 2); -// } else if (length <= 6 || length == 8) { -// buildInCols(false, false, 2); -// } else if (length == 7 || length == 9) { -// buildInCols(true, false, 2); -// } else if (length == 10) { -// buildInCols(false, true, 3); -// } else if (length == 13 || length == 16) { -// buildInCols(true, false, 3); -// } else if (length <= 18) { -// buildInCols(false, false, 3); -// } - - return Column( - children: children, - ); - } - - void _buildOverlayLayout(BuildContext context, Size size, List children) { - final participants = _conferenceRoom.participants; - if (participants.length == 1) { - children.add(_buildNoiseBox()); - } else { - final remoteParticipant = participants.firstWhere((ParticipantWidget participant) => participant.isRemote, orElse: () => null); - if (remoteParticipant != null) { - children.add(remoteParticipant); - } - } - - final localParticipant = participants.firstWhere((ParticipantWidget participant) => !participant.isRemote, orElse: () => null); - if (localParticipant != null) { - children.add(DraggablePublisher( - key: Key('publisher'), - child: localParticipant, - availableScreenSize: size, - onButtonBarVisible: _onButtonBarVisibleStreamController.stream, - onButtonBarHeight: _onButtonBarHeightStreamController.stream, - )); - } - } - - void _buildLayoutInGrid( - BuildContext context, - Size size, - List children, { - bool removeLocalBeforeChunking = false, - bool moveLastOfEachRowToNextRow = false, - int columns = 2, - }) { - final participants = _conferenceRoom.participants; - ParticipantWidget localParticipant; - if (removeLocalBeforeChunking) { - localParticipant = participants.firstWhere((ParticipantWidget participant) => !participant.isRemote, orElse: () => null); - if (localParticipant != null) { - participants.remove(localParticipant); - } - } - final chunkedParticipants = chunk(array: participants, size: columns); - if (localParticipant != null) { - chunkedParticipants.last.add(localParticipant); - participants.add(localParticipant); - } - - if (moveLastOfEachRowToNextRow) { - for (var i = 0; i < chunkedParticipants.length - 1; i++) { - var participant = chunkedParticipants[i].removeLast(); - chunkedParticipants[i + 1].insert(0, participant); - } - } - - for (final participantChunk in chunkedParticipants) { - final rowChildren = []; - for (final participant in participantChunk) { - rowChildren.add( - Container( - width: size.width / participantChunk.length, - height: size.height / chunkedParticipants.length, - child: participant, - ), - ); - } - children.add( - Container( - height: size.height / chunkedParticipants.length, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: rowChildren, - ), - ), - ); - } - } - - NoiseBox _buildNoiseBox() { - return NoiseBox( - density: NoiseBoxDensity.xLow, - backgroundColor: Colors.grey.shade900, - child: Center( - child: Container( - color: Colors.black54, - width: double.infinity, - height: 40, - child: Center( - child: Text( - 'Waiting for another participant to connect to the call...', - key: Key('text-wait'), - textAlign: TextAlign.center, - style: TextStyle(color: Colors.white), - ), - ), - ), - ), - ); - } - - List> chunk({@required List array, @required int size}) { - final result = >[]; - if (array.isEmpty || size <= 0) { - return result; - } - var first = 0; - var last = size; - final totalLoop = array.length % size == 0 ? array.length ~/ size : array.length ~/ size + 1; - for (var i = 0; i < totalLoop; i++) { - if (last > array.length) { - result.add(array.sublist(first, array.length)); - } else { - result.add(array.sublist(first, last)); - } - first = last; - last = last + size; - } - return result; - } - - void _onHeightBar(double height) { - _onButtonBarHeightStreamController.add(height); - } - - void _onShowBar() { - setState(() { - SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom, SystemUiOverlay.top]); - }); - _onButtonBarVisibleStreamController.add(true); - } - - void _onHideBar() { - setState(() { - SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]); - }); - _onButtonBarVisibleStreamController.add(false); - } - - Future _wakeLock(bool enable) async { - try { - return await (enable ? Wakelock.enable() : Wakelock.disable()); - } catch (err) { - print('Unable to change the Wakelock and set it to $enable'); - print(err); - } - } - - void _conferenceRoomUpdated() { - setState(() {}); - } -} +// import 'dart:async'; +// +// import 'package:diplomaticquarterapp/models/LiveCare/room_model.dart'; +// import 'package:diplomaticquarterapp/pages/conference/conference_button_bar.dart'; +// import 'package:diplomaticquarterapp/pages/conference/conference_room.dart'; +// import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; +// import 'package:diplomaticquarterapp/pages/conference/draggable_publisher.dart'; +// import 'package:diplomaticquarterapp/pages/conference/participant_widget.dart'; +// import 'package:diplomaticquarterapp/pages/conference/widgets/noise_box.dart'; +// import 'package:diplomaticquarterapp/pages/conference/widgets/platform_alert_dialog.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter/services.dart'; +// import 'package:wakelock/wakelock.dart'; +// +// class ConferencePage extends StatefulWidget { +// final RoomModel roomModel; +// +// const ConferencePage({Key key, this.roomModel}) : super(key: key); +// +// @override +// _ConferencePageState createState() => _ConferencePageState(); +// } +// +// class _ConferencePageState extends State { +// final StreamController _onButtonBarVisibleStreamController = StreamController.broadcast(); +// final StreamController _onButtonBarHeightStreamController = StreamController.broadcast(); +// // ConferenceRoom _conferenceRoom; +// StreamSubscription _onConferenceRoomException; +// +// @override +// void initState() { +// super.initState(); +// _lockInPortrait(); +// _connectToRoom(); +// _wakeLock(true); +// } +// +// void _connectToRoom() async { +// try { +// final conferenceRoom = ConferenceRoom( +// name: widget.roomModel.name, +// token: widget.roomModel.token, +// identity: widget.roomModel.identity, +// ); +// await conferenceRoom.connect(); +// setState(() { +// _conferenceRoom = conferenceRoom; +// _onConferenceRoomException = _conferenceRoom.onException.listen((err) async { +// await PlatformAlertDialog( +// title: err is PlatformException ? err.message : 'An error occured', +// content: err is PlatformException ? err.details : err.toString(), +// defaultActionText: 'OK', +// ).show(context); +// }); +// _conferenceRoom.addListener(_conferenceRoomUpdated); +// }); +// } catch (err) { +// print(err); +// await PlatformAlertDialog( +// title: err is PlatformException ? err.message : 'An error occured', +// content: err is PlatformException ? err.details : err.toString(), +// defaultActionText: 'OK', +// ).show(context); +// +// Navigator.of(context).pop(); +// } +// } +// +// Future _lockInPortrait() async { +// await SystemChrome.setPreferredOrientations([ +// DeviceOrientation.portraitUp, +// DeviceOrientation.portraitDown, +// ]); +// } +// +// @override +// void dispose() { +// _freePortraitLock(); +// _wakeLock(false); +// _disposeStreamsAndSubscriptions(); +// if (_conferenceRoom != null) _conferenceRoom.removeListener(_conferenceRoomUpdated); +// super.dispose(); +// } +// +// Future _freePortraitLock() async { +// await SystemChrome.setPreferredOrientations([ +// DeviceOrientation.landscapeRight, +// DeviceOrientation.landscapeLeft, +// DeviceOrientation.portraitUp, +// DeviceOrientation.portraitDown, +// ]); +// } +// +// Future _disposeStreamsAndSubscriptions() async { +// if (_onButtonBarVisibleStreamController != null) await _onButtonBarVisibleStreamController.close(); +// if (_onButtonBarHeightStreamController != null) await _onButtonBarHeightStreamController.close(); +// if (_onConferenceRoomException != null) await _onConferenceRoomException.cancel(); +// } +// +// @override +// Widget build(BuildContext context) { +// return WillPopScope( +// onWillPop: () async => false, +// child: Scaffold( +// backgroundColor: Colors.white, +// body: _conferenceRoom == null ? showProgress() : buildLayout(), +// ), +// ); +// } +// +// LayoutBuilder buildLayout() { +// return LayoutBuilder( +// builder: (BuildContext context, BoxConstraints constraints) { +// return Stack( +// children: [ +// _buildParticipants(context, constraints.biggest, _conferenceRoom), +// ConferenceButtonBar( +// audioEnabled: _conferenceRoom.onAudioEnabled, +// videoEnabled: _conferenceRoom.onVideoEnabled, +// onAudioEnabled: _conferenceRoom.toggleAudioEnabled, +// onVideoEnabled: _conferenceRoom.toggleVideoEnabled, +// onHangup: _onHangup, +// onSwitchCamera: _conferenceRoom.switchCamera, +// onPersonAdd: _onPersonAdd, +// onPersonRemove: _onPersonRemove, +// onHeight: _onHeightBar, +// onShow: _onShowBar, +// onHide: _onHideBar, +// ), +// ], +// ); +// }, +// ); +// } +// +// Widget showProgress() { +// return Column( +// mainAxisAlignment: MainAxisAlignment.center, +// crossAxisAlignment: CrossAxisAlignment.center, +// children: [ +// Center(child: CircularProgressIndicator()), +// SizedBox( +// height: 10, +// ), +// Text( +// 'Connecting to the call...', +// style: TextStyle(color: Colors.white), +// ), +// ], +// ); +// } +// +// Future _onHangup() async { +// print('onHangup'); +// await _conferenceRoom.disconnect(); +// LandingPage.isOpenCallPage = false; +// Navigator.of(context).pop(); +// } +// +// void _onPersonAdd() { +// print('onPersonAdd'); +// try { +// _conferenceRoom.addDummy( +// child: Stack( +// children: [ +// const Placeholder(), +// Center( +// child: Text( +// (_conferenceRoom.participants.length + 1).toString(), +// style: const TextStyle( +// shadows: [ +// Shadow( +// blurRadius: 3.0, +// color: Color.fromARGB(255, 0, 0, 0), +// ), +// Shadow( +// blurRadius: 8.0, +// color: Color.fromARGB(255, 255, 255, 255), +// ), +// ], +// fontSize: 80, +// ), +// ), +// ), +// ], +// ), +// ); +// } on PlatformException catch (err) { +// PlatformAlertDialog( +// title: err.message, +// content: err.details, +// defaultActionText: 'OK', +// ).show(context); +// } +// } +// +// void _onPersonRemove() { +// print('onPersonRemove'); +// _conferenceRoom.removeDummy(); +// } +// +// Widget _buildParticipants(BuildContext context, Size size, ConferenceRoom conferenceRoom) { +// final children = []; +// final length = conferenceRoom.participants.length; +// +// if (length <= 2) { +// _buildOverlayLayout(context, size, children); +// return Stack(children: children); +// } +// +// void buildInCols(bool removeLocalBeforeChunking, bool moveLastOfEachRowToNextRow, int columns) { +// _buildLayoutInGrid( +// context, +// size, +// children, +// removeLocalBeforeChunking: removeLocalBeforeChunking, +// moveLastOfEachRowToNextRow: moveLastOfEachRowToNextRow, +// columns: columns, +// ); +// } +// +// // if (length <= 3) { +// // buildInCols(true, false, 1); +// // } else if (length == 5) { +// // buildInCols(false, true, 2); +// // } else if (length <= 6 || length == 8) { +// // buildInCols(false, false, 2); +// // } else if (length == 7 || length == 9) { +// // buildInCols(true, false, 2); +// // } else if (length == 10) { +// // buildInCols(false, true, 3); +// // } else if (length == 13 || length == 16) { +// // buildInCols(true, false, 3); +// // } else if (length <= 18) { +// // buildInCols(false, false, 3); +// // } +// +// return Column( +// children: children, +// ); +// } +// +// void _buildOverlayLayout(BuildContext context, Size size, List children) { +// final participants = _conferenceRoom.participants; +// if (participants.length == 1) { +// children.add(_buildNoiseBox()); +// } else { +// final remoteParticipant = participants.firstWhere((ParticipantWidget participant) => participant.isRemote, orElse: () => null); +// if (remoteParticipant != null) { +// children.add(remoteParticipant); +// } +// } +// +// final localParticipant = participants.firstWhere((ParticipantWidget participant) => !participant.isRemote, orElse: () => null); +// if (localParticipant != null) { +// children.add(DraggablePublisher( +// key: Key('publisher'), +// child: localParticipant, +// availableScreenSize: size, +// onButtonBarVisible: _onButtonBarVisibleStreamController.stream, +// onButtonBarHeight: _onButtonBarHeightStreamController.stream, +// )); +// } +// } +// +// void _buildLayoutInGrid( +// BuildContext context, +// Size size, +// List children, { +// bool removeLocalBeforeChunking = false, +// bool moveLastOfEachRowToNextRow = false, +// int columns = 2, +// }) { +// final participants = _conferenceRoom.participants; +// ParticipantWidget localParticipant; +// if (removeLocalBeforeChunking) { +// localParticipant = participants.firstWhere((ParticipantWidget participant) => !participant.isRemote, orElse: () => null); +// if (localParticipant != null) { +// participants.remove(localParticipant); +// } +// } +// final chunkedParticipants = chunk(array: participants, size: columns); +// if (localParticipant != null) { +// chunkedParticipants.last.add(localParticipant); +// participants.add(localParticipant); +// } +// +// if (moveLastOfEachRowToNextRow) { +// for (var i = 0; i < chunkedParticipants.length - 1; i++) { +// var participant = chunkedParticipants[i].removeLast(); +// chunkedParticipants[i + 1].insert(0, participant); +// } +// } +// +// for (final participantChunk in chunkedParticipants) { +// final rowChildren = []; +// for (final participant in participantChunk) { +// rowChildren.add( +// Container( +// width: size.width / participantChunk.length, +// height: size.height / chunkedParticipants.length, +// child: participant, +// ), +// ); +// } +// children.add( +// Container( +// height: size.height / chunkedParticipants.length, +// child: Row( +// mainAxisAlignment: MainAxisAlignment.spaceEvenly, +// children: rowChildren, +// ), +// ), +// ); +// } +// } +// +// NoiseBox _buildNoiseBox() { +// return NoiseBox( +// density: NoiseBoxDensity.xLow, +// backgroundColor: Colors.grey.shade900, +// child: Center( +// child: Container( +// color: Colors.black54, +// width: double.infinity, +// height: 40, +// child: Center( +// child: Text( +// 'Waiting for another participant to connect to the call...', +// key: Key('text-wait'), +// textAlign: TextAlign.center, +// style: TextStyle(color: Colors.white), +// ), +// ), +// ), +// ), +// ); +// } +// +// List> chunk({@required List array, @required int size}) { +// final result = >[]; +// if (array.isEmpty || size <= 0) { +// return result; +// } +// var first = 0; +// var last = size; +// final totalLoop = array.length % size == 0 ? array.length ~/ size : array.length ~/ size + 1; +// for (var i = 0; i < totalLoop; i++) { +// if (last > array.length) { +// result.add(array.sublist(first, array.length)); +// } else { +// result.add(array.sublist(first, last)); +// } +// first = last; +// last = last + size; +// } +// return result; +// } +// +// void _onHeightBar(double height) { +// _onButtonBarHeightStreamController.add(height); +// } +// +// void _onShowBar() { +// setState(() { +// SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom, SystemUiOverlay.top]); +// }); +// _onButtonBarVisibleStreamController.add(true); +// } +// +// void _onHideBar() { +// setState(() { +// SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]); +// }); +// _onButtonBarVisibleStreamController.add(false); +// } +// +// Future _wakeLock(bool enable) async { +// try { +// return await (enable ? Wakelock.enable() : Wakelock.disable()); +// } catch (err) { +// print('Unable to change the Wakelock and set it to $enable'); +// print(err); +// } +// } +// +// void _conferenceRoomUpdated() { +// setState(() {}); +// } +// } diff --git a/lib/pages/conference/conference_room.dart b/lib/pages/conference/conference_room.dart index 9c8c1c9a..b68f8ee8 100644 --- a/lib/pages/conference/conference_room.dart +++ b/lib/pages/conference/conference_room.dart @@ -1,530 +1,529 @@ -import 'dart:async'; -import 'dart:typed_data'; - -import 'package:diplomaticquarterapp/pages/conference/participant_widget.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:twilio_programmable_video/twilio_programmable_video.dart'; - -class ConferenceRoom with ChangeNotifier { - final String name; - final String token; - final String identity; - - final StreamController _onAudioEnabledStreamController = StreamController.broadcast(); - Stream onAudioEnabled; - final StreamController _onVideoEnabledStreamController = StreamController.broadcast(); - Stream onVideoEnabled; - final StreamController _onExceptionStreamController = StreamController.broadcast(); - Stream onException; - - final Completer _completer = Completer(); - - final List _participants = []; - final List _participantBuffer = []; - final List _streamSubscriptions = []; - final List _dataTracks = []; - final List _messages = []; - - CameraCapturer _cameraCapturer; - Room _room; - Timer _timer; - - ConferenceRoom({ - @required this.name, - @required this.token, - @required this.identity, - }) { - onAudioEnabled = _onAudioEnabledStreamController.stream; - onVideoEnabled = _onVideoEnabledStreamController.stream; - onException = _onExceptionStreamController.stream; - } - - List get participants { - return [..._participants]; - } - - Future connect() async { - print('ConferenceRoom.connect()'); - try { - await TwilioProgrammableVideo.debug(dart: true, native: true); - await TwilioProgrammableVideo.setSpeakerphoneOn(true); - - _cameraCapturer = CameraCapturer(CameraSource.FRONT_CAMERA); - var connectOptions = ConnectOptions( - token, - roomName: name, - preferredAudioCodecs: [OpusCodec()], - audioTracks: [LocalAudioTrack(true)], - dataTracks: [LocalDataTrack()], - videoTracks: [LocalVideoTrack(true, _cameraCapturer)], - enableDominantSpeaker: true, - ); - - _room = await TwilioProgrammableVideo.connect(connectOptions); - - _streamSubscriptions.add(_room.onConnected.listen(_onConnected)); - _streamSubscriptions.add(_room.onConnectFailure.listen(_onConnectFailure)); - - return _completer.future; - } catch (err) { - print(err); - rethrow; - } - } - - Future disconnect() async { - print('ConferenceRoom.disconnect()'); - if (_timer != null) { - _timer.cancel(); - } - await _room.disconnect(); - } - - @override - void dispose() { - print('ConferenceRoom.dispose()'); - _disposeStreamsAndSubscriptions(); - super.dispose(); - } - - Future _disposeStreamsAndSubscriptions() async { - await _onAudioEnabledStreamController.close(); - await _onVideoEnabledStreamController.close(); - await _onExceptionStreamController.close(); - for (var streamSubscription in _streamSubscriptions) { - await streamSubscription.cancel(); - } - } - - Future sendMessage(String message) async { - final tracks = _room.localParticipant.localDataTracks; - final localDataTrack = tracks.isEmpty ? null : tracks[0].localDataTrack; - if (localDataTrack == null || _messages.isNotEmpty) { - print('ConferenceRoom.sendMessage => Track is not available yet, buffering message.'); - _messages.add(message); - return; - } - await localDataTrack.send(message); - } - - Future sendBufferMessage(ByteBuffer message) async { - final tracks = _room.localParticipant.localDataTracks; - final localDataTrack = tracks.isEmpty ? null : tracks[0].localDataTrack; - if (localDataTrack == null) { - return; - } - await localDataTrack.sendBuffer(message); - } - - Future toggleVideoEnabled() async { - final tracks = _room.localParticipant.localVideoTracks; - final localVideoTrack = tracks.isEmpty ? null : tracks[0].localVideoTrack; - if (localVideoTrack == null) { - print('ConferenceRoom.toggleVideoEnabled() => Track is not available yet!'); - return; - } - await localVideoTrack.enable(!localVideoTrack.isEnabled); - - var index = _participants.indexWhere((ParticipantWidget participant) => !participant.isRemote); - if (index < 0) { - return; - } - var participant = _participants[index]; - _participants.replaceRange( - index, - index + 1, - [ - participant.copyWith(videoEnabled: localVideoTrack.isEnabled), - ], - ); - print('ConferenceRoom.toggleVideoEnabled() => ${localVideoTrack.isEnabled}'); - _onVideoEnabledStreamController.add(localVideoTrack.isEnabled); - notifyListeners(); - } - - Future toggleAudioEnabled() async { - final tracks = _room.localParticipant.localAudioTracks; - final localAudioTrack = tracks.isEmpty ? null : tracks[0].localAudioTrack; - if (localAudioTrack == null) { - print('ConferenceRoom.toggleAudioEnabled() => Track is not available yet!'); - return; - } - await localAudioTrack.enable(!localAudioTrack.isEnabled); - - var index = _participants.indexWhere((ParticipantWidget participant) => !participant.isRemote); - if (index < 0) { - return; - } - var participant = _participants[index]; - _participants.replaceRange( - index, - index + 1, - [ - participant.copyWith(audioEnabled: localAudioTrack.isEnabled), - ], - ); - print('ConferenceRoom.toggleAudioEnabled() => ${localAudioTrack.isEnabled}'); - _onAudioEnabledStreamController.add(localAudioTrack.isEnabled); - notifyListeners(); - } - - Future switchCamera() async { - print('ConferenceRoom.switchCamera()'); - try { - await _cameraCapturer.switchCamera(); - } on FormatException catch (e) { - print( - 'ConferenceRoom.switchCamera() failed because of FormatException with message: ${e.message}', - ); - } - } - - void addDummy({Widget child}) { - print('ConferenceRoom.addDummy()'); - if (_participants.length >= 18) { - throw PlatformException( - code: 'ConferenceRoom.maximumReached', - message: 'Maximum reached', - details: 'Currently the lay-out can only render a maximum of 18 participants', - ); - } - _participants.insert( - 0, - ParticipantWidget( - id: (_participants.length + 1).toString(), - child: child, - isRemote: true, - audioEnabled: true, - videoEnabled: true, - isDummy: true, - ), - ); - notifyListeners(); - } - - void removeDummy() { - print('ConferenceRoom.removeDummy()'); - var dummy = _participants.firstWhere((participant) => participant.isDummy, orElse: () => null); - if (dummy != null) { - _participants.remove(dummy); - notifyListeners(); - } - } - - void _onConnected(Room room) { - print('ConferenceRoom._onConnected => state: ${room.state}'); - - // When connected for the first time, add remote participant listeners - _streamSubscriptions.add(_room.onParticipantConnected.listen(_onParticipantConnected)); - _streamSubscriptions.add(_room.onParticipantDisconnected.listen(_onParticipantDisconnected)); - _streamSubscriptions.add(_room.onDominantSpeakerChange.listen(_onDominantSpeakerChanged)); - // Only add ourselves when connected for the first time too. - _participants.add( - _buildParticipant( - child: room.localParticipant.localVideoTracks[0].localVideoTrack.widget(), - id: identity, - audioEnabled: true, - videoEnabled: true, - ), - ); - for (final remoteParticipant in room.remoteParticipants) { - var participant = _participants.firstWhere((participant) => participant.id == remoteParticipant.sid, orElse: () => null); - if (participant == null) { - print('Adding participant that was already present in the room ${remoteParticipant.sid}, before I connected'); - _addRemoteParticipantListeners(remoteParticipant); - } - } - // We have to listen for the [onDataTrackPublished] event on the [LocalParticipant] in - // order to be able to use the [send] method. - _streamSubscriptions.add(room.localParticipant.onDataTrackPublished.listen(_onLocalDataTrackPublished)); - notifyListeners(); - _completer.complete(room); - - _timer = Timer.periodic(const Duration(minutes: 1), (_) { - // Let's see if we can send some data over the DataTrack API - sendMessage('And another minute has passed since I connected...'); - // Also try the ByteBuffer way of sending data - final list = 'This data has been sent over the ByteBuffer channel of the DataTrack API'.codeUnits; - var bytes = Uint8List.fromList(list); - sendBufferMessage(bytes.buffer); - }); - } - - void _onLocalDataTrackPublished(LocalDataTrackPublishedEvent event) { - // Send buffered messages, if any... - while (_messages.isNotEmpty) { - var message = _messages.removeAt(0); - print('Sending buffered message: $message'); - event.localDataTrackPublication.localDataTrack.send(message); - } - } - - void _onConnectFailure(RoomConnectFailureEvent event) { - print('ConferenceRoom._onConnectFailure: ${event.exception}'); - _completer.completeError(event.exception); - } - - void _onDominantSpeakerChanged(DominantSpeakerChangedEvent event) { - print('ConferenceRoom._onDominantSpeakerChanged: ${event.remoteParticipant.identity}'); - var oldDominantParticipant = _participants.firstWhere((p) => p.isDominant, orElse: () => null); - if (oldDominantParticipant != null) { - var oldDominantParticipantIndex = _participants.indexOf(oldDominantParticipant); - _participants.replaceRange(oldDominantParticipantIndex, oldDominantParticipantIndex + 1, [oldDominantParticipant.copyWith(isDominant: false)]); - } - - var newDominantParticipant = _participants.firstWhere((p) => p.id == event.remoteParticipant.sid); - var newDominantParticipantIndex = _participants.indexOf(newDominantParticipant); - _participants.replaceRange(newDominantParticipantIndex, newDominantParticipantIndex + 1, [newDominantParticipant.copyWith(isDominant: true)]); - notifyListeners(); - } - - void _onParticipantConnected(RoomParticipantConnectedEvent event) { - print('ConferenceRoom._onParticipantConnected, ${event.remoteParticipant.sid}'); - _addRemoteParticipantListeners(event.remoteParticipant); - } - - void _onParticipantDisconnected(RoomParticipantDisconnectedEvent event) { - print('ConferenceRoom._onParticipantDisconnected: ${event.remoteParticipant.sid}'); - _participants.removeWhere((ParticipantWidget p) => p.id == event.remoteParticipant.sid); - notifyListeners(); - } - - ParticipantWidget _buildParticipant({ - @required Widget child, - @required String id, - @required bool audioEnabled, - @required bool videoEnabled, - RemoteParticipant remoteParticipant, - }) { - return ParticipantWidget( - id: remoteParticipant?.sid, - isRemote: remoteParticipant != null, - child: child, - audioEnabled: audioEnabled, - videoEnabled: videoEnabled, - ); - } - - void _addRemoteParticipantListeners(RemoteParticipant remoteParticipant) { - print('ConferenceRoom._addRemoteParticipantListeners() => Adding listeners to remoteParticipant ${remoteParticipant.sid}'); - _streamSubscriptions.add(remoteParticipant.onAudioTrackDisabled.listen(_onAudioTrackDisabled)); - _streamSubscriptions.add(remoteParticipant.onAudioTrackEnabled.listen(_onAudioTrackEnabled)); - _streamSubscriptions.add(remoteParticipant.onAudioTrackPublished.listen(_onAudioTrackPublished)); - _streamSubscriptions.add(remoteParticipant.onAudioTrackSubscribed.listen(_onAudioTrackSubscribed)); - _streamSubscriptions.add(remoteParticipant.onAudioTrackSubscriptionFailed.listen(_onAudioTrackSubscriptionFailed)); - _streamSubscriptions.add(remoteParticipant.onAudioTrackUnpublished.listen(_onAudioTrackUnpublished)); - _streamSubscriptions.add(remoteParticipant.onAudioTrackUnsubscribed.listen(_onAudioTrackUnsubscribed)); - - _streamSubscriptions.add(remoteParticipant.onDataTrackPublished.listen(_onDataTrackPublished)); - _streamSubscriptions.add(remoteParticipant.onDataTrackSubscribed.listen(_onDataTrackSubscribed)); - _streamSubscriptions.add(remoteParticipant.onDataTrackSubscriptionFailed.listen(_onDataTrackSubscriptionFailed)); - _streamSubscriptions.add(remoteParticipant.onDataTrackUnpublished.listen(_onDataTrackUnpublished)); - _streamSubscriptions.add(remoteParticipant.onDataTrackUnsubscribed.listen(_onDataTrackUnsubscribed)); - - _streamSubscriptions.add(remoteParticipant.onVideoTrackDisabled.listen(_onVideoTrackDisabled)); - _streamSubscriptions.add(remoteParticipant.onVideoTrackEnabled.listen(_onVideoTrackEnabled)); - _streamSubscriptions.add(remoteParticipant.onVideoTrackPublished.listen(_onVideoTrackPublished)); - _streamSubscriptions.add(remoteParticipant.onVideoTrackSubscribed.listen(_onVideoTrackSubscribed)); - _streamSubscriptions.add(remoteParticipant.onVideoTrackSubscriptionFailed.listen(_onVideoTrackSubscriptionFailed)); - _streamSubscriptions.add(remoteParticipant.onVideoTrackUnpublished.listen(_onVideoTrackUnpublished)); - _streamSubscriptions.add(remoteParticipant.onVideoTrackUnsubscribed.listen(_onVideoTrackUnsubscribed)); - } - - void _onAudioTrackDisabled(RemoteAudioTrackEvent event) { - print('ConferenceRoom._onAudioTrackDisabled(), ${event.remoteParticipant.sid}, ${event.remoteAudioTrackPublication.trackSid}, isEnabled: ${event.remoteAudioTrackPublication.isTrackEnabled}'); - _setRemoteAudioEnabled(event); - } - - void _onAudioTrackEnabled(RemoteAudioTrackEvent event) { - print('ConferenceRoom._onAudioTrackEnabled(), ${event.remoteParticipant.sid}, ${event.remoteAudioTrackPublication.trackSid}, isEnabled: ${event.remoteAudioTrackPublication.isTrackEnabled}'); - _setRemoteAudioEnabled(event); - } - - void _onAudioTrackPublished(RemoteAudioTrackEvent event) { - print('ConferenceRoom._onAudioTrackPublished(), ${event.remoteParticipant.sid}}'); - } - - void _onAudioTrackSubscribed(RemoteAudioTrackSubscriptionEvent event) { - print('ConferenceRoom._onAudioTrackSubscribed(), ${event.remoteParticipant.sid}, ${event.remoteAudioTrackPublication.trackSid}'); - _addOrUpdateParticipant(event); - } - - void _onAudioTrackSubscriptionFailed(RemoteAudioTrackSubscriptionFailedEvent event) { - print('ConferenceRoom._onAudioTrackSubscriptionFailed(), ${event.remoteParticipant.sid}, ${event.remoteAudioTrackPublication.trackSid}'); - _onExceptionStreamController.add( - PlatformException( - code: 'ConferenceRoom.audioTrackSubscriptionFailed', - message: 'AudioTrack Subscription Failed', - details: event.exception.toString(), - ), - ); - } - - void _onAudioTrackUnpublished(RemoteAudioTrackEvent event) { - print('ConferenceRoom._onAudioTrackUnpublished(), ${event.remoteParticipant.sid}, ${event.remoteAudioTrackPublication.trackSid}'); - } - - void _onAudioTrackUnsubscribed(RemoteAudioTrackSubscriptionEvent event) { - print('ConferenceRoom._onAudioTrackUnsubscribed(), ${event.remoteParticipant.sid}, ${event.remoteAudioTrack.sid}'); - } - - void _onDataTrackPublished(RemoteDataTrackEvent event) { - print('ConferenceRoom._onDataTrackPublished(), ${event.remoteParticipant.sid}}'); - } - - void _onDataTrackSubscribed(RemoteDataTrackSubscriptionEvent event) { - print('ConferenceRoom._onDataTrackSubscribed(), ${event.remoteParticipant.sid}, ${event.remoteDataTrackPublication.trackSid}'); - final dataTrack = event.remoteDataTrackPublication.remoteDataTrack; - _dataTracks.add(dataTrack); - _streamSubscriptions.add(dataTrack.onMessage.listen(_onMessage)); - _streamSubscriptions.add(dataTrack.onBufferMessage.listen(_onBufferMessage)); - } - - void _onDataTrackSubscriptionFailed(RemoteDataTrackSubscriptionFailedEvent event) { - print('ConferenceRoom._onDataTrackSubscriptionFailed(), ${event.remoteParticipant.sid}, ${event.remoteDataTrackPublication.trackSid}'); - _onExceptionStreamController.add( - PlatformException( - code: 'ConferenceRoom.dataTrackSubscriptionFailed', - message: 'DataTrack Subscription Failed', - details: event.exception.toString(), - ), - ); - } - - void _onDataTrackUnpublished(RemoteDataTrackEvent event) { - print('ConferenceRoom._onDataTrackUnpublished(), ${event.remoteParticipant.sid}, ${event.remoteDataTrackPublication.trackSid}'); - } - - void _onDataTrackUnsubscribed(RemoteDataTrackSubscriptionEvent event) { - print('ConferenceRoom._onDataTrackUnsubscribed(), ${event.remoteParticipant.sid}, ${event.remoteDataTrack.sid}'); - } - - void _onVideoTrackDisabled(RemoteVideoTrackEvent event) { - print('ConferenceRoom._onVideoTrackDisabled(), ${event.remoteParticipant.sid}, ${event.remoteVideoTrackPublication.trackSid}, isEnabled: ${event.remoteVideoTrackPublication.isTrackEnabled}'); - _setRemoteVideoEnabled(event); - } - - void _onVideoTrackEnabled(RemoteVideoTrackEvent event) { - print('ConferenceRoom._onVideoTrackEnabled(), ${event.remoteParticipant.sid}, ${event.remoteVideoTrackPublication.trackSid}, isEnabled: ${event.remoteVideoTrackPublication.isTrackEnabled}'); - _setRemoteVideoEnabled(event); - } - - void _onVideoTrackPublished(RemoteVideoTrackEvent event) { - print('ConferenceRoom._onVideoTrackPublished(), ${event.remoteParticipant.sid}, ${event.remoteVideoTrackPublication.trackSid}'); - } - - void _onVideoTrackSubscribed(RemoteVideoTrackSubscriptionEvent event) { - print('ConferenceRoom._onVideoTrackSubscribed(), ${event.remoteParticipant.sid}, ${event.remoteVideoTrack.sid}'); - _addOrUpdateParticipant(event); - } - - void _onVideoTrackSubscriptionFailed(RemoteVideoTrackSubscriptionFailedEvent event) { - print('ConferenceRoom._onVideoTrackSubscriptionFailed(), ${event.remoteParticipant.sid}, ${event.remoteVideoTrackPublication.trackSid}'); - _onExceptionStreamController.add( - PlatformException( - code: 'ConferenceRoom.videoTrackSubscriptionFailed', - message: 'VideoTrack Subscription Failed', - details: event.exception.toString(), - ), - ); - } - - void _onVideoTrackUnpublished(RemoteVideoTrackEvent event) { - print('ConferenceRoom._onVideoTrackUnpublished(), ${event.remoteParticipant.sid}, ${event.remoteVideoTrackPublication.trackSid}'); - } - - void _onVideoTrackUnsubscribed(RemoteVideoTrackSubscriptionEvent event) { - print('ConferenceRoom._onVideoTrackUnsubscribed(), ${event.remoteParticipant.sid}, ${event.remoteVideoTrack.sid}'); - } - - void _onMessage(RemoteDataTrackStringMessageEvent event) { - print('onMessage => ${event.remoteDataTrack.sid}, ${event.message}'); - } - - void _onBufferMessage(RemoteDataTrackBufferMessageEvent event) { - print('onBufferMessage => ${event.remoteDataTrack.sid}, ${String.fromCharCodes(event.message.asUint8List())}'); - } - - void _setRemoteAudioEnabled(RemoteAudioTrackEvent event) { - if (event.remoteAudioTrackPublication == null) { - return; - } - var index = _participants.indexWhere((ParticipantWidget participant) => participant.id == event.remoteParticipant.sid); - if (index < 0) { - return; - } - var participant = _participants[index]; - _participants.replaceRange( - index, - index + 1, - [ - participant.copyWith(audioEnabled: event.remoteAudioTrackPublication.isTrackEnabled), - ], - ); - notifyListeners(); - } - - void _setRemoteVideoEnabled(RemoteVideoTrackEvent event) { - if (event.remoteVideoTrackPublication == null) { - return; - } - var index = _participants.indexWhere((ParticipantWidget participant) => participant.id == event.remoteParticipant.sid); - if (index < 0) { - return; - } - var participant = _participants[index]; - _participants.replaceRange( - index, - index + 1, - [ - participant.copyWith(videoEnabled: event.remoteVideoTrackPublication.isTrackEnabled), - ], - ); - notifyListeners(); - } - - void _addOrUpdateParticipant(RemoteParticipantEvent event) { - print('ConferenceRoom._addOrUpdateParticipant(), ${event.remoteParticipant.sid}'); - final participant = _participants.firstWhere( - (ParticipantWidget participant) => participant.id == event.remoteParticipant.sid, - orElse: () => null, - ); - if (participant != null) { - print('Participant found: ${participant.id}, updating A/V enabled values'); - _setRemoteVideoEnabled(event); - _setRemoteAudioEnabled(event); - } else { - final bufferedParticipant = _participantBuffer.firstWhere( - (ParticipantBuffer participant) => participant.id == event.remoteParticipant.sid, - orElse: () => null, - ); - if (bufferedParticipant != null) { - _participantBuffer.remove(bufferedParticipant); - } else if (event is RemoteAudioTrackEvent) { - print('Audio subscription came first, waiting for the video subscription...'); - _participantBuffer.add( - ParticipantBuffer( - id: event.remoteParticipant.sid, - audioEnabled: event.remoteAudioTrackPublication?.remoteAudioTrack?.isEnabled ?? true, - ), - ); - return; - } - if (event is RemoteVideoTrackSubscriptionEvent) { - print('New participant, adding: ${event.remoteParticipant.sid}'); - _participants.insert( - 0, - _buildParticipant( - child: event.remoteVideoTrack.widget(), - id: event.remoteParticipant.sid, - remoteParticipant: event.remoteParticipant, - audioEnabled: bufferedParticipant?.audioEnabled ?? true, - videoEnabled: event.remoteVideoTrackPublication?.remoteVideoTrack?.isEnabled ?? true, - ), - ); - } - notifyListeners(); - } - } -} +// import 'dart:async'; +// import 'dart:typed_data'; +// +// import 'package:diplomaticquarterapp/pages/conference/participant_widget.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter/services.dart'; +// +// class ConferenceRoom with ChangeNotifier { +// final String name; +// final String token; +// final String identity; +// +// final StreamController _onAudioEnabledStreamController = StreamController.broadcast(); +// Stream onAudioEnabled; +// final StreamController _onVideoEnabledStreamController = StreamController.broadcast(); +// Stream onVideoEnabled; +// final StreamController _onExceptionStreamController = StreamController.broadcast(); +// Stream onException; +// +// final Completer _completer = Completer(); +// +// final List _participants = []; +// final List _participantBuffer = []; +// final List _streamSubscriptions = []; +// final List _dataTracks = []; +// final List _messages = []; +// +// CameraCapturer _cameraCapturer; +// Room _room; +// Timer _timer; +// +// ConferenceRoom({ +// @required this.name, +// @required this.token, +// @required this.identity, +// }) { +// onAudioEnabled = _onAudioEnabledStreamController.stream; +// onVideoEnabled = _onVideoEnabledStreamController.stream; +// onException = _onExceptionStreamController.stream; +// } +// +// List get participants { +// return [..._participants]; +// } +// +// Future connect() async { +// print('ConferenceRoom.connect()'); +// try { +// await TwilioProgrammableVideo.debug(dart: true, native: true); +// await TwilioProgrammableVideo.setSpeakerphoneOn(true); +// +// _cameraCapturer = CameraCapturer(CameraSource.FRONT_CAMERA); +// var connectOptions = ConnectOptions( +// token, +// roomName: name, +// preferredAudioCodecs: [OpusCodec()], +// audioTracks: [LocalAudioTrack(true)], +// dataTracks: [LocalDataTrack()], +// videoTracks: [LocalVideoTrack(true, _cameraCapturer)], +// enableDominantSpeaker: true, +// ); +// +// _room = await TwilioProgrammableVideo.connect(connectOptions); +// +// _streamSubscriptions.add(_room.onConnected.listen(_onConnected)); +// _streamSubscriptions.add(_room.onConnectFailure.listen(_onConnectFailure)); +// +// return _completer.future; +// } catch (err) { +// print(err); +// rethrow; +// } +// } +// +// Future disconnect() async { +// print('ConferenceRoom.disconnect()'); +// if (_timer != null) { +// _timer.cancel(); +// } +// await _room.disconnect(); +// } +// +// @override +// void dispose() { +// print('ConferenceRoom.dispose()'); +// _disposeStreamsAndSubscriptions(); +// super.dispose(); +// } +// +// Future _disposeStreamsAndSubscriptions() async { +// await _onAudioEnabledStreamController.close(); +// await _onVideoEnabledStreamController.close(); +// await _onExceptionStreamController.close(); +// for (var streamSubscription in _streamSubscriptions) { +// await streamSubscription.cancel(); +// } +// } +// +// Future sendMessage(String message) async { +// final tracks = _room.localParticipant.localDataTracks; +// final localDataTrack = tracks.isEmpty ? null : tracks[0].localDataTrack; +// if (localDataTrack == null || _messages.isNotEmpty) { +// print('ConferenceRoom.sendMessage => Track is not available yet, buffering message.'); +// _messages.add(message); +// return; +// } +// await localDataTrack.send(message); +// } +// +// Future sendBufferMessage(ByteBuffer message) async { +// final tracks = _room.localParticipant.localDataTracks; +// final localDataTrack = tracks.isEmpty ? null : tracks[0].localDataTrack; +// if (localDataTrack == null) { +// return; +// } +// await localDataTrack.sendBuffer(message); +// } +// +// Future toggleVideoEnabled() async { +// final tracks = _room.localParticipant.localVideoTracks; +// final localVideoTrack = tracks.isEmpty ? null : tracks[0].localVideoTrack; +// if (localVideoTrack == null) { +// print('ConferenceRoom.toggleVideoEnabled() => Track is not available yet!'); +// return; +// } +// await localVideoTrack.enable(!localVideoTrack.isEnabled); +// +// var index = _participants.indexWhere((ParticipantWidget participant) => !participant.isRemote); +// if (index < 0) { +// return; +// } +// var participant = _participants[index]; +// _participants.replaceRange( +// index, +// index + 1, +// [ +// participant.copyWith(videoEnabled: localVideoTrack.isEnabled), +// ], +// ); +// print('ConferenceRoom.toggleVideoEnabled() => ${localVideoTrack.isEnabled}'); +// _onVideoEnabledStreamController.add(localVideoTrack.isEnabled); +// notifyListeners(); +// } +// +// Future toggleAudioEnabled() async { +// final tracks = _room.localParticipant.localAudioTracks; +// final localAudioTrack = tracks.isEmpty ? null : tracks[0].localAudioTrack; +// if (localAudioTrack == null) { +// print('ConferenceRoom.toggleAudioEnabled() => Track is not available yet!'); +// return; +// } +// await localAudioTrack.enable(!localAudioTrack.isEnabled); +// +// var index = _participants.indexWhere((ParticipantWidget participant) => !participant.isRemote); +// if (index < 0) { +// return; +// } +// var participant = _participants[index]; +// _participants.replaceRange( +// index, +// index + 1, +// [ +// participant.copyWith(audioEnabled: localAudioTrack.isEnabled), +// ], +// ); +// print('ConferenceRoom.toggleAudioEnabled() => ${localAudioTrack.isEnabled}'); +// _onAudioEnabledStreamController.add(localAudioTrack.isEnabled); +// notifyListeners(); +// } +// +// Future switchCamera() async { +// print('ConferenceRoom.switchCamera()'); +// try { +// await _cameraCapturer.switchCamera(); +// } on FormatException catch (e) { +// print( +// 'ConferenceRoom.switchCamera() failed because of FormatException with message: ${e.message}', +// ); +// } +// } +// +// void addDummy({Widget child}) { +// print('ConferenceRoom.addDummy()'); +// if (_participants.length >= 18) { +// throw PlatformException( +// code: 'ConferenceRoom.maximumReached', +// message: 'Maximum reached', +// details: 'Currently the lay-out can only render a maximum of 18 participants', +// ); +// } +// _participants.insert( +// 0, +// ParticipantWidget( +// id: (_participants.length + 1).toString(), +// child: child, +// isRemote: true, +// audioEnabled: true, +// videoEnabled: true, +// isDummy: true, +// ), +// ); +// notifyListeners(); +// } +// +// void removeDummy() { +// print('ConferenceRoom.removeDummy()'); +// var dummy = _participants.firstWhere((participant) => participant.isDummy, orElse: () => null); +// if (dummy != null) { +// _participants.remove(dummy); +// notifyListeners(); +// } +// } +// +// void _onConnected(Room room) { +// print('ConferenceRoom._onConnected => state: ${room.state}'); +// +// // When connected for the first time, add remote participant listeners +// _streamSubscriptions.add(_room.onParticipantConnected.listen(_onParticipantConnected)); +// _streamSubscriptions.add(_room.onParticipantDisconnected.listen(_onParticipantDisconnected)); +// _streamSubscriptions.add(_room.onDominantSpeakerChange.listen(_onDominantSpeakerChanged)); +// // Only add ourselves when connected for the first time too. +// _participants.add( +// _buildParticipant( +// child: room.localParticipant.localVideoTracks[0].localVideoTrack.widget(), +// id: identity, +// audioEnabled: true, +// videoEnabled: true, +// ), +// ); +// for (final remoteParticipant in room.remoteParticipants) { +// var participant = _participants.firstWhere((participant) => participant.id == remoteParticipant.sid, orElse: () => null); +// if (participant == null) { +// print('Adding participant that was already present in the room ${remoteParticipant.sid}, before I connected'); +// _addRemoteParticipantListeners(remoteParticipant); +// } +// } +// // We have to listen for the [onDataTrackPublished] event on the [LocalParticipant] in +// // order to be able to use the [send] method. +// _streamSubscriptions.add(room.localParticipant.onDataTrackPublished.listen(_onLocalDataTrackPublished)); +// notifyListeners(); +// _completer.complete(room); +// +// _timer = Timer.periodic(const Duration(minutes: 1), (_) { +// // Let's see if we can send some data over the DataTrack API +// sendMessage('And another minute has passed since I connected...'); +// // Also try the ByteBuffer way of sending data +// final list = 'This data has been sent over the ByteBuffer channel of the DataTrack API'.codeUnits; +// var bytes = Uint8List.fromList(list); +// sendBufferMessage(bytes.buffer); +// }); +// } +// +// void _onLocalDataTrackPublished(LocalDataTrackPublishedEvent event) { +// // Send buffered messages, if any... +// while (_messages.isNotEmpty) { +// var message = _messages.removeAt(0); +// print('Sending buffered message: $message'); +// event.localDataTrackPublication.localDataTrack.send(message); +// } +// } +// +// void _onConnectFailure(RoomConnectFailureEvent event) { +// print('ConferenceRoom._onConnectFailure: ${event.exception}'); +// _completer.completeError(event.exception); +// } +// +// void _onDominantSpeakerChanged(DominantSpeakerChangedEvent event) { +// print('ConferenceRoom._onDominantSpeakerChanged: ${event.remoteParticipant.identity}'); +// var oldDominantParticipant = _participants.firstWhere((p) => p.isDominant, orElse: () => null); +// if (oldDominantParticipant != null) { +// var oldDominantParticipantIndex = _participants.indexOf(oldDominantParticipant); +// _participants.replaceRange(oldDominantParticipantIndex, oldDominantParticipantIndex + 1, [oldDominantParticipant.copyWith(isDominant: false)]); +// } +// +// var newDominantParticipant = _participants.firstWhere((p) => p.id == event.remoteParticipant.sid); +// var newDominantParticipantIndex = _participants.indexOf(newDominantParticipant); +// _participants.replaceRange(newDominantParticipantIndex, newDominantParticipantIndex + 1, [newDominantParticipant.copyWith(isDominant: true)]); +// notifyListeners(); +// } +// +// void _onParticipantConnected(RoomParticipantConnectedEvent event) { +// print('ConferenceRoom._onParticipantConnected, ${event.remoteParticipant.sid}'); +// _addRemoteParticipantListeners(event.remoteParticipant); +// } +// +// void _onParticipantDisconnected(RoomParticipantDisconnectedEvent event) { +// print('ConferenceRoom._onParticipantDisconnected: ${event.remoteParticipant.sid}'); +// _participants.removeWhere((ParticipantWidget p) => p.id == event.remoteParticipant.sid); +// notifyListeners(); +// } +// +// ParticipantWidget _buildParticipant({ +// @required Widget child, +// @required String id, +// @required bool audioEnabled, +// @required bool videoEnabled, +// RemoteParticipant remoteParticipant, +// }) { +// return ParticipantWidget( +// id: remoteParticipant?.sid, +// isRemote: remoteParticipant != null, +// child: child, +// audioEnabled: audioEnabled, +// videoEnabled: videoEnabled, +// ); +// } +// +// void _addRemoteParticipantListeners(RemoteParticipant remoteParticipant) { +// print('ConferenceRoom._addRemoteParticipantListeners() => Adding listeners to remoteParticipant ${remoteParticipant.sid}'); +// _streamSubscriptions.add(remoteParticipant.onAudioTrackDisabled.listen(_onAudioTrackDisabled)); +// _streamSubscriptions.add(remoteParticipant.onAudioTrackEnabled.listen(_onAudioTrackEnabled)); +// _streamSubscriptions.add(remoteParticipant.onAudioTrackPublished.listen(_onAudioTrackPublished)); +// _streamSubscriptions.add(remoteParticipant.onAudioTrackSubscribed.listen(_onAudioTrackSubscribed)); +// _streamSubscriptions.add(remoteParticipant.onAudioTrackSubscriptionFailed.listen(_onAudioTrackSubscriptionFailed)); +// _streamSubscriptions.add(remoteParticipant.onAudioTrackUnpublished.listen(_onAudioTrackUnpublished)); +// _streamSubscriptions.add(remoteParticipant.onAudioTrackUnsubscribed.listen(_onAudioTrackUnsubscribed)); +// +// _streamSubscriptions.add(remoteParticipant.onDataTrackPublished.listen(_onDataTrackPublished)); +// _streamSubscriptions.add(remoteParticipant.onDataTrackSubscribed.listen(_onDataTrackSubscribed)); +// _streamSubscriptions.add(remoteParticipant.onDataTrackSubscriptionFailed.listen(_onDataTrackSubscriptionFailed)); +// _streamSubscriptions.add(remoteParticipant.onDataTrackUnpublished.listen(_onDataTrackUnpublished)); +// _streamSubscriptions.add(remoteParticipant.onDataTrackUnsubscribed.listen(_onDataTrackUnsubscribed)); +// +// _streamSubscriptions.add(remoteParticipant.onVideoTrackDisabled.listen(_onVideoTrackDisabled)); +// _streamSubscriptions.add(remoteParticipant.onVideoTrackEnabled.listen(_onVideoTrackEnabled)); +// _streamSubscriptions.add(remoteParticipant.onVideoTrackPublished.listen(_onVideoTrackPublished)); +// _streamSubscriptions.add(remoteParticipant.onVideoTrackSubscribed.listen(_onVideoTrackSubscribed)); +// _streamSubscriptions.add(remoteParticipant.onVideoTrackSubscriptionFailed.listen(_onVideoTrackSubscriptionFailed)); +// _streamSubscriptions.add(remoteParticipant.onVideoTrackUnpublished.listen(_onVideoTrackUnpublished)); +// _streamSubscriptions.add(remoteParticipant.onVideoTrackUnsubscribed.listen(_onVideoTrackUnsubscribed)); +// } +// +// void _onAudioTrackDisabled(RemoteAudioTrackEvent event) { +// print('ConferenceRoom._onAudioTrackDisabled(), ${event.remoteParticipant.sid}, ${event.remoteAudioTrackPublication.trackSid}, isEnabled: ${event.remoteAudioTrackPublication.isTrackEnabled}'); +// _setRemoteAudioEnabled(event); +// } +// +// void _onAudioTrackEnabled(RemoteAudioTrackEvent event) { +// print('ConferenceRoom._onAudioTrackEnabled(), ${event.remoteParticipant.sid}, ${event.remoteAudioTrackPublication.trackSid}, isEnabled: ${event.remoteAudioTrackPublication.isTrackEnabled}'); +// _setRemoteAudioEnabled(event); +// } +// +// void _onAudioTrackPublished(RemoteAudioTrackEvent event) { +// print('ConferenceRoom._onAudioTrackPublished(), ${event.remoteParticipant.sid}}'); +// } +// +// void _onAudioTrackSubscribed(RemoteAudioTrackSubscriptionEvent event) { +// print('ConferenceRoom._onAudioTrackSubscribed(), ${event.remoteParticipant.sid}, ${event.remoteAudioTrackPublication.trackSid}'); +// _addOrUpdateParticipant(event); +// } +// +// void _onAudioTrackSubscriptionFailed(RemoteAudioTrackSubscriptionFailedEvent event) { +// print('ConferenceRoom._onAudioTrackSubscriptionFailed(), ${event.remoteParticipant.sid}, ${event.remoteAudioTrackPublication.trackSid}'); +// _onExceptionStreamController.add( +// PlatformException( +// code: 'ConferenceRoom.audioTrackSubscriptionFailed', +// message: 'AudioTrack Subscription Failed', +// details: event.exception.toString(), +// ), +// ); +// } +// +// void _onAudioTrackUnpublished(RemoteAudioTrackEvent event) { +// print('ConferenceRoom._onAudioTrackUnpublished(), ${event.remoteParticipant.sid}, ${event.remoteAudioTrackPublication.trackSid}'); +// } +// +// void _onAudioTrackUnsubscribed(RemoteAudioTrackSubscriptionEvent event) { +// print('ConferenceRoom._onAudioTrackUnsubscribed(), ${event.remoteParticipant.sid}, ${event.remoteAudioTrack.sid}'); +// } +// +// void _onDataTrackPublished(RemoteDataTrackEvent event) { +// print('ConferenceRoom._onDataTrackPublished(), ${event.remoteParticipant.sid}}'); +// } +// +// void _onDataTrackSubscribed(RemoteDataTrackSubscriptionEvent event) { +// print('ConferenceRoom._onDataTrackSubscribed(), ${event.remoteParticipant.sid}, ${event.remoteDataTrackPublication.trackSid}'); +// final dataTrack = event.remoteDataTrackPublication.remoteDataTrack; +// _dataTracks.add(dataTrack); +// _streamSubscriptions.add(dataTrack.onMessage.listen(_onMessage)); +// _streamSubscriptions.add(dataTrack.onBufferMessage.listen(_onBufferMessage)); +// } +// +// void _onDataTrackSubscriptionFailed(RemoteDataTrackSubscriptionFailedEvent event) { +// print('ConferenceRoom._onDataTrackSubscriptionFailed(), ${event.remoteParticipant.sid}, ${event.remoteDataTrackPublication.trackSid}'); +// _onExceptionStreamController.add( +// PlatformException( +// code: 'ConferenceRoom.dataTrackSubscriptionFailed', +// message: 'DataTrack Subscription Failed', +// details: event.exception.toString(), +// ), +// ); +// } +// +// void _onDataTrackUnpublished(RemoteDataTrackEvent event) { +// print('ConferenceRoom._onDataTrackUnpublished(), ${event.remoteParticipant.sid}, ${event.remoteDataTrackPublication.trackSid}'); +// } +// +// void _onDataTrackUnsubscribed(RemoteDataTrackSubscriptionEvent event) { +// print('ConferenceRoom._onDataTrackUnsubscribed(), ${event.remoteParticipant.sid}, ${event.remoteDataTrack.sid}'); +// } +// +// void _onVideoTrackDisabled(RemoteVideoTrackEvent event) { +// print('ConferenceRoom._onVideoTrackDisabled(), ${event.remoteParticipant.sid}, ${event.remoteVideoTrackPublication.trackSid}, isEnabled: ${event.remoteVideoTrackPublication.isTrackEnabled}'); +// _setRemoteVideoEnabled(event); +// } +// +// void _onVideoTrackEnabled(RemoteVideoTrackEvent event) { +// print('ConferenceRoom._onVideoTrackEnabled(), ${event.remoteParticipant.sid}, ${event.remoteVideoTrackPublication.trackSid}, isEnabled: ${event.remoteVideoTrackPublication.isTrackEnabled}'); +// _setRemoteVideoEnabled(event); +// } +// +// void _onVideoTrackPublished(RemoteVideoTrackEvent event) { +// print('ConferenceRoom._onVideoTrackPublished(), ${event.remoteParticipant.sid}, ${event.remoteVideoTrackPublication.trackSid}'); +// } +// +// void _onVideoTrackSubscribed(RemoteVideoTrackSubscriptionEvent event) { +// print('ConferenceRoom._onVideoTrackSubscribed(), ${event.remoteParticipant.sid}, ${event.remoteVideoTrack.sid}'); +// _addOrUpdateParticipant(event); +// } +// +// void _onVideoTrackSubscriptionFailed(RemoteVideoTrackSubscriptionFailedEvent event) { +// print('ConferenceRoom._onVideoTrackSubscriptionFailed(), ${event.remoteParticipant.sid}, ${event.remoteVideoTrackPublication.trackSid}'); +// _onExceptionStreamController.add( +// PlatformException( +// code: 'ConferenceRoom.videoTrackSubscriptionFailed', +// message: 'VideoTrack Subscription Failed', +// details: event.exception.toString(), +// ), +// ); +// } +// +// void _onVideoTrackUnpublished(RemoteVideoTrackEvent event) { +// print('ConferenceRoom._onVideoTrackUnpublished(), ${event.remoteParticipant.sid}, ${event.remoteVideoTrackPublication.trackSid}'); +// } +// +// void _onVideoTrackUnsubscribed(RemoteVideoTrackSubscriptionEvent event) { +// print('ConferenceRoom._onVideoTrackUnsubscribed(), ${event.remoteParticipant.sid}, ${event.remoteVideoTrack.sid}'); +// } +// +// void _onMessage(RemoteDataTrackStringMessageEvent event) { +// print('onMessage => ${event.remoteDataTrack.sid}, ${event.message}'); +// } +// +// void _onBufferMessage(RemoteDataTrackBufferMessageEvent event) { +// print('onBufferMessage => ${event.remoteDataTrack.sid}, ${String.fromCharCodes(event.message.asUint8List())}'); +// } +// +// void _setRemoteAudioEnabled(RemoteAudioTrackEvent event) { +// if (event.remoteAudioTrackPublication == null) { +// return; +// } +// var index = _participants.indexWhere((ParticipantWidget participant) => participant.id == event.remoteParticipant.sid); +// if (index < 0) { +// return; +// } +// var participant = _participants[index]; +// _participants.replaceRange( +// index, +// index + 1, +// [ +// participant.copyWith(audioEnabled: event.remoteAudioTrackPublication.isTrackEnabled), +// ], +// ); +// notifyListeners(); +// } +// +// void _setRemoteVideoEnabled(RemoteVideoTrackEvent event) { +// if (event.remoteVideoTrackPublication == null) { +// return; +// } +// var index = _participants.indexWhere((ParticipantWidget participant) => participant.id == event.remoteParticipant.sid); +// if (index < 0) { +// return; +// } +// var participant = _participants[index]; +// _participants.replaceRange( +// index, +// index + 1, +// [ +// participant.copyWith(videoEnabled: event.remoteVideoTrackPublication.isTrackEnabled), +// ], +// ); +// notifyListeners(); +// } +// +// void _addOrUpdateParticipant(RemoteParticipantEvent event) { +// print('ConferenceRoom._addOrUpdateParticipant(), ${event.remoteParticipant.sid}'); +// final participant = _participants.firstWhere( +// (ParticipantWidget participant) => participant.id == event.remoteParticipant.sid, +// orElse: () => null, +// ); +// if (participant != null) { +// print('Participant found: ${participant.id}, updating A/V enabled values'); +// _setRemoteVideoEnabled(event); +// _setRemoteAudioEnabled(event); +// } else { +// final bufferedParticipant = _participantBuffer.firstWhere( +// (ParticipantBuffer participant) => participant.id == event.remoteParticipant.sid, +// orElse: () => null, +// ); +// if (bufferedParticipant != null) { +// _participantBuffer.remove(bufferedParticipant); +// } else if (event is RemoteAudioTrackEvent) { +// print('Audio subscription came first, waiting for the video subscription...'); +// _participantBuffer.add( +// ParticipantBuffer( +// id: event.remoteParticipant.sid, +// audioEnabled: event.remoteAudioTrackPublication?.remoteAudioTrack?.isEnabled ?? true, +// ), +// ); +// return; +// } +// if (event is RemoteVideoTrackSubscriptionEvent) { +// print('New participant, adding: ${event.remoteParticipant.sid}'); +// _participants.insert( +// 0, +// _buildParticipant( +// child: event.remoteVideoTrack.widget(), +// id: event.remoteParticipant.sid, +// remoteParticipant: event.remoteParticipant, +// audioEnabled: bufferedParticipant?.audioEnabled ?? true, +// videoEnabled: event.remoteVideoTrackPublication?.remoteVideoTrack?.isEnabled ?? true, +// ), +// ); +// } +// notifyListeners(); +// } +// } +// } diff --git a/lib/pages/feedback/send_feedback_page.dart b/lib/pages/feedback/send_feedback_page.dart index 298e617e..8c2d3006 100644 --- a/lib/pages/feedback/send_feedback_page.dart +++ b/lib/pages/feedback/send_feedback_page.dart @@ -445,7 +445,7 @@ class _SendFeedbackPageState extends State { showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: selectedStatusIndex, onValueSelected: (index) { diff --git a/lib/pages/feedback/status_feedback_page.dart b/lib/pages/feedback/status_feedback_page.dart index 15e3e3dd..419cf1b0 100644 --- a/lib/pages/feedback/status_feedback_page.dart +++ b/lib/pages/feedback/status_feedback_page.dart @@ -95,7 +95,7 @@ class _StatusFeedbackPageState extends State { showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: selectedStatusIndex, onValueSelected: (index) { diff --git a/lib/pages/insurance/insurance_card_update_details.dart b/lib/pages/insurance/insurance_card_update_details.dart index f765d9b7..71637051 100644 --- a/lib/pages/insurance/insurance_card_update_details.dart +++ b/lib/pages/insurance/insurance_card_update_details.dart @@ -352,7 +352,7 @@ class InsuranceCardUpdateDetails extends StatelessWidget { void confirmAttachInsuranceCardImageDialogDialog({BuildContext context, String name, String fileNo, InsuranceViewModel model}) { showDialog( context: context, - child: AttachInsuranceCardImageDialog( + builder: (cxt) => AttachInsuranceCardImageDialog( fileNo: fileNo, name: name, image: (file, image) async { diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index aeb0af07..e420bf74 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -84,7 +84,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { ///inject the user data AuthenticatedUserObject authenticatedUserObject = locator(); - final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); + final FirebaseMessaging _firebaseMessaging = FirebaseMessaging?.instance; final authService = new AuthProvider(); var event = RobotProvider(); @@ -264,7 +264,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { // }).checkAndConnectIfNoInternet(); if (Platform.isIOS) { - _firebaseMessaging.requestNotificationPermissions(); + _firebaseMessaging.requestPermission(); } requestPermissions().then((results) { @@ -288,113 +288,178 @@ class _LandingPageState extends State with WidgetsBindingObserver { // if (results[Permission.accessMediaLocation].isGranted) ; // if (results[Permission.calendar].isGranted) ; }); - // }); - // - // //_firebase Background message handler - _firebaseMessaging.configure( - onMessage: (Map message) async { - // showDialog("onMessage: $message"); - print("onMessage: $message"); - print(message); - print(message['name']); - print(message['appointmentdate']); - - if (Platform.isIOS) { - if (message['is_call'] == "true") { - var route = ModalRoute.of(context); - - if (route != null) { - print(route.settings.name); - } - - Map myMap = new Map.from(message); - print(myMap); - LandingPage.isOpenCallPage = true; - LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); - if (!isPageNavigated) { - isPageNavigated = true; - Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) { - isPageNavigated = false; - }); - } - } else { - print("Is Call Not Found iOS"); + FirebaseMessaging.onMessage.listen((RemoteMessage message) async { + print("onMessage: $message"); + print(message); + print(message.data['name']); + print(message.data['appointmentdate']); + + if (Platform.isIOS) { + if (message.data['is_call'] == "true") { + var route = ModalRoute.of(context); + + if (route != null) { + print(route.settings.name); + } + + Map myMap = new Map.from(message.data); + print(myMap); + LandingPage.isOpenCallPage = true; + LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); + if (!isPageNavigated) { + isPageNavigated = true; + Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) { + isPageNavigated = false; + }); } } else { print("Is Call Not Found iOS"); } + } else { + print("Is Call Not Found iOS"); + } - if (Platform.isAndroid) { - if (message['data'].containsKey("is_call")) { - var route = ModalRoute.of(context); - - if (route != null) { - print(route.settings.name); - } - - Map myMap = new Map.from(message['data']); - print(myMap); - if (LandingPage.isOpenCallPage) { - return; - } - LandingPage.isOpenCallPage = true; - LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); - if (!isPageNavigated) { - isPageNavigated = true; - Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) { - Future.delayed(Duration(seconds: 5), () { - isPageNavigated = false; - }); - }); - } - } else { - print("Is Call Not Found Android"); - LocalNotification.getInstance().showNow(title: message['notification']['title'], subtitle: message['notification']['body']); + if (Platform.isAndroid) { + if (message.data['data'].containsKey("is_call")) { + var route = ModalRoute.of(context); + + if (route != null) { + print(route.settings.name); } - } else { - print("Is Call Not Found Android"); - } - }, - onBackgroundMessage: Platform.isIOS ? null : myBackgroundMessageHandler, - onLaunch: (Map message) async { - print("onLaunch: $message"); - // showDialog("onLaunch: $message"); - }, - onResume: (Map message) async { - print("onResume: $message"); - print(message); - print(message['name']); - print(message['appointmentdate']); - - // showDialog("onResume: $message"); - - if (Platform.isIOS) { - if (message['is_call'] == "true") { - var route = ModalRoute.of(context); - - if (route != null) { - print(route.settings.name); - } - - Map myMap = new Map.from(message); - print(myMap); - LandingPage.isOpenCallPage = true; - LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); - if (!isPageNavigated) { - isPageNavigated = true; - Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) { + + Map myMap = new Map.from(message.data); + print(myMap); + if (LandingPage.isOpenCallPage) { + return; + } + LandingPage.isOpenCallPage = true; + LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); + if (!isPageNavigated) { + isPageNavigated = true; + Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) { + Future.delayed(Duration(seconds: 5), () { isPageNavigated = false; }); - } - } else { - print("Is Call Not Found iOS"); + }); } } else { - print("Is Call Not Found iOS"); + print("Is Call Not Found Android"); + LocalNotification.getInstance().showNow(title: message.data['notification']['title'], subtitle: message.data['notification']['body']); } - }, - ); + } else { + print("Is Call Not Found Android"); + } + }); + FirebaseMessaging.onBackgroundMessage((message) { + return Platform.isIOS ? null : myBackgroundMessageHandler(message.data); + }); + + // todo verify all functionality + + // _firebaseMessaging.configure( + // // onMessage: (Map message) async { + // // // showDialog("onMessage: $message"); + // // print("onMessage: $message"); + // // print(message); + // // print(message['name']); + // // print(message['appointmentdate']); + // // + // // if (Platform.isIOS) { + // // if (message['is_call'] == "true") { + // // var route = ModalRoute.of(context); + // // + // // if (route != null) { + // // print(route.settings.name); + // // } + // // + // // Map myMap = new Map.from(message); + // // print(myMap); + // // LandingPage.isOpenCallPage = true; + // // LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); + // // if (!isPageNavigated) { + // // isPageNavigated = true; + // // Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) { + // // isPageNavigated = false; + // // }); + // // } + // // } else { + // // print("Is Call Not Found iOS"); + // // } + // // } else { + // // print("Is Call Not Found iOS"); + // // } + // // + // // if (Platform.isAndroid) { + // // if (message['data'].containsKey("is_call")) { + // // var route = ModalRoute.of(context); + // // + // // if (route != null) { + // // print(route.settings.name); + // // } + // // + // // Map myMap = new Map.from(message['data']); + // // print(myMap); + // // if (LandingPage.isOpenCallPage) { + // // return; + // // } + // // LandingPage.isOpenCallPage = true; + // // LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); + // // if (!isPageNavigated) { + // // isPageNavigated = true; + // // Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) { + // // Future.delayed(Duration(seconds: 5), () { + // // isPageNavigated = false; + // // }); + // // }); + // // } + // // } else { + // // print("Is Call Not Found Android"); + // // LocalNotification.getInstance().showNow(title: message['notification']['title'], subtitle: message['notification']['body']); + // // } + // // } else { + // // print("Is Call Not Found Android"); + // // } + // // }, + // onBackgroundMessage: Platform.isIOS ? null : myBackgroundMessageHandler, + // onLaunch: (Map message) async { + // print("onLaunch: $message"); + // // showDialog("onLaunch: $message"); + // }, + // onResume: (Map message) async { + // print("onResume: $message"); + // print(message); + // print(message['name']); + // print(message['appointmentdate']); + // + // // showDialog("onResume: $message"); + // + // if (Platform.isIOS) { + // if (message['is_call'] == "true") { + // var route = ModalRoute.of(context); + // + // if (route != null) { + // print(route.settings.name); + // } + // + // Map myMap = new Map.from(message); + // print(myMap); + // LandingPage.isOpenCallPage = true; + // LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); + // if (!isPageNavigated) { + // isPageNavigated = true; + // Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) { + // isPageNavigated = false; + // }); + // } + // } else { + // print("Is Call Not Found iOS"); + // } + // } else { + // print("Is Call Not Found iOS"); + // } + // }, + // ); } Future> requestPermissions() async { @@ -424,8 +489,8 @@ class _LandingPageState extends State with WidgetsBindingObserver { LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); LandingPage.isOpenCallPage = true; // Future.delayed(Duration(seconds: 3), () { - // Navigator.push(locator().navigatorKey.currentContext, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))); - NavigationService.instance.navigateTo(INCOMING_CALL_PAGE); + // Navigator.push(locator().navigatorKey.currentContext, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))); + NavigationService.instance.navigateTo(INCOMING_CALL_PAGE); // }); // if (!isPageNavigated) { // isPageNavigated = true; diff --git a/lib/pages/livecare/incoming_call.dart b/lib/pages/livecare/incoming_call.dart index b02676e0..c4f1f038 100644 --- a/lib/pages/livecare/incoming_call.dart +++ b/lib/pages/livecare/incoming_call.dart @@ -3,8 +3,6 @@ import 'dart:ui'; import 'package:camera/camera.dart'; import 'package:diplomaticquarterapp/models/LiveCare/IncomingCallData.dart'; import 'package:diplomaticquarterapp/models/LiveCare/room_model.dart'; -import 'package:diplomaticquarterapp/pages/conference/conference_page.dart'; -import 'package:diplomaticquarterapp/pages/conference/web_rtc/call_home_page.dart'; import 'package:diplomaticquarterapp/pages/conference/widgets/platform_exception_alert_dialog.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -350,12 +348,12 @@ class _IncomingCallState extends State with SingleTickerProviderSt // ConferencePage(roomModel: roomModel), // ), // ); - await Navigator.of(context).push( - MaterialPageRoute( - fullscreenDialog: true, - builder: (BuildContext context) => CallHomePage(), - ), - ); + // await Navigator.of(context).push( // todo temporary comment lines for call + // MaterialPageRoute( + // fullscreenDialog: true, + // builder: (BuildContext context) => CallHomePage(), + // ), + // ); } catch (err) { print(err); await PlatformExceptionAlertDialog( diff --git a/lib/pages/livecare/widgets/LiveCareHistoryCard.dart b/lib/pages/livecare/widgets/LiveCareHistoryCard.dart index 91659278..def0461d 100644 --- a/lib/pages/livecare/widgets/LiveCareHistoryCard.dart +++ b/lib/pages/livecare/widgets/LiveCareHistoryCard.dart @@ -223,7 +223,7 @@ class _LiveCareHistoryCardState extends State { openInvoice() { showDialog( context: context, - child: ConfirmSendEmailDialog( + builder: (cxt) => ConfirmSendEmailDialog( email: projectViewModel.user.emailAddress, onTapSendEmail: () { sendInvoiceEmail(context); diff --git a/lib/pages/livecare/widgets/LiveCarePendingRequest.dart b/lib/pages/livecare/widgets/LiveCarePendingRequest.dart index 4f0a86fc..c5628276 100644 --- a/lib/pages/livecare/widgets/LiveCarePendingRequest.dart +++ b/lib/pages/livecare/widgets/LiveCarePendingRequest.dart @@ -57,7 +57,7 @@ class _LiveCarePendingRequestState extends State { duration: widget.pendingERRequestHistoryList.watingtimeInteger * 60, width: MediaQuery.of(context).size.width / 2, height: MediaQuery.of(context).size.height / 2, - color: Colors.white, + ringColor: Colors.white, fillColor: CustomColors.green, strokeWidth: 7.0, textStyle: TextStyle(fontSize: 32.0, color: Color(0xff2E303A), fontWeight: FontWeight.w400), diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index 1903e561..b1217409 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -107,7 +107,7 @@ class _ConfirmLogin extends State { return Scaffold( backgroundColor: Color(0xfff8f8f8), - resizeToAvoidBottomPadding: false, + resizeToAvoidBottomInset: false, appBar: AppBar( backgroundColor: Colors.transparent, leading: IconButton( diff --git a/lib/pages/login/login-type.dart b/lib/pages/login/login-type.dart index b77d34f3..ab34d75f 100644 --- a/lib/pages/login/login-type.dart +++ b/lib/pages/login/login-type.dart @@ -21,7 +21,7 @@ class LoginType extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( backgroundColor: Color(0xfff8f8f8), - resizeToAvoidBottomPadding: false, + resizeToAvoidBottomInset: false, appBar: AppBar( backgroundColor: Colors.transparent, leading: IconButton( diff --git a/lib/pages/medical/active_medications/reminder_page.dart b/lib/pages/medical/active_medications/reminder_page.dart index a6df5f28..7ad8f9f2 100644 --- a/lib/pages/medical/active_medications/reminder_page.dart +++ b/lib/pages/medical/active_medications/reminder_page.dart @@ -281,7 +281,7 @@ class _ReminderPageState extends State { void confirmSelectDayDialog() { showDialog( context: context, - child: DayCheckBoxDialog( + builder: (cxt) => DayCheckBoxDialog( title: 'Select Day', selectedDaysOfWeek: widget.daysOfWeek, onValueSelected: (value) { diff --git a/lib/pages/medical/balance/advance_payment_page.dart b/lib/pages/medical/balance/advance_payment_page.dart index 051b9b95..2fdb93ce 100644 --- a/lib/pages/medical/balance/advance_payment_page.dart +++ b/lib/pages/medical/balance/advance_payment_page.dart @@ -101,7 +101,7 @@ class _AdvancePaymentPageState extends State { ]; showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: beneficiaryType == BeneficiaryType.MyAccount ? 0 : (beneficiaryType == BeneficiaryType.MyFamilyFiles ? 1 : (beneficiaryType == BeneficiaryType.OtherAccount ? 2 : -1)), @@ -359,7 +359,7 @@ class _AdvancePaymentPageState extends State { ]; showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: _selectedHospitalIndex, isScrollable: true, @@ -380,7 +380,7 @@ class _AdvancePaymentPageState extends State { ]; showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, isScrollable: true, selectedIndex: _selectedPatientIndex, @@ -404,7 +404,7 @@ class _AdvancePaymentPageState extends State { ]; showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, isScrollable: true, selectedIndex: _selectedFamilyMemberIndex, diff --git a/lib/pages/medical/balance/new_text_Field.dart b/lib/pages/medical/balance/new_text_Field.dart index 972d6b92..e1f7fdd4 100644 --- a/lib/pages/medical/balance/new_text_Field.dart +++ b/lib/pages/medical/balance/new_text_Field.dart @@ -189,7 +189,7 @@ class _NewTextFieldsState extends State { autofocus: widget.autoFocus ?? false, validator: widget.validator, onSaved: widget.onSaved, - style: Theme.of(context).textTheme.body2.copyWith( + style: Theme.of(context).textTheme.bodyText2.copyWith( fontSize: widget.fontSize, fontWeight: widget.fontWeight), inputFormatters: widget.keyboardType == TextInputType.phone ? [ diff --git a/lib/pages/medical/eye/ClassesPage.dart b/lib/pages/medical/eye/ClassesPage.dart index bb38d095..573e5bf3 100644 --- a/lib/pages/medical/eye/ClassesPage.dart +++ b/lib/pages/medical/eye/ClassesPage.dart @@ -106,7 +106,7 @@ class ClassesPage extends StatelessWidget { void showConfirmMessage(BuildContext context, GestureTapCallback onTap, String email) { showDialog( context: context, - child: ConfirmSendEmailDialog( + builder: (cxt) => ConfirmSendEmailDialog( email: email, onTapSendEmail: () { onTap(); diff --git a/lib/pages/medical/eye/ContactLensPage.dart b/lib/pages/medical/eye/ContactLensPage.dart index 007a5527..49db73b8 100644 --- a/lib/pages/medical/eye/ContactLensPage.dart +++ b/lib/pages/medical/eye/ContactLensPage.dart @@ -167,7 +167,7 @@ class ContactLensPage extends StatelessWidget { void showConfirmMessage(BuildContext context, GestureTapCallback onTap, String email) { showDialog( context: context, - child: ConfirmSendEmailDialog( + builder: (cxt) => ConfirmSendEmailDialog( email: email, onTapSendEmail: () { onTap(); diff --git a/lib/pages/medical/eye/EyeHomePage.dart b/lib/pages/medical/eye/EyeHomePage.dart index 3d59af3d..6a62af5d 100644 --- a/lib/pages/medical/eye/EyeHomePage.dart +++ b/lib/pages/medical/eye/EyeHomePage.dart @@ -167,7 +167,7 @@ class _EyeHomePageState extends State with SingleTickerProviderStat void showConfirmMessage(BuildContext context, GestureTapCallback onTap, String email) { showDialog( context: context, - child: ConfirmSendEmailDialog( + builder: (cxt) => ConfirmSendEmailDialog( email: email, onTapSendEmail: () { onTap(); diff --git a/lib/pages/medical/my_trackers/Weight/AddWeightPage.dart b/lib/pages/medical/my_trackers/Weight/AddWeightPage.dart index 5ef8c69c..a3452d0b 100644 --- a/lib/pages/medical/my_trackers/Weight/AddWeightPage.dart +++ b/lib/pages/medical/my_trackers/Weight/AddWeightPage.dart @@ -9,8 +9,6 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/ConfirmWithMessageDialog.dart'; - -import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; @@ -96,7 +94,7 @@ class _AddWeightPageState extends State { showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: weightUnit, onValueSelected: (index) { @@ -198,7 +196,7 @@ class _AddWeightPageState extends State { onTap: () { showDialog( context: context, - child: ConfirmWithMessageDialog( + builder: (cxt) => ConfirmWithMessageDialog( message: TranslationBase.of(context).removeMeasure, onTap: () async { GifLoaderDialogUtils.showMyDialog(context); diff --git a/lib/pages/medical/my_trackers/Weight/WeightHomePage.dart b/lib/pages/medical/my_trackers/Weight/WeightHomePage.dart index 6857b6cd..b2f7e759 100644 --- a/lib/pages/medical/my_trackers/Weight/WeightHomePage.dart +++ b/lib/pages/medical/my_trackers/Weight/WeightHomePage.dart @@ -57,7 +57,7 @@ class _WeightHomePageState extends State with SingleTickerProvid onPressed: () { showDialog( context: context, - child: ConfirmSendEmailDialog( + builder: (cxt) => ConfirmSendEmailDialog( email: model.user.emailAddress, onTapSendEmail: () async { GifLoaderDialogUtils.showMyDialog(context); diff --git a/lib/pages/medical/my_trackers/blood_pressure/AddBloodPressurePage.dart b/lib/pages/medical/my_trackers/blood_pressure/AddBloodPressurePage.dart index a4c0b943..9e666cf7 100644 --- a/lib/pages/medical/my_trackers/blood_pressure/AddBloodPressurePage.dart +++ b/lib/pages/medical/my_trackers/blood_pressure/AddBloodPressurePage.dart @@ -106,7 +106,7 @@ class _AddBloodPressurePageState extends State { showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: measuredArm, onValueSelected: (index) { diff --git a/lib/pages/medical/my_trackers/blood_pressure/BloodPressureHomePage.dart b/lib/pages/medical/my_trackers/blood_pressure/BloodPressureHomePage.dart index 7501e910..7cb1b154 100644 --- a/lib/pages/medical/my_trackers/blood_pressure/BloodPressureHomePage.dart +++ b/lib/pages/medical/my_trackers/blood_pressure/BloodPressureHomePage.dart @@ -127,7 +127,7 @@ class _BloodPressureHomePageState extends State with Sing () { showDialog( context: context, - child: ConfirmSendEmailDialog( + builder: (cxt) => ConfirmSendEmailDialog( email: model.user.emailAddress, onTapSendEmail: () async { GifLoaderDialogUtils.showMyDialog(context); diff --git a/lib/pages/medical/my_trackers/blood_suger/AddBloodSugarPage.dart b/lib/pages/medical/my_trackers/blood_suger/AddBloodSugarPage.dart index 8e47e4e8..a3c1fa94 100644 --- a/lib/pages/medical/my_trackers/blood_suger/AddBloodSugarPage.dart +++ b/lib/pages/medical/my_trackers/blood_suger/AddBloodSugarPage.dart @@ -214,7 +214,7 @@ class _AddBloodSugarPageState extends State { onTap: () { showDialog( context: context, - child: ConfirmWithMessageDialog( + builder: (cxt) => ConfirmWithMessageDialog( message: TranslationBase.of(context).removeMeasure, onTap: () async { GifLoaderDialogUtils.showMyDialog(context); @@ -301,7 +301,7 @@ class _AddBloodSugarPageState extends State { showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: _selectedMeasureUnitIndex, onValueSelected: (index) { @@ -320,7 +320,7 @@ class _AddBloodSugarPageState extends State { showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: _selectedMeasureTimeIndex, isScrollable: true, diff --git a/lib/pages/medical/my_trackers/blood_suger/blood_sugar_home_page.dart b/lib/pages/medical/my_trackers/blood_suger/blood_sugar_home_page.dart index eeef1de5..21ed5840 100644 --- a/lib/pages/medical/my_trackers/blood_suger/blood_sugar_home_page.dart +++ b/lib/pages/medical/my_trackers/blood_suger/blood_sugar_home_page.dart @@ -135,7 +135,7 @@ class _BloodSugarHomePageState extends State with SingleTick () { showDialog( context: context, - child: ConfirmSendEmailDialog( + builder: (cxt) => ConfirmSendEmailDialog( email: model.user.emailAddress, onTapSendEmail: () async { GifLoaderDialogUtils.showMyDialog(context); diff --git a/lib/pages/medical/my_trackers/widget/CurvedChartBloodPressure.dart b/lib/pages/medical/my_trackers/widget/CurvedChartBloodPressure.dart index 7248b7e0..4e0fe4e6 100644 --- a/lib/pages/medical/my_trackers/widget/CurvedChartBloodPressure.dart +++ b/lib/pages/medical/my_trackers/widget/CurvedChartBloodPressure.dart @@ -13,12 +13,7 @@ class CurvedChartBloodPressure extends StatelessWidget { final int indexes; final double horizontalInterval; - CurvedChartBloodPressure( - {this.title, - this.timeSeries1, - this.indexes, - this.timeSeries2, - this.horizontalInterval = 20.0}); + CurvedChartBloodPressure({this.title, this.timeSeries1, this.indexes, this.timeSeries2, this.horizontalInterval = 20.0}); List xAxixs = List(); List yAxixs = List(); @@ -43,8 +38,7 @@ class CurvedChartBloodPressure extends StatelessWidget { ), Text( title, - style: TextStyle( - color: Colors.black, fontSize: 15, letterSpacing: 2), + style: TextStyle(color: Colors.black, fontSize: 15, letterSpacing: 2), textAlign: TextAlign.center, ), SizedBox( @@ -52,8 +46,7 @@ class CurvedChartBloodPressure extends StatelessWidget { ), Expanded( child: Padding( - padding: - const EdgeInsets.only(right: 18.0, left: 16.0, top: 15), + padding: const EdgeInsets.only(right: 18.0, left: 16.0, top: 15), child: LineChart( sampleData1(context), swapAnimationDuration: const Duration(milliseconds: 250), @@ -72,9 +65,7 @@ class CurvedChartBloodPressure extends StatelessWidget { Container( width: 20, height: 20, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: Theme.of(context).primaryColor), + decoration: BoxDecoration(shape: BoxShape.rectangle, color: Theme.of(context).primaryColor), ), SizedBox( width: 5, @@ -90,8 +81,7 @@ class CurvedChartBloodPressure extends StatelessWidget { Container( width: 20, height: 20, - decoration: BoxDecoration( - shape: BoxShape.rectangle, color: secondaryColor), + decoration: BoxDecoration(shape: BoxShape.rectangle, color: secondaryColor), ), SizedBox( width: 5, @@ -124,19 +114,17 @@ class CurvedChartBloodPressure extends StatelessWidget { touchTooltipData: LineTouchTooltipData( tooltipBgColor: Colors.white, ), - touchCallback: (LineTouchResponse touchResponse) {}, + touchCallback: (touchEvent, LineTouchResponse touchResponse) {}, handleBuiltInTouches: true, ), - gridData: FlGridData( - show: true, drawVerticalLine: true, drawHorizontalLine: true), + gridData: FlGridData(show: true, drawVerticalLine: true, drawHorizontalLine: true), titlesData: FlTitlesData( bottomTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( + getTextStyles: (cxt, value) => const TextStyle( color: Colors.black, fontSize: 10, ), - margin: 22, getTitles: (value) { if (timeSeries1.length < 15) { @@ -145,10 +133,8 @@ class CurvedChartBloodPressure extends StatelessWidget { } else return ''; } else { - if (value.toInt() == 0) - return '${timeSeries1[value.toInt()].time.month}/ ${timeSeries1[value.toInt()].time.year}'; - if (value.toInt() == timeSeries1.length - 1) - return '${timeSeries1[value.toInt()].time.month}/ ${timeSeries1[value.toInt()].time.year}'; + if (value.toInt() == 0) return '${timeSeries1[value.toInt()].time.month}/ ${timeSeries1[value.toInt()].time.year}'; + if (value.toInt() == timeSeries1.length - 1) return '${timeSeries1[value.toInt()].time.month}/ ${timeSeries1[value.toInt()].time.year}'; if (xAxixs.contains(value.toInt())) { return '${timeSeries1[value.toInt()].time.month}/ ${timeSeries1[value.toInt()].time.year}'; } @@ -158,9 +144,12 @@ class CurvedChartBloodPressure extends StatelessWidget { ), leftTitles: SideTitles( showTitles: true, - interval:getMaxY() - getMinY() <=500?50:getMaxY() - getMinY() <=1000?100:200, - - getTextStyles: (value) => const TextStyle( + interval: getMaxY() - getMinY() <= 500 + ? 50 + : getMaxY() - getMinY() <= 1000 + ? 100 + : 200, + getTextStyles: (cxt, value) => const TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 10, diff --git a/lib/pages/medical/my_trackers/widget/LineChartCurved.dart b/lib/pages/medical/my_trackers/widget/LineChartCurved.dart index 47a5d490..a49f7c80 100644 --- a/lib/pages/medical/my_trackers/widget/LineChartCurved.dart +++ b/lib/pages/medical/my_trackers/widget/LineChartCurved.dart @@ -163,14 +163,14 @@ class LineChartCurved extends StatelessWidget { touchTooltipData: LineTouchTooltipData( tooltipBgColor: Colors.white, ), - touchCallback: (LineTouchResponse touchResponse) {}, + touchCallback: (touchEvent, LineTouchResponse touchResponse) {}, handleBuiltInTouches: true, ), gridData: FlGridData(show: true, drawVerticalLine: true, drawHorizontalLine: true, horizontalInterval: 14, verticalInterval: 14), titlesData: FlTitlesData( bottomTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( + getTextStyles: (cxt, value) => const TextStyle( color: Colors.black, fontSize: 10, ), @@ -194,7 +194,7 @@ class LineChartCurved extends StatelessWidget { ), leftTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( + getTextStyles: (cxt, value) => const TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 10, diff --git a/lib/pages/medical/my_trackers/widget/MonthCurvedChartBloodPressure.dart b/lib/pages/medical/my_trackers/widget/MonthCurvedChartBloodPressure.dart index bf3d9cb9..8431dd0b 100644 --- a/lib/pages/medical/my_trackers/widget/MonthCurvedChartBloodPressure.dart +++ b/lib/pages/medical/my_trackers/widget/MonthCurvedChartBloodPressure.dart @@ -113,14 +113,14 @@ class MonthCurvedChartBloodPressure extends StatelessWidget { touchTooltipData: LineTouchTooltipData( tooltipBgColor: Colors.white, ), - touchCallback: (LineTouchResponse touchResponse) {}, + touchCallback: (touchEvent, LineTouchResponse touchResponse) {}, handleBuiltInTouches: true, ), gridData: FlGridData(show: true, drawVerticalLine: true, drawHorizontalLine: true, horizontalInterval: 14, verticalInterval: 14), titlesData: FlTitlesData( bottomTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( + getTextStyles: (cxt, value) => const TextStyle( color: Colors.black, fontSize: 10, ), @@ -138,7 +138,7 @@ class MonthCurvedChartBloodPressure extends StatelessWidget { ? 30 : 40, - getTextStyles: (value) => const TextStyle( + getTextStyles: (cxt, value) => const TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 10, diff --git a/lib/pages/medical/my_trackers/widget/MonthLineChartCurved.dart b/lib/pages/medical/my_trackers/widget/MonthLineChartCurved.dart index c1ef7f5a..6192134c 100644 --- a/lib/pages/medical/my_trackers/widget/MonthLineChartCurved.dart +++ b/lib/pages/medical/my_trackers/widget/MonthLineChartCurved.dart @@ -87,7 +87,7 @@ class MonthLineChartCurved extends StatelessWidget { touchTooltipData: LineTouchTooltipData( tooltipBgColor: Colors.white, ), - touchCallback: (LineTouchResponse touchResponse) {}, + touchCallback: (touchEvent, LineTouchResponse touchResponse) {}, handleBuiltInTouches: true, ), gridData: FlGridData( @@ -100,7 +100,7 @@ class MonthLineChartCurved extends StatelessWidget { titlesData: FlTitlesData( bottomTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( + getTextStyles: (cxt, value) => const TextStyle( color: Colors.black, fontSize: 10, ), @@ -111,7 +111,7 @@ class MonthLineChartCurved extends StatelessWidget { ), leftTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( + getTextStyles: (cxt, value) => const TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 10, diff --git a/lib/pages/medical/patient_sick_leave_page.dart b/lib/pages/medical/patient_sick_leave_page.dart index f9f8f7e2..401bf694 100644 --- a/lib/pages/medical/patient_sick_leave_page.dart +++ b/lib/pages/medical/patient_sick_leave_page.dart @@ -66,7 +66,7 @@ class _PatientSickLeavePageState extends State { void showConfirmMessage(PatientSickLeaveViewMode model, int index) { showDialog( context: context, - child: ConfirmSendEmailDialog( + builder: (cxt) => ConfirmSendEmailDialog( email: model.user.emailAddress, onTapSendEmail: () { model.sendSickLeaveEmail( diff --git a/lib/pages/medical/prescriptions/PrescriptionIDeliveryAddressPage.dart b/lib/pages/medical/prescriptions/PrescriptionIDeliveryAddressPage.dart index 6574780d..ba094229 100644 --- a/lib/pages/medical/prescriptions/PrescriptionIDeliveryAddressPage.dart +++ b/lib/pages/medical/prescriptions/PrescriptionIDeliveryAddressPage.dart @@ -7,14 +7,14 @@ import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/add_new_address_Request_Model.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/PrescriptionDeliveryViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/cmc_location_page.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart'; +import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/h2o/h20_setting.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/select_location_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; @@ -39,6 +39,7 @@ class PrescriptionDeliveryAddressPage extends StatefulWidget { class _PrescriptionDeliveryAddressPageState extends State { AddressInfo _selectedAddress; + int _selectedAddressIndex = -1; Completer _controller = Completer(); CameraPosition _kGooglePlex = CameraPosition( @@ -86,55 +87,58 @@ class _PrescriptionDeliveryAddressPageState extends State confirmSelectLocationDialog(model.addressesList), - child: Container( - padding: EdgeInsets.all(8), - width: double.infinity, - // height: 65, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.white, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Text( - getAddressName(), - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 12, - letterSpacing: -0.45, - ), - ), + CommonDropDownView(TranslationBase.of(context).selectAddress, getAddressName(), () { + List list = [ + for (int i = 0; i < model.addressesList.length; i++) RadioSelectionDialogModel(model.addressesList[i].address1, i), + ]; + + showDialog( + context: context, + builder: (cxt) => RadioSelectionDialog( + listData: list, + isScrollable: true, + selectedIndex: _selectedAddressIndex, + onValueSelected: (index) { + _selectedAddressIndex = index; + _selectedAddress = model.addressesList[index]; + List latLongArr = _selectedAddress.latLong.split(','); + + latitude = double.parse(latLongArr[0]); + longitude = double.parse(latLongArr[1]); + markers = Set(); + markers.add( + Marker( + markerId: MarkerId( + _selectedAddress.latLong.hashCode.toString(), ), - Icon(Icons.arrow_drop_down) - ], - ), - ), + position: LatLng(latitude, longitude), + ), + ); + _kGooglePlex = CameraPosition( + target: LatLng(latitude, longitude), + zoom: 14.4746, + ); + setState(() {}); + }, ), - height: 50, - width: double.infinity, - ), - ), + ); + }).withBorderedContainer, + SizedBox(height: 12), InkWell( onTap: () async { Navigator.push( context, FadePage( - page: LocationPage( - latitude: latitude, - longitude: longitude, - )), + page: LocationPage( + latitude: latitude, + longitude: longitude, + ), + ), ).then((value) { if (value != null && value is AddNewAddressRequestModel) { setState(() { @@ -179,140 +183,108 @@ class _PrescriptionDeliveryAddressPageState extends State SelectLocationDialog( addresses: addresses, selectedAddress: _selectedAddress, onValueSelected: (value) { @@ -355,9 +327,6 @@ class _PrescriptionDeliveryAddressPageState extends State ConfirmWithMessageDialog( message: TranslationBase.of(context).confirmPrescription, okTitle: TranslationBase.of(context).ok, onTap: () async { @@ -225,7 +225,7 @@ class PrescriptionOrderOverview extends StatelessWidget { void showErrorDialog(BuildContext context, String error) { showDialog( context: context, - child: ConfirmWithMessageDialog( + builder: (cxt) => ConfirmWithMessageDialog( message: TranslationBase.of(context).youAlreadyHaveOrder, okTitle: TranslationBase.of(context).orderOverview, onTap: () { diff --git a/lib/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart b/lib/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart index b12cc386..bb0f6a30 100644 --- a/lib/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart +++ b/lib/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart @@ -28,7 +28,7 @@ class PharmacyForPrescriptionsPage extends StatelessWidget { body: Column( children: [ Padding( - padding: const EdgeInsets.fromLTRB(21, 21, 21, 0), + padding: const EdgeInsets.fromLTRB(21, 21, 21, 10), child: Container( width: double.infinity, padding: const EdgeInsets.only(left: 12, right: 12, top: 12, bottom: 12), @@ -50,7 +50,7 @@ class PharmacyForPrescriptionsPage extends StatelessWidget { ClipRRect( borderRadius: BorderRadius.all(Radius.circular(5)), child: Image.network( - prescriptionReport.imageSRCUrl, + prescriptionReport?.imageSRCUrl ?? "", fit: BoxFit.cover, width: 60, height: 70, @@ -60,7 +60,7 @@ class PharmacyForPrescriptionsPage extends StatelessWidget { child: Padding( padding: const EdgeInsets.all(8.0), child: Center( - child: Texts(prescriptionReport.itemDescription.isNotEmpty ? prescriptionReport.itemDescription : prescriptionReport.itemDescriptionN ?? ''), + child: Texts((prescriptionReport?.itemDescription ?? "").isNotEmpty ? prescriptionReport?.itemDescription ?? "" : prescriptionReport?.itemDescriptionN ?? ''), ), ), ) @@ -72,7 +72,7 @@ class PharmacyForPrescriptionsPage extends StatelessWidget { ? Expanded( child: ListView.builder( scrollDirection: Axis.vertical, - padding: EdgeInsets.all(21), + padding: EdgeInsets.fromLTRB(21, 11, 21, 21), physics: BouncingScrollPhysics(), itemBuilder: (context, index) { GetHMGLocationsModel location = GetHMGLocationsModel(); diff --git a/lib/pages/medical/prescriptions/prescription_details_inp.dart b/lib/pages/medical/prescriptions/prescription_details_inp.dart index 8c181f88..25c3790c 100644 --- a/lib/pages/medical/prescriptions/prescription_details_inp.dart +++ b/lib/pages/medical/prescriptions/prescription_details_inp.dart @@ -1,279 +1,216 @@ +import 'package:diplomaticquarterapp/core/model/prescriptions/Prescriptions.dart'; +import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report_inp.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/reminder_dialog.dart'; +import 'package:diplomaticquarterapp/extensions/string_extensions.dart'; +import 'package:diplomaticquarterapp/models/header_model.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/reminder_dialog.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart'; +import 'package:diplomaticquarterapp/uitl/CalendarUtils.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; +import 'package:diplomaticquarterapp/widgets/new_design/doctor_header.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/show_zoom_image_dialog.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:jiffy/jiffy.dart'; import 'package:provider/provider.dart'; class PrescriptionDetailsPageINP extends StatelessWidget { final PrescriptionReportINP prescriptionReport; + final Prescriptions prescriptions; - PrescriptionDetailsPageINP({Key key, this.prescriptionReport}); + PrescriptionDetailsPageINP({Key key, this.prescriptionReport, this.prescriptions}); @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); return AppScaffold( isShowAppBar: true, + showNewAppBar: true, + showNewAppBarTitle: true, appBarTitle: TranslationBase.of(context).prescriptions, - body: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: double.infinity, - margin: EdgeInsets.only(top: 10, left: 10, right: 10), - padding: EdgeInsets.all(8.0), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(10.0), - ), - border: Border.all(color: Colors.grey[200], width: 0.5), - ), - child: Row( - children: [ - ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(5)), - child: Image.network( - prescriptionReport.imageSRCUrl, - fit: BoxFit.cover, - width: 60, - height: 70, - ), - ), - Expanded( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Center( - child: Texts(prescriptionReport.itemDescription.isNotEmpty - ? prescriptionReport.itemDescription - : prescriptionReport.itemDescriptionN ?? ''), - ), - ), - ) - ], - ), - ), - Container( - margin: EdgeInsets.all(8), - child: Row( - children: [ - Expanded( - child: InkWell( - onTap: () => Navigator.push( - context, - FadePage( - page: PharmacyForPrescriptionsPage( - itemID: prescriptionReport.itemID, - ), - ), - ), - child: Center( - child: Column( - children: [ - Container( - width: 50, - decoration: BoxDecoration(color: Colors.white, shape: BoxShape.rectangle), - child: Column( - children: [ - Icon( - Icons.pin_drop, - color: Colors.red[800], - size: 55, - ), - ], - ), - ), - SizedBox( - height: 5, - ), - Texts(TranslationBase.of(context).availability) - ], - ), - )), - ), - _addReminderButton(context) - ], - ), + body: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + DoctorHeader( + headerModel: HeaderModel( + prescriptions.doctorName, + prescriptions.doctorID, + prescriptions.doctorImageURL, + prescriptions.speciality, + "", + prescriptions.name, + DateUtil.convertStringToDate(prescriptions.appointmentDate), + DateUtil.formatDateToTime(DateUtil.convertStringToDate(prescriptions.appointmentDate)), + prescriptions.nationalityFlagURL, + prescriptions.doctorRate, + prescriptions.actualDoctorRate, + prescriptions.noOfPatientsRate, + "", ), - Container( - color: Colors.white, - margin: EdgeInsets.only(top: 10, left: 10, right: 10), - child: Table( - border: TableBorder.symmetric(inside: BorderSide(width: 0.5), outside: BorderSide(width: 0.5)), - children: [ - TableRow( - children: [ - Container( - color: Colors.white, - height: 40, - width: double.infinity, - child: Center( - child: Texts( - TranslationBase.of(context).route, - fontSize: 14, - ))), - Container( - color: Colors.white, - height: 40, - width: double.infinity, - child: Center( - child: Texts( - TranslationBase.of(context).frequency, - fontSize: 14, - ))), - Container( - color: Colors.white, - height: 40, - width: double.infinity, - padding: EdgeInsets.symmetric(horizontal: 4), - child: Center( - child: Texts( - "${TranslationBase.of(context).dailyDoses}", - fontSize: 14, - ))), - Container( - color: Colors.white, - height: 40, - width: double.infinity, - child: Center( - child: Texts( - TranslationBase.of(context).duration, - fontSize: 14, - ))), + isNeedToShowButton: false, + ), + Expanded( + child: ListView( + physics: BouncingScrollPhysics(), + padding: EdgeInsets.all(21), + children: [ + Container( + padding: EdgeInsets.all(14), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(10.0)), + boxShadow: [ + BoxShadow( + color: Color(0xff000000).withOpacity(.05), + //spreadRadius: 5, + blurRadius: 27, + offset: Offset(0, -3), + ), ], ), - TableRow( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, children: [ - Container( - color: Colors.white, - height: 50, - width: double.infinity, - child: Center(child: Text(prescriptionReport.routeN ?? ''))), - Container( - color: Colors.white, - height: 50, - width: double.infinity, - child: Center(child: Text(prescriptionReport.frequencyN ?? ''))), - Container( - color: Colors.white, - height: 50, - width: double.infinity, - child: Center(child: Text('${prescriptionReport.doseDailyQuantity}'))), - Container( - color: Colors.white, - height: 50, - width: double.infinity, - child: Center(child: Text('${prescriptionReport.days}'))) + Row( + children: [ + InkWell( + child: Stack( + alignment: Alignment.center, + children: [ + Container( + child: Image.network( + prescriptionReport.imageSRCUrl, + fit: BoxFit.cover, + width: 48, + height: 49, + ), + margin: EdgeInsets.zero, + clipBehavior: Clip.antiAlias, + decoration: cardRadius(2000), + ), + Container( + child: Icon( + Icons.search, + size: 18, + color: Colors.white, + ), + padding: EdgeInsets.all(6), + decoration: containerRadius(Colors.black.withOpacity(0.3), 200), + ) + ], + ), + onTap: () { + showZoomImageDialog(context, prescriptionReport.imageSRCUrl); + }, + ), + SizedBox(width: 12), + Expanded( + child: Text( + (prescriptionReport.itemDescription.isNotEmpty ? prescriptionReport.itemDescription : prescriptionReport.itemDescriptionN ?? '').toLowerCase().capitalizeFirstofEach, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64), + ), + ) + ], + ), + SizedBox(height: 12), + Table(border: TableBorder(horizontalInside: BorderSide(width: 1, color: Colors.black, style: BorderStyle.solid)), children: [ + TableRow( + children: [ + Utils.tableColumnTitle(TranslationBase.of(context).route, showDivider: false), + Utils.tableColumnTitle(TranslationBase.of(context).frequency, showDivider: false), + Utils.tableColumnTitle(TranslationBase.of(context).dailyDoses, showDivider: false), + Utils.tableColumnTitle(TranslationBase.of(context).duration, showDivider: false) + ], + ), + TableRow( + children: [ + Utils.tableColumnValue(prescriptionReport?.routeN ?? '', isLast: true, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(prescriptionReport?.frequencyN ?? '', isLast: true, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(prescriptionReport?.doseDailyQuantity.toString() ?? '', isLast: true, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(prescriptionReport?.days.toString() ?? '', isLast: true, mProjectViewModel: projectViewModel), + ], + ), + ]), + Text( + TranslationBase.of(context).remarks, + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.48), + ), + Text( + prescriptionReport.remarks, + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), + ), ], ), - ], - ), + ), + ], ), - Container( - margin: EdgeInsets.only(top: 10, left: 10, right: 10), - width: double.infinity, - color: Colors.white, - padding: EdgeInsets.all(5), - child: Center( - child: Column( - children: [ - Texts(TranslationBase.of(context).notes), - SizedBox( - height: 5, - ), - Divider( - height: 0.5, - color: Colors.grey[300], - ), - SizedBox( - height: 5, - ), - Texts(prescriptionReport.remarks ?? ''), - ], + ), + Container( + color: Colors.white, + padding: EdgeInsets.only(top: 16, bottom: 16, right: 21, left: 21), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Expanded( + child: DefaultButton( + TranslationBase.of(context).availability, + () { + Navigator.push( + context, + FadePage( + page: PharmacyForPrescriptionsPage( + itemID: prescriptionReport.itemID, + prescriptionReport: PrescriptionReport.fromJson(prescriptionReport.toJson()), + ), + ), + ); + }, + iconData: Icons.location_on, + color: Color(0xff359846), + ), ), - ), - ) - ], - ), - ), - ); - } - - Widget _addReminderButton(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); + SizedBox(width: 10), + Expanded( + child: DefaultButton( + TranslationBase.of(context).addReminder, + () { + DateTime startDate = DateTime.now(); + DateTime endDate = DateTime(startDate.year, startDate.month, startDate.day + prescriptionReport.days); - return GestureDetector( - onTap: () { - DateTime startDate = DateTime.now(); - DateTime endDate = DateTime(startDate.year, startDate.month, startDate.day + prescriptionReport.days); - - print(prescriptionReport); - showGeneralDialog( - barrierColor: Colors.black.withOpacity(0.5), - transitionBuilder: (context, a1, a2, widget) { - final curvedValue = Curves.easeInOutBack.transform(a1.value) - 1.0; - return Transform( - transform: Matrix4.translationValues(0.0, curvedValue * 200, 0.0), - child: Opacity( - opacity: a1.value, - child: ReminderDialog( - eventId: prescriptionReport.itemID.toString(), - title: "Prescription Reminder", - description: - "${prescriptionReport.itemDescriptionN} ${prescriptionReport.frequencyN} ${prescriptionReport.routeN} ", - startDate: "/Date(${startDate.millisecondsSinceEpoch}+0300)/", - endDate: "/Date(${endDate.millisecondsSinceEpoch}+0300)/", - location: prescriptionReport.remarks, + showReminderDialog( + context, + endDate, + "", + prescriptionReport.itemID.toString(), + "", + "", + title: "${prescriptionReport.itemDescriptionN} Prescription Reminder", + description: "${prescriptionReport.itemDescriptionN} ${prescriptionReport.frequencyN} ${prescriptionReport.routeN} ", + onSuccess: () { + AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess); + }, + onMultiDateSuccess: (int selectedIndex) { + setCalender(context, prescriptionReport.itemID.toString(), selectedIndex); + }, + ); + return; + }, + iconData: Icons.notifications_active, + color: Color(0xffD02127), + fontSize: 13.0, + //textColor: Color(0xff2B353E), ), ), - ); - }, - transitionDuration: Duration(milliseconds: 500), - barrierDismissible: true, - barrierLabel: '', - context: context, - pageBuilder: (context, animation1, animation2) {}); - }, - child: Column( - mainAxisSize: MainAxisSize.max, - children: [ - Container( - // height: 100.0, - margin: EdgeInsets.all(7.0), - padding: EdgeInsets.only(bottom: 4.0), - decoration: BoxDecoration( - boxShadow: [BoxShadow(color: Colors.grey[400], blurRadius: 2.0, spreadRadius: 0.0)], - borderRadius: BorderRadius.circular(10), - color: Colors.white), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ - Container( - margin: EdgeInsets.fromLTRB(5.0, 5.0, 5.0, 0.0), - child: Text("add", - overflow: TextOverflow.clip, - style: TextStyle(color: new Color(0xffB8382C), letterSpacing: 1.0, fontSize: 18.0)), - ), - Container( - margin: EdgeInsets.fromLTRB(5.0, 0.0, 5.0, 0.0), - child: Text("reminder", - overflow: TextOverflow.clip, - style: TextStyle(color: Colors.black, letterSpacing: 1.0, fontSize: 15.0)), - ), - Container( - alignment: projectViewModel.isArabic ? Alignment.bottomLeft : Alignment.bottomRight, - margin: projectViewModel.isArabic - ? EdgeInsets.fromLTRB(10.0, 7.0, 0.0, 8.0) - : EdgeInsets.fromLTRB(0.0, 7.0, 10.0, 8.0), - child: Image.asset("assets/images/new-design/reminder_icon.png", width: 45.0, height: 45.0), - ), ], ), ), @@ -281,4 +218,57 @@ class PrescriptionDetailsPageINP extends StatelessWidget { ), ); } + + setCalender(BuildContext context, String eventId, int reminderIndex) async { + CalendarUtils calendarUtils = await CalendarUtils.getInstance(); + int frequencyNumber = int.parse(prescriptionReport?.frequency); + + DateTime actualDate = DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day, 8, 0); //Time will start at 8:00 AM from starting date + if (frequencyNumber == null) frequencyNumber = 1; //Some time frequency number is null so by default will be 2 + + int remainingDays = prescriptionReport.days - (Jiffy(DateTime.now()).diff(DateUtil.convertStringToDate(prescriptionReport.orderDate), Units.DAY)); + + GifLoaderDialogUtils.showMyDialog(context); + + for (int i = 0; i < remainingDays; i++) { + //event for number of days. + for (int j = 0; j < frequencyNumber ?? 1; j++) { + // event for number of times per day. + if (j != 0) { + actualDate.add(new Duration(hours: 8)); // 8 hours addition for daily dose. + } + //Time subtraction from actual reminder time. like before 30, or 1 hour. + if (reminderIndex == 0) { + // Before 30 mints + actualDate = Jiffy(actualDate).subtract(minutes: 30).dateTime; + // dateTime.add(new Duration(minutes: -30)); + } else if (reminderIndex == 1) { + // Before 1 hour + // dateTime.add(new Duration(minutes: -60)); + actualDate = Jiffy(actualDate).subtract(hours: 1).dateTime; + } else if (reminderIndex == 2) { + // Before 1 hour and 30 mints + // dateTime.add(new Duration(minutes: -90)); + actualDate = Jiffy(actualDate).subtract(hours: 1, minutes: 30).dateTime; + } else if (reminderIndex == 3) { + // Before 2 hours + // dateTime.add(new Duration(minutes: -120)); + actualDate = Jiffy(actualDate).subtract(hours: 2).dateTime; + } + calendarUtils + .createOrUpdateEvent( + title: "${prescriptionReport.itemDescriptionN} Prescription Reminder", + description: "${prescriptionReport.itemDescriptionN} ${prescriptionReport.frequencyN} ${prescriptionReport.routeN} ", + scheduleDateTime: actualDate, + eventId: eventId + (i.toString() + j.toString()), //event id with varitions + ) + .then((value) {}); + actualDate = DateTime(actualDate.year, actualDate.month, actualDate.day, 8, 0); + } + actualDate = Jiffy(actualDate).add(days: 1).dateTime; + print(actualDate); + } + AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess); + GifLoaderDialogUtils.hideDialog(context); + } } diff --git a/lib/pages/medical/prescriptions/prescription_details_page.dart b/lib/pages/medical/prescriptions/prescription_details_page.dart index 3a5b124b..36f77a33 100644 --- a/lib/pages/medical/prescriptions/prescription_details_page.dart +++ b/lib/pages/medical/prescriptions/prescription_details_page.dart @@ -98,21 +98,6 @@ class _PrescriptionDetailsPageState extends State { children: [ Row( children: [ - // Container( - // decoration: BoxDecoration( - // border: Border.all(width: 1.0, color: Color(0xffEBEBEB)), - // borderRadius: BorderRadius.all(Radius.circular(30.0)), - // ), - // child: ClipRRect( - // borderRadius: BorderRadius.all(Radius.circular(30)), - // child: Image.network( - // prescriptionReport.imageSRCUrl, - // fit: BoxFit.cover, - // width: 48, - // height: 48, - // ), - // ), - // ), InkWell( child: Stack( alignment: Alignment.center, @@ -257,8 +242,8 @@ class _PrescriptionDetailsPageState extends State { checkIfHasReminder() async { CalendarUtils calendarUtils = await CalendarUtils.getInstance(); - DateTime startEventsDate = Jiffy(DateTime.now()).subtract(days: 30); - DateTime endEventsDate = Jiffy(DateTime.now()).add(days: 120); + DateTime startEventsDate = Jiffy(DateTime.now()).subtract(days: 30).dateTime; + DateTime endEventsDate = Jiffy(DateTime.now()).add(days: 120).dateTime; RetrieveEventsParams params = new RetrieveEventsParams(startDate: startEventsDate, endDate: endEventsDate); @@ -276,8 +261,8 @@ class _PrescriptionDetailsPageState extends State { cancelReminders() async { CalendarUtils calendarUtils = await CalendarUtils.getInstance(); - DateTime startEventsDate = Jiffy(DateTime.now()).subtract(days: 30); - DateTime endEventsDate = Jiffy(DateTime.now()).add(days: 120); + DateTime startEventsDate = Jiffy(DateTime.now()).subtract(days: 30).dateTime; + DateTime endEventsDate = Jiffy(DateTime.now()).add(days: 120).dateTime; RetrieveEventsParams params = new RetrieveEventsParams(startDate: startEventsDate, endDate: endEventsDate); @@ -313,20 +298,20 @@ class _PrescriptionDetailsPageState extends State { //Time subtraction from actual reminder time. like before 30, or 1 hour. if (reminderIndex == 0) { // Before 30 mints - actualDate = Jiffy(actualDate).subtract(minutes: 30); + actualDate = Jiffy(actualDate).subtract(minutes: 30).dateTime; // dateTime.add(new Duration(minutes: -30)); } else if (reminderIndex == 1) { // Before 1 hour // dateTime.add(new Duration(minutes: -60)); - actualDate = Jiffy(actualDate).subtract(hours: 1); + actualDate = Jiffy(actualDate).subtract(hours: 1).dateTime; } else if (reminderIndex == 2) { // Before 1 hour and 30 mints // dateTime.add(new Duration(minutes: -90)); - actualDate = Jiffy(actualDate).subtract(hours: 1, minutes: 30); + actualDate = Jiffy(actualDate).subtract(hours: 1, minutes: 30).dateTime; } else if (reminderIndex == 3) { // Before 2 hours // dateTime.add(new Duration(minutes: -120)); - actualDate = Jiffy(actualDate).subtract(hours: 2); + actualDate = Jiffy(actualDate).subtract(hours: 2).dateTime; } calendarUtils .createOrUpdateEvent( @@ -338,7 +323,7 @@ class _PrescriptionDetailsPageState extends State { .then((value) {}); actualDate = DateTime(actualDate.year, actualDate.month, actualDate.day, 8, 0); } - actualDate = Jiffy(actualDate).add(days: 1); + actualDate = Jiffy(actualDate).add(days: 1).dateTime; print(actualDate); } AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess); diff --git a/lib/pages/medical/prescriptions/prescription_items_page.dart b/lib/pages/medical/prescriptions/prescription_items_page.dart index a9be08d2..3e830747 100644 --- a/lib/pages/medical/prescriptions/prescription_items_page.dart +++ b/lib/pages/medical/prescriptions/prescription_items_page.dart @@ -79,6 +79,7 @@ class PrescriptionItemsPage extends StatelessWidget { FadePage( page: PrescriptionDetailsPageINP( prescriptionReport: model.prescriptionReportListINP[index], + prescriptions: prescriptions, ), ), ); @@ -410,7 +411,7 @@ class PrescriptionItemsPage extends StatelessWidget { void showConfirmMessage(BuildContext context, PrescriptionsViewModel model) { showDialog( context: context, - child: ConfirmSendEmailDialog( + builder: (cxt) => ConfirmSendEmailDialog( email: model.user.emailAddress, onTapSendEmail: () { model.sendPrescriptionEmail( diff --git a/lib/pages/medical/radiology/radiology_details_page.dart b/lib/pages/medical/radiology/radiology_details_page.dart index f2a9490e..8a13d860 100644 --- a/lib/pages/medical/radiology/radiology_details_page.dart +++ b/lib/pages/medical/radiology/radiology_details_page.dart @@ -110,7 +110,7 @@ class RadiologyDetailsPage extends StatelessWidget { void showConfirmMessage({FinalRadiology finalRadiology, RadiologyViewModel model}) { showDialog( context: AppGlobal.context, - child: ConfirmSendEmailDialog( + builder: (cxt) => ConfirmSendEmailDialog( email: model.user.emailAddress, onTapSendEmail: () { model.sendRadReportEmail(mes: TranslationBase.of(AppGlobal.context).sendSuc, finalRadiology: finalRadiology); diff --git a/lib/pages/medical/reports/report_list_widget.dart b/lib/pages/medical/reports/report_list_widget.dart index 8d72216a..cc76214b 100644 --- a/lib/pages/medical/reports/report_list_widget.dart +++ b/lib/pages/medical/reports/report_list_widget.dart @@ -121,7 +121,7 @@ class ReportListWidget extends StatelessWidget { void showConfirmMessage(Reports report) { showDialog( context: AppGlobal.context, - child: ConfirmSendEmailDialog( + builder: (cxt) => ConfirmSendEmailDialog( email: emailAddress, onTapSendEmail: () { sendReportEmail(report); diff --git a/lib/pages/medical/reports/reports_page.dart b/lib/pages/medical/reports/reports_page.dart index 85d35d84..bdd638e5 100644 --- a/lib/pages/medical/reports/reports_page.dart +++ b/lib/pages/medical/reports/reports_page.dart @@ -20,7 +20,7 @@ class MedicalReports extends StatelessWidget { void confirmBox(AppointmentHistory model, ReportsViewModel reportsViewModel) { showDialog( context: context, - child: ConfirmWithMessageDialog( + builder: (cxt) => ConfirmWithMessageDialog( message: TranslationBase.of(context).confirmMsgReport, onTap: () => reportsViewModel.insertRequestForMedicalReport(model, TranslationBase.of(context).successSendReport), ), diff --git a/lib/pages/medical/vital_sign/LineChartCurved.dart b/lib/pages/medical/vital_sign/LineChartCurved.dart index 12cfa026..305d158e 100644 --- a/lib/pages/medical/vital_sign/LineChartCurved.dart +++ b/lib/pages/medical/vital_sign/LineChartCurved.dart @@ -101,14 +101,14 @@ class LineChartCurved extends StatelessWidget { touchTooltipData: LineTouchTooltipData( tooltipBgColor: Colors.white, ), - touchCallback: (LineTouchResponse touchResponse) {}, + touchCallback: (touchEvent, LineTouchResponse touchResponse) {}, handleBuiltInTouches: true, ), gridData: FlGridData(show: true, drawVerticalLine: true, drawHorizontalLine: true, horizontalInterval: 14, verticalInterval: 14), titlesData: FlTitlesData( bottomTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( + getTextStyles: (cxt, value) => const TextStyle( color: Colors.black, fontSize: 10, ), @@ -132,7 +132,7 @@ class LineChartCurved extends StatelessWidget { ), leftTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( + getTextStyles: (cxt, value) => const TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 10, diff --git a/lib/pages/medical/vital_sign/LineChartCurvedBloodPressure.dart b/lib/pages/medical/vital_sign/LineChartCurvedBloodPressure.dart index b4afebad..967c98cc 100644 --- a/lib/pages/medical/vital_sign/LineChartCurvedBloodPressure.dart +++ b/lib/pages/medical/vital_sign/LineChartCurvedBloodPressure.dart @@ -142,14 +142,14 @@ class LineChartCurvedBloodPressure extends StatelessWidget { touchTooltipData: LineTouchTooltipData( tooltipBgColor: Colors.white, ), - touchCallback: (LineTouchResponse touchResponse) {}, + touchCallback: (touchEvent, LineTouchResponse touchResponse) {}, handleBuiltInTouches: true, ), gridData: FlGridData(show: true, drawVerticalLine: true, drawHorizontalLine: true, horizontalInterval: 14, verticalInterval: 14), titlesData: FlTitlesData( bottomTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( + getTextStyles: (cxt, value) => const TextStyle( color: Colors.black, fontSize: 10, ), @@ -173,7 +173,7 @@ class LineChartCurvedBloodPressure extends StatelessWidget { ), leftTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( + getTextStyles: (cxt, value) => const TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 10, diff --git a/lib/pages/packages_offers/OfferAndPackagesCartPage.dart b/lib/pages/packages_offers/OfferAndPackagesCartPage.dart index cd640f6f..ee0e3880 100644 --- a/lib/pages/packages_offers/OfferAndPackagesCartPage.dart +++ b/lib/pages/packages_offers/OfferAndPackagesCartPage.dart @@ -242,7 +242,7 @@ class _PackagesCartPageState extends State with AfterLayoutMix ]; showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: _selectedHospitalIndex, isScrollable: true, diff --git a/lib/pages/packages_offers/OfferAndPackagesPage.dart b/lib/pages/packages_offers/OfferAndPackagesPage.dart index 2573204e..91f59c74 100644 --- a/lib/pages/packages_offers/OfferAndPackagesPage.dart +++ b/lib/pages/packages_offers/OfferAndPackagesPage.dart @@ -195,7 +195,7 @@ class _PackagesHomePageState extends State { ]; showDialog( context: context, - child: RadioSelectionDialog( + builder: (cxt) => RadioSelectionDialog( listData: list, selectedIndex: _selectedClinic, isScrollable: true, diff --git a/lib/pages/pharmacy/order/TrackDriver.dart b/lib/pages/pharmacy/order/TrackDriver.dart index 40114c03..21b2572f 100644 --- a/lib/pages/pharmacy/order/TrackDriver.dart +++ b/lib/pages/pharmacy/order/TrackDriver.dart @@ -1,341 +1,341 @@ -import 'dart:async'; -import 'dart:typed_data'; -import 'dart:ui' as ui; - -import 'package:async/async.dart'; -import 'package:diplomaticquarterapp/config/config.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; -import 'package:diplomaticquarterapp/core/service/parmacyModule/order-preview-service.dart'; -import 'package:diplomaticquarterapp/locator.dart'; -import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_animarker/lat_lng_interpolation.dart'; -import 'package:flutter_animarker/models/lat_lng_delta.dart'; -import 'package:flutter_animarker/models/lat_lng_info.dart'; -import 'package:flutter_polyline_points/flutter_polyline_points.dart'; -import 'package:google_maps_flutter/google_maps_flutter.dart'; -import 'package:location/location.dart'; - -class TrackDriver extends StatefulWidget { - final OrderDetailModel order; - TrackDriver({this.order}); - - @override - State createState() => _TrackDriverState(); -} - -class _TrackDriverState extends State { - OrderPreviewService _orderServices = locator(); - OrderDetailModel _order; - - Completer _controller = Completer(); - - - double CAMERA_ZOOM = 14; - double CAMERA_TILT = 0; - double CAMERA_BEARING = 30; - LatLng SOURCE_LOCATION = null; - LatLng DEST_LOCATION = null; - - // for my drawn routes on the map - Set _polylines = Set(); - List polylineCoordinates = []; - PolylinePoints polylinePoints; - - Set _markers = Set(); - - BitmapDescriptor sourceIcon; // for my custom marker pins - BitmapDescriptor destinationIcon; // for my custom marker pins - Location location;// wrapper around the location API - - - int locationUpdateFreq = 2; - LatLngInterpolationStream _latLngStream; - StreamGroup subscriptions; - - @override - void initState() { - super.initState(); - - _order = widget.order; - DEST_LOCATION = _order.shippingAddress.getLocation(); - location = new Location(); - polylinePoints = PolylinePoints(); - setSourceAndDestinationIcons(); - - initMarkerUpdateStream(); - startUpdatingDriverLocation(); - - } - - @override - void dispose() { - super.dispose(); - subscriptions.close(); - _latLngStream.cancel(); - stopUpdatingDriverLocation(); - } - - initMarkerUpdateStream(){ - _latLngStream = LatLngInterpolationStream(movementDuration: Duration(seconds: locationUpdateFreq+1)); - subscriptions = StreamGroup(); - - subscriptions.add(_latLngStream.getAnimatedPosition('sourcePin')); - subscriptions.stream.listen((LatLngDelta delta) { - //Update the marker with animation - setState(() { - //Get the marker Id for this animation - var markerId = MarkerId(delta.markerId); - Marker sourceMarker = Marker( - markerId: markerId, - // rotation: delta.rotation, - icon: sourceIcon, - position: LatLng( - delta.from.latitude, - delta.from.longitude, - ), - onTap: onSourceMarkerTap - ); - - _markers.removeWhere((m) => m.markerId.value == 'sourcePin'); - _markers.add(sourceMarker); - }); - }); - } - - @override - Widget build(BuildContext context) { - - return AppScaffold( - appBarTitle: TranslationBase.of(context).deliveryDriverTrack, - isShowAppBar: true, - isPharmacy: true, - showPharmacyCart: false, - showHomeAppBarIcon: false, - body: GoogleMap( - myLocationEnabled: true, - compassEnabled: true, - markers: _markers, - polylines: _polylines, - mapType: MapType.normal, - initialCameraPosition: CameraPosition(target: DEST_LOCATION, zoom: 4), - onMapCreated: (GoogleMapController controller) { - _controller.complete(controller); - // showPinsOnMap(); - }, - ), - // floatingActionButton: FloatingActionButton.extended( - // onPressed: _goToDriver, - // label: Text('To the lake!'), - // icon: Icon(Icons.directions_boat), - // ), - ); - } - - - void setSourceAndDestinationIcons() async { - final Uint8List srcMarkerBytes = await getBytesFromAsset('assets/images/map_markers/source_map_marker.png', getMarkerIconSize()); - final Uint8List destMarkerBytes = await getBytesFromAsset('assets/images/map_markers/destination_map_marker.png', getMarkerIconSize()); - sourceIcon = await BitmapDescriptor.fromBytes(srcMarkerBytes); - destinationIcon = await BitmapDescriptor.fromBytes(destMarkerBytes); - } - - CameraPosition _orderDeliveryLocationCamera(){ - if(DEST_LOCATION != null){ - final CameraPosition orderDeliveryLocCamera = CameraPosition( - bearing: CAMERA_BEARING, - target: DEST_LOCATION, - tilt: CAMERA_TILT, - zoom: CAMERA_ZOOM); - return orderDeliveryLocCamera; - } - return null; - } - - CameraPosition _driverLocationCamera(){ - if(DEST_LOCATION != null) { - final CameraPosition driverLocCamera = CameraPosition( - bearing: CAMERA_BEARING, - target: SOURCE_LOCATION, - tilt: CAMERA_TILT, - zoom: CAMERA_ZOOM); - return driverLocCamera; - } - return null; - } - - - Future _goToOrderDeliveryLocation() async { - final GoogleMapController controller = await _controller.future; - final CameraPosition orderDeliveryLocCamera = _orderDeliveryLocationCamera(); - controller.animateCamera(CameraUpdate.newCameraPosition(orderDeliveryLocCamera)); - } - - Future _goToDriver() async { - final GoogleMapController controller = await _controller.future; - final CameraPosition driverLocCamera = _driverLocationCamera(); - controller.animateCamera(CameraUpdate.newCameraPosition(driverLocCamera)); - } - - - void showPinsOnMap() { - // source pin - if(SOURCE_LOCATION != null){ - setState(() { - var pinPosition = SOURCE_LOCATION; - _markers.removeWhere((m) => m.markerId.value == 'sourcePin'); - _markers.add(Marker( - markerId: MarkerId('sourcePin'), - position: pinPosition, - icon: sourceIcon, - infoWindow: InfoWindow(title: TranslationBase.of(context).driver), - onTap: onSourceMarkerTap - )); - }); - } - - // destination pin - if(DEST_LOCATION != null){ - setState(() { - var destPosition = DEST_LOCATION; - _markers.removeWhere((m) => m.markerId.value == 'destPin'); - _markers.add(Marker( - markerId: MarkerId('destPin'), - position: destPosition, - icon: destinationIcon, - infoWindow: InfoWindow(title: TranslationBase.of(context).deliveryLocation), - onTap: onDestinationMarkerTap - )); - }); - } - // set the route lines on the map from source to destination - // for more info follow this tutorial - // drawRoute(); - } - - void updatePinOnMap() async { - _latLngStream.addLatLng(LatLngInfo(SOURCE_LOCATION.latitude, SOURCE_LOCATION.longitude, "sourcePin")); - drawRoute(); - } - - void drawRoute() async { - return; // Ignore draw Route - - List result = await polylinePoints.getRouteBetweenCoordinates( - GOOGLE_API_KEY, - SOURCE_LOCATION.latitude, - SOURCE_LOCATION.longitude, - DEST_LOCATION.latitude, - DEST_LOCATION.longitude); - if(result.isNotEmpty){ - result.forEach((PointLatLng point){ - polylineCoordinates.add( - LatLng(point.latitude,point.longitude) - ); - }); - setState(() { - _polylines.add(Polyline( - width: 5, // set the width of the polylines - polylineId: PolylineId('poly'), - color: Color.fromARGB(255, 40, 122, 198), - points: polylineCoordinates - )); - }); - } - } - - bool isLocationUpdating = false; - startUpdatingDriverLocation({int frequencyInSeconds = 2}) async{ - isLocationUpdating = true; - int driverId = int.tryParse(_order.driverID); - - Future.doWhile(() async{ - if(isLocationUpdating){ - - await Future.delayed(Duration(seconds: frequencyInSeconds)); - - showLoading(); - LatLng driverLocation = (await _orderServices.getDriverLocation(driverId)); - hideLoading(); - - if(driverLocation != null){ - if(SOURCE_LOCATION == null || DEST_LOCATION == null){ - SOURCE_LOCATION = driverLocation; - DEST_LOCATION = _order.shippingAddress.getLocation(); - showPinsOnMap(); - } - SOURCE_LOCATION = driverLocation; - updatePinOnMap(); - updateMapCamera(); - }else{ - GifLoaderDialogUtils.hideDialog(context); - } - } - return isLocationUpdating; - - }); - } - - showLoading(){ - if(SOURCE_LOCATION == null){ - GifLoaderDialogUtils.showMyDialog(context); - } - } - - hideLoading(){ - if(SOURCE_LOCATION == null){ - GifLoaderDialogUtils.hideDialog(context); - } - } - - stopUpdatingDriverLocation(){ - isLocationUpdating = false; - } - - Future getBytesFromAsset(String path, int width) async { - ByteData data = await rootBundle.load(path); - ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(), targetWidth: width); - ui.FrameInfo fi = await codec.getNextFrame(); - return (await fi.image.toByteData(format: ui.ImageByteFormat.png)).buffer.asUint8List(); - } - - int getMarkerIconSize(){ - return 140; - } - - updateMapCamera() async{ - if(SOURCE_LOCATION != null && DEST_LOCATION != null){ - - // 'package:google_maps_flutter_platform_interface/src/types/location.dart': Failed assertion: line 72 pos 16: 'southwest.latitude <= northeast.latitude': is not true. - LatLngBounds bound; - if(SOURCE_LOCATION.latitude <= DEST_LOCATION.latitude){ - bound = LatLngBounds(southwest: SOURCE_LOCATION, northeast: DEST_LOCATION); - }else{ - bound = LatLngBounds(southwest: DEST_LOCATION, northeast: SOURCE_LOCATION); - } - - if(bound == null) - return; - - CameraUpdate camera = CameraUpdate.newLatLngBounds(bound, 50); - final GoogleMapController controller = await _controller.future; - controller.animateCamera(camera); - } - } - - bool showSrcMarkerTitle = false; - onSourceMarkerTap() async{ - // showSrcMarkerTitle = !showSrcMarkerTitle; - } - - bool showDestMarkerTitle = false; - onDestinationMarkerTap() async{ - // showDestMarkerTitle = !showDestMarkerTitle; - // Marker m = _markers.firstWhere((m) => m.markerId.value == 'destPin'); - // if(showDestMarkerTitle){ - // } - } -} +// import 'dart:async'; +// import 'dart:typed_data'; +// import 'dart:ui' as ui; +// +// import 'package:async/async.dart'; +// import 'package:diplomaticquarterapp/config/config.dart'; +// import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; +// import 'package:diplomaticquarterapp/core/service/parmacyModule/order-preview-service.dart'; +// import 'package:diplomaticquarterapp/locator.dart'; +// import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +// import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +// import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter/services.dart'; +// import 'package:flutter_animarker/lat_lng_interpolation.dart'; +// import 'package:flutter_animarker/models/lat_lng_delta.dart'; +// import 'package:flutter_animarker/models/lat_lng_info.dart'; +// import 'package:flutter_polyline_points/flutter_polyline_points.dart'; +// import 'package:google_maps_flutter/google_maps_flutter.dart'; +// import 'package:location/location.dart'; +// +// class TrackDriver extends StatefulWidget { +// final OrderDetailModel order; +// TrackDriver({this.order}); +// +// @override +// State createState() => _TrackDriverState(); +// } +// +// class _TrackDriverState extends State { +// OrderPreviewService _orderServices = locator(); +// OrderDetailModel _order; +// +// Completer _controller = Completer(); +// +// +// double CAMERA_ZOOM = 14; +// double CAMERA_TILT = 0; +// double CAMERA_BEARING = 30; +// LatLng SOURCE_LOCATION = null; +// LatLng DEST_LOCATION = null; +// +// // for my drawn routes on the map +// Set _polylines = Set(); +// List polylineCoordinates = []; +// PolylinePoints polylinePoints; +// +// Set _markers = Set(); +// +// BitmapDescriptor sourceIcon; // for my custom marker pins +// BitmapDescriptor destinationIcon; // for my custom marker pins +// Location location;// wrapper around the location API +// +// +// int locationUpdateFreq = 2; +// LatLngInterpolationStream _latLngStream; +// StreamGroup subscriptions; +// +// @override +// void initState() { +// super.initState(); +// +// _order = widget.order; +// DEST_LOCATION = _order.shippingAddress.getLocation(); +// location = new Location(); +// polylinePoints = PolylinePoints(); +// setSourceAndDestinationIcons(); +// +// initMarkerUpdateStream(); +// startUpdatingDriverLocation(); +// +// } +// +// @override +// void dispose() { +// super.dispose(); +// subscriptions.close(); +// _latLngStream.cancel(); +// stopUpdatingDriverLocation(); +// } +// +// initMarkerUpdateStream(){ +// _latLngStream = LatLngInterpolationStream(movementDuration: Duration(seconds: locationUpdateFreq+1)); +// subscriptions = StreamGroup(); +// +// subscriptions.add(_latLngStream.getAnimatedPosition('sourcePin')); +// subscriptions.stream.listen((LatLngDelta delta) { +// //Update the marker with animation +// setState(() { +// //Get the marker Id for this animation +// var markerId = MarkerId(delta.markerId); +// Marker sourceMarker = Marker( +// markerId: markerId, +// // rotation: delta.rotation, +// icon: sourceIcon, +// position: LatLng( +// delta.from.latitude, +// delta.from.longitude, +// ), +// onTap: onSourceMarkerTap +// ); +// +// _markers.removeWhere((m) => m.markerId.value == 'sourcePin'); +// _markers.add(sourceMarker); +// }); +// }); +// } +// +// @override +// Widget build(BuildContext context) { +// +// return AppScaffold( +// appBarTitle: TranslationBase.of(context).deliveryDriverTrack, +// isShowAppBar: true, +// isPharmacy: true, +// showPharmacyCart: false, +// showHomeAppBarIcon: false, +// body: GoogleMap( +// myLocationEnabled: true, +// compassEnabled: true, +// markers: _markers, +// polylines: _polylines, +// mapType: MapType.normal, +// initialCameraPosition: CameraPosition(target: DEST_LOCATION, zoom: 4), +// onMapCreated: (GoogleMapController controller) { +// _controller.complete(controller); +// // showPinsOnMap(); +// }, +// ), +// // floatingActionButton: FloatingActionButton.extended( +// // onPressed: _goToDriver, +// // label: Text('To the lake!'), +// // icon: Icon(Icons.directions_boat), +// // ), +// ); +// } +// +// +// void setSourceAndDestinationIcons() async { +// final Uint8List srcMarkerBytes = await getBytesFromAsset('assets/images/map_markers/source_map_marker.png', getMarkerIconSize()); +// final Uint8List destMarkerBytes = await getBytesFromAsset('assets/images/map_markers/destination_map_marker.png', getMarkerIconSize()); +// sourceIcon = await BitmapDescriptor.fromBytes(srcMarkerBytes); +// destinationIcon = await BitmapDescriptor.fromBytes(destMarkerBytes); +// } +// +// CameraPosition _orderDeliveryLocationCamera(){ +// if(DEST_LOCATION != null){ +// final CameraPosition orderDeliveryLocCamera = CameraPosition( +// bearing: CAMERA_BEARING, +// target: DEST_LOCATION, +// tilt: CAMERA_TILT, +// zoom: CAMERA_ZOOM); +// return orderDeliveryLocCamera; +// } +// return null; +// } +// +// CameraPosition _driverLocationCamera(){ +// if(DEST_LOCATION != null) { +// final CameraPosition driverLocCamera = CameraPosition( +// bearing: CAMERA_BEARING, +// target: SOURCE_LOCATION, +// tilt: CAMERA_TILT, +// zoom: CAMERA_ZOOM); +// return driverLocCamera; +// } +// return null; +// } +// +// +// Future _goToOrderDeliveryLocation() async { +// final GoogleMapController controller = await _controller.future; +// final CameraPosition orderDeliveryLocCamera = _orderDeliveryLocationCamera(); +// controller.animateCamera(CameraUpdate.newCameraPosition(orderDeliveryLocCamera)); +// } +// +// Future _goToDriver() async { +// final GoogleMapController controller = await _controller.future; +// final CameraPosition driverLocCamera = _driverLocationCamera(); +// controller.animateCamera(CameraUpdate.newCameraPosition(driverLocCamera)); +// } +// +// +// void showPinsOnMap() { +// // source pin +// if(SOURCE_LOCATION != null){ +// setState(() { +// var pinPosition = SOURCE_LOCATION; +// _markers.removeWhere((m) => m.markerId.value == 'sourcePin'); +// _markers.add(Marker( +// markerId: MarkerId('sourcePin'), +// position: pinPosition, +// icon: sourceIcon, +// infoWindow: InfoWindow(title: TranslationBase.of(context).driver), +// onTap: onSourceMarkerTap +// )); +// }); +// } +// +// // destination pin +// if(DEST_LOCATION != null){ +// setState(() { +// var destPosition = DEST_LOCATION; +// _markers.removeWhere((m) => m.markerId.value == 'destPin'); +// _markers.add(Marker( +// markerId: MarkerId('destPin'), +// position: destPosition, +// icon: destinationIcon, +// infoWindow: InfoWindow(title: TranslationBase.of(context).deliveryLocation), +// onTap: onDestinationMarkerTap +// )); +// }); +// } +// // set the route lines on the map from source to destination +// // for more info follow this tutorial +// // drawRoute(); +// } +// +// void updatePinOnMap() async { +// _latLngStream.addLatLng(LatLngInfo(SOURCE_LOCATION.latitude, SOURCE_LOCATION.longitude, "sourcePin")); +// drawRoute(); +// } +// +// void drawRoute() async { +// return; // Ignore draw Route +// +// List result = await polylinePoints.getRouteBetweenCoordinates( +// GOOGLE_API_KEY, +// SOURCE_LOCATION.latitude, +// SOURCE_LOCATION.longitude, +// DEST_LOCATION.latitude, +// DEST_LOCATION.longitude); +// if(result.isNotEmpty){ +// result.forEach((PointLatLng point){ +// polylineCoordinates.add( +// LatLng(point.latitude,point.longitude) +// ); +// }); +// setState(() { +// _polylines.add(Polyline( +// width: 5, // set the width of the polylines +// polylineId: PolylineId('poly'), +// color: Color.fromARGB(255, 40, 122, 198), +// points: polylineCoordinates +// )); +// }); +// } +// } +// +// bool isLocationUpdating = false; +// startUpdatingDriverLocation({int frequencyInSeconds = 2}) async{ +// isLocationUpdating = true; +// int driverId = int.tryParse(_order.driverID); +// +// Future.doWhile(() async{ +// if(isLocationUpdating){ +// +// await Future.delayed(Duration(seconds: frequencyInSeconds)); +// +// showLoading(); +// LatLng driverLocation = (await _orderServices.getDriverLocation(driverId)); +// hideLoading(); +// +// if(driverLocation != null){ +// if(SOURCE_LOCATION == null || DEST_LOCATION == null){ +// SOURCE_LOCATION = driverLocation; +// DEST_LOCATION = _order.shippingAddress.getLocation(); +// showPinsOnMap(); +// } +// SOURCE_LOCATION = driverLocation; +// updatePinOnMap(); +// updateMapCamera(); +// }else{ +// GifLoaderDialogUtils.hideDialog(context); +// } +// } +// return isLocationUpdating; +// +// }); +// } +// +// showLoading(){ +// if(SOURCE_LOCATION == null){ +// GifLoaderDialogUtils.showMyDialog(context); +// } +// } +// +// hideLoading(){ +// if(SOURCE_LOCATION == null){ +// GifLoaderDialogUtils.hideDialog(context); +// } +// } +// +// stopUpdatingDriverLocation(){ +// isLocationUpdating = false; +// } +// +// Future getBytesFromAsset(String path, int width) async { +// ByteData data = await rootBundle.load(path); +// ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(), targetWidth: width); +// ui.FrameInfo fi = await codec.getNextFrame(); +// return (await fi.image.toByteData(format: ui.ImageByteFormat.png)).buffer.asUint8List(); +// } +// +// int getMarkerIconSize(){ +// return 140; +// } +// +// updateMapCamera() async{ +// if(SOURCE_LOCATION != null && DEST_LOCATION != null){ +// +// // 'package:google_maps_flutter_platform_interface/src/types/location.dart': Failed assertion: line 72 pos 16: 'southwest.latitude <= northeast.latitude': is not true. +// LatLngBounds bound; +// if(SOURCE_LOCATION.latitude <= DEST_LOCATION.latitude){ +// bound = LatLngBounds(southwest: SOURCE_LOCATION, northeast: DEST_LOCATION); +// }else{ +// bound = LatLngBounds(southwest: DEST_LOCATION, northeast: SOURCE_LOCATION); +// } +// +// if(bound == null) +// return; +// +// CameraUpdate camera = CameraUpdate.newLatLngBounds(bound, 50); +// final GoogleMapController controller = await _controller.future; +// controller.animateCamera(camera); +// } +// } +// +// bool showSrcMarkerTitle = false; +// onSourceMarkerTap() async{ +// // showSrcMarkerTitle = !showSrcMarkerTitle; +// } +// +// bool showDestMarkerTitle = false; +// onDestinationMarkerTap() async{ +// // showDestMarkerTitle = !showDestMarkerTitle; +// // Marker m = _markers.firstWhere((m) => m.markerId.value == 'destPin'); +// // if(showDestMarkerTitle){ +// // } +// } +// } diff --git a/lib/pages/pharmacy/profile/profile.dart b/lib/pages/pharmacy/profile/profile.dart index 72fa43dc..09522ba6 100644 --- a/lib/pages/pharmacy/profile/profile.dart +++ b/lib/pages/pharmacy/profile/profile.dart @@ -431,7 +431,7 @@ class _ProfilePageState extends State { ), InkWell( onTap: () { - Navigator.push(context, FadePage(page: PharmacyAddressesPage())); + Navigator.push(context, FadePage(page: PharmacyAddressesPage())); }, child: Row( children: [ diff --git a/lib/pages/vaccine/my_vaccines_screen.dart b/lib/pages/vaccine/my_vaccines_screen.dart index 1030c709..5fa74c4f 100644 --- a/lib/pages/vaccine/my_vaccines_screen.dart +++ b/lib/pages/vaccine/my_vaccines_screen.dart @@ -96,7 +96,7 @@ class _MyVaccinesState extends State { () { showDialog( context: context, - child: ConfirmSendEmailDialog( + builder: (cxt) => ConfirmSendEmailDialog( email: projectViewModel.user.emailAddress, onTapSendEmail: () { model.sendEmail(message: TranslationBase.of(context).emailSentSuccessfully); diff --git a/lib/pages/webRTC/call_page.dart b/lib/pages/webRTC/call_page.dart index 0c6caf54..c3dc6934 100644 --- a/lib/pages/webRTC/call_page.dart +++ b/lib/pages/webRTC/call_page.dart @@ -1,7 +1,6 @@ import 'dart:io'; import 'package:diplomaticquarterapp/models/LiveCare/IncomingCallData.dart'; -import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/pages/livecare/incoming_call.dart'; import 'package:diplomaticquarterapp/pages/webRTC/signaling.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -49,10 +48,9 @@ class _CallPageState extends State { super.dispose(); } - @override Widget build(BuildContext context) { - FirebaseMessaging().getToken().then((value){ + FirebaseMessaging.instance.getToken().then((value) { print('FCM_TOKEN: $value'); }); @@ -123,10 +121,9 @@ class _CallPageState extends State { ], ), ); - } - dummyCall() async{ + dummyCall() async { final json = { "callerID": "12345", "receiverID": "54321", @@ -146,7 +143,8 @@ class _CallPageState extends State { "appointmentdate": "Sun, 15th Dec, 2019", "appointmenttime": "09:00", "type": "video", - "session_id": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImN0eSI6InR3aWxpby1mcGE7dj0xIn0.eyJqdGkiOiJTS2I2NjYyOWMzN2ZhOTM3YjFjNDI2Zjg1MTgyNWFmN2M0LTE1OTg3NzQ1MDYiLCJpc3MiOiJTS2I2NjYyOWMzN2ZhOTM3YjFjNDI2Zjg1MTgyNWFmN2M0Iiwic3ViIjoiQUNhYWQ1YTNmOGM2NGZhNjczNTY3NTYxNTc0N2YyNmMyYiIsImV4cCI6MTU5ODc3ODEwNiwiZ3JhbnRzIjp7ImlkZW50aXR5IjoiSGFyb29uMSIsInZpZGVvIjp7InJvb20iOiJTbWFsbERhaWx5U3RhbmR1cCJ9fX0.7XUS5uMQQJfkrBZu9EjQ6STL6R7iXkso6BtO1HmrQKk", + "session_id": + "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImN0eSI6InR3aWxpby1mcGE7dj0xIn0.eyJqdGkiOiJTS2I2NjYyOWMzN2ZhOTM3YjFjNDI2Zjg1MTgyNWFmN2M0LTE1OTg3NzQ1MDYiLCJpc3MiOiJTS2I2NjYyOWMzN2ZhOTM3YjFjNDI2Zjg1MTgyNWFmN2M0Iiwic3ViIjoiQUNhYWQ1YTNmOGM2NGZhNjczNTY3NTYxNTc0N2YyNmMyYiIsImV4cCI6MTU5ODc3ODEwNiwiZ3JhbnRzIjp7ImlkZW50aXR5IjoiSGFyb29uMSIsInZpZGVvIjp7InJvb20iOiJTbWFsbERhaWx5U3RhbmR1cCJ9fX0.7XUS5uMQQJfkrBZu9EjQ6STL6R7iXkso6BtO1HmrQKk", "identity": "Haroon1", "name": "SmallDailyStandup", "videoUrl": "video", @@ -154,26 +152,19 @@ class _CallPageState extends State { "is_call": "true" }; - IncomingCallData incomingCallData = IncomingCallData.fromJson(json); + IncomingCallData incomingCallData = IncomingCallData.fromJson(json); final result = await Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: incomingCallData))); } - fcmConfigure(){ - FirebaseMessaging().configure( - onMessage: (message) async{ - print(message.toString()); + fcmConfigure() { + FirebaseMessaging.onMessage.listen((RemoteMessage message) async { + print(message.toString()); - IncomingCallData incomingCallData; - if(Platform.isAndroid) - incomingCallData = IncomingCallData.fromJson(message['data']); - else if(Platform.isIOS) - incomingCallData = IncomingCallData.fromJson(message); - if(incomingCallData != null) - final result = await Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: incomingCallData))); - - } - ); + IncomingCallData incomingCallData; + if (Platform.isAndroid) + incomingCallData = IncomingCallData.fromJson(message.data['data']); + else if (Platform.isIOS) incomingCallData = IncomingCallData.fromJson(message.data); + if (incomingCallData != null) final result = await Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: incomingCallData))); + }); } - - } diff --git a/lib/uitl/LocalNotification.dart b/lib/uitl/LocalNotification.dart index 5488d39b..3d31e84b 100644 --- a/lib/uitl/LocalNotification.dart +++ b/lib/uitl/LocalNotification.dart @@ -31,7 +31,7 @@ class LocalNotification { _initialize() { var initializationSettingsAndroid = new AndroidInitializationSettings('app_icon'); var initializationSettingsIOS = IOSInitializationSettings(onDidReceiveLocalNotification: null); - var initializationSettings = InitializationSettings(initializationSettingsAndroid, initializationSettingsIOS); + var initializationSettings = InitializationSettings(android: initializationSettingsAndroid, iOS: initializationSettingsIOS); flutterLocalNotificationsPlugin.initialize(initializationSettings, onSelectNotification: _onNotificationClick); } @@ -53,10 +53,10 @@ class LocalNotification { Future showNow({@required String title, @required String subtitle, String payload}) { Future.delayed(Duration(seconds: 1)).then((result) async { - var androidPlatformChannelSpecifics = - AndroidNotificationDetails('com.hmg.local_notification', 'HMG', 'HMG', importance: Importance.Max, priority: Priority.High, ticker: 'ticker', vibrationPattern: _vibrationPattern()); + var androidPlatformChannelSpecifics = AndroidNotificationDetails('com.hmg.local_notification', 'HMG', + channelDescription: 'HMG', importance: Importance.max, priority: Priority.high, ticker: 'ticker', vibrationPattern: _vibrationPattern()); var iOSPlatformChannelSpecifics = IOSNotificationDetails(); - var platformChannelSpecifics = NotificationDetails(androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); + var platformChannelSpecifics = NotificationDetails(android: androidPlatformChannelSpecifics, iOS: iOSPlatformChannelSpecifics); await flutterLocalNotificationsPlugin.show(_randomNumber(), title, subtitle, platformChannelSpecifics, payload: payload).catchError((err) { print(err); }); @@ -71,7 +71,8 @@ class LocalNotification { vibrationPattern[2] = 5000; vibrationPattern[3] = 2000; - var androidPlatformChannelSpecifics = AndroidNotificationDetails('active-prescriptions', 'ActivePrescriptions', 'ActivePrescriptionsDescription', + var androidPlatformChannelSpecifics = AndroidNotificationDetails('active-prescriptions', 'ActivePrescriptions', + channelDescription: 'ActivePrescriptionsDescription', // icon: 'secondary_icon', sound: RawResourceAndroidNotificationSound('slow_spring_board'), @@ -86,14 +87,14 @@ class LocalNotification { var iOSPlatformChannelSpecifics = IOSNotificationDetails(sound: 'slow_spring_board.aiff'); // /change it to be as ionic - var platformChannelSpecifics = NotificationDetails(androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); + var platformChannelSpecifics = NotificationDetails(android: androidPlatformChannelSpecifics, iOS: iOSPlatformChannelSpecifics); await flutterLocalNotificationsPlugin.schedule(0, title, description, scheduledNotificationDateTime, platformChannelSpecifics); } ///Repeat notification every day at approximately 10:00:00 am Future showDailyAtTime() async { var time = Time(10, 0, 0); - var androidPlatformChannelSpecifics = AndroidNotificationDetails('repeatDailyAtTime channel id', 'repeatDailyAtTime channel name', 'repeatDailyAtTime description'); + var androidPlatformChannelSpecifics = AndroidNotificationDetails('repeatDailyAtTime channel id', 'repeatDailyAtTime channel name', channelDescription: 'repeatDailyAtTime description'); var iOSPlatformChannelSpecifics = IOSNotificationDetails(); // var platformChannelSpecifics = NotificationDetails( // androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); @@ -108,7 +109,7 @@ class LocalNotification { ///Repeat notification weekly on Monday at approximately 10:00:00 am Future showWeeklyAtDayAndTime() async { var time = Time(10, 0, 0); - var androidPlatformChannelSpecifics = AndroidNotificationDetails('show weekly channel id', 'show weekly channel name', 'show weekly description'); + var androidPlatformChannelSpecifics = AndroidNotificationDetails('show weekly channel id', 'show weekly channel name', channelDescription: 'show weekly description'); var iOSPlatformChannelSpecifics = IOSNotificationDetails(); // var platformChannelSpecifics = NotificationDetails( // androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); diff --git a/lib/uitl/gif_loader_dialog_utils.dart b/lib/uitl/gif_loader_dialog_utils.dart index 785a6c6c..eae84e38 100644 --- a/lib/uitl/gif_loader_dialog_utils.dart +++ b/lib/uitl/gif_loader_dialog_utils.dart @@ -4,13 +4,13 @@ import '../widgets/Loader/gif_loader_container.dart'; class GifLoaderDialogUtils { static showMyDialog(BuildContext context) { - showDialog(context: context, child: GifLoaderContainer()); + showDialog(context: context, builder: (cxt) => GifLoaderContainer()); } static hideDialog(BuildContext context) { - try{ + try { Navigator.of(context).pop(); - }catch(error){ + } catch (error) { Future.delayed(Duration(milliseconds: 250)).then((value) => Navigator.of(context).pop()); } } diff --git a/lib/widgets/bottom_options/BottomSheet.dart b/lib/widgets/bottom_options/BottomSheet.dart index a9e9c4c1..0fc26907 100644 --- a/lib/widgets/bottom_options/BottomSheet.dart +++ b/lib/widgets/bottom_options/BottomSheet.dart @@ -23,7 +23,7 @@ class ImageOptions { icon: Icons.image, onTap: () async { File _image = - await ImagePicker.pickImage(source: ImageSource.gallery, imageQuality: 20); + File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 20)).path); String fileName = _image.path; final bytes = File(fileName).readAsBytesSync(); String base64Encode = base64.encode(bytes); @@ -37,7 +37,7 @@ class ImageOptions { icon: Icons.camera_alt, onTap: () async { File _image = - await ImagePicker.pickImage(source: ImageSource.camera, imageQuality: 20); + File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 20)).path); String fileName = _image.path; final bytes = File(fileName).readAsBytesSync(); String base64Encode = base64.encode(bytes); diff --git a/lib/widgets/charts/custom_line_chart.dart b/lib/widgets/charts/custom_line_chart.dart index cfd1e718..7176846d 100644 --- a/lib/widgets/charts/custom_line_chart.dart +++ b/lib/widgets/charts/custom_line_chart.dart @@ -1,5 +1,3 @@ -import 'dart:math' as math; - import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; @@ -13,6 +11,7 @@ class LineChartModel { class CustomLineChart extends StatefulWidget { final List list; final bool isArabic; + CustomLineChart(this.list, this.isArabic); @override @@ -81,7 +80,7 @@ class _CustomLineChartState extends State { SideTitles left = SideTitles( showTitles: true, interval: 1, - getTextStyles: (value) => const TextStyle(color: Color(0xff2E303A), fontWeight: FontWeight.w600, fontSize: 12, letterSpacing: 0), + getTextStyles: (cxt, value) => const TextStyle(color: Color(0xff2E303A), fontWeight: FontWeight.w600, fontSize: 12, letterSpacing: 0), getTitles: (value) { if (widget.list.isEmpty) { return (value).toInt().toString(); @@ -110,7 +109,7 @@ class _CustomLineChartState extends State { showTitles: true, reservedSize: 22, interval: 1, - getTextStyles: (value) => const TextStyle(color: Color(0xff2E303A), fontWeight: FontWeight.w600, fontSize: 12, letterSpacing: 0), + getTextStyles: (cxt, value) => const TextStyle(color: Color(0xff2E303A), fontWeight: FontWeight.w600, fontSize: 12, letterSpacing: 0), getTitles: (value) { String _title = list[value.toInt()].title; return (_title.length > 3 ? (widget.isArabic ? _title : _title.substring(0, 3)) : _title).toUpperCase(); diff --git a/lib/widgets/charts/show_chart.dart b/lib/widgets/charts/show_chart.dart index 301d45ff..0e89238d 100644 --- a/lib/widgets/charts/show_chart.dart +++ b/lib/widgets/charts/show_chart.dart @@ -102,21 +102,21 @@ class ShowChart extends StatelessWidget { touchTooltipData: LineTouchTooltipData( tooltipBgColor: Colors.white, ), - touchCallback: (LineTouchResponse touchResponse) {}, + touchCallback: (touchEvent, LineTouchResponse touchResponse) {}, handleBuiltInTouches: true, ), gridData: FlGridData(show: true, drawVerticalLine: true, drawHorizontalLine: true), titlesData: FlTitlesData( bottomTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( + getTextStyles: (cxt, value) => const TextStyle( color: Colors.black, fontSize: 10, ), rotateAngle: -65, margin: 22, getTitles: (value) { - if(isWeeklyOrMonthly) { + if (isWeeklyOrMonthly) { return '${timeSeries[value.toInt()].time.day}/ ${timeSeries[value.toInt()].time.month}'; } else { if (timeSeries.length < 15) { @@ -137,7 +137,7 @@ class ShowChart extends StatelessWidget { ), leftTitles: SideTitles( showTitles: true, - getTextStyles: (value) => const TextStyle( + getTextStyles: (cxt, value) => const TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 10, diff --git a/lib/widgets/data_display/medical/LabResult/LabResultWidget.dart b/lib/widgets/data_display/medical/LabResult/LabResultWidget.dart index f4081c21..5f0ac594 100644 --- a/lib/widgets/data_display/medical/LabResult/LabResultWidget.dart +++ b/lib/widgets/data_display/medical/LabResult/LabResultWidget.dart @@ -132,7 +132,7 @@ class LabResultWidget extends StatelessWidget { void showConfirmMessage(BuildContext context, String email, String isOutsideKSA) { showDialog( context: context, - child: ConfirmSendEmailDialog( + builder: (cxt) => ConfirmSendEmailDialog( email: email, onTapSendEmail: () { generateCovidCertificate(context, isOutsideKSA); diff --git a/lib/widgets/data_display/medical/LabResult/LineChartCurved.dart b/lib/widgets/data_display/medical/LabResult/LineChartCurved.dart index e83cc6ca..992e5659 100644 --- a/lib/widgets/data_display/medical/LabResult/LineChartCurved.dart +++ b/lib/widgets/data_display/medical/LabResult/LineChartCurved.dart @@ -76,14 +76,14 @@ class LineChartCurvedState extends State { touchTooltipData: LineTouchTooltipData( tooltipBgColor: Colors.white, ), - touchCallback: (LineTouchResponse touchResponse) {}, + touchCallback: (touchEvent, LineTouchResponse touchResponse) {}, handleBuiltInTouches: true, ), gridData: FlGridData(show: true, drawVerticalLine: false, drawHorizontalLine: true), titlesData: FlTitlesData( bottomTitles: SideTitles( showTitles: true, - getTextStyles: (value) => TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: 0, height: 18 / 12), + getTextStyles: (cxt, value) => TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: 0, height: 18 / 12), margin: 8, rotateAngle: -0, getTitles: (value) { @@ -107,7 +107,7 @@ class LineChartCurvedState extends State { ), leftTitles: SideTitles( showTitles: true, - getTextStyles: (value) => TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: 0, height: 18 / 12), + getTextStyles: (cxt, value) => TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: 0, height: 18 / 12), getTitles: (value) { return '${value}'; diff --git a/lib/widgets/dialogs/radio_selection_dialog.dart b/lib/widgets/dialogs/radio_selection_dialog.dart index 7175d6dc..ffce6c29 100644 --- a/lib/widgets/dialogs/radio_selection_dialog.dart +++ b/lib/widgets/dialogs/radio_selection_dialog.dart @@ -77,27 +77,38 @@ class RadioSelectionDialogState extends State { shrinkWrap: !widget.isScrollable, padding: EdgeInsets.only(bottom: widget.isScrollable ? 21 : 42, top: 10), itemBuilder: (context, index) { - return Row( - children: [ - SizedBox( - width: 22, - height: 22, - child: Radio( - value: widget.listData[index].value, - groupValue: selectedIndex, - onChanged: (value) { - setState(() { - selectedIndex = value; - }); - }, + return InkWell( + onTap: () { + setState(() { + selectedIndex = widget.listData[index].value; + }); + }, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: 22, + height: 22, + child: Radio( + value: widget.listData[index].value, + groupValue: selectedIndex, + onChanged: (value) { + setState(() { + selectedIndex = value; + }); + }, + ), ), - ), - SizedBox(width: 8), - Text( - widget.listData[index].title, - style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.56), - ), - ], + SizedBox(width: 8), + Expanded( + child: Text( + widget.listData[index].title, + // maxLines: 2, + style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.56), + ), + ), + ], + ), ); }, separatorBuilder: (context, index) => SizedBox(height: 10), @@ -110,7 +121,7 @@ class RadioSelectionDialogState extends State { Expanded( child: DefaultButton( TranslationBase.of(context).save, - (){ + () { Navigator.pop(context); widget.onValueSelected(selectedIndex); }, diff --git a/lib/widgets/in_app_browser/InAppBrowser.dart b/lib/widgets/in_app_browser/InAppBrowser.dart index 158de780..4fff16c3 100644 --- a/lib/widgets/in_app_browser/InAppBrowser.dart +++ b/lib/widgets/in_app_browser/InAppBrowser.dart @@ -22,19 +22,17 @@ var _InAppBrowserOptions = InAppBrowserClassOptions( inAppWebViewGroupOptions: InAppWebViewGroupOptions(crossPlatform: InAppWebViewOptions(useShouldOverrideUrlLoading: true)), crossPlatform: InAppBrowserOptions(hideUrlBar: true), ios: IOSInAppBrowserOptions( - toolbarBottom: false, + hideToolbarBottom: false, )); class MyInAppBrowser extends InAppBrowser { _PAYMENT_TYPE paymentType; - static String SERVICE_URL = - 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT + static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT // static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE - static String PREAUTH_SERVICE_URL = - 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort PreAuth Payment Gateway URL UAT + static String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort PreAuth Payment Gateway URL UAT // static String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort PreAuth Payment Gateway URL Live Store @@ -77,17 +75,17 @@ class MyInAppBrowser extends InAppBrowser { } @override - Future onLoadStart(String url) async { + Future onLoadStart(Uri url) async { if (onLoadStartCallback != null) onLoadStartCallback(url); } @override - Future onLoadStop(String url) async { + Future onLoadStop(Uri url) async { print("\n\nStopped $url\n\n"); } @override - void onLoadError(String url, int code, String message) { + void onLoadError(Uri url, int code, String message) { print("Can't load $url.. Error: $message"); } @@ -100,18 +98,18 @@ class MyInAppBrowser extends InAppBrowser { if (onExitCallback != null) onExitCallback(appo, isPaymentDone); } - @override - Future shouldOverrideUrlLoading(ShouldOverrideUrlLoadingRequest shouldOverrideUrlLoadingRequest) async { - var url = shouldOverrideUrlLoadingRequest.url; - debugPrint("redirecting/overriding to: $url"); - - if (paymentType == _PAYMENT_TYPE.PACKAGES && [PACKAGES_PAYMENT_SUCCESS_URL, PACKAGES_PAYMENT_FAIL_URL].contains(url)) { - isPaymentDone = (url == PACKAGES_PAYMENT_SUCCESS_URL); - close(); - } - - return ShouldOverrideUrlLoadingAction.ALLOW; - } + // @override + // Future shouldOverrideUrlLoading(ShouldOverrideUrlLoadingRequest shouldOverrideUrlLoadingRequest) async { + // var url = shouldOverrideUrlLoadingRequest.url; + // debugPrint("redirecting/overriding to: $url"); + // + // if (paymentType == _PAYMENT_TYPE.PACKAGES && [PACKAGES_PAYMENT_SUCCESS_URL, PACKAGES_PAYMENT_FAIL_URL].contains(url)) { + // isPaymentDone = (url == PACKAGES_PAYMENT_SUCCESS_URL); + // close(); + // } + // + // return ShouldOverrideUrlLoadingAction.ALLOW; + // } getLanguageID() async { return await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); @@ -136,7 +134,7 @@ class MyInAppBrowser extends InAppBrowser { openPackagesPaymentBrowser({@required int customer_id, @required int order_id}) { paymentType = _PAYMENT_TYPE.PACKAGES; var full_url = '$PACKAGES_REQUEST_PAYMENT_URL?customer_id=$customer_id&order_id=$order_id'; - this.openUrl(url: full_url, options: _InAppBrowserOptions); + this.browser.openUrlRequest(urlRequest: URLRequest(url: Uri.parse(full_url)), options: _InAppBrowserOptions); } openPaymentBrowser(double amount, String orderDesc, String transactionID, String projId, String emailId, String paymentMethod, dynamic patientType, String patientName, dynamic patientID, @@ -182,9 +180,8 @@ class MyInAppBrowser extends InAppBrowser { service.applePayInsertRequest(applePayInsertRequest, context).then((res) { if (context != null) GifLoaderDialogUtils.hideDialog(context); - var url = "https://hmgwebservices.com/HMGApplePayLive/applepay/pay?apq=" + res['result']; - print(url); - safariBrowser.open(url: url); + String url = "https://hmgwebservices.com/HMGApplePayLive/applepay/pay?apq=" + res['result']; + safariBrowser.open(url: Uri.parse(url)); // this.browser.openUrl(url: url, options: _InAppBrowserOptions); }).catchError((err) { print(err); @@ -196,7 +193,7 @@ class MyInAppBrowser extends InAppBrowser { clinicID, doctorID) .then((value) { paymentType = _PAYMENT_TYPE.PATIENT; - this.browser.openUrl(url: value, options: _InAppBrowserOptions); + this.browser.openUrlRequest(urlRequest: URLRequest(url: Uri.parse(value)), options: _InAppBrowserOptions); }); } } @@ -206,13 +203,13 @@ class MyInAppBrowser extends InAppBrowser { this.browser = browser; getPatientData(); generatePharmacyURL(order, amount, orderDesc, transactionID, emailId, paymentMethod, patientName, patientID, authenticatedUser).then((value) { - this.browser.openUrl(url: value); + this.browser.openUrlRequest(urlRequest: URLRequest(url: Uri.parse(value))); }); } openBrowser(String url) { this.browser = browser; - this.browser.openUrl(url: url, options: _InAppBrowserOptions); + this.browser.openUrlRequest(urlRequest: URLRequest(url: Uri.parse(url)), options: _InAppBrowserOptions); } Future generateURL(double amount, String orderDesc, String transactionID, String projId, String emailId, String paymentMethod, dynamic patientType, String patientName, dynamic patientID, @@ -351,7 +348,7 @@ class MyChromeSafariBrowser extends ChromeSafariBrowser { final Function onLoadStartCallback; AppoitmentAllHistoryResultList appo; - MyChromeSafariBrowser(browserFallback, {@required this.onExitCallback, @required this.onLoadStartCallback, @required this.appo}) : super(bFallback: browserFallback); + MyChromeSafariBrowser(browserFallback, {@required this.onExitCallback, @required this.onLoadStartCallback, @required this.appo}); @override void onOpened() { diff --git a/lib/widgets/new_design/doctor_header.dart b/lib/widgets/new_design/doctor_header.dart index 59444b31..5c556efb 100644 --- a/lib/widgets/new_design/doctor_header.dart +++ b/lib/widgets/new_design/doctor_header.dart @@ -176,7 +176,7 @@ class DoctorHeader extends StatelessWidget { void showConfirmMessage(BuildContext context, GestureTapCallback onTap, String email) { showDialog( context: context, - child: ConfirmSendEmailDialog( + builder: (cxt) => ConfirmSendEmailDialog( email: email, onTapSendEmail: () { onTap(); diff --git a/lib/widgets/offers_packages/offers_packages.dart b/lib/widgets/offers_packages/offers_packages.dart index aed4f699..89d395fa 100644 --- a/lib/widgets/offers_packages/offers_packages.dart +++ b/lib/widgets/offers_packages/offers_packages.dart @@ -104,7 +104,7 @@ class _OffersAndPackagesWidgetState extends State { return Container( child: CarouselSlider.builder( itemCount: widget.models.length, - itemBuilder: (BuildContext context, int itemIndex) { + itemBuilder: (BuildContext context, int itemIndex,int realIndex) { var item = widget.models[itemIndex]; return OfferPackagesItemWidget(model: item); }, diff --git a/lib/widgets/others/floating_button_search.dart b/lib/widgets/others/floating_button_search.dart index 8a9274be..da922323 100644 --- a/lib/widgets/others/floating_button_search.dart +++ b/lib/widgets/others/floating_button_search.dart @@ -269,7 +269,7 @@ class _FloatingSearchButton extends State with TickerProvi } requestPermissions() async { - if (await Permission.microphone.isDenied || await Permission.microphone.isUndetermined) { + if (await Permission.microphone.isDenied || await Permission.microphone.isPermanentlyDenied) { Map statuses = await [ Permission.microphone, ].request(); diff --git a/lib/widgets/others/not_auh_page.dart b/lib/widgets/others/not_auh_page.dart index b774b7c6..5e957904 100644 --- a/lib/widgets/others/not_auh_page.dart +++ b/lib/widgets/others/not_auh_page.dart @@ -125,7 +125,7 @@ class _NotAutPageState extends State { Scaffold( backgroundColor: Color(0xfff8f8f8), - resizeToAvoidBottomPadding: false, + resizeToAvoidBottomInset: false, appBar: AppBar( backgroundColor: Colors.transparent, leading: IconButton( diff --git a/lib/widgets/otp/sms-popup.dart b/lib/widgets/otp/sms-popup.dart index 6fccaec4..afb27530 100644 --- a/lib/widgets/otp/sms-popup.dart +++ b/lib/widgets/otp/sms-popup.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:io'; import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; @@ -6,7 +7,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:provider/provider.dart'; -import 'package:sms_otp_auto_verify/sms_otp_auto_verify.dart'; +import 'package:sms_retriever/sms_retriever.dart'; import '../otp_widget.dart'; @@ -58,6 +59,7 @@ class SMSOTP { String _code; dynamic setState; static String signature; + displayDialog(BuildContext context) async { return showDialog( context: context, @@ -84,7 +86,7 @@ class SMSOTP { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ SvgPicture.asset( - type == 1 ?"assets/images/new/verify_sms.svg":"assets/images/new/verify_whatsapp.svg", + type == 1 ? "assets/images/new/verify_sms.svg" : "assets/images/new/verify_whatsapp.svg", height: 50, width: 50, ), @@ -236,6 +238,10 @@ class SMSOTP { } static getSignature() async { - return await SmsRetrieved.getAppSignature(); + if (Platform.isAndroid) { + return await SmsRetriever.getAppSignature(); + } else { + return null; + } } } diff --git a/pubspec.yaml b/pubspec.yaml index ff6873fc..8cf5ace0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ description: A new Flutter application. version: 4.3.5+1 environment: - sdk: ">=2.9.0 <3.0.0" + sdk: ">=2.7.0 <3.0.0" dependencies: flutter: @@ -14,58 +14,58 @@ dependencies: # Localizations flutter_localizations: sdk: flutter - intl: ^0.16.0 + intl: ^0.17.0 # web view - webview_flutter: ^1.0.7 + webview_flutter: ^2.3.1 # http client - http: ^0.12.1 - connectivity: ^0.4.9+3 - async: ^2.4.2 + http: ^0.13.4 + connectivity: ^3.0.6 + async: ^2.8.1 - audio_wave: ^0.0.3 + audio_wave: ^0.1.2 # State Management - provider: ^4.3.2+2 + provider: ^6.0.1 #Dependency Injection - get_it: ^4.0.2 + get_it: ^7.2.0 #Google Fit & Apple HealthKit fit_kit: ^1.1.2 #chart - fl_chart: ^0.12.3 + fl_chart: ^0.40.2 #Camera Preview - camera: ^0.7.0+4 + camera: ^0.9.4+5 # Permissions - permission_handler: ^5.1.0+2 + permission_handler: ^8.3.0 # Flutter Html View - flutter_html: ^1.2.0 + flutter_html: ^2.1.5 # Pagnation - pull_to_refresh: 1.6.2 + pull_to_refresh: ^2.0.0 # Native - local_auth: ^0.6.2+3 - localstorage: ^3.0.3+6 - maps_launcher: ^1.2.1 - url_launcher: ^5.5.0 - shared_preferences: ^0.5.8 + local_auth: ^1.1.8 + localstorage: ^4.0.0+1 + maps_launcher: ^2.0.1 + url_launcher: ^6.0.15 + shared_preferences: ^2.0.9 flutter_flexible_toast: ^0.1.4 - firebase_messaging: ^7.0.3 - firebase_analytics: ^6.3.0 + firebase_messaging: ^11.1.0 + firebase_analytics: ^8.3.4 # Progress bar progress_hud_v2: ^2.0.0 - percent_indicator: ^2.1.5 + percent_indicator: ^3.4.0 # Icons font_awesome_flutter: any cupertino_icons: ^1.0.0 # Image Attachments - image_picker: ^0.6.7+1 + image_picker: ^0.8.4+4 #GIF image flutter_gifimage: ^1.0.1 @@ -81,15 +81,15 @@ dependencies: # flutter_local_notifications: # charts - charts_flutter: ^0.9.0 + charts_flutter: ^0.12.0 - google_maps_flutter: ^1.0.3 - huawei_map: ^5.0.3+303 + google_maps_flutter: ^2.1.1 + huawei_map: ^6.0.1+304 # Qr code Scanner TODO fix it # barcode_scanner: ^1.0.1 - flutter_polyline_points: ^0.1.0 - location: ^2.3.5 + flutter_polyline_points: ^1.0.0 + location: ^4.3.0 # Qr code Scanner barcode_scan_fix: ^1.0.2 @@ -97,66 +97,62 @@ dependencies: rating_bar: ^0.2.0 # Calendar - syncfusion_flutter_calendar: ^18.4.49 + syncfusion_flutter_calendar: ^19.3.55 # SVG Images - flutter_svg: ^0.19.0 + flutter_svg: ^0.23.0+1 #Calendar Events - manage_calendar_events: ^1.0.2 + manage_calendar_events: ^2.0.1 #InAppBrowser - flutter_inappwebview: ^4.0.0+4 + flutter_inappwebview: ^5.3.2 #Circular progress bar for reverse timer - circular_countdown_timer: ^0.0.5 + circular_countdown_timer: ^0.2.0 #Just Audio to play ringing for incoming video call - just_audio: ^0.3.4 + just_audio: ^0.9.18 #hijri hijri: ^2.0.3 #datetime_picker - flutter_datetime_picker: ^1.4.0 + flutter_datetime_picker: ^1.5.1 # Carousel carousel_pro: ^1.0.0 #local_notifications - flutter_local_notifications: ^1.5.0 - - #rxdart - rxdart: ^0.24.1 + flutter_local_notifications: ^9.1.4 #device_calendar device_calendar: ^3.1.0 #Handle Geolocation - geolocator: ^6.1.10 + geolocator: ^7.7.1 - jiffy: ^3.0.0 + jiffy: ^4.1.0 #Flutter WebRTC - flutter_webrtc: ^0.5.9 + flutter_webrtc: ^0.7.1 screen: ^0.0.5 #google maps places - google_maps_place_picker: ^1.0.0 + + google_maps_place_picker: ^2.1.0-nullsafety.3 #countdown timer for Upcoming List - flutter_countdown_timer: ^1.6.0 + flutter_countdown_timer: ^4.1.0 #Dependencies for video call implementation - native_device_orientation: ^0.3.0 - enum_to_string: ^1.0.9 - wakelock: ^0.2.1+1 - after_layout: ^1.0.7 - twilio_programmable_video: ^0.6.2 - cached_network_image: ^2.4.1 + native_device_orientation: ^1.0.0 + wakelock: ^0.5.6 + after_layout: ^1.1.0 +# twilio_programmable_video: ^0.11.0+1 + cached_network_image: ^3.1.0+1 flutter_tts: path: flutter_tts-voice_enhancement - sms_otp_auto_verify: ^1.2.2 wifi: ^0.1.5 vibration: ^1.7.3 @@ -165,42 +161,43 @@ dependencies: speech_to_text: path: speech_to_text - in_app_update: ^1.1.15 + in_app_update: ^2.0.0 - in_app_review: ^1.0.4 + in_app_review: ^2.0.3 - badges: ^1.1.4 - syncfusion_flutter_sliders: ^18.4.49-beta + badges: ^2.0.1 + syncfusion_flutter_sliders: ^19.3.55 searchable_dropdown: ^1.1.3 dropdown_search: 0.4.9 # Dep by Zohaib - shimmer: ^1.1.2 - carousel_slider: ^2.3.1 - flutter_material_pickers: 1.7.4 - flutter_staggered_grid_view: 0.3.4 - flutter_hms_gms_availability: ^1.0.0 + shimmer: ^2.0.0 + carousel_slider: ^4.0.0 + flutter_material_pickers: ^3.1.2 + flutter_staggered_grid_view: ^0.4.1 + flutter_hms_gms_availability: ^2.0.0 huawei_location: path: ./hms-plugins/flutter-hms-location - # Marker Animation - flutter_animarker: ^1.0.0 - auto_size_text: ^2.0.1 - equatable: ^1.2.5 - signalr_core: ^1.0.8 - wave: ^0.1.0 + flutter_animarker: ^3.2.0 + auto_size_text: ^3.0.0 + equatable: ^2.0.3 + signalr_core: ^1.1.1 + wave: ^0.2.0 + sms_retriever: ^1.0.0 + +dependency_overrides: + provider : ^5.0.0 + permission_handler : ^6.0.1+1 dev_dependencies: flutter_test: sdk: flutter - build_runner: any - + build_runner: ^2.1.5 flutter: - uses-material-design: true - # assets: assets: - assets/images/ diff --git a/speech_to_text/pubspec.yaml b/speech_to_text/pubspec.yaml index 34b3da29..831c9181 100644 --- a/speech_to_text/pubspec.yaml +++ b/speech_to_text/pubspec.yaml @@ -10,15 +10,15 @@ environment: dependencies: flutter: sdk: flutter - json_annotation: ^3.0.0 - clock: ^1.0.1 + json_annotation: ^4.3.0 + clock: ^1.1.0 dev_dependencies: flutter_test: sdk: flutter - build_runner: ^1.0.0 - json_serializable: ^3.0.0 - fake_async: ^1.0.1 + build_runner: ^2.1.5 + json_serializable: ^6.0.1 + fake_async: ^1.2.0 flutter: plugin: