HomeWighet.dart

lvxinquan
LRC 3 years ago
parent bf8753c22e
commit ddf2aa6ff8

@ -3,21 +3,22 @@ import 'dart:ui';
import 'package:timemanagerapp/entity/Course.dart';
import 'package:timemanagerapp/setting/Setting.dart';
class CourseWidgetController{
final double pixelToMinuteRatio = 0.9*Setting.pixelToMinuteRatio_ratio; //old:0.9
class CourseWidgetController {
final double pixelToMinuteRatio =
0.9 * Setting.pixelToMinuteRatio_ratio; //old:0.9
late List<Course> courseList;
late DateTime mondayTime;
late int weekCount;
late DateTime termStartDate;
CourseWidgetController(){
CourseWidgetController() {
mondayTime = getmondayTime();
termStartDate = Setting.startdate;
weekCount = getWeekCount();
}
//getInstance
static CourseWidgetController getInstance(){
static CourseWidgetController getInstance() {
return new CourseWidgetController();
}
@ -95,7 +96,7 @@ class CourseWidgetController{
];
//piexl
List<Offset> convertTimeList(List<DateTime> timePoints) {
List<Offset> convertTimeList(List<DateTime> timePoints, double deviceWidth) {
List<Offset> convertedTimes = [];
for (var time in timePoints) {
int hour = time.hour;
@ -103,18 +104,18 @@ class CourseWidgetController{
int totalMinutes = (hour - 7) * 60 + minute;
double convertedTime = totalMinutes * pixelToMinuteRatio;
convertedTimes.add(Offset(5, convertedTime));
convertedTimes.add(Offset(deviceWidth * 0.02, convertedTime));
}
return convertedTimes;
}
int getWeekCount(){
int getWeekCount() {
weekCount = DateTime.now().difference(termStartDate).inDays ~/ 7 + 1;
return weekCount;
}
DateTime getmondayTime(){
DateTime getmondayTime() {
mondayTime = DateTime.now();
//
while (mondayTime.weekday != 1) {
@ -123,8 +124,8 @@ class CourseWidgetController{
return mondayTime;
}
Map<int,List<Course>> transformCourseMap(List<Course> courseList){
Map<int,List<Course>> courseMap = {};
Map<int, List<Course>> transformCourseMap(List<Course> courseList) {
Map<int, List<Course>> courseMap = {};
for (var course in courseList) {
int weekCount = course.start.difference(termStartDate).inDays ~/ 7 + 1; //
if (courseMap.containsKey(weekCount)) {
@ -135,5 +136,4 @@ class CourseWidgetController{
}
return courseMap;
}
}
}

@ -17,12 +17,12 @@ class MyDatabase {
final database =
await openDatabase(path, version: 1, onCreate: _createTables);
//!
_createTables(database, 1);
// //
// await _dropAllTables(database);
//!
_createTables(database, 1);
return Future.value(database);
}
@ -47,11 +47,10 @@ class MyDatabase {
await db.execute('''
CREATE TABLE IF NOT EXISTS users(
id INTEGER PRIMARY KEY,
teamId INTEGER NOT NULL,
username TEXT NOT NULL,
password TEXT NOT NULL,
role INTEGER NOT NULL
)
);
''');
print("userstable create success");
}
@ -62,11 +61,11 @@ class MyDatabase {
CREATE TABLE IF NOT EXISTS works (
id INTEGER PRIMARY KEY,
userId INTEGER NOT NULL,
workId INTEGER NOT NULL,
teamId INTEGER NOT NULL,
status TEXT NOT NULL,
workContent TEXT NOT NULL,
teamId INTEGER NOT NULL,
functionaryId INTEGER NOT NULL,
workId INTEGER NOT NULL,
endTime TEXT NOT NULL,
startTime TEXT NOT NULL
);
@ -79,11 +78,11 @@ class MyDatabase {
await db.execute('''
CREATE TABLE IF NOT EXISTS clocks (
id INTEGER PRIMARY KEY,
clockId INTEGER NOT NULL,
userId INTEGER NOT NULL,
text TEXT NOT NULL,
img TEXT NOT NULL,
music TEXT NOT NULL,
continueTime TEXT NOT NULL
music TEXT NOT NULL
);
''');
}
@ -93,9 +92,9 @@ class MyDatabase {
await db.execute('''
CREATE TABLE IF NOT EXISTS tasks (
id INTEGER PRIMARY KEY,
taskId INTEGER NOT NULL,
userId INTEGER NOT NULL,
content TEXT NOT NULL,
taskId INTEGER NOT NULL,
name TEXT NOT NULL,
startTime TEXT NOT NULL,
endTime TEXT NOT NULL
@ -117,7 +116,7 @@ class MyDatabase {
remark TEXT NOT NULL,
start TEXT NOT NULL,
end TEXT NOT NULL
)
);
''');
}
@ -128,7 +127,19 @@ class MyDatabase {
id INTEGER PRIMARY KEY,
leaderId INTEGER NOT NULL,
teamName TEXT NOT NULL,
maxNumber INTEGER NOT NULL
maxNumber INTEGER NOT NULL,
introduce TEXT
);
''');
}
static Future<void> _createUserTeamTable(Database db, int version) async {
// userTeam
await db.execute('''
CREATE TABLE IF NOT EXISTS userteams (
id INTEGER PRIMARY KEY,
userId INTEGER NOT NULL,
teamId INTEGER NOT NULL
);
''');
}
@ -138,9 +149,13 @@ class MyDatabase {
// SQL
await database.transaction((txn) async {
// 'table1''table2''table3'
await txn.execute('DROP TABLE IF EXISTS teams');
await txn.execute('DROP TABLE IF EXISTS Course');
await txn.execute('DROP TABLE IF EXISTS users');
await txn.execute('DROP TABLE IF EXISTS clocks');
await txn.execute('DROP TABLE IF EXISTS tasks');
await txn.execute('DROP TABLE IF EXISTS works');
await txn.execute('DROP TABLE IF EXISTS course');
await txn.execute('DROP TABLE IF EXISTS teams');
await txn.execute('DROP TABLE IF EXISTS userteams');
});
}
}

@ -8,7 +8,6 @@ import 'package:timemanagerapp/wighets/LoginWidget.dart';
import 'package:timemanagerapp/wighets/TestWidget.dart';
import 'package:timemanagerapp/wighets/TimetableWighet.dart';
init() async {
WidgetsFlutterBinding.ensureInitialized();
await Setting.init();
@ -17,8 +16,6 @@ init() async {
void main() async {
await init();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@ -26,12 +23,13 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
Setting.deviceWidth = MediaQuery.of(context).size.width;
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('测试'),
),
body: TestWidget(),
// appBar: AppBar(
// title: Text('测试'),
// ),
body: HomeWidget(),
),
);
}

@ -4,6 +4,7 @@ import 'package:timemanagerapp/wighets/AddCourseFormWidget.dart';
import 'package:timemanagerapp/wighets/TimetableWighet.dart';
class TimetableRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
@ -13,4 +14,4 @@ class TimetableRoute extends StatelessWidget {
body: TimetableWidget(),
);
}
}
}

@ -10,6 +10,7 @@ class Setting {
static late DateTime startdate;
static late User? user;
static double pixelToMinuteRatio_ratio = 1;
static late double deviceWidth ;
static init() async {
//

@ -22,6 +22,8 @@ void main() async {
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(

@ -1,28 +1,224 @@
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/wighets/AddCourseFormWidget.dart';
import 'package:timemanagerapp/wighets/LoginWidget.dart';
import 'package:timemanagerapp/wighets/TestWidget.dart';
import 'package:timemanagerapp/controller/CourseController.dart';
import 'package:timemanagerapp/controller/UserController.dart';
import 'package:timemanagerapp/entity/Course.dart';
import 'package:timemanagerapp/entity/User.dart';
import 'package:timemanagerapp/database/MyDatebase.dart';
import 'package:timemanagerapp/tests/TestWidget.dart';
import 'package:timemanagerapp/wighets/TimetableWighet.dart';
class HomeWighet extends StatefulWidget {
const HomeWighet({Key? key}) : super(key: key);
import '../ruters/AddCourseRoute.dart';
import '../ruters/TimetableRoute.dart';
class HomeWidget extends StatefulWidget {
const HomeWidget({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomeWighet> {
class _HomePageState extends State<HomeWidget> {
late UserController userController;
late CourseController courseController;
@override
void initState() {
super.initState();
MyDatabase.initDatabase();
userController = UserController.getInstance();
courseController = CourseController.getInstance();
}
void handleAddCourse() {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return AddCourseRoute();
},
),
);
}
void handleAddTask() {
// Implement the functionality for adding a task here
}
void handleAddTeam() {
// Implement the functionality for adding a team here
}
void handleMenu() {
// Implement the functionality for the menu here
}
@override
Widget build(BuildContext context) {
return TimetableWidget();
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.blue,
actions: [
IconButton( //addIconButton
icon: const Icon(Icons.add),
onPressed: () {
showDialog( //
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('添加功能'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton(
onPressed: () {
// AddCourseFormWidget
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return AddCourseRoute();
},
),
);
},
child: Text('添加课程'),
),
ElevatedButton(
onPressed: () {
// AddCourseFormWidget
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
//todo
return AddCourseRoute(); //
},
),
);
},
child: Text('添加任务'),
),
const SizedBox(height: 10),
],
),
);
},
);
},
),
IconButton(
icon: const Icon(Icons.more),
onPressed: () {},
),
IconButton(
icon: const Icon(Icons.group_add),
onPressed: () {},
),
Builder(
builder: (context) => IconButton( //
icon: const Icon(Icons.more_horiz),
onPressed: () {
Scaffold.of(context).openEndDrawer(); // Open the right drawer
},
),
),
],
),
endDrawer: Drawer(
// Use endDrawer to place the drawer on the right side
child: Column(
children: [
UserAccountsDrawerHeader(
accountName: Text('Username'),
accountEmail: Text('user@example.com'),
),
ListTile(
title: Text('开发者测试'),
onTap: () {
// TestWidget
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return TestWidget();
},
),
);
},
),
ListTile(
title: Text('删除课程'),
onTap: courseController.deleteAllCourses,
),
ListTile(
title: Text('导入课程(待开发)'),
onTap: () => courseController.autoImportCours(1, "1", 1, 1),
),
ListTile(
title: Text('插入课程'),
onTap: () => courseController.insertCourse(Course(
userId: 1,
courseId: 2,
name: "测试课",
credit: 3,
teacher: "嘉豪",
location: "638",
remark: "happy",
start: DateTime.now(),
end: DateTime.now().add(Duration(hours: 2)),
)),
),
ListTile(
title: Text('获取课程列表'),
onTap: () {
courseController.getCourses().then((courses) {
print(courses.length);
});
courseController.getCourses().then((courses) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('课程列表'),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: courses
.map((course) => ListTile(
title: Text(course.getName),
subtitle: Text(course.toString()),
))
.toList(),
),
),
);
},
);
});
},
),
ListTile(
title: Text('查看时间表'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return TimetableRoute();
},
),
);
},
),
],
),
),
body: TimetableWidget(),
);
}
}
}

@ -1,25 +1,3 @@
/*
import 'package:flutter/material.dart';
import 'package:timemanagerapp/wighets/AddCourseFormWidget.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('添加课程'),
),
body: AddCourseFormWidget(),
),
);
}
}
*/
import 'package:flutter/material.dart';
import 'package:sqflite/sqflite.dart';
import 'package:timemanagerapp/controller/CourseController.dart';
@ -36,16 +14,20 @@ import '../tests/database_test.dart';
import 'AddCourseFormWidget.dart';
class TestWidget extends StatefulWidget {
const TestWidget({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
_TestPageState createState() => _TestPageState();
}
class _HomePageState extends State<TestWidget> {
class _TestPageState extends State<TestWidget> {
late UserController userController;
late CourseController courseController;
@override
void initState() {
super.initState();
@ -54,57 +36,165 @@ class _HomePageState extends State<TestWidget> {
courseController = CourseController.getInstance();
}
void handleAddCourse() {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return AddCourseRoute();
},
),
);
}
void handleAddTask() {
// Implement the functionality for adding a task here
}
void handleAddTeam() {
// Implement the functionality for adding a team here
}
void handleMenu() {
// Implement the functionality for the menu here
}
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: userController.deleteAllUsers,
child: Text('删除所有用户'),
),
ElevatedButton(
onPressed: () => userController.insertUser(User(
teamId: 3231, username: "测试用户", password: "23243", role: 1)),
child: Text('插入一个测试用户'),
),
ElevatedButton(
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.blue,
actions: [
IconButton(
icon: const Icon(Icons.add),
onPressed: () {
userController.getUsers().then((users) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('用户列表'),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: users
.map((user) => ListTile(
title: Text(user['username']),
subtitle: Text(user.toString()),
))
.toList(),
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('+功能'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton(
onPressed: () {
// AddCourseFormWidget
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return AddCourseRoute();
},
),
);
},
child: Text('添加课程'),
),
),
);
},
);
});
ElevatedButton(
onPressed: () {
// AddCourseFormWidget
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return AddCourseRoute(); //
},
),
);
},
child: Text('添加任务'),
),
const SizedBox(height: 10),
],
),
);
},
);
},
child: Text('显示用户列表'),
),
ElevatedButton(
onPressed: courseController.deleteAllCourses,
child: Text('删除所有课程'),
IconButton(
icon: const Icon(Icons.more),
onPressed: () {},
),
IconButton(
icon: const Icon(Icons.group_add),
onPressed: () {},
),
Builder(
builder: (context) => IconButton(
icon: const Icon(Icons.more_horiz),
onPressed: () {
Scaffold.of(context).openEndDrawer(); // Open the right drawer
},
),
),
// ElevatedButton(
// onPressed: () => courseController.autoImportCours(jsonstr),
// child: Text('导入课程(待开发)'),
// ),
ElevatedButton(
onPressed: () => courseController.insertCourse(Course(
],
),
endDrawer: Drawer(
// Use endDrawer to place the drawer on the right side
child: Column(
children: [
UserAccountsDrawerHeader(
accountName: Text('Username'),
accountEmail: Text('user@example.com'),
),
ListTile(
title: Text('删除用户'),
onTap: () {
Navigator.pop(context); // Close the drawer
userController.deleteAllUsers();
},
),
ListTile(
title: Text('插入用户'),
onTap: () {
Navigator.pop(context); // Close the drawer
userController.insertUser(User(
teamId: 3231,
username: "嘉豪急啊急啊",
password: "23243",
role: 2341,
));
},
),
ListTile(
title: Text('获取用户列表'),
onTap: () {
Navigator.pop(context); // Close the drawer
userController.getUsers().then((users) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('用户列表'),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: users
.map((user) => ListTile(
title: Text(user['username']),
subtitle: Text(user.toString()),
))
.toList(),
),
),
);
},
);
});
},
),
ListTile(
title: Text('删除课程'),
onTap: courseController.deleteAllCourses,
),
ListTile(
title: Text('导入课程(待开发)'),
onTap: () => courseController.autoImportCours(1, "1", 1, 1),
),
ListTile(
title: Text('插入课程'),
onTap: () => courseController.insertCourse(Course(
userId: 1,
courseId: 2,
name: "测试课",
@ -113,135 +203,75 @@ class _HomePageState extends State<TestWidget> {
location: "638",
remark: "happy",
start: DateTime.now(),
end: DateTime.now().add(Duration(hours: 2)))),
child: Text('插入一个测试课程'),
),
ElevatedButton(
onPressed: () {
// AddCourseFormWidget
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return AddCourseRoute();
},
),
);
},
child: Text('添加自定义课程'),
),
ElevatedButton(
onPressed: () {
courseController.getCourses().then((courses) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('课程列表'),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: courses
.map((course) => ListTile(
title: Text(course.getName),
subtitle: Text(course.toString()),
))
.toList(),
end: DateTime.now().add(Duration(hours: 2)),
)),
),
ListTile(
title: Text('获取课程列表'),
onTap: () {
courseController.getCourses().then((courses) {
print(courses.length);
});
courseController.getCourses().then((courses) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('课程列表'),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: courses
.map((course) => ListTile(
title: Text(course.getName),
subtitle: Text(course.toString()),
))
.toList(),
),
),
),
);
},
);
},
);
});
},
),
ListTile(
title: Text('查看时间表'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return TimetableRoute();
},
),
);
});
},
child: Text('显示课程列表'),
),
ElevatedButton(
onPressed: () {
// AddCourseFormWidget
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return TimetableRoute();
},
),
);
},
child: Text('查看时间表'),
),
AddCourseButton(
onCourseAdded: (jsonstr) {
// addCourse()
// courseController.autoImportCours(jsonstr);
}
)
],
),
);
}
}
//string
class AddCourseButton extends StatefulWidget {
final Function(String jsonstr) onCourseAdded;
AddCourseButton({required this.onCourseAdded});
@override
_AddCourseButtonState createState() => _AddCourseButtonState();
}
class _AddCourseButtonState extends State<AddCourseButton> {
TextEditingController _jsonstrController = TextEditingController();
void _showAddCourseDialog(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('json导入课程'),
content: TextField(
controller: _jsonstrController,
decoration: InputDecoration(labelText: '请输入json字符串'),
),
actions: <Widget>[
TextButton(
child: Text('取消'),
onPressed: () {
Navigator.of(context).pop();
},
),
TextButton(
child: Text('确定'),
],
),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
final jsonstr = _jsonstrController.text;
if (jsonstr.isNotEmpty) {
widget.onCourseAdded(jsonstr);
Navigator.of(context).pop();
}
Navigator.push(
// 使 pushReplacement push
context,
MaterialPageRoute(
builder: (context) {
return TimetableRoute();
},
),
);
},
),
child: Text('直接显示 TimetableRoute()'), //
)
],
);
},
);
}
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {
_showAddCourseDialog(context);
},
child: Text('json导入课程'),
),
),
);
}
@override
void dispose() {
_jsonstrController.dispose();
super.dispose();
}
}

@ -7,13 +7,16 @@ import 'package:timemanagerapp/controller/CourseWidgetController.dart';
import 'package:timemanagerapp/main.dart';
import '../entity/Course.dart';
import '../setting/Setting.dart';
class TimetableWidget extends StatefulWidget {
final double deviceWidth=Setting.deviceWidth;
@override
State<StatefulWidget> createState() => PageState();
State<StatefulWidget> createState() => PageState(deviceWidth: deviceWidth);
}
class PageState extends State<TimetableWidget> {
late double deviceWidth;
//
late CourseWidgetController courseWidgetController = CourseWidgetController();
late CourseController courseController = CourseController.getInstance();
@ -56,6 +59,8 @@ class PageState extends State<TimetableWidget> {
bool loading = true;
PageState({required this.deviceWidth});
updateDateByWeekCount() {
var mondayTime = courseWidgetController.getmondayTime();
//
@ -96,7 +101,8 @@ class PageState extends State<TimetableWidget> {
// print('Recent monday '+DateTime.now().day.toString());
//
positions = courseWidgetController.convertTimeList(timePoints);
positions =
courseWidgetController.convertTimeList(timePoints, deviceWidth);
setState(() {
loading = false;
@ -147,45 +153,45 @@ class PageState extends State<TimetableWidget> {
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)),
),
],
)
//
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)),
],
),
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)),
],
),
),
);
}),
@ -193,92 +199,92 @@ class PageState extends State<TimetableWidget> {
//stack
Expanded(
child: SingleChildScrollView(
child: Row(
children: [
//stack
Container(
width: 390,
height: 2000,
child: Stack(
alignment: Alignment.center,
children: [
// Stack
Positioned(
top: 0,
left: 0,
child: Container(
width: 390,
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]
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'),
),
SizedBox(width: 5),
Container(
width: 10,
height: 10,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.amber,
width: 2,
),
),
),
Container(
width: 315,
height: 2,
color: const Color.fromARGB(
255, 136, 61, 61),
':' +
timePoints[index]
.minute
.toString()
.padLeft(2, '0'),
),
SizedBox(width: 5),
Container(
width: deviceWidth * 0.04,
height: 10,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.amber,
width: 2,
),
],
),
),
Container(
width: deviceWidth * 0.82,
height: 2,
color: const Color.fromARGB(
255, 136, 61, 61),
),
),
],
),
),
)),
//Stack
Container(
constraints:
),
),
)),
//Stack
Container(
constraints:
BoxConstraints.expand(), // 使constraints
// width: 390,
// height: 2000,
child: Stack(
children: List.generate(
//
courseWeekMap.containsKey(weekCount)
? courseWeekMap[weekCount]!.length
: 0,
((index) => Positioned(
// width: 390,
// height: 2000,
child: Stack(
children: List.generate(
//
courseWeekMap.containsKey(weekCount)
? courseWeekMap[weekCount]!.length
: 0,
((index) => Positioned(
top: courseWeekMap[weekCount]![index]
.getdy() +
.getdy() +
10,
left: courseWeekMap[weekCount]![index]
.getdx() +
.getdx() +
50,
child: SingleChildScrollView(
child: Container(
//
width: 40,
width: deviceWidth * 0.16,
height:
courseWeekMap[weekCount]![index]
.getHeight(),
courseWeekMap[weekCount]![index]
.getHeight(),
decoration: BoxDecoration(
color: Colors.tealAccent,
//
@ -292,71 +298,71 @@ class PageState extends State<TimetableWidget> {
children: [
Text(
courseWeekMap[weekCount]![
index]
index]
.name,
style: TextStyle(
fontSize: 10,
fontWeight:
FontWeight.bold),
FontWeight.bold),
overflow: TextOverflow
.clip, //name
),
Text(
courseWeekMap[weekCount]![
index]
index]
.teacher,
style:
TextStyle(fontSize: 8),
TextStyle(fontSize: 8),
overflow: TextOverflow.clip,
),
Text(
courseWeekMap[weekCount]![
index]
index]
.location,
style:
TextStyle(fontSize: 10),
TextStyle(fontSize: 10),
overflow: TextOverflow.clip,
),
Text(
courseWeekMap[weekCount]![
index]
.start
.hour
.toString() +
index]
.start
.hour
.toString() +
':' +
courseWeekMap[
weekCount]![
index]
weekCount]![
index]
.start
.minute
.toString(),
style:
TextStyle(fontSize: 10),
TextStyle(fontSize: 10),
overflow: TextOverflow.clip,
),
Text(
courseWeekMap[weekCount]![
index]
.end
.hour
.toString() +
index]
.end
.hour
.toString() +
':' +
courseWeekMap[
weekCount]![
index]
weekCount]![
index]
.end
.minute
.toString(),
style:
TextStyle(fontSize: 10),
TextStyle(fontSize: 10),
overflow: TextOverflow.clip,
),
Text(
courseWeekMap[weekCount]![
index]
index]
.remark,
style:
TextStyle(fontSize: 10),
TextStyle(fontSize: 10),
overflow: TextOverflow.clip,
),
],
@ -365,13 +371,13 @@ class PageState extends State<TimetableWidget> {
),
),
))),
))
],
),
),
],
))
],
),
),
))
],
),
))
],
),
);

Loading…
Cancel
Save