|
|
|
|
@ -25,14 +25,15 @@ class TimetableWidgetState extends State<TimetableWidget> {
|
|
|
|
|
int firstInit = 0;
|
|
|
|
|
|
|
|
|
|
//控制器
|
|
|
|
|
late TimetableWidgetController timetableWidgetController = TimetableWidgetController();
|
|
|
|
|
late TimetableWidgetController timetableWidgetController =
|
|
|
|
|
TimetableWidgetController();
|
|
|
|
|
late CourseController courseController = CourseController.getInstance();
|
|
|
|
|
late TaskController taskController = TaskController();
|
|
|
|
|
|
|
|
|
|
late List timeBlockList = [];
|
|
|
|
|
List taskList = [];
|
|
|
|
|
Map<int, List> timeBlockWeekMap = {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//第一行显示的周几的数据
|
|
|
|
|
var weekList = ['一', '二', '三', '四', '五', '六', '日'];
|
|
|
|
|
//自定义的几个数据,其中信息并不很全,但是目前足够制作课表界面
|
|
|
|
|
@ -73,9 +74,7 @@ class TimetableWidgetState extends State<TimetableWidget> {
|
|
|
|
|
|
|
|
|
|
TimetableWidgetState({required this.deviceWidth});
|
|
|
|
|
|
|
|
|
|
updateDateByWeekCount() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
updateDateByWeekCount() {}
|
|
|
|
|
|
|
|
|
|
Future<void> futureDo() async {
|
|
|
|
|
print('开始futureDo');
|
|
|
|
|
@ -83,7 +82,6 @@ class TimetableWidgetState extends State<TimetableWidget> {
|
|
|
|
|
//获取数据库课程表
|
|
|
|
|
courseList = await courseController.getCourses();
|
|
|
|
|
taskList = await taskController.getTasks();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//执行初始化,将需要的数值进行加工
|
|
|
|
|
@ -92,7 +90,7 @@ class TimetableWidgetState extends State<TimetableWidget> {
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dataInitAfterFutherDo(){
|
|
|
|
|
dataInitAfterFutherDo() {
|
|
|
|
|
//初始化
|
|
|
|
|
timeBlockWeekMap = {};
|
|
|
|
|
timeBlockList = [];
|
|
|
|
|
@ -102,7 +100,8 @@ class TimetableWidgetState extends State<TimetableWidget> {
|
|
|
|
|
|
|
|
|
|
timeBlockList.addAll(courseList);
|
|
|
|
|
timeBlockList.addAll(taskList);
|
|
|
|
|
timeBlockWeekMap = timetableWidgetController.transformCourseMap(timeBlockList);
|
|
|
|
|
timeBlockWeekMap =
|
|
|
|
|
timetableWidgetController.transformCourseMap(timeBlockList);
|
|
|
|
|
|
|
|
|
|
//获取本周星期一是几号
|
|
|
|
|
var mondayTime = timetableWidgetController.getmondayTime();
|
|
|
|
|
@ -115,18 +114,19 @@ class TimetableWidgetState extends State<TimetableWidget> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//调用函数初始化时间轴的绝对坐标
|
|
|
|
|
positions = timetableWidgetController.convertTimeList(timePoints, deviceWidth);
|
|
|
|
|
positions =
|
|
|
|
|
timetableWidgetController.convertTimeList(timePoints, deviceWidth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateAfterFutherDo(){
|
|
|
|
|
updateAfterFutherDo() {
|
|
|
|
|
timeBlockWeekMap = {};
|
|
|
|
|
timeBlockList = [];
|
|
|
|
|
|
|
|
|
|
timeBlockList.addAll(courseList);
|
|
|
|
|
timeBlockList.addAll(taskList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
timeBlockWeekMap = timetableWidgetController.transformCourseMap(timeBlockList);//按每周分组
|
|
|
|
|
timeBlockWeekMap =
|
|
|
|
|
timetableWidgetController.transformCourseMap(timeBlockList); //按每周分组
|
|
|
|
|
|
|
|
|
|
var mondayTime = timetableWidgetController.getmondayTime();
|
|
|
|
|
//更新初始化日期列表
|
|
|
|
|
@ -141,238 +141,256 @@ class TimetableWidgetState extends State<TimetableWidget> {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext contexvoidt) {
|
|
|
|
|
return Consumer<TimeProvider>(
|
|
|
|
|
builder: (ctx, timePro, child) {
|
|
|
|
|
print('Rebuild timePro');
|
|
|
|
|
return FutureBuilder<void>(
|
|
|
|
|
future: futureDo(),
|
|
|
|
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
|
|
|
|
// 请求已结束
|
|
|
|
|
if (snapshot.connectionState == ConnectionState.done) {
|
|
|
|
|
if(firstInit == 0){ //第一次初始化
|
|
|
|
|
dataInitAfterFutherDo();
|
|
|
|
|
firstInit = 1;
|
|
|
|
|
}else{ //更新
|
|
|
|
|
updateAfterFutherDo();
|
|
|
|
|
}
|
|
|
|
|
return RefreshIndicator(
|
|
|
|
|
onRefresh: () {
|
|
|
|
|
print('下拉refresh');
|
|
|
|
|
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:
|
|
|
|
|
return Consumer<TimeProvider>(builder: (ctx, timePro, child) {
|
|
|
|
|
print('Rebuild timePro');
|
|
|
|
|
return FutureBuilder<void>(
|
|
|
|
|
future: futureDo(),
|
|
|
|
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
|
|
|
|
// 请求已结束
|
|
|
|
|
if (snapshot.connectionState == ConnectionState.done) {
|
|
|
|
|
if (firstInit == 0) {
|
|
|
|
|
//第一次初始化
|
|
|
|
|
dataInitAfterFutherDo();
|
|
|
|
|
firstInit = 1;
|
|
|
|
|
} else {
|
|
|
|
|
//更新
|
|
|
|
|
updateAfterFutherDo();
|
|
|
|
|
}
|
|
|
|
|
return RefreshIndicator(
|
|
|
|
|
onRefresh: () {
|
|
|
|
|
print('下拉refresh');
|
|
|
|
|
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() +
|
|
|
|
|
'周', //显示周数
|
|
|
|
|
//每行显示的数量
|
|
|
|
|
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: currentWeek ==
|
|
|
|
|
weekCount //如果是当前周,就显示蓝色
|
|
|
|
|
? Colors.amber
|
|
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
width: deviceWidth * 0.84,
|
|
|
|
|
height: 2,
|
|
|
|
|
color: const Color.fromARGB(
|
|
|
|
|
255, 136, 61, 61),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: 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,
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
//第二个Stack
|
|
|
|
|
Container(
|
|
|
|
|
constraints: BoxConstraints
|
|
|
|
|
.expand(), // 使用constraints来自适应
|
|
|
|
|
// width: 390,
|
|
|
|
|
// 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),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
children: List.generate(
|
|
|
|
|
timeBlockWeekMap
|
|
|
|
|
.containsKey(weekCount)
|
|
|
|
|
? timeBlockWeekMap[weekCount]!
|
|
|
|
|
.length
|
|
|
|
|
: 0,
|
|
|
|
|
(index) {
|
|
|
|
|
var currentItem = timeBlockWeekMap[
|
|
|
|
|
weekCount]![index];
|
|
|
|
|
return Positioned(
|
|
|
|
|
top: timetableWidgetController
|
|
|
|
|
.getdy(currentItem) +
|
|
|
|
|
10,
|
|
|
|
|
left: timetableWidgetController
|
|
|
|
|
.getdx(currentItem) +
|
|
|
|
|
deviceWidth * 0.15,
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: deviceWidth * 0.115,
|
|
|
|
|
height:
|
|
|
|
|
timetableWidgetController
|
|
|
|
|
.getHeight(
|
|
|
|
|
currentItem),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: getItemColor(
|
|
|
|
|
currentItem),
|
|
|
|
|
borderRadius:
|
|
|
|
|
BorderRadius.all(
|
|
|
|
|
Radius.circular(10.0),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
if (currentItem
|
|
|
|
|
is Course)
|
|
|
|
|
CouresBlockContenWidget(
|
|
|
|
|
currentItem:
|
|
|
|
|
currentItem),
|
|
|
|
|
if (currentItem is Task)
|
|
|
|
|
TaskBlockContentWidget(
|
|
|
|
|
currentItem:
|
|
|
|
|
currentItem),
|
|
|
|
|
if (currentItem is Work)
|
|
|
|
|
WorkBlockContentWidget(
|
|
|
|
|
currentItem:
|
|
|
|
|
currentItem),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
//第二个Stack
|
|
|
|
|
Container(
|
|
|
|
|
constraints: BoxConstraints
|
|
|
|
|
.expand(), // 使用constraints来自适应
|
|
|
|
|
// width: 390,
|
|
|
|
|
// height: 2000,
|
|
|
|
|
child: Stack(
|
|
|
|
|
children: List.generate(
|
|
|
|
|
timeBlockWeekMap.containsKey(weekCount)
|
|
|
|
|
? timeBlockWeekMap[weekCount]!.length
|
|
|
|
|
: 0,
|
|
|
|
|
(index) {
|
|
|
|
|
var currentItem = timeBlockWeekMap[weekCount]![index];
|
|
|
|
|
return Positioned(
|
|
|
|
|
top: timetableWidgetController.getdy(currentItem) + 10,
|
|
|
|
|
left: timetableWidgetController.getdx(currentItem) + deviceWidth * 0.15,
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: deviceWidth * 0.115,
|
|
|
|
|
height: timetableWidgetController.getHeight(currentItem),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: getItemColor(currentItem),
|
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
|
Radius.circular(10.0),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
if (currentItem is Course)
|
|
|
|
|
CouresBlockContenWidget(currentItem: currentItem),
|
|
|
|
|
if (currentItem is Task)
|
|
|
|
|
TaskBlockContentWidget(currentItem: currentItem),
|
|
|
|
|
if (currentItem is Work)
|
|
|
|
|
WorkBlockContentWidget(currentItem: currentItem),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return Center(
|
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return Center(
|
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 根据类型返回对应的颜色
|
|
|
|
|
@ -386,7 +404,106 @@ class TimetableWidgetState extends State<TimetableWidget> {
|
|
|
|
|
}
|
|
|
|
|
return Colors.tealAccent; // 默认颜色
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class BlockGestureWidget extends StatelessWidget {
|
|
|
|
|
const BlockGestureWidget({
|
|
|
|
|
super.key,
|
|
|
|
|
required this.currentItem,
|
|
|
|
|
required this.blockGestureWidgetChilld,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
final currentItem;
|
|
|
|
|
final blockGestureWidgetChilld;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: () {
|
|
|
|
|
// 弹出大号弹窗
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return AlertDialog(
|
|
|
|
|
// 根据currentItem显示更多信息
|
|
|
|
|
title: Text(currentItem.name),
|
|
|
|
|
content: SingleChildScrollView(
|
|
|
|
|
child: ListBody(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
if (currentItem is Course) ...{
|
|
|
|
|
Text('老师: ${(currentItem as Course).teacher ?? ""}'),
|
|
|
|
|
Text('地点: ${(currentItem as Course).location ?? ""}'),
|
|
|
|
|
Text('开始时间: ${(currentItem as Course).startTime.toString()}'),
|
|
|
|
|
Text('结束时间: ${(currentItem as Course).endTime.toString()}'),
|
|
|
|
|
Text('备注: ${(currentItem as Course).remark ?? ""}'),
|
|
|
|
|
} else if (currentItem is Task) ...{
|
|
|
|
|
Text('内容: ${(currentItem as Task).content ?? ""}'),
|
|
|
|
|
Text('开始时间: ${(currentItem as Task).startTime.toString()}'),
|
|
|
|
|
Text('结束时间: ${(currentItem as Task).endTime.toString()}'),
|
|
|
|
|
} else if (currentItem is Work) ...{
|
|
|
|
|
Text('工作内容: ${(currentItem as Work).workContent ?? ""}'),
|
|
|
|
|
Text('开始时间: ${(currentItem as Work).startTime.toString()}'),
|
|
|
|
|
Text('结束时间: ${(currentItem as Work).endTime.toString()}'),
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
actions: <Widget>[
|
|
|
|
|
TextButton(
|
|
|
|
|
child: Text('关闭'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
onLongPress: () {
|
|
|
|
|
// 弹出选项
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return AlertDialog(
|
|
|
|
|
title: Text('选择操作'),
|
|
|
|
|
content: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
ElevatedButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
// TODO: 添加编辑功能
|
|
|
|
|
if (currentItem is Course) {
|
|
|
|
|
} else if (currentItem is Task) {
|
|
|
|
|
} else {}
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
child: Text('编辑'),
|
|
|
|
|
),
|
|
|
|
|
ElevatedButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
// TODO: 添加删除功能
|
|
|
|
|
if (currentItem is Course) {
|
|
|
|
|
CourseController()
|
|
|
|
|
.deleteCourse((currentItem as Course).getCourseId);
|
|
|
|
|
} else if (currentItem is Task) {
|
|
|
|
|
TaskController().deleteTaskByTaskid(
|
|
|
|
|
(currentItem as Task).getTaskId);
|
|
|
|
|
} else {}
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
child: Text('删除'),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 10),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
child: blockGestureWidgetChilld,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class CouresBlockContenWidget extends StatelessWidget {
|
|
|
|
|
@ -399,56 +516,59 @@ class CouresBlockContenWidget extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Course).name,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
return BlockGestureWidget(
|
|
|
|
|
currentItem: currentItem,
|
|
|
|
|
blockGestureWidgetChilld: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Course).name,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Course).teacher,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 8,
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Course).teacher,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 8,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Course).location,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Course).location,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Course).startTime.hour.toString() +
|
|
|
|
|
':' +
|
|
|
|
|
(currentItem as Course).startTime.minute.toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Course).startTime.hour.toString() +
|
|
|
|
|
':' +
|
|
|
|
|
(currentItem as Course).startTime.minute.toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Course).endTime.hour.toString() +
|
|
|
|
|
':' +
|
|
|
|
|
(currentItem as Course).endTime.minute.toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Course).endTime.hour.toString() +
|
|
|
|
|
':' +
|
|
|
|
|
(currentItem as Course).endTime.minute.toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Course).remark,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Course).remark,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -463,38 +583,41 @@ class TaskBlockContentWidget extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Task).name,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
return BlockGestureWidget(
|
|
|
|
|
currentItem: currentItem,
|
|
|
|
|
blockGestureWidgetChilld: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Task).name,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Task).content,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 8,
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Task).content,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 8,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Task).startTime.toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Task).startTime.toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Task).endTime.toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
Text(
|
|
|
|
|
(currentItem as Task).endTime.toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -509,38 +632,41 @@ class WorkBlockContentWidget extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
currentItem.name,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
return BlockGestureWidget(
|
|
|
|
|
currentItem: currentItem,
|
|
|
|
|
blockGestureWidgetChilld: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
currentItem.name,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
currentItem.workContent,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 8,
|
|
|
|
|
Text(
|
|
|
|
|
currentItem.workContent,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 8,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
currentItem.startTime.toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
Text(
|
|
|
|
|
currentItem.startTime.toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
currentItem.endTime.toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
Text(
|
|
|
|
|
currentItem.endTime.toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|