Skip to content

Commit

Permalink
Merge pull request #74 from NKUST-ITC/develop
Browse files Browse the repository at this point in the history
Update to v3.2.4
  • Loading branch information
abc873693 authored Sep 11, 2019
2 parents bda5172 + c3baca5 commit fccdb53
Show file tree
Hide file tree
Showing 18 changed files with 394 additions and 505 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ flutter {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

apply plugin: 'com.google.gms.google-services'
12 changes: 1 addition & 11 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}

dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath 'io.fabric.tools:gradle:1.26.1'
classpath 'com.android.tools.build:gradle:3.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.0' // Google Services plugin
Expand All @@ -34,14 +34,4 @@ subprojects {

task clean(type: Delete) {
delete rootProject.buildDir
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.1.0"
}
}
}
}
8 changes: 4 additions & 4 deletions ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/rainvisitor/development/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/rainvisitor/Documents/GitHub/NKUST-AP-Flutter"
export "FLUTTER_APPLICATION_PATH=/Users/rainvisitor/Documents/GitHub-NKUST-ITC/NKUST-AP-Flutter"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "FLUTTER_FRAMEWORK_DIR=/Users/rainvisitor/development/flutter/bin/cache/artifacts/engine/ios"
export "FLUTTER_BUILD_NAME=3.2.1"
export "FLUTTER_BUILD_NUMBER=30201"
export "FLUTTER_FRAMEWORK_DIR=/Users/rainvisitor/development/flutter/bin/cache/artifacts/engine/ios-release"
export "FLUTTER_BUILD_NAME=3.2.4"
export "FLUTTER_BUILD_NUMBER=30204"
67 changes: 21 additions & 46 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import 'dart:io';

