lvxinquan
Unknown 3 years ago
parent 63c0f98356
commit c583c116c1

BIN
.DS_Store vendored

Binary file not shown.

BIN
src/.DS_Store vendored

Binary file not shown.

@ -1,126 +1,133 @@
import 'package:timemanagerapp/controller/NetWorkController.dart';
import 'package:timemanagerapp/database/dao/CourseDao.dart';
import 'package:timemanagerapp/entity/Course.dart';
import 'package:timemanagerapp/entity/CourseForm.dart';
import 'package:timemanagerapp/setting/Setting.dart';
import 'package:timemanagerapp/util/GetCourseByLogin.dart';
import '../util/dataUtil.dart';
class CourseController {
static CourseController getInstance() {
return new CourseController();
}
GetCourseByLogin getCourseByLogin = GetCourseByLogin();
IdGenerator idGenerator = IdGenerator();
List<Course> courseList = []; //courseList
NetWorkController netWorkController = NetWorkController();
DateTime termstartdate = Setting.startdate; //Setting.getStartDate();
//
final List<List<String>> raspiyane = [
["8:00", "8:45"], //1
["8:50", "9:35"], //2
["10:05", "10:50"], //3
["10:55", "11:40"], //4
["13:30", "14:15"], //5
["14:20", "15:05"], //6
["15:35", "16:20"], //7
["16:25", "17:10"], //8
["18:30", "19:15"],
["19:20", "20:05"],
["20:10", "20:55"],
["21:10", "21:50"],
["22:05", "22:35"],
];
Future<void> addCourseForm(CourseForm courseForm) async {
List<Course> courseListToInsert = [];
for (int week = courseForm.getStartWeek(); week <= courseForm.getEndWeek(); week++) {
for(int day in courseForm.selectedDays){
//
final startDate = termstartdate.add(Duration(
days: (7 * (week - 1) + day! - 1),
hours: int.parse(raspiyane[courseForm.getStartTime() - 1][0].split(':')[0]),
minutes: int.parse(raspiyane[courseForm.getStartTime() - 1][0].split(':')[1]),
));
final endDate = termstartdate.add(Duration(
days: (7 * (week - 1) + day! - 1),
hours: int.parse(raspiyane[courseForm.getEndTime() - 1][1].split(':')[0]),
minutes: int.parse(raspiyane[courseForm.getEndTime() - 1][1].split(':')[1]),
));
int courseId = await idGenerator.generateId();
Course course = Course(
name: courseForm.getCourse(),
userId: Setting.user!.getId!,
courseId: courseId,
teacher: courseForm.getTeacher(),
location: courseForm.getLocation(),
start: startDate,
end: endDate,
credit: courseForm.getCredit(),
remark: courseForm.getNote()
);
courseListToInsert.add(course);
}
}
await insertCourseList(courseListToInsert);
}
Future<List<Course>> getCourses() async {
List<Map<String, dynamic>> courseMaps = await CourseDao().getCourses();
List<Course> courses = []; // Course
for (var courseMap in courseMaps) {
// 使CourseMapCourse
Course course = Course(
id: courseMap['id'],
userId: courseMap['userId'],
courseId: courseMap['courseId'],
name: courseMap['name'],
credit: courseMap['credit'],
teacher: courseMap['teacher'],
location: courseMap['location'],
remark: courseMap['remark'],
start: DateTime.parse(courseMap['start']),
end: DateTime.parse(courseMap['end']),
);
courses.add(course);
}
courseList = courses; // Course
return courseList;
}
Future<int> insertCourse(Course course) async {
return await CourseDao().insertCourse(course);
}
Future<int> insertCourseList(List<Course> courseList) async {
int result = 0;
for(Course course in courseList){
result += await CourseDao().insertCourse(course);
}
return result;
}
Future<int> autoImportCours(int stuid,String passwd,int year, int term) async {
String jsonstr = await netWorkController.getUserCoursejson(stuid, passwd, year, term);
List<Course> courseList = await getCourseByLogin.dealRawString(jsonstr);
return await insertCourseList(courseList);
}
Future<int> deleteAllCourses() async {
return await CourseDao().deleteAllCourses();
}
Future<int> deleteCourse(int id) async {
return await CourseDao().deleteCourseById(id);
}
}
import 'package:timemanagerapp/controller/NetWorkController.dart';
import 'package:timemanagerapp/database/dao/CourseDao.dart';
import 'package:timemanagerapp/entity/Course.dart';
import 'package:timemanagerapp/entity/CourseForm.dart';
import 'package:timemanagerapp/setting/Setting.dart';
import 'package:timemanagerapp/util/GetCourseByLogin.dart';
import '../util/dataUtil.dart';
class CourseController {
static CourseController getInstance() {
return new CourseController();
}
GetCourseByLogin getCourseByLogin = GetCourseByLogin();
IdGenerator idGenerator = IdGenerator();
List<Course> courseList = []; //courseList
NetWorkController netWorkController = NetWorkController();
DateTime termstartdate = Setting.startdate; //Setting.getStartDate();
//
final List<List<String>> raspiyane = [
["8:00", "8:45"], //1
["8:50", "9:35"], //2
["10:05", "10:50"], //3
["10:55", "11:40"], //4
["13:30", "14:15"], //5
["14:20", "15:05"], //6
["15:35", "16:20"], //7
["16:25", "17:10"], //8
["18:30", "19:15"],
["19:20", "20:05"],
["20:10", "20:55"],
["21:10", "21:50"],
["22:05", "22:35"],
];
Future<void> addCourseForm(CourseForm courseForm) async {
List<Course> courseListToInsert = [];
for (int week = courseForm.getStartWeek(); week <= courseForm.getEndWeek(); week++) {
for(int day in courseForm.selectedDays){
//
final startDate = termstartdate.add(Duration(
days: (7 * (week - 1) + day! - 1),
hours: int.parse(raspiyane[courseForm.getStartTime() - 1][0].split(':')[0]),
minutes: int.parse(raspiyane[courseForm.getStartTime() - 1][0].split(':')[1]),
));
final endDate = termstartdate.add(Duration(
days: (7 * (week - 1) + day! - 1),
hours: int.parse(raspiyane[courseForm.getEndTime() - 1][1].split(':')[0]),
minutes: int.parse(raspiyane[courseForm.getEndTime() - 1][1].split(':')[1]),
));
int courseId = await idGenerator.generateId();
Course course = Course(
id:await idGenerator.generateId(),
name: courseForm.getCourse(),
userId: Setting.user!.getId!,
courseId: courseId,
teacher: courseForm.getTeacher(),
location: courseForm.getLocation(),
start: startDate,
end: endDate,
credit: courseForm.getCredit(),
remark: courseForm.getNote()
);
courseListToInsert.add(course);
}
}
await insertCourseList(courseListToInsert);
}
Future<List<Course>> getCourses() async {
List<Map<String, dynamic>> courseMaps = await CourseDao().getCourses();
List<Course> courses = []; // Course
for (var courseMap in courseMaps) {
// 使CourseMapCourse
Course course = Course(
id: courseMap['id'],
userId: courseMap['userId'],
courseId: courseMap['courseId'],
name: courseMap['name'],
credit: courseMap['credit'],
teacher: courseMap['teacher'],
location: courseMap['location'],
remark: courseMap['remark'],
start: DateTime.parse(courseMap['start']),
end: DateTime.parse(courseMap['end']),
);
courses.add(course);
}
courseList = courses; // Course
return courseList;
}
Future<int> insertCourse(Course course) async {
return await CourseDao().insertCourse(course);
}
Future<int> insertCourseList(List<Course> courseList) async {
int result = 0;
for(Course course in courseList){
result += await CourseDao().insertCourse(course);
}
return result;
}
Future<int> autoImportCours(int stuid,String passwd,int year, int term) async {
String jsonstr = await netWorkController.getUserCoursejson(stuid, passwd, year, term);
List<Course> courseList = await getCourseByLogin.dealRawString(jsonstr);
return await insertCourseList(courseList);
}
//test_autoImportCours
Future<int> test_autoImportCours(String jsonstr) async {
List<Course> courseList = await GetCourseByLogin().dealRawString(jsonstr);
return await insertCourseList(courseList);
}
Future<int> deleteAllCourses() async {
return await CourseDao().deleteAllCourses();
}
Future<int> deleteCourse(int id) async {
return await CourseDao().deleteCourseById(id);
}
}

@ -1,139 +1,245 @@
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
late List<Course> courseList;
late DateTime mondayTime;
late int weekCount;
late DateTime termStartDate;
CourseWidgetController() {
mondayTime = getmondayTime();
termStartDate = Setting.startdate;
weekCount = getWeekCount();
}
//getInstance
static CourseWidgetController getInstance() {
return new CourseWidgetController();
}
static final List<Course> testcourseList = [
Course(
userId: 1,
courseId: 2,
name: 'Math',
credit: 3,
teacher: 'Mr. Smith',
location: 'Room 101',
remark: "null",
start: DateTime(2023, 9, 18, 7, 20),
end: DateTime(2023, 9, 18, 10, 0)),
Course(
userId: 1,
courseId: 2,
name: 'Math',
credit: 3,
teacher: 'Mr. Smith',
location: 'Room 101',
remark: "null",
start: DateTime(2023, 9, 19, 7, 20),
end: DateTime(2023, 9, 19, 10, 0)),
Course(
userId: 1,
courseId: 2,
name: 'Math',
credit: 3,
teacher: 'Mr. Smith',
location: 'Room 101',
remark: "null",
start: DateTime(2023, 9, 20, 7, 20),
end: DateTime(2023, 9, 20, 10, 0)),
Course(
userId: 1,
courseId: 2,
name: 'Math',
credit: 3,
teacher: 'Mr. Smith',
location: 'Room 101',
remark: "null",
start: DateTime(2023, 9, 21, 7, 20),
end: DateTime(2023, 9, 21, 10, 0)),
Course(
userId: 1,
courseId: 2,
name: 'Math',
credit: 3,
teacher: 'Mr. Smith',
location: 'Room 101',
remark: "null",
start: DateTime(2023, 9, 22, 7, 20),
end: DateTime(2023, 9, 22, 10, 0)),
Course(
userId: 1,
courseId: 2,
name: 'Math',
credit: 3,
teacher: 'Mr. Smith',
location: 'Room 101',
remark: "null",
start: DateTime(2023, 9, 23, 7, 20),
end: DateTime(2023, 9, 23, 10, 0)),
Course(
userId: 1,
courseId: 2,
name: 'Math',
credit: 3,
teacher: 'Mr. Smith',
location: 'Room 101',
remark: "null",
start: DateTime(2023, 9, 24, 7, 20),
end: DateTime(2023, 9, 24, 10, 0)),
];
//piexl
List<Offset> convertTimeList(List<DateTime> timePoints, double deviceWidth) {
List<Offset> convertedTimes = [];
for (var time in timePoints) {
int hour = time.hour;
int minute = time.minute;
int totalMinutes = (hour - 7) * 60 + minute;
double convertedTime = totalMinutes * pixelToMinuteRatio;
convertedTimes.add(Offset(deviceWidth * 0.02, convertedTime));
}
return convertedTimes;
}
int getWeekCount() {
weekCount = DateTime.now().difference(termStartDate).inDays ~/ 7 + 1;
return weekCount;
}
DateTime getmondayTime() {
mondayTime = DateTime.now();
//
while (mondayTime.weekday != 1) {
mondayTime = mondayTime.subtract(Duration(days: 1));
}
return mondayTime;
}
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)) {
courseMap[weekCount]!.add(course);
} else {
courseMap[weekCount] = [course];
}
}
return courseMap;
}
}
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
late List<Course> courseList;
late DateTime mondayTime;
late int weekCount;
late DateTime termStartDate;
CourseWidgetController() {
mondayTime = getmondayTime();
termStartDate = Setting.startdate;
weekCount = getWeekCount();
}
//getInstance
static CourseWidgetController getInstance() {
return new CourseWidgetController();
}
static final List<Course> testcourseList = [
Course(
userId: 1,
courseId: 2,
name: 'Math',
credit: 3,
teacher: 'Mr. Smith',
location: 'Room 101',
remark: "null",
start: DateTime(2023, 9, 18, 7, 20),
end: DateTime(2023, 9, 18, 10, 0)),
Course(
userId: 1,
courseId: 2,
name: 'Math',
credit: 3,
teacher: 'Mr. Smith',
location: 'Room 101',
remark: "null",
start: DateTime(2023, 9, 19, 7, 20),
end: DateTime(2023, 9, 19, 10, 0)),
Course(
userId: 1,
courseId: 2,
name: 'Math',
credit: 3,
teacher: 'Mr. Smith',
location: 'Room 101',
remark: "null",
start: DateTime(2023, 9, 20, 7, 20),
end: DateTime(2023, 9, 20, 10, 0)),
Course(
userId: 1,
courseId: 2,
name: 'Math',
credit: 3,
teacher: 'Mr. Smith',
location: 'Room 101',
remark: "null",
start: DateTime(2023, 9, 21, 7, 20),
end: DateTime(2023, 9, 21, 10, 0)),
Course(
userId: 1,
courseId: 2,
name: 'Math',
credit: 3,
teacher: 'Mr. Smith',
location: 'Room 101',
remark: "null",
start: DateTime(2023, 9, 22, 7, 20),
end: DateTime(2023, 9, 22, 10, 0)),
Course(
userId: 1,
courseId: 2,
name: 'Math',
credit: 3,
teacher: 'Mr. Smith',
location: 'Room 101',
remark: "null",
start: DateTime(2023, 9, 23, 7, 20),
end: DateTime(2023, 9, 23, 10, 0)),
Course(
userId: 1,
courseId: 2,
name: 'Math',
credit: 3,
teacher: 'Mr. Smith',
location: 'Room 101',
remark: "null",
start: DateTime(2023, 9, 24, 7, 20),
end: DateTime(2023, 9, 24, 10, 0)),
];
//piexl
List<Offset> convertTimeList(List<DateTime> timePoints, double deviceWidth) {
List<Offset> convertedTimes = [];
for (var time in timePoints) {
int hour = time.hour;
int minute = time.minute;
int totalMinutes = (hour - 7) * 60 + minute;
double convertedTime = totalMinutes * pixelToMinuteRatio;
convertedTimes.add(Offset(deviceWidth * 0.015, convertedTime));
}
return convertedTimes;
}
int getWeekCount() {
weekCount = DateTime.now().difference(termStartDate).inDays ~/ 7 + 1;
return weekCount;
}
DateTime getmondayTime() {
mondayTime = DateTime.now();
//
while (mondayTime.weekday != 1) {
mondayTime = mondayTime.subtract(Duration(days: 1));
}
return mondayTime;
}
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)) {
courseMap[weekCount]!.add(course);
} else {
courseMap[weekCount] = [course];
}
}
return courseMap;
}
}

@ -1,85 +1,85 @@
import 'dart:async';
import 'dart:async';
import 'dart:io';
import '../entity/Course.dart';
import '../entity/Team.dart';
import '../entity/User.dart';
import '../entity/Work.dart';
class NetWorkController{
final httpClient = HttpClient();
final Uri baseUri=Uri(scheme: "http", host: "www.tianqiapi.com",path:'/api/' , queryParameters: {
"version":"v1",
"appid":"97799796",
"appsecret":"mN3u09pY",
});
Future<int> login(User user) async {
return Future(() => 1);
}
Future<int> register(User user) async {
return Future(() => 1);
}
Future<List<Work>> getSameFreeWork(int teamid){
List<Work> workList = [];
return Future(() => workList);
}
Future<List<Work>> getTeamWorkList (int teamid){
List<Work> workList = [];
return Future(() => workList);
}
Future<List<Team>> getTeamList(int userid){
List<Team> teamList = [];
return Future(() => teamList);
}
Future<bool> insertTeam(Team team) async {
return true;
}
Future<bool> deleteTeam(int teamid) async {
return true;
}
Future<bool> updateTeam(Team team) async {
return true;
}
Future<List<User>> getTeamUserList(int teamid) async {
List<User> userList = [];
return userList;
}
Future<bool> insertTeamUser(int teamid,int userid) async {
return true;
}
Future<bool> deleteTeamUser(int teamid,int userid) async {
return true;
}
//todo
// Future<bool> deleteTeamUser(int teamid,int userid) async {
// return true;
// }
//app,
Future<bool> updateCourse(List<Course> courseList) async {
return true;
}
Future<bool> updateTask(List<Work> workList) async {
return true;
}
Future<String> getUserCoursejson(int stuid,String passwd,int year, int term){
String res = "";
return Future(() => res);
}
import 'dart:async';
import 'dart:async';
import 'dart:io';
import '../entity/Course.dart';
import '../entity/Team.dart';
import '../entity/User.dart';
import '../entity/Work.dart';
class NetWorkController{
final httpClient = HttpClient();
final Uri baseUri=Uri(scheme: "http", host: "www.tianqiapi.com",path:'/api/' , queryParameters: {
"version":"v1",
"appid":"97799796",
"appsecret":"mN3u09pY",
});
Future<int> login(User user) async {
return Future(() => 1);
}
Future<int> register(User user) async {
return Future(() => 1);
}
Future<List<Work>> getSameFreeWork(int teamid){
List<Work> workList = [];
return Future(() => workList);
}
Future<List<Work>> getTeamWorkList (int teamid){
List<Work> workList = [];
return Future(() => workList);
}
Future<List<Team>> getTeamList(int userid){
List<Team> teamList = [];
return Future(() => teamList);
}
Future<bool> insertTeam(Team team) async {
return true;
}
Future<bool> deleteTeam(int teamid) async {
return true;
}
Future<bool> updateTeam(Team team) async {
return true;
}
Future<List<User>> getTeamUserList(int teamid) async {
List<User> userList = [];
return userList;
}
Future<bool> insertTeamUser(int teamid,int userid) async {
return true;
}
Future<bool> deleteTeamUser(int teamid,int userid) async {
return true;
}
//todo
// Future<bool> deleteTeamUser(int teamid,int userid) async {
// return true;
// }
//app,
Future<bool> updateCourse(List<Course> courseList) async {
return true;
}
Future<bool> updateTask(List<Work> workList) async {
return true;
}
Future<String> getUserCoursejson(int stuid,String passwd,int year, int term){
String res = "";
return Future(() => res);
}
}

@ -1,88 +1,88 @@
import 'package:timemanagerapp/controller/NetWorkController.dart';
import '../entity/Team.dart';
import '../entity/Work.dart';
import 'package:timemanagerapp/database/dao/TeamDao.dart';
import 'package:timemanagerapp/database/dao/WorkDao.dart';
class TeamController {
late int leaderid;
List<Team> teamList = []; //teamList
Map<int, List<Work>> Wordmaplist = {};
NetWorkController netWorkController = NetWorkController();
TeamController(int leaderid) {
this.leaderid = leaderid;
//TODO: leaderidteamList
for (var team in teamList) {
//TODO: team.idWorklist[team.id]
//Wordmaplist[team.id].add()
}
}
Future<List<Team>> getTeams(int userid) async {
return await netWorkController.getTeamList(userid);
}
Future<bool> createTeam(Team team) async {
return await netWorkController.insertTeam(team);
}
Future<void> insertTeamList(List<Team> teamList) async {
for (Team team in teamList) {
await TeamDao().insertTeam(team);
}
}
Future<void> deleteAllTeams() async {
await TeamDao().deleteAllTeams();
}
Future<bool> deleteTeam(int teamid) async {
return await netWorkController.deleteTeam(teamid);
}
Future<bool> updateTeam(Team team) async {
return await netWorkController.updateTeam(team);
}
Future<void> insertWork(Work work) async {
// return await netWorkController.insertWork(work);
}
Future<void> insertWorkList(List<Work> workList) async {
for (Work work in workList) {
await WorkDao().insertWork(work);
}
}
Future<void> deleteAllWorks() async {
await WorkDao().deleteAllWorks();
}
Future<void> deleteWork(int id) async {
await WorkDao().deleteWorkByid(id);
}
Future<void> updateWork(Work work) async {
await WorkDao().updateWork(work);
}
Future<List<Map<String, dynamic>>> getWorks() async {
return WorkDao().getWorks();
}
Future<List<Map<String, dynamic>>> getWorksByTeamid(int teamid) async {
return WorkDao().getWorksByTeamid(teamid);
}
Future<List<Work>> getSameFreeWork(int teamid){
return netWorkController.getSameFreeWork(teamid);
}
}
import 'package:timemanagerapp/controller/NetWorkController.dart';
import '../entity/Team.dart';
import '../entity/Work.dart';
import 'package:timemanagerapp/database/dao/TeamDao.dart';
import 'package:timemanagerapp/database/dao/WorkDao.dart';
class TeamController {
late int leaderid;
List<Team> teamList = []; //teamList
Map<int, List<Work>> Wordmaplist = {};
NetWorkController netWorkController = NetWorkController();
TeamController(int leaderid) {
this.leaderid = leaderid;
//TODO: leaderidteamList
for (var team in teamList) {
//TODO: team.idWorklist[team.id]
//Wordmaplist[team.id].add()
}
}
Future<List<Team>> getTeams(int userid) async {
return await netWorkController.getTeamList(userid);
}
Future<bool> createTeam(Team team) async {
return await netWorkController.insertTeam(team);
}
Future<void> insertTeamList(List<Team> teamList) async {
for (Team team in teamList) {
await TeamDao().insertTeam(team);
}
}
Future<void> deleteAllTeams() async {
await TeamDao().deleteAllTeams();
}
Future<bool> deleteTeam(int teamid) async {
return await netWorkController.deleteTeam(teamid);
}
Future<bool> updateTeam(Team team) async {
return await netWorkController.updateTeam(team);
}
Future<void> insertWork(Work work) async {
// return await netWorkController.insertWork(work);
}
Future<void> insertWorkList(List<Work> workList) async {
for (Work work in workList) {
await WorkDao().insertWork(work);
}
}
Future<void> deleteAllWorks() async {
await WorkDao().deleteAllWorks();
}
Future<void> deleteWork(int id) async {
await WorkDao().deleteWorkByid(id);
}
Future<void> updateWork(Work work) async {
await WorkDao().updateWork(work);
}
Future<List<Map<String, dynamic>>> getWorks() async {
return WorkDao().getWorks();
}
Future<List<Map<String, dynamic>>> getWorksByTeamid(int teamid) async {
return WorkDao().getWorksByTeamid(teamid);
}
Future<List<Work>> getSameFreeWork(int teamid){
return netWorkController.getSameFreeWork(teamid);
}
}

@ -1,51 +1,51 @@
import 'package:timemanagerapp/database/dao/UserDao.dart';
import 'package:timemanagerapp/database/MyDatebase.dart';
import 'package:timemanagerapp/entity/User.dart';
import '../setting/Setting.dart';
import 'NetWorkController.dart';
/**
*
*/
class UserController {
NetWorkController netWorkController = NetWorkController();
//
static UserController getInstance() {
return new UserController();
}
Future<List<Map<String, dynamic>>> getUsers() async {
return await UserDao.getInstance().getUsers();
}
Future<bool> login(User user) async {
int userid = await netWorkController.login(user);
user.id = userid;
await Setting.saveUser(user);
return true;
}
Future<bool> register(User user) async {
int userid = await netWorkController.register(user);
user.id = userid;
await Setting.saveUser(user);
return true;
}
Future<void> insertUser(User user) async {
await UserDao.getInstance().insertUser(user);
}
Future<void> insertUserList(List<User> userList) async {
for (User user in userList) {
await UserDao.getInstance().insertUser(user);
}
}
//deleteAllUsers
Future<void> deleteAllUsers() async {
await UserDao.getInstance().deleteAllUsers();
}
}
import 'package:timemanagerapp/database/dao/UserDao.dart';
import 'package:timemanagerapp/database/MyDatebase.dart';
import 'package:timemanagerapp/entity/User.dart';
import '../setting/Setting.dart';
import 'NetWorkController.dart';
/**
*
*/
class UserController {
NetWorkController netWorkController = NetWorkController();
//
static UserController getInstance() {
return new UserController();
}
Future<List<Map<String, dynamic>>> getUsers() async {
return await UserDao.getInstance().getUsers();
}
Future<bool> login(User user) async {
int userid = await netWorkController.login(user);
user.id = userid;
await Setting.saveUser(user);
return true;
}
Future<bool> register(User user) async {
int userid = await netWorkController.register(user);
user.id = userid;
await Setting.saveUser(user);
return true;
}
Future<void> insertUser(User user) async {
await UserDao.getInstance().insertUser(user);
}
Future<void> insertUserList(List<User> userList) async {
for (User user in userList) {
await UserDao.getInstance().insertUser(user);
}
}
//deleteAllUsers
Future<void> deleteAllUsers() async {
await UserDao.getInstance().deleteAllUsers();
}
}

@ -1,161 +1,161 @@
import 'package:sqflite/sqflite.dart';
import 'package:path/path.dart';
import 'dart:async';
import 'package:timemanagerapp/entity/Task.dart';
/**
*
*/
class MyDatabase {
static Future<Database> initDatabase() async {
final databasePath = await getDatabasesPath();
final path = join(databasePath, 'tma.db');
//
//onCreate onCreate
final database =
await openDatabase(path, version: 1, onCreate: _createTables);
// //
// await _dropAllTables(database);
//!
_createTables(database, 1);
return Future.value(database);
}
static Future<void> _createTables(Database db, int version) async {
//Course
await _createCourseTable(db, version);
// User
await _createUserTable(db, version);
// Work
await _createWorkTable(db, version);
// Clock
await _createClockTable(db, version);
// Task
await _createTaskTable(db, version);
// Team
await _createTeamTable(db, version);
}
static Future<void> _createUserTable(Database db, int version) async {
// User
await db.execute('''
CREATE TABLE IF NOT EXISTS users(
id INTEGER PRIMARY KEY,
username TEXT NOT NULL,
password TEXT NOT NULL,
role INTEGER NOT NULL
);
''');
print("userstable create success");
}
static Future<void> _createWorkTable(Database db, int version) async {
// Work
await db.execute('''
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,
functionaryId INTEGER NOT NULL,
endTime TEXT NOT NULL,
startTime TEXT NOT NULL
);
''');
print("Coursetable create success");
}
static Future<void> _createClockTable(Database db, int version) async {
// Clock
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
);
''');
}
static Future<void> _createTaskTable(Database db, int version) async {
// Task
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,
name TEXT NOT NULL,
startTime TEXT NOT NULL,
endTime TEXT NOT NULL
);
''');
}
static Future<void> _createCourseTable(Database db, int version) async {
// Course
await db.execute('''
CREATE TABLE IF NOT EXISTS course(
id INTEGER PRIMARY KEY,
userId INTEGER,
courseId INTEGER NOT NULL,
name TEXT NOT NULL,
credit REAL NOT NULL,
teacher TEXT NOT NULL,
location TEXT NOT NULL,
remark TEXT NOT NULL,
start TEXT NOT NULL,
end TEXT NOT NULL
);
''');
}
static Future<void> _createTeamTable(Database db, int version) async {
// Team
await db.execute('''
CREATE TABLE IF NOT EXISTS teams (
id INTEGER PRIMARY KEY,
leaderId INTEGER NOT NULL,
teamName TEXT 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
);
''');
}
//
static Future<void> _dropAllTables(Database database) async {
// SQL
await database.transaction((txn) async {
// 'table1''table2''table3'
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');
});
}
}
import 'package:sqflite/sqflite.dart';
import 'package:path/path.dart';
import 'dart:async';
import 'package:timemanagerapp/entity/Task.dart';
/**
*
*/
class MyDatabase {
static Future<Database> initDatabase() async {
final databasePath = await getDatabasesPath();
final path = join(databasePath, 'tma.db');
//
//onCreate onCreate
final database =
await openDatabase(path, version: 1, onCreate: _createTables);
// //
// await _dropAllTables(database);
//
await _createTables(database, 1);
return Future.value(database);
}
static Future<void> _createTables(Database db, int version) async {
//Course
await _createCourseTable(db, version);
// User
await _createUserTable(db, version);
// Work
await _createWorkTable(db, version);
// Clock
await _createClockTable(db, version);
// Task
await _createTaskTable(db, version);
// Team
await _createTeamTable(db, version);
}
static Future<void> _createUserTable(Database db, int version) async {
// User
await db.execute('''
CREATE TABLE IF NOT EXISTS users(
id INTEGER PRIMARY KEY,
username TEXT NOT NULL,
password TEXT NOT NULL,
role INTEGER NOT NULL
);
''');
print("userstable create success");
}
static Future<void> _createWorkTable(Database db, int version) async {
// Work
await db.execute('''
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,
functionaryId INTEGER NOT NULL,
endTime TEXT NOT NULL,
startTime TEXT NOT NULL
);
''');
print("Coursetable create success");
}
static Future<void> _createClockTable(Database db, int version) async {
// Clock
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
);
''');
}
static Future<void> _createTaskTable(Database db, int version) async {
// Task
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,
name TEXT NOT NULL,
startTime TEXT NOT NULL,
endTime TEXT NOT NULL
);
''');
}
static Future<void> _createCourseTable(Database db, int version) async {
// Course
await db.execute('''
CREATE TABLE IF NOT EXISTS course(
id INTEGER PRIMARY KEY,
userId INTEGER,
courseId INTEGER NOT NULL,
name TEXT NOT NULL,
credit REAL NOT NULL,
teacher TEXT NOT NULL,
location TEXT NOT NULL,
remark TEXT NOT NULL,
start TEXT NOT NULL,
end TEXT NOT NULL
);
''');
}
static Future<void> _createTeamTable(Database db, int version) async {
// Team
await db.execute('''
CREATE TABLE IF NOT EXISTS teams (
id INTEGER PRIMARY KEY,
leaderId INTEGER NOT NULL,
teamName TEXT 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
);
''');
}
//
static Future<void> _dropAllTables(Database database) async {
// SQL
await database.transaction((txn) async {
// 'table1''table2''table3'
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');
});
}
}

@ -1,104 +1,104 @@
import 'package:timemanagerapp/database/MyDatebase.dart';
import 'package:timemanagerapp/entity/Course.dart';
/**
*
*/
class CourseDao {
//
static CourseDao getInstance() {
return new CourseDao();
}
var db = MyDatabase.initDatabase();
Future<List<Map<String, dynamic>>> getCourses() async {
final database = await db;
if (database != null) {
return database.rawQuery('SELECT * FROM course');
} else {
return [];
}
}
Future<int> insertCourse(Course course) async {
final database = await db;
int result = 0;
if (database != null) {
await database.transaction((txn) async {
//
//!!!
result = await txn.rawInsert('''
INSERT INTO course(userId,courseId,name,credit,teacher,location,remark,start,end)
VALUES(${course.userId},${course.courseId},"${course.name}",${course.credit},"${course.teacher}","${course.location}","${course.remark}","${course.start}","${course.end}")
''');
});
// print("课程插入 : " + course.toString());
}
return result;
}
Future<int> updateCourseById(Course course) async {
final database = await db;
int result = 0;
if (database != null) {
await database.transaction((txn) async {
result = await txn.rawUpdate('''
UPDATE course SET userId = ${course.userId},courseId = ${course
.courseId},name = "${course.name}",credit = ${course
.credit},teacher = "${course.teacher}",location = "${course
.location}",remark = "${course.remark}",start = "${course
.start}",end = "${course.end}"
WHERE id = ${course.id}
''');
});
}
return result;
}
Future<int> updateCourseByCourseId(Course course) async {
final database = await db;
int result = 0;
if (database != null) {
await database.transaction((txn) async {
result = await txn.rawUpdate('''
UPDATE course SET userId = ${course.userId},courseId = ${course
.courseId},name = "${course.name}",credit = ${course
.credit},teacher = "${course.teacher}",location = "${course
.location}",remark = "${course.remark}",start = "${course
.start}",end = "${course.end}"
WHERE courseId = ${course.courseId}
''');
});
}
return result;
}
Future<int> deleteCourseById(int id) async {
final database = await db;
int result = 0;
if (database != null) {
result = await database.delete('course', where: 'id = ?', whereArgs: [id]);
}
return result;
}
Future<int> deleteCourseByCourseId(int courseId) async {
final database = await db;
int result = 0;
if (database != null) {
result = await database
.delete('course', where: 'courseId = ?', whereArgs: [courseId]);
}
return result;
}
Future<int> deleteAllCourses() async {
final database = await db;
int result = 0;
if (database != null) {
result = await database.delete('course', where: '1=1');
}
return result;
}
}
import 'package:timemanagerapp/database/MyDatebase.dart';
import 'package:timemanagerapp/entity/Course.dart';
/**
*
*/
class CourseDao {
//
static CourseDao getInstance() {
return new CourseDao();
}
var db = MyDatabase.initDatabase();
Future<List<Map<String, dynamic>>> getCourses() async {
final database = await db;
if (database != null) {
return database.rawQuery('SELECT * FROM course');
} else {
return [];
}
}
Future<int> insertCourse(Course course) async {
final database = await db;
int result = 0;
if (database != null) {
await database.transaction((txn) async {
//
//!!!
result = await txn.rawInsert('''
INSERT INTO course(userId,courseId,name,credit,teacher,location,remark,start,end)
VALUES(${course.userId},${course.courseId},"${course.name}",${course.credit},"${course.teacher}","${course.location}","${course.remark}","${course.start}","${course.end}")
''');
});
// print("课程插入 : " + course.toString());
}
return result;
}
Future<int> updateCourseById(Course course) async {
final database = await db;
int result = 0;
if (database != null) {
await database.transaction((txn) async {
result = await txn.rawUpdate('''
UPDATE course SET userId = ${course.userId},courseId = ${course
.courseId},name = "${course.name}",credit = ${course
.credit},teacher = "${course.teacher}",location = "${course
.location}",remark = "${course.remark}",start = "${course
.start}",end = "${course.end}"
WHERE id = ${course.id}
''');
});
}
return result;
}
Future<int> updateCourseByCourseId(Course course) async {
final database = await db;
int result = 0;
if (database != null) {
await database.transaction((txn) async {
result = await txn.rawUpdate('''
UPDATE course SET userId = ${course.userId},courseId = ${course
.courseId},name = "${course.name}",credit = ${course
.credit},teacher = "${course.teacher}",location = "${course
.location}",remark = "${course.remark}",start = "${course
.start}",end = "${course.end}"
WHERE courseId = ${course.courseId}
''');
});
}
return result;
}
Future<int> deleteCourseById(int id) async {
final database = await db;
int result = 0;
if (database != null) {
result = await database.delete('course', where: 'id = ?', whereArgs: [id]);
}
return result;
}
Future<int> deleteCourseByCourseId(int courseId) async {
final database = await db;
int result = 0;
if (database != null) {
result = await database
.delete('course', where: 'courseId = ?', whereArgs: [courseId]);
}
return result;
}
Future<int> deleteAllCourses() async {
final database = await db;
int result = 0;
if (database != null) {
result = await database.delete('course', where: '1=1');
}
return result;
}
}

@ -1,56 +1,56 @@
import '../../entity/Task.dart';
import '../MyDatebase.dart';
class TaskDao {
//
static TaskDao getInstance() {
return new TaskDao();
}
var db = MyDatabase.initDatabase();
Future<List<Map<String, dynamic>>> getTasks() async {
final database = await db;
if (database != null) {
return database.query('Task', orderBy: 'id ASC');
} else {
return [];
}
}
Future<void> insertTask(Task task) async {
final database = await db;
if (database != null) {
await database.insert('Task', task.toMap());
}
}
Future<void> updateTask(Task task) async {
final database = await db;
if (database != null) {
await database
.update('Task', task.toMap(), where: 'id = ?', whereArgs: [task.id]);
}
}
Future<void> deleteTaskByid(int id) async {
final database = await db;
if (database != null) {
await database.delete('Task', where: 'id = ?', whereArgs: [id]);
}
}
Future<void> deleteTaskByTaskid(int taskid) async {
final database = await db;
if (database != null) {
await database.delete('Task', where: 'taskid = ?', whereArgs: [taskid]);
}
}
Future<void> deleteAllTasks() async {
final database = await db;
if (database != null) {
await database.delete('Task', where: '1=1');
}
}
import '../../entity/Task.dart';
import '../MyDatebase.dart';
class TaskDao {
//
static TaskDao getInstance() {
return new TaskDao();
}
var db = MyDatabase.initDatabase();
Future<List<Map<String, dynamic>>> getTasks() async {
final database = await db;
if (database != null) {
return database.query('Task', orderBy: 'id ASC');
} else {
return [];
}
}
Future<void> insertTask(Task task) async {
final database = await db;
if (database != null) {
await database.insert('Task', task.toMap());
}
}
Future<void> updateTask(Task task) async {
final database = await db;
if (database != null) {
await database
.update('Task', task.toMap(), where: 'id = ?', whereArgs: [task.id]);
}
}
Future<void> deleteTaskByid(int id) async {
final database = await db;
if (database != null) {
await database.delete('Task', where: 'id = ?', whereArgs: [id]);
}
}
Future<void> deleteTaskByTaskid(int taskid) async {
final database = await db;
if (database != null) {
await database.delete('Task', where: 'taskid = ?', whereArgs: [taskid]);
}
}
Future<void> deleteAllTasks() async {
final database = await db;
if (database != null) {
await database.delete('Task', where: '1=1');
}
}
}

@ -1,55 +1,55 @@
import 'package:timemanagerapp/database/MyDatebase.dart';
import 'package:timemanagerapp/entity/Team.dart';
/**
*
*/
class TeamDao {
//
static TeamDao getInstance() {
return new TeamDao();
}
var db = MyDatabase.initDatabase();
Future<List<Map<String, dynamic>>> getTeams() async {
final database = await db;
if (database != null) {
return database.query('Team', orderBy: 'id ASC');
} else {
return [];
}
}
Future<void> insertTeam(Team team) async {
final database = await db;
if (database != null) {
await database.insert('Team', team.toMap());
}
}
Future<void> updateTeam(Team team) async {
final database = await db;
if (database != null) {
await database
.update('Team', team.toMap(), where: 'id = ?', whereArgs: [team.id]);
}
}
Future<void> deleteTeamById(int id) async {
final database = await db;
if (database != null) {
await database.delete('Team', where: 'id = ?', whereArgs: [id]);
}
}
Future<void> deleteAllTeams() async {
final database = await db;
if (database != null) {
await database.delete('Team', where: '1=1');
}
}
}
import 'package:timemanagerapp/database/MyDatebase.dart';
import 'package:timemanagerapp/entity/Team.dart';
/**
*
*/
class TeamDao {
//
static TeamDao getInstance() {
return new TeamDao();
}
var db = MyDatabase.initDatabase();
Future<List<Map<String, dynamic>>> getTeams() async {
final database = await db;
if (database != null) {
return database.query('Team', orderBy: 'id ASC');
} else {
return [];
}
}
Future<void> insertTeam(Team team) async {
final database = await db;
if (database != null) {
await database.insert('Team', team.toMap());
}
}
Future<void> updateTeam(Team team) async {
final database = await db;
if (database != null) {
await database
.update('Team', team.toMap(), where: 'id = ?', whereArgs: [team.id]);
}
}
Future<void> deleteTeamById(int id) async {
final database = await db;
if (database != null) {
await database.delete('Team', where: 'id = ?', whereArgs: [id]);
}
}
Future<void> deleteAllTeams() async {
final database = await db;
if (database != null) {
await database.delete('Team', where: '1=1');
}
}
}

@ -1,64 +1,64 @@
import 'package:timemanagerapp/database/MyDatebase.dart';
import '../../entity/User.dart';
/**
*
*/
class UserDao {
//
static UserDao getInstance() {
return new UserDao();
}
//
//UserService userService=UserService.getInstance();
var db = MyDatabase.initDatabase();
Future<List<Map<String, dynamic>>> getUsers() async {
final database = await db;
if (database != null) {
return await database.rawQuery('SELECT * FROM users');
} else {
return [];
}
}
Future<void> insertUser(User user) async {
final database = await db;
if (database != null) {
await database.transaction((txn) async {
//
//!!!
await txn.rawInsert('''
INSERT INTO users(teamId,username,password,role)
VALUES(${user.teamId},"${user.username}","${user.password}",${user.role})
''');
});
}
}
Future<void> deleteUser(int id) async {
final database = await db;
if (database != null) {
await database.transaction((txn) async {
//
await txn.rawDelete('''
DELETE FROM users WHERE id=$id
''');
});
}
}
Future<void> deleteAllUsers() async {
final database = await db;
if (database != null) {
await database.transaction((txn) async {
//
await txn.rawDelete('''
DELETE FROM users
''');
});
}
}
}
import 'package:timemanagerapp/database/MyDatebase.dart';
import '../../entity/User.dart';
/**
*
*/
class UserDao {
//
static UserDao getInstance() {
return new UserDao();
}
//
//UserService userService=UserService.getInstance();
var db = MyDatabase.initDatabase();
Future<List<Map<String, dynamic>>> getUsers() async {
final database = await db;
if (database != null) {
return await database.rawQuery('SELECT * FROM users');
} else {
return [];
}
}
Future<void> insertUser(User user) async {
final database = await db;
if (database != null) {
await database.transaction((txn) async {
//
//!!!
await txn.rawInsert('''
INSERT INTO users(teamId,username,password,role)
VALUES(${user.teamId},"${user.username}","${user.password}",${user.role})
''');
});
}
}
Future<void> deleteUser(int id) async {
final database = await db;
if (database != null) {
await database.transaction((txn) async {
//
await txn.rawDelete('''
DELETE FROM users WHERE id=$id
''');
});
}
}
Future<void> deleteAllUsers() async {
final database = await db;
if (database != null) {
await database.transaction((txn) async {
//
await txn.rawDelete('''
DELETE FROM users
''');
});
}
}
}

@ -1,76 +1,76 @@
import 'package:timemanagerapp/database/MyDatebase.dart';
import 'package:timemanagerapp/entity/Work.dart';
/**
*
*/
class WorkDao {
//
static WorkDao getInstance() {
return new WorkDao();
}
var db = MyDatabase.initDatabase();
Future<List<Map<String, dynamic>>> getWorks() async {
final database = await db;
if (database != null) {
return database.query('Work', orderBy: 'id ASC');
} else {
return [];
}
}
Future<List<Map<String, dynamic>>> getWorksByTeamid(int teamid) async {
final database = await db;
if (database != null) {
return database.query('Work', where: 'teamid = ?', whereArgs: [teamid], orderBy: 'id ASC');
} else {
return [];
}
}
Future<void> insertWork(Work work) async {
final database = await db;
if (database != null) {
await database.insert('Work', work.toMap());
}
}
Future<void> updateWork(Work work) async {
final database = await db;
if (database != null) {
await database
.update('Work', work.toMap(), where: 'id = ?', whereArgs: [work.id]);
}
}
Future<void> deleteWorkByid(int id) async {
final database = await db;
if (database != null) {
await database.delete('Work', where: 'id = ?', whereArgs: [id]);
}
}
Future<void> deleteWorkByWorkid(int workid) async {
final database = await db;
if (database != null) {
await database.delete('Work', where: 'workid = ?', whereArgs: [workid]);
}
}
Future<void> deleteWorkByTeamid(int teamid) async {
final database = await db;
if (database != null) {
await database.delete('Work', where: 'teamid = ?', whereArgs: [teamid]);
}
}
Future<void> deleteAllWorks() async {
final database = await db;
if (database != null) {
await database.delete('Work', where: '1=1');
}
}
}
import 'package:timemanagerapp/database/MyDatebase.dart';
import 'package:timemanagerapp/entity/Work.dart';
/**
*
*/
class WorkDao {
//
static WorkDao getInstance() {
return new WorkDao();
}
var db = MyDatabase.initDatabase();
Future<List<Map<String, dynamic>>> getWorks() async {
final database = await db;
if (database != null) {
return database.query('Work', orderBy: 'id ASC');
} else {
return [];
}
}
Future<List<Map<String, dynamic>>> getWorksByTeamid(int teamid) async {
final database = await db;
if (database != null) {
return database.query('Work', where: 'teamid = ?', whereArgs: [teamid], orderBy: 'id ASC');
} else {
return [];
}
}
Future<void> insertWork(Work work) async {
final database = await db;
if (database != null) {
await database.insert('Work', work.toMap());
}
}
Future<void> updateWork(Work work) async {
final database = await db;
if (database != null) {
await database
.update('Work', work.toMap(), where: 'id = ?', whereArgs: [work.id]);
}
}
Future<void> deleteWorkByid(int id) async {
final database = await db;
if (database != null) {
await database.delete('Work', where: 'id = ?', whereArgs: [id]);
}
}
Future<void> deleteWorkByWorkid(int workid) async {
final database = await db;
if (database != null) {
await database.delete('Work', where: 'workid = ?', whereArgs: [workid]);
}
}
Future<void> deleteWorkByTeamid(int teamid) async {
final database = await db;
if (database != null) {
await database.delete('Work', where: 'teamid = ?', whereArgs: [teamid]);
}
}
Future<void> deleteAllWorks() async {
final database = await db;
if (database != null) {
await database.delete('Work', where: '1=1');
}
}
}

@ -1,75 +1,75 @@
class Clock {
int? id;
int userId;
String text;
String img;
String music;
DateTime continueTime;
Clock({
this.id,
required this.userId,
required this.text,
required this.img,
required this.music,
required this.continueTime,
});
Map<String, dynamic> toMap() {
return {
'userId': userId,
'text': "$text",
'img': "$img",
'music': "$music",
'continueTime': "${continueTime.toIso8601String()}",
};
}
// Getter methods
int? get getId => id;
int get getUserId => userId;
String get getText => text;
String get getImg => img;
String get getMusic => music;
DateTime get getContinueTime => continueTime;
// Setter methods
set setId(int newId) {
id = newId;
}
set setUserId(int newUserId) {
userId = newUserId;
}
set setText(String newText) {
text = newText;
}
set setImg(String newImg) {
img = newImg;
}
set setMusic(String newMusic) {
music = newMusic;
}
set setContinueTime(DateTime newContinueTime) {
continueTime = newContinueTime;
}
// toString method
@override
String toString() {
return 'Clock(id: $id, userId: $userId, text: $text, img: $img, music: $music, continueTime: $continueTime)';
}
}
class Clock {
int? id;
int userId;
String text;
String img;
String music;
DateTime continueTime;
Clock({
this.id,
required this.userId,
required this.text,
required this.img,
required this.music,
required this.continueTime,
});
Map<String, dynamic> toMap() {
return {
'userId': userId,
'text': "$text",
'img': "$img",
'music': "$music",
'continueTime': "${continueTime.toIso8601String()}",
};
}
// Getter methods
int? get getId => id;
int get getUserId => userId;
String get getText => text;
String get getImg => img;
String get getMusic => music;
DateTime get getContinueTime => continueTime;
// Setter methods
set setId(int newId) {
id = newId;
}
set setUserId(int newUserId) {
userId = newUserId;
}
set setText(String newText) {
text = newText;
}
set setImg(String newImg) {
img = newImg;
}
set setMusic(String newMusic) {
music = newMusic;
}
set setContinueTime(DateTime newContinueTime) {
continueTime = newContinueTime;
}
// toString method
@override
String toString() {
return 'Clock(id: $id, userId: $userId, text: $text, img: $img, music: $music, continueTime: $continueTime)';
}
}

@ -1,127 +1,127 @@
import 'package:timemanagerapp/setting/Setting.dart';
class Course {
int? id;
int? userId;
int courseId;
String name;
double credit;
String teacher;
String location;
String remark;
DateTime start;
DateTime end;
Course({
this.id,
required this.userId,
required this.courseId,
required this.name,
required this.credit,
required this.teacher,
required this.location,
required this.remark,
required this.start,
required this.end,
});
Map<String,dynamic> toMap(){
return {
'userId':userId,
'courseId':courseId,
'name':"$name",
'credit':credit,
'teacher':"$teacher",
'location':"$location",
'remark':"$remark",
'start':"${start.toIso8601String()}",
'end':"${end.toIso8601String()}"
};
}
//x
var weekListPixel=[0,50,100,150,200,250,300];
// Course(this.name, this.teacher, this.location, this.start, this.end);
double getdy()
{
double y=(((start.hour-7)*60+start.minute)*0.9)*Setting.pixelToMinuteRatio_ratio;
return y;
}
double getdx()
{
int x=start.weekday-1;
return weekListPixel[x].toDouble();
}
double getHeight(){
return (((end.hour-7)*60+end.minute)*0.9-this.getdy())*Setting.pixelToMinuteRatio_ratio;
}
// Getter methods
int? get getId => id;
int? get getUserId => userId;
int get getCourseId => courseId;
String get getName => name;
double get getCredit => credit;
String get getTeacher => teacher;
String get getLocation => location;
String get getRemark => remark;
DateTime get getStart => start;
DateTime get getEnd => end;
// Setter methods
set setId(int newId) {
id = newId;
}
set setUserId(int newUserId) {
userId = newUserId;
}
set setCourseId(int newCourseId) {
courseId = newCourseId;
}
set setName(String newName) {
name = newName;
}
set setCredit(double newCredit) {
credit = newCredit;
}
set setTeacher(String newTeacher) {
teacher = newTeacher;
}
set setLocation(String newLocation) {
location = newLocation;
}
set setRemark(String newRemark) {
remark = newRemark;
}
set setStart(DateTime newStart) {
start = newStart;
}
set setEnd(DateTime newEnd) {
end = newEnd;
}
// toString method
@override
String toString() {
return 'Course(id: $id, userid: $userId, courseId:$courseId, name: $name, credit: $credit, teacher: $teacher, location: $location, remark: $remark, start: $start, end: $end)';
}
}
import 'package:timemanagerapp/setting/Setting.dart';
class Course {
int? id;
int? userId;
int courseId;
String name;
double credit;
String teacher;
String location;
String remark;
DateTime start;
DateTime end;
Course({
this.id,
required this.userId,
required this.courseId,
required this.name,
required this.credit,
required this.teacher,
required this.location,
required this.remark,
required this.start,
required this.end,
});
Map<String,dynamic> toMap(){
return {
'userId':userId,
'courseId':courseId,
'name':"$name",
'credit':credit,
'teacher':"$teacher",
'location':"$location",
'remark':"$remark",
'start':"${start.toIso8601String()}",
'end':"${end.toIso8601String()}"
};
}
//x
var weekListPixel=[0,Setting.deviceWidth*0.12,Setting.deviceWidth*0.24,Setting.deviceWidth*0.36,Setting.deviceWidth*0.48,Setting.deviceWidth*0.60,Setting.deviceWidth*0.72];
// Course(this.name, this.teacher, this.location, this.start, this.end);
double getdy()
{
double y=(((start.hour-7)*60+start.minute)*0.9)*Setting.pixelToMinuteRatio_ratio;
return y;
}
double getdx()
{
int x=start.weekday-1;
return weekListPixel[x].toDouble();
}
double getHeight(){
return (((end.hour-7)*60+end.minute)*0.9-this.getdy())*Setting.pixelToMinuteRatio_ratio;
}
// Getter methods
int? get getId => id;
int? get getUserId => userId;
int get getCourseId => courseId;
String get getName => name;
double get getCredit => credit;
String get getTeacher => teacher;
String get getLocation => location;
String get getRemark => remark;
DateTime get getStart => start;
DateTime get getEnd => end;
// Setter methods
set setId(int newId) {
id = newId;
}
set setUserId(int newUserId) {
userId = newUserId;
}
set setCourseId(int newCourseId) {
courseId = newCourseId;
}
set setName(String newName) {
name = newName;
}
set setCredit(double newCredit) {
credit = newCredit;
}
set setTeacher(String newTeacher) {
teacher = newTeacher;
}
set setLocation(String newLocation) {
location = newLocation;
}
set setRemark(String newRemark) {
remark = newRemark;
}
set setStart(DateTime newStart) {
start = newStart;
}
set setEnd(DateTime newEnd) {
end = newEnd;
}
// toString method
@override
String toString() {
return 'Course(id: $id, userid: $userId, courseId:$courseId, name: $name, credit: $credit, teacher: $teacher, location: $location, remark: $remark, start: $start, end: $end)';
}
}

@ -1,117 +1,117 @@
class CourseForm{
late String course;
late double credit ;
late String note;
late int startWeek;
late int endWeek;
late int startTime;
late int endTime;
late String teacher;
late String location;
late List<int> selectedDays = [];
// CourseForm({
// required this.course,
// required this.credit,
// required this.note,
// required this.day,
// required this.startWeek,
// required this.endWeek,
// required this.startTime,
// required this.endTime,
// required this.teacher,
// required this.location,
// required this.selectedDays,
// });
String setCourse(String course){
this.course = course;
return this.course;
}
double setCredit(double credit){
this.credit = credit;
return this.credit;
}
String setNote (String note){
this.note = note;
return this.note;
}
int setStartWeek (int startWeek){
this.startWeek = startWeek;
return this.startWeek;
}
int setEndWeek (int endWeek){
this.endWeek = endWeek;
return this.endWeek;
}
int setStartTime (int startTime){
this.startTime = startTime;
return this.startTime;
}
int setEndTime (int endTime){
this.endTime = endTime;
return this.endTime;
}
String setTeacher (String teacher){
this.teacher = teacher;
return this.teacher;
}
String setLocation (String location){
this.location = location;
return this.location;
}
List<int> setSelectedDays (List<int> selectedDays){
this.selectedDays = selectedDays;
return this.selectedDays;
}
String getCourse(){
return this.course;
}
double getCredit(){
return this.credit;
}
String getNote(){
return this.note;
}
int getStartWeek(){
return this.startWeek;
}
int getEndWeek(){
return this.endWeek;
}
int getStartTime(){
return this.startTime;
}
int getEndTime(){
return this.endTime;
}
String getTeacher(){
return this.teacher;
}
String getLocation(){
return this.location;
}
List<int> getSelectedDays(){
return this.selectedDays;
}
class CourseForm{
late String course;
late double credit ;
late String note;
late int startWeek;
late int endWeek;
late int startTime;
late int endTime;
late String teacher;
late String location;
late List<int> selectedDays = [];
// CourseForm({
// required this.course,
// required this.credit,
// required this.note,
// required this.day,
// required this.startWeek,
// required this.endWeek,
// required this.startTime,
// required this.endTime,
// required this.teacher,
// required this.location,
// required this.selectedDays,
// });
String setCourse(String course){
this.course = course;
return this.course;
}
double setCredit(double credit){
this.credit = credit;
return this.credit;
}
String setNote (String note){
this.note = note;
return this.note;
}
int setStartWeek (int startWeek){
this.startWeek = startWeek;
return this.startWeek;
}
int setEndWeek (int endWeek){
this.endWeek = endWeek;
return this.endWeek;
}
int setStartTime (int startTime){
this.startTime = startTime;
return this.startTime;
}
int setEndTime (int endTime){
this.endTime = endTime;
return this.endTime;
}
String setTeacher (String teacher){
this.teacher = teacher;
return this.teacher;
}
String setLocation (String location){
this.location = location;
return this.location;
}
List<int> setSelectedDays (List<int> selectedDays){
this.selectedDays = selectedDays;
return this.selectedDays;
}
String getCourse(){
return this.course;
}
double getCredit(){
return this.credit;
}
String getNote(){
return this.note;
}
int getStartWeek(){
return this.startWeek;
}
int getEndWeek(){
return this.endWeek;
}
int getStartTime(){
return this.startTime;
}
int getEndTime(){
return this.endTime;
}
String getTeacher(){
return this.teacher;
}
String getLocation(){
return this.location;
}
List<int> getSelectedDays(){
return this.selectedDays;
}
}

@ -1,82 +1,82 @@
class ScheduleForm {
int? id;
int userId;
String content;
int ScheduleFormId;
String name;
DateTime startTime;
DateTime endTime;
String type;
ScheduleForm({
this.id,
required this.userId,
required this.content,
required this.ScheduleFormId,
required this.name,
required this.startTime,
required this.endTime,
required this.type
});
Map<String, dynamic> toMap() {
return {
'userId': userId,
'content': "$content",
'ScheduleFormId': ScheduleFormId,
'name': "$name",
'startTime': "${startTime.toIso8601String()}",
'endTime': "${endTime.toIso8601String()}"
};
}
// Getter methods
int? get getId => id;
int get getUserId => userId;
String get getContent => content;
int get getScheduleFormId => ScheduleFormId;
String get getName => name;
DateTime get getStartTime => startTime;
DateTime get getEndTime => endTime;
// Setter methods
set setId(int newId) {
id = newId;
}
set setUserId(int newUserId) {
userId = newUserId;
}
set setContent(String newContent) {
content = newContent;
}
set setScheduleFormId(int newScheduleFormId) {
ScheduleFormId = newScheduleFormId;
}
set setName(String newName) {
name = newName;
}
set setStartTime(DateTime newStartTime) {
startTime = newStartTime;
}
set setEndTime(DateTime newEndTime) {
endTime = newEndTime;
}
// toString method
@override
String toString() {
return 'ScheduleForm(id: $id, userId: $userId, content: $content, ScheduleFormId: $ScheduleFormId, name: $name, startTime: $startTime, endTime: $endTime)';
}
}
class ScheduleForm {
int? id;
int userId;
String content;
int ScheduleFormId;
String name;
DateTime startTime;
DateTime endTime;
String type;
ScheduleForm({
this.id,
required this.userId,
required this.content,
required this.ScheduleFormId,
required this.name,
required this.startTime,
required this.endTime,
required this.type
});
Map<String, dynamic> toMap() {
return {
'userId': userId,
'content': "$content",
'ScheduleFormId': ScheduleFormId,
'name': "$name",
'startTime': "${startTime.toIso8601String()}",
'endTime': "${endTime.toIso8601String()}"
};
}
// Getter methods
int? get getId => id;
int get getUserId => userId;
String get getContent => content;
int get getScheduleFormId => ScheduleFormId;
String get getName => name;
DateTime get getStartTime => startTime;
DateTime get getEndTime => endTime;
// Setter methods
set setId(int newId) {
id = newId;
}
set setUserId(int newUserId) {
userId = newUserId;
}
set setContent(String newContent) {
content = newContent;
}
set setScheduleFormId(int newScheduleFormId) {
ScheduleFormId = newScheduleFormId;
}
set setName(String newName) {
name = newName;
}
set setStartTime(DateTime newStartTime) {
startTime = newStartTime;
}
set setEndTime(DateTime newEndTime) {
endTime = newEndTime;
}
// toString method
@override
String toString() {
return 'ScheduleForm(id: $id, userId: $userId, content: $content, ScheduleFormId: $ScheduleFormId, name: $name, startTime: $startTime, endTime: $endTime)';
}
}

@ -1,80 +1,80 @@
class Task {
int? id;
int userId;
String content;
int taskId;
String name;
DateTime startTime;
DateTime endTime;
Task({
this.id,
required this.userId,
required this.content,
required this.taskId,
required this.name,
required this.startTime,
required this.endTime,
});
Map<String, dynamic> toMap() {
return {
'userId': userId,
'content': "$content",
'taskId': taskId,
'name': "$name",
'startTime': "${startTime.toIso8601String()}",
'endTime': "${endTime.toIso8601String()}"
};
}
// Getter methods
int? get getId => id;
int get getUserId => userId;
String get getContent => content;
int get getTaskId => taskId;
String get getName => name;
DateTime get getStartTime => startTime;
DateTime get getEndTime => endTime;
// Setter methods
set setId(int newId) {
id = newId;
}
set setUserId(int newUserId) {
userId = newUserId;
}
set setContent(String newContent) {
content = newContent;
}
set setTaskId(int newTaskId) {
taskId = newTaskId;
}
set setName(String newName) {
name = newName;
}
set setStartTime(DateTime newStartTime) {
startTime = newStartTime;
}
set setEndTime(DateTime newEndTime) {
endTime = newEndTime;
}
// toString method
@override
String toString() {
return 'Task(id: $id, userId: $userId, content: $content, taskId: $taskId, name: $name, startTime: $startTime, endTime: $endTime)';
}
}
class Task {
int? id;
int userId;
String content;
int taskId;
String name;
DateTime startTime;
DateTime endTime;
Task({
this.id,
required this.userId,
required this.content,
required this.taskId,
required this.name,
required this.startTime,
required this.endTime,
});
Map<String, dynamic> toMap() {
return {
'userId': userId,
'content': "$content",
'taskId': taskId,
'name': "$name",
'startTime': "${startTime.toIso8601String()}",
'endTime': "${endTime.toIso8601String()}"
};
}
// Getter methods
int? get getId => id;
int get getUserId => userId;
String get getContent => content;
int get getTaskId => taskId;
String get getName => name;
DateTime get getStartTime => startTime;
DateTime get getEndTime => endTime;
// Setter methods
set setId(int newId) {
id = newId;
}
set setUserId(int newUserId) {
userId = newUserId;
}
set setContent(String newContent) {
content = newContent;
}
set setTaskId(int newTaskId) {
taskId = newTaskId;
}
set setName(String newName) {
name = newName;
}
set setStartTime(DateTime newStartTime) {
startTime = newStartTime;
}
set setEndTime(DateTime newEndTime) {
endTime = newEndTime;
}
// toString method
@override
String toString() {
return 'Task(id: $id, userId: $userId, content: $content, taskId: $taskId, name: $name, startTime: $startTime, endTime: $endTime)';
}
}

@ -1,53 +1,53 @@
class Team {
int? id;
int leaderId;
String teamName;
int maxNumber;
Team({
this.id,
required this.leaderId,
required this.teamName,
required this.maxNumber,
});
Map<String, dynamic> toMap() {
return {
'leaderId': leaderId,
'teamName': "$teamName",
'maxNumber': maxNumber,
};
}
// Getter methods
int? get getId => id;
int get getLeaderId => leaderId;
String get getTeamName => teamName;
int get getMaxNumber => maxNumber;
// Setter methods
set setId(int newId) {
id = newId;
}
set setLeaderId(int newLeaderId) {
leaderId = newLeaderId;
}
set setTeamName(String newTeamName) {
teamName = newTeamName;
}
set setMaxNumber(int newMaxNumber) {
maxNumber = newMaxNumber;
}
// toString method
@override
String toString() {
return 'Team(id: $id, leaderId:$leaderId, teamName:$teamName, maxNumber: $maxNumber)';
}
}
class Team {
int? id;
int leaderId;
String teamName;
int maxNumber;
Team({
this.id,
required this.leaderId,
required this.teamName,
required this.maxNumber,
});
Map<String, dynamic> toMap() {
return {
'leaderId': leaderId,
'teamName': "$teamName",
'maxNumber': maxNumber,
};
}
// Getter methods
int? get getId => id;
int get getLeaderId => leaderId;
String get getTeamName => teamName;
int get getMaxNumber => maxNumber;
// Setter methods
set setId(int newId) {
id = newId;
}
set setLeaderId(int newLeaderId) {
leaderId = newLeaderId;
}
set setTeamName(String newTeamName) {
teamName = newTeamName;
}
set setMaxNumber(int newMaxNumber) {
maxNumber = newMaxNumber;
}
// toString method
@override
String toString() {
return 'Team(id: $id, leaderId:$leaderId, teamName:$teamName, maxNumber: $maxNumber)';
}
}

@ -1,81 +1,81 @@
class User {
int? id;
int teamId;
String username;
String password;
int role; //01
User({
this.id,
required this.teamId,
required this.username,
required this.password,
required this.role,
});
Map<String, dynamic> toMap() {
return {
'teamId': teamId,
'username': "$username",
'password': "$password",
'role': role,
};
}
// Getter methods
int? get getId => id;
int get getTeamId => teamId;
String get getUsername => username;
String get getPassword => password;
int get getRole => role;
// Setter methods
set setId(int newId) {
id = newId;
}
set setTeamId(int newTeamId) {
teamId = newTeamId;
}
set setUsername(String newUsername) {
username = newUsername;
}
set setPassword(String newPassword) {
password = newPassword;
}
set setRole(int newRole) {
role = newRole;
}
// User
factory User.parseString(String userString) {
final parts = userString.split(', '); // toString()
final id = int.parse(parts[0].substring(8)); // id
final teamId = int.parse(parts[1].substring(7)); // teamId
final username = parts[2].substring(10); //
final password = parts[3].substring(10); //
final role = int.parse(parts[4].substring(6)); // role
return User(
id: id,
teamId: teamId,
username: username,
password: password,
role: role,
);
}
// toString method
@override
String toString() {
return 'User(id: $id, teamId:$teamId, username: $username, password: $password, role: $role)';
}
}
class User {
int? id;
int teamId;
String username;
String password;
int role; //01
User({
this.id,
required this.teamId,
required this.username,
required this.password,
required this.role,
});
Map<String, dynamic> toMap() {
return {
'teamId': teamId,
'username': "$username",
'password': "$password",
'role': role,
};
}
// Getter methods
int? get getId => id;
int get getTeamId => teamId;
String get getUsername => username;
String get getPassword => password;
int get getRole => role;
// Setter methods
set setId(int newId) {
id = newId;
}
set setTeamId(int newTeamId) {
teamId = newTeamId;
}
set setUsername(String newUsername) {
username = newUsername;
}
set setPassword(String newPassword) {
password = newPassword;
}
set setRole(int newRole) {
role = newRole;
}
// User
factory User.parseString(String userString) {
final parts = userString.split(', '); // toString()
final id = int.parse(parts[0].substring(8)); // id
final teamId = int.parse(parts[1].substring(7)); // teamId
final username = parts[2].substring(10); //
final password = parts[3].substring(10); //
final role = int.parse(parts[4].substring(6)); // role
return User(
id: id,
teamId: teamId,
username: username,
password: password,
role: role,
);
}
// toString method
@override
String toString() {
return 'User(id: $id, teamId:$teamId, username: $username, password: $password, role: $role)';
}
}

@ -1,98 +1,98 @@
class Work {
int? id;
int userId;
String status;
String workContent;
int teamId;
int functionaryId;
int workId;
DateTime endTime;
DateTime startTime;
Work({
this.id,
required this.userId,
required this.status,
required this.workContent,
required this.teamId,
required this.functionaryId,
required this.workId,
required this.endTime,
required this.startTime,
});
Map<String, dynamic> toMap() {
return {
'userId': userId,
'status': "$status",
'workContent': "$workContent",
'teamId': teamId,
'functionaryId': functionaryId,
'workId': workId,
'endTime': "${endTime.toIso8601String()}",
'startTime': "${startTime.toIso8601String()}"
};
}
// Getter methods
int? get getId => id;
int get getUserId => userId;
String get getStatus => status;
String get getWorkContent => workContent;
int get getTeamId => teamId;
int get getFunctionaryId => functionaryId;
int get getWorkId => workId;
DateTime get getEndTime => endTime;
DateTime get getStartTime => startTime;
// Setter methods
set setId(int newId) {
id = newId;
}
set setUserId(int newUserId) {
userId = newUserId;
}
set setStatus(String newStatus) {
status = newStatus;
}
set setWorkContent(String newWorkContent) {
workContent = newWorkContent;
}
set setTeamId(int newTeamId) {
teamId = newTeamId;
}
set setFunctionaryId(int newFunctionaryId) {
functionaryId = newFunctionaryId;
}
set setWorkId(int newWorkId) {
workId = newWorkId;
}
set setEndTime(DateTime newEndTime) {
endTime = newEndTime;
}
set setStartTime(DateTime newStartTime) {
startTime = newStartTime;
}
// toString method
@override
String toString() {
return 'Work(id: $id, userId:$userId, status: $status, workContent: $workContent, teamId: $teamId, functionaryId: $functionaryId, workId: $workId, endTime: $endTime, startTime: $startTime)';
}
}
class Work {
int? id;
int userId;
String status;
String workContent;
int teamId;
int functionaryId;
int workId;
DateTime endTime;
DateTime startTime;
Work({
this.id,
required this.userId,
required this.status,
required this.workContent,
required this.teamId,
required this.functionaryId,
required this.workId,
required this.endTime,
required this.startTime,
});
Map<String, dynamic> toMap() {
return {
'userId': userId,
'status': "$status",
'workContent': "$workContent",
'teamId': teamId,
'functionaryId': functionaryId,
'workId': workId,
'endTime': "${endTime.toIso8601String()}",
'startTime': "${startTime.toIso8601String()}"
};
}
// Getter methods
int? get getId => id;
int get getUserId => userId;
String get getStatus => status;
String get getWorkContent => workContent;
int get getTeamId => teamId;
int get getFunctionaryId => functionaryId;
int get getWorkId => workId;
DateTime get getEndTime => endTime;
DateTime get getStartTime => startTime;
// Setter methods
set setId(int newId) {
id = newId;
}
set setUserId(int newUserId) {
userId = newUserId;
}
set setStatus(String newStatus) {
status = newStatus;
}
set setWorkContent(String newWorkContent) {
workContent = newWorkContent;
}
set setTeamId(int newTeamId) {
teamId = newTeamId;
}
set setFunctionaryId(int newFunctionaryId) {
functionaryId = newFunctionaryId;
}
set setWorkId(int newWorkId) {
workId = newWorkId;
}
set setEndTime(DateTime newEndTime) {
endTime = newEndTime;
}
set setStartTime(DateTime newStartTime) {
startTime = newStartTime;
}
// toString method
@override
String toString() {
return 'Work(id: $id, userId:$userId, status: $status, workContent: $workContent, teamId: $teamId, functionaryId: $functionaryId, workId: $workId, endTime: $endTime, startTime: $startTime)';
}
}

@ -1,36 +1,31 @@
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/HomeWighet.dart';
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();
}
void main() async {
await init();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
Setting.deviceWidth = MediaQuery.of(context).size.width;
return MaterialApp(
home: Scaffold(
// appBar: AppBar(
// title: Text('测试'),
// ),
body: HomeWidget(),
),
);
}
}
import 'package:flutter/material.dart';
import 'package:timemanagerapp/setting/Setting.dart';
import 'package:timemanagerapp/widgets/HomeWidget.dart';
init() async {
WidgetsFlutterBinding.ensureInitialized();
await Setting.init();
}
void main() async {
await init();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
Setting.deviceWidth = MediaQuery.of(context).size.width;
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
// appBar: AppBar(
// title: Text('测试'),
// ),
body: HomeWidget(),
),
);
}
}

@ -1,15 +1,24 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:timemanagerapp/wighets/AddCourseFormWidget.dart';
class AddCourseRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('添加自定义课程'),
),
body: AddCourseFormWidget(),
);
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:timemanagerapp/widgets/AddCourseFormWidget.dart';
class AddCourseRoute extends StatelessWidget {
final VoidCallback onCourseAdded;
AddCourseRoute({required this.onCourseAdded});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('添加自定义课程'),
),
body: AddCourseFormWidget(),
);
}
@override
dispose() {//
onCourseAdded();
}
}

@ -1,15 +1,15 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:timemanagerapp/wighets/AddScheduleFormWighet.dart';
class AddScheduleRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('添加自定义个人计划'),
),
body: AddScheduleFormWidget(),
);
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:timemanagerapp/widgets/AddScheduleFormWidget.dart';
class AddScheduleRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('添加自定义个人计划'),
),
body: AddScheduleFormWidget(),
);
}
}

@ -1,16 +1,16 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../tests/TestWidget.dart';
class TestRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('开发者测试'),
),
body: TestWidget(),
);
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../widgets/TestWidget.dart';
class TestRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('开发者测试'),
),
body: TestWidget(),
);
}
}

@ -1,17 +1,17 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:timemanagerapp/wighets/AddCourseFormWidget.dart';
import 'package:timemanagerapp/wighets/TimetableWighet.dart';
class TimetableRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('时间表'),
),
body: TimetableWidget(),
);
}
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:timemanagerapp/widgets/AddCourseFormWidget.dart';
import 'package:timemanagerapp/widgets/TimetableWidget.dart';
class TimetableRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('时间表'),
),
body: TimetableWidget(),
);
}
}

