Skip to content

Commit

Permalink
UI优化
Browse files Browse the repository at this point in the history
  • Loading branch information
ChinaGamer committed Feb 26, 2022
1 parent c1e8104 commit 3cd4417
Show file tree
Hide file tree
Showing 16 changed files with 599 additions and 286 deletions.
28 changes: 28 additions & 0 deletions lib/common/animation.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:flutter/cupertino.dart';

class SlideTopRoute extends PageRouteBuilder {
final Widget page;

SlideTopRoute({required this.page})
: super(
pageBuilder: (
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
) =>
page,
transitionsBuilder: (
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child,
) =>
SlideTransition(
position: Tween<Offset>(
begin: const Offset(0,1),
end: Offset.zero,
).animate(animation),
child: child,
),
);
}
32 changes: 20 additions & 12 deletions lib/common/get.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ Future<void> getWeek() async {
print("getWeek End");
} on TimeoutException catch (e) {
print("超时");
print(e);
readConfig();
} on SocketException catch (e) {
print("连接失败");
print(e);
readConfig();
}
}
Expand Down Expand Up @@ -70,9 +72,7 @@ Future<String> getSchedule() async {
print("登录过期");
return "fail";
} else {
dom.Document document = parse(gbk
.decode(response.bodyBytes)
.toString());
dom.Document document = parse(gbk.decode(response.bodyBytes).toString());
var list = document.querySelectorAll(".infolist_common");
num listLength = document.querySelectorAll(".infolist_common").length - 23;
for (var i = 0; i < listLength; i++) {
Expand All @@ -84,8 +84,7 @@ Future<String> getSchedule() async {
.innerHtml
.trim()
.replaceAll("第", "")
.replaceAll("节", "")
;
.replaceAll("节", "");
//周次
String zc = list[i]
.querySelectorAll("table.none>tbody>tr")[j]
Expand All @@ -95,8 +94,7 @@ Future<String> getSchedule() async {
.replaceAll("第", "")
.replaceAll("单", "")
.replaceAll("双", "")
.replaceAll("周", "")
; //课节
.replaceAll("周", ""); //课节
List kjList = kj.trim().split('-');
List zcList = zc.trim().split('-');
String week = list[i]
Expand Down Expand Up @@ -130,7 +128,9 @@ Future<String> getSchedule() async {
? list[i].querySelectorAll("a.infolist")[1].innerHtml.trim()
: null,
//上课地点
area != "&nbsp" ? area : null
area != "&nbsp" ? area : null,
//备注
list[i].querySelectorAll("table.none>tbody>tr")[j].text.trim().replaceAll(" ", ";")
];
}
} else {
Expand All @@ -140,13 +140,15 @@ Future<String> getSchedule() async {
.innerHtml
.trim()]]?[k.toString()] = [
//课程名
list[i].querySelectorAll("a.infolist")[0].innerHtml.trim(),
list[i].querySelectorAll("a.infolist")[0].innerHtml.trim(),
//老师名字
list[i].querySelectorAll("a.infolist").length > 1
? list[i].querySelectorAll("a.infolist")[1].innerHtml.trim()
: null,
//上课地点
area != "&nbsp" ? area : null
area != "&nbsp" ? area : null,
//备注
list[i].querySelectorAll("table.none>tbody>tr")[j].text.trim().replaceAll(" ", ";")
];
}
}
Expand Down Expand Up @@ -176,7 +178,6 @@ Future<String> getSchedule() async {
if (tables.length >= 3) {
dom.Element table = tables[2];
List<dom.Element> trs = table.querySelectorAll(".infolist_hr_common");
int _index = 0;
String _name = "";
String _teacher = "";
trs.forEach((element) {
Expand Down Expand Up @@ -269,7 +270,6 @@ Future<String> getSchedule() async {
}
}
}
_index++;
});
}
}
Expand All @@ -282,9 +282,11 @@ Future<String> getSchedule() async {
return "success";
} on TimeoutException catch (e) {
print("getExam Error");
print(e);
return Global.timeOutError;
} on SocketException catch (e) {
print("getExam Error");
print(e);
return Global.socketError;
}
}
Expand Down Expand Up @@ -355,9 +357,11 @@ Future<List> getScore() async {
return list;
} on TimeoutException catch (e) {
print("getScore Error");
print(e);
return [Global.timeOutError];
} on SocketException catch (e) {
print("getScore Error");
print(e);
return [Global.socketError];
}
}
Expand Down Expand Up @@ -413,9 +417,11 @@ Future<String> getExam() async {
}
} on TimeoutException catch (e) {
print("getExam Error");
print(e);
return Global.timeOutError;
} on SocketException catch (e) {
print("getExam Error");
print(e);
return Global.socketError;
}
}
Expand Down Expand Up @@ -513,9 +519,11 @@ Future getCareer() async {
}
} on TimeoutException catch (e) {
print("getExam Error");
print(e);
return Global.timeOutError;
} on SocketException catch (e) {
print("getExam Error");
print(e);
return Global.socketError;
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/common/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ Future<String> codeCheck(String code) async {
return result;
} on TimeoutException catch (e) {
print("getExam Error");
print(e);
return Global.timeOutError;
} on SocketException catch (e) {
print("getExam Error");
print(e);
return Global.socketError;
}
}
Expand All @@ -42,9 +44,11 @@ Future<String> login(String username, String password, String code) async {
}
} on TimeoutException catch (e) {
print("getExam Error");
print(e);
return Global.timeOutError;
} on SocketException catch (e) {
print("getExam Error");
print(e);
return Global.socketError;
}
}
40 changes: 40 additions & 0 deletions lib/common/noripple.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:flutter/material.dart';
// 取消涟漪效果
/// Cancel ripples caused by excessive Listview scrolling.
class NoRippleOverScroll extends StatefulWidget {
final Widget child;

NoRippleOverScroll({required this.child});

@override
NoRippleOverScrollState createState() => NoRippleOverScrollState();
}

class NoRippleOverScrollState extends State<NoRippleOverScroll> {
@override
Widget build(BuildContext context) {
return ScrollConfiguration(
behavior: _OverScrollBehavior(),
child: widget.child,
);
}
}

class _OverScrollBehavior extends ScrollBehavior {
@override
Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) {
if (getPlatform(context) == TargetPlatform.android ||
getPlatform(context) == TargetPlatform.fuchsia) {
return GlowingOverscrollIndicator(
child: child,
showLeading: false,
showTrailing: false,
axisDirection: axisDirection,
//'accentColor' is deprecated and shouldn't be used. Use colorScheme.secondary instead. For more information, consult the migration guide at https://flutter.dev/docs/release/breaking-changes/theme-data-accent-properties#migration-guide. This feature was deprecated after v2.3.0-0.1.pre.. (文档) Try replacing the use of the deprecated member with the replacement.
color: Theme.of(context).colorScheme.secondary,
);
} else {
return child;
}
}
}
Loading

0 comments on commit 3cd4417

Please sign in to comment.