diff --git a/src/timemanagerapp/lib/controller/NetWorkController.dart b/src/timemanagerapp/lib/controller/NetWorkController.dart index d031a9f..4db31ce 100644 --- a/src/timemanagerapp/lib/controller/NetWorkController.dart +++ b/src/timemanagerapp/lib/controller/NetWorkController.dart @@ -15,27 +15,6 @@ class NetWorkController { // String baseUrl = "http://5902e9v900.zicp.fun:30002/"; // String baseUrl = "http://5902e9v900.zicp.fun:3000/"; - //getLIst参考模板 - // Future?> getTeamList(int leaderId) async { - // final response = await http.get( - // Uri.parse(baseUrl + 'get_team').replace(queryParameters: {'leaderId': leaderId.toString()}), - // headers: { - // 'Content-Type': 'application/json; charset=UTF-8', - // }, - // - // ); - // - // final jsonResponse = json.decode(response.body); - // if (jsonResponse['code'] == 200) { - // List teamList = (jsonResponse['data'] as List) - // .map((team) => Team.fromJson(team as Map)) - // .toList(); - // return teamList; - // } else { - // return null; - // } - // } - //----------------------登录注册相关---------------------------- //getUserList Future?> getUserList() async { @@ -176,7 +155,7 @@ class NetWorkController { 'Content-Type': 'application/json; charset=UTF-8', }, body: JsonEncoder().convert({ - 'teamId': teamId, + 'teamId':teamId, }), ); @@ -184,6 +163,7 @@ class NetWorkController { if (jsonResponse['code'] == 200) { return true; } else { + print("delete team 失败:" + jsonResponse['data'].toString()); return false; } } @@ -303,6 +283,8 @@ class NetWorkController { if (jsonResponse['code'] == 200) { return true; } else { + print("TeamWork插入失败"); + print("body:"+ workList.map((work) => work.toMap()).toList().toString()); return false; } } diff --git a/src/timemanagerapp/lib/ruters/TeamRoute.dart b/src/timemanagerapp/lib/ruters/TeamRoute.dart index 557548b..ba60f04 100644 --- a/src/timemanagerapp/lib/ruters/TeamRoute.dart +++ b/src/timemanagerapp/lib/ruters/TeamRoute.dart @@ -3,9 +3,11 @@ import 'package:flutter/material.dart'; import '../setting/Setting.dart'; import '../widgets/AddTeamWidget.dart'; -import '../widgets/TeamWidgt.dart'; +import '../widgets/TeamWidget.dart'; class TeamRoute extends StatelessWidget { + //TeamWidgetKey + GlobalKey teamWidgetKey = GlobalKey(); @override Widget build(BuildContext context) { @@ -27,14 +29,15 @@ class TeamRoute extends StatelessWidget { body: TeamWidget(), floatingActionButton: FloatingActionButton( onPressed: () async { - Navigator.push( + await Navigator.push( context, - MaterialPageRoute( + MaterialPageRoute( builder: (context) { return AddTeamWidget(); }, ), ); + teamWidgetKey.currentState!.futureDo(); }, child: Icon(Icons.add), ), diff --git a/src/timemanagerapp/lib/tests/timetable_tes.dart b/src/timemanagerapp/lib/tests/timetable_tes.dart index 3219a16..4f24b5f 100644 --- a/src/timemanagerapp/lib/tests/timetable_tes.dart +++ b/src/timemanagerapp/lib/tests/timetable_tes.dart @@ -1,38 +1,38 @@ -import 'dart:developer'; - -import 'package:flutter/material.dart'; -import 'package:shared_preferences/shared_preferences.dart'; -import 'package:timemanagerapp/setting/Setting.dart'; -import 'package:timemanagerapp/util/GetCourseByLogin.dart'; -import 'package:timemanagerapp/widgets/AddCourseFormWidget.dart'; -import 'package:timemanagerapp/widgets/LoginWidget.dart'; -import 'package:timemanagerapp/widgets/TimetableWidget.dart'; - - -init() async { - WidgetsFlutterBinding.ensureInitialized(); - await Setting.init(); -} - -void main() async { - await init(); - runApp(MyApp()); - - -} - -class MyApp extends StatelessWidget { - - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: Text('课表'), - ), - body: TimetableWidget(), - ), - ); - } -} +// import 'dart:developer'; +// +// import 'package:flutter/material.dart'; +// import 'package:shared_preferences/shared_preferences.dart'; +// import 'package:timemanagerapp/setting/Setting.dart'; +// import 'package:timemanagerapp/util/GetCourseByLogin.dart'; +// import 'package:timemanagerapp/widgets/AddCourseFormWidget.dart'; +// import 'package:timemanagerapp/widgets/LoginWidget.dart'; +// import 'package:timemanagerapp/widgets/TimetableWidget.dart'; +// +// +// init() async { +// WidgetsFlutterBinding.ensureInitialized(); +// await Setting.init(); +// } +// +// void main() async { +// await init(); +// runApp(MyApp()); +// +// +// } +// +// class MyApp extends StatelessWidget { +// +// +// @override +// Widget build(BuildContext context) { +// return MaterialApp( +// home: Scaffold( +// appBar: AppBar( +// title: Text('课表'), +// ), +// body: TimetableWidget(), +// ), +// ); +// } +// } diff --git a/src/timemanagerapp/lib/widgets/AddCourseFormWidget.dart b/src/timemanagerapp/lib/widgets/AddCourseFormWidget.dart index d842b80..1c806a0 100644 --- a/src/timemanagerapp/lib/widgets/AddCourseFormWidget.dart +++ b/src/timemanagerapp/lib/widgets/AddCourseFormWidget.dart @@ -226,11 +226,7 @@ class _AddCourseFormWidgetState extends State { }, child: Text('取消'), ), - Selector( // time状态改变时会重新构建子树 - selector: (ctx, provider) => provider, - shouldRebuild: (pre, next) => false, - builder: (ctx, timePro, child) { - return ElevatedButton( + ElevatedButton( onPressed: () { // 点击确定按钮后的操作 if (_formKey.currentState!.validate()) { @@ -250,7 +246,7 @@ class _AddCourseFormWidgetState extends State { courseController.deleteCourse(exitCourse!.getCourseId).then((value){ courseController.addCourseForm(courseForm).then(((value){ // 关闭当前界面 - timePro.updateTimetable(); + // Provider.of(context, listen: false).updateTimetable(); // 更新菜单栏页面操作 // timePro.updatTimtTablecount = 100; Navigator.pop(context); @@ -259,19 +255,15 @@ class _AddCourseFormWidgetState extends State { }else{ courseController.addCourseForm(courseForm).then(((value){ // 关闭当前界面 - timePro.updateTimetable(); + // Provider.of(context, listen: false).updateTimetable(); // 更新菜单栏页面操作 // timePro.updatTimtTablecount = 100; Navigator.pop(context); - })); } }; }, child: Text('确定'), - ); - }, - // child: Icon(Icons.add), - ), + ), ], ), ], diff --git a/src/timemanagerapp/lib/widgets/AddScheduleFormWidget.dart b/src/timemanagerapp/lib/widgets/AddScheduleFormWidget.dart index fb94fa7..d2b64ad 100644 --- a/src/timemanagerapp/lib/widgets/AddScheduleFormWidget.dart +++ b/src/timemanagerapp/lib/widgets/AddScheduleFormWidget.dart @@ -213,11 +213,7 @@ class _AddScheduleFormWidgetState extends State { }, child: Text('取消'), ), - Selector( // time状态改变时会重新构建子树 - selector: (ctx, provider) => provider, - shouldRebuild: (pre, next) => false, - builder: (ctx, timePro, child) { - return ElevatedButton( + ElevatedButton( onPressed: () { // 点击确定按钮后的操作 if (_formKey.currentState!.validate()) { @@ -236,7 +232,7 @@ class _AddScheduleFormWidgetState extends State { taskController.addScheduleForm(scheduleForm).then(((value){ Provider.of(context, listen: false).updateTimetable(); // 更新时间表页面操作 // 关闭当前界面 - timePro.updateTimetable(); + // Provider.of(context, listen: false).updateTimetable(); // 更新菜单栏页面操作 // timePro.updatTimtTablecount++; Navigator.pop(context); })); @@ -245,7 +241,7 @@ class _AddScheduleFormWidgetState extends State { taskController.addScheduleForm(scheduleForm).then(((value){ Provider.of(context, listen: false).updateTimetable(); // 更新时间表页面操作 // 关闭当前界面 - timePro.updateTimetable(); + // Provider.of(context, listen: false).updateTimetable(); // 更新菜单栏页面操作 // timePro.updatTimtTablecount++; Navigator.pop(context); })); @@ -256,7 +252,7 @@ class _AddScheduleFormWidgetState extends State { teamController.addScheduleForm(scheduleForm,teamId!).then(((value){ Provider.of(context, listen: false).updateTimetable(); // 更新时间表页面操作 // 关闭当前界面 - timePro.updateTimetable(); + // Provider.of(context, listen: false).updateTimetable(); // 更新菜单栏页面操作 // timePro.updatTimtTablecount++; Navigator.pop(context); })); @@ -265,7 +261,6 @@ class _AddScheduleFormWidgetState extends State { teamController.addScheduleForm(scheduleForm,teamId!).then(((value){ Provider.of(context, listen: false).updateTimetable(); // 更新时间表页面操作 // 关闭当前界面 - timePro.updateTimetable(); // timePro.updatTimtTablecount++; Navigator.pop(context); })); @@ -274,9 +269,7 @@ class _AddScheduleFormWidgetState extends State { } }, child: Text('确定'), - ); - } - ), + ), ], ), ], diff --git a/src/timemanagerapp/lib/widgets/HomeWidget.dart b/src/timemanagerapp/lib/widgets/HomeWidget.dart index 727179b..ebafcee 100644 --- a/src/timemanagerapp/lib/widgets/HomeWidget.dart +++ b/src/timemanagerapp/lib/widgets/HomeWidget.dart @@ -28,7 +28,7 @@ class HomeWidget extends StatefulWidget { } class _HomeWidgetState extends State { - GlobalKey timetableWidgetKey = GlobalKey(); //课程表的key + GlobalKey timetableWidgetKey = GlobalKey(); //课程表的key,用于刷新课程表,代表TimetableWidgetState对象 late UserController userController; late CourseController courseController; @@ -76,9 +76,9 @@ class _HomeWidgetState extends State { mainAxisSize: MainAxisSize.min, children: [ ElevatedButton( - onPressed: () { + onPressed: () async { // 导航到AddCourseFormWidget页面 - Navigator.push( + await Navigator.push( context, MaterialPageRoute( builder: (context) { @@ -86,13 +86,19 @@ class _HomeWidgetState extends State { }, ), ); + // setState(() { + // + // }); + //更新课程表从本地数据库 + // print("触发更新课程表"); + timetableWidgetKey.currentState!.localFutureDo(); }, child: Text('添加课程'), ), ElevatedButton( - onPressed: () { + onPressed: () async { // 导航到AddCourseFormWidget页面 - Navigator.push( + await Navigator.push( context, MaterialPageRoute( builder: (context) { @@ -103,6 +109,7 @@ class _HomeWidgetState extends State { }, ), ); + timetableWidgetKey.currentState!.localFutureDo(); }, child: Text('添加个人计划'), ), @@ -131,9 +138,9 @@ class _HomeWidgetState extends State { ), IconButton( icon: const Icon(Icons.group_add), - onPressed: () { + onPressed: () async { //跳转到团队管理界面 - Navigator.push( + await Navigator.push( context, MaterialPageRoute( builder: (context) { @@ -142,6 +149,8 @@ class _HomeWidgetState extends State { }, ), ); + timetableWidgetKey.currentState!.serverFutureDo(); + timetableWidgetKey.currentState!.localFutureDo(); }, ), Builder( @@ -162,10 +171,10 @@ class _HomeWidgetState extends State { children: [ UserAccountsDrawerHeader( accountName: GestureDetector( - onTap: () { + onTap: () async { if (Setting.user!.getId! == -1) { // 导航到登录页面 - Navigator.push( + await Navigator.push( context, MaterialPageRoute( builder: (context) { @@ -176,18 +185,19 @@ class _HomeWidgetState extends State { } else { //退出登录 Setting.saveUser(Setting.nullUser); - setState(() {}); } + setState(() {}); + timetableWidgetKey.currentState!.localFutureDo(); }, child: Setting.user!.getId! != -1 ? Text(Setting.user!.getUsername!) : Text('未登录'), ), accountEmail: GestureDetector( - onTap: () { + onTap: () async { if (Setting.user!.getId! == -1) { // 导航到登录页面 - Navigator.push( + await Navigator.push( context, MaterialPageRoute( builder: (context) { @@ -198,8 +208,9 @@ class _HomeWidgetState extends State { } else { //退出登录 Setting.saveUser(Setting.nullUser); - setState(() {}); } + setState(() {}); + timetableWidgetKey.currentState!.localFutureDo(); }, child: Setting.user!.getId! != -1 ? Text('退出登录') @@ -212,10 +223,10 @@ class _HomeWidgetState extends State { ), ListTile( title: Text('导入学校课程'), - onTap: () { + onTap: () async { //todo // 导航到自动导入页面 - Navigator.push( + await Navigator.push( context, MaterialPageRoute( builder: (context) { @@ -223,6 +234,7 @@ class _HomeWidgetState extends State { }, ), ); + timetableWidgetKey.currentState!.localFutureDo(); }, ), GestureDetector( @@ -248,10 +260,10 @@ class _HomeWidgetState extends State { }, child: ListTile( title: Text('用户设置'), - onTap: () { + onTap: () async { //todo // 导航到deng页面 - Navigator.push( + await Navigator.push( context, MaterialPageRoute( builder: (context) { @@ -259,16 +271,19 @@ class _HomeWidgetState extends State { }, ), ); + setState(() { + + }); }, ), ), if (Setting.user!.getId! == -1) ListTile( title: Text('注册'), - onTap: () { + onTap: () async { //todo // 导航到UserSettingWight页面 - Navigator.push( + await Navigator.push( context, MaterialPageRoute( builder: (context) { @@ -276,13 +291,15 @@ class _HomeWidgetState extends State { }, ), ); + setState(() { + }); }, ), if (Setting.isDeveloperButtonVisible) ListTile( title: Text('开发者测试'), - onTap: () { - Navigator.push( + onTap: () async { + await Navigator.push( context, MaterialPageRoute( builder: (context) { @@ -290,13 +307,16 @@ class _HomeWidgetState extends State { }, ), ); + setState(() { + }); + timetableWidgetKey.currentState!.localFutureDo(); }, ), ], ), ); }), - body: TimetableWidget(), + body: TimetableWidget(key: timetableWidgetKey), ); } diff --git a/src/timemanagerapp/lib/widgets/ManageUserTeamWidget.dart b/src/timemanagerapp/lib/widgets/ManageUserTeamWidget.dart index 73f64f1..ad8c6ed 100644 --- a/src/timemanagerapp/lib/widgets/ManageUserTeamWidget.dart +++ b/src/timemanagerapp/lib/widgets/ManageUserTeamWidget.dart @@ -124,9 +124,8 @@ class _ManageUserTeamWidgetState extends State { child: CircularProgressIndicator(), ); } else { - return Consumer(builder: (ctx, teamPro, child) { - print('Rebuild teamPro'); - return Scaffold( + return + Scaffold( resizeToAvoidBottomInset: false, appBar: AppBar( title: Text('团队成员'), @@ -180,7 +179,6 @@ class _ManageUserTeamWidgetState extends State { ) ), ); - }); - } + } } } diff --git a/src/timemanagerapp/lib/widgets/TeamWidgt.dart b/src/timemanagerapp/lib/widgets/TeamWidget.dart similarity index 89% rename from src/timemanagerapp/lib/widgets/TeamWidgt.dart rename to src/timemanagerapp/lib/widgets/TeamWidget.dart index 718c2c8..e73880e 100644 --- a/src/timemanagerapp/lib/widgets/TeamWidgt.dart +++ b/src/timemanagerapp/lib/widgets/TeamWidget.dart @@ -11,10 +11,10 @@ class TeamWidget extends StatefulWidget { const TeamWidget({Key? key}) : super(key: key); @override - _TeamWidgetState createState() => _TeamWidgetState(); + TeamWidgetState createState() => TeamWidgetState(); } -class _TeamWidgetState extends State { +class TeamWidgetState extends State { int firstInit = 0; List myTeamList = []; @@ -33,39 +33,25 @@ class _TeamWidgetState extends State { //获取数据库课程表 myTeamList = await teamController.getMyTeamList(); joinTeamList = await teamController.getJoinedTeamList(); - } - - dataInitAfterFutherDo() {} - updateAfterFutherDo() {} + setState(() { + }); + } @override initState() { super.initState(); + futureDo(); //todo: get teamList from database } @override Widget build(BuildContext context) { - return Consumer(builder: (ctx, teamUserPro, child) { - print('Rebuild teamUserPro'); - return FutureBuilder( - future: futureDo(), - builder: (BuildContext context, AsyncSnapshot snapshot) { - // 请求已结束 - if (snapshot.connectionState == ConnectionState.done) { - if (firstInit == 0) { - //第一次初始化 - dataInitAfterFutherDo(); - firstInit = 1; - } else { - //更新 - updateAfterFutherDo(); - } - return RefreshIndicator( + print('Rebuild teamUserPro'); + return RefreshIndicator( onRefresh: () { print('下拉refresh'); - return futureDo().then((value) => setState(() {})); + return futureDo(); }, child: CustomScrollView( slivers: [ @@ -148,12 +134,11 @@ class _TeamWidgetState extends State { // 删除团队的功能按键 icon: Icon(Icons.delete), onPressed: () { + print('删除团队'+ team.getTeamName + ' ' + team.id.toString()); teamController .deleteTeam(team.id!) .then((value) { - setState(() { - myTeamList.remove(team); - }); + futureDo(); }); }, ), @@ -236,12 +221,5 @@ class _TeamWidgetState extends State { ], ), ); - } else { - return Center( - child: CircularProgressIndicator(), - ); - } - }); - }); } } diff --git a/src/timemanagerapp/lib/widgets/TimetableWidget.dart b/src/timemanagerapp/lib/widgets/TimetableWidget.dart index 0920255..39f1079 100644 --- a/src/timemanagerapp/lib/widgets/TimetableWidget.dart +++ b/src/timemanagerapp/lib/widgets/TimetableWidget.dart @@ -18,6 +18,7 @@ import '../provider/TimeProvider.dart'; import '../setting/Setting.dart'; class TimetableWidget extends StatefulWidget { + TimetableWidget({required Key key}) : super(key: key); final double deviceWidth = Setting.deviceWidth; @override State createState() => @@ -85,30 +86,36 @@ class TimetableWidgetState extends State { TimetableWidgetState({required this.deviceWidth}); - updateDateByWeekCount() {} - - Future futureDo() async { - print('开始futureDo'); + Future localFutureDo() async { + print('开始localFutureDo'); //获取数据库课程表 courseList = await courseController.getCourses(); taskList = await taskController.getTasks(); - workList = await teamController.getWorks(); + + dataCaculateAfterFutherDo(); + + print('localFutureDo 完成'); + setState(() {}); + } + + Future serverFutureDo() async { + print('开始serverFutureDo'); + + //获取数据库课程表 + workList = await teamController.getWorks(); + + dataCaculateAfterFutherDo(); + + print('serverFutureDo 完成'); + setState(() {}); + } //执行初始化,将需要的数值进行加工 @override initState() { super.initState(); - } - - @override - dispose() { - super.dispose(); - // Setting.saveInitFlag(false); - } - - dataInitAfterFutherDo() { //初始化 timeBlockWeekMap = {}; timeBlockList = []; @@ -117,27 +124,53 @@ class TimetableWidgetState extends State { currentWeek = timetableWidgetController.getWeekCount(); showWeek = currentWeek; // showWeek = 1; + // showMonth = DateTime.now().month; + dataCaculateAfterFutherDo(); + + serverFutureDo(); + localFutureDo(); + } + + @override + dispose() { + super.dispose(); + // Setting.saveInitFlag(false); + + } + + dataCaculateAfterFutherDo() { + + + timeBlockWeekMap = {}; + timeBlockList = []; timeBlockList.addAll(courseList); timeBlockList.addAll(taskList); timeBlockList.addAll(workList); timeBlockWeekMap = timetableWidgetController.transformCourseMap(timeBlockList); - //获取本周星期一是几号 + + var mondayTime = timetableWidgetController.getmondayTime(); + + //showMon + showMonth = mondayTime.add(Duration(days: 7 * (showWeek - currentWeek))).month; + //更新初始化日期列表 + dateListstr = []; for (int i = 0; i < 7; i++) { - dateListstr.add((mondayTime.day + i).toString()); - if ((mondayTime.day + i) == DateTime.now().day) { - currentWeekDayIndex = i + 1; - } + dateListstr.add(mondayTime + .add(Duration(days: i + 7 * (showWeek - currentWeek))) + .day + .toString() + ); } - //调用函数初始化时间轴的绝对坐标 positions = timetableWidgetController.convertTimeList(timePoints, deviceWidth); + } updateAfterFutherDo() { @@ -172,267 +205,267 @@ class TimetableWidgetState extends State { @override Widget build(BuildContext contexvoidt) { + // if (firstInit == 0) { + // //第一次初始化 + // dataInitAfterFutherDo(); + // firstInit = 1; + // } else { + // //更新 + // updateAfterFutherDo(); + // } + + // print('dataCaculateAfterFutherDo'); + // dataCaculateAfterFutherDo(); return Consumer(builder: (ctx, timePro, child) { print('Rebuild timePro'); - return FutureBuilder( - 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){ - Provider.of(context, listen: false).updateTimetable(); // 更新时间表页面操作 + + return RefreshIndicator( + onRefresh: () { + print('下拉refresh'); + return serverFutureDo().then((value){ + // Provider.of(context, listen: false).updateTimetable(); // 更新时间表页面操作 + }); + }, + child: GestureDetector( + onHorizontalDragEnd: (details) { + teamController.getWorks().then((value){ + workList = value; + setState(() { + + }); }); + if (details.primaryVelocity! > 0) { + // 右滑 + setState(() { + showWeek--; + // updateDateByWeekCount(); + }); + } else if (details.primaryVelocity! < 0) { + // 左滑 + setState(() { + showWeek++; + // updateDateByWeekCount(); + }); + } }, - child: GestureDetector( - onHorizontalDragEnd: (details) { - if (details.primaryVelocity! > 0) { - // 右滑 - setState(() { - showWeek--; - updateDateByWeekCount(); - }); - } else if (details.primaryVelocity! < 0) { - // 左滑 - setState(() { - showWeek++; - 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( - '第' + - showWeek.toString() + - '周', //显示周数 - style: TextStyle( - fontSize: 12, - color: currentWeek == - showWeek //如果是当前周,就显示蓝色 - ? Colors.amber - : Colors.black87)), - ), - Container( - // height: 10, - // width: 6, - child: Text( - showMonth.toString() + '月', //显示月数 - style: TextStyle( - fontSize: 12, - color: currentWeek == - showWeek //如果是当前周,就显示蓝色 - ? 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)), - ], - ), + 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( + '第' + + showWeek.toString() + + '周', //显示周数 + style: TextStyle( + fontSize: 12, + color: currentWeek == + showWeek //如果是当前周,就显示蓝色 + ? Colors.amber + : Colors.black87)), + ), + Container( + // height: 10, + // width: 6, + child: Text( + showMonth.toString() + '月', //显示月数 + style: TextStyle( + fontSize: 12, + color: currentWeek == + showWeek //如果是当前周,就显示蓝色 + ? 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, + ), + ); + }), + ), + //显示下面的界面中的两个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: Colors.lightBlue - ), - ], + Container( + width: deviceWidth * 0.84, + height: 2, + color: Colors.lightBlue + ), + ], + ), ), ), ), - ), - )), - //第二个Stack - Container( - constraints: BoxConstraints - .expand(), // 使用constraints来自适应 - // width: 390, - // height: 2000, - child: Stack( - children: List.generate( - timeBlockWeekMap - .containsKey(showWeek) - ? timeBlockWeekMap[showWeek]! - .length - : 0, - (index) { - var currentItem = timeBlockWeekMap[ - showWeek]![index]; - return Positioned( - top: timetableWidgetController - .getdy(currentItem), - left: timetableWidgetController - .getdx(currentItem) + - deviceWidth * 0.15, - child: SingleChildScrollView( - child: Container( - width: deviceWidth * 0.115, - height: - timetableWidgetController - .getHeight( - currentItem), - decoration: BoxDecoration( - color: getItemColor( + )), + //第二个Stack + Container( + constraints: BoxConstraints + .expand(), // 使用constraints来自适应 + // width: 390, + // height: 2000, + child: Stack( + children: List.generate( + timeBlockWeekMap + .containsKey(showWeek) + ? timeBlockWeekMap[showWeek]! + .length + : 0, + (index) { + var currentItem = timeBlockWeekMap[ + showWeek]![index]; + return Positioned( + top: timetableWidgetController + .getdy(currentItem), + left: timetableWidgetController + .getdx(currentItem) + + deviceWidth * 0.15, + child: SingleChildScrollView( + child: Container( + width: deviceWidth * 0.115, + height: + timetableWidgetController + .getHeight( currentItem), - borderRadius: - BorderRadius.all( - Radius.circular(10.0), + 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), - ], + 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(), - ); - } - }); + ), + ); + ; }); } diff --git a/src/timemanagerapp/lib/widgets/UserSettingWidget.dart b/src/timemanagerapp/lib/widgets/UserSettingWidget.dart index db9dc42..96b53b1 100644 --- a/src/timemanagerapp/lib/widgets/UserSettingWidget.dart +++ b/src/timemanagerapp/lib/widgets/UserSettingWidget.dart @@ -34,7 +34,7 @@ class _UserSettingWightState extends State { await savepixelToMinuteRatio_ratio(number); DateTime date = DateTime.tryParse(_startDateController.text) ?? DateTime.now(); await saveStartDate(date); - Provider.of(context, listen: false).updateTimetable(); // 更新时间表页面操作 + // Provider.of(context, listen: false).updateTimetable(); // 更新时间表页面操作 setState(() { }); } diff --git a/src/workserver/controllers/team.js b/src/workserver/controllers/team.js index e5da443..9afcaa0 100644 --- a/src/workserver/controllers/team.js +++ b/src/workserver/controllers/team.js @@ -102,8 +102,9 @@ const teamController = { // 删除团队 deleteTeam: async function(req, res, next) { try { + console.log('delete_team:'); const teamId = req.body.teamId; // Assuming the team ID is passed as a parameter - const result = await Team.delete(teamId); // Use an appropriate function to delete the team + const result = await Team.delete('id',teamId); // Use an appropriate function to delete the team if (result) { res.json({ code: 200,