diff --git a/lib/pages/AlHabibMedicalService/all_habib_medical_service_page2.dart b/lib/pages/AlHabibMedicalService/all_habib_medical_service_page2.dart index ac4c11e1..37bc5fe6 100644 --- a/lib/pages/AlHabibMedicalService/all_habib_medical_service_page2.dart +++ b/lib/pages/AlHabibMedicalService/all_habib_medical_service_page2.dart @@ -223,8 +223,6 @@ class _AllHabibMedicalSevicePage2State extends State var data = await this.sharedPref.getObject(WEATHER); if (data == null) { var d = await _weatherService.getWeatherData(); - - print(d); weatherNum = d.temperature; setState(() { weather = d != null ? d.temperature.toString() + '\u2103' : '--'; diff --git a/lib/pages/Blood/blood_donation.dart b/lib/pages/Blood/blood_donation.dart index 5d4d8194..e0c6bfe7 100644 --- a/lib/pages/Blood/blood_donation.dart +++ b/lib/pages/Blood/blood_donation.dart @@ -72,14 +72,38 @@ class _BloodDonationPageState extends State { super.initState(); } + int getSelectedCityID(MyBalanceViewModel model) { + int cityID = 1; + + model.CitiesModelList.forEach((element) { + if (element.description == model.bloodModelList[0].city) { + cityID = element.iD; + } + }); + + return cityID; + } + @override Widget build(BuildContext context) { projectProvider = Provider.of(context); return BaseView( onModelReady: (model) { - model.getCities(); - model.getBlood(); + model.getCities().then((value) { + model.getBlood().then((value) { + if (model.bloodModelList.length > 0) { + CitiesModel citiesModel = new CitiesModel(); + citiesModel.iD = getSelectedCityID(model); + _selectedHospitalIndex = (citiesModel.iD - 1); + citiesModel.description = model.CitiesModelList[_selectedHospitalIndex].description; + citiesModel.descriptionN = model.CitiesModelList[_selectedHospitalIndex].descriptionN; + _selectedHospital = citiesModel; + } else { + _selectedHospital = model.CitiesModelList[0]; + } + }); + }); }, builder: (_, model, w) => AppScaffold( isShowAppBar: true, @@ -108,11 +132,10 @@ class _BloodDonationPageState extends State { if (projectProvider.isLogin && model.state != ViewState.Busy) CommonDropDownView( TranslationBase.of(context).city, - (model.bloodModelList.isNotEmpty && model.CitiesModelList.isNotEmpty) - ? model.bloodModelList[0].city - : projectProvider.isArabic - ? model.CitiesModelList[_selectedHospitalIndex].descriptionN - : model.CitiesModelList[_selectedHospitalIndex].description, () { + // (model.bloodModelList.isNotEmpty && model.CitiesModelList.isNotEmpty) + // ? model.bloodModelList[0].city + // : + projectProvider.isArabic ? _selectedHospital.descriptionN : _selectedHospital.description, () { List list = [ for (int i = 0; i < model.CitiesModelList.length; i++) RadioSelectionDialogModel(projectProvider.isArabic ? model.CitiesModelList[i].descriptionN : model.CitiesModelList[i].description, i), @@ -127,6 +150,7 @@ class _BloodDonationPageState extends State { onValueSelected: (index) { _selectedHospitalIndex = index; _selectedHospital = model.CitiesModelList[index]; + setState(() {}); }, ), ); @@ -249,7 +273,7 @@ class _BloodDonationPageState extends State { AppToast.showErrorToast(message: TranslationBase.of(context).selectCity); return; } - bloodDetails.city = projectProvider.isArabic ? _selectedHospital.descriptionN : _selectedHospital.description; + bloodDetails.city = _selectedHospital.description; bloodDetails.cityCode = _selectedHospital.iD.toString(); bloodDetails.gender = _selectedGenderIndex; bloodDetails.bloodGroup = getBlood(_selectedBloodTypeIndex); diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index 78f3c173..cb26c8b7 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -29,7 +29,6 @@ import 'package:diplomaticquarterapp/uitl/location_util.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/bottom_navigation/bottom_nav_bar.dart'; import 'package:diplomaticquarterapp/widgets/buttons/floatingActionButton.dart'; -import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/drawer/app_drawer_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/not_auh_page.dart'; @@ -242,7 +241,6 @@ class _LandingPageState extends State with WidgetsBindingObserver { pageController = PageController(keepPage: true); _firebaseMessaging.setAutoInitEnabled(true); - // signalRUtil = new SignalRUtil(hubName: "http://192.168.8.101:5001/chatHub", context: context); signalRUtil = new SignalRUtil(hubName: "https://VCallApi.hmg.com/WebRTCHub?source=mobile&username=2001273", context: context); locationUtils = new LocationUtils(isShowConfirmDialog: false, context: context); @@ -250,7 +248,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { if (projectViewModel.isLogin && !projectViewModel.isLoginChild) { familyFileProvider.getSharedRecordByStatus(); } - signalRUtil.startSignalRConnection(); + if (!signalRUtil.getConnectionState()) signalRUtil.startSignalRConnection(); }); // HMG (Guest/Internet) Wifi Access [Zohaib Kambrani] //for now commented to reduce this call will enable it when needed @@ -507,91 +505,93 @@ class _LandingPageState extends State with WidgetsBindingObserver { model = Provider.of(context); // currentTab == 0 ? 45 : 0.0 return Scaffold( - appBar: currentTab == 0 ? PreferredSize( - preferredSize: Size.fromHeight(currentTab == 0 ? 45 : 0.0), - child: AppBar( - elevation: 0, - backgroundColor: CustomColors.backgroudGreyColor, - textTheme: TextTheme( - headline6: TextStyle(color: Theme.of(context).textTheme.headline1.color, fontWeight: FontWeight.bold), - ), - title: Text( - getText(currentTab).toUpperCase(), - style: TextStyle( - fontWeight: FontWeight.bold, - color: currentTab == 0 ? CustomColors.backgroudGreyColor : Theme.of(context).textTheme.headline1.color, - fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins'), - // bold: true, - ), - leading: Builder( - builder: (BuildContext context) { - return new Stack( - children: [ - currentTab == 0 - ? IconButton( - icon: SvgPicture.asset("assets/images/new/menu.svg"), - color: Theme.of(context).textTheme.headline1.color, - onPressed: () => Scaffold.of(context).openDrawer(), - ) - : IconButton( - icon: Icon(Icons.arrow_back), - onPressed: () { - setState(() { - currentTab = 0; - }); - - pageController.jumpToPage(0); - }, - ), - projectViewModel.isLogin && model.notificationsCount != null && !projectViewModel.isLoginChild - ? new Positioned( - right: projectViewModel.isArabic ? 35 : 0, - top: 5, - child: new Container( - padding: EdgeInsets.all(4), - decoration: new BoxDecoration( - color: CustomColors.accentColor, - borderRadius: BorderRadius.circular(20), - ), - constraints: BoxConstraints( - minWidth: 20, - minHeight: 20, - ), - child: new Text( - model.notificationsCount.toString(), - style: new TextStyle( - color: Colors.white, - fontSize: projectViewModel.isArabic ? 8 : 9, + appBar: currentTab == 0 + ? PreferredSize( + preferredSize: Size.fromHeight(currentTab == 0 ? 45 : 0.0), + child: AppBar( + elevation: 0, + backgroundColor: CustomColors.backgroudGreyColor, + textTheme: TextTheme( + headline6: TextStyle(color: Theme.of(context).textTheme.headline1.color, fontWeight: FontWeight.bold), + ), + title: Text( + getText(currentTab).toUpperCase(), + style: TextStyle( + fontWeight: FontWeight.bold, + color: currentTab == 0 ? CustomColors.backgroudGreyColor : Theme.of(context).textTheme.headline1.color, + fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins'), + // bold: true, + ), + leading: Builder( + builder: (BuildContext context) { + return new Stack( + children: [ + currentTab == 0 + ? IconButton( + icon: SvgPicture.asset("assets/images/new/menu.svg"), + color: Theme.of(context).textTheme.headline1.color, + onPressed: () => Scaffold.of(context).openDrawer(), + ) + : IconButton( + icon: Icon(Icons.arrow_back), + onPressed: () { + setState(() { + currentTab = 0; + }); + + pageController.jumpToPage(0); + }, ), - textAlign: TextAlign.center, - ), - ), - ) - : SizedBox() + projectViewModel.isLogin && model.notificationsCount != null && !projectViewModel.isLoginChild + ? new Positioned( + right: projectViewModel.isArabic ? 35 : 0, + top: 5, + child: new Container( + padding: EdgeInsets.all(4), + decoration: new BoxDecoration( + color: CustomColors.accentColor, + borderRadius: BorderRadius.circular(20), + ), + constraints: BoxConstraints( + minWidth: 20, + minHeight: 20, + ), + child: new Text( + model.notificationsCount.toString(), + style: new TextStyle( + color: Colors.white, + fontSize: projectViewModel.isArabic ? 8 : 9, + ), + textAlign: TextAlign.center, + ), + ), + ) + : SizedBox() + ], + ); + }, + ), + actions: [ + // IconButton( + // //iconSize: 70, + // icon: Icon( + // projectViewModel.isLogin ? Icons.settings : Icons.login, + // color: Theme.of(context).textTheme.headline1.color, + // ), + // onPressed: () { + // if (projectViewModel.isLogin) + // Navigator.of(context).pushNamed( + // SETTINGS, + // ); + // else + // login(); + // }, //do something, + // ) ], - ); - }, - ), - actions: [ - // IconButton( - // //iconSize: 70, - // icon: Icon( - // projectViewModel.isLogin ? Icons.settings : Icons.login, - // color: Theme.of(context).textTheme.headline1.color, - // ), - // onPressed: () { - // if (projectViewModel.isLogin) - // Navigator.of(context).pushNamed( - // SETTINGS, - // ); - // else - // login(); - // }, //do something, - // ) - ], - centerTitle: true, - ), - ) : null, + centerTitle: true, + ), + ) + : null, drawer: SafeArea(child: AppDrawer()), extendBody: false, body: WillPopScope( diff --git a/lib/uitl/SignalRUtil.dart b/lib/uitl/SignalRUtil.dart index 52f34cf7..a1a411e0 100644 --- a/lib/uitl/SignalRUtil.dart +++ b/lib/uitl/SignalRUtil.dart @@ -29,6 +29,10 @@ class SignalRUtil { }); } + void closeSignalRConnection() { + connectionBuilder.stop(); + } + void handleIncomingMessage(List message) { print(message.toString()); } @@ -38,7 +42,7 @@ class SignalRUtil { } bool getConnectionState() { - if (connectionBuilder.state == HubConnectionState.connected) return true; - if (connectionBuilder.state == HubConnectionState.connected) return true; + if (connectionBuilder.state == HubConnectionState.connected || connectionBuilder.state == HubConnectionState.connecting) return true; + if (connectionBuilder.state == HubConnectionState.disconnected || connectionBuilder.state == HubConnectionState.disconnecting) return false; } } diff --git a/lib/uitl/utils_new.dart b/lib/uitl/utils_new.dart index 70bd7df0..832a92b1 100644 --- a/lib/uitl/utils_new.dart +++ b/lib/uitl/utils_new.dart @@ -570,10 +570,6 @@ bool timeCalculator(int startHour, int startMint, int endHour, int endMint) { DateTime now = DateTime.now(); DateTime startDate = DateTime(now.year, now.month, now.day, startHour, startHour); DateTime endDate = DateTime(now.year, now.month, now.day, endHour, endMint); - print(startDate.toString()); - print(endDate.toString()); - print(now); - print("------------"); if (startDate.isBefore(now) && endDate.isAfter(now)) return true; else