diff --git a/assets/images/dash_line_dark_theme.webp b/assets/images/dash_line_dark_theme.webp
new file mode 100644
index 00000000..2b5510cd
Binary files /dev/null and b/assets/images/dash_line_dark_theme.webp differ
diff --git a/assets/images/drawer-backbroud.webp b/assets/images/drawer-background.webp
similarity index 100%
rename from assets/images/drawer-backbroud.webp
rename to assets/images/drawer-background.webp
diff --git a/ios/Podfile b/ios/Podfile
index 2dfb5019..48accee4 100644
--- a/ios/Podfile
+++ b/ios/Podfile
@@ -56,6 +56,9 @@ target 'Runner' do
}
end
+# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
+install! 'cocoapods', :disable_input_output_paths => true
+
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index b27dc4a8..653fbbf5 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -248,42 +248,9 @@
files = (
);
inputPaths = (
- "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
- "${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework",
- "${PODS_ROOT}/../.symlinks/flutter/ios-release/Flutter.framework",
- "${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework",
- "${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework",
- "${BUILT_PRODUCTS_DIR}/Reachability/Reachability.framework",
- "${BUILT_PRODUCTS_DIR}/add_2_calendar/add_2_calendar.framework",
- "${BUILT_PRODUCTS_DIR}/app_review/app_review.framework",
- "${BUILT_PRODUCTS_DIR}/connectivity/connectivity.framework",
- "${BUILT_PRODUCTS_DIR}/flutter_local_notifications/flutter_local_notifications.framework",
- "${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
- "${BUILT_PRODUCTS_DIR}/package_info/package_info.framework",
- "${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework",
- "${BUILT_PRODUCTS_DIR}/share/share.framework",
- "${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework",
- "${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework",
- "${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Reachability.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/add_2_calendar.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/app_review.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/connectivity.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_local_notifications.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/package_info.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/share.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework",
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
diff --git a/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
index 949b6789..0c67376e 100644
--- a/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
+++ b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
@@ -1,8 +1,5 @@
-
- BuildSystemType
- Original
-
+
diff --git a/lib/config/constants.dart b/lib/config/constants.dart
index 5aafcc41..c849f7a8 100644
--- a/lib/config/constants.dart
+++ b/lib/config/constants.dart
@@ -36,6 +36,7 @@ class Constants {
static const PREF_BUS_RESERVATIONS_DATA = "pref_bus_reservevations_data";
static const PREF_LANGUAGE_CODE = 'pref_language_code';
+ static const PREF_THEME_CODE = 'pref_theme_code';
static const PREF_AP_ENABLE = "pref_ap_enable";
static const PREF_BUS_ENABLE = "pref_bus_enable";
diff --git a/lib/main.dart b/lib/main.dart
index a57a9eb4..9a2c6d5f 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -12,7 +12,7 @@ import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:nkust_ap/config/constants.dart';
import 'package:nkust_ap/pages/home/bus/bus_rule_page.dart';
import 'package:nkust_ap/pages/page.dart';
-import 'package:nkust_ap/res/resource.dart' as Resource;
+import 'package:nkust_ap/res/app_theme.dart';
import 'package:nkust_ap/utils/app_localizations.dart';
import 'package:nkust_ap/utils/firebase_analytics_utils.dart';
import 'package:nkust_ap/utils/preferences.dart';
@@ -21,6 +21,13 @@ import 'package:nkust_ap/widgets/share_data_widget.dart';
void main() async {
bool isInDebugMode = Constants.isInDebugMode;
+ String themeCode = AppTheme.LIGHT;
+ if (Platform.isIOS || Platform.isAndroid) {
+ await Preferences.init();
+ themeCode =
+ Preferences.getString(Constants.PREF_THEME_CODE, AppTheme.LIGHT);
+ }
+ AppTheme.code = themeCode;
if (Platform.isIOS || Platform.isAndroid) {
FlutterError.onError = (FlutterErrorDetails details) {
if (isInDebugMode) {
@@ -36,7 +43,11 @@ void main() async {
await FlutterCrashlytics().initialize();
runZoned>(() async {
- runApp(MyApp());
+ runApp(
+ MyApp(
+ themeData: AppTheme.data,
+ ),
+ );
}, onError: (error, stackTrace) async {
// Whenever an error occurs, call the `reportCrash` function. This will send
// Dart errors to our dev console or Crashlytics depending on the environment.
@@ -46,23 +57,38 @@ void main() async {
} else {
// See https://github.com/flutter/flutter/wiki/Desktop-shells#target-platform-override
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
- runApp(MyApp());
+ runApp(
+ MyApp(
+ themeData: AppTheme.data,
+ ),
+ );
//TODO add other platform Crashlytics
}
}
class MyApp extends StatefulWidget {
+ final ThemeData themeData;
+
+ const MyApp({Key key, @required this.themeData}) : super(key: key);
+
@override
- _MyAppState createState() => _MyAppState();
+ MyAppState createState() => MyAppState();
}
-class _MyAppState extends State {
+class MyAppState extends State {
FirebaseAnalytics analytics;
FirebaseMessaging _firebaseMessaging;
- Brightness brightness = Brightness.light;
+ ThemeData themeData;
+
+ setThemeData(ThemeData themeData) {
+ setState(() {
+ this.themeData = themeData;
+ });
+ }
@override
void initState() {
+ themeData = widget.themeData;
if (Platform.isAndroid || Platform.isIOS) {
analytics = FirebaseAnalytics();
_firebaseMessaging = FirebaseMessaging();
@@ -76,6 +102,7 @@ class _MyAppState extends State {
@override
Widget build(BuildContext context) {
return ShareDataWidget(
+ this,
child: MaterialApp(
localeResolutionCallback:
(Locale locale, Iterable supportedLocales) {
@@ -102,18 +129,7 @@ class _MyAppState extends State {
NewsContentPage(null),
LeavePage.routerName: (BuildContext context) => LeavePage(),
},
- theme: ThemeData(
- brightness: brightness,
- hintColor: Colors.white,
- accentColor: Resource.Colors.blue,
- unselectedWidgetColor: Resource.Colors.grey,
- backgroundColor: Colors.black12,
- inputDecorationTheme: InputDecorationTheme(
- labelStyle: TextStyle(color: Colors.white),
- border: UnderlineInputBorder(
- borderSide: BorderSide(color: Colors.white)),
- ),
- ),
+ theme: themeData,
navigatorObservers: (Platform.isIOS || Platform.isAndroid)
? [
FirebaseAnalyticsObserver(analytics: analytics),
@@ -123,7 +139,7 @@ class _MyAppState extends State {
const AppLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
- CupertinoEnDefaultLocalizationsDelegate(),
+ GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
const Locale('en', 'US'), // English
diff --git a/lib/models/bus_data.dart b/lib/models/bus_data.dart
index f0260a1e..8650ff20 100644
--- a/lib/models/bus_data.dart
+++ b/lib/models/bus_data.dart
@@ -120,8 +120,8 @@ class BusTime {
Color getColorState() {
return isReserve == 1
- ? Resource.Colors.blue
- : canReserve() ? Resource.Colors.grey : Colors.grey[400];
+ ? Resource.Colors.blueAccent
+ : canReserve() ? Resource.Colors.grey : Resource.Colors.disabled;
}
String getReserveState(AppLocalizations local) {
diff --git a/lib/pages/home/about/about_us_page.dart b/lib/pages/home/about/about_us_page.dart
index 94dbf48b..5f53c00e 100644
--- a/lib/pages/home/about/about_us_page.dart
+++ b/lib/pages/home/about/about_us_page.dart
@@ -1,6 +1,7 @@
import 'dart:io';
import 'package:flutter/material.dart';
+import 'package:nkust_ap/res/assets.dart';
import 'package:nkust_ap/res/resource.dart' as Resource;
import 'package:nkust_ap/utils/global.dart';
@@ -62,7 +63,7 @@ class AboutUsPageState extends State
backgroundColor: Resource.Colors.blue,
flexibleSpace: FlexibleSpaceBar(
background: Image.asset(
- "assets/images/kuasap2.webp",
+ ImageAssets.kuasap2,
fit: BoxFit.cover,
),
),
@@ -84,7 +85,7 @@ class AboutUsPageState extends State
child: Align(
alignment: Alignment.topRight,
child: Image.asset(
- "assets/images/kuas_itc.webp",
+ ImageAssets.kuasITC,
width: 64.0,
fit: BoxFit.cover,
),
@@ -116,7 +117,7 @@ class AboutUsPageState extends State
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
- icon: Image.asset("assets/images/ic_fb.webp"),
+ icon: Image.asset(ImageAssets.fb),
onPressed: () {
if (Platform.isAndroid)
Utils.launchUrl('fb://page/735951703168873')
@@ -136,7 +137,7 @@ class AboutUsPageState extends State
iconSize: 48.0,
),
IconButton(
- icon: Image.asset("assets/images/ic_github.webp"),
+ icon: Image.asset(ImageAssets.github),
onPressed: () {
if (Platform.isAndroid)
Utils.launchUrl(
@@ -154,7 +155,7 @@ class AboutUsPageState extends State
iconSize: 48.0,
),
IconButton(
- icon: Image.asset("assets/images/ic_email.webp"),
+ icon: Image.asset(ImageAssets.email),
onPressed: () {
Utils.launchUrl('mailto:abc873693@gmail.com')
.catchError((onError) => Utils.showToast(
diff --git a/lib/pages/home/bus/bus_reservations_page.dart b/lib/pages/home/bus/bus_reservations_page.dart
index 038344b6..26057d52 100644
--- a/lib/pages/home/bus/bus_reservations_page.dart
+++ b/lib/pages/home/bus/bus_reservations_page.dart
@@ -135,7 +135,7 @@ class BusReservationsPageState extends State
child: Icon(
Icons.directions_bus,
size: 20.0,
- color: Resource.Colors.blue,
+ color: Resource.Colors.blueAccent,
),
),
Expanded(
@@ -172,21 +172,20 @@ class BusReservationsPageState extends State
context: context,
builder: (BuildContext context) =>
YesNoDialog(
- title: app.busCancelReserve,
- contentWidget: Text(
- "${app.busCancelReserveConfirmContent1}${busReservation.getStart(app)}"
- "${app.busCancelReserveConfirmContent2}${busReservation.getEnd(app)}\n"
- "${busReservation.getTime()}${app.busCancelReserveConfirmContent3}",
- textAlign: TextAlign.center,
- ),
- leftActionText: app.back,
- rightActionText: app.determine,
- rightActionFunction: () {
- _cancelBusReservation(
- busReservation);
- FA.logAction('cancel_bus', 'click');
- },
- ),
+ title: app.busCancelReserve,
+ contentWidget: Text(
+ "${app.busCancelReserveConfirmContent1}${busReservation.getStart(app)}"
+ "${app.busCancelReserveConfirmContent2}${busReservation.getEnd(app)}\n"
+ "${busReservation.getTime()}${app.busCancelReserveConfirmContent3}",
+ textAlign: TextAlign.center,
+ ),
+ leftActionText: app.back,
+ rightActionText: app.determine,
+ rightActionFunction: () {
+ _cancelBusReservation(busReservation);
+ FA.logAction('cancel_bus', 'click');
+ },
+ ),
);
FA.logAction('cancel_bus', 'create');
},
diff --git a/lib/pages/home/bus/bus_reserve_page.dart b/lib/pages/home/bus/bus_reserve_page.dart
index 864332e2..66c2fe67 100644
--- a/lib/pages/home/bus/bus_reserve_page.dart
+++ b/lib/pages/home/bus/bus_reserve_page.dart
@@ -114,8 +114,8 @@ class BusReservePageState extends State
child: ConstrainedBox(
constraints: BoxConstraints(minWidth: double.infinity),
child: CupertinoSegmentedControl(
- selectedColor: Resource.Colors.blue,
- borderColor: Resource.Colors.blue,
+ selectedColor: Resource.Colors.blueAccent,
+ borderColor: Resource.Colors.blueAccent,
groupValue: selectStartStation,
children: {
Station.janGong: Container(
@@ -216,44 +216,42 @@ class BusReservePageState extends State
showDialog(
context: context,
builder: (BuildContext context) => YesNoDialog(
- title: '${busTime.getSpecialTrainTitle(app)}'
- '${busTime.specialTrain == "0" ? app.reserve : ""}',
- contentWidget: RichText(
- textAlign: TextAlign.center,
- text: TextSpan(
+ title: '${busTime.getSpecialTrainTitle(app)}'
+ '${busTime.specialTrain == "0" ? app.reserve : ""}',
+ contentWidget: RichText(
+ textAlign: TextAlign.center,
+ text: TextSpan(
+ style: TextStyle(
+ color: Resource.Colors.grey,
+ height: 1.3,
+ fontSize: 16.0),
+ children: [
+ TextSpan(
+ text: '${busTime.getTime()} $start\n',
+ style: TextStyle(fontWeight: FontWeight.bold),
+ ),
+ TextSpan(
+ text:
+ '${busTime.getSpecialTrainRemark()}${app.busReserveConfirmTitle}\n',
style: TextStyle(
color: Resource.Colors.grey,
height: 1.3,
- fontSize: 16.0),
- children: [
- TextSpan(
- text: '${busTime.getTime()} $start\n',
- style: TextStyle(
- fontWeight: FontWeight.bold),
- ),
- TextSpan(
- text:
- '${busTime.getSpecialTrainRemark()}${app.busReserveConfirmTitle}\n',
- style: TextStyle(
- color: Resource.Colors.grey,
- height: 1.3,
- fontSize: 14.0),
- ),
- TextSpan(
- text: '${app.reserveDeadline}:\n',
- style: TextStyle(
- fontWeight: FontWeight.bold)),
- TextSpan(
- text: '${busTime.endEnrollDateTime}'),
- ]),
- ),
- leftActionText: app.cancel,
- rightActionText: app.reserve,
- leftActionFunction: null,
- rightActionFunction: () {
- _bookingBus(busTime);
- },
- ),
+ fontSize: 14.0),
+ ),
+ TextSpan(
+ text: '${app.reserveDeadline}:\n',
+ style:
+ TextStyle(fontWeight: FontWeight.bold)),
+ TextSpan(text: '${busTime.endEnrollDateTime}'),
+ ]),
+ ),
+ leftActionText: app.cancel,
+ rightActionText: app.reserve,
+ leftActionFunction: null,
+ rightActionFunction: () {
+ _bookingBus(busTime);
+ },
+ ),
);
}
: busTime.isReserve != 0
@@ -261,20 +259,20 @@ class BusReservePageState extends State
showDialog(
context: context,
builder: (BuildContext context) => YesNoDialog(
- title: app.busCancelReserve,
- contentWidget: Text(
- "${app.busCancelReserveConfirmContent1}${busTime.getStart(app)}"
- "${app.busCancelReserveConfirmContent2}${busTime.getEnd(app)}\n"
- "${busTime.getTime()}${app.busCancelReserveConfirmContent3}",
- textAlign: TextAlign.center,
- ),
- leftActionText: app.back,
- rightActionText: app.determine,
- rightActionFunction: () {
- _cancelBusReservation(busTime);
- FA.logAction('cancel_bus', 'click');
- },
- ),
+ title: app.busCancelReserve,
+ contentWidget: Text(
+ "${app.busCancelReserveConfirmContent1}${busTime.getStart(app)}"
+ "${app.busCancelReserveConfirmContent2}${busTime.getEnd(app)}\n"
+ "${busTime.getTime()}${app.busCancelReserveConfirmContent3}",
+ textAlign: TextAlign.center,
+ ),
+ leftActionText: app.back,
+ rightActionText: app.determine,
+ rightActionFunction: () {
+ _cancelBusReservation(busTime);
+ FA.logAction('cancel_bus', 'click');
+ },
+ ),
);
FA.logAction('cancel_bus', 'create');
}
diff --git a/lib/pages/home/bus/bus_rule_page.dart b/lib/pages/home/bus/bus_rule_page.dart
index d27254b3..535b3405 100644
--- a/lib/pages/home/bus/bus_rule_page.dart
+++ b/lib/pages/home/bus/bus_rule_page.dart
@@ -58,9 +58,9 @@ class BusRulePageState extends State
TextSpan(
text: '預約校車\n',
style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 24.0,
- color: Colors.black),
+ fontWeight: FontWeight.bold,
+ fontSize: 24.0,
+ ),
),
TextSpan(
text: "• 請上 ",
@@ -68,7 +68,7 @@ class BusRulePageState extends State
TextSpan(
text: "http://bus.kuas.edu.tw/",
style: TextStyle(
- color: Resource.Colors.blue,
+ color: Resource.Colors.blueAccent,
decoration: TextDecoration.underline,
),
recognizer: TapGestureRecognizer()
@@ -98,16 +98,16 @@ class BusRulePageState extends State
TextSpan(
text: '上車\n',
style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 24.0,
- color: Colors.black),
+ fontWeight: FontWeight.bold,
+ fontSize: 24.0,
+ ),
),
TextSpan(
text: "• 每次上車繳款20元",
),
TextSpan(
text: '(未發卡前先以投幣繳費,請自備20元銅板投幣)\n',
- style: TextStyle(color: Resource.Colors.blue),
+ style: TextStyle(color: Resource.Colors.blueText),
),
TextSpan(
text: "• 請持學生證或教職員證(未發卡前先採用身分證識別)上車\n",
@@ -131,9 +131,9 @@ class BusRulePageState extends State
TextSpan(
text: '候補上車\n',
style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 24.0,
- color: Colors.black),
+ fontWeight: FontWeight.bold,
+ fontSize: 24.0,
+ ),
),
TextSpan(
text: "• 未依預約的班次搭乘者,視為違規,計違規點數一次(例如:8:20與9:30視為不同班次)\n" +
@@ -142,9 +142,9 @@ class BusRulePageState extends State
TextSpan(
text: '罰款\n',
style: TextStyle(
- fontWeight: FontWeight.bold,
- color: Colors.black,
- fontSize: 24.0),
+ fontWeight: FontWeight.bold,
+ fontSize: 24.0,
+ ),
),
TextSpan(
text: "• 違規罰款金額計算,違規前三次不計點,從第四次開始違規記點,每點應繳納等同車資之罰款\n" +
diff --git a/lib/pages/home/course_page.dart b/lib/pages/home/course_page.dart
index 6850a389..66614358 100644
--- a/lib/pages/home/course_page.dart
+++ b/lib/pages/home/course_page.dart
@@ -81,30 +81,27 @@ class CoursePageState extends State
Text(
selectSemester == null ? "" : selectSemester.text,
style: TextStyle(
- color: Resource.Colors.blue, fontSize: 18.0),
+ color: Resource.Colors.semesterText, fontSize: 18.0),
),
SizedBox(width: 8.0),
Icon(
Icons.keyboard_arrow_down,
- color: Resource.Colors.blue,
+ color: Resource.Colors.semesterText,
)
],
),
),
- SizedBox(height: 4.0),
- Container(
- child: isOffline
- ? Text(
- app.offlineCourse,
- style: TextStyle(color: Resource.Colors.grey),
- )
- : null,
+ Text(
+ '${isOffline ? app.offlineCourse + ' ' : ''}'
+ '${app.courseClickHint}',
+ style: TextStyle(color: Resource.Colors.grey),
),
+ SizedBox(height: 4.0),
Expanded(
child: RefreshIndicator(
onRefresh: () async {
if (isOffline) await Helper.instance.initByPreference();
- _getCourseTables();
+ await _getCourseTables();
FA.logAction('refresh', 'swipe');
return null;
},
@@ -144,7 +141,6 @@ class CoursePageState extends State
content: app.noOfflineData,
);
default:
- var list = renderCourseList();
return SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
@@ -166,7 +162,7 @@ class CoursePageState extends State
width: 0,
),
),
- children: list,
+ children: renderCourseList(),
),
),
);
@@ -235,7 +231,7 @@ class CoursePageState extends State
alignment: Alignment.center,
child: Text(
text ?? '',
- style: TextStyle(color: Resource.Colors.blue, fontSize: 12.0),
+ style: TextStyle(color: Resource.Colors.blueText, fontSize: 12.0),
),
);
}
@@ -246,40 +242,38 @@ class CoursePageState extends State
showDialog(
context: context,
builder: (BuildContext context) => DefaultDialog(
- title: app.courseDialogTitle,
- actionText: app.iKnow,
- actionFunction: () =>
- Navigator.of(context, rootNavigator: true).pop('dialog'),
- contentWidget: RichText(
- text: TextSpan(
- style: TextStyle(
- color: Resource.Colors.grey,
- height: 1.3,
- fontSize: 16.0),
- children: [
- TextSpan(
- text: '${app.courseDialogName}:',
- style: TextStyle(fontWeight: FontWeight.bold)),
- TextSpan(text: '${course.title}\n'),
- TextSpan(
- text: '${app.courseDialogProfessor}:',
- style: TextStyle(fontWeight: FontWeight.bold)),
- TextSpan(text: '${course.getInstructors()}\n'),
- TextSpan(
- text: '${app.courseDialogLocation}:',
- style: TextStyle(fontWeight: FontWeight.bold)),
- TextSpan(
- text:
- '${course.location.building}${course.location.room}\n'),
- TextSpan(
- text: '${app.courseDialogTime}:',
- style: TextStyle(fontWeight: FontWeight.bold)),
- TextSpan(
- text:
- '${course.date.startTime}-${course.date.endTime}'),
- ]),
- ),
- ),
+ title: app.courseDialogTitle,
+ actionText: app.iKnow,
+ actionFunction: () =>
+ Navigator.of(context, rootNavigator: true).pop('dialog'),
+ contentWidget: RichText(
+ text: TextSpan(
+ style: TextStyle(
+ color: Resource.Colors.grey, height: 1.3, fontSize: 16.0),
+ children: [
+ TextSpan(
+ text: '${app.courseDialogName}:',
+ style: TextStyle(fontWeight: FontWeight.bold)),
+ TextSpan(text: '${course.title}\n'),
+ TextSpan(
+ text: '${app.courseDialogProfessor}:',
+ style: TextStyle(fontWeight: FontWeight.bold)),
+ TextSpan(text: '${course.getInstructors()}\n'),
+ TextSpan(
+ text: '${app.courseDialogLocation}:',
+ style: TextStyle(fontWeight: FontWeight.bold)),
+ TextSpan(
+ text:
+ '${course.location.building}${course.location.room}\n'),
+ TextSpan(
+ text: '${app.courseDialogTime}:',
+ style: TextStyle(fontWeight: FontWeight.bold)),
+ TextSpan(
+ text:
+ '${course.date.startTime}-${course.date.endTime}'),
+ ]),
+ ),
+ ),
);
FA.logAction('show_course', 'click');
},
@@ -288,7 +282,7 @@ class CoursePageState extends State
alignment: Alignment.center,
child: Text(
(course.title[0] + course.title[1]) ?? "",
- style: TextStyle(color: Colors.black, fontSize: 14.0),
+ style: TextStyle(fontSize: 14.0),
),
),
);
@@ -320,7 +314,7 @@ class CoursePageState extends State
break;
default:
state = _State.error;
- Utils.handleDioError(context, e);
+ if (mounted) Utils.handleDioError(context, e);
break;
}
} else {
@@ -377,6 +371,7 @@ class CoursePageState extends State
setState(() {
selectSemesterIndex = position;
selectSemester = semesterData.semesters[selectSemesterIndex];
+ state = _State.loading;
});
SharedPreferences prefs = await SharedPreferences.getInstance();
if (prefs.getBool(Constants.PREF_IS_OFFLINE_LOGIN))
@@ -398,11 +393,6 @@ class CoursePageState extends State
_getCourseTables() async {
Helper.cancelToken.cancel("");
Helper.cancelToken = CancelToken();
- if (mounted) {
- setState(() {
- state = _State.loading;
- });
- }
if (semesterData == null) {
_getSemester();
return;
diff --git a/lib/pages/home/info/notification_page.dart b/lib/pages/home/info/notification_page.dart
index 07766ce7..eac0c662 100644
--- a/lib/pages/home/info/notification_page.dart
+++ b/lib/pages/home/info/notification_page.dart
@@ -58,8 +58,7 @@ class NotificationPageState extends State
}
_textStyle() {
- return TextStyle(
- color: Colors.black, fontSize: 18.0, fontWeight: FontWeight.bold);
+ return TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold);
}
Widget _notificationItem(NotificationModel notification) {
diff --git a/lib/pages/home/info/phone_page.dart b/lib/pages/home/info/phone_page.dart
index c2d63a50..1e3172e2 100644
--- a/lib/pages/home/info/phone_page.dart
+++ b/lib/pages/home/info/phone_page.dart
@@ -50,7 +50,7 @@ class PhonePageState extends State
_textBlueStyle() {
return TextStyle(
- color: Resource.Colors.blue,
+ color: Resource.Colors.blueText,
fontSize: 18.0,
fontWeight: FontWeight.bold);
}
@@ -60,8 +60,7 @@ class PhonePageState extends State
}
_textStyle() {
- return TextStyle(
- color: Colors.black, fontSize: 18.0, fontWeight: FontWeight.bold);
+ return TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold);
}
Widget _phoneItem(PhoneModel phone) {
diff --git a/lib/pages/home/info/schedule_page.dart b/lib/pages/home/info/schedule_page.dart
index 3bc701dd..85c40bbc 100644
--- a/lib/pages/home/info/schedule_page.dart
+++ b/lib/pages/home/info/schedule_page.dart
@@ -134,13 +134,13 @@ class SchedulePageState extends State
_textBlueStyle() {
return TextStyle(
- color: Resource.Colors.blue,
+ color: Resource.Colors.blueText,
fontSize: 18.0,
fontWeight: FontWeight.bold);
}
_textStyle() {
- return TextStyle(color: Colors.black, fontSize: 16.0);
+ return TextStyle(fontSize: 16.0);
}
List _scheduleItem(ScheduleData schedule) {
@@ -188,29 +188,29 @@ class SchedulePageState extends State
showDialog(
context: context,
builder: (BuildContext context) => YesNoDialog(
- title: app.events,
- contentWidget: RichText(
- textAlign: TextAlign.center,
- text: TextSpan(
- style: TextStyle(
- color: Resource.Colors.grey,
- height: 1.3,
- fontSize: 16.0),
- children: [
- TextSpan(
- text: sprintf(app.addCalendarContent,
- [schedule.events[index]]),
- ),
- ]),
- ),
- leftActionText: app.cancel,
- rightActionText: app.determine,
- leftActionFunction: null,
- rightActionFunction: () {
- _addToCalendar(schedule.events[index]);
- FA.logAction('add_schedule', 'click');
- },
- ),
+ title: app.events,
+ contentWidget: RichText(
+ textAlign: TextAlign.center,
+ text: TextSpan(
+ style: TextStyle(
+ color: Resource.Colors.grey,
+ height: 1.3,
+ fontSize: 16.0),
+ children: [
+ TextSpan(
+ text: sprintf(app.addCalendarContent,
+ [schedule.events[index]]),
+ ),
+ ]),
+ ),
+ leftActionText: app.cancel,
+ rightActionText: app.determine,
+ leftActionFunction: null,
+ rightActionFunction: () {
+ _addToCalendar(schedule.events[index]);
+ FA.logAction('add_schedule', 'click');
+ },
+ ),
);
},
child: Container(
diff --git a/lib/pages/home/leaves/leave_record_page.dart b/lib/pages/home/leaves/leave_record_page.dart
index b6373fbe..059e3663 100644
--- a/lib/pages/home/leaves/leave_record_page.dart
+++ b/lib/pages/home/leaves/leave_record_page.dart
@@ -67,11 +67,11 @@ class LeaveRecordPageState extends State
}
_textBlueStyle() {
- return TextStyle(color: Resource.Colors.blue, fontSize: 16.0);
+ return TextStyle(color: Resource.Colors.blueText, fontSize: 16.0);
}
_textStyle() {
- return TextStyle(color: Colors.black, fontSize: 14.0);
+ return TextStyle(fontSize: 14.0);
}
_leaveTitle(List timeCodes) {
@@ -111,34 +111,31 @@ class LeaveRecordPageState extends State
showDialog(
context: context,
builder: (BuildContext context) => DefaultDialog(
- title: app.leaveContent,
- actionText: app.iKnow,
- actionFunction: () =>
- Navigator.of(context, rootNavigator: true)
- .pop('dialog'),
- contentWidget: RichText(
- text: TextSpan(
- style: TextStyle(
- color: Resource.Colors.grey,
- height: 1.3,
- fontSize: 16.0),
- children: [
- TextSpan(
- text: '${app.leaveSheetId}:',
- style:
- TextStyle(fontWeight: FontWeight.bold)),
- TextSpan(text: '${leave.leaveSheetId}\n'),
- TextSpan(
- text: '${app.instructorsComment}:'
- '${leave.instructorsComment.length < 8 ? '' : '\n'}',
- style:
- TextStyle(fontWeight: FontWeight.bold)),
- TextSpan(
- text:
- '${leave.instructorsComment.replaceAll(':', ' ')}'),
- ]),
- ),
- ),
+ title: app.leaveContent,
+ actionText: app.iKnow,
+ actionFunction: () =>
+ Navigator.of(context, rootNavigator: true).pop('dialog'),
+ contentWidget: RichText(
+ text: TextSpan(
+ style: TextStyle(
+ color: Resource.Colors.grey,
+ height: 1.3,
+ fontSize: 16.0),
+ children: [
+ TextSpan(
+ text: '${app.leaveSheetId}:',
+ style: TextStyle(fontWeight: FontWeight.bold)),
+ TextSpan(text: '${leave.leaveSheetId}\n'),
+ TextSpan(
+ text: '${app.instructorsComment}:'
+ '${leave.instructorsComment.length < 8 ? '' : '\n'}',
+ style: TextStyle(fontWeight: FontWeight.bold)),
+ TextSpan(
+ text:
+ '${leave.instructorsComment.replaceAll(':', ' ')}'),
+ ]),
+ ),
+ ),
);
},
));
@@ -171,12 +168,13 @@ class LeaveRecordPageState extends State
children: [
Text(
selectSemester == null ? "" : selectSemester.text,
- style: TextStyle(color: Resource.Colors.blue, fontSize: 18.0),
+ style: TextStyle(
+ color: Resource.Colors.semesterText, fontSize: 18.0),
),
SizedBox(width: 8.0),
Icon(
Icons.keyboard_arrow_down,
- color: Resource.Colors.blue,
+ color: Resource.Colors.semesterText,
)
],
),
diff --git a/lib/pages/home/news_content_page.dart b/lib/pages/home/news_content_page.dart
index 40adc0cb..c620d76d 100644
--- a/lib/pages/home/news_content_page.dart
+++ b/lib/pages/home/news_content_page.dart
@@ -117,7 +117,7 @@ class NewsContentPageState extends State
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20.0,
- color: Resource.Colors.grey,
+ color: Resource.Colors.greyText,
fontWeight: FontWeight.w500),
),
),
@@ -132,7 +132,7 @@ class NewsContentPageState extends State
child: Text(
news.content,
textAlign: TextAlign.center,
- style: TextStyle(fontSize: 16.0, color: Resource.Colors.grey),
+ style: TextStyle(fontSize: 16.0, color: Resource.Colors.greyText),
),
),
SizedBox(height: 16.0),
diff --git a/lib/pages/home/score_page.dart b/lib/pages/home/score_page.dart
index 2fcf6ce5..23679ddf 100644
--- a/lib/pages/home/score_page.dart
+++ b/lib/pages/home/score_page.dart
@@ -78,13 +78,13 @@ class ScorePageState extends State
children: [
Text(
selectSemester == null ? "" : selectSemester.text,
- style:
- TextStyle(color: Resource.Colors.blue, fontSize: 18.0),
+ style: TextStyle(
+ color: Resource.Colors.semesterText, fontSize: 18.0),
),
SizedBox(width: 8.0),
Icon(
Icons.keyboard_arrow_down,
- color: Resource.Colors.blue,
+ color: Resource.Colors.semesterText,
)
],
),
@@ -206,11 +206,11 @@ class ScorePageState extends State
}
_textBlueStyle() {
- return TextStyle(color: Resource.Colors.blue, fontSize: 16.0);
+ return TextStyle(color: Resource.Colors.blueText, fontSize: 16.0);
}
_textStyle() {
- return TextStyle(color: Colors.black, fontSize: 14.0);
+ return TextStyle(fontSize: 14.0);
}
_scoreTitle() => TableRow(
@@ -229,7 +229,7 @@ class ScorePageState extends State
border: Border(
top: isTop
? BorderSide.none
- : BorderSide(color: Colors.grey, width: 0.5),
+ : BorderSide(color: Resource.Colors.grey, width: 0.5),
),
),
child: Text(
@@ -303,12 +303,14 @@ class ScorePageState extends State
return;
}
Helper.instance.getSemester().then((semesterData) {
- setState(() {
- this.semesterData = semesterData;
- selectSemester = semesterData.defaultSemester;
- selectSemesterIndex = semesterData.defaultIndex;
- });
- _getSemesterScore();
+ if (mounted) {
+ setState(() {
+ this.semesterData = semesterData;
+ selectSemester = semesterData.defaultSemester;
+ selectSemesterIndex = semesterData.defaultIndex;
+ });
+ _getSemesterScore();
+ }
CacheUtils.saveSemesterData(semesterData);
}).catchError((e) {
if (e is DioError) {
@@ -415,16 +417,18 @@ class ScorePageState extends State
_loadOfflineScoreData() async {
scoreData = await CacheUtils.loadScoreData(
semesterData.semesters[selectSemesterIndex].value);
- setState(() {
- isOffline = true;
- if (scoreData == null)
- state = _State.offlineEmpty;
- else if (scoreData.status == 204)
- state = _State.empty;
- else {
- _renderScoreDataWidget();
- state = _State.finish;
- }
- });
+ if (mounted) {
+ setState(() {
+ isOffline = true;
+ if (scoreData == null)
+ state = _State.offlineEmpty;
+ else if (scoreData.status == 204)
+ state = _State.empty;
+ else {
+ _renderScoreDataWidget();
+ state = _State.finish;
+ }
+ });
+ }
}
}
diff --git a/lib/pages/home/setting_page.dart b/lib/pages/home/setting_page.dart
index 1b35fc4a..94f045d5 100644
--- a/lib/pages/home/setting_page.dart
+++ b/lib/pages/home/setting_page.dart
@@ -6,11 +6,13 @@ import 'package:flutter/material.dart';
import 'package:nkust_ap/models/bus_reservations_data.dart';
import 'package:nkust_ap/models/course_data.dart';
import 'package:nkust_ap/models/semester_data.dart';
+import 'package:nkust_ap/res/app_theme.dart';
import 'package:nkust_ap/res/resource.dart' as Resource;
import 'package:nkust_ap/utils/cache_utils.dart';
import 'package:nkust_ap/utils/global.dart';
import 'package:nkust_ap/utils/preferences.dart';
import 'package:nkust_ap/widgets/progress_dialog.dart';
+import 'package:nkust_ap/widgets/share_data_widget.dart';
import 'package:package_info/package_info.dart';
class SettingPageRoute extends MaterialPageRoute {
@@ -144,6 +146,51 @@ class SettingPageState extends State {
AppLocalizations.languageCode = languageCode;
});
});
+ FA.logAction('pick_language', 'click');
+ },
+ ),
+ _item(
+ app.theme,
+ app.themeText,
+ () {
+ showDialog(
+ context: context,
+ builder: (BuildContext context) => SimpleDialog(
+ title: Text(app.theme),
+ children: [
+ SimpleDialogOption(
+ child: Text(app.light),
+ onPressed: () {
+ AppTheme.code = AppTheme.LIGHT;
+ ShareDataWidget.of(context)
+ .data
+ .setThemeData(AppTheme.light);
+ setState(() {
+ AppLocalizations.themeCode = AppTheme.LIGHT;
+ });
+ if (Platform.isAndroid || Platform.isIOS)
+ Preferences.setString(
+ Constants.PREF_THEME_CODE, AppTheme.LIGHT);
+ Navigator.pop(context);
+ }),
+ SimpleDialogOption(
+ child: Text(app.dark),
+ onPressed: () {
+ AppTheme.code = AppTheme.DARK;
+ ShareDataWidget.of(context)
+ .data
+ .setThemeData(AppTheme.dark);
+ setState(() {
+ AppLocalizations.themeCode = AppTheme.DARK;
+ });
+ if (Platform.isAndroid || Platform.isIOS)
+ Preferences.setString(
+ Constants.PREF_THEME_CODE, AppTheme.DARK);
+ Navigator.pop(context);
+ })
+ ]),
+ ).then((int position) {});
+ FA.logAction('pick_theme', 'click');
},
),
Divider(
@@ -201,7 +248,7 @@ class SettingPageState extends State {
padding: EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0),
child: Text(
text,
- style: TextStyle(color: Resource.Colors.blue, fontSize: 14.0),
+ style: TextStyle(color: Resource.Colors.blueText, fontSize: 14.0),
textAlign: TextAlign.start,
),
);
@@ -215,10 +262,11 @@ class SettingPageState extends State {
),
subtitle: Text(
subText,
- style: TextStyle(fontSize: 14.0, color: Resource.Colors.grey),
+ style: TextStyle(fontSize: 14.0, color: Resource.Colors.greyText),
),
value: value,
onChanged: function,
+ activeColor: Resource.Colors.blueAccent,
);
Widget _item(String text, String subText, Function function) => ListTile(
@@ -228,7 +276,7 @@ class SettingPageState extends State {
),
subtitle: Text(
subText,
- style: TextStyle(fontSize: 14.0, color: Resource.Colors.grey),
+ style: TextStyle(fontSize: 14.0, color: Resource.Colors.greyText),
),
onTap: function,
);
@@ -401,7 +449,8 @@ class SettingPageState extends State {
alignment: Alignment.center,
child: Text(
app.ratingDialogTitle,
- style: TextStyle(color: Resource.Colors.blue, fontSize: 20.0),
+ style: TextStyle(
+ color: Resource.Colors.blueText, fontSize: 20.0),
),
),
),
diff --git a/lib/pages/home/user_info_page.dart b/lib/pages/home/user_info_page.dart
index 4367a1bc..177ede09 100644
--- a/lib/pages/home/user_info_page.dart
+++ b/lib/pages/home/user_info_page.dart
@@ -157,14 +157,14 @@ class UserInfoPageState extends State
}
}
}).catchError((e) {
- assert(e is DioError);
- DioError dioError = e as DioError;
- switch (dioError.type) {
- case DioErrorType.RESPONSE:
- Utils.handleResponseError(context, 'getUserPicture', mounted, e);
- break;
- default:
- break;
+ if (e is DioError) {
+ switch (e.type) {
+ case DioErrorType.RESPONSE:
+ Utils.handleResponseError(context, 'getUserPicture', mounted, e);
+ break;
+ default:
+ break;
+ }
}
});
} else {
diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart
index f4ea1404..2cf4e3a5 100644
--- a/lib/pages/home_page.dart
+++ b/lib/pages/home_page.dart
@@ -188,7 +188,7 @@ class HomePageState extends State {
);
}),
bottomNavigationBar: BottomNavigationBar(
- fixedColor: Color(0xff737373),
+ fixedColor: Resource.Colors.bottomNavigationSelect,
type: BottomNavigationBarType.fixed,
currentIndex: _currentTabIndex,
onTap: onTabTapped,
@@ -312,6 +312,7 @@ class HomePageState extends State {
userInfo = response;
});
FA.setUserProperty('department', userInfo.department);
+ FA.setUserProperty('student_id', userInfo.studentId);
FA.setUserId(userInfo.studentId);
FA.logUserInfo(userInfo.department);
CacheUtils.saveUserInfo(userInfo);
@@ -335,17 +336,17 @@ class HomePageState extends State {
showDialog(
context: context,
builder: (BuildContext context) => YesNoDialog(
- title: app.logout,
- contentWidget: Text(app.logoutCheck,
- textAlign: TextAlign.center,
- style: TextStyle(color: Resource.Colors.grey)),
- leftActionText: app.cancel,
- rightActionText: app.ok,
- rightActionFunction: () {
- Navigator.popUntil(
- context, ModalRoute.withName(Navigator.defaultRouteName));
- },
- ),
+ title: app.logout,
+ contentWidget: Text(app.logoutCheck,
+ textAlign: TextAlign.center,
+ style: TextStyle(color: Resource.Colors.greyText)),
+ leftActionText: app.cancel,
+ rightActionText: app.ok,
+ rightActionFunction: () {
+ Navigator.popUntil(
+ context, ModalRoute.withName(Navigator.defaultRouteName));
+ },
+ ),
);
}
@@ -354,42 +355,42 @@ class HomePageState extends State {
showDialog(
context: context,
builder: (BuildContext context) => YesNoDialog(
- title: app.newsRuleTitle,
- contentWidget: RichText(
- text: TextSpan(
- style: TextStyle(color: Resource.Colors.grey, fontSize: 16.0),
- children: [
- TextSpan(
- text: '${app.newsRuleDescription1}',
- style: TextStyle(fontWeight: FontWeight.normal)),
- TextSpan(
- text: '${app.newsRuleDescription2}',
- style: TextStyle(fontWeight: FontWeight.bold)),
- TextSpan(
- text: '${app.newsRuleDescription3}',
- style: TextStyle(fontWeight: FontWeight.normal)),
- ]),
- ),
- leftActionText: app.cancel,
- rightActionText: app.contactFansPage,
- leftActionFunction: () {},
- rightActionFunction: () {
- if (Platform.isAndroid)
- Utils.launchUrl('fb://messaging/${Constants.FANS_PAGE_ID}')
- .catchError(
- (onError) => Utils.launchUrl(Constants.FANS_PAGE_URL));
- else if (Platform.isIOS)
- Utils.launchUrl(
- 'fb-messenger://user-thread/${Constants.FANS_PAGE_ID}')
- .catchError(
- (onError) => Utils.launchUrl(Constants.FANS_PAGE_URL));
- else {
- Utils.launchUrl(Constants.FANS_PAGE_URL).catchError(
- (onError) => Utils.showToast(context, app.platformError));
- }
- FA.logAction('contact_fans_page', 'click');
- },
- ),
+ title: app.newsRuleTitle,
+ contentWidget: RichText(
+ text: TextSpan(
+ style: TextStyle(color: Resource.Colors.grey, fontSize: 16.0),
+ children: [
+ TextSpan(
+ text: '${app.newsRuleDescription1}',
+ style: TextStyle(fontWeight: FontWeight.normal)),
+ TextSpan(
+ text: '${app.newsRuleDescription2}',
+ style: TextStyle(fontWeight: FontWeight.bold)),
+ TextSpan(
+ text: '${app.newsRuleDescription3}',
+ style: TextStyle(fontWeight: FontWeight.normal)),
+ ]),
+ ),
+ leftActionText: app.cancel,
+ rightActionText: app.contactFansPage,
+ leftActionFunction: () {},
+ rightActionFunction: () {
+ if (Platform.isAndroid)
+ Utils.launchUrl('fb://messaging/${Constants.FANS_PAGE_ID}')
+ .catchError(
+ (onError) => Utils.launchUrl(Constants.FANS_PAGE_URL));
+ else if (Platform.isIOS)
+ Utils.launchUrl(
+ 'fb-messenger://user-thread/${Constants.FANS_PAGE_ID}')
+ .catchError(
+ (onError) => Utils.launchUrl(Constants.FANS_PAGE_URL));
+ else {
+ Utils.launchUrl(Constants.FANS_PAGE_URL).catchError(
+ (onError) => Utils.showToast(context, app.platformError));
+ }
+ FA.logAction('contact_fans_page', 'click');
+ },
+ ),
);
}
}
diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart
index 5863bce0..7d779a94 100644
--- a/lib/pages/login_page.dart
+++ b/lib/pages/login_page.dart
@@ -5,12 +5,12 @@ import 'package:encrypt/encrypt.dart';
import 'package:firebase_remote_config/firebase_remote_config.dart';
import 'package:flutter/material.dart';
import 'package:nkust_ap/models/api/login_response.dart';
+import 'package:nkust_ap/res/assets.dart';
import 'package:nkust_ap/res/colors.dart' as Resource;
import 'package:nkust_ap/utils/global.dart';
import 'package:nkust_ap/widgets/default_dialog.dart';
import 'package:nkust_ap/widgets/drawer_body.dart';
import 'package:nkust_ap/widgets/progress_dialog.dart';
-import 'package:nkust_ap/widgets/share_data_widget.dart';
import 'package:nkust_ap/widgets/yes_no_dialog.dart';
import 'package:package_info/package_info.dart';
import 'package:shared_preferences/shared_preferences.dart';
@@ -90,7 +90,7 @@ class LoginPageState extends State
? [
Center(
child: Image.asset(
- "assets/images/K.webp",
+ ImageAssets.K,
width: 120.0,
height: 120.0,
),
@@ -100,7 +100,7 @@ class LoginPageState extends State
: [
Expanded(
child: Image.asset(
- "assets/images/K.webp",
+ ImageAssets.K,
width: 120.0,
height: 120.0,
),
@@ -235,17 +235,17 @@ class LoginPageState extends State
showDialog(
context: context,
builder: (BuildContext context) => DefaultDialog(
- title: app.updateNoteTitle,
- contentWidget: Text(
- "v${packageInfo.version}\n"
- "${app.updateNoteContent}",
- textAlign: TextAlign.center,
- style: TextStyle(color: Resource.Colors.grey),
- ),
- actionText: app.iKnow,
- actionFunction: () =>
- Navigator.of(context, rootNavigator: true).pop('dialog'),
- ),
+ title: app.updateNoteTitle,
+ contentWidget: Text(
+ "v${packageInfo.version}\n"
+ "${app.updateNoteContent}",
+ textAlign: TextAlign.center,
+ style: TextStyle(color: Resource.Colors.grey),
+ ),
+ actionText: app.iKnow,
+ actionFunction: () =>
+ Navigator.of(context, rootNavigator: true).pop('dialog'),
+ ),
);
prefs.setString(Constants.PREF_CURRENT_VERSION, packageInfo.buildNumber);
}
@@ -285,7 +285,36 @@ class LoginPageState extends State
showDialog(
context: context,
builder: (BuildContext context) => YesNoDialog(
+ title: app.updateTitle,
+ contentWidget: RichText(
+ textAlign: TextAlign.center,
+ text: TextSpan(
+ style: TextStyle(
+ color: Resource.Colors.grey, height: 1.3, fontSize: 16.0),
+ children: [
+ TextSpan(
+ text:
+ '${Utils.getPlatformUpdateContent(app)}\n${versionContent.replaceAll('\\n', '\n')}',
+ style: TextStyle(fontWeight: FontWeight.bold),
+ ),
+ ]),
+ ),
+ leftActionText: app.skip,
+ rightActionText: app.update,
+ leftActionFunction: null,
+ rightActionFunction: () {
+ Utils.launchUrl(url);
+ },
+ ),
+ );
+ } else if (versionDiff >= 5) {
+ showDialog(
+ context: context,
+ barrierDismissible: false,
+ builder: (BuildContext context) => WillPopScope(
+ child: DefaultDialog(
title: app.updateTitle,
+ actionText: app.update,
contentWidget: RichText(
textAlign: TextAlign.center,
text: TextSpan(
@@ -295,49 +324,18 @@ class LoginPageState extends State
fontSize: 16.0),
children: [
TextSpan(
- text:
- '${Utils.getPlatformUpdateContent(app)}\n${versionContent.replaceAll('\\n', '\n')}',
- style: TextStyle(fontWeight: FontWeight.bold),
- ),
+ text:
+ '${Utils.getPlatformUpdateContent(app)}\n${versionContent.replaceAll('\\n', '\n')}',
+ style: TextStyle(fontWeight: FontWeight.bold)),
]),
),
- leftActionText: app.skip,
- rightActionText: app.update,
- leftActionFunction: null,
- rightActionFunction: () {
+ actionFunction: () {
Utils.launchUrl(url);
- },
- ),
- );
- } else if (versionDiff >= 5) {
- showDialog(
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) => WillPopScope(
- child: DefaultDialog(
- title: app.updateTitle,
- actionText: app.update,
- contentWidget: RichText(
- textAlign: TextAlign.center,
- text: TextSpan(
- style: TextStyle(
- color: Resource.Colors.grey,
- height: 1.3,
- fontSize: 16.0),
- children: [
- TextSpan(
- text:
- '${Utils.getPlatformUpdateContent(app)}\n${versionContent.replaceAll('\\n', '\n')}',
- style: TextStyle(fontWeight: FontWeight.bold)),
- ]),
- ),
- actionFunction: () {
- Utils.launchUrl(url);
- }),
- onWillPop: () async {
- return false;
- },
- ),
+ }),
+ onWillPop: () async {
+ return false;
+ },
+ ),
);
}
}
@@ -471,8 +469,6 @@ class LoginPageState extends State
else {
prefs.setBool(Constants.PREF_IS_OFFLINE_LOGIN, true);
Utils.showToast(context, app.loadOfflineData);
- ShareDataWidget.of(context).username =
- prefs.getString(Constants.PREF_USERNAME);
_navigateToFilterObject(context);
}
}
diff --git a/lib/res/app_theme.dart b/lib/res/app_theme.dart
new file mode 100644
index 00000000..d03c0bf4
--- /dev/null
+++ b/lib/res/app_theme.dart
@@ -0,0 +1,50 @@
+import 'package:flutter/material.dart';
+
+import 'colors.dart' as Resource;
+
+class AppTheme {
+ static const String DARK = 'dark';
+ static const String LIGHT = 'light';
+
+ static String code = AppTheme.LIGHT;
+
+ static ThemeData get data {
+ switch (AppTheme.code) {
+ case AppTheme.DARK:
+ return dark;
+ case AppTheme.LIGHT:
+ default:
+ return light;
+ }
+ }
+
+ static ThemeData get light => ThemeData(
+ brightness: Brightness.light,
+ appBarTheme: AppBarTheme(
+ color: Resource.Colors.blue,
+ ),
+ accentColor: Resource.Colors.blueText,
+ unselectedWidgetColor: Resource.Colors.grey,
+ backgroundColor: Colors.black12,
+ inputDecorationTheme: InputDecorationTheme(
+ labelStyle: TextStyle(color: Colors.white),
+ border: UnderlineInputBorder(
+ borderSide: BorderSide(color: Colors.white),
+ ),
+ ),
+ );
+
+ static ThemeData get dark => ThemeData(
+ brightness: Brightness.dark,
+ scaffoldBackgroundColor: Resource.Colors.onyx,
+ accentColor: Resource.Colors.blueAccent,
+ unselectedWidgetColor: Resource.Colors.grey,
+ backgroundColor: Colors.black12,
+ inputDecorationTheme: InputDecorationTheme(
+ labelStyle: TextStyle(color: Colors.white),
+ border: UnderlineInputBorder(
+ borderSide: BorderSide(color: Colors.white),
+ ),
+ ),
+ );
+}
diff --git a/lib/res/assets.dart b/lib/res/assets.dart
new file mode 100644
index 00000000..30c70944
--- /dev/null
+++ b/lib/res/assets.dart
@@ -0,0 +1,27 @@
+import 'app_theme.dart';
+
+class ImageAssets {
+ static const String basePath = 'assets/images';
+
+ static const String kuasap1 = '$basePath/kuasap.webp';
+ static const String kuasap2 = '$basePath/kuasap2.webp';
+ static const String kuasap3 = '$basePath/kuasap3.webp';
+ static const String kuasITC = '$basePath/kuas_itc.webp';
+ static const String fb = '$basePath/ic_fb.webp';
+ static const String github = '$basePath/ic_github.webp';
+ static const String email = '$basePath/ic_email.webp';
+ static const String drawerBackground = '$basePath/drawer-background.webp';
+ static const String drawerIcon = '$basePath/drawer-icon.webp';
+ static const String K = '$basePath/K.webp';
+ static const String dashLineLight = '$basePath/dash_line.webp';
+ static const String dashLineDarkTheme = '$basePath/dash_line_dark_theme.webp';
+ static String get dashLine {
+ switch (AppTheme.code) {
+ case AppTheme.DARK:
+ return dashLineDarkTheme;
+ case AppTheme.LIGHT:
+ default:
+ return dashLineLight;
+ }
+ }
+}
diff --git a/lib/res/colors.dart b/lib/res/colors.dart
index 6724d1a9..453a2123 100644
--- a/lib/res/colors.dart
+++ b/lib/res/colors.dart
@@ -1,10 +1,139 @@
import 'package:flutter/material.dart';
+import 'app_theme.dart';
+
class Colors {
Colors._();
- static const Color blue = const Color(0xff2574ff);
- static const Color grey = const Color(0xff7c7c7c);
- static const Color yellow = const Color(0xffffba00);
- static const Color red = const Color(0xffff4a5a);
+ static Color get blue {
+ switch (AppTheme.code) {
+ case AppTheme.DARK:
+ return blueDark;
+ case AppTheme.LIGHT:
+ default:
+ return blue500;
+ }
+ }
+
+ static Color get blueText {
+ switch (AppTheme.code) {
+ case AppTheme.DARK:
+ return grayChateau;
+ case AppTheme.LIGHT:
+ default:
+ return blue500;
+ }
+ }
+
+ static get blueAccent {
+ switch (AppTheme.code) {
+ case AppTheme.DARK:
+ return blue300;
+ case AppTheme.LIGHT:
+ default:
+ return blue500;
+ }
+ }
+
+ static get semesterText {
+ switch (AppTheme.code) {
+ case AppTheme.DARK:
+ return Color(0xffffffff);
+ case AppTheme.LIGHT:
+ default:
+ return blue500;
+ }
+ }
+
+ static Color get grey {
+ switch (AppTheme.code) {
+ case AppTheme.DARK:
+ return grey200;
+ case AppTheme.LIGHT:
+ default:
+ return grey500;
+ }
+ }
+
+ static Color get greyText {
+ switch (AppTheme.code) {
+ case AppTheme.DARK:
+ return grey200;
+ case AppTheme.LIGHT:
+ default:
+ return grey500;
+ }
+ }
+
+ static get disabled {
+ switch (AppTheme.code) {
+ case AppTheme.DARK:
+ return Color(0xFF424242);
+ case AppTheme.LIGHT:
+ default:
+ return Color(0xFFBDBDBD);
+ }
+ }
+
+ static Color get calendarTileSelect {
+ switch (AppTheme.code) {
+ case AppTheme.DARK:
+ return Color(0xff000000);
+ case AppTheme.LIGHT:
+ default:
+ return Color(0xffffffff);
+ }
+ }
+
+ static Color get yellow {
+ switch (AppTheme.code) {
+ case AppTheme.DARK:
+ return yellow200;
+ case AppTheme.LIGHT:
+ default:
+ return yellow500;
+ }
+ }
+
+ static Color get red {
+ switch (AppTheme.code) {
+ case AppTheme.DARK:
+ return red200;
+ case AppTheme.LIGHT:
+ default:
+ return red500;
+ }
+ }
+
+ static Color get bottomNavigationSelect {
+ switch (AppTheme.code) {
+ case AppTheme.DARK:
+ return Color(0xffc1c1c1);
+ case AppTheme.LIGHT:
+ default:
+ return Color(0xff737373);
+ }
+ }
+
+ static const Color blueDark = const Color(0xff131a25);
+ static const Color onyx = const Color(0xff121212);
+ static const Color grayChateau = const Color(0xffa5a5a5);
+
+ static const Color blue200 = const Color(0xffa7c7ff);
+ static const Color blue300 = const Color(0xff7cabff);
+ static const Color blue400 = const Color(0xff508fff);
+ static const Color blue500 = const Color(0xff2574ff);
+ static const Color blue800 = const Color(0xff0e2e66);
+
+ static const Color grey200 = const Color(0xffbdbdbd);
+ static const Color grey500 = const Color(0xff7c7c7c);
+ static const Color grey800 = const Color(0xff313131);
+
+ static const Color yellow200 = const Color(0xffffe399);
+ static const Color yellow500 = const Color(0xffffba00);
+ static const Color yellow800 = const Color(0xff664a00);
+
+ static const Color red200 = const Color(0xffffb6bd);
+ static const Color red500 = const Color(0xffff4a5a);
+ static const Color red800 = const Color(0xff661d24);
}
diff --git a/lib/utils/app_localizations.dart b/lib/utils/app_localizations.dart
index 4c71f486..aae41cb9 100644
--- a/lib/utils/app_localizations.dart
+++ b/lib/utils/app_localizations.dart
@@ -16,6 +16,7 @@ class AppLocalizations {
static Locale locale;
static String languageCode = 'system';
+ static String themeCode = 'light';
static AppLocalizations of(BuildContext context) {
return Localizations.of(context, AppLocalizations);
@@ -32,11 +33,23 @@ class AppLocalizations {
}
}
+ String get themeText {
+ switch (themeCode) {
+ case 'light':
+ return light;
+ case 'dark':
+ return dark;
+ default:
+ return systemLanguage;
+ }
+ }
+
static Map> _localizedValues = {
'en': {
'app_name': 'NKUST AP',
'update_note_title': 'Update Notes',
- 'update_note_content': '1.Imporve some UI.\n2.Fix some error.',
+ 'update_note_content':
+ '1.Add dark theme.\n2.Imporve some UI.\n3.Fix some error.',
'splash_content': '我們全都包了\n只剩下學校不包我們',
'share': 'Share',
'teacher_confirm_title': 'Are you a teacher?',
@@ -129,6 +142,7 @@ class AppLocalizations {
'course_dialog_time': 'Time',
'course_dialog_title': 'Class Info',
'course_holiday': 'Rotate Screen to see weekend schedule %s',
+ 'courseClickHint': 'Click subject show more.',
'no_internet': 'No internet connection',
'setting_internet': 'Internet Settings',
'score_no_score':
@@ -314,12 +328,16 @@ class AppLocalizations {
'This feature provides information about the school or student\'s publication of the school.\n\nPlease contact the fan page if you need it\n',
'newsRuleDescription2':
'1. Image and upload to imgur, please use JPEG compressed file. It is recommended not to exceed 100KB. \n2. The title suggests placing the name of the event, not too long. \n3. Activity URL link. \n4. Description of the content. \n5. Must be a non-profit activity.\n\n',
- 'newsRuleDescription3': 'The NKUST AP team has the final right to modify.'
+ 'newsRuleDescription3':
+ 'The NKUST AP team has the final right to modify.',
+ 'theme': 'Theme',
+ 'light': 'Light',
+ 'dark': 'Dark',
},
'zh': {
'app_name': '高科校務通',
'update_note_title': '更新日誌',
- 'update_note_content': '1.優化部分介面\n2.修正部分錯誤',
+ 'update_note_content': '1.新增深色主題\n2.優化部分介面\n3.修正部分錯誤',
'splash_content': '我們全都包了\n只剩下學校不包我們',
'share': '分享',
'teacher_confirm_title': '您是老師嗎?',
@@ -405,6 +423,7 @@ class AppLocalizations {
'course_dialog_time': '上課時間',
'course_dialog_title': '課程資訊',
'course_holiday': '旋轉橫向即可查看周末課表 %s',
+ 'courseClickHint': '點擊科目名稱可看詳細資訊',
'no_internet': '沒有網路連線,請檢查你的網路',
'setting_internet': '設定網路',
'score_no_score': 'Oops!本學期沒有任何成績資料哦~\n請選擇其他學期 \uD83D\uDE0B',
@@ -580,7 +599,10 @@ class AppLocalizations {
'newsRuleDescription1': '本功能提供社團或學生\n刊登學校相關資訊\n\n若需要請聯絡粉絲專頁並提供\n',
'newsRuleDescription2':
'1. 圖片且上傳至 imgur\n請使用JPEG有壓縮過的檔案\n建議不要超過100KB\n2. 標題建議放活動名稱,不要太長\n3. 活動網址連結\n4. 內容說明\n5.必須為非營利活動\n\n',
- 'newsRuleDescription3': '高科校務通團隊有最終修改權利'
+ 'newsRuleDescription3': '高科校務通團隊有最終修改權利',
+ 'theme': '主題',
+ 'light': '淺色',
+ 'dark': '深色',
},
};
@@ -770,6 +792,8 @@ class AppLocalizations {
String get courseDialogTitle => _vocabularies['course_dialog_title'];
+ String get courseClickHint => _vocabularies['courseClickHint'];
+
String get mon => _vocabularies['mon'];
String get tue => _vocabularies['tue'];
@@ -1041,6 +1065,12 @@ class AppLocalizations {
String get newsRuleDescription2 => _vocabularies['newsRuleDescription2'];
String get newsRuleDescription3 => _vocabularies['newsRuleDescription3'];
+
+ String get theme => _vocabularies['theme'];
+
+ String get dark => _vocabularies['dark'];
+
+ String get light => _vocabularies['light'];
}
class AppLocalizationsDelegate extends LocalizationsDelegate {
diff --git a/lib/widgets/calendar_tile.dart b/lib/widgets/calendar_tile.dart
index d4a00c58..07f67158 100644
--- a/lib/widgets/calendar_tile.dart
+++ b/lib/widgets/calendar_tile.dart
@@ -47,7 +47,9 @@ class CalendarTile extends StatelessWidget {
alignment: Alignment.center,
child: new Text(
DateUtils.formatDay(date).toString(),
- style: isSelected ? new TextStyle(color: Colors.white) : dateStyles,
+ style: isSelected
+ ? new TextStyle(color: Resource.Colors.calendarTileSelect)
+ : dateStyles,
textAlign: TextAlign.center,
),
),
diff --git a/lib/widgets/carousel.dart b/lib/widgets/carousel.dart
deleted file mode 100644
index 6cd26201..00000000
--- a/lib/widgets/carousel.dart
+++ /dev/null
@@ -1,92 +0,0 @@
-import 'package:flutter/material.dart';
-import 'dart:async';
-
-class Carousel extends StatefulWidget {
- ///All the [Widget] on this Carousel.
- final List children;
-
- ///Returns [children]`s [lenght].
- int get childrenCount => children.length;
-
- ///The transition animation timing curve. Default is [Curves.ease]
- final Curve animationCurve;
-
- ///The transition animation duration. Default is 250ms.
- final Duration animationDuration;
-
- ///The amount of time each frame is displayed. Default is 2s.
- final Duration displayDuration;
-
- Carousel(
- {this.children,
- this.animationCurve = Curves.ease,
- this.animationDuration = const Duration(milliseconds: 250),
- this.displayDuration = const Duration(seconds: 2)})
- : assert(children != null),
- assert(children.length > 1),
- assert(animationCurve != null),
- assert(animationDuration != null),
- assert(displayDuration != null);
-
- @override
- State createState() => new _CarouselState();
-}
-
-class _CarouselState extends State
- with SingleTickerProviderStateMixin {
- TabController _controller;
- Timer _timer;
-
- ///Actual index of the displaying Widget
- int get actualIndex => _controller.index;
-
- ///Returns the calculated value of the next index.
- int get nextIndex {
- var nextIndexValue = actualIndex;
-
- if (nextIndexValue < _controller.length - 1)
- nextIndexValue++;
- else
- nextIndexValue = 0;
-
- return nextIndexValue;
- }
-
- @override
- void initState() {
- super.initState();
-
- _controller = new TabController(length: widget.childrenCount, vsync: this);
-
- startAnimating();
- }
-
- @override
- void dispose() {
- _controller.dispose();
- _timer?.cancel();
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) {
- return new TabBarView(
- children: widget.children
- .map((widget) => new Center(
- child: widget,
- ))
- .toList(),
- controller: this._controller,
- );
- }
-
- void startAnimating() {
- _timer?.cancel();
-
- //Every widget.displayDuration (time) the tabbar controller will animate to the next index.
- _timer = new Timer.periodic(
- widget.displayDuration,
- (_) => this._controller.animateTo(this.nextIndex,
- curve: widget.animationCurve, duration: widget.animationDuration));
- }
-}
diff --git a/lib/widgets/checkbox_title.dart b/lib/widgets/checkbox_title.dart
deleted file mode 100644
index 5a345629..00000000
--- a/lib/widgets/checkbox_title.dart
+++ /dev/null
@@ -1,27 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:nkust_ap/res/resource.dart' as Resource;
-
-class CheckboxTitle extends StatelessWidget {
- final String title;
- final bool checkboxValue;
- final ValueChanged valueChanged;
-
- CheckboxTitle(this.title, this.checkboxValue, this.valueChanged);
-
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: [
- Checkbox(
- activeColor: Colors.blue,
- value: this.checkboxValue,
- onChanged: (value) => valueChanged,
- ),
- Text(title)
- ],
- ),
- onTap: () => checkboxValue);
- }
-}
diff --git a/lib/widgets/default_dialog.dart b/lib/widgets/default_dialog.dart
index a1d52b8e..e39f968b 100644
--- a/lib/widgets/default_dialog.dart
+++ b/lib/widgets/default_dialog.dart
@@ -18,15 +18,15 @@ class DefaultDialog extends StatelessWidget {
static showSample(BuildContext context) => showDialog(
context: context,
builder: (BuildContext context) => DefaultDialog(
- title: '預約成功',
- actionText: '我知道了',
- actionFunction: () =>
- Navigator.of(context, rootNavigator: true).pop('dialog'),
- contentWidget: Text(
- '預約日期:2017/09/05\n上車地點:燕巢校區\n預約班次:08:20',
- style: TextStyle(color: Resource.Colors.grey, height: 1.3),
- ),
- ),
+ title: '預約成功',
+ actionText: '我知道了',
+ actionFunction: () =>
+ Navigator.of(context, rootNavigator: true).pop('dialog'),
+ contentWidget: Text(
+ '預約日期:2017/09/05\n上車地點:燕巢校區\n預約班次:08:20',
+ style: TextStyle(color: Resource.Colors.grey, height: 1.3),
+ ),
+ ),
);
@override
@@ -41,7 +41,7 @@ class DefaultDialog extends StatelessWidget {
title,
textAlign: TextAlign.center,
style: TextStyle(
- color: Resource.Colors.blue,
+ color: Resource.Colors.blueText,
fontWeight: FontWeight.bold,
fontSize: 18.0,
),
@@ -77,7 +77,7 @@ class DefaultDialog extends StatelessWidget {
child: Text(
actionText,
style: TextStyle(
- color: Resource.Colors.grey,
+ color: Resource.Colors.greyText,
fontSize: 18.0,
),
),
diff --git a/lib/widgets/drawer_body.dart b/lib/widgets/drawer_body.dart
index 12813815..1bb45d11 100644
--- a/lib/widgets/drawer_body.dart
+++ b/lib/widgets/drawer_body.dart
@@ -7,6 +7,7 @@ import 'package:nkust_ap/api/helper.dart';
import 'package:nkust_ap/config/constants.dart';
import 'package:nkust_ap/models/models.dart';
import 'package:nkust_ap/pages/page.dart';
+import 'package:nkust_ap/res/assets.dart';
import 'package:nkust_ap/res/resource.dart' as Resource;
import 'package:nkust_ap/utils/app_localizations.dart';
import 'package:nkust_ap/utils/cache_utils.dart';
@@ -115,8 +116,7 @@ class DrawerBodyState extends State {
decoration: BoxDecoration(
color: Color(0xff0071FF),
image: DecorationImage(
- image:
- AssetImage("assets/images/drawer-backbroud.webp"),
+ image: AssetImage(ImageAssets.drawerBackground),
fit: BoxFit.fitWidth,
alignment: Alignment.bottomCenter),
),
@@ -126,7 +126,7 @@ class DrawerBodyState extends State {
right: 20.0,
child: Container(
child: Image.asset(
- "assets/images/drawer-icon.webp",
+ ImageAssets.drawerIcon,
width: 90.0,
),
),
@@ -143,7 +143,7 @@ class DrawerBodyState extends State {
leading: Icon(
Icons.school,
color: isStudyExpanded
- ? Resource.Colors.blue
+ ? Resource.Colors.blueAccent
: Resource.Colors.grey,
),
title: Text(app.courseInfo, style: _defaultStyle()),
@@ -163,7 +163,7 @@ class DrawerBodyState extends State {
leading: Icon(
Icons.calendar_today,
color: isLeaveExpanded
- ? Resource.Colors.blue
+ ? Resource.Colors.blueAccent
: Resource.Colors.grey,
),
title: Text(app.leave, style: _defaultStyle()),
@@ -182,8 +182,9 @@ class DrawerBodyState extends State {
},
leading: Icon(
Icons.directions_bus,
- color:
- isBusExpanded ? Resource.Colors.blue : Resource.Colors.grey,
+ color: isBusExpanded
+ ? Resource.Colors.blueAccent
+ : Resource.Colors.grey,
),
title: Text(app.bus, style: _defaultStyle()),
children: [
@@ -249,22 +250,24 @@ class DrawerBodyState extends State {
_getUserPicture() {
Helper.instance.getUsersPicture().then((url) async {
- var response = await http.get(url);
- if (!response.body.contains('html')) {
- if (mounted) {
- setState(() {
- pictureBytes = response.bodyBytes;
- });
- }
- CacheUtils.savePictureData(response.bodyBytes);
- } else {
- var bytes = await CacheUtils.loadPictureData();
- if (mounted) {
- setState(() {
- pictureBytes = bytes;
- });
+ try {
+ var response = await http.get(url);
+ if (!response.body.contains('html')) {
+ if (mounted) {
+ setState(() {
+ pictureBytes = response.bodyBytes;
+ });
+ }
+ CacheUtils.savePictureData(response.bodyBytes);
+ } else {
+ var bytes = await CacheUtils.loadPictureData();
+ if (mounted) {
+ setState(() {
+ pictureBytes = bytes;
+ });
+ }
}
- }
+ } catch (e) {}
}).catchError((e) {
if (e is DioError) {
switch (e.type) {
diff --git a/lib/widgets/hint_content.dart b/lib/widgets/hint_content.dart
index 81f9cd0e..de245083 100644
--- a/lib/widgets/hint_content.dart
+++ b/lib/widgets/hint_content.dart
@@ -1,11 +1,15 @@
import 'package:flutter/material.dart';
+import 'package:nkust_ap/res/assets.dart';
import 'package:nkust_ap/res/resource.dart' as Resource;
class HintContent extends StatelessWidget {
final IconData icon;
final String content;
- HintContent({this.icon, this.content});
+ HintContent({
+ @required this.icon,
+ @required this.content,
+ });
@override
Widget build(BuildContext context) {
@@ -17,13 +21,14 @@ class HintContent extends StatelessWidget {
Container(
padding: EdgeInsets.all(25.0),
decoration: BoxDecoration(
- image: DecorationImage(
- image: AssetImage("assets/images/dash_line.webp"),
- )),
+ image: DecorationImage(
+ image: AssetImage(ImageAssets.dashLine),
+ ),
+ ),
child: Icon(
icon,
size: 50.0,
- color: Resource.Colors.blue,
+ color: Resource.Colors.blueAccent,
),
),
SizedBox(height: 20.0),
diff --git a/lib/widgets/progress_dialog.dart b/lib/widgets/progress_dialog.dart
index 4cd848c0..41111373 100644
--- a/lib/widgets/progress_dialog.dart
+++ b/lib/widgets/progress_dialog.dart
@@ -22,13 +22,14 @@ class ProgressDialog extends StatelessWidget {
SizedBox(height: 8.0),
CircularProgressIndicator(
value: null,
- valueColor: AlwaysStoppedAnimation(Resource.Colors.blue),
+ valueColor:
+ AlwaysStoppedAnimation(Resource.Colors.blueAccent),
),
SizedBox(height: 28.0),
Container(
child: Text(
content,
- style: TextStyle(color: Resource.Colors.blue),
+ style: TextStyle(color: Resource.Colors.blueAccent),
),
),
],
diff --git a/lib/widgets/share_data_widget.dart b/lib/widgets/share_data_widget.dart
index 4c4e98ca..50d6b1cd 100644
--- a/lib/widgets/share_data_widget.dart
+++ b/lib/widgets/share_data_widget.dart
@@ -1,10 +1,11 @@
+import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
+import 'package:nkust_ap/main.dart';
class ShareDataWidget extends InheritedWidget {
- String username = '';
- bool isOfflineLogin = false;
+ final MyAppState data;
- ShareDataWidget({Widget child}) : super(child: child);
+ ShareDataWidget(this.data, {Widget child}) : super(child: child);
static ShareDataWidget of(BuildContext context) {
return context.inheritFromWidgetOfExactType(ShareDataWidget);
@@ -12,6 +13,6 @@ class ShareDataWidget extends InheritedWidget {
@override
bool updateShouldNotify(ShareDataWidget oldWidget) {
- return oldWidget.username != username;
+ return true;
}
}
diff --git a/lib/widgets/yes_no_dialog.dart b/lib/widgets/yes_no_dialog.dart
index 564b1ad6..8197eb5e 100644
--- a/lib/widgets/yes_no_dialog.dart
+++ b/lib/widgets/yes_no_dialog.dart
@@ -22,16 +22,16 @@ class YesNoDialog extends StatelessWidget {
static showSample(BuildContext context) => showDialog(
context: context,
builder: (BuildContext context) => YesNoDialog(
- title: '預約成功',
- contentWidget: Text(
- '預約日期:2017/09/05\n上車地點:燕巢校區\n預約班次:08:20',
- style: TextStyle(color: Resource.Colors.grey, height: 1.3),
- ),
- leftActionText: '取消',
- rightActionText: '預約',
- leftActionFunction: null,
- rightActionFunction: null,
- ),
+ title: '預約成功',
+ contentWidget: Text(
+ '預約日期:2017/09/05\n上車地點:燕巢校區\n預約班次:08:20',
+ style: TextStyle(color: Resource.Colors.greyText, height: 1.3),
+ ),
+ leftActionText: '取消',
+ rightActionText: '預約',
+ leftActionFunction: null,
+ rightActionFunction: null,
+ ),
);
@override
@@ -46,7 +46,7 @@ class YesNoDialog extends StatelessWidget {
title,
textAlign: TextAlign.center,
style: TextStyle(
- color: Resource.Colors.blue,
+ color: Resource.Colors.blueText,
fontWeight: FontWeight.bold,
fontSize: 18.0,
),
@@ -88,7 +88,7 @@ class YesNoDialog extends StatelessWidget {
child: Text(
leftActionText,
style: TextStyle(
- color: Resource.Colors.grey,
+ color: Resource.Colors.greyText,
fontSize: 16.0,
),
),
@@ -110,7 +110,7 @@ class YesNoDialog extends StatelessWidget {
child: Text(
rightActionText,
style: TextStyle(
- color: Resource.Colors.grey,
+ color: Resource.Colors.greyText,
fontSize: 16.0,
),
),
diff --git a/pubspec.yaml b/pubspec.yaml
index 690b2cb8..7d7dcfbe 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,7 +1,7 @@
name: nkust_ap
description: A new Flutter application.
-version: 3.1.10+30110
+version: 3.1.11+30111
environment:
sdk: ">=2.1.0 <3.0.0"
@@ -11,6 +11,7 @@ dependencies:
sdk: flutter
flutter_localizations:
sdk: flutter
+ flutter_cupertino_localizations: ^1.0.1
cupertino_icons: ^0.1.2
#official plugin
shared_preferences: ^0.5.3+1
@@ -28,7 +29,7 @@ dependencies:
toast: ^0.1.4
tuple: ^1.0.1
flutter_crashlytics:
- path: ../flutter_crashlytics
+ git: https://github.com/abc873693/flutter_crashlytics
encrypt: ^2.0.0
flutter_local_notifications: ^0.7.1+3
sprintf: ^4.0.2
@@ -52,44 +53,3 @@ flutter:
uses-material-design: true
assets:
- assets/images/
- - assets/images/kuasap.webp
- - assets/images/kuasap2.webp
- - assets/images/kuasap3.webp
- - assets/images/kuas_itc.webp
- - assets/images/ic_fb.webp
- - assets/images/ic_github.webp
- - assets/images/ic_email.webp
- - assets/images/drawer-backbroud.webp
- - assets/images/drawer-icon.webp
- - assets/images/K.webp
- - assets/images/dash_line.webp
- # To add assets to your application, add an assets section, like this:
- # assets:
- # - images/a_dot_burr.jpeg
- # - images/a_dot_ham.jpeg
-
- # An image asset can refer to one or more resolution-specific "variants", see
- # https://flutter.io/assets-and-images/#resolution-aware.
-
- # For details regarding adding assets from package dependencies, see
- # https://flutter.io/assets-and-images/#from-packages
-
- # To add custom fonts to your application, add a fonts section here,
- # in this "flutter" section. Each entry in this list should have a
- # "family" key with the font family name, and a "fonts" key with a
- # list giving the asset and other descriptors for the font. For
- # example:
- # fonts:
- # - family: Schyler
- # fonts:
- # - asset: fonts/Schyler-Regular.ttf
- # - asset: fonts/Schyler-Italic.ttf
- # style: italic
- # - family: Trajan Pro
- # fonts:
- # - asset: fonts/TrajanPro.ttf
- # - asset: fonts/TrajanPro_Bold.ttf
- # weight: 700
- #
- # For details regarding fonts from package dependencies,
- # see https://flutter.io/custom-fonts/#from-packages