Skip to content

Commit

Permalink
Merge pull request #13 from abc873693/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
abc873693 authored Dec 12, 2018
2 parents b857134 + 1742dda commit eec49c0
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 118 deletions.
Binary file added assets/images/drawer-backbroud.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/drawer-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions lib/pages/home/bus/bus_reserve_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,12 @@ class BusReservePageState extends State<BusReservePage>
break;
case DioErrorType.DEFAULT:
if (dioError.message.contains("HttpException")) {
setState(() {
state = BusReserveState.error;
Utils.showToast(local.busFailInfinity);
});
if (mounted) {
setState(() {
state = BusReserveState.error;
Utils.showToast(local.busFailInfinity);
});
}
}
break;
case DioErrorType.CANCEL:
Expand Down
30 changes: 22 additions & 8 deletions lib/pages/home/bus_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ import 'package:nkust_ap/pages/page.dart';
import 'package:nkust_ap/utils/app_localizations.dart';

class BusPageRoute extends MaterialPageRoute {
BusPageRoute() : super(builder: (BuildContext context) => new BusPage());
BusPageRoute({this.initIndex = 0})
: super(
builder: (BuildContext context) =>
new BusPage(initIndex: initIndex));

final int initIndex;

@override
Widget buildPage(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
return new FadeTransition(opacity: animation, child: new BusPage());
return new FadeTransition(
opacity: animation, child: new BusPage(initIndex: initIndex));
}
}

Expand All @@ -23,27 +29,32 @@ class BusPage extends StatefulWidget {
new BusReservePage(),
new BusReservationsPage()
];
final int initIndex;

BusPage({this.initIndex = 0});

@override
BusPageState createState() => new BusPageState(_children);
BusPageState createState() => new BusPageState(_children, initIndex);
}

class BusPageState extends State<BusPage>
with SingleTickerProviderStateMixin {
class BusPageState extends State<BusPage> with SingleTickerProviderStateMixin {
final List<Widget> _children;
final int initIndex;
int _currentIndex = 0;
List<String> _title;

AppLocalizations local;

TabController controller;

BusPageState(this._children);
BusPageState(this._children, this.initIndex) {
_currentIndex = initIndex;
}

@override
void initState() {
super.initState();
controller = TabController(length: 2, vsync: this);
controller = TabController(length: 2, initialIndex: initIndex, vsync: this);
}

@override
Expand All @@ -63,7 +74,10 @@ class BusPageState extends State<BusPage>
title: new Text(_title[_currentIndex]),
backgroundColor: Resource.Colors.blue,
),
body: TabBarView(children: _children,controller: controller,physics: new NeverScrollableScrollPhysics()),
body: TabBarView(
children: _children,
controller: controller,
physics: new NeverScrollableScrollPhysics()),
bottomNavigationBar: new BottomNavigationBar(
currentIndex: _currentIndex,
onTap: onTabTapped,
Expand Down
36 changes: 19 additions & 17 deletions lib/pages/home/score_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class ScorePageState extends State<ScorePage>
Widget _scoreTextBorder(String text, bool isTitle) {
return Container(
width: double.maxFinite,
padding: EdgeInsets.symmetric(vertical:2.0,horizontal: 4.0),
padding: EdgeInsets.symmetric(vertical: 2.0, horizontal: 4.0),
alignment: Alignment.center,
child: Text(
text ?? "",
Expand Down Expand Up @@ -310,22 +310,24 @@ class ScorePageState extends State<ScorePage>
}
});
}).catchError((e) {
assert(e is DioError);
DioError dioError = e as DioError;
switch (dioError.type) {
case DioErrorType.RESPONSE:
Utils.showToast(AppLocalizations.of(context).tokenExpiredContent);
Navigator.popUntil(
context, ModalRoute.withName(Navigator.defaultRouteName));
break;
case DioErrorType.CANCEL:
break;
default:
setState(() {
state = ScoreState.error;
Utils.handleDioError(dioError, local);
});
break;
if (e is DioError) {
switch (e.type) {
case DioErrorType.RESPONSE:
Utils.showToast(AppLocalizations.of(context).tokenExpiredContent);
Navigator.popUntil(
context, ModalRoute.withName(Navigator.defaultRouteName));
break;
case DioErrorType.CANCEL:
break;
default:
setState(() {
state = ScoreState.error;
Utils.handleDioError(e, local);
});
break;
}
} else {
throw e;
}
});
} else {
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class LoginPageState extends State<LoginPage>
onTap: () => _onChanged(!isRememberPassword),
),
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(24.0))),
padding: EdgeInsets.all(12.0),
onPressed: _login,
color: Colors.grey[300],
Expand Down
4 changes: 3 additions & 1 deletion lib/utils/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ class AppLocalizations {
'course': '學期課表',
'score': '學期成績',
'leave': '缺曠系統',
'bus': '校車系統',
'bus': '校車系統(建工/燕巢)',
'simcourse': '模擬選課',
'school_info': '校園資訊',
'notifications': '最新消息',
Expand Down Expand Up @@ -728,6 +728,8 @@ class AppLocalizations {
String get reserving => _vocabularies['reserving'];

String get canceling => _vocabularies['canceling'];

String get logout => _vocabularies['logout'];
}

class AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
Expand Down
Loading

0 comments on commit eec49c0

Please sign in to comment.