Skip to content

Commit

Permalink
Merge pull request #81 from NKUST-ITC/develop
Browse files Browse the repository at this point in the history
Update to v3.2.10
  • Loading branch information
abc873693 authored Oct 10, 2019
2 parents d19f45e + dfd6b80 commit 8ee4332
Show file tree
Hide file tree
Showing 10 changed files with 507 additions and 400 deletions.
5 changes: 3 additions & 2 deletions ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# 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-ITC/NKUST-AP-Flutter"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_TARGET=/Users/rainvisitor/Documents/GitHub-NKUST-ITC/NKUST-AP-Flutter/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-release"
export "FLUTTER_FRAMEWORK_DIR=/Users/rainvisitor/development/flutter/bin/cache/artifacts/engine/ios"
export "FLUTTER_BUILD_NAME=3.2.9"
export "FLUTTER_BUILD_NUMBER=30209"
export "TRACK_WIDGET_CREATION=true"
45 changes: 32 additions & 13 deletions lib/api/helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:convert';
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:encrypt/encrypt.dart';
import 'package:http_parser/http_parser.dart';
import 'package:intl/intl.dart';
import 'package:nkust_ap/config/constants.dart';
import 'package:nkust_ap/models/announcements_data.dart';
Expand All @@ -21,10 +21,10 @@ import 'package:nkust_ap/models/reward_and_penalty_data.dart';
import 'package:nkust_ap/models/room_data.dart';
import 'package:nkust_ap/models/server_info_data.dart';
import 'package:nkust_ap/utils/preferences.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:nkust_ap/utils/utils.dart';

class Helper {
static const HOST = 'nkust.taki.dog';
static const HOST = 'nkus-ap-staging.rainvisitor.me';

static const VERSION = 'v3';

Expand Down Expand Up @@ -56,7 +56,6 @@ class Helper {

Helper() {
var host = Preferences.getString(Constants.API_HOST, HOST);
print(host);
options = BaseOptions(
baseUrl: 'https://$host/$VERSION',
connectTimeout: 10000,
Expand All @@ -65,6 +64,12 @@ class Helper {
dio = Dio(options);
}

static resetInstance() {
_instance = Helper();
jsonCodec = JsonCodec();
cancelToken = CancelToken();
}

handleDioError(DioError dioError) {
switch (dioError.type) {
case DioErrorType.DEFAULT:
Expand Down Expand Up @@ -144,8 +149,13 @@ class Helper {
var response = await dio.get("/news/announcements/all");
if (response.statusCode == 204)
return AnnouncementsData(data: []);
else
return AnnouncementsData.fromJson(response.data);
else {
var announcementsData = AnnouncementsData.fromJson(response.data);
announcementsData.data.sort((a, b) {
return b.weight.compareTo(a.weight);
});
return announcementsData;
}
} on DioError catch (dioError) {
print(dioError);
throw dioError;
Expand Down Expand Up @@ -418,15 +428,24 @@ class Helper {
Future<Response> sendLeavesSubmit(LeaveSubmitData data, File image) async {
if (isExpire()) await login(username, password);
try {
MultipartFile file;
if (image != null) {
file = MultipartFile.fromFileSync(
image.path,
filename: image.path.split('/').last,
contentType: MediaType(
'image', Utils.parserImageFileType(image.path.split('.').last)),
);
}
print(data.toRawJson());
var response = await dio.post(
'/leave/submit',
data: {
'leavesData': data.toJson(),
'proofImage': image == null
? null
: MultipartFile.fromFile(image.path,
filename: image.path.split('/').last),
},
data: FormData.fromMap(
{
'leavesData': data.toRawJson(),
'proofImage': file,
},
),
cancelToken: cancelToken,
);
return response;
Expand Down
1 change: 1 addition & 0 deletions lib/pages/home/bus_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class BusPageState extends State<BusPage> with SingleTickerProviderStateMixin {

@override
void initState() {
_currentIndex = widget.initIndex;
controller =
TabController(length: 2, initialIndex: widget.initIndex, vsync: this);
super.initState();
Expand Down
Loading

0 comments on commit 8ee4332

Please sign in to comment.