Skip to content

Commit

Permalink
Improve bus time arrived text
Browse files Browse the repository at this point in the history
  • Loading branch information
abc873693 committed Feb 22, 2021
1 parent 9dde4fc commit f96b2ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/pages/bus/bus_time_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:flutter/material.dart';
import 'package:nsysu_ap/api/bus_helper.dart';
import 'package:nsysu_ap/models/bus_info.dart';
import 'package:nsysu_ap/models/bus_time.dart';
import 'package:nsysu_ap/utils/app_localizations.dart';

enum _State { loading, finish, error }

Expand Down Expand Up @@ -160,8 +161,14 @@ class BusTimeItem extends StatelessWidget {

@override
Widget build(BuildContext context) {
final postfix = int.tryParse(busTime.arrivedTime ?? '') == null
? ''
: ' ${AppLocalizations.of(context).minute}';
return ListTile(
leading: Container(
constraints: BoxConstraints(
minWidth: 65.0,
),
decoration: BoxDecoration(
border: Border.all(
width: 1.0,
Expand All @@ -175,12 +182,13 @@ class BusTimeItem extends StatelessWidget {
),
padding: EdgeInsets.all(8.0),
child: Text(
busTime.arrivedTime,
'${busTime.arrivedTime ?? ''}$postfix',
style: TextStyle(
color: busTime.arrivedTime == '進站中'
? Colors.red
: ApTheme.of(context).greyText,
),
textAlign: TextAlign.center,
),
),
title: Text(busTime.name ?? ''),
Expand Down
4 changes: 4 additions & 0 deletions lib/utils/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class AppLocalizations {

static Locale locale;

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

static AppLocalizations of(BuildContext context) {
return Localizations.of<AppLocalizations>(context, AppLocalizations);
}
Expand Down Expand Up @@ -122,6 +124,7 @@ class AppLocalizations {
'hasPreScoreHint': 'Yellow Text not final score, proved by instructor.',
'pleaseConfirmForm': 'Please fill out confirm form before login.',
'bus': 'Bus System',
'minute': 'Min',
},
'zh': {
'app_name': '中山校務通',
Expand Down Expand Up @@ -156,6 +159,7 @@ class AppLocalizations {
'hasPreScoreHint': '黃字為授課老師開放成績查詢 並非最終成績',
'pleaseConfirmForm': '請先填寫確認表單再進行登入',
'bus': '校園公車',
'minute': '分',
},
};
}
Expand Down

0 comments on commit f96b2ae

Please sign in to comment.