@ -1,17 +1,17 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:timemanagerapp/wighets/UserSettingWighet.dart';
import '../tests/TestWidget.dart';
class UserSettingRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('设置'),
),
body: UserSettingWight(),
);
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:timemanagerapp/widgets/UserSettingWidget.dart';
import '../tests/TestWidget.dart';
class UserSettingRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('设置'),
),
body: UserSettingWidgt(),
);
}
}

@ -1,57 +1,57 @@
import 'dart:ffi';
import 'package:shared_preferences/shared_preferences.dart';
import '../entity/User.dart';
class Setting {
static SharedPreferences? prefs;
static DateTime startdate_init = DateTime(2023, 8, 28);
static late DateTime startdate;
static late User? user;
static double pixelToMinuteRatio_ratio = 1;
static late double deviceWidth ;
static init() async {
//
print("Setting初始化");
prefs = await SharedPreferences.getInstance();
saveStartDate(startdate_init); //
startdate = getStartDate();
user = getUser();
print("Setting初始化成功");
}
static DateTime getStartDate() {
//
String res = null.toString();
if(prefs!.containsKey("startdate")) res = prefs!.getString("startdate")!;
if (res == null.toString()) {
saveStartDate(startdate_init);
return startdate_init;
} else {
return DateTime.parse(res);
}
}
static saveStartDate(DateTime startdate) {
//
prefs?.setString("startdate", startdate.toString());
}
static User? getUser() {
//
String res = null.toString();
if(prefs!.containsKey("user")) res = prefs!.getString("user")!;
if (res == null.toString()) {
return User(id:0, teamId: 0, username: "", password: "", role: 0);
} else {
return User.parseString(res);
}
}
static saveUser(User user) {
//
prefs?.setString("user", user.toString());
}
}
import 'dart:ffi';
import 'package:shared_preferences/shared_preferences.dart';
import '../entity/User.dart';
class Setting {
static SharedPreferences? prefs;
static DateTime startdate_init = DateTime(2023, 8, 28);
static late DateTime startdate;
static late User? user;
static double pixelToMinuteRatio_ratio = 1;
static late double deviceWidth ;
static init() async {
//
print("Setting初始化");
prefs = await SharedPreferences.getInstance();
saveStartDate(startdate_init); //
startdate = getStartDate();
user = getUser();
print("Setting初始化成功");
}
static DateTime getStartDate() {
//
String res = null.toString();
if(prefs!.containsKey("startdate")) res = prefs!.getString("startdate")!;
if (res == null.toString()) {
saveStartDate(startdate_init);
return startdate_init;
} else {
return DateTime.parse(res);
}
}
static saveStartDate(DateTime startdate) {
//
prefs?.setString("startdate", startdate.toString());
}
static User? getUser() {
//
String res = null.toString();
if(prefs!.containsKey("user")) res = prefs!.getString("user")!;
if (res == null.toString()) {
return User(id:0, teamId: 0, username: "", password: "", role: 0);
} else {
return User.parseString(res);
}
}
static saveUser(User user) {
//
prefs?.setString("user", user.toString());
}
}

@ -1,36 +1,36 @@
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/wighets/AddCourseFormWidget.dart';
import 'package:timemanagerapp/wighets/LoginWidget.dart';
import 'package:timemanagerapp/wighets/TimetableWighet.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: AddCourseFormWidget(),
),
);
}
}
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: AddCourseFormWidget(),
),
);
}
}

@ -1,11 +1,11 @@
import '../setting/Setting.dart';
import 'dart:ui' as ui;
void init(){
Setting.init();
}
void main() {
init();
print(Setting.getStartDate());
}
import '../setting/Setting.dart';
import 'dart:ui' as ui;
void init(){
Setting.init();
}
void main() {
init();
print(Setting.getStartDate());
}

