Skip to content

Commit

Permalink
Merge pull request #12 from abc873693/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
abc873693 authored Dec 5, 2018
2 parents 9ba21f0 + 54e7fdf commit b857134
Show file tree
Hide file tree
Showing 16 changed files with 149 additions and 101 deletions.
5 changes: 4 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ buildscript {
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:3.1.2'
classpath 'com.google.gms:google-services:4.2.0'
}
}

allprojects {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
"${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework",
"${BUILT_PRODUCTS_DIR}/fluttertoast/fluttertoast.framework",
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
"${BUILT_PRODUCTS_DIR}/package_info/package_info.framework",
"${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework",
"${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework",
);
Expand All @@ -251,6 +252,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/fluttertoast.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/package_info.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework",
);
Expand Down
8 changes: 6 additions & 2 deletions lib/config/constants.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
class Constants {
static bool get isInDebugMode {
bool inDebugMode = false;
assert(inDebugMode = true);
return inDebugMode;
}

static const PREF_FIRST_ENTER_APP = "pref_first_enter_app";
static const PREF_REMEMBER_PASSWORD = "pref_remember_password";
static const PREF_USERNAME = "pref_username";
Expand All @@ -9,6 +15,4 @@ class Constants {
static const PREF_VIBRATE_COURSE = "pref_vibrate_course";

static const SCHEDULE_DATA = "schedule_data";

static const APP_VERSION = "v0.3.1";
}
3 changes: 2 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:nkust_ap/config/constants.dart';
import 'package:nkust_ap/pages/page.dart';
import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:firebase_analytics/observer.dart';
Expand All @@ -10,7 +11,7 @@ import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter_crashlytics/flutter_crashlytics.dart';

void main() async {
bool isInDebugMode = false;
bool isInDebugMode = Constants.isInDebugMode;
FlutterError.onError = (FlutterErrorDetails details) {
if (isInDebugMode) {
// In development mode simply print to console.
Expand Down
66 changes: 35 additions & 31 deletions lib/models/course_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class CourseData {
);
}

Map<String, dynamic> toJson() =>
{
Map<String, dynamic> toJson() => {
'status': status,
'messages': messages,
'coursetables': courseTables,
Expand Down Expand Up @@ -73,8 +72,7 @@ class CourseTables {
int maxTimeCodes = 10;
for (int i = 0; i < weeks.length; i++) {
if (getCourseList(weeks[i]) != null)
for (var data
in getCourseList(weeks[i])) {
for (var data in getCourseList(weeks[i])) {
for (int j = 0; j < timeCode.length; j++) {
if (timeCode[j] == data.section) {
if ((j + 1) > maxTimeCodes) maxTimeCodes = (j + 1);
Expand All @@ -87,22 +85,18 @@ class CourseTables {

static CourseTables fromJson(Map<String, dynamic> json) {
return CourseTables(
sunday: Course.toList(json['Sunday']),
tuesday: Course.toList(json['Tuesday']),
friday: Course.toList(json['Friday']),
saturday: Course.toList(json['Saturday']),
thursday: Course.toList(json['Thursday']),
wednesday: Course.toList(json['Wednesday']),
monday: Course.toList(json['Monday']),
timeCode: List < String
>
.from(json['timecode'] ??
[
]),);
sunday: Course.toList(json['Sunday']),
tuesday: Course.toList(json['Tuesday']),
friday: Course.toList(json['Friday']),
saturday: Course.toList(json['Saturday']),
thursday: Course.toList(json['Thursday']),
wednesday: Course.toList(json['Wednesday']),
monday: Course.toList(json['Monday']),
timeCode: List<String>.from(json['timecode'] ?? []),
);
}

Map<String, dynamic> toJson() =>
{
Map<String, dynamic> toJson() => {
'Sunday': sunday,
'Tuesday': tuesday,
'Friday': friday,
Expand Down Expand Up @@ -137,26 +131,36 @@ class Course {

static List<Course> toList(List<dynamic> jsonArray) {
List<Course> list = [];
for (var item in (jsonArray ?? []))
list.add(Course.fromJson(item));
for (var item in (jsonArray ?? [])) list.add(Course.fromJson(item));
return list;
}

static Course fromJson(Map<String, dynamic> json) {
print(json['instructors']);
return Course(
title: json['title'],
startTime: json['date']["start_time"],
endTime: json['date']["end_time"],
weekday: json['date']["weekday"],
section: json['date']["section"],
building: json['location']["building"],
room: json['location']["room"],
instructors: List<String>.from(json['instructors']),);
title: json['title'],
startTime: json['date']["start_time"],
endTime: json['date']["end_time"],
weekday: json['date']["weekday"],
section: json['date']["section"],
building: json['location']["building"],
room: json['location']["room"],
instructors: List<String>.from(json['instructors'])
);
}

String getInstructors() {
String text = "";
if(instructors.length>0){
text += instructors[0];
for(var i = 1 ; i < instructors.length ; i++)
text += ",${instructors[i]}";
}
return text;
}

Map<String, dynamic> toJson() =>
{
Map<String, dynamic> toJson() => {
'title': title,
'instructors': instructors,
};
}
}
21 changes: 18 additions & 3 deletions lib/pages/home/about/about_us_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:nkust_ap/res/resource.dart' as Resource;
import 'package:nkust_ap/api/helper.dart';
Expand Down Expand Up @@ -55,7 +57,8 @@ class AboutUsPageState extends State<AboutUsPage>
IconButton(
icon: Icon(Icons.code),
onPressed: () {
Navigator.of(context).pushNamed(OpenSourcePage.routerName);
Navigator.of(context)
.pushNamed(OpenSourcePage.routerName);
})
],
backgroundColor: Resource.Colors.blue,
Expand Down Expand Up @@ -116,14 +119,26 @@ class AboutUsPageState extends State<AboutUsPage>
IconButton(
icon: Image.asset("assets/images/ic_fb.png"),
onPressed: () {
Utils.launchUrl('https://www.facebook.com/NKUST.ITC/');
if (Platform.isAndroid)
Utils.launchUrl('fb://page/735951703168873')
.catchError((onError) => Utils.launchUrl(
'https://www.facebook.com/NKUST.ITC/'));
else
Utils.launchUrl(
'https://www.facebook.com/NKUST.ITC/');
},
iconSize: 48.0,
),
IconButton(
icon: Image.asset("assets/images/ic_github.png"),
onPressed: () {
Utils.launchUrl('https://github.com/NKUST-ITC');
if (Platform.isAndroid)
Utils.launchUrl(
'github://organization/NKUST-ITC')
.catchError((onError) => Utils.launchUrl(
'https://github.com/NKUST-ITC'));
else
Utils.launchUrl('https://github.com/NKUST-ITC');
},
iconSize: 48.0,
),
Expand Down
5 changes: 4 additions & 1 deletion lib/pages/home/bus/bus_reservations_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ class BusReservationsPage extends StatefulWidget {
}

class BusReservationsPageState extends State<BusReservationsPage>
with SingleTickerProviderStateMixin {
with AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;

BusReservationsState state = BusReservationsState.loading;
BusReservationsData busReservationsData;
List<Widget> busReservationWeights = [];
Expand Down
5 changes: 4 additions & 1 deletion lib/pages/home/bus/bus_reserve_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ class BusReservePage extends StatefulWidget {
}

class BusReservePageState extends State<BusReservePage>
with SingleTickerProviderStateMixin {
with AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;

BusReserveState state = BusReserveState.loading;
BusData busData;
List<Widget> busTimeWeights = [];
Expand Down
23 changes: 16 additions & 7 deletions lib/pages/home/bus_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,37 @@ class BusPageRoute extends MaterialPageRoute {

class BusPage extends StatefulWidget {
static const String routerName = "/bus";
final List<Widget> _children = [
new BusReservePage(),
new BusReservationsPage()
];

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

class BusPageState extends State<BusPage> with SingleTickerProviderStateMixin {
class BusPageState extends State<BusPage>
with SingleTickerProviderStateMixin {
final List<Widget> _children;
int _currentIndex = 0;
final List<Widget> _children = [
new BusReservePage(),
new BusReservationsPage()
];
List<String> _title;

AppLocalizations local;

TabController controller;

BusPageState(this._children);

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

@override
void dispose() {
super.dispose();
controller.dispose();
}

@override
Expand All @@ -55,7 +63,7 @@ class BusPageState extends State<BusPage> with SingleTickerProviderStateMixin {
title: new Text(_title[_currentIndex]),
backgroundColor: Resource.Colors.blue,
),
body: _children[_currentIndex],
body: TabBarView(children: _children,controller: controller,physics: new NeverScrollableScrollPhysics()),
bottomNavigationBar: new BottomNavigationBar(
currentIndex: _currentIndex,
onTap: onTabTapped,
Expand All @@ -77,6 +85,7 @@ class BusPageState extends State<BusPage> with SingleTickerProviderStateMixin {
void onTabTapped(int index) {
setState(() {
_currentIndex = index;
controller.animateTo(_currentIndex);
});
}
}
7 changes: 5 additions & 2 deletions lib/pages/home/course_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class CoursePageState extends State<CoursePage>

Widget _courseBorder(Course course) {
String content = "${local.courseDialogName}:${course.title}\n"
"${local.courseDialogProfessor}:${course.instructors[0] ?? ""}\n"
"${local.courseDialogProfessor}:${course.getInstructors()}\n"
"${local.courseDialogLocation}:${course.building}${course.room}\n"
"${local.courseDialogTime}:${course.startTime}-${course.endTime}";
return new Container(
Expand All @@ -112,7 +112,10 @@ class CoursePageState extends State<CoursePage>
showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
title: Text(local.courseDialogTitle),
title: Text(
local.courseDialogTitle,
style: TextStyle(color: Resource.Colors.blue),
),
content: Text(content),
actions: <Widget>[
FlatButton(
Expand Down
Loading

0 comments on commit b857134

Please sign in to comment.