Skip to content

Commit

Permalink
Merge pull request #10 from SE2020-TopUnderstanding/master
Browse files Browse the repository at this point in the history
同步
  • Loading branch information
zhyixuan committed Apr 23, 2020
2 parents 575ef6e + bcc1fbe commit 26051f8
Show file tree
Hide file tree
Showing 15 changed files with 339 additions and 230 deletions.
Binary file modified .DS_Store
Binary file not shown.
62 changes: 32 additions & 30 deletions jiaowu_assistent/assets/data/courseCenter.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
{
"student_id": "17373349",
"ddl": [
{
"content": [
{
"ddl": "2020-04-28 04:03:00",
"homework": "第一次作业",
"state": "已提交"
},
{
"ddl": "2020-04-20 02:03:00",
"homework": "第二次作业",
"state": "未提交"
}
],
"name": "计算机科学方法论"
},
{
"content": [
{
"ddl": "2020-04-23 04:03:00",
"homework": "第一次作业",
"state": "未提交"
}
],
"name": "计算机图形学"
}
]
}
[
{
"name": "计算机科学方法论",
"content": [
{
"homework": "第二次作业1231231331231231",
"ddl": "2020-04-23 23:00:00",
"state": "未提交"
},
{
"homework": "第一次作业",
"ddl": "2020-04-28 04:03:00",
"state": "已提交"
},
{
"homework": "第三次作业",
"ddl": "",
"state": "已提交"
}
]
},
{
"name": "计算机图形学",
"content": [
{
"homework": "第一次作业",
"ddl": "2020-04-23 04:03:00",
"state": "已提交"
}
]
}
]
2 changes: 1 addition & 1 deletion jiaowu_assistent/assets/data/grade.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"course_name": "计算机网络",
"course_name": "毛泽东思想和中国\n特色社会主义理论\n体系概论",
"credit": 2.0,
"score": 99
},
Expand Down
1 change: 1 addition & 0 deletions jiaowu_assistent/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class MyApp extends StatelessWidget {
home: getHomePage(),
routes: {
'/loginPage': (context) => LoginPage(),
'/homePage': (context) => MyHomePage(),
},
);
}
Expand Down
41 changes: 23 additions & 18 deletions jiaowu_assistent/lib/pages/CourseCenterPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'package:jiaowuassistent/pages/User.dart';
import 'package:jiaowuassistent/GlobalUser.dart';

