diff --git a/assets/images/HMG_logo.png b/assets/images/HMG_logo.png new file mode 100644 index 00000000..480ba15e Binary files /dev/null and b/assets/images/HMG_logo.png differ diff --git a/assets/images/update_rocket_image.png b/assets/images/update_rocket_image.png new file mode 100644 index 00000000..539604d7 Binary files /dev/null and b/assets/images/update_rocket_image.png differ diff --git a/lib/UpdatePage.dart b/lib/UpdatePage.dart new file mode 100644 index 00000000..2094d749 --- /dev/null +++ b/lib/UpdatePage.dart @@ -0,0 +1,64 @@ +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/secondary_button.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; +import 'dart:io' show Platform; + +class UpdatePage extends StatelessWidget { + final String message; + final String androidLink; + final String iosLink; + + const UpdatePage({Key key, this.message, this.androidLink, this.iosLink}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return SafeArea( + child: AppScaffold( + isShowAppBar: false, + backgroundColor: Colors.white, + body: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Image.asset( + 'assets/images/update_rocket_image.png', + width: double.maxFinite,fit: BoxFit.fill, + ), + Image.asset('assets/images/HMG_logo.png'), + SizedBox(height: 8,), + Texts( + TranslationBase.of(context).updateTheApp.toUpperCase(),fontSize: 17, + fontWeight: FontWeight.w600, + ), + SizedBox(height: 12,), + Texts(message??"Update the app",fontSize: 12,) + ], + ), + ), + bottomSheet: Container( + height: 80, + child: Container( + // padding: const EdgeInsets.all(8.0), + margin: EdgeInsets.all(15), + child: SecondaryButton( + color: Colors.red[800], + onTap: () { + if (Platform.isIOS) + launch(iosLink); + else + launch(androidLink); + }, + label: TranslationBase.of(context).updateNow.toUpperCase(), + ), + ), + ), + ), + ); + } +} diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 45e4a671..e68aa27b 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -6,10 +6,13 @@ import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:http/http.dart' as http; import 'dart:io' show Platform; +import '../UpdatePage.dart'; + DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); Helpers helpers = new Helpers(); //ProjectProvider projectsProvider = new ProjectProvider(); @@ -31,12 +34,11 @@ Helpers helpers = new Helpers(); * */ class BaseAppClient { //TODO change the post fun to nun static when you change all service - post( - String endPoint, { - Map body, - Function(dynamic response, int statusCode) onSuccess, - Function(String error, int statusCode) onFailure,bool isAllowAny = false - }) async { + post(String endPoint, + {Map body, + Function(dynamic response, int statusCode) onSuccess, + Function(String error, int statusCode) onFailure, + bool isAllowAny = false}) async { String url = BASE_URL + endPoint; try { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); @@ -86,9 +88,6 @@ class BaseAppClient { print("URL : $url"); print("Body : ${json.encode(body)}"); - String request= json.encode(body); - var asd=""; - if (await Helpers.checkConnection()) { final response = await http.post(url, @@ -102,14 +101,19 @@ class BaseAppClient { onFailure('Error While Fetching data', statusCode); } else { var parsed = json.decode(response.body.toString()); + + if (parsed['ErrorType'] == 4) { + navigateToUpdatePage(parsed['ErrorEndUserMessage'],parsed['AndroidLink'],parsed['IOSLink']); + } + if (!parsed['IsAuthenticated']) { if (body['OTP_SendType'] != null) { onFailure(getError(parsed), statusCode); - } else if(!isAllowAny){ + } else if (!isAllowAny) { await helpers.logout(); helpers.showErrorToast('Your session expired Please login agian'); } - if(isAllowAny){ + if (isAllowAny) { onFailure(getError(parsed), statusCode); } } else if (parsed['MessageStatus'] == 1) { @@ -218,6 +222,9 @@ class BaseAppClient { if (parsed['Response_Message'] != null) { onSuccess(parsed, statusCode); } else { + if (parsed['ErrorType'] == 4) { + navigateToUpdatePage(parsed['ErrorEndUserMessage'],parsed['AndroidLink'],parsed['IOSLink']); + } if (parsed['IsAuthenticated'] == null) { if (parsed['isSMSSent'] == true) { onSuccess(parsed, statusCode); @@ -280,6 +287,19 @@ class BaseAppClient { } } + navigateToUpdatePage(String message, String androidLink, iosLink) { + Navigator.pushAndRemoveUntil( + AppGlobal.CONTEX, + FadePage( + page: UpdatePage( + message: message, + androidLink: androidLink, + iosLink: iosLink, + ), + ), + (r) => false); + } + String getError(parsed) { //TODO change this fun String error = parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']; diff --git a/lib/config/config.dart b/lib/config/config.dart index 04844667..b00c3960 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -305,7 +305,7 @@ const TRANSACTION_NO = 0; const LANGUAGE_ID = 2; const STAMP = '2020-04-27T12:17:17.721Z'; const IP_ADDRESS = '9.9.9.9'; -const VERSION_ID = 5.3; +const VERSION_ID = 5.5; const CHANNEL = 9; const SESSION_ID = 'BlUSkYymTt'; const IS_LOGIN_FOR_DOCTOR_APP = true; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index ff9dcb69..d941ab2c 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -849,4 +849,6 @@ const Map> localizedValues = { "en": "Patient ID, National ID, Mobile Number", "ar": "هوية المريض ، الهوية الوطنية ، رقم الهاتف المحمول" }, + "updateNow": {"en": "Update Now", "ar": "تحديث الان"}, + "updateTheApp": {"en": "Update The App", "ar": "تحديث التطبيق"}, }; diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index 7874cc82..88539838 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -1,7 +1,9 @@ import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/models/doctor/list_doctor_working_hours_table_model.dart'; import 'package:doctor_app_flutter/routes.dart'; +import 'package:doctor_app_flutter/screens/auth/login_screen.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; +import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:doctor_app_flutter/config/config.dart'; @@ -358,10 +360,8 @@ class Helpers { String lang = await sharedPref.getString(APP_Language); await clearSharedPref(); sharedPref.setString(APP_Language, lang); - Navigator.of(AppGlobal.CONTEX).pushReplacementNamed(LOGIN); + Navigator.pushAndRemoveUntil(AppGlobal.CONTEX, FadePage(page: Loginsreen(),), (r) => false); - // TODO Fix it - // Navigator.of(AppGlobal.CONTEX).popUntil((ModalRoute.withName(LOGIN))); } String parseHtmlString(String htmlString) { diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 06b34678..e2c1da11 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -1225,6 +1225,9 @@ class TranslationBase { localizedValues['enter_credentials'][locale.languageCode]; String get patpatientIDMobilenationalientID => localizedValues['patientIDMobilenational'][locale.languageCode]; + + String get updateNow => localizedValues['updateNow'][locale.languageCode]; + String get updateTheApp => localizedValues['updateTheApp'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate {