Skip to content

Commit

Permalink
Merge pull request #19 from abc873693/develop
Browse files Browse the repository at this point in the history
Update to v0.5.1
  • Loading branch information
abc873693 authored Dec 18, 2018
2 parents f101235 + 59773d3 commit a78d3b8
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 57 deletions.
6 changes: 3 additions & 3 deletions lib/pages/home/bus/bus_reservations_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class BusReservationsPageState extends State<BusReservationsPage>
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;
Expand Down Expand Up @@ -222,7 +222,7 @@ class BusReservationsPageState extends State<BusReservationsPage>
showDialog(
context: context,
builder: (BuildContext context) =>
ProgressDialog(AppLocalizations.of(context).canceling),
ProgressDialog(app.canceling),
barrierDismissible: true);
Helper.instance
.cancelBusReservation(busReservation.cancelKey)
Expand All @@ -246,7 +246,7 @@ class BusReservationsPageState extends State<BusReservationsPage>
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;
Expand Down
6 changes: 3 additions & 3 deletions lib/pages/home/bus/bus_reserve_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class BusReservePageState extends State<BusReservePage> {
// 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;
Expand Down Expand Up @@ -315,7 +315,7 @@ class BusReservePageState extends State<BusReservePage> {
showDialog(
context: context,
builder: (BuildContext context) =>
ProgressDialog(AppLocalizations.of(context).reserving),
ProgressDialog(app.reserving),
barrierDismissible: true);
Helper.instance.bookingBusReservation(busTime.busId).then((response) {
//TODO 優化成物件
Expand All @@ -338,7 +338,7 @@ class BusReservePageState extends State<BusReservePage> {
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;
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/home/calculate_units_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class CalculateUnitsPageState extends State<CalculateUnitsPage>
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;
Expand Down Expand Up @@ -355,7 +355,7 @@ class CalculateUnitsPageState extends State<CalculateUnitsPage>
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;
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/home/course_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class CoursePageState extends State<CoursePage>
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;
Expand Down Expand Up @@ -352,7 +352,7 @@ class CoursePageState extends State<CoursePage>
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;
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/home/info/notification_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class NotificationPageState extends State<NotificationPage>
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;
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/home/score_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class ScorePageState extends State<ScorePage>
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;
Expand Down Expand Up @@ -306,7 +306,7 @@ class ScorePageState extends State<ScorePage>
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;
Expand Down
32 changes: 16 additions & 16 deletions lib/pages/home/setting_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SettingPageState extends State<SettingPage>
displayPicture = true,
vibrateCourse = false;

AppLocalizations local;
AppLocalizations app;

String appVersion = "1.0.0";

Expand All @@ -51,63 +51,63 @@ class SettingPageState extends State<SettingPage>

@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: <Widget>[
_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(
'https://www.facebook.com/954175941266264/'));
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", () {}),
]),
),
);
Expand Down
56 changes: 29 additions & 27 deletions lib/pages/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class LoginPageState extends State<LoginPage>
onPressed: _login,
color: Colors.white,
child: Text(
AppLocalizations.of(context).login,
app.login,
style: TextStyle(color: Resource.Colors.blue, fontSize: 18.0),
),
),
Expand All @@ -197,34 +197,36 @@ class LoginPageState extends State<LoginPage>
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 {
Expand Down Expand Up @@ -262,12 +264,12 @@ class LoginPageState extends State<LoginPage>

_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)
Expand All @@ -284,7 +286,7 @@ class LoginPageState extends State<LoginPage>
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;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit a78d3b8

Please sign in to comment.