@ -1,247 +1,247 @@
/*
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';
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/wighets/TimetableWighet.dart';
import '../main.dart';
import '../ruters/AddCourseRoute.dart';
import '../ruters/TimetableRoute.dart';
import '../tests/database_test.dart';
import 'package:timemanagerapp/wighets/AddCourseFormWidget.dart';
class TestWidget extends StatefulWidget {
const TestWidget({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<TestWidget> {
late UserController userController;
late CourseController courseController;
@override
void initState() {
super.initState();
MyDatabase.initDatabase();
userController = UserController.getInstance();
courseController = CourseController.getInstance();
}
@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(
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(),
),
),
);
},
);
});
},
child: Text('显示用户列表'),
),
ElevatedButton(
onPressed: courseController.deleteAllCourses,
child: Text('删除所有课程'),
),
// ElevatedButton(
// onPressed: () => courseController.autoImportCours(jsonstr),
// child: Text('导入课程(待开发)'),
// ),
ElevatedButton(
onPressed: () => 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)))),
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(),
),
),
);
},
);
});
},
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('确定'),
onPressed: () {
final jsonstr = _jsonstrController.text;
if (jsonstr.isNotEmpty) {
widget.onCourseAdded(jsonstr);
Navigator.of(context).pop();
}
},
),
],
);
},
);
}
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {
_showAddCourseDialog(context);
},
child: Text('json导入课程'),
);
}
@override
void dispose() {
_jsonstrController.dispose();
super.dispose();
}
}
// /*
// 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';
// 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/Wighets/TimetableWidget.dart';
//
// import '../main.dart';
// import '../ruters/AddCourseRoute.dart';
// import '../ruters/TimetableRoute.dart';
// import '../tests/database_test.dart';
// import 'package:timemanagerapp/Wighets/AddCourseFormWidget.dart';
//
// class TestWidget extends StatefulWidget {
// const TestWidget({Key? key}) : super(key: key);
//
// @override
// _HomePageState createState() => _HomePageState();
// }
//
// class _HomePageState extends State<TestWidget> {
// late UserController userController;
// late CourseController courseController;
//
// @override
// void initState() {
// super.initState();
// MyDatabase.initDatabase();
// userController = UserController.getInstance();
// courseController = CourseController.getInstance();
// }
//
// @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(
// 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(),
// ),
// ),
// );
// },
// );
// });
// },
// child: Text('显示用户列表'),
// ),
// ElevatedButton(
// onPressed: courseController.deleteAllCourses,
// child: Text('删除所有课程'),
// ),
// // ElevatedButton(
// // onPressed: () => courseController.autoImportCours(jsonstr),
// // child: Text('导入课程(待开发)'),
// // ),
// ElevatedButton(
// onPressed: () => 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)))),
// 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(),
// ),
// ),
// );
// },
// );
// });
// },
// 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('确定'),
// onPressed: () {
// final jsonstr = _jsonstrController.text;
// if (jsonstr.isNotEmpty) {
// widget.onCourseAdded(jsonstr);
// Navigator.of(context).pop();
// }
// },
// ),
// ],
// );
// },
// );
// }
//
// @override
// Widget build(BuildContext context) {
// return ElevatedButton(
// onPressed: () {
// _showAddCourseDialog(context);
// },
// child: Text('json导入课程'),
// );
// }
//
// @override
// void dispose() {
// _jsonstrController.dispose();
// super.dispose();
// }
// }

@ -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/wighets/AddCourseFormWidget.dart';
import 'package:timemanagerapp/wighets/LoginWidget.dart';
import 'package:timemanagerapp/wighets/TimetableWighet.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(),
),
);
}
}

@ -1,263 +1,263 @@
import 'dart:io';
import 'dart:convert';
import 'package:path_provider/path_provider.dart';
import 'package:timemanagerapp/entity/Course.dart';
import 'package:timemanagerapp/setting/Setting.dart';
import 'package:timemanagerapp/util/dataUtil.dart';
class GetCourseByLogin {
String id = "210340156"; //
String passwd = "123111@qaq"; //
String year = "2022"; //
String term = "1"; //
DateTime termstartdate = Setting.startdate;
List<Course> courses = []; //
IdGenerator idGenerator = IdGenerator();
// GetCourseByLogin({this.id = "", this.passwd = "", this.year = "2021", this.term = "1"});
//
final List<List<String>> raspiyane = [
["8:00", "8:45"], //1
["8:50", "9:35"], //2
["10:05", "10:50"], //3
["10:55", "11:40"], //4
["13:30", "14:15"], //5
["14:20", "15:05"], //6
["15:35", "16:20"], //7
["16:25", "17:10"], //8
["18:30", "19:11"],
["19:20", "20:05"],
["20:10", "20:55"],
["21:10", "21:50"],
["22:05", "22:35"],
];
final weekdayMap = {
'': 1,
'': 2,
'': 3,
'': 4,
'': 5,
'': 6,
'': 7,
};
var pythonScriptPath = "/assets/pythoncode/getschedule.py";
Future<String> getRawString() async {
// var documentsDirectory = (await getApplicationDocumentsDirectory()).list();
// print("path = " + documentsDirectory.list().map((event) => event.path.toString()).toString());
// pythonScriptPath = documentsDirectory.path + pythonScriptPath;
final file = File(pythonScriptPath);
String res = "";
if (!file.existsSync()) {
print('Python脚本文件不存在: $pythonScriptPath');
// return "";
}
final process = await Process.start('python', [pythonScriptPath]);
// final process = await Process.start('python',['-c', pythonCode]);
process.stdin.writeln('$id');
process.stdin.writeln('$passwd');
process.stdin.writeln('$year');
process.stdin.writeln('$term');
process.stdout.transform(utf8.decoder).listen((data) {
print('$data');
res += data;
});
process.stderr.transform(utf8.decoder).listen((data) {
print('Python Error: $data');
res += data;
});
final exitCode = await process.exitCode;
return Future(() => res);
}
dealRawString(String rawStr) async {
rawStr = rawStr.replaceAll("'", "\"");
// JSON
final jsonData = jsonDecode(rawStr);
final data = jsonData['data'];
final coursesData = data['courses'];
for (var courseData in coursesData) {
final courseId = courseData['course_id'];
final courseTime = courseData['time'];
final courseTitle = courseData['title'];
//
final timeRegex = RegExp(r'星期([一二三四五六日])第(\d)-(\d)节\{([^{}]+)\}');
final match = timeRegex.firstMatch(courseTime);
if (match != null) {
final weekday = weekdayMap[match.group(1)!];
final startSection = int.parse(match.group(2)!);
final endSection = int.parse(match.group(3)!);
final weekInfo = match.group(4)!;
//
final weekRanges = weekInfo.split('');
for (var weekRange in weekRanges) {
//
// weekRange = weekRange.replaceAll('', '1').replaceAll('', '2');
//
// final weekRegex = RegExp(r'(\d+)-(\d+)周');
final weekRegex = RegExp(r'(\d+)-(\d+)周(?:\((单|双)\))?');
final weekMatch = weekRegex.firstMatch(weekRange);
if (weekMatch != null) {
final startWeek = int.parse(weekMatch.group(1)!);
final endWeek = int.parse(weekMatch.group(2)!);
final weekType = weekMatch.group(3); // null
//
for (var week = startWeek; week <= endWeek; week++) {
//
if (week % 2 == 0 && weekType == '' ||
week % 2 == 1 && weekType == '') {
continue;
}
//
final startdate = termstartdate.add(Duration(
days: (7 * (week - 1) + weekday! - 1),
hours: int.parse(raspiyane[startSection - 1][0].split(':')[0]),
minutes:
int.parse(raspiyane[startSection - 1][0].split(':')[1]),
));
final endDate = termstartdate.add(Duration(
days: (7 * (week - 1) + weekday! - 1),
hours: int.parse(raspiyane[endSection - 1][1].split(':')[0]),
minutes: int.parse(raspiyane[endSection - 1][1].split(':')[1]),
));
// Course
final course = Course(
id: int.parse(courseId),
userId: Setting.user != null ? Setting.user!.id : null,
courseId: await idGenerator.generateId(),
name: courseTitle,
credit: courseData['credit'],
teacher: courseData['teacher'],
location: courseData['place'],
remark: "schoolclass",
start: startdate,
end: endDate,
);
courses.add(course);
// //
// for (var section = startSection; section <= endSection; section++) {
// //
// final termstartdate = termstartdate.add(Duration(
// days: (7 * (week - 1) + weekday! - 1),
// hours: int.parse(raspiyane[section - 1][0].split(':')[0]),
// minutes: int.parse(raspiyane[section - 1][0].split(':')[1]),
// ));
//
// final endDate = termstartdate.add(Duration(
// days: (7 * (week - 1) + weekday! - 1),
// hours: int.parse(raspiyane[section - 1][1].split(':')[0]),
// minutes: int.parse(raspiyane[section - 1][1].split(':')[1]),
// ));
//
// // Course
// final course = Course(
// id: courseId,
// name: courseTitle,
// credit: courseData['credit'],
// teacher: courseData['teacher'],
// location: courseData['place'],
// start: termstartdate,
// end: endDate,
// );
//
// courses.add(course);
// }
}
}
}
}
}
return courses;
}
run() async {
String rawStr = await getRawString();
await dealRawString(rawStr);
// printcourseinfo();
return courses;
}
printcourseinfo() {
if (courses.length != 0) {
for (Course course in courses) {
print("====================================");
print("name = " + course.name);
print("id = " + course.id.toString());
print("credit = " + course.credit.toString());
print("teacher = " + course.teacher);
print("location = " + course.location);
print("start = " + course.start.toString());
print("end = " + course.end.toString());
}
} else {
print("null");
}
}
String _extractValue(String source, String key) {
final startIndex = source.indexOf(key) + key.length;
final endIndex = source.indexOf("'", startIndex);
return source.substring(startIndex, endIndex);
}
List<int> getweeklist(String weekstr) {
List<int> ans = [];
if (weekstr.contains('-')) {
if (weekstr.contains('')) {
weekstr = weekstr.replaceAll('(单)', '');
var weekstrlist = weekstr.split('-');
var startweek = int.parse(weekstrlist[0]);
var endweek = int.parse(weekstrlist[1]);
for (int i = startweek; i <= endweek; i++) {
if (i % 2 == 1) {
ans.add(i);
}
}
} else if (weekstr.contains('')) {
weekstr = weekstr.replaceAll('(双)', '');
var weekstrlist = weekstr.split('-');
var startweek = int.parse(weekstrlist[0]);
var endweek = int.parse(weekstrlist[1]);
for (int i = startweek; i <= endweek; i++) {
if (i % 2 == 0) {
ans.add(i);
}
}
} else {
var weekstrlist = weekstr.split('-');
var startweek = int.parse(weekstrlist[0]);
var endweek = int.parse(weekstrlist[1]);
for (int i = startweek; i <= endweek; i++) {
ans.add(i);
}
}
} else if (weekstr.contains(',')) {
var weekstrlist = weekstr.split(',');
for (String week in weekstrlist) {
ans.add(int.parse(week));
}
} else {
ans.add(int.parse(weekstr));
}
return ans;
}
}
import 'dart:io';
import 'dart:convert';
import 'package:path_provider/path_provider.dart';
import 'package:timemanagerapp/entity/Course.dart';
import 'package:timemanagerapp/setting/Setting.dart';
import 'package:timemanagerapp/util/dataUtil.dart';
class GetCourseByLogin {
String id = "210340156"; //
String passwd = "123111@qaq"; //
String year = "2022"; //
String term = "1"; //
DateTime termstartdate = Setting.startdate;
List<Course> courses = []; //
IdGenerator idGenerator = IdGenerator();
// GetCourseByLogin({this.id = "", this.passwd = "", this.year = "2021", this.term = "1"});
//
final List<List<String>> raspiyane = [
["8:00", "8:45"], //1
["8:50", "9:35"], //2
["10:05", "10:50"], //3
["10:55", "11:40"], //4
["13:30", "14:15"], //5
["14:20", "15:05"], //6
["15:35", "16:20"], //7
["16:25", "17:10"], //8
["18:30", "19:11"],
["19:20", "20:05"],
["20:10", "20:55"],
["21:10", "21:50"],
["22:05", "22:35"],
];
final weekdayMap = {
'': 1,
'': 2,
'': 3,
'': 4,
'': 5,
'': 6,
'': 7,
};
var pythonScriptPath = "/assets/pythoncode/getschedule.py";
Future<String> getRawString() async {
// var documentsDirectory = (await getApplicationDocumentsDirectory()).list();
// print("path = " + documentsDirectory.list().map((event) => event.path.toString()).toString());
// pythonScriptPath = documentsDirectory.path + pythonScriptPath;
final file = File(pythonScriptPath);
String res = "";
if (!file.existsSync()) {
print('Python脚本文件不存在: $pythonScriptPath');
// return "";
}
final process = await Process.start('python', [pythonScriptPath]);
// final process = await Process.start('python',['-c', pythonCode]);
process.stdin.writeln('$id');
process.stdin.writeln('$passwd');
process.stdin.writeln('$year');
process.stdin.writeln('$term');
process.stdout.transform(utf8.decoder).listen((data) {
print('$data');
res += data;
});
process.stderr.transform(utf8.decoder).listen((data) {
print('Python Error: $data');
res += data;
});
final exitCode = await process.exitCode;
return Future(() => res);
}
dealRawString(String rawStr) async {
rawStr = rawStr.replaceAll("'", "\"");
// JSON
final jsonData = jsonDecode(rawStr);
final data = jsonData['data'];
final coursesData = data['courses'];
for (var courseData in coursesData) {
final courseId = courseData['course_id'];
final courseTime = courseData['time'];
final courseTitle = courseData['title'];
//
final timeRegex = RegExp(r'星期([一二三四五六日])第(\d)-(\d)节\{([^{}]+)\}');
final match = timeRegex.firstMatch(courseTime);
if (match != null) {
final weekday = weekdayMap[match.group(1)!];
final startSection = int.parse(match.group(2)!);
final endSection = int.parse(match.group(3)!);
final weekInfo = match.group(4)!;
//
final weekRanges = weekInfo.split('');
for (var weekRange in weekRanges) {
//
// weekRange = weekRange.replaceAll('', '1').replaceAll('', '2');
//
// final weekRegex = RegExp(r'(\d+)-(\d+)周');
final weekRegex = RegExp(r'(\d+)-(\d+)周(?:\((单|双)\))?');
final weekMatch = weekRegex.firstMatch(weekRange);
if (weekMatch != null) {
final startWeek = int.parse(weekMatch.group(1)!);
final endWeek = int.parse(weekMatch.group(2)!);
final weekType = weekMatch.group(3); // null
//
for (var week = startWeek; week <= endWeek; week++) {
//
if (week % 2 == 0 && weekType == '' ||
week % 2 == 1 && weekType == '') {
continue;
}
//
final startdate = termstartdate.add(Duration(
days: (7 * (week - 1) + weekday! - 1),
hours: int.parse(raspiyane[startSection - 1][0].split(':')[0]),
minutes:
int.parse(raspiyane[startSection - 1][0].split(':')[1]),
));
final endDate = termstartdate.add(Duration(
days: (7 * (week - 1) + weekday! - 1),
hours: int.parse(raspiyane[endSection - 1][1].split(':')[0]),
minutes: int.parse(raspiyane[endSection - 1][1].split(':')[1]),
));
// Course
final course = Course(
id: int.parse(courseId),
userId: Setting.user != null ? Setting.user!.id : null,
courseId: await idGenerator.generateId(),
name: courseTitle,
credit: courseData['credit'],
teacher: courseData['teacher'],
location: courseData['place'],
remark: "schoolclass",
start: startdate,
end: endDate,
);
courses.add(course);
// //
// for (var section = startSection; section <= endSection; section++) {
// //
// final termstartdate = termstartdate.add(Duration(
// days: (7 * (week - 1) + weekday! - 1),
// hours: int.parse(raspiyane[section - 1][0].split(':')[0]),
// minutes: int.parse(raspiyane[section - 1][0].split(':')[1]),
// ));
//
// final endDate = termstartdate.add(Duration(
// days: (7 * (week - 1) + weekday! - 1),
// hours: int.parse(raspiyane[section - 1][1].split(':')[0]),
// minutes: int.parse(raspiyane[section - 1][1].split(':')[1]),
// ));
//
// // Course
// final course = Course(
// id: courseId,
// name: courseTitle,
// credit: courseData['credit'],
// teacher: courseData['teacher'],
// location: courseData['place'],
// start: termstartdate,
// end: endDate,
// );
//
// courses.add(course);
// }
}
}
}
}
}
return courses;
}
run() async {
String rawStr = await getRawString();
await dealRawString(rawStr);
// printcourseinfo();
return courses;
}
printcourseinfo() {
if (courses.length != 0) {
for (Course course in courses) {
print("====================================");
print("name = " + course.name);
print("id = " + course.id.toString());
print("credit = " + course.credit.toString());
print("teacher = " + course.teacher);
print("location = " + course.location);
print("start = " + course.start.toString());
print("end = " + course.end.toString());
}
} else {
print("null");
}
}
String _extractValue(String source, String key) {
final startIndex = source.indexOf(key) + key.length;
final endIndex = source.indexOf("'", startIndex);
return source.substring(startIndex, endIndex);
}
List<int> getweeklist(String weekstr) {
List<int> ans = [];
if (weekstr.contains('-')) {
if (weekstr.contains('')) {
weekstr = weekstr.replaceAll('(单)', '');
var weekstrlist = weekstr.split('-');
var startweek = int.parse(weekstrlist[0]);
var endweek = int.parse(weekstrlist[1]);
for (int i = startweek; i <= endweek; i++) {
if (i % 2 == 1) {
ans.add(i);
}
}
} else if (weekstr.contains('')) {
weekstr = weekstr.replaceAll('(双)', '');
var weekstrlist = weekstr.split('-');
var startweek = int.parse(weekstrlist[0]);
var endweek = int.parse(weekstrlist[1]);
for (int i = startweek; i <= endweek; i++) {
if (i % 2 == 0) {
ans.add(i);
}
}
} else {
var weekstrlist = weekstr.split('-');
var startweek = int.parse(weekstrlist[0]);
var endweek = int.parse(weekstrlist[1]);
for (int i = startweek; i <= endweek; i++) {
ans.add(i);
}
}
} else if (weekstr.contains(',')) {
var weekstrlist = weekstr.split(',');
for (String week in weekstrlist) {
ans.add(int.parse(week));
}
} else {
ans.add(int.parse(weekstr));
}
return ans;
}
}

@ -1,115 +1,115 @@
import 'dart:io';
import 'dart:math';
import 'package:device_info/device_info.dart';
import 'package:flutter/services.dart';
//id
class IdGenerator {
static const int EPOCH = 1609459200000; // 2021-01-01 00:00:00
static const int WORKER_ID_BITS = 5;
static const int DATACENTER_ID_BITS = 5;
static const int SEQUENCE_BITS = 12;
late int workerId;
late int datacenterId;
late var sequenceFuther ;
late int sequence = 0;
late int lastTimestamp = -1;
IdGenerator() {
//workerId = Random().nextInt(pow(2, WORKER_ID_BITS)) % 4096;
var wordidrang = pow(2, WORKER_ID_BITS).toInt();
workerId = Random().nextInt(wordidrang);
datacenterId = Random().nextInt(pow(2, DATACENTER_ID_BITS).toInt());
sequenceFuther = generateSequenceFromMacAddress();
if (workerId < 0 || workerId >= pow(2, WORKER_ID_BITS)) {
throw ArgumentError('Worker ID must be between 0 and ${pow(2, WORKER_ID_BITS) - 1}');
}
if (datacenterId < 0 || datacenterId >= pow(2, DATACENTER_ID_BITS)) {
throw ArgumentError('Datacenter ID must be between 0 and ${pow(2, DATACENTER_ID_BITS) - 1}');
}
}
Future<int> generateId() async{
sequence = await sequenceFuther;
int timestamp = DateTime.now().millisecondsSinceEpoch - EPOCH;
if (timestamp < lastTimestamp) {
throw Exception('Invalid system clock');
}
if (timestamp == lastTimestamp) {
sequence = (sequence + 1) & ((1 << SEQUENCE_BITS) - 1);
if (sequence == 0) {
timestamp = tilNextMillis(lastTimestamp);
}
} else {
sequence = 0;
}
lastTimestamp = timestamp;
int id = (timestamp << (WORKER_ID_BITS + DATACENTER_ID_BITS + SEQUENCE_BITS)) |
(datacenterId << (WORKER_ID_BITS + SEQUENCE_BITS)) |
(workerId << SEQUENCE_BITS) |
sequence;
return id;
}
int tilNextMillis(int lastTimestamp) {
int timestamp = DateTime.now().millisecondsSinceEpoch - EPOCH;
while (timestamp <= lastTimestamp) {
timestamp = DateTime.now().millisecondsSinceEpoch - EPOCH;
}
return timestamp;
}
Future<int> generateSequenceFromMacAddress() async{
String macAddress = await getMacAddress();;
// MAC
String sanitizedMacAddress = macAddress.replaceAll(':', '').toUpperCase();
// MAC6
int sum = int.parse(sanitizedMacAddress.substring(0, 12), radix: 16);
// sequence
return sum % (1 << 12);
}
Future<String> getMacAddress() async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
if (Platform.isAndroid) {
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
return _getMacAddress(androidInfo);
} else if (Platform.isIOS) {
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
return iosInfo.identifierForVendor;
}
return '';
}
Future<String> _getMacAddress(AndroidDeviceInfo androidInfo) async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
String macAddress = androidInfo.androidId;
print("get MAC address:" + macAddress);
return macAddress;
// 使WifiManagerMAC
MethodChannel channel = MethodChannel('plugins.flutter.io/device_info');
try {
macAddress = await channel.invokeMethod('getWifiMacAddress');
} catch (e) {
print('Failed to get MAC address: $e');
}
return macAddress;
}
}
import 'dart:io';
import 'dart:math';
import 'package:device_info/device_info.dart';
import 'package:flutter/services.dart';
//id
class IdGenerator {
static const int EPOCH = 1609459200000; // 2021-01-01 00:00:00
static const int WORKER_ID_BITS = 5;
static const int DATACENTER_ID_BITS = 5;
static const int SEQUENCE_BITS = 12;
late int workerId;
late int datacenterId;
late var sequenceFuther ;
late int sequence = 0;
late int lastTimestamp = -1;
IdGenerator() {
//workerId = Random().nextInt(pow(2, WORKER_ID_BITS)) % 4096;
var wordidrang = pow(2, WORKER_ID_BITS).toInt();
workerId = Random().nextInt(wordidrang);
datacenterId = Random().nextInt(pow(2, DATACENTER_ID_BITS).toInt());
sequenceFuther = generateSequenceFromMacAddress();
if (workerId < 0 || workerId >= pow(2, WORKER_ID_BITS)) {
throw ArgumentError('Worker ID must be between 0 and ${pow(2, WORKER_ID_BITS) - 1}');
}
if (datacenterId < 0 || datacenterId >= pow(2, DATACENTER_ID_BITS)) {
throw ArgumentError('Datacenter ID must be between 0 and ${pow(2, DATACENTER_ID_BITS) - 1}');
}
}
Future<int> generateId() async{
sequence = await sequenceFuther;
int timestamp = DateTime.now().millisecondsSinceEpoch - EPOCH;
if (timestamp < lastTimestamp) {
throw Exception('Invalid system clock');
}
if (timestamp == lastTimestamp) {
sequence = (sequence + 1) & ((1 << SEQUENCE_BITS) - 1);
if (sequence == 0) {
timestamp = tilNextMillis(lastTimestamp);
}
} else {
sequence = 0;
}
lastTimestamp = timestamp;
int id = (timestamp << (WORKER_ID_BITS + DATACENTER_ID_BITS + SEQUENCE_BITS)) |
(datacenterId << (WORKER_ID_BITS + SEQUENCE_BITS)) |
(workerId << SEQUENCE_BITS) |
sequence;
return id;
}
int tilNextMillis(int lastTimestamp) {
int timestamp = DateTime.now().millisecondsSinceEpoch - EPOCH;
while (timestamp <= lastTimestamp) {
timestamp = DateTime.now().millisecondsSinceEpoch - EPOCH;
}
return timestamp;
}
Future<int> generateSequenceFromMacAddress() async{
String macAddress = await getMacAddress();;
// MAC
String sanitizedMacAddress = macAddress.replaceAll(':', '').toUpperCase();
// MAC6
int sum = int.parse(sanitizedMacAddress.substring(0, 12), radix: 16);
// sequence
return sum % (1 << 12);
}
Future<String> getMacAddress() async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
if (Platform.isAndroid) {
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
return _getMacAddress(androidInfo);
} else if (Platform.isIOS) {
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
return iosInfo.identifierForVendor;
}
return '';
}
Future<String> _getMacAddress(AndroidDeviceInfo androidInfo) async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
String macAddress = androidInfo.androidId;
print("get MAC address:" + macAddress);
return macAddress;
// 使WifiManagerMAC
MethodChannel channel = MethodChannel('plugins.flutter.io/device_info');
try {
macAddress = await channel.invokeMethod('getWifiMacAddress');
} catch (e) {
print('Failed to get MAC address: $e');
}
return macAddress;
}
}

@ -1,54 +1,54 @@
# example.py
import base64
import os
import sys
from pprint import pprint
import sys
from zfn_api import Client
sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf-8', buffering=1)
cookies = {}
base_url = 'http://jwgl.cauc.edu.cn'
raspisanie = []
ignore_type = []
detail_category_type = []
timeout = 5
userid = input() #账号
passwd = input() #密码
year = input() #学年
term = input() #学期
stu = Client(cookies=cookies, base_url=base_url, raspisanie=raspisanie, ignore_type=ignore_type, detail_category_type=detail_category_type, timeout=timeout)
if cookies == {}:
lgn = stu.login(userid, passwd)
if lgn["code"] == 1001:
verify_data = lgn["data"]
with open(os.path.abspath("kaptcha.png"), "wb") as pic:
pic.write(base64.b64decode(verify_data.pop("kaptcha_pic")))
verify_data["kaptcha"] = input("输入验证码:")
ret = stu.login_with_kaptcha(**verify_data)
if ret["code"] != 1000:
pprint(ret)
sys.exit()
pprint(ret)
elif lgn["code"] != 1000:
pprint(lgn)
sys.exit()
# result = stu.get_info('210340156') # 获取个人信息
# # result = stu.get_grade(2021, 2) # 获取成绩信息,若接口错误请添加 use_personal_info=True只填年份获取全年
# result = stu.get_schedule(2022, 2) # 获取课程表信息
# # result = stu.get_academia() # 获取学业生涯数据
# # result = stu.get_notifications() # 获取通知消息
result = stu.get_selected_courses(int(year), int(term)) # 获取已选课程信息
# # result = stu.get_block_courses(2021, 1, 1) # 获取选课板块课列表
pprint(result)
# # file_result = stu.get_academia_pdf()["data"] # 获取学业生涯学生成绩总表PDF文件
# file_result = stu.get_schedule_pdf(2022, 1)["data"] # 获取课程表PDF文件
# with open(os.path.abspath("preview.pdf"), "wb") as f:
# example.py
import base64
import os
import sys
from pprint import pprint
import sys
from zfn_api import Client
sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf-8', buffering=1)
cookies = {}
base_url = 'http://jwgl.cauc.edu.cn'
raspisanie = []
ignore_type = []
detail_category_type = []
timeout = 5
userid = input() #账号
passwd = input() #密码
year = input() #学年
term = input() #学期
stu = Client(cookies=cookies, base_url=base_url, raspisanie=raspisanie, ignore_type=ignore_type, detail_category_type=detail_category_type, timeout=timeout)
if cookies == {}:
lgn = stu.login(userid, passwd)
if lgn["code"] == 1001:
verify_data = lgn["data"]
with open(os.path.abspath("kaptcha.png"), "wb") as pic:
pic.write(base64.b64decode(verify_data.pop("kaptcha_pic")))
verify_data["kaptcha"] = input("输入验证码:")
ret = stu.login_with_kaptcha(**verify_data)
if ret["code"] != 1000:
pprint(ret)
sys.exit()
pprint(ret)
elif lgn["code"] != 1000:
pprint(lgn)
sys.exit()
# result = stu.get_info('210340156') # 获取个人信息
# # result = stu.get_grade(2021, 2) # 获取成绩信息,若接口错误请添加 use_personal_info=True只填年份获取全年
# result = stu.get_schedule(2022, 2) # 获取课程表信息
# # result = stu.get_academia() # 获取学业生涯数据
# # result = stu.get_notifications() # 获取通知消息
result = stu.get_selected_courses(int(year), int(term)) # 获取已选课程信息
# # result = stu.get_block_courses(2021, 1, 1) # 获取选课板块课列表
pprint(result)
# # file_result = stu.get_academia_pdf()["data"] # 获取学业生涯学生成绩总表PDF文件
# file_result = stu.get_schedule_pdf(2022, 1)["data"] # 获取课程表PDF文件
# with open(os.path.abspath("preview.pdf"), "wb") as f:
# f.write(file_result)

File diff suppressed because it is too large Load Diff

@ -1,215 +1,215 @@
import 'package:flutter/material.dart';
import 'package:multi_select_flutter/dialog/multi_select_dialog_field.dart';
import 'package:multi_select_flutter/util/multi_select_item.dart';
import 'package:timemanagerapp/controller/CourseController.dart';
import 'package:timemanagerapp/entity/CourseForm.dart';
class AddCourseFormWidget extends StatefulWidget {
const AddCourseFormWidget({Key? key}) : super(key: key);
@override
_AddCourseFormWidgetState createState() => _AddCourseFormWidgetState();
}
class _AddCourseFormWidgetState extends State<AddCourseFormWidget> {
CourseController courseController = CourseController();
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
CourseForm courseForm = CourseForm();
String course = '';
String credit = '';
String note = '';
String startWeek = '1';
String endWeek = '12';
String startTime = '1';
String endTime = '2';
String teacher = '';
String location = '';
List<String> selectedDays = [];
List<MultiSelectItem<String>> daysList = [
MultiSelectItem('周一', ''),
MultiSelectItem('周二', ''),
MultiSelectItem('周三', ''),
MultiSelectItem('周四', ''),
MultiSelectItem('周五', ''),
MultiSelectItem('周六', ''),
MultiSelectItem('周日', ''),
];
final weekdayMap = {
'周一': 1,
'周二': 2,
'周三': 3,
'周四': 4,
'周五': 5,
'周六': 6,
'周日': 7,
};
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Padding( //
padding: const EdgeInsets.all(16.0), // 16
child: Form( //
key: _formKey, // globalKeyFormState
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, //
children: <Widget>[
TextFormField( //
decoration: InputDecoration(labelText: '课程*'), //
onSaved: (value) => course = value ?? '', //
validator: (value) { //
if (value == null || value.isEmpty) {
return '课程名为必填项';
}
return null;
},
),
SizedBox(height: 16.0),//
TextFormField(
decoration: InputDecoration(labelText: '学分'),
onSaved: (value) => credit = value ?? '',
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '备注'),
onSaved: (value) => note = value ?? '',
),
SizedBox(height: 16.0),
MultiSelectDialogField<String>(
items: daysList,
title: Text('上课日*'),
validator: (values) {
if (values == null || values.isEmpty) {
return '上课日为必填项';
}
return null;
},
onConfirm: (values) {
setState(() {
selectedDays = values;
});
},
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '开始周'),
onSaved: (value) => startWeek = value ?? '',
validator: (value) {
if (value == null || value.isEmpty) {
return '开始周为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '结束周'),
onSaved: (value) => endWeek = value ?? '',
validator: (value) {
if (value == null || value.isEmpty) {
return '结束周为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
DropdownButtonFormField<String>(
value: startTime,
onChanged: (newValue) {
setState(() {
startTime = newValue ?? '';
});
},
items: List.generate(12, (index) => (index + 1).toString())
.map((time) => DropdownMenuItem(
value: time,
child: Text(time),
))
.toList(),
decoration: InputDecoration(labelText: '上课时间'),
validator: (value) {
if (value == null || value.isEmpty) {
return '上课时间为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
DropdownButtonFormField<String>(
value: endTime,
onChanged: (newValue) {
setState(() {
endTime = newValue ?? '';
});
},
items: List.generate(12, (index) => (index + 1).toString())
.map((time) => DropdownMenuItem(
value: time,
child: Text(time),
))
.toList(),
decoration: InputDecoration(labelText: '下课时间*'),
validator: (value) {
if (value == null || value.isEmpty) {
return '下课时间为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '老师'),
onSaved: (value) => teacher = value ?? '',
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '地点'),
onSaved: (value) => location = value ?? '',
),
SizedBox(height: 24.0),
Row( //
mainAxisAlignment: MainAxisAlignment.spaceAround, //
children: <Widget>[
ElevatedButton(
onPressed: () {
//
Navigator.pop(context); //
},
child: Text('取消'),
),
ElevatedButton(
onPressed: () {
//
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
//
courseForm.course = course;
courseForm.credit = double.parse(credit);
courseForm.note = note;
courseForm.location = location;
courseForm.selectedDays = selectedDays.map((e) => weekdayMap[e]!).toList();
courseForm.startWeek = int.parse(startWeek);
courseForm.endWeek = int.parse(endWeek);
courseForm.startTime = int.parse(startTime);
courseForm.endTime = int.parse(endTime);
courseForm.teacher = teacher;
courseController.addCourseForm(courseForm).then((value) => Navigator.pop(context)); //
}
},
child: Text('确定'),
),
],
),
],
),
),
),
);
}
import 'package:flutter/material.dart';
import 'package:multi_select_flutter/dialog/multi_select_dialog_field.dart';
import 'package:multi_select_flutter/util/multi_select_item.dart';
import 'package:timemanagerapp/controller/CourseController.dart';
import 'package:timemanagerapp/entity/CourseForm.dart';
class AddCourseFormWidget extends StatefulWidget {
const AddCourseFormWidget({Key? key}) : super(key: key);
@override
_AddCourseFormWidgetState createState() => _AddCourseFormWidgetState();
}
class _AddCourseFormWidgetState extends State<AddCourseFormWidget> {
CourseController courseController = CourseController();
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
CourseForm courseForm = CourseForm();
String course = '';
String credit = '';
String note = '';
String startWeek = '1';
String endWeek = '12';
String startTime = '1';
String endTime = '2';
String teacher = '';
String location = '';
List<String> selectedDays = [];
List<MultiSelectItem<String>> daysList = [
MultiSelectItem('周一', ''),
MultiSelectItem('周二', ''),
MultiSelectItem('周三', ''),
MultiSelectItem('周四', ''),
MultiSelectItem('周五', ''),
MultiSelectItem('周六', ''),
MultiSelectItem('周日', ''),
];
final weekdayMap = {
'周一': 1,
'周二': 2,
'周三': 3,
'周四': 4,
'周五': 5,
'周六': 6,
'周日': 7,
};
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Padding( //
padding: const EdgeInsets.all(16.0), // 16
child: Form( //
key: _formKey, // globalKeyFormState
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, //
children: <Widget>[
TextFormField( //
decoration: InputDecoration(labelText: '课程*'), //
onSaved: (value) => course = value ?? '', //
validator: (value) { //
if (value == null || value.isEmpty) {
return '课程名为必填项';
}
return null;
},
),
SizedBox(height: 16.0),//
TextFormField(
decoration: InputDecoration(labelText: '学分'),
onSaved: (value) => credit = value ?? '',
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '备注'),
onSaved: (value) => note = value ?? '',
),
SizedBox(height: 16.0),
MultiSelectDialogField<String>(
items: daysList,
title: Text('上课日*'),
validator: (values) {
if (values == null || values.isEmpty) {
return '上课日为必填项';
}
return null;
},
onConfirm: (values) {
setState(() {
selectedDays = values;
});
},
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '开始周'),
onSaved: (value) => startWeek = value ?? '',
validator: (value) {
if (value == null || value.isEmpty) {
return '开始周为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '结束周'),
onSaved: (value) => endWeek = value ?? '',
validator: (value) {
if (value == null || value.isEmpty) {
return '结束周为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
DropdownButtonFormField<String>(
value: startTime,
onChanged: (newValue) {
setState(() {
startTime = newValue ?? '';
});
},
items: List.generate(12, (index) => (index + 1).toString())
.map((time) => DropdownMenuItem(
value: time,
child: Text(time),
))
.toList(),
decoration: InputDecoration(labelText: '上课时间'),
validator: (value) {
if (value == null || value.isEmpty) {
return '上课时间为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
DropdownButtonFormField<String>(
value: endTime,
onChanged: (newValue) {
setState(() {
endTime = newValue ?? '';
});
},
items: List.generate(12, (index) => (index + 1).toString())
.map((time) => DropdownMenuItem(
value: time,
child: Text(time),
))
.toList(),
decoration: InputDecoration(labelText: '下课时间*'),
validator: (value) {
if (value == null || value.isEmpty) {
return '下课时间为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '老师'),
onSaved: (value) => teacher = value ?? '',
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '地点'),
onSaved: (value) => location = value ?? '',
),
SizedBox(height: 24.0),
Row( //
mainAxisAlignment: MainAxisAlignment.spaceAround, //
children: <Widget>[
ElevatedButton(
onPressed: () {
//
Navigator.pop(context); //
},
child: Text('取消'),
),
ElevatedButton(
onPressed: () {
//
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
//
courseForm.course = course;
courseForm.credit = double.parse(credit);
courseForm.note = note;
courseForm.location = location;
courseForm.selectedDays = selectedDays.map((e) => weekdayMap[e]!).toList();
courseForm.startWeek = int.parse(startWeek);
courseForm.endWeek = int.parse(endWeek);
courseForm.startTime = int.parse(startTime);
courseForm.endTime = int.parse(endTime);
courseForm.teacher = teacher;
courseController.addCourseForm(courseForm).then((value) => Navigator.pop(context)); //
}
},
child: Text('确定'),
),
],
),
],
),
),
),
);
}
}

@ -1,215 +1,215 @@
import 'package:flutter/material.dart';
import 'package:multi_select_flutter/dialog/multi_select_dialog_field.dart';
import 'package:multi_select_flutter/util/multi_select_item.dart';
import 'package:timemanagerapp/controller/CourseController.dart';
import 'package:timemanagerapp/entity/CourseForm.dart';
class AddScheduleFormWidget extends StatefulWidget {
const AddScheduleFormWidget({Key? key}) : super(key: key);
@override
_AddScheduleFormWidgetState createState() => _AddScheduleFormWidgetState();
}
class _AddScheduleFormWidgetState extends State<AddScheduleFormWidget> {
CourseController courseController = CourseController();
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
CourseForm courseForm = CourseForm();
String course = '';
String credit = '';
String note = '';
String startWeek = '1';
String endWeek = '12';
String startTime = '1';
String endTime = '2';
String teacher = '';
String location = '';
List<String> selectedDays = [];
List<MultiSelectItem<String>> daysList = [
MultiSelectItem('周一', ''),
MultiSelectItem('周二', ''),
MultiSelectItem('周三', ''),
MultiSelectItem('周四', ''),
MultiSelectItem('周五', ''),
MultiSelectItem('周六', ''),
MultiSelectItem('周日', ''),
];
final weekdayMap = {
'周一': 1,
'周二': 2,
'周三': 3,
'周四': 4,
'周五': 5,
'周六': 6,
'周日': 7,
};
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Padding( //
padding: const EdgeInsets.all(16.0), // 16
child: Form( //
key: _formKey, // globalKeyFormState
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, //
children: <Widget>[
TextFormField( //
decoration: InputDecoration(labelText: '课程*'), //
onSaved: (value) => course = value ?? '', //
validator: (value) { //
if (value == null || value.isEmpty) {
return '课程名为必填项';
}
return null;
},
),
SizedBox(height: 16.0),//
TextFormField(
decoration: InputDecoration(labelText: '学分'),
onSaved: (value) => credit = value ?? '',
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '备注'),
onSaved: (value) => note = value ?? '',
),
SizedBox(height: 16.0),
MultiSelectDialogField<String>(
items: daysList,
title: Text('上课日*'),
validator: (values) {
if (values == null || values.isEmpty) {
return '上课日为必填项';
}
return null;
},
onConfirm: (values) {
setState(() {
selectedDays = values;
});
},
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '开始周'),
onSaved: (value) => startWeek = value ?? '',
validator: (value) {
if (value == null || value.isEmpty) {
return '开始周为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '结束周'),
onSaved: (value) => endWeek = value ?? '',
validator: (value) {
if (value == null || value.isEmpty) {
return '结束周为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
DropdownButtonFormField<String>(
value: startTime,
onChanged: (newValue) {
setState(() {
startTime = newValue ?? '';
});
},
items: List.generate(12, (index) => (index + 1).toString())
.map((time) => DropdownMenuItem(
value: time,
child: Text(time),
))
.toList(),
decoration: InputDecoration(labelText: '上课时间'),
validator: (value) {
if (value == null || value.isEmpty) {
return '上课时间为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
DropdownButtonFormField<String>(
value: endTime,
onChanged: (newValue) {
setState(() {
endTime = newValue ?? '';
});
},
items: List.generate(12, (index) => (index + 1).toString())
.map((time) => DropdownMenuItem(
value: time,
child: Text(time),
))
.toList(),
decoration: InputDecoration(labelText: '下课时间*'),
validator: (value) {
if (value == null || value.isEmpty) {
return '下课时间为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '老师'),
onSaved: (value) => teacher = value ?? '',
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '地点'),
onSaved: (value) => location = value ?? '',
),
SizedBox(height: 24.0),
Row( //
mainAxisAlignment: MainAxisAlignment.spaceAround, //
children: <Widget>[
ElevatedButton(
onPressed: () {
//
Navigator.pop(context); //
},
child: Text('取消'),
),
ElevatedButton(
onPressed: () {
//
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
//
courseForm.course = course;
courseForm.credit = double.parse(credit);
courseForm.note = note;
courseForm.location = location;
courseForm.selectedDays = selectedDays.map((e) => weekdayMap[e]!).toList();
courseForm.startWeek = int.parse(startWeek);
courseForm.endWeek = int.parse(endWeek);
courseForm.startTime = int.parse(startTime);
courseForm.endTime = int.parse(endTime);
courseForm.teacher = teacher;
courseController.addCourseForm(courseForm).then((value) => Navigator.pop(context)); //
}
},
child: Text('确定'),
),
],
),
],
),
),
),
);
}
import 'package:flutter/material.dart';
import 'package:multi_select_flutter/dialog/multi_select_dialog_field.dart';
import 'package:multi_select_flutter/util/multi_select_item.dart';
import 'package:timemanagerapp/controller/CourseController.dart';
import 'package:timemanagerapp/entity/CourseForm.dart';
class AddScheduleFormWidget extends StatefulWidget {
const AddScheduleFormWidget({Key? key}) : super(key: key);
@override
_AddScheduleFormWidgetState createState() => _AddScheduleFormWidgetState();
}
class _AddScheduleFormWidgetState extends State<AddScheduleFormWidget> {
CourseController courseController = CourseController();
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
CourseForm courseForm = CourseForm();
String course = '';
String credit = '';
String note = '';
String startWeek = '1';
String endWeek = '12';
String startTime = '1';
String endTime = '2';
String teacher = '';
String location = '';
List<String> selectedDays = [];
List<MultiSelectItem<String>> daysList = [
MultiSelectItem('周一', ''),
MultiSelectItem('周二', ''),
MultiSelectItem('周三', ''),
MultiSelectItem('周四', ''),
MultiSelectItem('周五', ''),
MultiSelectItem('周六', ''),
MultiSelectItem('周日', ''),
];
final weekdayMap = {
'周一': 1,
'周二': 2,
'周三': 3,
'周四': 4,
'周五': 5,
'周六': 6,
'周日': 7,
};
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Padding( //
padding: const EdgeInsets.all(16.0), // 16
child: Form( //
key: _formKey, // globalKeyFormState
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, //
children: <Widget>[
TextFormField( //
decoration: InputDecoration(labelText: '课程*'), //
onSaved: (value) => course = value ?? '', //
validator: (value) { //
if (value == null || value.isEmpty) {
return '课程名为必填项';
}
return null;
},
),
SizedBox(height: 16.0),//
TextFormField(
decoration: InputDecoration(labelText: '学分'),
onSaved: (value) => credit = value ?? '',
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '备注'),
onSaved: (value) => note = value ?? '',
),
SizedBox(height: 16.0),
MultiSelectDialogField<String>(
items: daysList,
title: Text('上课日*'),
validator: (values) {
if (values == null || values.isEmpty) {
return '上课日为必填项';
}
return null;
},
onConfirm: (values) {
setState(() {
selectedDays = values;
});
},
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '开始周'),
onSaved: (value) => startWeek = value ?? '',
validator: (value) {
if (value == null || value.isEmpty) {
return '开始周为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '结束周'),
onSaved: (value) => endWeek = value ?? '',
validator: (value) {
if (value == null || value.isEmpty) {
return '结束周为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
DropdownButtonFormField<String>(
value: startTime,
onChanged: (newValue) {
setState(() {
startTime = newValue ?? '';
});
},
items: List.generate(12, (index) => (index + 1).toString())
.map((time) => DropdownMenuItem(
value: time,
child: Text(time),
))
.toList(),
decoration: InputDecoration(labelText: '上课时间'),
validator: (value) {
if (value == null || value.isEmpty) {
return '上课时间为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
DropdownButtonFormField<String>(
value: endTime,
onChanged: (newValue) {
setState(() {
endTime = newValue ?? '';
});
},
items: List.generate(12, (index) => (index + 1).toString())
.map((time) => DropdownMenuItem(
value: time,
child: Text(time),
))
.toList(),
decoration: InputDecoration(labelText: '下课时间*'),
validator: (value) {
if (value == null || value.isEmpty) {
return '下课时间为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '老师'),
onSaved: (value) => teacher = value ?? '',
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '地点'),
onSaved: (value) => location = value ?? '',
),
SizedBox(height: 24.0),
Row( //
mainAxisAlignment: MainAxisAlignment.spaceAround, //
children: <Widget>[
ElevatedButton(
onPressed: () {
//
Navigator.pop(context); //
},
child: Text('取消'),
),
ElevatedButton(
onPressed: () {
//
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
//
courseForm.course = course;
courseForm.credit = double.parse(credit);
courseForm.note = note;
courseForm.location = location;
courseForm.selectedDays = selectedDays.map((e) => weekdayMap[e]!).toList();
courseForm.startWeek = int.parse(startWeek);
courseForm.endWeek = int.parse(endWeek);
courseForm.startTime = int.parse(startTime);
courseForm.endTime = int.parse(endTime);
courseForm.teacher = teacher;
courseController.addCourseForm(courseForm).then((value) => Navigator.pop(context)); //
}
},
child: Text('确定'),
),
],
),
],
),
),
),
);
}
}

@ -0,0 +1,86 @@
import 'package:flutter/material.dart';
class AddScheduleWidget extends StatefulWidget {
const AddScheduleWidget({Key? key}) : super(key: key);
@override
_TeamTasksWidgetState createState() => _TeamTasksWidgetState();
}
class _TeamTasksWidgetState extends State<AddScheduleWidget> {
List<String> tasks = []; //
void addTask(String task) {
setState(() {
tasks.add(task);
});
}
void removeTask(int index) {
setState(() {
tasks.removeAt(index);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('团队任务'),
actions: [
IconButton(
icon: Icon(Icons.add), //
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('添加任务'),
content: TextField(
onChanged: (value) {
//
},
decoration: InputDecoration(
hintText: '输入任务名称',
),
),
actions: [
TextButton(
child: Text('取消'),
onPressed: () {
Navigator.of(context).pop();
},
),
TextButton(
child: Text('添加'),
onPressed: () {
String task = ''; //
addTask(task);
Navigator.of(context).pop();
},
),
],
);
},
);
},
),
],
),
body: ListView.builder(
itemCount: tasks.length,
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text(tasks[index]),
trailing: TextButton(
child: Text('删除'),
onPressed: () {
removeTask(index);
},
),
);
},
),
);
}
}

@ -0,0 +1,45 @@
import 'package:flutter/material.dart';
class AddTeamWidget extends StatelessWidget {
TextEditingController teamNameController = TextEditingController();
TextEditingController teamDescriptionController = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Add Team'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
TextField(
controller: teamNameController,
decoration: InputDecoration(
labelText: 'Team Name',
),
),
SizedBox(height: 10),
TextField(
controller: teamDescriptionController,
decoration: InputDecoration(
labelText: 'Team Description',
),
),
SizedBox(height: 20),
ElevatedButton(
onPressed: () {
String teamName = teamNameController.text;
String teamDescription = teamDescriptionController.text;
Navigator.pop(context,
{'name': teamName, 'description': teamDescription});
},
child: Text('Create Team'),
),
],
),
),
);
}
}

@ -1,211 +1,260 @@
import 'package:flutter/material.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/ruters/AddScheduleRoute.dart';
import 'package:timemanagerapp/ruters/TestRoute.dart';
import 'package:timemanagerapp/tests/TestWidget.dart';
import 'package:timemanagerapp/wighets/TimetableWighet.dart';
import '../ruters/AddCourseRoute.dart';
import '../ruters/TimetableRoute.dart';
import '../ruters/UserSettingRoute.dart';
class HomeWidget extends StatefulWidget {
const HomeWidget({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
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 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 AddScheduleRoute(); //
},
),
);
},
child: Text('添加任务'),
),
const SizedBox(height: 10),
],
),
);
},
);
},
),
IconButton(
//todo 使
icon: const Icon(Icons.more),
onPressed: () {},
),
IconButton(
icon: const Icon(Icons.group_add),
onPressed: () {
//
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
//todo
return Container();
},
),
);
},
),
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(
//todo ,,
accountName: Text('Username'),
accountEmail: Text('user@example.com'),
),
ListTile(
title: Text('用户设置'),
onTap: () {
//todo
// deng
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return UserSettingRoute();
},
),
);
},
),
ListTile(
title: Text('登录'),
onTap: () {
//todo
// UserSettingWight
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return UserSettingRoute();
},
),
);
},
),
ListTile(
title: Text('退出登录'),
onTap: () {
//todo action
},
),
ListTile(
title: Text('开发者测试'),
onTap: () {
// TestWidget
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return TestRoute();
},
),
);
},
),
],
),
),
body: TimetableWidget(),
);
}
}
import 'package:flutter/material.dart';
import 'package:timemanagerapp/controller/CourseController.dart';
import 'package:timemanagerapp/controller/UserController.dart';
import 'package:timemanagerapp/database/MyDatebase.dart';
import 'package:timemanagerapp/ruters/AddScheduleRoute.dart';
import 'package:timemanagerapp/ruters/TestRoute.dart';
import 'package:timemanagerapp/widgets/LoginWidget.dart';
import 'package:timemanagerapp/widgets/RegisterWidget.dart';
import 'package:timemanagerapp/widgets/TeamWidgt.dart';
import 'package:timemanagerapp/widgets/TimetableWidget.dart';
import '../ruters/AddCourseRoute.dart';
import '../ruters/UserSettingRoute.dart';
class HomeWidget extends StatefulWidget {
const HomeWidget({Key? key}) : super(key: key);
@override
_HomeWidgetState createState() => _HomeWidgetState();
}
class _HomeWidgetState extends State<HomeWidget> {
GlobalKey<TimetableWidgetState> timetableWidgetKey = GlobalKey(); //key
late UserController userController;
late CourseController courseController;
bool isLoggedIn = false; //
@override
void initState() {
super.initState();
MyDatabase.initDatabase();
userController = UserController.getInstance();
courseController = CourseController.getInstance();
}
void handleAddCourse() {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return AddCourseRoute(onCourseAdded: () {
setState(() {
//
// timetableWidgetKey.currentState?.updateWhenDataChange();
});
});
},
),
);
}
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 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(onCourseAdded: () {
setState(() {
//
// timetableWidgetKey.currentState?.updateWhenDataChange();
});
});
},
),
);
},
child: Text('添加课程'),
),
ElevatedButton(
onPressed: () {
// AddCourseFormWidget
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
//todo
return AddScheduleRoute(); //
},
),
);
},
child: Text('添加任务'),
),
const SizedBox(height: 10),
],
),
);
},
);
},
),
IconButton(
//todo 使
icon: const Icon(Icons.more),
onPressed: () {},
),
IconButton(
icon: const Icon(Icons.group_add),
onPressed: () {
//
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
//todo
return TeamWidget(
teamName: 'Team Name', //
teamMembers: const ['Member 1', 'Member 2'], //
);
},
),
);
},
),
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: GestureDetector(
onTap: () {
if (!isLoggedIn) {
//
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return LoginWidget(); //
},
),
);
}
},
child: isLoggedIn ? Text('已登录用户名') : Text('未登录'),
),
accountEmail: GestureDetector(
onTap: () {
if (!isLoggedIn) {
//
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return LoginWidget(); //
},
),
);
}
},
child: isLoggedIn
? Text('user@example.com')
: SizedBox(), //
),
currentAccountPicture: CircleAvatar(
backgroundImage: AssetImage(
'assets/images/profile_picture.png'), //
),
),
ListTile(
title: Text('用户设置'),
onTap: () {
//todo
// deng
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return UserSettingRoute();
},
),
);
},
),
ListTile(
title: Text('注册'),
onTap: () {
//todo
// UserSettingWight
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return RegisterWidget();
},
),
);
},
),
ListTile(
title: Text('退出登录'),
onTap: () {
//todo action
},
),
ListTile(
title: Text('开发者测试'),
onTap: () {
// TestWidget
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return TestRoute();
},
),
);
},
),
],
),
),
body: TimetableWidget(),
);
}
}

@ -1,42 +1,42 @@
import 'package:flutter/material.dart';
class LoginWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('登录'),
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextFormField(
decoration: InputDecoration(
labelText: '用户名',
),
),
SizedBox(height: 16.0),
TextFormField(
obscureText: true, //
decoration: InputDecoration(
labelText: '密码',
),
),
SizedBox(height: 24.0),
ElevatedButton(
onPressed: () {
//
//
},
child: Text('登录'),
),
],
),
),
),
);
}
}
import 'package:flutter/material.dart';
class LoginWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('登录'),
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextFormField(
decoration: InputDecoration(
labelText: '用户名',
),
),
SizedBox(height: 16.0),
TextFormField(
obscureText: true, //
decoration: InputDecoration(
labelText: '密码',
),
),
SizedBox(height: 24.0),
ElevatedButton(
onPressed: () {
//
//
},
child: Text('登录'),
),
],
),
),
),
);
}
}

@ -0,0 +1,61 @@
import 'package:flutter/material.dart';
class ManageUserTeamWidget extends StatefulWidget {
const ManageUserTeamWidget({Key? key}) : super(key: key);
@override
_AddTeamWidgetState createState() => _AddTeamWidgetState();
}
class _AddTeamWidgetState extends State<ManageUserTeamWidget> {
TextEditingController memberIdController = TextEditingController();
void handleInviteButton() {
String memberId = memberIdController.text;
//
//
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('成功发送邀请'),
content: Text('已成功发送邀请给成员ID: $memberId'),
actions: [
TextButton(
child: Text('确定'),
onPressed: () {
Navigator.of(context).pop(); //
},
),
],
);
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('添加团队成员'),
),
body: Padding(
padding: EdgeInsets.all(16.0),
child: Column(
children: [
TextField(
controller: memberIdController,
decoration: InputDecoration(labelText: '成员ID'),
),
SizedBox(height: 20),
ElevatedButton(
onPressed: handleInviteButton,
child: Text('邀请'),
),
],
),
),
);
}
}

@ -1,49 +1,49 @@
import 'package:flutter/material.dart';
class RegisterWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('注册'),
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextFormField(
decoration: InputDecoration(
labelText: '用户名',
),
),
SizedBox(height: 16.0),
TextFormField(
obscureText: true, //
decoration: InputDecoration(
labelText: '密码',
),
),
SizedBox(height: 16.0),
TextFormField(
obscureText: true, //
decoration: InputDecoration(
labelText: '确认密码',
),
),
SizedBox(height: 24.0),
ElevatedButton(
onPressed: () {
//
//
},
child: Text('注册'),
),
],
),
),
),
);
}
}
import 'package:flutter/material.dart';
class RegisterWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('注册'),
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextFormField(
decoration: InputDecoration(
labelText: '用户名',
),
),
SizedBox(height: 16.0),
TextFormField(
obscureText: true, //
decoration: InputDecoration(
labelText: '密码',
),
),
SizedBox(height: 16.0),
TextFormField(
obscureText: true, //
decoration: InputDecoration(
labelText: '确认密码',
),
),
SizedBox(height: 24.0),
ElevatedButton(
onPressed: () {
//
//
},
child: Text('注册'),
),
],
),
),
),
);
}
}

@ -0,0 +1,26 @@
// ignore_for_file: must_be_immutable
import 'package:flutter/material.dart';
/// @desc 线
/// @author xiedong
/// @date 2020-02-24.
class SpaceWidget extends StatelessWidget {
double height, width;
SpaceWidget({
super.key,
this.height = 1,
this.width = 1,
});
@override
Widget build(BuildContext context) {
return Container(
height: height,
width: width,
color: Colors.transparent,
);
}
}

@ -0,0 +1,88 @@
import 'package:flutter/material.dart';
import 'package:timemanagerapp/widgets/AddScheduleWidget.dart';
import 'package:timemanagerapp/widgets/AddTeamWidget.dart';
import 'package:flutter/material.dart';
import 'package:timemanagerapp/widgets/AddScheduleWidget.dart';
import 'package:timemanagerapp/widgets/AddTeamWidget.dart';
import 'package:timemanagerapp/widgets/ManageUserTeamWidget.dart';
class TeamWidget extends StatelessWidget {
final String teamName;
final List<String> teamMembers;
const TeamWidget({
Key? key, //
required this.teamName,
required this.teamMembers,
});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('团队详情'),
),
body: Column(
children: [
ListTile(
leading: Icon(Icons.group), // icon
title: Text(teamName), //
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: Icon(Icons.person_add), //
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return ManageUserTeamWidget();
},
),
);
},
),
IconButton(
icon: Icon(Icons.assignment), //
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return AddScheduleWidget();
},
),
);
},
),
],
),
),
],
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
Map<String, String> teamInfo = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return AddTeamWidget();
},
),
);
if (teamInfo != null && teamInfo.isNotEmpty) {
String? newTeamName = teamInfo['name'];
String? newTeamDescription = teamInfo['description'];
// Implement logic to add the new team using newTeamName and newTeamDescription
} else {
// Handle the case when teamInfo is null or empty, for example, show an error message.
// You can display a snackbar, showDialog, or any other appropriate UI element.
}
},
child: Icon(Icons.add),
),
);
}
}

@ -0,0 +1,244 @@
// ignore_for_file: unused_import
/*
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';
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 '../ruters/TimetableRoute.dart';
class TestWidget extends StatefulWidget {
const TestWidget({Key? key}) : super(key: key);
@override
_TestWidgetState createState() => _TestWidgetState();
}
class _TestWidgetState extends State<TestWidget> {
late UserController userController;
late CourseController courseController;
@override
void initState() {
super.initState();
MyDatabase.initDatabase();
userController = UserController.getInstance();
courseController = CourseController.getInstance();
}
@override
Widget build(BuildContext context) {
return Center(
child: SingleChildScrollView(
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(
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(),
),
),
);
},
);
});
},
child: Text('显示用户列表'),
),
ElevatedButton(
onPressed: courseController.deleteAllCourses,
child: Text('删除所有课程'),
),
// ElevatedButton(
// onPressed: () => courseController.autoImportCours(jsonstr),
// child: Text('导入课程(待开发)'),
// ),
ElevatedButton(
onPressed: () => 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)))),
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(),
),
),
);
},
);
});
},
child: Text('显示课程列表'),
),
ElevatedButton(
onPressed: () {
// AddCourseFormWidget
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return TimetableRoute();
},
),
);
},
child: Text('查看时间表'),
),
AddCourseButton(onCourseAdded: (jsonstr) {
// addCourse()
courseController.test_autoImportCours(jsonstr);
}),
// ElevatedButton(
// onPressed: () {
// // AddCourseFormWidget
// //
// showDialog(
// context: context,
// builder: (context) async {
// return AlertDialog(
// title: Text('数据库ID 生成器测试'),
// content: Text((await IdGenerator().generateId()).toString())
//
// },
// child: Text('数据库ID 生成器测试'),
// ),
],
),
),
);
}
}
//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('确定'),
onPressed: () {
final jsonstr = _jsonstrController.text;
if (jsonstr.isNotEmpty) {
widget.onCourseAdded(jsonstr);
Navigator.of(context).pop();
}
},
),
],
);
},
);
}
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {
_showAddCourseDialog(context);
},
child: Text('json导入课程'),
);
}
@override
void dispose() {
_jsonstrController.dispose();
super.dispose();
}
}

@ -1,389 +1,390 @@
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:timemanagerapp/controller/CourseController.dart';
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(deviceWidth: deviceWidth);
}
class PageState extends State<TimetableWidget> {
late double deviceWidth;
//
late CourseWidgetController courseWidgetController = CourseWidgetController();
late CourseController courseController = CourseController.getInstance();
//
var weekList = ['', '', '', '', '', '', ''];
//
List<Course> courseList = [];
Map<int, List<Course>> courseWeekMap = {};
//
var dateListstr = [];
//
var currentWeekDayIndex = 0;
//
int weekCount = 0;
int currentWeek = 0;
String weekCountstr = '第1周';
final double hourHeight = 60.0 * 1.5;
//DateTimePiexl
List<DateTime> timePoints = [
DateTime(2023, 9, 22, 7, 30),
DateTime(2023, 9, 22, 8, 0), // 8:00 AM
DateTime(2023, 9, 22, 9, 35), // 8:15 PM
DateTime(2023, 9, 22, 10, 5),
DateTime(2023, 9, 22, 11, 40),
DateTime(2023, 9, 22, 13, 30),
DateTime(2023, 9, 22, 15, 5), // 8:00 AM
DateTime(2023, 9, 22, 15, 35), // 12:30 PM
DateTime(2023, 9, 22, 17, 10),
DateTime(2023, 9, 22, 18, 30),
DateTime(2023, 9, 22, 19, 15), // 8:00 AM
DateTime(2023, 9, 22, 20, 5), // 12:30 PM
DateTime(2023, 9, 22, 20, 55),
];
//Offset
var positions = [];
bool loading = true;
PageState({required this.deviceWidth});
updateDateByWeekCount() {
var mondayTime = courseWidgetController.getmondayTime();
//
for (int i = 0; i < 7; i++) {
dateListstr[i] = mondayTime
.add(Duration(days: i + 7 * (weekCount - currentWeek)))
.day
.toString();
}
}
//
@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);
//
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());
//
positions =
courseWidgetController.convertTimeList(timePoints, deviceWidth);
setState(() {
loading = false;
});
});
}
@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'),
),
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:
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() +
50,
child: SingleChildScrollView(
child: Container(
//
width: deviceWidth * 0.16,
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('加载中'),
);
}
}
// ignore_for_file: unused_import, unnecessary_import
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:timemanagerapp/controller/CourseController.dart';
import 'package:timemanagerapp/controller/CourseWidgetController.dart';
import '../entity/Course.dart';
import '../setting/Setting.dart';
class TimetableWidget extends StatefulWidget {
final double deviceWidth = Setting.deviceWidth;
@override
State<StatefulWidget> createState() =>
TimetableWidgetState(deviceWidth: deviceWidth);
}
class TimetableWidgetState extends State<TimetableWidget> {
late double deviceWidth;
//
late CourseWidgetController courseWidgetController = CourseWidgetController();
late CourseController courseController = CourseController.getInstance();
//
var weekList = ['', '', '', '', '', '', ''];
//
List<Course> courseList = [];
Map<int, List<Course>> courseWeekMap = {};
//
var dateListstr = [];
//
var currentWeekDayIndex = 0;
//
int weekCount = 0;
int currentWeek = 0;
String weekCountstr = '第1周';
final double hourHeight = 60.0 * 1.5;
//DateTimePiexl
List<DateTime> timePoints = [
DateTime(2023, 9, 22, 7, 30),
DateTime(2023, 9, 22, 8, 0), // 8:00 AM
DateTime(2023, 9, 22, 9, 35), // 8:15 PM
DateTime(2023, 9, 22, 10, 5),
DateTime(2023, 9, 22, 11, 40),
DateTime(2023, 9, 22, 13, 30),
DateTime(2023, 9, 22, 15, 5), // 8:00 AM
DateTime(2023, 9, 22, 15, 35), // 12:30 PM
DateTime(2023, 9, 22, 17, 10),
DateTime(2023, 9, 22, 18, 30),
DateTime(2023, 9, 22, 19, 15), // 8:00 AM
DateTime(2023, 9, 22, 20, 5), // 12:30 PM
DateTime(2023, 9, 22, 20, 55),
];
//Offset
var positions = [];
bool loading = true;
TimetableWidgetState({required this.deviceWidth});
updateDateByWeekCount() {
var mondayTime = courseWidgetController.getmondayTime();
//
for (int i = 0; i < 7; i++) {
dateListstr[i] = mondayTime
.add(Duration(days: i + 7 * (weekCount - currentWeek)))
.day
.toString();
}
}
//
@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);
//
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());
//
positions =
courseWidgetController.convertTimeList(timePoints, deviceWidth);
setState(() {
loading = false;
});
});
}
@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,
),
),
),
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('加载中'),
);
}
}

@ -1,17 +1,17 @@
//Wight
import 'package:flutter/cupertino.dart';
class UserSettingWight extends StatefulWidget {
@override
_UserSettingWightState createState() => _UserSettingWightState();
}
//Wight
//todo:Wight
class _UserSettingWightState extends State<UserSettingWight> {
@override
Widget build(BuildContext context) {
return Container(
);
}
//Wight
import 'package:flutter/cupertino.dart';
class UserSettingWidgt extends StatefulWidget {
@override
_UserSettingWightState createState() => _UserSettingWightState();
}
//Wight
//todo:Wight
class _UserSettingWightState extends State<UserSettingWidgt> {
@override
Widget build(BuildContext context) {
return Container(
);
}
}

@ -1,27 +0,0 @@
import 'package:flutter/material.dart';
/**
* @desc 线
* @author xiedong
* @date 2020-02-24.
*/
class SpaceWidget extends StatelessWidget {
double height, width;
SpaceWidget({
this.height = 1,
this.width = 1,
}) : super();
@override
Widget build(BuildContext context) {
return
Container(
height: height,
width: width,
color: Colors.transparent,
);
}
}