import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:firebase_analytics/observer.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'
show debugDefaultTargetPlatformOverride;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_crashlytics/flutter_crashlytics.dart';
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';
Expand All @@ -31,50 +32,21 @@ void main() async {
Preferences.getString(Constants.PREF_ICON_STYLE_CODE, AppIcon.OUTLINED);
AppTheme.code =
Preferences.getString(Constants.PREF_THEME_CODE, AppTheme.LIGHT);
if (Platform.isIOS || Platform.isAndroid) {
if (!Constants.isInDebugMode) {
FlutterError.onError = (FlutterErrorDetails details) {
if (isInDebugMode) {
// In development mode simply print to console.
FlutterError.dumpErrorToConsole(details);
} else {
// In production mode report to the application zone to report to
// Crashlytics.
Zone.current.handleUncaughtError(details.exception, details.stack);
}
};

await FlutterCrashlytics().initialize();

runZoned<Future<Null>>(() async {
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.
await FlutterCrashlytics()
.reportCrash(error, stackTrace, forceCrash: false);
});
} else {
runApp(
MyApp(
themeData: AppTheme.data,
),
);
}
if (kIsWeb) {
} else if (Platform.isIOS || Platform.isAndroid) {
Crashlytics.instance.enableInDevMode = true;
// Pass all uncaught errors from the framework to Crashlytics.
FlutterError.onError = Crashlytics.instance.recordFlutterError;
} else {
// See https://github.com/flutter/flutter/wiki/Desktop-shells#target-platform-override
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
runApp(
MyApp(
themeData: AppTheme.data,
),
);
//TODO add other platform Crashlytics
}
runApp(
MyApp(
themeData: AppTheme.data,
),
);
}

class MyApp extends StatefulWidget {
Expand Down Expand Up @@ -103,7 +75,8 @@ class MyAppState extends State<MyApp> {
@override
void initState() {
themeData = widget.themeData;
if (Platform.isAndroid || Platform.isIOS) {
if (kIsWeb) {
} else if (Platform.isAndroid || Platform.isIOS) {
analytics = FirebaseAnalytics();
firebaseMessaging = FirebaseMessaging();
_initFCM();
Expand Down Expand Up @@ -144,11 +117,13 @@ class MyAppState extends State<MyApp> {
LeavePage.routerName: (BuildContext context) => LeavePage(),
},
theme: themeData,
navigatorObservers: (Platform.isIOS || Platform.isAndroid)
? [
FirebaseAnalyticsObserver(analytics: analytics),
]
: [],
navigatorObservers: (kIsWeb)
? []
: (Platform.isIOS || Platform.isAndroid)
? [
FirebaseAnalyticsObserver(analytics: analytics),
]
: [],
localizationsDelegates: [
const AppLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate,
Expand Down
54 changes: 6 additions & 48 deletions lib/models/booking_bus_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,20 @@ import 'dart:convert';

class BookingBusData {
bool success;
int code;
String message;
int count;
Data data;

BookingBusData({
this.success,
this.code,
this.message,
this.count,
this.data,
});

factory BookingBusData.fromRawJson(String str) =>
BookingBusData.fromJson(json.decode(str));
factory BookingBusData.fromRawJson(String str) => BookingBusData.fromJson(json.decode(str));

String toRawJson() => json.encode(toJson());

factory BookingBusData.fromJson(Map<String, dynamic> json) =>
new BookingBusData(
success: json["success"],
code: json["code"],
message: json["message"],
count: json["count"],
data: Data.fromJson(json["data"]),
);
factory BookingBusData.fromJson(Map<String, dynamic> json) => BookingBusData(
success: json["success"] == null ? null : json["success"],
);

Map<String, dynamic> toJson() => {
"success": success,
"code": code,
"message": message,
"count": count,
"data": data.toJson(),
};
}

class Data {
String startTime;
int budId;

Data({
this.startTime,
this.budId,
});

factory Data.fromRawJson(String str) => Data.fromJson(json.decode(str));

String toRawJson() => json.encode(toJson());

factory Data.fromJson(Map<String, dynamic> json) => new Data(
startTime: json["startTime"],
budId: json["budId"],
);

Map<String, dynamic> toJson() => {
"startTime": startTime,
"budId": budId,
};
"success": success == null ? null : success,
};
}
8 changes: 4 additions & 4 deletions lib/models/bus_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BusTime {
int limitCount;
bool isReserve;
String specialTrain;
String discription;
String description;
String cancelKey;
bool homeCharteredBus;

Expand All @@ -58,7 +58,7 @@ class BusTime {
this.limitCount,
this.isReserve,
this.specialTrain,
this.discription,
this.description,
this.cancelKey,
this.homeCharteredBus,
});
Expand Down Expand Up @@ -101,7 +101,7 @@ class BusTime {
limitCount: json["limitCount"],
isReserve: json["isReserve"],
specialTrain: json["specialTrain"],
discription: json["discription"],
description: json["description"],
cancelKey: json["cancelKey"],
homeCharteredBus: json["homeCharteredBus"],
);
Expand All @@ -115,7 +115,7 @@ class BusTime {
"limitCount": limitCount,
"isReserve": isReserve,
"specialTrain": specialTrain,
"discription": discription,
"description": description,
"cancelKey": cancelKey,
"homeCharteredBus": homeCharteredBus,
};
Expand Down
18 changes: 9 additions & 9 deletions lib/models/bus_reservations_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class BusReservation {
DateTime getDateTime() {
initializeDateFormatting();
var formatter = new DateFormat('yyyy-MM-ddTHH:mm:ssZ');
return formatter.parse(this.dateTime);
return formatter.parse(this.dateTime).add(Duration(hours: 8));
}

String getDateTimeStr() {
Expand Down Expand Up @@ -137,12 +137,12 @@ class BusReservation {
}
}

bool canCancel() {
var now = new DateTime.now();
initializeDateFormatting();
var formatter = new DateFormat('yyyy-MM-ddTHH:mm:ssZ');
var endEnrollDateTime = formatter.parse(this.endTime);
return now.millisecondsSinceEpoch <
endEnrollDateTime.millisecondsSinceEpoch;
}
// bool canCancel() {
// var now = new DateTime.now();
// initializeDateFormatting();
// var formatter = new DateFormat('yyyy-MM-ddTHH:mm:ssZ');
// var endEnrollDateTime = formatter.parse(this.endTime);
// return now.millisecondsSinceEpoch <
// endEnrollDateTime.millisecondsSinceEpoch;
// }
}
55 changes: 3 additions & 52 deletions lib/models/cancel_bus_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,21 @@ import 'dart:convert';

class CancelBusData {
bool success;
int code;
String message;
int count;
Data data;

CancelBusData({
this.success,
this.code,
this.message,
this.count,
this.data,
});

factory CancelBusData.fromRawJson(String str) =>
CancelBusData.fromJson(json.decode(str));

String toRawJson() => json.encode(toJson());

factory CancelBusData.fromJson(Map<String, dynamic> json) =>
new CancelBusData(
success: json["success"],
code: json["code"],
message: json["message"],
count: json["count"],
data: Data.fromJson(json["data"]),
factory CancelBusData.fromJson(Map<String, dynamic> json) => CancelBusData(
success: json["success"] == null ? null : json["success"],
);

Map<String, dynamic> toJson() => {
"success": success,
"code": code,
"message": message,
"count": count,
"data": data.toJson(),
};
}

class Data {
String message;
int busId;
String runTime;
String reserveMemberId;

Data({
this.message,
this.busId,
this.runTime,
this.reserveMemberId,
});

factory Data.fromRawJson(String str) => Data.fromJson(json.decode(str));

String toRawJson() => json.encode(toJson());

factory Data.fromJson(Map<String, dynamic> json) => new Data(
message: json["message"],
busId: json["busId"],
runTime: json["runTime"],
reserveMemberId: json["reserveMemberId"],
);

Map<String, dynamic> toJson() => {
"message": message,
"busId": busId,
"runTime": runTime,
"reserveMemberId": reserveMemberId,
"success": success == null ? null : success,
};
}
29 changes: 29 additions & 0 deletions lib/models/error_response.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// To parse this JSON data, do
//
// final errorResponse = errorResponseFromJson(jsonString);

import 'dart:convert';

class ErrorResponse {
int errorCode;
String description;

ErrorResponse({
this.errorCode,
this.description,
});

factory ErrorResponse.fromRawJson(String str) => ErrorResponse.fromJson(json.decode(str));

String toRawJson() => json.encode(toJson());

factory ErrorResponse.fromJson(Map<String, dynamic> json) => ErrorResponse(
errorCode: json["errorCode"] == null ? null : json["errorCode"],
description: json["description"] == null ? null : json["description"],
);

Map<String, dynamic> toJson() => {
"errorCode": errorCode == null ? null : errorCode,
"description": description == null ? null : description,
};
}
Loading

0 comments on commit fccdb53

Please sign in to comment.