diff --git a/lib/core/service/weather_service.dart b/lib/core/service/weather_service.dart index b2dcf0ef..679a4c9d 100644 --- a/lib/core/service/weather_service.dart +++ b/lib/core/service/weather_service.dart @@ -21,17 +21,15 @@ class WeatherService extends BaseService { await baseAppClient.post(WEATHER_INDICATOR, onSuccess: (dynamic response, int statusCode) { - - response['GetCityInfo_List'].forEach((data) { weatherIndicatorData.add(GetCityInfoList.fromJson(data)); }); print(weatherIndicatorData); - }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); - await this.sharedPref.setObject(WEATHER,weatherIndicatorData[0]); + await this.sharedPref.setObject(WEATHER, weatherIndicatorData[0]); + return Future.value(weatherIndicatorData[0]); } } diff --git a/lib/pages/AlHabibMedicalService/all_habib_medical_service_page.dart b/lib/pages/AlHabibMedicalService/all_habib_medical_service_page.dart index 870fef97..a0166957 100644 --- a/lib/pages/AlHabibMedicalService/all_habib_medical_service_page.dart +++ b/lib/pages/AlHabibMedicalService/all_habib_medical_service_page.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/core/service/weather_service.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/%E2%80%8B%20health_calculators.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/E-Referral/e_referral_index_page.dart'; @@ -31,6 +32,7 @@ import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:geolocator/geolocator.dart'; import 'package:url_launcher/url_launcher.dart'; class AllHabibMedicalService extends StatefulWidget { @@ -48,14 +50,16 @@ class _AllHabibMedicalServiceState extends State { AuthenticatedUser authUser = new AuthenticatedUser(); LocationUtils locationUtils; var weather = '--'; - + WeatherService _weatherService = WeatherService(); @override void initState() { WidgetsBinding.instance.addPostFrameCallback((timeStamp) { - getAuthUser(); locationUtils = new LocationUtils(isShowConfirmDialog: true, context: context); - locationUtils.getCurrentLocation(); + WidgetsBinding.instance.addPostFrameCallback((_) => { + Geolocator.getLastKnownPosition() + .then((value) => setLocation(value)) + }); }); super.initState(); } @@ -130,8 +134,11 @@ class _AllHabibMedicalServiceState extends State { width: 60, height: 60, ), - AppText(weather, - fontSize: 22, color: Colors.white) + Directionality( + textDirection: TextDirection.ltr, + child: AppText(weather, + fontSize: 22, + color: Colors.white)) ], ), Texts( @@ -276,7 +283,23 @@ class _AllHabibMedicalServiceState extends State { }); } var data = await this.sharedPref.getObject(WEATHER); - weather = data != null ? data['Temperature'].toString() + '\u2103' : '--'; - print(data); + if (data == null) { + var d = await _weatherService.getWeatherData(); + print(d); + setState(() { + weather = d != null ? d.temperature.toString() + '\u2103' : '--'; + }); + } else { + setState(() { + weather = + data != null ? data['Temperature'].toString() + '\u2103' : '--'; + }); + } + } + + void setLocation(Position position) { + this.sharedPref.setDouble(USER_LAT, position.latitude ?? 0.0); + this.sharedPref.setDouble(USER_LONG, position.longitude ?? 0.0); + getAuthUser(); } } diff --git a/lib/pages/AlHabibMedicalService/health-weather/health-weather-indicator.dart b/lib/pages/AlHabibMedicalService/health-weather/health-weather-indicator.dart index 343c6e3e..dbb46eee 100644 --- a/lib/pages/AlHabibMedicalService/health-weather/health-weather-indicator.dart +++ b/lib/pages/AlHabibMedicalService/health-weather/health-weather-indicator.dart @@ -97,8 +97,11 @@ class _HospitalsPageState extends State { width: 60, height: 60, ), - AppText(weather, - fontSize: 22, color: Colors.white) + Directionality( + textDirection: TextDirection.ltr, + child: AppText(weather, + fontSize: 22, + color: Colors.white)) ], ), ], diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index 5935617d..bb629f6b 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -577,8 +577,13 @@ class _LandingPageState extends State with WidgetsBindingObserver { authService.getDashboard().then((value) => { setState(() { notificationCount = value['List_PatientDashboard'][0] - ['UnreadPatientNotificationCount'] - .toString(); + ['UnreadPatientNotificationCount'] > + 99 + ? '99+' + : value['List_PatientDashboard'][0] + ['UnreadPatientNotificationCount'] + .toString(); + sharedPref.setString(NOTIFICATION_COUNT, notificationCount); }) }); diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index 7f7c883d..a3537e54 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -360,8 +360,11 @@ class _ConfirmLogin extends State { context, type, this.mobileNumber, - (value) => {this.checkActivationCode(value: value)}, + (value) { + this.checkActivationCode(value: value); + }, () => { + Navigator.pop(context), print('Faild..'), }, ).displayDialog(context); diff --git a/lib/pages/settings/profile_setting.dart b/lib/pages/settings/profile_setting.dart index 13ca5da6..c0a3dafd 100644 --- a/lib/pages/settings/profile_setting.dart +++ b/lib/pages/settings/profile_setting.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; @@ -10,6 +11,7 @@ import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:provider/provider.dart'; class ProfileSettings extends StatefulWidget { @override @@ -28,7 +30,9 @@ class _ProfileSettings extends State @override void initState() { Future.delayed(new Duration(seconds: 0), () { - getSettings(context); + ProjectViewModel projectProvider; + projectProvider = Provider.of(context); + if (projectProvider.isLogin == true) getSettings(context); }); super.initState(); } @@ -37,182 +41,188 @@ class _ProfileSettings extends State return BaseView( onModelReady: (model) => {}, builder: (_, model, wi) => Container( - child: - ListView(scrollDirection: Axis.vertical, children: [ - Container( - padding: EdgeInsets.all(15), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AppText( - TranslationBase.of(context).fileNo, - color: Colors.black, + child: model.user != null + ? ListView(scrollDirection: Axis.vertical, children: [ + Container( + padding: EdgeInsets.all(15), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AppText( + TranslationBase.of(context).fileNo, + color: Colors.black, + ), + AppText( + model.user.patientID.toString(), + color: Colors.black, + ), + ], + ), ), - AppText( - model.user.patientID.toString(), - color: Colors.black, + SizedBox( + height: 1, + width: MediaQuery.of(context).size.width, + child: Container( + color: Colors.grey[300], + ), ), - ], - ), - ), - SizedBox( - height: 1, - width: MediaQuery.of(context).size.width, - child: Container( - color: Colors.grey[300], - ), - ), - Padding( - child: AppText(TranslationBase.of(context).languageSetting, - fontWeight: FontWeight.bold), - padding: EdgeInsets.all(10), - ), - Container( - color: Colors.white, - padding: - EdgeInsets.only(top: 0, left: 10, right: 10, bottom: 0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AppText(TranslationBase.of(context).english), - new Radio( - value: 2, - groupValue: language, - onChanged: (value) { - setState(() { - language = value; - }); - }, - ) - ], - )), - Container( - color: Colors.white, - padding: - EdgeInsets.only(top: 0, left: 10, right: 10, bottom: 0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AppText(TranslationBase.of(context).arabic), - new Radio( - value: 1, - groupValue: language, - onChanged: (value) { - setState(() { - language = value; - }); - }, - ) - ], - )), - Padding( - child: AppText(TranslationBase.of(context).alert), - padding: EdgeInsets.all(10), - ), - Container( - color: Colors.white, - padding: - EdgeInsets.only(top: 0, left: 10, right: 10, bottom: 0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AppText(TranslationBase.of(context).emailAlert), - Switch( - value: emailAlert, - onChanged: (value) { - setState(() { - emailAlert = value; - }); - }, - activeTrackColor: Colors.lightGreenAccent, - activeColor: Colors.green, - ) - ], - )), - Container( - color: Colors.white, - padding: - EdgeInsets.only(top: 0, left: 10, right: 10, bottom: 0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AppText(TranslationBase.of(context).smsAlert), - Switch( - value: smsAlert, - onChanged: (value) { - setState(() { - smsAlert = value; - }); - }, - activeTrackColor: Colors.lightGreenAccent, - activeColor: Colors.green, - ) - ], - )), - Padding( - child: AppText(TranslationBase.of(context).contactInfo), - padding: EdgeInsets.all(10), - ), - Container( - color: Colors.white, - padding: - EdgeInsets.only(top: 0, left: 10, right: 10, bottom: 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText(TranslationBase.of(context).email), - TextField( - controller: emailController, - decoration: InputDecoration( - suffixIcon: Icon(Icons.edit), - )) - ], - )), - Container( - color: Colors.white, - padding: - EdgeInsets.only(top: 0, left: 10, right: 10, bottom: 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText(TranslationBase.of(context).emergencyName), - TextField( - controller: emergencyContactName, - decoration: InputDecoration( - suffixIcon: Icon(Icons.edit), - )) - ], - )), - Container( - color: Colors.white, - padding: - EdgeInsets.only(top: 0, left: 10, right: 10, bottom: 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText(TranslationBase.of(context).emergencyContact), - TextField( - controller: emergencyContact, - decoration: InputDecoration( - suffixIcon: Icon(Icons.edit), - ), - ) - ], - )), - Container( - padding: EdgeInsets.all(10), - child: Row( - children: [ - Expanded( - child: DefaultButton( - TranslationBase.of(context).submit, - () { - saveSettings(); - }, - )), - ], - )) - ]))); + Padding( + child: AppText( + TranslationBase.of(context).languageSetting, + fontWeight: FontWeight.bold), + padding: EdgeInsets.all(10), + ), + Container( + color: Colors.white, + padding: EdgeInsets.only( + top: 0, left: 10, right: 10, bottom: 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AppText(TranslationBase.of(context).english), + new Radio( + value: 2, + groupValue: language, + onChanged: (value) { + setState(() { + language = value; + }); + }, + ) + ], + )), + Container( + color: Colors.white, + padding: EdgeInsets.only( + top: 0, left: 10, right: 10, bottom: 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AppText(TranslationBase.of(context).arabic), + new Radio( + value: 1, + groupValue: language, + onChanged: (value) { + setState(() { + language = value; + }); + }, + ) + ], + )), + Padding( + child: AppText(TranslationBase.of(context).alert), + padding: EdgeInsets.all(10), + ), + Container( + color: Colors.white, + padding: EdgeInsets.only( + top: 0, left: 10, right: 10, bottom: 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AppText(TranslationBase.of(context).emailAlert), + Switch( + value: emailAlert, + onChanged: (value) { + setState(() { + emailAlert = value; + }); + }, + activeTrackColor: Colors.lightGreenAccent, + activeColor: Colors.green, + ) + ], + )), + Container( + color: Colors.white, + padding: EdgeInsets.only( + top: 0, left: 10, right: 10, bottom: 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AppText(TranslationBase.of(context).smsAlert), + Switch( + value: smsAlert, + onChanged: (value) { + setState(() { + smsAlert = value; + }); + }, + activeTrackColor: Colors.lightGreenAccent, + activeColor: Colors.green, + ) + ], + )), + Padding( + child: AppText(TranslationBase.of(context).contactInfo), + padding: EdgeInsets.all(10), + ), + Container( + color: Colors.white, + padding: EdgeInsets.only( + top: 0, left: 10, right: 10, bottom: 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText(TranslationBase.of(context).email), + TextField( + controller: emailController, + decoration: InputDecoration( + suffixIcon: Icon(Icons.edit), + )) + ], + )), + Container( + color: Colors.white, + padding: EdgeInsets.only( + top: 0, left: 10, right: 10, bottom: 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText(TranslationBase.of(context).emergencyName), + TextField( + controller: emergencyContactName, + decoration: InputDecoration( + suffixIcon: Icon(Icons.edit), + )) + ], + )), + Container( + color: Colors.white, + padding: EdgeInsets.only( + top: 0, left: 10, right: 10, bottom: 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + TranslationBase.of(context).emergencyContact), + TextField( + controller: emergencyContact, + decoration: InputDecoration( + suffixIcon: Icon(Icons.edit), + ), + ) + ], + )), + Container( + padding: EdgeInsets.all(10), + child: Row( + children: [ + Expanded( + child: DefaultButton( + TranslationBase.of(context).submit, + () { + saveSettings(); + }, + )), + ], + )) + ]) + : Center( + child: + AppText(TranslationBase.of(context).loginToUseService), + ))); } getSettings(context) { diff --git a/lib/pages/settings/settings.dart b/lib/pages/settings/settings.dart index abdac118..cba561b3 100644 --- a/lib/pages/settings/settings.dart +++ b/lib/pages/settings/settings.dart @@ -30,6 +30,14 @@ class _Settings extends State with TickerProviderStateMixin { return Scaffold( appBar: AppBar( bottom: TabBar( + // isScrollable: true, + + indicatorWeight: 5.0, + //indicatorSize: TabBarIndicatorSize.label, + // indicatorSize: TabBarIndicatorSize.tab, + + indicatorColor: Theme.of(context).primaryColor, + // labelColor: Theme.of(context).primaryColor, tabs: [ Tab(text: TranslationBase.of(context).general), Tab( diff --git a/lib/widgets/otp/sms-popup.dart b/lib/widgets/otp/sms-popup.dart index 02282c7b..1694f675 100644 --- a/lib/widgets/otp/sms-popup.dart +++ b/lib/widgets/otp/sms-popup.dart @@ -64,7 +64,10 @@ class SMSOTP { children: [ IconButton( icon: Icon(Icons.close), - onPressed: () => {Navigator.pop(context), this.onSuccess()}, + onPressed: () { + Navigator.pop(context); + this.onFailure(); + }, ) ], ), @@ -111,7 +114,7 @@ class SMSOTP { textInputAction: TextInputAction.next, style: buildTextStyle(), autofocus: true, - maxLength: 1, + // maxLength: 1, controller: digit1, textAlign: TextAlign.center, keyboardType: TextInputType.number, @@ -138,7 +141,7 @@ class SMSOTP { child: TextFormField( focusNode: focusD2, textInputAction: TextInputAction.next, - maxLength: 1, + // maxLength: 1, controller: digit2, textAlign: TextAlign.center, style: buildTextStyle(), @@ -165,7 +168,7 @@ class SMSOTP { child: TextFormField( focusNode: focusD3, textInputAction: TextInputAction.next, - maxLength: 1, + // maxLength: 1, controller: digit3, textAlign: TextAlign.center, style: buildTextStyle(), @@ -191,7 +194,7 @@ class SMSOTP { width: SizeConfig.realScreenWidth * 0.15, child: TextFormField( focusNode: focusD4, - maxLength: 1, + // maxLength: 1, textAlign: TextAlign.center, style: buildTextStyle(), controller: digit4,