|
|
|
|
@ -2,16 +2,19 @@ import 'dart:io';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:timemanagerapp/controller/CourseController.dart';
|
|
|
|
|
import 'package:timemanagerapp/controller/CourseWidgetController.dart';
|
|
|
|
|
|
|
|
|
|
import '../entity/Course.dart';
|
|
|
|
|
import '../provider/TimeProvider.dart';
|
|
|
|
|
import '../setting/Setting.dart';
|
|
|
|
|
|
|
|
|
|
class TimetableWidget extends StatefulWidget {
|
|
|
|
|
final double deviceWidth=Setting.deviceWidth;
|
|
|
|
|
final double deviceWidth = Setting.deviceWidth;
|
|
|
|
|
@override
|
|
|
|
|
State<StatefulWidget> createState() => TimetableWidgetState(deviceWidth: deviceWidth);
|
|
|
|
|
State<StatefulWidget> createState() =>
|
|
|
|
|
TimetableWidgetState(deviceWidth: deviceWidth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TimetableWidgetState extends State<TimetableWidget> {
|
|
|
|
|
@ -71,318 +74,351 @@ class TimetableWidgetState extends State<TimetableWidget> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//执行初始化,将需要的数值进行加工
|
|
|
|
|
@override
|
|
|
|
|
initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
|
|
courseController.getCourses().then((res) {
|
|
|
|
|
courseList = res;
|
|
|
|
|
|
|
|
|
|
//数据初始化
|
|
|
|
|
//获取数据库课程表
|
|
|
|
|
// courseList = await courseController.getCourses();
|
|
|
|
|
//获取本周星期一是几号
|
|
|
|
|
var mondayTime = courseWidgetController.getmondayTime();
|
|
|
|
|
currentWeek = courseWidgetController.getWeekCount();
|
|
|
|
|
weekCount = currentWeek;
|
|
|
|
|
// courseList = CourseWidgetController.testcourseList;
|
|
|
|
|
weekCount = courseWidgetController.getWeekCount();
|
|
|
|
|
courseWeekMap = courseWidgetController.transformCourseMap(courseList);
|
|
|
|
|
Future<void> futureDo() async {
|
|
|
|
|
courseList = await courseController.getCourses();
|
|
|
|
|
//数据初始化
|
|
|
|
|
//获取数据库课程表
|
|
|
|
|
// courseList = await courseController.getCourses();
|
|
|
|
|
//获取本周星期一是几号
|
|
|
|
|
var mondayTime = courseWidgetController.getmondayTime();
|
|
|
|
|
currentWeek = courseWidgetController.getWeekCount();
|
|
|
|
|
weekCount = currentWeek;
|
|
|
|
|
// courseList = CourseWidgetController.testcourseList;
|
|
|
|
|
weekCount = courseWidgetController.getWeekCount();
|
|
|
|
|
courseWeekMap = courseWidgetController.transformCourseMap(courseList);
|
|
|
|
|
|
|
|
|
|
//初始化日期列表
|
|
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
|
|
dateListstr.add((mondayTime.day + i).toString());
|
|
|
|
|
if ((mondayTime.day + i) == DateTime.now().day) {
|
|
|
|
|
currentWeekDayIndex = i + 1;
|
|
|
|
|
}
|
|
|
|
|
//初始化日期列表
|
|
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
|
|
dateListstr.add((mondayTime.day + i).toString());
|
|
|
|
|
if ((mondayTime.day + i) == DateTime.now().day) {
|
|
|
|
|
currentWeekDayIndex = i + 1;
|
|
|
|
|
}
|
|
|
|
|
// print('Recent monday '+DateTime.now().day.toString());
|
|
|
|
|
}
|
|
|
|
|
// print('Recent monday '+DateTime.now().day.toString());
|
|
|
|
|
|
|
|
|
|
//调用函数初始化时间轴的绝对坐标
|
|
|
|
|
positions =
|
|
|
|
|
courseWidgetController.convertTimeList(timePoints, deviceWidth);
|
|
|
|
|
//调用函数初始化时间轴的绝对坐标
|
|
|
|
|
positions = courseWidgetController.convertTimeList(timePoints, deviceWidth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
loading = false;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
//执行初始化,将需要的数值进行加工
|
|
|
|
|
@override
|
|
|
|
|
initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
if (loading == false) {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onHorizontalDragEnd: (details) {
|
|
|
|
|
if (details.primaryVelocity! > 0) {
|
|
|
|
|
// 右滑
|
|
|
|
|
setState(() {
|
|
|
|
|
weekCount--;
|
|
|
|
|
updateDateByWeekCount();
|
|
|
|
|
});
|
|
|
|
|
} else if (details.primaryVelocity! < 0) {
|
|
|
|
|
// 左滑
|
|
|
|
|
setState(() {
|
|
|
|
|
weekCount++;
|
|
|
|
|
updateDateByWeekCount();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, //垂直方向居中对齐
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
//顶部的周数和日期
|
|
|
|
|
//显示第一行的周天数和日期
|
|
|
|
|
child: GridView.builder(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
//解决无限高度问题
|
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
|
//禁用滑动事件
|
|
|
|
|
itemCount: 8,
|
|
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
|
crossAxisCount: 8, childAspectRatio: 1 / 1),
|
|
|
|
|
//每行显示的数量
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
//构建每个item的样式
|
|
|
|
|
return Container(
|
|
|
|
|
color: index == this.currentWeekDayIndex
|
|
|
|
|
? Color(0xf7f7f7) //如果是当前周,就显示灰色
|
|
|
|
|
: Colors.white,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: index == 0
|
|
|
|
|
? Column(
|
|
|
|
|
//第一行显示第几周
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
// height: 10,
|
|
|
|
|
// width: 6,
|
|
|
|
|
child: Text(
|
|
|
|
|
'第' + weekCount.toString() + '周', //显示周数
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
color: currentWeek ==
|
|
|
|
|
weekCount //如果是当前周,就显示蓝色
|
|
|
|
|
? Colors.amber
|
|
|
|
|
: Colors.black87)),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Text(weekList[index - 1], //显示周数
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
color: index ==
|
|
|
|
|
currentWeekDayIndex //如果是当前周,就显示蓝色
|
|
|
|
|
? Colors.lightBlue
|
|
|
|
|
: Colors.black87)),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 5,
|
|
|
|
|
),
|
|
|
|
|
Text(dateListstr[index - 1], //显示日期
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
color: index ==
|
|
|
|
|
currentWeekDayIndex //如果是当前周,就显示蓝色
|
|
|
|
|
? Colors.lightBlue
|
|
|
|
|
: Colors.black87)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
//显示下面的界面中的两个stack,一个下层的时间轴,一个是上层课程或者人物的方块
|
|
|
|
|
Expanded(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
//借助两个stack重叠,实现效果
|
|
|
|
|
Container(
|
|
|
|
|
width: deviceWidth,
|
|
|
|
|
height: 2000,
|
|
|
|
|
child: Stack(
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
// 第一个Stack
|
|
|
|
|
Positioned(
|
|
|
|
|
top: 0,
|
|
|
|
|
left: 0,
|
|
|
|
|
child: Container(
|
|
|
|
|
width: deviceWidth,
|
|
|
|
|
height: 2000,
|
|
|
|
|
child: Stack(
|
|
|
|
|
children: List.generate(
|
|
|
|
|
//根据时间轴的长度,生成对应的时间轴
|
|
|
|
|
positions.length,
|
|
|
|
|
(index) => Positioned(
|
|
|
|
|
top: positions[index].dy,
|
|
|
|
|
left: positions[index].dx,
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
timePoints[index]
|
|
|
|
|
.hour
|
|
|
|
|
.toString()
|
|
|
|
|
.padLeft(2, '0') +
|
|
|
|
|
':' +
|
|
|
|
|
timePoints[index]
|
|
|
|
|
.minute
|
|
|
|
|
.toString()
|
|
|
|
|
.padLeft(2, '0'),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
width: deviceWidth * 0.04,
|
|
|
|
|
height: 10,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: Colors.amber,
|
|
|
|
|
width: 2,
|
|
|
|
|
),
|
|
|
|
|
Widget build(BuildContext contexvoidt) {
|
|
|
|
|
return Consumer<TimeProvider>(
|
|
|
|
|
builder: (ctx, timePro, child) {
|
|
|
|
|
print('Rebuild timePro.updatTimtTablecount = ' + timePro.updatTimtTablecount.toString());
|
|
|
|
|
return FutureBuilder<void>(
|
|
|
|
|
future: futureDo(),
|
|
|
|
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
|
|
|
|
// 请求已结束
|
|
|
|
|
if (snapshot.connectionState == ConnectionState.done) {
|
|
|
|
|
return RefreshIndicator(
|
|
|
|
|
onRefresh: () {
|
|
|
|
|
return futureDo().then((value) => setState(() {}));
|
|
|
|
|
},
|
|
|
|
|
child: GestureDetector(
|
|
|
|
|
onHorizontalDragEnd: (details) {
|
|
|
|
|
if (details.primaryVelocity! > 0) {
|
|
|
|
|
// 右滑
|
|
|
|
|
setState(() {
|
|
|
|
|
weekCount--;
|
|
|
|
|
updateDateByWeekCount();
|
|
|
|
|
});
|
|
|
|
|
} else if (details.primaryVelocity! < 0) {
|
|
|
|
|
// 左滑
|
|
|
|
|
setState(() {
|
|
|
|
|
weekCount++;
|
|
|
|
|
updateDateByWeekCount();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, //垂直方向居中对齐
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
//顶部的周数和日期
|
|
|
|
|
//显示第一行的周天数和日期
|
|
|
|
|
child: GridView.builder(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
//解决无限高度问题
|
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
|
//禁用滑动事件
|
|
|
|
|
itemCount: 8,
|
|
|
|
|
gridDelegate:
|
|
|
|
|
SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
|
crossAxisCount: 8, childAspectRatio: 1 / 1),
|
|
|
|
|
//每行显示的数量
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
//构建每个item的样式
|
|
|
|
|
return Container(
|
|
|
|
|
color: index == this.currentWeekDayIndex
|
|
|
|
|
? Color(0xf7f7f7) //如果是当前周,就显示灰色
|
|
|
|
|
: Colors.white,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: index == 0
|
|
|
|
|
? Column(
|
|
|
|
|
//第一行显示第几周
|
|
|
|
|
mainAxisAlignment:
|
|
|
|
|
MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
// height: 10,
|
|
|
|
|
// width: 6,
|
|
|
|
|
child: Text(
|
|
|
|
|
'第' +
|
|
|
|
|
weekCount.toString() +
|
|
|
|
|
'周', //显示周数
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
color: currentWeek ==
|
|
|
|
|
weekCount //如果是当前周,就显示蓝色
|
|
|
|
|
? Colors.amber
|
|
|
|
|
: Colors.black87)),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: Column(
|
|
|
|
|
mainAxisAlignment:
|
|
|
|
|
MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Text(weekList[index - 1], //显示周数
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
color: index ==
|
|
|
|
|
currentWeekDayIndex //如果是当前周,就显示蓝色
|
|
|
|
|
? Colors.lightBlue
|
|
|
|
|
: Colors.black87)),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 5,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
width: deviceWidth * 0.84,
|
|
|
|
|
height: 2,
|
|
|
|
|
color: const Color.fromARGB(
|
|
|
|
|
255, 136, 61, 61),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
Text(dateListstr[index - 1], //显示日期
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
color: index ==
|
|
|
|
|
currentWeekDayIndex //如果是当前周,就显示蓝色
|
|
|
|
|
? Colors.lightBlue
|
|
|
|
|
: Colors.black87)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
//第二个Stack
|
|
|
|
|
Container(
|
|
|
|
|
constraints:
|
|
|
|
|
BoxConstraints.expand(), // 使用constraints来自适应
|
|
|
|
|
// width: 390,
|
|
|
|
|
// height: 2000,
|
|
|
|
|
child: Stack(
|
|
|
|
|
children: List.generate(
|
|
|
|
|
//根据课程的数量,生成对应的课程方块
|
|
|
|
|
courseWeekMap.containsKey(weekCount)
|
|
|
|
|
? courseWeekMap[weekCount]!.length
|
|
|
|
|
: 0,
|
|
|
|
|
((index) => Positioned(
|
|
|
|
|
top: courseWeekMap[weekCount]![index]
|
|
|
|
|
.getdy() +
|
|
|
|
|
10,
|
|
|
|
|
left: courseWeekMap[weekCount]![index]
|
|
|
|
|
.getdx() +
|
|
|
|
|
deviceWidth*0.15,
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Container(
|
|
|
|
|
//课程方块
|
|
|
|
|
width: deviceWidth * 0.115,
|
|
|
|
|
height:
|
|
|
|
|
courseWeekMap[weekCount]![index]
|
|
|
|
|
.getHeight(),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.tealAccent,
|
|
|
|
|
// 设置颜色
|
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
|
Radius.circular(
|
|
|
|
|
10.0)), // 添加圆角
|
|
|
|
|
),
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
//课程方块中的文字
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
courseWeekMap[weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.name,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
fontWeight:
|
|
|
|
|
FontWeight.bold),
|
|
|
|
|
overflow: TextOverflow
|
|
|
|
|
.clip, //name加粗
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
courseWeekMap[weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.teacher,
|
|
|
|
|
style:
|
|
|
|
|
TextStyle(fontSize: 8),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
courseWeekMap[weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.location,
|
|
|
|
|
style:
|
|
|
|
|
TextStyle(fontSize: 10),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
courseWeekMap[weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.start
|
|
|
|
|
.hour
|
|
|
|
|
.toString() +
|
|
|
|
|
':' +
|
|
|
|
|
courseWeekMap[
|
|
|
|
|
weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.start
|
|
|
|
|
.minute
|
|
|
|
|
.toString(),
|
|
|
|
|
style:
|
|
|
|
|
TextStyle(fontSize: 10),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
courseWeekMap[weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.end
|
|
|
|
|
.hour
|
|
|
|
|
.toString() +
|
|
|
|
|
':' +
|
|
|
|
|
courseWeekMap[
|
|
|
|
|
weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.end
|
|
|
|
|
.minute
|
|
|
|
|
.toString(),
|
|
|
|
|
style:
|
|
|
|
|
TextStyle(fontSize: 10),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
courseWeekMap[weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.remark,
|
|
|
|
|
style:
|
|
|
|
|
TextStyle(fontSize: 10),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
//显示下面的界面中的两个stack,一个下层的时间轴,一个是上层课程或者人物的方块
|
|
|
|
|
Expanded(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
//借助两个stack重叠,实现效果
|
|
|
|
|
Container(
|
|
|
|
|
width: deviceWidth,
|
|
|
|
|
height: 2000,
|
|
|
|
|
child: Stack(
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
// 第一个Stack
|
|
|
|
|
Positioned(
|
|
|
|
|
top: 0,
|
|
|
|
|
left: 0,
|
|
|
|
|
child: Container(
|
|
|
|
|
width: deviceWidth,
|
|
|
|
|
height: 2000,
|
|
|
|
|
child: Stack(
|
|
|
|
|
children: List.generate(
|
|
|
|
|
//根据时间轴的长度,生成对应的时间轴
|
|
|
|
|
positions.length,
|
|
|
|
|
(index) => Positioned(
|
|
|
|
|
top: positions[index].dy,
|
|
|
|
|
left: positions[index].dx,
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
timePoints[index]
|
|
|
|
|
.hour
|
|
|
|
|
.toString()
|
|
|
|
|
.padLeft(2, '0') +
|
|
|
|
|
':' +
|
|
|
|
|
timePoints[index]
|
|
|
|
|
.minute
|
|
|
|
|
.toString()
|
|
|
|
|
.padLeft(2, '0'),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
width: deviceWidth * 0.04,
|
|
|
|
|
height: 10,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: Colors.amber,
|
|
|
|
|
width: 2,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
width: deviceWidth * 0.84,
|
|
|
|
|
height: 2,
|
|
|
|
|
color: const Color.fromARGB(
|
|
|
|
|
255, 136, 61, 61),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
))),
|
|
|
|
|
))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
//第二个Stack
|
|
|
|
|
Container(
|
|
|
|
|
constraints: BoxConstraints
|
|
|
|
|
.expand(), // 使用constraints来自适应
|
|
|
|
|
// width: 390,
|
|
|
|
|
// height: 2000,
|
|
|
|
|
child: Stack(
|
|
|
|
|
children: List.generate(
|
|
|
|
|
//根据课程的数量,生成对应的课程方块
|
|
|
|
|
courseWeekMap.containsKey(weekCount)
|
|
|
|
|
? courseWeekMap[weekCount]!.length
|
|
|
|
|
: 0,
|
|
|
|
|
((index) => Positioned(
|
|
|
|
|
top: courseWeekMap[weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.getdy() +
|
|
|
|
|
10,
|
|
|
|
|
left: courseWeekMap[weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.getdx() +
|
|
|
|
|
deviceWidth * 0.15,
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Container(
|
|
|
|
|
//课程方块
|
|
|
|
|
width: deviceWidth * 0.115,
|
|
|
|
|
height: courseWeekMap[
|
|
|
|
|
weekCount]![index]
|
|
|
|
|
.getHeight(),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.tealAccent,
|
|
|
|
|
// 设置颜色
|
|
|
|
|
borderRadius: BorderRadius
|
|
|
|
|
.all(Radius.circular(
|
|
|
|
|
10.0)), // 添加圆角
|
|
|
|
|
),
|
|
|
|
|
child:
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
//课程方块中的文字
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
courseWeekMap[
|
|
|
|
|
weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.name,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
fontWeight:
|
|
|
|
|
FontWeight
|
|
|
|
|
.bold),
|
|
|
|
|
overflow: TextOverflow
|
|
|
|
|
.clip, //name加粗
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
courseWeekMap[
|
|
|
|
|
weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.teacher,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 8),
|
|
|
|
|
overflow:
|
|
|
|
|
TextOverflow
|
|
|
|
|
.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
courseWeekMap[
|
|
|
|
|
weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.location,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10),
|
|
|
|
|
overflow:
|
|
|
|
|
TextOverflow
|
|
|
|
|
.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
courseWeekMap[weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.start
|
|
|
|
|
.hour
|
|
|
|
|
.toString() +
|
|
|
|
|
':' +
|
|
|
|
|
courseWeekMap[
|
|
|
|
|
weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.start
|
|
|
|
|
.minute
|
|
|
|
|
.toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10),
|
|
|
|
|
overflow:
|
|
|
|
|
TextOverflow
|
|
|
|
|
.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
courseWeekMap[weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.end
|
|
|
|
|
.hour
|
|
|
|
|
.toString() +
|
|
|
|
|
':' +
|
|
|
|
|
courseWeekMap[
|
|
|
|
|
weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.end
|
|
|
|
|
.minute
|
|
|
|
|
.toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10),
|
|
|
|
|
overflow:
|
|
|
|
|
TextOverflow
|
|
|
|
|
.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
courseWeekMap[
|
|
|
|
|
weekCount]![
|
|
|
|
|
index]
|
|
|
|
|
.remark,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10),
|
|
|
|
|
overflow:
|
|
|
|
|
TextOverflow
|
|
|
|
|
.clip,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
))),
|
|
|
|
|
))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return Container(
|
|
|
|
|
child: Text('加载中'),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return Center(
|
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|