@ -1,247 +0,0 @@
/*
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';
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/wighets/TimetableWighet.dart';
import '../main.dart';
import '../ruters/AddCourseRoute.dart';
import '../ruters/TimetableRoute.dart';
import '../tests/database_test.dart';
import 'AddCourseFormWidget.dart';
class TestWidget extends StatefulWidget {
const TestWidget({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<TestWidget> {
late UserController userController;
late CourseController courseController;
@override
void initState() {
super.initState();
MyDatabase.initDatabase();
userController = UserController.getInstance();
courseController = CourseController.getInstance();
}
@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(
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(),
),
),
);
},
);
});
},
child: Text('显示用户列表'),
),
ElevatedButton(
onPressed: courseController.deleteAllCourses,
child: Text('删除所有课程'),
),
// ElevatedButton(
// onPressed: () => courseController.autoImportCours(jsonstr),
// child: Text('导入课程(待开发)'),
// ),
ElevatedButton(
onPressed: () => 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)))),
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(),
),
),
);
},
);
});
},
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('确定'),
onPressed: () {
final jsonstr = _jsonstrController.text;
if (jsonstr.isNotEmpty) {
widget.onCourseAdded(jsonstr);
Navigator.of(context).pop();
}
},
),
],
);
},
);
}
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {
_showAddCourseDialog(context);
},
child: Text('json导入课程'),
);
}
@override
void dispose() {
_jsonstrController.dispose();
super.dispose();
}
}
Loading…
Cancel
Save