diff --git a/lib/pages/home/bus/bus_reservations_page.dart b/lib/pages/home/bus/bus_reservations_page.dart index 74ab6e30..2b3f91a9 100644 --- a/lib/pages/home/bus/bus_reservations_page.dart +++ b/lib/pages/home/bus/bus_reservations_page.dart @@ -194,7 +194,7 @@ class BusReservationsPageState extends State DioError dioError = e as DioError; switch (dioError.type) { case DioErrorType.RESPONSE: - Utils.showToast(AppLocalizations.of(context).tokenExpiredContent); + Utils.showToast(app.tokenExpiredContent); Navigator.popUntil( context, ModalRoute.withName(Navigator.defaultRouteName)); break; @@ -222,7 +222,7 @@ class BusReservationsPageState extends State showDialog( context: context, builder: (BuildContext context) => - ProgressDialog(AppLocalizations.of(context).canceling), + ProgressDialog(app.canceling), barrierDismissible: true); Helper.instance .cancelBusReservation(busReservation.cancelKey) @@ -246,7 +246,7 @@ class BusReservationsPageState extends State DioError dioError = e as DioError; switch (dioError.type) { case DioErrorType.RESPONSE: - Utils.showToast(AppLocalizations.of(context).tokenExpiredContent); + Utils.showToast(app.tokenExpiredContent); Navigator.popUntil( context, ModalRoute.withName(Navigator.defaultRouteName)); break; diff --git a/lib/pages/home/bus/bus_reserve_page.dart b/lib/pages/home/bus/bus_reserve_page.dart index 9a161470..ff76851e 100644 --- a/lib/pages/home/bus/bus_reserve_page.dart +++ b/lib/pages/home/bus/bus_reserve_page.dart @@ -285,7 +285,7 @@ class BusReservePageState extends State { // dioError.message = HttpException: Connection closed before full header was received switch (dioError.type) { case DioErrorType.RESPONSE: - Utils.showToast(AppLocalizations.of(context).tokenExpiredContent); + Utils.showToast(app.tokenExpiredContent); Navigator.popUntil( context, ModalRoute.withName(Navigator.defaultRouteName)); break; @@ -315,7 +315,7 @@ class BusReservePageState extends State { showDialog( context: context, builder: (BuildContext context) => - ProgressDialog(AppLocalizations.of(context).reserving), + ProgressDialog(app.reserving), barrierDismissible: true); Helper.instance.bookingBusReservation(busTime.busId).then((response) { //TODO 優化成物件 @@ -338,7 +338,7 @@ class BusReservePageState extends State { DioError dioError = e as DioError; switch (dioError.type) { case DioErrorType.RESPONSE: - Utils.showToast(AppLocalizations.of(context).tokenExpiredContent); + Utils.showToast(app.tokenExpiredContent); Navigator.popUntil( context, ModalRoute.withName(Navigator.defaultRouteName)); break; diff --git a/lib/pages/home/calculate_units_page.dart b/lib/pages/home/calculate_units_page.dart index ddd2199f..c1de2ab4 100644 --- a/lib/pages/home/calculate_units_page.dart +++ b/lib/pages/home/calculate_units_page.dart @@ -286,7 +286,7 @@ class CalculateUnitsPageState extends State DioError dioError = e as DioError; switch (dioError.type) { case DioErrorType.RESPONSE: - Utils.showToast(AppLocalizations.of(context).tokenExpiredContent); + Utils.showToast(app.tokenExpiredContent); Navigator.popUntil( context, ModalRoute.withName(Navigator.defaultRouteName)); break; @@ -355,7 +355,7 @@ class CalculateUnitsPageState extends State if (e is DioError) { switch (e.type) { case DioErrorType.RESPONSE: - Utils.showToast(AppLocalizations.of(context).tokenExpiredContent); + Utils.showToast(app.tokenExpiredContent); Navigator.popUntil( context, ModalRoute.withName(Navigator.defaultRouteName)); break; diff --git a/lib/pages/home/course_page.dart b/lib/pages/home/course_page.dart index 1a7c1206..2fab51ff 100644 --- a/lib/pages/home/course_page.dart +++ b/lib/pages/home/course_page.dart @@ -232,7 +232,7 @@ class CoursePageState extends State DioError dioError = e as DioError; switch (dioError.type) { case DioErrorType.RESPONSE: - Utils.showToast(AppLocalizations.of(context).tokenExpiredContent); + Utils.showToast(app.tokenExpiredContent); Navigator.popUntil( context, ModalRoute.withName(Navigator.defaultRouteName)); break; @@ -352,7 +352,7 @@ class CoursePageState extends State DioError dioError = e as DioError; switch (dioError.type) { case DioErrorType.RESPONSE: - Utils.showToast(AppLocalizations.of(context).tokenExpiredContent); + Utils.showToast(app.tokenExpiredContent); Navigator.popUntil( context, ModalRoute.withName(Navigator.defaultRouteName)); break; diff --git a/lib/pages/home/info/notification_page.dart b/lib/pages/home/info/notification_page.dart index 9e492539..b0091a74 100644 --- a/lib/pages/home/info/notification_page.dart +++ b/lib/pages/home/info/notification_page.dart @@ -176,7 +176,7 @@ class NotificationPageState extends State DioError dioError = e as DioError; switch (dioError.type) { case DioErrorType.RESPONSE: - Utils.showToast(AppLocalizations.of(context).tokenExpiredContent); + Utils.showToast(app.tokenExpiredContent); Navigator.popUntil( context, ModalRoute.withName(Navigator.defaultRouteName)); break; diff --git a/lib/pages/home/score_page.dart b/lib/pages/home/score_page.dart index b0690d66..7c90454f 100644 --- a/lib/pages/home/score_page.dart +++ b/lib/pages/home/score_page.dart @@ -267,7 +267,7 @@ class ScorePageState extends State DioError dioError = e as DioError; switch (dioError.type) { case DioErrorType.RESPONSE: - Utils.showToast(AppLocalizations.of(context).tokenExpiredContent); + Utils.showToast(app.tokenExpiredContent); Navigator.popUntil( context, ModalRoute.withName(Navigator.defaultRouteName)); break; @@ -306,7 +306,7 @@ class ScorePageState extends State if (e is DioError) { switch (e.type) { case DioErrorType.RESPONSE: - Utils.showToast(AppLocalizations.of(context).tokenExpiredContent); + Utils.showToast(app.tokenExpiredContent); Navigator.popUntil( context, ModalRoute.withName(Navigator.defaultRouteName)); break; diff --git a/lib/pages/home/setting_page.dart b/lib/pages/home/setting_page.dart index e586dadd..0eb28d0d 100644 --- a/lib/pages/home/setting_page.dart +++ b/lib/pages/home/setting_page.dart @@ -33,7 +33,7 @@ class SettingPageState extends State displayPicture = true, vibrateCourse = false; - AppLocalizations local; + AppLocalizations app; String appVersion = "1.0.0"; @@ -51,51 +51,51 @@ class SettingPageState extends State @override Widget build(BuildContext context) { - local = AppLocalizations.of(context); + app = AppLocalizations.of(context); return new Scaffold( appBar: new AppBar( - title: new Text(local.settings), + title: new Text(app.settings), backgroundColor: Resource.Colors.blue, ), body: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - _titleItem(local.notificationItem), - _itemSwitch(local.courseNotify, notifyCourse, () { + _titleItem(app.notificationItem), + _itemSwitch(app.courseNotify, notifyCourse, () { notifyCourse = !notifyCourse; prefs.setBool(Constants.PREF_NOTIFY_COURSE, notifyCourse); - Utils.showToast(local.functionNotOpen); + Utils.showToast(app.functionNotOpen); //setState(() {}); }), - _itemSwitch(local.busNotify, notifyBus, () { + _itemSwitch(app.busNotify, notifyBus, () { notifyBus = !notifyBus; prefs.setBool(Constants.PREF_NOTIFY_BUS, notifyBus); - Utils.showToast(local.functionNotOpen); + Utils.showToast(app.functionNotOpen); //setState(() {}); }), Container( color: Colors.grey, height: 0.5, ), - _titleItem(local.otherSettings), - _itemSwitch(local.headPhotoSetting, displayPicture, () { + _titleItem(app.otherSettings), + _itemSwitch(app.headPhotoSetting, displayPicture, () { displayPicture = !displayPicture; prefs.setBool(Constants.PREF_DISPLAY_PICTURE, displayPicture); setState(() {}); }), - _itemSwitch(local.courseVibrate, vibrateCourse, () { + _itemSwitch(app.courseVibrate, vibrateCourse, () { vibrateCourse = !vibrateCourse; prefs.setBool(Constants.PREF_VIBRATE_COURSE, vibrateCourse); - Utils.showToast(local.functionNotOpen); + Utils.showToast(app.functionNotOpen); //setState(() {}); }), Container( color: Colors.grey, height: 0.5, ), - _titleItem(local.otherInfo), - _item(local.feedback, local.feedbackViaFacebook, () { + _titleItem(app.otherInfo), + _item(app.feedback, app.feedbackViaFacebook, () { if (Platform.isAndroid) Utils.launchUrl('fb://messaging/954175941266264').catchError( (onError) => Utils.launchUrl( @@ -103,11 +103,11 @@ class SettingPageState extends State else Utils.launchUrl('https://www.facebook.com/954175941266264/'); }), - _item(local.donateTitle, local.donateContent, () { + _item(app.donateTitle, app.donateContent, () { Utils.launchUrl( "https://payment.ecpay.com.tw/QuickCollect/PayData?mLM7iy8RpUGk%2fyBotSDMdvI0qGI5ToToqBW%2bOQbOE80%3d"); }), - _item(local.appVersion, "v$appVersion", () {}), + _item(app.appVersion, "v$appVersion", () {}), ]), ), ); diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index 86e3e845..af902549 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -173,7 +173,7 @@ class LoginPageState extends State onPressed: _login, color: Colors.white, child: Text( - AppLocalizations.of(context).login, + app.login, style: TextStyle(color: Resource.Colors.blue, fontSize: 18.0), ), ), @@ -197,34 +197,36 @@ class LoginPageState extends State if (currentVersion != packageInfo.buildNumber) Utils.showDefaultDialog( context, - AppLocalizations.of(context).updateNoteTitle, + app.updateNoteTitle, "v${packageInfo.version}\n" - "${AppLocalizations.of(context).updateNoteContent}", - AppLocalizations.of(context).ok, () { + "${app.updateNoteContent}", + app.ok, () { prefs.setString( Constants.PREF_CURRENT_VERSION, packageInfo.buildNumber); }); - final RemoteConfig remoteConfig = await RemoteConfig.instance; - await remoteConfig.fetch(expiration: const Duration(seconds: 10)); - await remoteConfig.activateFetched(); - String url = ""; - int versionDiff = 0; - if (Platform.isAndroid) { - url = "market://details?id=${packageInfo.packageName}"; - versionDiff = remoteConfig.getInt(Constants.ANDROID_APP_VERSION) - - int.parse(packageInfo.buildNumber); - } else if (Platform.isIOS) { - url = "itms-apps://itunes.apple.com/tw/app/apple-store/id1439751462?mt=8"; - versionDiff = remoteConfig.getInt(Constants.IOS_APP_VERSION) - - int.parse(packageInfo.buildNumber); - } else { - url = "https://www.facebook.com/NKUST.ITC/"; - versionDiff = remoteConfig.getInt(Constants.APP_VERSION) - - int.parse(packageInfo.buildNumber); + if(!Constants.isInDebugMode){ + final RemoteConfig remoteConfig = await RemoteConfig.instance; + await remoteConfig.fetch(expiration: const Duration(seconds: 10)); + await remoteConfig.activateFetched(); + String url = ""; + int versionDiff = 0; + if (Platform.isAndroid) { + url = "market://details?id=${packageInfo.packageName}"; + versionDiff = remoteConfig.getInt(Constants.ANDROID_APP_VERSION) - + int.parse(packageInfo.buildNumber); + } else if (Platform.isIOS) { + url = "itms-apps://itunes.apple.com/tw/app/apple-store/id1439751462?mt=8"; + versionDiff = remoteConfig.getInt(Constants.IOS_APP_VERSION) - + int.parse(packageInfo.buildNumber); + } else { + url = "https://www.facebook.com/NKUST.ITC/"; + versionDiff = remoteConfig.getInt(Constants.APP_VERSION) - + int.parse(packageInfo.buildNumber); + } + if (versionDiff < 5 && versionDiff > 0) + Utils.showUpdateDialog(context, url); + else if (versionDiff >= 5) Utils.showForceUpdateDialog(context, url); } - if (versionDiff < 5 && versionDiff > 0) - Utils.showUpdateDialog(context, url); - else if (versionDiff >= 5) Utils.showForceUpdateDialog(context, url); } _onRememberPasswordChanged(bool value) async { @@ -262,12 +264,12 @@ class LoginPageState extends State _login() async { if (_username.text.isEmpty || _password.text.isEmpty) { - Utils.showToast(AppLocalizations.of(context).doNotEmpty); + Utils.showToast(app.doNotEmpty); } else { showDialog( context: context, builder: (BuildContext context) => - ProgressDialog(AppLocalizations.of(context).logining), + ProgressDialog(app.logining), barrierDismissible: true); prefs.setString(Constants.PREF_USERNAME, _username.text); if (isRememberPassword) @@ -284,7 +286,7 @@ class LoginPageState extends State DioError dioError = e as DioError; switch (dioError.type) { case DioErrorType.RESPONSE: - Utils.showToast(AppLocalizations.of(context).loginFail); + Utils.showToast(app.loginFail); break; case DioErrorType.CANCEL: break; diff --git a/pubspec.yaml b/pubspec.yaml index cc97b087..c4ab3da3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: nkust_ap description: A new Flutter application. -version: 0.5.0+500 +version: 0.5.1+501 environment: sdk: ">=2.0.0-dev.68.0 <3.0.0"