class CourseCenterPage extends StatefulWidget {
@override
Expand All @@ -15,7 +16,7 @@ class _CourseCenterPageState extends State<CourseCenterPage> {
@override
initState() {
super.initState();
courseCenter = getCourseCenter();
courseCenter = getCourseCenter(GlobalUser.studentID);
}

//修改展开与闭合的内部方法
Expand All @@ -35,26 +36,29 @@ class _CourseCenterPageState extends State<CourseCenterPage> {
List<DataRow> dataRows = [];
var now = DateTime.now();
for (int i = 0; i < course.content.length; i++) {
var time = DateTime.parse(course.content[i].time);
// var time = DateTime.parse("2020-04-23 19:00:00");
var duration = time.difference(now);
var time, duration;
if (course.content[i].time != "") {
time = DateTime.parse(course.content[i].time);
duration = time.difference(now);
}
dataRows.add(DataRow(
cells: [
DataCell(
course.content[i].status.contains('已提交')
? Icon(Icons.done_all)
: duration.inHours <= 0
course.content[i].status.contains('已提交') ||
course.content[i].status.contains('重新提交') ||
course.content[i].status.contains('已返还') ||
course.content[i].time == ""
? Icon(Icons.check_circle_outline)
: duration.inHours < 0
? Text('已截止')
: Text('剩${duration.inHours.toString()}h'),
: duration.inDays > 0
? Text('剩${duration.inDays.toString()}天')
: Text('剩${duration.inHours.toString()}时'),
),
DataCell(Text(
'${course.content[i].text}',
textAlign: TextAlign.center,
)),
DataCell(Text(
'${course.content[i].time}',
textAlign: TextAlign.center,
)),
DataCell(Text('${course.content[i].text}')),
DataCell(course.content[i].time == ""
? Text('没有截止时间')
: Text('${course.content[i].time}')),
],
));
}
Expand All @@ -78,10 +82,11 @@ class _CourseCenterPageState extends State<CourseCenterPage> {
for (int i = 0; i < snapshot.data.courses.length; i++) {
if (!mList.contains(i)) {
mList.add(i);
courseList.add(ExpandStateBean(i, true)); //item初始状态为闭着的
courseList.add(ExpandStateBean(i, false)); //item初始状态为闭着的
}
}
return SingleChildScrollView(
scrollDirection: Axis.vertical,
child: ExpansionPanelList(
//交互回调属性,里面是个匿名函数
expansionCallback: (index, bol) {
Expand Down Expand Up @@ -131,7 +136,7 @@ class _CourseCenterPageState extends State<CourseCenterPage> {
);
} else {
return Container(
alignment: Alignment(0.0, -0.2),
alignment: Alignment(0.0, 0.0),
child: CircularProgressIndicator(
valueColor: new AlwaysStoppedAnimation<Color>(Colors.blue),
));
Expand Down
18 changes: 12 additions & 6 deletions jiaowu_assistent/lib/pages/EmptyRoomPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,20 @@ class _DateTimeDemoState extends State<EmptyRoomPage> {
}
try {
currBuilding = buildingMap[_selectedCampus - 1][_selectedBuilding];
getEmptyRoom(campusMap[_selectedCampus], DateFormat('yyyy-MM-dd').format(_selectedDate), section,
getEmptyRoom(context, campusMap[_selectedCampus], DateFormat('yyyy-MM-dd').format(_selectedDate), section,
buildingMap[_selectedCampus - 1][_selectedBuilding]).then((EmptyRoom temp) {
setState(() {
response = temp.getResPonse();
if (temp.getRooms() == null) {
if (temp == null) {
_list = null;
}
else {
_list = temp.getRooms();
response = temp.getResPonse();
if (temp.getRooms() == null) {
_list = null;
}
else {
_list = temp.getRooms();
}
}
});
});
Expand Down Expand Up @@ -147,7 +152,7 @@ class _DateTimeDemoState extends State<EmptyRoomPage> {
textAlign: TextAlign.center,
style: TextStyle(color: Colors.red, fontSize: 20),
),
subtitle: Text(response),
// subtitle: Text(response),
// subtitle: Text(buildingMap[_selectedBuilding] + " " + lessonMap[_selectedBegin] + "->" + lessonMap[_selectedEnd], textAlign: TextAlign.center,),
trailing: Icon(Icons.not_interested, color: Colors.red,),
),
Expand Down Expand Up @@ -238,6 +243,7 @@ class _DateTimeDemoState extends State<EmptyRoomPage> {
elevation: 0.0,
),
body: SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Expand Down Expand Up @@ -347,7 +353,7 @@ class _DateTimeDemoState extends State<EmptyRoomPage> {
items: getListData(),
onChanged: (value){
setState(() {
if (_selectedEnd != null && value < _selectedBegin) {
if (_selectedBegin != null && value < _selectedBegin) {
_showAlertDialog();
}
else {
Expand Down
8 changes: 4 additions & 4 deletions jiaowu_assistent/lib/pages/FunctionsPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:jiaowuassistent/pages/CourseTablePage.dart';


class FunctionsPage extends StatelessWidget {

// 图标函数,其中page 参数需要给出页面函数

Column _block(BuildContext context, Icon icon, Text text, Widget page) {
Expand Down Expand Up @@ -53,19 +53,19 @@ class FunctionsPage extends StatelessWidget {
_block(context, Icon(Icons.school, size: 40,), Text("成绩查询"), ScorePage()),

_block(context, Icon(Icons.business, size: 40,), Text("空教室查询"), EmptyRoomPage()),

_block(context, Icon(Icons.check_circle_outline, size: 40,), Text("课程中心查询"), CourseCenterPage()),
],
),
SizedBox(height: 40,),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
_block(context, Icon(Icons.school, size: 40,), Text("课程评价"), ScorePage()),
// _block(context, Icon(Icons.school, size: 40,), Text("课程评价"), ScorePage()),

_block(context, Icon(Icons.date_range, size: 40,), Text("课表查询"), CourseTablePage()),

_block(context, Icon(Icons.date_range, size: 40,), Text("未知"), ScorePage()),
// _block(context, Icon(Icons.date_range, size: 40,), Text("未知"), ScorePage()),
],
)
],
Expand Down
7 changes: 7 additions & 0 deletions jiaowu_assistent/lib/pages/HomePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,18 @@ class _MyHomePageState extends State<MyHomePage> {
_controller.dispose();
}

void _pageChange(int index) {
setState(() {
_currentIndex = index;
});
}

@override
Widget build(BuildContext context) {
// TODO: implement build
return new Scaffold(
body: new PageView(
onPageChanged: _pageChange,
children: <Widget>[
FirstPage(),
//CourseTablePage(),
Expand Down
9 changes: 4 additions & 5 deletions jiaowu_assistent/lib/pages/LoginPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ class _LoginPageStateBody extends State<LoginPageBody> {
//contentType: "applicatio/json",
);
try{
/*
Response response;
response = await new Dio(options).request(
'http://114.115.208.32:8000/login/',
Expand All @@ -184,13 +183,13 @@ class _LoginPageStateBody extends State<LoginPageBody> {
//保存用户信息
GlobalUser.setUser(_userNameController.text, _passwordController.text,
response.data['name'], response.data['student_id']);
*/
GlobalUser.setUser(_userNameController.text, _passwordController.text,
'张艺璇', '17373182');
// GlobalUser.setUser(_userNameController.text, _passwordController.text,
// '张艺璇', '17373182');
GlobalUser.setIsLogin(true);
GlobalUser.setChoice(1);//课表

Navigator.push(context, MaterialPageRoute(builder: (context) => MyHomePage()));
// Navigator.push(context, MaterialPageRoute(builder: (context) => MyHomePage()));
Navigator.pushReplacementNamed(context, '/homePage');
}catch(e){
print(e.toString());
if(e.toString()!='账号或密码错误'){
Expand Down
6 changes: 6 additions & 0 deletions jiaowu_assistent/lib/pages/Person.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,13 @@ class _PersonPageState extends State<PersonPage> {
title: Text("退出登录", style: TextStyle(fontSize: 20), textAlign: TextAlign.center,),
onTap: () {
GlobalUser.setIsLogin(false);
// Navigator.pushAndRemoveUntil(
// context,
// MaterialPageRoute(builder: (BuildContext context) => LoginPage()),
// (Route<dynamic> route) => false,
// );
Navigator.pushNamedAndRemoveUntil(context, '/loginPage', ModalRoute.withName("/loginPage"));
//Navigator.popUntil(context, ModalRoute.withName("/loginPage"));
},
),
decoration: BoxDecoration(border: Border.all(width: 1)),
Expand Down

0 comments on commit 26051f8

Please sign in to comment.