diff --git a/src/timemanagerapp/.gitignore b/src/timemanagerapp/.gitignore new file mode 100644 index 0000000..24476c5 --- /dev/null +++ b/src/timemanagerapp/.gitignore @@ -0,0 +1,44 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/src/timemanagerapp/.metadata b/src/timemanagerapp/.metadata new file mode 100644 index 0000000..620e877 --- /dev/null +++ b/src/timemanagerapp/.metadata @@ -0,0 +1,45 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a + base_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a + - platform: android + create_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a + base_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a + - platform: ios + create_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a + base_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a + - platform: linux + create_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a + base_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a + - platform: macos + create_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a + base_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a + - platform: web + create_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a + base_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a + - platform: windows + create_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a + base_revision: ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/src/timemanagerapp/README.md b/src/timemanagerapp/README.md new file mode 100644 index 0000000..0a0c87c --- /dev/null +++ b/src/timemanagerapp/README.md @@ -0,0 +1,16 @@ +# timemanagerapp + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/src/timemanagerapp/analysis_options.yaml b/src/timemanagerapp/analysis_options.yaml new file mode 100644 index 0000000..2a49e61 --- /dev/null +++ b/src/timemanagerapp/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + prefer_const_constructors: false + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/src/timemanagerapp/android/.gitignore b/src/timemanagerapp/android/.gitignore new file mode 100644 index 0000000..6f56801 --- /dev/null +++ b/src/timemanagerapp/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/src/timemanagerapp/android/app/build.gradle b/src/timemanagerapp/android/app/build.gradle new file mode 100644 index 0000000..d6f4833 --- /dev/null +++ b/src/timemanagerapp/android/app/build.gradle @@ -0,0 +1,57 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +android { + namespace "com.example.timemanagerapp" + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.example.timemanagerapp" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} diff --git a/src/timemanagerapp/android/app/src/debug/AndroidManifest.xml b/src/timemanagerapp/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/src/timemanagerapp/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/src/timemanagerapp/android/app/src/main/AndroidManifest.xml b/src/timemanagerapp/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..f6f59e2 --- /dev/null +++ b/src/timemanagerapp/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/src/timemanagerapp/android/app/src/main/java/com/example/timemanagerapp/MainActivity.java b/src/timemanagerapp/android/app/src/main/java/com/example/timemanagerapp/MainActivity.java new file mode 100644 index 0000000..95ba7af --- /dev/null +++ b/src/timemanagerapp/android/app/src/main/java/com/example/timemanagerapp/MainActivity.java @@ -0,0 +1,6 @@ +package com.example.timemanagerapp; + +import io.flutter.embedding.android.FlutterActivity; + +public class MainActivity extends FlutterActivity { +} diff --git a/src/timemanagerapp/android/app/src/main/res/drawable-v21/launch_background.xml b/src/timemanagerapp/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/src/timemanagerapp/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/src/timemanagerapp/android/app/src/main/res/drawable/launch_background.xml b/src/timemanagerapp/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/src/timemanagerapp/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/src/timemanagerapp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/src/timemanagerapp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..db77bb4 Binary files /dev/null and b/src/timemanagerapp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/timemanagerapp/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/src/timemanagerapp/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..17987b7 Binary files /dev/null and b/src/timemanagerapp/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/timemanagerapp/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/src/timemanagerapp/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..09d4391 Binary files /dev/null and b/src/timemanagerapp/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/timemanagerapp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/src/timemanagerapp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..d5f1c8d Binary files /dev/null and b/src/timemanagerapp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/timemanagerapp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/src/timemanagerapp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..4d6372e Binary files /dev/null and b/src/timemanagerapp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/timemanagerapp/android/app/src/main/res/values-night/styles.xml b/src/timemanagerapp/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/src/timemanagerapp/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/src/timemanagerapp/android/app/src/main/res/values/styles.xml b/src/timemanagerapp/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..cb1ef88 --- /dev/null +++ b/src/timemanagerapp/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/src/timemanagerapp/android/app/src/profile/AndroidManifest.xml b/src/timemanagerapp/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/src/timemanagerapp/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/src/timemanagerapp/android/build.gradle b/src/timemanagerapp/android/build.gradle new file mode 100644 index 0000000..f7eb7f6 --- /dev/null +++ b/src/timemanagerapp/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.7.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.3.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/src/timemanagerapp/android/gradle.properties b/src/timemanagerapp/android/gradle.properties new file mode 100644 index 0000000..94adc3a --- /dev/null +++ b/src/timemanagerapp/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/src/timemanagerapp/android/gradle/wrapper/gradle-wrapper.properties b/src/timemanagerapp/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..3c472b9 --- /dev/null +++ b/src/timemanagerapp/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/src/timemanagerapp/android/settings.gradle b/src/timemanagerapp/android/settings.gradle new file mode 100644 index 0000000..55c4ca8 --- /dev/null +++ b/src/timemanagerapp/android/settings.gradle @@ -0,0 +1,20 @@ +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + } + settings.ext.flutterSdkPath = flutterSdkPath() + + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") + + plugins { + id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false + } +} + +include ":app" + +apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/src/新建文本文档.txt b/src/timemanagerapp/assets/data/新建文本文档.txt similarity index 100% rename from src/新建文本文档.txt rename to src/timemanagerapp/assets/data/新建文本文档.txt diff --git a/src/timemanagerapp/assets/fonts/新建文本文档.txt b/src/timemanagerapp/assets/fonts/新建文本文档.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/timemanagerapp/assets/images/新建文本文档.txt b/src/timemanagerapp/assets/images/新建文本文档.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/timemanagerapp/assets/pythoncode/getschedule.py b/src/timemanagerapp/assets/pythoncode/getschedule.py new file mode 100644 index 0000000..80018e4 --- /dev/null +++ b/src/timemanagerapp/assets/pythoncode/getschedule.py @@ -0,0 +1,49 @@ +# 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 + +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(input(), input()) + 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(input()), int(input())) # 获取已选课程信息 +# # 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) \ No newline at end of file diff --git a/src/timemanagerapp/assets/pythoncode/main.py b/src/timemanagerapp/assets/pythoncode/main.py new file mode 100644 index 0000000..19d65ad --- /dev/null +++ b/src/timemanagerapp/assets/pythoncode/main.py @@ -0,0 +1,46 @@ +# example.py +import base64 +import os +import sys +from pprint import pprint + +from zfn_api import Client + +cookies = {} +base_url = 'http://jwgl.cauc.edu.cn' +raspisanie = [] +ignore_type = [] +detail_category_type = [] +timeout = 5 + +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("210340156", "123111@qaq") + 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(2022, 2) # 获取已选课程信息 +# # 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) \ No newline at end of file diff --git a/src/timemanagerapp/assets/pythoncode/zfn_api.py b/src/timemanagerapp/assets/pythoncode/zfn_api.py new file mode 100644 index 0000000..6dc408e --- /dev/null +++ b/src/timemanagerapp/assets/pythoncode/zfn_api.py @@ -0,0 +1,1559 @@ +import base64 +import binascii +import json +import re +import time +import traceback +import unicodedata +from urllib.parse import urljoin + +import requests +import rsa +from pyquery import PyQuery as pq +from requests import exceptions + +RASPIANIE = [ + ["8:00", "8:40"], + ["8:45", "9:25"], + ["9:30", "10:10"], + ["10:30", "11:10"], + ["11:15", "11:55"], + ["14:30", "15:10"], + ["15:15", "15:55"], + ["16:05", "16:45"], + ["16:50", "17:30"], + ["18:40", "19:20"], + ["19:25", "20:05"], + ["20:10", "20:50"], + ["20:55", "21:35"], +] + + +class Client: + raspisanie = [] + ignore_type = [] + + def __init__(self, cookies={}, **kwargs): + # 基础配置 + self.base_url = kwargs.get("base_url") + self.raspisanie = kwargs.get("raspisanie", RASPIANIE) + self.ignore_type = kwargs.get("ignore_type", []) + self.detail_category_type = kwargs.get("detail_category_type", []) + self.timeout = kwargs.get("timeout", 3) + Client.raspisanie = self.raspisanie + Client.ignore_type = self.ignore_type + + self.key_url = urljoin(self.base_url, "xtgl/login_getPublicKey.html") + self.login_url = urljoin(self.base_url, "xtgl/login_slogin.html") + self.kaptcha_url = urljoin(self.base_url, "kaptcha") + self.headers = requests.utils.default_headers() + self.headers["Referer"] = self.login_url + self.headers[ + "User-Agent" + ] = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36" + self.headers[ + "Accept" + ] = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3" + self.sess = requests.Session() + self.sess.keep_alive = False + self.cookies = cookies + + def login(self, sid, password): + """登录教务系统""" + need_verify = False + try: + # 登录页 + req_csrf = self.sess.get( + self.login_url, headers=self.headers, timeout=self.timeout + ) + if req_csrf.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + # 获取csrf_token + doc = pq(req_csrf.text) + csrf_token = doc("#csrftoken").attr("value") + pre_cookies = self.sess.cookies.get_dict() + # 获取publicKey并加密密码 + req_pubkey = self.sess.get( + self.key_url, headers=self.headers, timeout=self.timeout + ).json() + modulus = req_pubkey["modulus"] + exponent = req_pubkey["exponent"] + if str(doc("input#yzm")) == "": + # 不需要验证码 + encrypt_password = self.encrypt_password(password, modulus, exponent) + # 登录数据 + login_data = { + "csrftoken": csrf_token, + "yhm": sid, + "mm": encrypt_password, + } + # 请求登录 + req_login = self.sess.post( + self.login_url, + headers=self.headers, + data=login_data, + timeout=self.timeout, + ) + doc = pq(req_login.text) + tips = doc("p#tips") + if str(tips) != "": + if "用户名或密码" in tips.text(): + return {"code": 1002, "msg": "用户名或密码不正确"} + return {"code": 998, "msg": tips.text()} + self.cookies = self.sess.cookies.get_dict() + return {"code": 1000, "msg": "登录成功", "data": {"cookies": self.cookies}} + # 需要验证码,返回相关页面验证信息给用户,TODO: 增加更多验证方式 + need_verify = True + req_kaptcha = self.sess.get( + self.kaptcha_url, headers=self.headers, timeout=self.timeout + ) + kaptcha_pic = base64.b64encode(req_kaptcha.content).decode() + return { + "code": 1001, + "msg": "获取验证码成功", + "data": { + "sid": sid, + "csrf_token": csrf_token, + "cookies": pre_cookies, + "password": password, + "modulus": modulus, + "exponent": exponent, + "kaptcha_pic": kaptcha_pic, + "timestamp": time.time(), + }, + } + except exceptions.Timeout: + msg = "获取验证码超时" if need_verify else "登录超时" + return {"code": 1003, "msg": msg} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + msg = "获取验证码时未记录的错误" if need_verify else "登录时未记录的错误" + return {"code": 999, "msg": f"{msg}:{str(e)}"} + + def login_with_kaptcha( + self, sid, csrf_token, cookies, password, modulus, exponent, kaptcha, **kwargs + ): + """需要验证码的登陆""" + try: + encrypt_password = self.encrypt_password(password, modulus, exponent) + login_data = { + "csrftoken": csrf_token, + "yhm": sid, + "mm": encrypt_password, + "yzm": kaptcha, + } + req_login = self.sess.post( + self.login_url, + headers=self.headers, + cookies=cookies, + data=login_data, + timeout=self.timeout, + ) + if req_login.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + # 请求登录 + doc = pq(req_login.text) + tips = doc("p#tips") + if str(tips) != "": + if "验证码" in tips.text(): + return {"code": 1004, "msg": "验证码输入错误"} + if "用户名或密码" in tips.text(): + return {"code": 1002, "msg": "用户名或密码不正确"} + return {"code": 998, "msg": tips.text()} + self.cookies = self.sess.cookies.get_dict() + # 不同学校系统兼容差异 + if not self.cookies.get("route"): + route_cookies = { + "JSESSIONID": self.cookies["JSESSIONID"], + "route": cookies["route"], + } + self.cookies = route_cookies + else: + return {"code": 1000, "msg": "登录成功", "data": {"cookies": self.cookies}} + except exceptions.Timeout: + return {"code": 1003, "msg": "登录超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "验证码登录时未记录的错误:" + str(e)} + + def get_info(self): + """获取个人信息""" + url = urljoin(self.base_url, "xsxxxggl/xsxxwh_cxCkDgxsxx.html?gnmkdm=N100801") + try: + req_info = self.sess.get( + url, + headers=self.headers, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_info.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_info.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + info = req_info.json() + if info is None: + return self._get_info() + result = { + "sid": info.get("xh"), + "name": info.get("xm"), + "college_name": info.get("zsjg_id", info.get("jg_id")), + "major_name": info.get("zszyh_id", info.get("zyh_id")), + "class_name": info.get("bh_id", info.get("xjztdm")), + "status": info.get("xjztdm"), + "enrollment_date": info.get("rxrq"), + "candidate_number": info.get("ksh"), + "graduation_school": info.get("byzx"), + "domicile": info.get("jg"), + "postal_code": info.get("yzbm"), + "politics_status": info.get("zzmmm"), + "nationality": info.get("mzm"), + "education": info.get("pyccdm"), + "phone_number": info.get("sjhm"), + "parents_number": info.get("gddh"), + "email": info.get("dzyx"), + "birthday": info.get("csrq"), + "id_number": info.get("zjhm"), + } + return {"code": 1000, "msg": "获取个人信息成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取个人信息超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "获取个人信息时未记录的错误:" + str(e)} + + def _get_info(self): + """获取个人信息""" + url = urljoin(self.base_url, "xsxxxggl/xsgrxxwh_cxXsgrxx.html?gnmkdm=N100801") + try: + req_info = self.sess.get( + url, headers=self.headers, cookies=self.cookies, timeout=self.timeout + ) + if req_info.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_info.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + pending_result = {} + # 学生基本信息 + for ul_item in doc.find("div.col-sm-6").items(): + content = pq(ul_item).find("div.form-group") + # key = re.findall(r'^[\u4E00-\u9FA5A-Za-z0-9]+', pq(content).find('label.col-sm-4.control-label').text())[0] + key = pq(content).find("label.col-sm-4.control-label").text() + value = pq(content).find("div.col-sm-8 p.form-control-static").text() + # 到这一步,解析到的数据基本就是一个键值对形式的html数据了,比如"[学号:]:123456" + pending_result[key] = value + # 学生学籍信息,其他信息,联系方式 + for ul_item in doc.find("div.col-sm-4").items(): + content = pq(ul_item).find("div.form-group") + key = pq(content).find("label.col-sm-4.control-label").text() + value = pq(content).find("div.col-sm-8 p.form-control-static").text() + # 到这一步,解析到的数据基本就是一个键值对形式的html数据了,比如"[学号:]:123456" + pending_result[key] = value + if pending_result.get("学号:") == "": + return { + "code": 1014, + "msg": "当前学年学期无学生时盒数据,您可能已经毕业了。\n\n如果是专升本同学,请使用专升本后的新学号登录~", + } + result = { + "sid": pending_result["学号:"], + "name": pending_result["姓名:"], + # "birthday": "无" if pending_result.get("出生日期:") == '' else pending_result["出生日期:"], + # "id_number": "无" if pending_result.get("证件号码:") == '' else pending_result["证件号码:"], + # "candidate_number": "无" if pending_result.get("考生号:") == '' else pending_result["考生号:"], + # "status": "无" if pending_result.get("学籍状态:") == '' else pending_result["学籍状态:"], + # "entry_date": "无" if pending_result.get("入学日期:") == '' else pending_result["入学日期:"], + # "graduation_school": "无" if pending_result.get("毕业中学:") == '' else pending_result["毕业中学:"], + "domicile": "无" + if pending_result.get("籍贯:") == "" + else pending_result["籍贯:"], + "phone_number": "无" + if pending_result.get("手机号码:") == "" + else pending_result["手机号码:"], + "parents_number": "无", + "email": "无" + if pending_result.get("电子邮箱:") == "" + else pending_result["电子邮箱:"], + "political_status": "无" + if pending_result.get("政治面貌:") == "" + else pending_result["政治面貌:"], + "national": "无" + if pending_result.get("民族:") == "" + else pending_result["民族:"], + # "education": "无" if pending_result.get("培养层次:") == '' else pending_result["培养层次:"], + # "postal_code": "无" if pending_result.get("邮政编码:") == '' else pending_result["邮政编码:"], + # "grade": int(pending_result["学号:"][0:4]), + } + if pending_result.get("学院名称:") is not None: + # 如果在个人信息页面获取到了学院班级 + result.update( + { + "college_name": "无" + if pending_result.get("学院名称:") == "" + else pending_result["学院名称:"], + "major_name": "无" + if pending_result.get("专业名称:") == "" + else pending_result["专业名称:"], + "class_name": "无" + if pending_result.get("班级名称:") == "" + else pending_result["班级名称:"], + } + ) + else: + # 如果个人信息页面获取不到学院班级,则此处需要请求另外一个地址以获取学院、专业、班级等信息 + _url = urljoin( + self.base_url, + "xszbbgl/xszbbgl_cxXszbbsqIndex.html?doType=details&gnmkdm=N106005", + ) + _req_info = self.sess.post( + _url, + headers=self.headers, + cookies=self.cookies, + timeout=self.timeout, + data={"offDetails": "1", "gnmkdm": "N106005", "czdmKey": "00"}, + ) + _doc = pq(_req_info.text) + if _doc("p.error_title").text() != "无功能权限,": + # 通过学生证补办申请入口,来补全部分信息 + for ul_item in _doc.find("div.col-sm-6").items(): + content = pq(ul_item).find("div.form-group") + key = ( + pq(content).find("label.col-sm-4.control-label").text() + + ":" + ) # 为了保持格式一致,这里加个冒号 + value = ( + pq(content).find("div.col-sm-8 label.control-label").text() + ) + # 到这一步,解析到的数据基本就是一个键值对形式的html数据了,比如"[学号:]:123456" + pending_result[key] = value + result.update( + { + "college_name": "无" + if pending_result.get("学院:") is None + else pending_result["学院:"], + "major_name": "无" + if pending_result.get("专业:") is None + else pending_result["专业:"], + "class_name": "无" + if pending_result.get("班级:") is None + else pending_result["班级:"], + } + ) + return {"code": 1000, "msg": "获取个人信息成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取个人信息超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "获取个人信息时未记录的错误:" + str(e)} + + def get_grade(self, year: int, term: int = 0, use_personal_info: bool = False): + """ + 获取成绩 + use_personal_info: 是否使用获取个人信息接口获取成绩 + """ + url = urljoin( + self.base_url, + "cjcx/cjcx_cxDgXscj.html?doType=query&gnmkdm=N305005" + if use_personal_info + else "cjcx/cjcx_cxXsgrcj.html?doType=query&gnmkdm=N305005", + ) + temp_term = term + term = term**2 * 3 + term = "" if term == 0 else term + data = { + "xnm": str(year), # 学年数 + "xqm": str(term), # 学期数,第一学期为3,第二学期为12, 整个学年为空'' + "_search": "false", + "nd": int(time.time() * 1000), + "queryModel.showCount": "100", # 每页最多条数 + "queryModel.currentPage": "1", + "queryModel.sortName": "", + "queryModel.sortOrder": "asc", + "time": "0", # 查询次数 + } + try: + req_grade = self.sess.post( + url, + headers=self.headers, + data=data, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_grade.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_grade.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + grade = req_grade.json() + grade_items = grade.get("items") + if not grade_items: + return {"code": 1005, "msg": "获取内容为空"} + result = { + "sid": grade_items[0]["xh"], + "name": grade_items[0]["xm"], + "year": year, + "term": temp_term, + "count": len(grade_items), + "courses": [ + { + "course_id": i.get("kch_id"), + "title": i.get("kcmc"), + "teacher": i.get("jsxm"), + "class_name": i.get("jxbmc"), + "credit": self.align_floats(i.get("xf")), + "category": i.get("kclbmc"), + "nature": i.get("kcxzmc"), + "grade": self.parse_int(i.get("cj")), + "grade_point": self.align_floats(i.get("jd")), + "grade_nature": i.get("ksxz"), + "start_college": i.get("kkbmmc"), + "mark": i.get("kcbj"), + } + for i in grade_items + ], + } + return {"code": 1000, "msg": "获取成绩成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取成绩超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "获取成绩时未记录的错误:" + str(e)} + + def get_schedule(self, year: int, term: int): + """获取课程表信息""" + url = urljoin(self.base_url, "kbcx/xskbcx_cxXsKb.html?gnmkdm=N2151") + temp_term = term + term = term**2 * 3 + data = {"xnm": str(year), "xqm": str(term)} + try: + req_schedule = self.sess.post( + url, + headers=self.headers, + data=data, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_schedule.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_schedule.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + schedule = req_schedule.json() + if not schedule.get("kbList"): + return {"code": 1005, "msg": "获取内容为空"} + result = { + "sid": schedule["xsxx"].get("XH"), + "name": schedule["xsxx"].get("XM"), + "year": year, + "term": temp_term, + "count": len(schedule["kbList"]), + "courses": [ + { + "course_id": i.get("kch_id"), + "title": i.get("kcmc"), + "teacher": i.get("xm"), + "class_name": i.get("jxbmc"), + "credit": self.align_floats(i.get("xf")), + "weekday": self.parse_int(i.get("xqj")), + "time": self.display_course_time(i.get("jc")), + "sessions": i.get("jc"), + "list_sessions": self.list_sessions(i.get("jc")), + "weeks": i.get("zcd"), + "list_weeks": self.list_weeks(i.get("zcd")), + "evaluation_mode": i.get("khfsmc"), + "campus": i.get("xqmc"), + "place": i.get("cdmc"), + "hours_composition": i.get("kcxszc"), + "weekly_hours": self.parse_int(i.get("zhxs")), + "total_hours": self.parse_int(i.get("zxs")), + } + for i in schedule["kbList"] + ], + "extra_courses": [i.get("qtkcgs") for i in schedule.get("sjkList")], + } + result = self.split_merge_display(result) + return {"code": 1000, "msg": "获取课表成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取课表超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "获取课表时未记录的错误:" + str(e)} + + def get_academia(self): + """获取学业生涯情况""" + url_main = urljoin( + self.base_url, + "xsxy/xsxyqk_cxXsxyqkIndex.html?gnmkdm=N105515&layout=default", + ) + url_info = urljoin( + self.base_url, "xsxy/xsxyqk_cxJxzxjhxfyqKcxx.html?gnmkdm=N105515" + ) + try: + req_main = self.sess.get( + url_main, + headers=self.headers, + cookies=self.cookies, + timeout=self.timeout, + stream=True, + ) + if req_main.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc_main = pq(req_main.text) + if doc_main("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + if str(doc_main("div.alert-danger")) != "": + return {"code": 998, "msg": doc_main("div.alert-danger").text()} + sid = doc_main("form#form input#xh_id").attr("value") + display_statistics = ( + doc_main("div#alertBox").text().replace(" ", "").replace("\n", "") + ) + sid = doc_main("input#xh_id").attr("value") + statistics = self.get_academia_statistics(display_statistics) + type_statistics = self.get_academia_type_statistics(req_main.text) + details = {} + for type in type_statistics.keys(): + details[type] = self.sess.post( + url_info, + headers=self.headers, + data={"xfyqjd_id": type_statistics[type]["id"]}, + cookies=self.cookies, + timeout=self.timeout, + stream=True, + ).json() + result = { + "sid": sid, + "statistics": statistics, + "details": [ + { + "type": type, + "credits": type_statistics[type]["credits"], + "courses": [ + { + "course_id": i.get("KCH"), + "title": i.get("KCMC"), + "situation": self.parse_int(i.get("XDZT")), + "display_term": self.get_display_term( + sid, i.get("JYXDXNM"), i.get("JYXDXQMC") + ), + "credit": self.align_floats(i.get("XF")), + "category": self.get_course_category(type, i), + "nature": i.get("KCXZMC"), + "max_grade": self.parse_int(i.get("MAXCJ")), + "grade_point": self.align_floats(i.get("JD")), + } + for i in details[type] + ], + } + for type in type_statistics.keys() + if len(details[type]) > 0 + ], + } + return {"code": 1000, "msg": "获取学业情况成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取学业情况超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "获取学业情况时未记录的错误:" + str(e)} + + def get_academia_pdf(self): + """获取学业生涯(学生成绩总表)pdf""" + url_view = urljoin(self.base_url, "bysxxcx/xscjzbdy_dyXscjzbView.html") + url_window = urljoin(self.base_url, "bysxxcx/xscjzbdy_dyCjdyszxView.html") + url_policy = urljoin(self.base_url, "xtgl/bysxxcx/xscjzbdy_cxXsCount.html") + url_filetype = urljoin(self.base_url, "bysxxcx/xscjzbdy_cxGswjlx.html") + url_common = urljoin(self.base_url, "common/common_cxJwxtxx.html") + url_file = urljoin(self.base_url, "bysxxcx/xscjzbdy_dyList.html") + url_progress = urljoin(self.base_url, "xtgl/progress_cxProgressStatus.html") + data = { + "gsdygx": "10628-zw-mrgs", + "ids": "", + "bdykcxzDms": "", + "cytjkcxzDms": "", + "cytjkclbDms": "", + "cytjkcgsDms": "", + "bjgbdykcxzDms": "", + "bjgbdyxxkcxzDms": "", + "djksxmDms": "", + "cjbzmcDms": "", + "cjdySzxs": "", + "wjlx": "pdf", + } + + try: + data_view = {"time": str(round(time.time() * 1000)), "gnmkdm": "N558020"} + data_params = data_view + del data_params["time"] + # View接口 + req_view = self.sess.post( + url_view, + headers=self.headers, + data=data_view, + params=data_view, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_view.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_view.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + # Window接口 + data_window = {"xh": ""} + self.sess.post( + url_window, + headers=self.headers, + data=data_window, + params=data_params, + cookies=self.cookies, + timeout=self.timeout, + ) + # 许可接口 + data_policy = data + del data_policy["wjlx"] + self.sess.post( + url_policy, + headers=self.headers, + data=data_policy, + params=data_params, + cookies=self.cookies, + timeout=self.timeout, + ) + # 文件类型接口 + data_filetype = data_policy + self.sess.post( + url_filetype, + headers=self.headers, + data=data_filetype, + params=data_params, + cookies=self.cookies, + timeout=self.timeout, + ) + # Common接口 + self.sess.post( + url_common, + headers=self.headers, + data=data_params, + params=data_params, + cookies=self.cookies, + timeout=self.timeout, + ) + # 获取PDF文件URL + req_file = self.sess.post( + url_file, + headers=self.headers, + data=data, + params=data_params, + cookies=self.cookies, + timeout=self.timeout, + ) + doc = pq(req_file.text) + if "错误" in doc("title").text(): + error = doc("p.error_title").text() + return {"code": 998, "msg": error} + # 进度接口 + data_progress = { + "key": "score_print_processed", + "gnmkdm": "N558020", + } + self.sess.post( + url_progress, + headers=self.headers, + data=data_progress, + params=data_progress, + cookies=self.cookies, + timeout=self.timeout, + ) + # 生成PDF文件URL + pdf = ( + req_file.text.replace("#成功", "") + .replace('"', "") + .replace("/", "\\") + .replace("\\\\", "/") + ) + # 下载PDF文件 + req_pdf = self.sess.get( + urljoin(self.base_url, pdf), + headers=self.headers, + cookies=self.cookies, + timeout=self.timeout + 2, + ) + result = req_pdf.content # 二进制内容 + return {"code": 1000, "msg": "获取学生成绩总表pdf成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取成绩总表pdf超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "获取成绩总表pdf时未记录的错误:" + str(e)} + + def get_schedule_pdf(self, year: int, term: int, name: str = "导出"): + """获取课表pdf""" + url_policy = urljoin(self.base_url, "kbdy/bjkbdy_cxXnxqsfkz.html") + url_file = urljoin(self.base_url, "kbcx/xskbcx_cxXsShcPdf.html") + origin_term = term + term = term**2 * 3 + data = { + "xm": name, + "xnm": str(year), + "xqm": str(term), + "xnmc": f"{year}-{year + 1}", + "xqmmc": str(origin_term), + "jgmc": "undefined", + "xxdm": "", + "xszd.sj": "true", + "xszd.cd": "true", + "xszd.js": "true", + "xszd.jszc": "false", + "xszd.jxb": "true", + "xszd.xkbz": "true", + "xszd.kcxszc": "true", + "xszd.zhxs": "true", + "xszd.zxs": "true", + "xszd.khfs": "true", + "xszd.xf": "true", + "xszd.skfsmc": "false", + "kzlx": "dy", + } + + try: + # 许可接口 + pilicy_params = {"gnmkdm": "N2151"} + req_policy = self.sess.post( + url_policy, + headers=self.headers, + data=data, + params=pilicy_params, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_policy.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_policy.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + # 获取PDF文件URL + file_params = {"doType": "table"} + req_file = self.sess.post( + url_file, + headers=self.headers, + data=data, + params=file_params, + cookies=self.cookies, + timeout=self.timeout, + ) + doc = pq(req_file.text) + if "错误" in doc("title").text(): + error = doc("p.error_title").text() + return {"code": 998, "msg": error} + result = req_file.content # 二进制内容 + return {"code": 1000, "msg": "获取课程表pdf成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取课程表pdf超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "获取课程表pdf时未记录的错误:" + str(e)} + + def get_notifications(self): + """获取通知消息""" + url = urljoin(self.base_url, "xtgl/index_cxDbsy.html?doType=query") + data = { + "sfyy": "0", # 是否已阅,未阅未1,已阅为2 + "flag": "1", + "_search": "false", + "nd": int(time.time() * 1000), + "queryModel.showCount": "1000", # 最多条数 + "queryModel.currentPage": "1", # 当前页数 + "queryModel.sortName": "cjsj", + "queryModel.sortOrder": "desc", # 时间倒序, asc正序 + "time": "0", + } + try: + req_notification = self.sess.post( + url, + headers=self.headers, + data=data, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_notification.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_notification.text) + if doc("h5").text() == "用户登录" or "错误" in doc("title").text(): + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + notifications = req_notification.json() + result = [ + {**self.split_notifications(i), "create_time": i.get("cjsj")} + for i in notifications.get("items") + ] + return {"code": 1000, "msg": "获取消息成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取消息超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "获取消息时未记录的错误:" + str(e)} + + def get_selected_courses(self, year: int, term: int): + """获取已选课程信息""" + try: + url = urljoin( + self.base_url, + "xsxk/zzxkyzb_cxZzxkYzbChoosedDisplay.html?gnmkdm=N253512", + ) + temp_term = term + term = term**2 * 3 + data = {"xkxnm": str(year), "xkxqm": str(term)} + req_selected = self.sess.post( + url, + data=data, + headers=self.headers, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_selected.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_selected.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + selected = req_selected.json() + result = { + "year": year, + "term": temp_term, + "count": len(selected), + "courses": [ + { + "course_id": i.get("kch"), + "class_id": i.get("jxb_id"), + "do_id": i.get("do_jxb_id"), + "title": i.get("kcmc"), + "teacher_id": (re.findall(r"(.*?\d+)/", i.get("jsxx")))[0], + "teacher": (re.findall(r"/(.*?)/", i.get("jsxx")))[0], + "credit": float(i.get("xf", 0)), + "category": i.get("kklxmc"), + "capacity": int(i.get("jxbrs", 0)), + "selected_number": int(i.get("yxzrs", 0)), + "place": self.get_place(i.get("jxdd")), + "time": self.get_course_time(i.get("sksj")), + "optional": int(i.get("zixf", 0)), + "waiting": i.get("sxbj"), + } + for i in selected + ], + } + return {"code": 1000, "msg": "获取已选课程成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取已选课程超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": f"获取已选课程时未记录的错误:{str(e)}"} + + def get_block_courses(self, year: int, term: int, block: int): + """获取板块课选课列表""" + # TODO: 优化代码 + try: + # 获取head_data + url_head = urljoin( + self.base_url, + "xsxk/zzxkyzb_cxZzxkYzbIndex.html?gnmkdm=N253512&layout=default", + ) + req_head_data = self.sess.get( + url_head, + headers=self.headers, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_head_data.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_head_data.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + if str(doc("div.nodata")) != "": + return {"code": 998, "msg": doc("div.nodata").text()} + got_credit_list = [i for i in doc("font[color='red']").items()] + if len(got_credit_list) == 0: + return {"code": 1005, "msg": "板块课内容为空"} + head_data = {"got_credit": got_credit_list[2].string} + + kklxdm_list = [] + xkkz_id_list = [] + for tab_content in doc("a[role='tab']").items(): + onclick_content = tab_content.attr("onclick") + r = re.findall(r"'(.*?)'", str(onclick_content)) + kklxdm_list.append(r[0].strip()) + xkkz_id_list.append(r[1].strip()) + head_data["bkk1_kklxdm"] = kklxdm_list[0] + head_data["bkk2_kklxdm"] = kklxdm_list[1] + head_data["bkk3_kklxdm"] = kklxdm_list[2] + head_data["bkk1_xkkz_id"] = xkkz_id_list[0] + head_data["bkk2_xkkz_id"] = xkkz_id_list[1] + head_data["bkk3_xkkz_id"] = xkkz_id_list[2] + + for head_data_content in doc("input[type='hidden']"): + name = head_data_content.attr("name") + value = head_data_content.attr("value") + head_data[str(name)] = str(value) + + url_display = urljoin( + self.base_url, "xsxk/zzxkyzb_cxZzxkYzbDisplay.html?gnmkdm=N253512" + ) + display_req_data = { + "xkkz_id": head_data[f"bkk{block}_xkkz_id"], + "xszxzt": "1", + "kspage": "0", + } + req_display_data = self.sess.post( + url_display, + headers=self.headers, + data=display_req_data, + cookies=self.cookies, + timeout=self.timeout, + ) + doc_display = pq(req_display_data.text) + display_data = {} + for display_data_content in doc_display("input[type='hidden']").items(): + name = display_data_content.get("name") + value = display_data_content.get("value") + display_data[str(name)] = str(value) + head_data.update(display_data) + + # 获取课程列表 + url_kch = urljoin( + self.base_url, "xsxk/zzxkyzb_cxZzxkYzbPartDisplay.html?gnmkdm=N253512" + ) + url_bkk = urljoin( + self.base_url, "xsxk/zzxkyzb_cxJxbWithKchZzxkYzb.html?gnmkdm=N253512" + ) + term = term**2 * 3 + kch_data = { + "bklx_id": head_data["bklx_id"], + "xqh_id": head_data["xqh_id"], + "zyfx_id": head_data["zyfx_id"], + "njdm_id": head_data["njdm_id"], + "bh_id": head_data["bh_id"], + "xbm": head_data["xbm"], + "xslbdm": head_data["xslbdm"], + "ccdm": head_data["ccdm"], + "xsbj": head_data["xsbj"], + "xkxnm": str(year), + "xkxqm": str(term), + "kklxdm": head_data[f"bkk{block}_kklxdm"], + "kkbk": head_data["kkbk"], + "rwlx": head_data["rwlx"], + "kspage": "1", + "jspage": "10", + } + kch_res = self.sess.post( + url_kch, + headers=self.headers, + data=kch_data, + cookies=self.cookies, + timeout=self.timeout, + ) + jkch_res = kch_res.json() + bkk_data = { + "bklx_id": head_data["bklx_id"], + "xkxnm": str(year), + "xkxqm": str(term), + "xkkz_id": head_data[f"bkk{block}_xkkz_id"], + "xqh_id": head_data["xqh_id"], + "zyfx_id": head_data["zyfx_id"], + "njdm_id": head_data["njdm_id"], + "bh_id": head_data["bh_id"], + "xbm": head_data["xbm"], + "xslbdm": head_data["xslbdm"], + "ccdm": head_data["ccdm"], + "xsbj": head_data["xsbj"], + "kklxdm": head_data[f"bkk{block}_kklxdm"], + "kch_id": jkch_res["tmpList"][0]["kch_id"], + "kkbk": head_data["kkbk"], + "rwlx": head_data["rwlx"], + "zyh_id": head_data["zyh_id"], + } + bkk_res = self.sess.post( + url_bkk, + headers=self.headers, + data=bkk_data, + cookies=self.cookies, + timeout=self.timeout, + ) + jbkk_res = bkk_res.json() + if block != 3 and (len(jkch_res["tmpList"]) != len(jbkk_res)): + return {"code": 999, "msg": "板块课编号及长度错误"} + temp_list = jkch_res["tmpList"] + block_list = jbkk_res + for i in range(len(temp_list)): + temp_list[i].update(block_list[i]) + + result = { + "count": len(temp_list), + "courses": [ + { + "course_id": j["kch_id"], + "class_id": j.get("jxb_id"), + "do_id": j.get("do_jxb_id"), + "title": j.get("kcmc"), + "teacher_id": (re.findall(r"(.*?\d+)/", j.get("jsxx")))[0], + "teacher": (re.findall(r"/(.*?)/", j.get("jsxx")))[0], + "credit": float(j.get("xf"), 0), + "kklxdm": head_data[f"bkk{block}_kklxdm"], + "capacity": int(i.get("jxbrl", 0)), + "selected_number": int(i.get("yxzrs", 0)), + "place": self.get_place(i.get("jxdd")), + "time": self.get_course_time(i.get("sksj")), + } + for j in temp_list + ], + } + return {"code": 1000, "msg": "获取板块课信息成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取板块课信息超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": f"获取板块课信息时未记录的错误:{str(e)}"} + + def select_course( + self, + sid: str, + course_id: str, + do_id: str, + kklxdm: str, + year: int, + term: int, + ): + """选课""" + try: + url_select = urljoin( + self.base_url, "xsxk/zzxkyzb_xkBcZyZzxkYzb.html?gnmkdm=N253512" + ) + term = term**2 * 3 + select_data = { + "jxb_ids": do_id, + "kch_id": course_id, + # 'rwlx': '3', + # 'rlkz': '0', + # 'rlzlkz': '1', + # 'sxbj': '1', + # 'xxkbj': '0', + # 'cxbj': '0', + "qz": "0", + # 'xkkz_id': '9B247F4EFD6291B9E055000000000001', + "xkxnm": str(year), + "xkxqm": str(term), + "njdm_id": str(sid[0:2]), + "zyh_id": str(sid[2:6]), + "kklxdm": str(kklxdm), + # 'xklc': '1', + } + req_select = self.sess.post( + url_select, + headers=self.headers, + data=select_data, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_select.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_select.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + result = req_select.json() + return {"code": 1000, "msg": "选课成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "选课超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": f"选课时未记录的错误:{str(e)}"} + + def cancel_course(self, do_id: str, course_id: str, year: int, term: int): + """取消选课""" + try: + url_cancel = urljoin( + self.base_url, "xsxk/zzxkyzb_tuikBcZzxkYzb.html?gnmkdm=N253512" + ) + term = term**2 * 3 + cancel_data = { + "jxb_ids": do_id, + "kch_id": course_id, + "xkxnm": str(year), + "xkxqm": str(term), + } + req_cancel = self.sess.post( + url_cancel, + headers=self.headers, + data=cancel_data, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_cancel.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_cancel.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + result = {"status": re.findall(r"(\d+)", req_cancel.text)[0]} + return {"code": 1000, "msg": "退课成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "选课超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": f"选课时未记录的错误:{str(e)}"} + + # ============= utils ================= + + def get_gpa(self): + """获取GPA""" + url = urljoin( + self.base_url, + "xsxy/xsxyqk_cxXsxyqkIndex.html?gnmkdm=N105515&layout=default", + ) + req_gpa = self.sess.get( + url, + headers=self.headers, + cookies=self.cookies, + timeout=self.timeout, + ) + doc = pq(req_gpa.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + allc_str = [allc.text() for allc in doc("font[size='2px']").items()] + try: + gpa = float(allc_str[2]) + return gpa + except Exception: + return "init" + + def get_course_category(self, type, item): + """根据课程号获取类别""" + if type not in self.detail_category_type: + return item.get("KCLBMC") + if not item.get("KCH"): + return None + url = urljoin(self.base_url, f"jxjhgl/common_cxKcJbxx.html?id={item['KCH']}") + req_category = self.sess.get( + url, + headers=self.headers, + cookies=self.cookies, + timeout=self.timeout, + ) + doc = pq(req_category.text) + ths = doc("th") + try: + data_list = [(th.text).strip() for th in ths] + return data_list[6] + except: + return None + + @classmethod + def encrypt_password(cls, pwd, n, e): + """对密码base64编码""" + message = str(pwd).encode() + rsa_n = binascii.b2a_hex(binascii.a2b_base64(n)) + rsa_e = binascii.b2a_hex(binascii.a2b_base64(e)) + key = rsa.PublicKey(int(rsa_n, 16), int(rsa_e, 16)) + encropy_pwd = rsa.encrypt(message, key) + result = binascii.b2a_base64(encropy_pwd) + return result + + @classmethod + def parse_int(cls, digits): + if not digits: + return None + if not digits.isdigit(): + return digits + return int(digits) + + @classmethod + def align_floats(cls, floats): + if not floats: + return None + if floats == "无": + return "0.0" + return format(float(floats), ".1f") + + @classmethod + def display_course_time(cls, sessions): + if not sessions: + return None + args = re.findall(r"(\d+)", sessions) + start_time = cls.raspisanie[int(args[0]) + 1][0] + end_time = cls.raspisanie[int(args[0]) + 1][1] + return f"{start_time}~{end_time}" + + @classmethod + def list_sessions(cls, sessions): + if not sessions: + return None + args = re.findall(r"(\d+)", sessions) + return [n for n in range(int(args[0]), int(args[1]) + 1)] + + @classmethod + def list_weeks(cls, weeks): + """返回课程所含周列表""" + if not weeks: + return None + args = re.findall(r"[^,]+", weeks) + week_list = [] + for item in args: + if "-" in item: + weeks_pair = re.findall(r"(\d+)", item) + if len(weeks_pair) != 2: + continue + if "单" in item: + for i in range(int(weeks_pair[0]), int(weeks_pair[1]) + 1): + if i % 2 == 1: + week_list.append(i) + elif "双" in item: + for i in range(int(weeks_pair[0]), int(weeks_pair[1]) + 1): + if i % 2 == 0: + week_list.append(i) + else: + for i in range(int(weeks_pair[0]), int(weeks_pair[1]) + 1): + week_list.append(i) + else: + week_num = re.findall(r"(\d+)", item) + if len(week_num) == 1: + week_list.append(int(week_num[0])) + return week_list + + @classmethod + def get_academia_statistics(cls, display_statistics): + display_statistics = "".join(display_statistics.split()) + gpa_list = re.findall(r"([0-9]{1,}[.][0-9]*)", display_statistics) + if len(gpa_list) == 0 or not cls.is_number(gpa_list[0]): + gpa = None + else: + gpa = float(gpa_list[0]) + plan_list = re.findall( + r"计划总课程(\d+)门通过(\d+)门?.*未通过(\d+)门?.*未修(\d+)?.*在读(\d+)门?.*计划外?.*通过(\d+)门?.*未通过(\d+)门", + display_statistics, + ) + if len(plan_list) == 0 or len(plan_list[0]) < 7: + return {"gpa": gpa} + plan_list = plan_list[0] + return { + "gpa": gpa, # 平均学分绩点GPA + "planed_courses": { + "total": int(plan_list[0]), # 计划内总课程数 + "passed": int(plan_list[1]), # 计划内已过课程数 + "failed": int(plan_list[2]), # 计划内未过课程数 + "missed": int(plan_list[3]), # 计划内未修课程数 + "in": int(plan_list[4]), # 计划内在读课程数 + }, + "unplaned_courses": { + "passed": int(plan_list[5]), # 计划外已过课程数 + "failed": int(plan_list[6]), # 计划外未过课程数 + }, + } + + @classmethod + def get_academia_type_statistics(cls, content: str): + finder = re.findall( + r"\"(.*) .*要求学分.*:([0-9]{1,}[.][0-9]*|0| ).*获得学分.*:([0-9]{1,}[.][0-9]*|0| ).*未获得学分.*:([0-9]{1,}[.][0-9]*|0| )[\s\S]*?", + content, + ) + finder_list = list({}.fromkeys(finder).keys()) + academia_list = [ + list(i) + for i in finder_list + if i[0] != "" # 类型名称不为空 + and len(i[0]) <= 20 # 避免正则到首部过长类型名称 + and "span" not in i[-1] # 避免正则到尾部过长类型名称 + and i[0] not in cls.ignore_type # 忽略的类型名称 + ] + result = { + i[0]: { + "id": i[-1], + "credits": { + "required": i[1] if cls.is_number(i[1]) and i[1] != "0" else None, + "earned": i[2] if cls.is_number(i[2]) and i[2] != "0" else None, + "missed": i[3] if cls.is_number(i[3]) and i[3] != "0" else None, + }, + } + for i in academia_list + } + return result + + @classmethod + def get_display_term(cls, sid, year, term): + """ + 计算培养方案具体学期转化成中文 + note: 留级和当兵等情况会不准确 + """ + if (sid and year and term) is None: + return None + grade = int(sid[0:2]) + year = int(year[2:4]) + term = int(term) + dict = { + grade: "大一上" if term == 1 else "大一下", + grade + 1: "大二上" if term == 1 else "大二下", + grade + 2: "大三上" if term == 1 else "大三下", + grade + 3: "大四上" if term == 1 else "大四下", + } + return dict.get(year) + + @classmethod + def split_merge_display(cls, schedule): + """ + 拆分同周同天同课程不同时段数据合并的问题 + """ + repetIndex = [] + count = 0 + for items in schedule["courses"]: + for index in range(len(schedule["courses"])): + if (schedule["courses"]).index(items) == count: # 如果对比到自己就忽略 + continue + elif ( + items["course_id"] + == schedule["courses"][index]["course_id"] # 同周同天同课程 + and items["weekday"] == schedule["courses"][index]["weekday"] + and items["weeks"] == schedule["courses"][index]["weeks"] + ): + repetIndex.append(index) # 满足条件记录索引 + count += 1 # 记录当前对比课程的索引 + if len(repetIndex) % 2 != 0: # 暂时考虑一天两个时段上同一门课,不满足条件不进行修改 + return schedule + for r in range(0, len(repetIndex), 2): # 索引数组两两成对,故步进2循环 + fir = repetIndex[r] + sec = repetIndex[r + 1] + if len(re.findall(r"(\d+)", schedule["courses"][fir]["sessions"])) == 4: + schedule["courses"][fir]["sessions"] = ( + re.findall(r"(\d+)", schedule["courses"][fir]["sessions"])[0] + + "-" + + re.findall(r"(\d+)", schedule["courses"][fir]["sessions"])[1] + + "节" + ) + schedule["courses"][fir]["list_sessions"] = cls.list_sessions( + schedule["courses"][fir]["sessions"] + ) + schedule["courses"][fir]["time"] = cls.display_course_time( + schedule["courses"][fir]["sessions"] + ) + + schedule["courses"][sec]["sessions"] = ( + re.findall(r"(\d+)", schedule["courses"][sec]["sessions"])[2] + + "-" + + re.findall(r"(\d+)", schedule["courses"][sec]["sessions"])[3] + + "节" + ) + schedule["courses"][sec]["list_sessions"] = cls.list_sessions( + schedule["courses"][sec]["sessions"] + ) + schedule["courses"][sec]["time"] = cls.display_course_time( + schedule["courses"][sec]["sessions"] + ) + return schedule + + @classmethod + def split_notifications(cls, item): + if not item.get("xxnr"): + return {"type": None, "content": None} + content_list = re.findall(r"(.*):(.*)", item["xxnr"]) + if len(content_list) == 0: + return {"type": None, "content": item["xxnr"]} + return {"type": content_list[0][0], "content": content_list[0][1]} + + @classmethod + def get_place(cls, place): + return place.split("
")[0] if "
" in place else place + + @classmethod + def get_course_time(cls, time): + return "、".join(time.split("
")) if "
" in time else time + + @classmethod + def is_number(cls, s): + if s == "": + return False + try: + float(s) + return True + except ValueError: + pass + try: + for i in s: + unicodedata.numeric(i) + return True + except (TypeError, ValueError): + pass + return False + + +if __name__ == "__main__": + from pprint import pprint + import json + import base64 + import sys + import os + + base_url = "https://xxxx.xxx.edu.cn" # 教务系统URL + sid = "123456" # 学号 + password = "abc654321" # 密码 + lgn_cookies = ( + { + # "insert_cookie": "", + # "route": "", + "JSESSIONID": "" + } + if False + else None + ) # cookies登录,调整成True使用cookies登录,反之使用密码登录 + test_year = 2022 # 查询学年 + test_term = 2 # 查询学期(1-上|2-下) + + # 初始化 + lgn = Client(lgn_cookies if lgn_cookies is not None else {}, base_url=base_url) + # 判断是否需要使用cookies登录 + if lgn_cookies is None: + # 登录 + pre_login = lgn.login(sid, password) + # 判断登录结果 + if pre_login["code"] == 1001: + # 需要验证码 + pre_dict = pre_login["data"] + with open(os.path.abspath("temp.json"), mode="w", encoding="utf-8") as f: + f.write(json.dumps(pre_dict)) + with open(os.path.abspath("kaptcha.png"), "wb") as pic: + pic.write(base64.b64decode(pre_dict["kaptcha_pic"])) + kaptcha = input("输入验证码:") + result = lgn.login_with_kaptcha( + pre_dict["sid"], + pre_dict["csrf_token"], + pre_dict["cookies"], + pre_dict["password"], + pre_dict["modulus"], + pre_dict["exponent"], + kaptcha, + ) + if result["code"] != 1000: + pprint(result) + sys.exit() + lgn_cookies = lgn.cookies + elif pre_login["code"] == 1000: + # 不需要验证码,直接登录 + lgn_cookies = lgn.cookies + else: + # 出错 + pprint(pre_login) + sys.exit() + + # 下面是各个函数调用,想调用哪个,取消注释即可 + """ 获取个人信息 """ + result = lgn.get_info() + + """ 获取成绩单PDF """ + # result = lgn.get_academia_pdf() + # if result["code"] == 1000: + # with open(os.path.abspath("grade.pdf"), "wb") as pdf: + # pdf.write(result["data"]) + # result = "已保存到本地" + + """ 获取学业情况 """ + # result = lgn.get_academia() + + """ 获取GPA """ + # result = lgn.get_gpa() + + """ 获取课程表 """ + # result = lgn.get_schedule(test_year, test_term) + + """ 获取成绩 """ + # result = lgn.get_grade(test_year, test_term) + + # 输出结果 + pprint(result) diff --git a/src/timemanagerapp/ios/.gitignore b/src/timemanagerapp/ios/.gitignore new file mode 100644 index 0000000..7a7f987 --- /dev/null +++ b/src/timemanagerapp/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/src/timemanagerapp/ios/Flutter/AppFrameworkInfo.plist b/src/timemanagerapp/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000..9625e10 --- /dev/null +++ b/src/timemanagerapp/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 11.0 + + diff --git a/src/timemanagerapp/ios/Flutter/Debug.xcconfig b/src/timemanagerapp/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/src/timemanagerapp/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/src/timemanagerapp/ios/Flutter/Release.xcconfig b/src/timemanagerapp/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/src/timemanagerapp/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/src/timemanagerapp/ios/Runner.xcodeproj/project.pbxproj b/src/timemanagerapp/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..f1609ce --- /dev/null +++ b/src/timemanagerapp/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,614 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 331C8082294A63A400263BE5 /* RunnerTests */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + 331C8081294A63A400263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C8080294A63A400263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C807D294A63A400263BE5 /* Sources */, + 331C807E294A63A400263BE5 /* Frameworks */, + 331C807F294A63A400263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C8086294A63A400263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastUpgradeCheck = 1430; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C8080294A63A400263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + 331C8080294A63A400263BE5 /* RunnerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C807F294A63A400263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C807D294A63A400263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C8086294A63A400263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.timemanagerapp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = AE0B7B92F70575B8D7E0D07E /* Pods-RunnerTests.debug.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.timemanagerapp.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Debug; + }; + 331C8089294A63A400263BE5 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 89B67EB44CE7B6631473024E /* Pods-RunnerTests.release.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.timemanagerapp.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Release; + }; + 331C808A294A63A400263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 640959BDD8F10B91D80A66BE /* Pods-RunnerTests.profile.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.timemanagerapp.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.timemanagerapp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.timemanagerapp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C8088294A63A400263BE5 /* Debug */, + 331C8089294A63A400263BE5 /* Release */, + 331C808A294A63A400263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/src/timemanagerapp/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/src/timemanagerapp/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/src/timemanagerapp/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/src/timemanagerapp/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/src/timemanagerapp/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/src/timemanagerapp/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/src/timemanagerapp/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/src/timemanagerapp/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/src/timemanagerapp/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/src/timemanagerapp/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/src/timemanagerapp/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..87131a0 --- /dev/null +++ b/src/timemanagerapp/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/timemanagerapp/ios/Runner.xcworkspace/contents.xcworkspacedata b/src/timemanagerapp/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/src/timemanagerapp/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/src/timemanagerapp/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/src/timemanagerapp/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/src/timemanagerapp/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/src/timemanagerapp/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/src/timemanagerapp/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/src/timemanagerapp/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/src/timemanagerapp/ios/Runner/AppDelegate.swift b/src/timemanagerapp/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000..70693e4 --- /dev/null +++ b/src/timemanagerapp/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d36b1fa --- /dev/null +++ b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000..dc9ada4 Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000..7353c41 Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000..797d452 Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000..6ed2d93 Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000..4cd7b00 Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000..fe73094 Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000..321773c Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000..797d452 Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000..502f463 Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000..0ec3034 Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000..0ec3034 Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000..e9f5fea Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000..84ac32a Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000..8953cba Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000..0467bf1 Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/src/timemanagerapp/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000..0bedcf2 --- /dev/null +++ b/src/timemanagerapp/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/src/timemanagerapp/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/src/timemanagerapp/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/src/timemanagerapp/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/src/timemanagerapp/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000..89c2725 --- /dev/null +++ b/src/timemanagerapp/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/src/timemanagerapp/ios/Runner/Base.lproj/LaunchScreen.storyboard b/src/timemanagerapp/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f2e259c --- /dev/null +++ b/src/timemanagerapp/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/timemanagerapp/ios/Runner/Base.lproj/Main.storyboard b/src/timemanagerapp/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f3c2851 --- /dev/null +++ b/src/timemanagerapp/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/timemanagerapp/ios/Runner/Info.plist b/src/timemanagerapp/ios/Runner/Info.plist new file mode 100644 index 0000000..fab11c2 --- /dev/null +++ b/src/timemanagerapp/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Timemanagerapp + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + timemanagerapp + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + + diff --git a/src/timemanagerapp/ios/Runner/Runner-Bridging-Header.h b/src/timemanagerapp/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000..308a2a5 --- /dev/null +++ b/src/timemanagerapp/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/src/timemanagerapp/ios/RunnerTests/RunnerTests.swift b/src/timemanagerapp/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..86a7c3b --- /dev/null +++ b/src/timemanagerapp/ios/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Flutter +import UIKit +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/src/timemanagerapp/lib/controller/CourseController.dart b/src/timemanagerapp/lib/controller/CourseController.dart new file mode 100644 index 0000000..01c5677 --- /dev/null +++ b/src/timemanagerapp/lib/controller/CourseController.dart @@ -0,0 +1,126 @@ +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 courseList = []; //实时维护的courseList缓存 + NetWorkController netWorkController = NetWorkController(); + + DateTime termstartdate = Setting.startdate; //Setting.getStartDate(); + + // 课表的时间范围 + final List> 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 addCourseForm(CourseForm courseForm) async { + List 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> getCourses() async { + List> courseMaps = await CourseDao().getCourses(); + List courses = []; // 用于存储转换后的Course对象列表 + + for (var courseMap in courseMaps) { + // 使用Course类的构造函数从Map创建Course对象 + 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 insertCourse(Course course) async { + return await CourseDao().insertCourse(course); + } + + Future insertCourseList(List courseList) async { + int result = 0; + for(Course course in courseList){ + result += await CourseDao().insertCourse(course); + } + return result; + } + + Future autoImportCours(int stuid,String passwd,int year, int term) async { + String jsonstr = await netWorkController.getUserCoursejson(stuid, passwd, year, term); + List courseList = await getCourseByLogin.dealRawString(jsonstr); + return await insertCourseList(courseList); + } + + + Future deleteAllCourses() async { + return await CourseDao().deleteAllCourses(); + } + + Future deleteCourse(int id) async { + return await CourseDao().deleteCourseById(id); + } + +} diff --git a/src/timemanagerapp/lib/controller/CourseWidgetController.dart b/src/timemanagerapp/lib/controller/CourseWidgetController.dart new file mode 100644 index 0000000..ef623b7 --- /dev/null +++ b/src/timemanagerapp/lib/controller/CourseWidgetController.dart @@ -0,0 +1,139 @@ +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 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 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 convertTimeList(List timePoints, double deviceWidth) { + List 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> transformCourseMap(List courseList) { + Map> 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; + } +} diff --git a/src/timemanagerapp/lib/controller/NetWorkController.dart b/src/timemanagerapp/lib/controller/NetWorkController.dart new file mode 100644 index 0000000..6684252 --- /dev/null +++ b/src/timemanagerapp/lib/controller/NetWorkController.dart @@ -0,0 +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 login(User user) async { + return Future(() => 1); + } + + Future register(User user) async { + return Future(() => 1); + } + + Future> getSameFreeWork(int teamid){ + List workList = []; + return Future(() => workList); + } + + Future> getTeamWorkList (int teamid){ + List workList = []; + return Future(() => workList); + } + + Future> getTeamList(int userid){ + List teamList = []; + return Future(() => teamList); + } + + Future insertTeam(Team team) async { + return true; + } + + Future deleteTeam(int teamid) async { + return true; + } + + Future updateTeam(Team team) async { + return true; + } + + Future> getTeamUserList(int teamid) async { + List userList = []; + return userList; + } + + Future insertTeamUser(int teamid,int userid) async { + return true; + } + + Future deleteTeamUser(int teamid,int userid) async { + return true; + } +//todo +// Future deleteTeamUser(int teamid,int userid) async { +// return true; +// } + + + //app启动时调用,同步所有数据库 + Future updateCourse(List courseList) async { + return true; + } + + Future updateTask(List workList) async { + return true; + } + + Future getUserCoursejson(int stuid,String passwd,int year, int term){ + String res = ""; + return Future(() => res); + } + +} \ No newline at end of file diff --git a/src/timemanagerapp/lib/controller/TaskController.dart b/src/timemanagerapp/lib/controller/TaskController.dart new file mode 100644 index 0000000..e69de29 diff --git a/src/timemanagerapp/lib/controller/TeamController.dart b/src/timemanagerapp/lib/controller/TeamController.dart new file mode 100644 index 0000000..5398cbc --- /dev/null +++ b/src/timemanagerapp/lib/controller/TeamController.dart @@ -0,0 +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 teamList = []; //实时维护的teamList缓存 + Map> Wordmaplist = {}; + NetWorkController netWorkController = NetWorkController(); + + + TeamController(int leaderid) { + this.leaderid = leaderid; + //TODO: 从服务器中根据leaderid获取teamList + + for (var team in teamList) { + //TODO: 从服务器中根据team.id获取Worklist[team.id] + //Wordmaplist[team.id].add() + } + } + + Future> getTeams(int userid) async { + return await netWorkController.getTeamList(userid); + } + + Future createTeam(Team team) async { + return await netWorkController.insertTeam(team); + } + + Future insertTeamList(List teamList) async { + for (Team team in teamList) { + await TeamDao().insertTeam(team); + } + } + + Future deleteAllTeams() async { + await TeamDao().deleteAllTeams(); + } + + Future deleteTeam(int teamid) async { + return await netWorkController.deleteTeam(teamid); + } + + Future updateTeam(Team team) async { + return await netWorkController.updateTeam(team); + } + + Future insertWork(Work work) async { + // return await netWorkController.insertWork(work); + } + + Future insertWorkList(List workList) async { + for (Work work in workList) { + await WorkDao().insertWork(work); + } + } + + Future deleteAllWorks() async { + await WorkDao().deleteAllWorks(); + } + + Future deleteWork(int id) async { + await WorkDao().deleteWorkByid(id); + } + + Future updateWork(Work work) async { + await WorkDao().updateWork(work); + } + + Future>> getWorks() async { + return WorkDao().getWorks(); + } + + Future>> getWorksByTeamid(int teamid) async { + return WorkDao().getWorksByTeamid(teamid); + } + + Future> getSameFreeWork(int teamid){ + return netWorkController.getSameFreeWork(teamid); + } + + + +} + diff --git a/src/timemanagerapp/lib/controller/UserController.dart b/src/timemanagerapp/lib/controller/UserController.dart new file mode 100644 index 0000000..95bd2bd --- /dev/null +++ b/src/timemanagerapp/lib/controller/UserController.dart @@ -0,0 +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>> getUsers() async { + return await UserDao.getInstance().getUsers(); + } + + Future login(User user) async { + int userid = await netWorkController.login(user); + user.id = userid; + await Setting.saveUser(user); + return true; + } + + Future register(User user) async { + int userid = await netWorkController.register(user); + user.id = userid; + await Setting.saveUser(user); + return true; + } + + Future insertUser(User user) async { + await UserDao.getInstance().insertUser(user); + } + + Future insertUserList(List userList) async { + for (User user in userList) { + await UserDao.getInstance().insertUser(user); + } + } + + //deleteAllUsers + Future deleteAllUsers() async { + await UserDao.getInstance().deleteAllUsers(); + } +} diff --git a/src/timemanagerapp/lib/controller/WorkController.dart b/src/timemanagerapp/lib/controller/WorkController.dart new file mode 100644 index 0000000..e69de29 diff --git a/src/timemanagerapp/lib/database/MyDatebase.dart b/src/timemanagerapp/lib/database/MyDatebase.dart new file mode 100644 index 0000000..16296fa --- /dev/null +++ b/src/timemanagerapp/lib/database/MyDatebase.dart @@ -0,0 +1,146 @@ +import 'package:sqflite/sqflite.dart'; +import 'package:path/path.dart'; +import 'dart:async'; + +import 'package:timemanagerapp/entity/Task.dart'; + +/** + * 用于创建数据库,数据库表,并将其放回 + */ +class MyDatabase { + static Future initDatabase() async { + final databasePath = await getDatabasesPath(); + final path = join(databasePath, 'tma.db'); + + // 打开数据库连接 + //onCreate表示只有如果数据库版本发生变化,将会触发 onCreate 回调 + final database = + await openDatabase(path, version: 1, onCreate: _createTables); + + //! + _createTables(database, 1); + + // // 删除所有已存在的表格 + // await _dropAllTables(database); + + return Future.value(database); + } + + static Future _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 _createUserTable(Database db, int version) async { + // 创建User表 + await db.execute(''' + CREATE TABLE IF NOT EXISTS users( + id INTEGER PRIMARY KEY, + teamId INTEGER NOT NULL, + username TEXT NOT NULL, + password TEXT NOT NULL, + role INTEGER NOT NULL + ) + '''); + print("userstable create success"); + } + + static Future _createWorkTable(Database db, int version) async { + // 创建Work表 + await db.execute(''' + CREATE TABLE IF NOT EXISTS works ( + id INTEGER PRIMARY KEY, + userId INTEGER NOT NULL, + status TEXT NOT NULL, + workContent TEXT NOT NULL, + teamId INTEGER NOT NULL, + functionaryId INTEGER NOT NULL, + workId INTEGER NOT NULL, + endTime TEXT NOT NULL, + startTime TEXT NOT NULL + ); + '''); + print("Coursetable create success"); + } + + static Future _createClockTable(Database db, int version) async { + // 创建Clock表 + await db.execute(''' + CREATE TABLE IF NOT EXISTS clocks ( + id INTEGER PRIMARY KEY, + userId INTEGER NOT NULL, + text TEXT NOT NULL, + img TEXT NOT NULL, + music TEXT NOT NULL, + continueTime TEXT NOT NULL + ); + '''); + } + + static Future _createTaskTable(Database db, int version) async { + // 创建Task表 + await db.execute(''' + CREATE TABLE IF NOT EXISTS tasks ( + id INTEGER PRIMARY KEY, + userId INTEGER NOT NULL, + content TEXT NOT NULL, + taskId INTEGER NOT NULL, + name TEXT NOT NULL, + startTime TEXT NOT NULL, + endTime TEXT NOT NULL + ); + '''); + } + + static Future _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 _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 + ); + '''); + } + + // 执行删除表格 + static Future _dropAllTables(Database database) async { + // 执行删除表格的 SQL 语句 + await database.transaction((txn) async { + // 例如,如果有表格名为 'table1'、'table2'、'table3',可以执行以下操作: + await txn.execute('DROP TABLE IF EXISTS teams'); + await txn.execute('DROP TABLE IF EXISTS Course'); + await txn.execute('DROP TABLE IF EXISTS users'); + }); + } +} diff --git a/src/timemanagerapp/lib/database/dao/CourseDao.dart b/src/timemanagerapp/lib/database/dao/CourseDao.dart new file mode 100644 index 0000000..eb017ad --- /dev/null +++ b/src/timemanagerapp/lib/database/dao/CourseDao.dart @@ -0,0 +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>> getCourses() async { + final database = await db; + if (database != null) { + return database.rawQuery('SELECT * FROM course'); + } else { + return []; + } + } + + Future 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 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 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 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 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 deleteAllCourses() async { + final database = await db; + int result = 0; + if (database != null) { + result = await database.delete('course', where: '1=1'); + } + return result; + } +} diff --git a/src/timemanagerapp/lib/database/dao/TaskDao.dart b/src/timemanagerapp/lib/database/dao/TaskDao.dart new file mode 100644 index 0000000..3646e83 --- /dev/null +++ b/src/timemanagerapp/lib/database/dao/TaskDao.dart @@ -0,0 +1,56 @@ +import '../../entity/Task.dart'; +import '../MyDatebase.dart'; + +class TaskDao { + //对外暴露实例 + static TaskDao getInstance() { + return new TaskDao(); + } + + var db = MyDatabase.initDatabase(); + + Future>> getTasks() async { + final database = await db; + if (database != null) { + return database.query('Task', orderBy: 'id ASC'); + } else { + return []; + } + } + + Future insertTask(Task task) async { + final database = await db; + if (database != null) { + await database.insert('Task', task.toMap()); + } + } + + Future updateTask(Task task) async { + final database = await db; + if (database != null) { + await database + .update('Task', task.toMap(), where: 'id = ?', whereArgs: [task.id]); + } + } + + Future deleteTaskByid(int id) async { + final database = await db; + if (database != null) { + await database.delete('Task', where: 'id = ?', whereArgs: [id]); + } + } + + Future deleteTaskByTaskid(int taskid) async { + final database = await db; + if (database != null) { + await database.delete('Task', where: 'taskid = ?', whereArgs: [taskid]); + } + } + + Future deleteAllTasks() async { + final database = await db; + if (database != null) { + await database.delete('Task', where: '1=1'); + } + } +} \ No newline at end of file diff --git a/src/timemanagerapp/lib/database/dao/TeamDao.dart b/src/timemanagerapp/lib/database/dao/TeamDao.dart new file mode 100644 index 0000000..4a6b347 --- /dev/null +++ b/src/timemanagerapp/lib/database/dao/TeamDao.dart @@ -0,0 +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>> getTeams() async { + final database = await db; + if (database != null) { + return database.query('Team', orderBy: 'id ASC'); + } else { + return []; + } + } + + Future insertTeam(Team team) async { + final database = await db; + if (database != null) { + await database.insert('Team', team.toMap()); + } + } + + Future updateTeam(Team team) async { + final database = await db; + if (database != null) { + await database + .update('Team', team.toMap(), where: 'id = ?', whereArgs: [team.id]); + } + } + + + Future deleteTeamById(int id) async { + final database = await db; + if (database != null) { + await database.delete('Team', where: 'id = ?', whereArgs: [id]); + } + } + + + + Future deleteAllTeams() async { + final database = await db; + if (database != null) { + await database.delete('Team', where: '1=1'); + } + } +} diff --git a/src/timemanagerapp/lib/database/dao/UserDao.dart b/src/timemanagerapp/lib/database/dao/UserDao.dart new file mode 100644 index 0000000..0d8f883 --- /dev/null +++ b/src/timemanagerapp/lib/database/dao/UserDao.dart @@ -0,0 +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>> getUsers() async { + final database = await db; + if (database != null) { + return await database.rawQuery('SELECT * FROM users'); + } else { + return []; + } + } + + Future 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 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 deleteAllUsers() async { + final database = await db; + if (database != null) { + await database.transaction((txn) async { + // 删除数据 + await txn.rawDelete(''' + DELETE FROM users + '''); + }); + } + } +} diff --git a/src/timemanagerapp/lib/database/dao/WorkDao.dart b/src/timemanagerapp/lib/database/dao/WorkDao.dart new file mode 100644 index 0000000..b18ccf8 --- /dev/null +++ b/src/timemanagerapp/lib/database/dao/WorkDao.dart @@ -0,0 +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>> getWorks() async { + final database = await db; + if (database != null) { + return database.query('Work', orderBy: 'id ASC'); + } else { + return []; + } + } + + Future>> 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 insertWork(Work work) async { + final database = await db; + if (database != null) { + await database.insert('Work', work.toMap()); + } + } + + Future updateWork(Work work) async { + final database = await db; + if (database != null) { + await database + .update('Work', work.toMap(), where: 'id = ?', whereArgs: [work.id]); + } + } + + Future deleteWorkByid(int id) async { + final database = await db; + if (database != null) { + await database.delete('Work', where: 'id = ?', whereArgs: [id]); + } + } + + Future deleteWorkByWorkid(int workid) async { + final database = await db; + if (database != null) { + await database.delete('Work', where: 'workid = ?', whereArgs: [workid]); + } + } + + Future deleteWorkByTeamid(int teamid) async { + final database = await db; + if (database != null) { + await database.delete('Work', where: 'teamid = ?', whereArgs: [teamid]); + } + } + + Future deleteAllWorks() async { + final database = await db; + if (database != null) { + await database.delete('Work', where: '1=1'); + } + } +} diff --git a/src/timemanagerapp/lib/entity/Clock.dart b/src/timemanagerapp/lib/entity/Clock.dart new file mode 100644 index 0000000..60d9782 --- /dev/null +++ b/src/timemanagerapp/lib/entity/Clock.dart @@ -0,0 +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 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)'; + } +} diff --git a/src/timemanagerapp/lib/entity/Course.dart b/src/timemanagerapp/lib/entity/Course.dart new file mode 100644 index 0000000..2bd5233 --- /dev/null +++ b/src/timemanagerapp/lib/entity/Course.dart @@ -0,0 +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 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)'; + } +} diff --git a/src/timemanagerapp/lib/entity/CourseForm.dart b/src/timemanagerapp/lib/entity/CourseForm.dart new file mode 100644 index 0000000..aa133ec --- /dev/null +++ b/src/timemanagerapp/lib/entity/CourseForm.dart @@ -0,0 +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 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 setSelectedDays (List 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 getSelectedDays(){ + return this.selectedDays; + } + +} \ No newline at end of file diff --git a/src/timemanagerapp/lib/entity/ScheduleForm.dart b/src/timemanagerapp/lib/entity/ScheduleForm.dart new file mode 100644 index 0000000..3fd7d76 --- /dev/null +++ b/src/timemanagerapp/lib/entity/ScheduleForm.dart @@ -0,0 +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 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)'; + } +} diff --git a/src/timemanagerapp/lib/entity/Task.dart b/src/timemanagerapp/lib/entity/Task.dart new file mode 100644 index 0000000..59d7c49 --- /dev/null +++ b/src/timemanagerapp/lib/entity/Task.dart @@ -0,0 +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 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)'; + } +} diff --git a/src/timemanagerapp/lib/entity/Team.dart b/src/timemanagerapp/lib/entity/Team.dart new file mode 100644 index 0000000..94773e2 --- /dev/null +++ b/src/timemanagerapp/lib/entity/Team.dart @@ -0,0 +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 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)'; + } +} diff --git a/src/timemanagerapp/lib/entity/User.dart b/src/timemanagerapp/lib/entity/User.dart new file mode 100644 index 0000000..c044a2f --- /dev/null +++ b/src/timemanagerapp/lib/entity/User.dart @@ -0,0 +1,81 @@ +class User { + int? id; + int teamId; + String username; + String password; + int role; //0表示一般用户,1表示管理员 + + User({ + this.id, + required this.teamId, + required this.username, + required this.password, + required this.role, + }); + + + Map 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)'; + } +} diff --git a/src/timemanagerapp/lib/entity/Work.dart b/src/timemanagerapp/lib/entity/Work.dart new file mode 100644 index 0000000..d1ef65e --- /dev/null +++ b/src/timemanagerapp/lib/entity/Work.dart @@ -0,0 +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 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)'; + } +} diff --git a/src/timemanagerapp/lib/main.dart b/src/timemanagerapp/lib/main.dart new file mode 100644 index 0000000..003c271 --- /dev/null +++ b/src/timemanagerapp/lib/main.dart @@ -0,0 +1,36 @@ +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: TestWidget(), + ), + ); + } +} diff --git a/src/timemanagerapp/lib/ruters/AddCourseRoute.dart b/src/timemanagerapp/lib/ruters/AddCourseRoute.dart new file mode 100644 index 0000000..1d084dc --- /dev/null +++ b/src/timemanagerapp/lib/ruters/AddCourseRoute.dart @@ -0,0 +1,15 @@ +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(), + ); + } +} \ No newline at end of file diff --git a/src/timemanagerapp/lib/ruters/TimetableRoute.dart b/src/timemanagerapp/lib/ruters/TimetableRoute.dart new file mode 100644 index 0000000..9fe00c4 --- /dev/null +++ b/src/timemanagerapp/lib/ruters/TimetableRoute.dart @@ -0,0 +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(), + ); + } +} diff --git a/src/timemanagerapp/lib/setting/Setting.dart b/src/timemanagerapp/lib/setting/Setting.dart new file mode 100644 index 0000000..2ad17a8 --- /dev/null +++ b/src/timemanagerapp/lib/setting/Setting.dart @@ -0,0 +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()); + } +} diff --git a/src/timemanagerapp/lib/tests/Addcoursewidget_test.dart b/src/timemanagerapp/lib/tests/Addcoursewidget_test.dart new file mode 100644 index 0000000..42fbde5 --- /dev/null +++ b/src/timemanagerapp/lib/tests/Addcoursewidget_test.dart @@ -0,0 +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(), + ), + ); + } +} diff --git a/src/timemanagerapp/lib/tests/Setting_test.dart b/src/timemanagerapp/lib/tests/Setting_test.dart new file mode 100644 index 0000000..ac3e84c --- /dev/null +++ b/src/timemanagerapp/lib/tests/Setting_test.dart @@ -0,0 +1,11 @@ +import '../setting/Setting.dart'; +import 'dart:ui' as ui; + +void init(){ + Setting.init(); +} + +void main() { + init(); + print(Setting.getStartDate()); +} diff --git a/src/timemanagerapp/lib/tests/TestWidget.dart b/src/timemanagerapp/lib/tests/TestWidget.dart new file mode 100644 index 0000000..7fd4e01 --- /dev/null +++ b/src/timemanagerapp/lib/tests/TestWidget.dart @@ -0,0 +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 { + 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 { + 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: [ + 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(); + } +} diff --git a/src/timemanagerapp/lib/tests/database_test.dart b/src/timemanagerapp/lib/tests/database_test.dart new file mode 100644 index 0000000..e69de29 diff --git a/src/timemanagerapp/lib/tests/timetable_tes.dart b/src/timemanagerapp/lib/tests/timetable_tes.dart new file mode 100644 index 0000000..dbbb1c1 --- /dev/null +++ b/src/timemanagerapp/lib/tests/timetable_tes.dart @@ -0,0 +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(), + ), + ); + } +} diff --git a/src/timemanagerapp/lib/util/GetCourseByLogin.dart b/src/timemanagerapp/lib/util/GetCourseByLogin.dart new file mode 100644 index 0000000..d01f679 --- /dev/null +++ b/src/timemanagerapp/lib/util/GetCourseByLogin.dart @@ -0,0 +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 courses = []; //获取的所有课程 + IdGenerator idGenerator = IdGenerator(); + + // GetCourseByLogin({this.id = "", this.passwd = "", this.year = "2021", this.term = "1"}); + + // 课表的时间范围 + final List> 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 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 getweeklist(String weekstr) { + List 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; + } +} diff --git a/src/timemanagerapp/lib/util/dataUtil.dart b/src/timemanagerapp/lib/util/dataUtil.dart new file mode 100644 index 0000000..c7e1252 --- /dev/null +++ b/src/timemanagerapp/lib/util/dataUtil.dart @@ -0,0 +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 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 generateSequenceFromMacAddress() async{ + String macAddress = await getMacAddress();; + // 移除冒号,并将MAC地址转为大写 + String sanitizedMacAddress = macAddress.replaceAll(':', '').toUpperCase(); + + // 将MAC地址的前6个字节转换为整数,并计算它们的总和 + int sum = int.parse(sanitizedMacAddress.substring(0, 12), radix: 16); + + // 将总和作为sequence + return sum % (1 << 12); + } + + Future 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 _getMacAddress(AndroidDeviceInfo androidInfo) async { + + DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); + + AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; + + String macAddress = androidInfo.androidId; + print("get MAC address:" + macAddress); + return macAddress; + // 使用WifiManager获取MAC地址 + 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; + } + + +} diff --git a/src/timemanagerapp/lib/util/getschedule.py b/src/timemanagerapp/lib/util/getschedule.py new file mode 100644 index 0000000..1b2c0e5 --- /dev/null +++ b/src/timemanagerapp/lib/util/getschedule.py @@ -0,0 +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: +# f.write(file_result) \ No newline at end of file diff --git a/src/timemanagerapp/lib/util/zfn_api.py b/src/timemanagerapp/lib/util/zfn_api.py new file mode 100644 index 0000000..6dc408e --- /dev/null +++ b/src/timemanagerapp/lib/util/zfn_api.py @@ -0,0 +1,1559 @@ +import base64 +import binascii +import json +import re +import time +import traceback +import unicodedata +from urllib.parse import urljoin + +import requests +import rsa +from pyquery import PyQuery as pq +from requests import exceptions + +RASPIANIE = [ + ["8:00", "8:40"], + ["8:45", "9:25"], + ["9:30", "10:10"], + ["10:30", "11:10"], + ["11:15", "11:55"], + ["14:30", "15:10"], + ["15:15", "15:55"], + ["16:05", "16:45"], + ["16:50", "17:30"], + ["18:40", "19:20"], + ["19:25", "20:05"], + ["20:10", "20:50"], + ["20:55", "21:35"], +] + + +class Client: + raspisanie = [] + ignore_type = [] + + def __init__(self, cookies={}, **kwargs): + # 基础配置 + self.base_url = kwargs.get("base_url") + self.raspisanie = kwargs.get("raspisanie", RASPIANIE) + self.ignore_type = kwargs.get("ignore_type", []) + self.detail_category_type = kwargs.get("detail_category_type", []) + self.timeout = kwargs.get("timeout", 3) + Client.raspisanie = self.raspisanie + Client.ignore_type = self.ignore_type + + self.key_url = urljoin(self.base_url, "xtgl/login_getPublicKey.html") + self.login_url = urljoin(self.base_url, "xtgl/login_slogin.html") + self.kaptcha_url = urljoin(self.base_url, "kaptcha") + self.headers = requests.utils.default_headers() + self.headers["Referer"] = self.login_url + self.headers[ + "User-Agent" + ] = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36" + self.headers[ + "Accept" + ] = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3" + self.sess = requests.Session() + self.sess.keep_alive = False + self.cookies = cookies + + def login(self, sid, password): + """登录教务系统""" + need_verify = False + try: + # 登录页 + req_csrf = self.sess.get( + self.login_url, headers=self.headers, timeout=self.timeout + ) + if req_csrf.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + # 获取csrf_token + doc = pq(req_csrf.text) + csrf_token = doc("#csrftoken").attr("value") + pre_cookies = self.sess.cookies.get_dict() + # 获取publicKey并加密密码 + req_pubkey = self.sess.get( + self.key_url, headers=self.headers, timeout=self.timeout + ).json() + modulus = req_pubkey["modulus"] + exponent = req_pubkey["exponent"] + if str(doc("input#yzm")) == "": + # 不需要验证码 + encrypt_password = self.encrypt_password(password, modulus, exponent) + # 登录数据 + login_data = { + "csrftoken": csrf_token, + "yhm": sid, + "mm": encrypt_password, + } + # 请求登录 + req_login = self.sess.post( + self.login_url, + headers=self.headers, + data=login_data, + timeout=self.timeout, + ) + doc = pq(req_login.text) + tips = doc("p#tips") + if str(tips) != "": + if "用户名或密码" in tips.text(): + return {"code": 1002, "msg": "用户名或密码不正确"} + return {"code": 998, "msg": tips.text()} + self.cookies = self.sess.cookies.get_dict() + return {"code": 1000, "msg": "登录成功", "data": {"cookies": self.cookies}} + # 需要验证码,返回相关页面验证信息给用户,TODO: 增加更多验证方式 + need_verify = True + req_kaptcha = self.sess.get( + self.kaptcha_url, headers=self.headers, timeout=self.timeout + ) + kaptcha_pic = base64.b64encode(req_kaptcha.content).decode() + return { + "code": 1001, + "msg": "获取验证码成功", + "data": { + "sid": sid, + "csrf_token": csrf_token, + "cookies": pre_cookies, + "password": password, + "modulus": modulus, + "exponent": exponent, + "kaptcha_pic": kaptcha_pic, + "timestamp": time.time(), + }, + } + except exceptions.Timeout: + msg = "获取验证码超时" if need_verify else "登录超时" + return {"code": 1003, "msg": msg} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + msg = "获取验证码时未记录的错误" if need_verify else "登录时未记录的错误" + return {"code": 999, "msg": f"{msg}:{str(e)}"} + + def login_with_kaptcha( + self, sid, csrf_token, cookies, password, modulus, exponent, kaptcha, **kwargs + ): + """需要验证码的登陆""" + try: + encrypt_password = self.encrypt_password(password, modulus, exponent) + login_data = { + "csrftoken": csrf_token, + "yhm": sid, + "mm": encrypt_password, + "yzm": kaptcha, + } + req_login = self.sess.post( + self.login_url, + headers=self.headers, + cookies=cookies, + data=login_data, + timeout=self.timeout, + ) + if req_login.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + # 请求登录 + doc = pq(req_login.text) + tips = doc("p#tips") + if str(tips) != "": + if "验证码" in tips.text(): + return {"code": 1004, "msg": "验证码输入错误"} + if "用户名或密码" in tips.text(): + return {"code": 1002, "msg": "用户名或密码不正确"} + return {"code": 998, "msg": tips.text()} + self.cookies = self.sess.cookies.get_dict() + # 不同学校系统兼容差异 + if not self.cookies.get("route"): + route_cookies = { + "JSESSIONID": self.cookies["JSESSIONID"], + "route": cookies["route"], + } + self.cookies = route_cookies + else: + return {"code": 1000, "msg": "登录成功", "data": {"cookies": self.cookies}} + except exceptions.Timeout: + return {"code": 1003, "msg": "登录超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "验证码登录时未记录的错误:" + str(e)} + + def get_info(self): + """获取个人信息""" + url = urljoin(self.base_url, "xsxxxggl/xsxxwh_cxCkDgxsxx.html?gnmkdm=N100801") + try: + req_info = self.sess.get( + url, + headers=self.headers, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_info.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_info.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + info = req_info.json() + if info is None: + return self._get_info() + result = { + "sid": info.get("xh"), + "name": info.get("xm"), + "college_name": info.get("zsjg_id", info.get("jg_id")), + "major_name": info.get("zszyh_id", info.get("zyh_id")), + "class_name": info.get("bh_id", info.get("xjztdm")), + "status": info.get("xjztdm"), + "enrollment_date": info.get("rxrq"), + "candidate_number": info.get("ksh"), + "graduation_school": info.get("byzx"), + "domicile": info.get("jg"), + "postal_code": info.get("yzbm"), + "politics_status": info.get("zzmmm"), + "nationality": info.get("mzm"), + "education": info.get("pyccdm"), + "phone_number": info.get("sjhm"), + "parents_number": info.get("gddh"), + "email": info.get("dzyx"), + "birthday": info.get("csrq"), + "id_number": info.get("zjhm"), + } + return {"code": 1000, "msg": "获取个人信息成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取个人信息超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "获取个人信息时未记录的错误:" + str(e)} + + def _get_info(self): + """获取个人信息""" + url = urljoin(self.base_url, "xsxxxggl/xsgrxxwh_cxXsgrxx.html?gnmkdm=N100801") + try: + req_info = self.sess.get( + url, headers=self.headers, cookies=self.cookies, timeout=self.timeout + ) + if req_info.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_info.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + pending_result = {} + # 学生基本信息 + for ul_item in doc.find("div.col-sm-6").items(): + content = pq(ul_item).find("div.form-group") + # key = re.findall(r'^[\u4E00-\u9FA5A-Za-z0-9]+', pq(content).find('label.col-sm-4.control-label').text())[0] + key = pq(content).find("label.col-sm-4.control-label").text() + value = pq(content).find("div.col-sm-8 p.form-control-static").text() + # 到这一步,解析到的数据基本就是一个键值对形式的html数据了,比如"[学号:]:123456" + pending_result[key] = value + # 学生学籍信息,其他信息,联系方式 + for ul_item in doc.find("div.col-sm-4").items(): + content = pq(ul_item).find("div.form-group") + key = pq(content).find("label.col-sm-4.control-label").text() + value = pq(content).find("div.col-sm-8 p.form-control-static").text() + # 到这一步,解析到的数据基本就是一个键值对形式的html数据了,比如"[学号:]:123456" + pending_result[key] = value + if pending_result.get("学号:") == "": + return { + "code": 1014, + "msg": "当前学年学期无学生时盒数据,您可能已经毕业了。\n\n如果是专升本同学,请使用专升本后的新学号登录~", + } + result = { + "sid": pending_result["学号:"], + "name": pending_result["姓名:"], + # "birthday": "无" if pending_result.get("出生日期:") == '' else pending_result["出生日期:"], + # "id_number": "无" if pending_result.get("证件号码:") == '' else pending_result["证件号码:"], + # "candidate_number": "无" if pending_result.get("考生号:") == '' else pending_result["考生号:"], + # "status": "无" if pending_result.get("学籍状态:") == '' else pending_result["学籍状态:"], + # "entry_date": "无" if pending_result.get("入学日期:") == '' else pending_result["入学日期:"], + # "graduation_school": "无" if pending_result.get("毕业中学:") == '' else pending_result["毕业中学:"], + "domicile": "无" + if pending_result.get("籍贯:") == "" + else pending_result["籍贯:"], + "phone_number": "无" + if pending_result.get("手机号码:") == "" + else pending_result["手机号码:"], + "parents_number": "无", + "email": "无" + if pending_result.get("电子邮箱:") == "" + else pending_result["电子邮箱:"], + "political_status": "无" + if pending_result.get("政治面貌:") == "" + else pending_result["政治面貌:"], + "national": "无" + if pending_result.get("民族:") == "" + else pending_result["民族:"], + # "education": "无" if pending_result.get("培养层次:") == '' else pending_result["培养层次:"], + # "postal_code": "无" if pending_result.get("邮政编码:") == '' else pending_result["邮政编码:"], + # "grade": int(pending_result["学号:"][0:4]), + } + if pending_result.get("学院名称:") is not None: + # 如果在个人信息页面获取到了学院班级 + result.update( + { + "college_name": "无" + if pending_result.get("学院名称:") == "" + else pending_result["学院名称:"], + "major_name": "无" + if pending_result.get("专业名称:") == "" + else pending_result["专业名称:"], + "class_name": "无" + if pending_result.get("班级名称:") == "" + else pending_result["班级名称:"], + } + ) + else: + # 如果个人信息页面获取不到学院班级,则此处需要请求另外一个地址以获取学院、专业、班级等信息 + _url = urljoin( + self.base_url, + "xszbbgl/xszbbgl_cxXszbbsqIndex.html?doType=details&gnmkdm=N106005", + ) + _req_info = self.sess.post( + _url, + headers=self.headers, + cookies=self.cookies, + timeout=self.timeout, + data={"offDetails": "1", "gnmkdm": "N106005", "czdmKey": "00"}, + ) + _doc = pq(_req_info.text) + if _doc("p.error_title").text() != "无功能权限,": + # 通过学生证补办申请入口,来补全部分信息 + for ul_item in _doc.find("div.col-sm-6").items(): + content = pq(ul_item).find("div.form-group") + key = ( + pq(content).find("label.col-sm-4.control-label").text() + + ":" + ) # 为了保持格式一致,这里加个冒号 + value = ( + pq(content).find("div.col-sm-8 label.control-label").text() + ) + # 到这一步,解析到的数据基本就是一个键值对形式的html数据了,比如"[学号:]:123456" + pending_result[key] = value + result.update( + { + "college_name": "无" + if pending_result.get("学院:") is None + else pending_result["学院:"], + "major_name": "无" + if pending_result.get("专业:") is None + else pending_result["专业:"], + "class_name": "无" + if pending_result.get("班级:") is None + else pending_result["班级:"], + } + ) + return {"code": 1000, "msg": "获取个人信息成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取个人信息超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "获取个人信息时未记录的错误:" + str(e)} + + def get_grade(self, year: int, term: int = 0, use_personal_info: bool = False): + """ + 获取成绩 + use_personal_info: 是否使用获取个人信息接口获取成绩 + """ + url = urljoin( + self.base_url, + "cjcx/cjcx_cxDgXscj.html?doType=query&gnmkdm=N305005" + if use_personal_info + else "cjcx/cjcx_cxXsgrcj.html?doType=query&gnmkdm=N305005", + ) + temp_term = term + term = term**2 * 3 + term = "" if term == 0 else term + data = { + "xnm": str(year), # 学年数 + "xqm": str(term), # 学期数,第一学期为3,第二学期为12, 整个学年为空'' + "_search": "false", + "nd": int(time.time() * 1000), + "queryModel.showCount": "100", # 每页最多条数 + "queryModel.currentPage": "1", + "queryModel.sortName": "", + "queryModel.sortOrder": "asc", + "time": "0", # 查询次数 + } + try: + req_grade = self.sess.post( + url, + headers=self.headers, + data=data, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_grade.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_grade.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + grade = req_grade.json() + grade_items = grade.get("items") + if not grade_items: + return {"code": 1005, "msg": "获取内容为空"} + result = { + "sid": grade_items[0]["xh"], + "name": grade_items[0]["xm"], + "year": year, + "term": temp_term, + "count": len(grade_items), + "courses": [ + { + "course_id": i.get("kch_id"), + "title": i.get("kcmc"), + "teacher": i.get("jsxm"), + "class_name": i.get("jxbmc"), + "credit": self.align_floats(i.get("xf")), + "category": i.get("kclbmc"), + "nature": i.get("kcxzmc"), + "grade": self.parse_int(i.get("cj")), + "grade_point": self.align_floats(i.get("jd")), + "grade_nature": i.get("ksxz"), + "start_college": i.get("kkbmmc"), + "mark": i.get("kcbj"), + } + for i in grade_items + ], + } + return {"code": 1000, "msg": "获取成绩成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取成绩超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "获取成绩时未记录的错误:" + str(e)} + + def get_schedule(self, year: int, term: int): + """获取课程表信息""" + url = urljoin(self.base_url, "kbcx/xskbcx_cxXsKb.html?gnmkdm=N2151") + temp_term = term + term = term**2 * 3 + data = {"xnm": str(year), "xqm": str(term)} + try: + req_schedule = self.sess.post( + url, + headers=self.headers, + data=data, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_schedule.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_schedule.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + schedule = req_schedule.json() + if not schedule.get("kbList"): + return {"code": 1005, "msg": "获取内容为空"} + result = { + "sid": schedule["xsxx"].get("XH"), + "name": schedule["xsxx"].get("XM"), + "year": year, + "term": temp_term, + "count": len(schedule["kbList"]), + "courses": [ + { + "course_id": i.get("kch_id"), + "title": i.get("kcmc"), + "teacher": i.get("xm"), + "class_name": i.get("jxbmc"), + "credit": self.align_floats(i.get("xf")), + "weekday": self.parse_int(i.get("xqj")), + "time": self.display_course_time(i.get("jc")), + "sessions": i.get("jc"), + "list_sessions": self.list_sessions(i.get("jc")), + "weeks": i.get("zcd"), + "list_weeks": self.list_weeks(i.get("zcd")), + "evaluation_mode": i.get("khfsmc"), + "campus": i.get("xqmc"), + "place": i.get("cdmc"), + "hours_composition": i.get("kcxszc"), + "weekly_hours": self.parse_int(i.get("zhxs")), + "total_hours": self.parse_int(i.get("zxs")), + } + for i in schedule["kbList"] + ], + "extra_courses": [i.get("qtkcgs") for i in schedule.get("sjkList")], + } + result = self.split_merge_display(result) + return {"code": 1000, "msg": "获取课表成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取课表超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "获取课表时未记录的错误:" + str(e)} + + def get_academia(self): + """获取学业生涯情况""" + url_main = urljoin( + self.base_url, + "xsxy/xsxyqk_cxXsxyqkIndex.html?gnmkdm=N105515&layout=default", + ) + url_info = urljoin( + self.base_url, "xsxy/xsxyqk_cxJxzxjhxfyqKcxx.html?gnmkdm=N105515" + ) + try: + req_main = self.sess.get( + url_main, + headers=self.headers, + cookies=self.cookies, + timeout=self.timeout, + stream=True, + ) + if req_main.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc_main = pq(req_main.text) + if doc_main("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + if str(doc_main("div.alert-danger")) != "": + return {"code": 998, "msg": doc_main("div.alert-danger").text()} + sid = doc_main("form#form input#xh_id").attr("value") + display_statistics = ( + doc_main("div#alertBox").text().replace(" ", "").replace("\n", "") + ) + sid = doc_main("input#xh_id").attr("value") + statistics = self.get_academia_statistics(display_statistics) + type_statistics = self.get_academia_type_statistics(req_main.text) + details = {} + for type in type_statistics.keys(): + details[type] = self.sess.post( + url_info, + headers=self.headers, + data={"xfyqjd_id": type_statistics[type]["id"]}, + cookies=self.cookies, + timeout=self.timeout, + stream=True, + ).json() + result = { + "sid": sid, + "statistics": statistics, + "details": [ + { + "type": type, + "credits": type_statistics[type]["credits"], + "courses": [ + { + "course_id": i.get("KCH"), + "title": i.get("KCMC"), + "situation": self.parse_int(i.get("XDZT")), + "display_term": self.get_display_term( + sid, i.get("JYXDXNM"), i.get("JYXDXQMC") + ), + "credit": self.align_floats(i.get("XF")), + "category": self.get_course_category(type, i), + "nature": i.get("KCXZMC"), + "max_grade": self.parse_int(i.get("MAXCJ")), + "grade_point": self.align_floats(i.get("JD")), + } + for i in details[type] + ], + } + for type in type_statistics.keys() + if len(details[type]) > 0 + ], + } + return {"code": 1000, "msg": "获取学业情况成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取学业情况超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "获取学业情况时未记录的错误:" + str(e)} + + def get_academia_pdf(self): + """获取学业生涯(学生成绩总表)pdf""" + url_view = urljoin(self.base_url, "bysxxcx/xscjzbdy_dyXscjzbView.html") + url_window = urljoin(self.base_url, "bysxxcx/xscjzbdy_dyCjdyszxView.html") + url_policy = urljoin(self.base_url, "xtgl/bysxxcx/xscjzbdy_cxXsCount.html") + url_filetype = urljoin(self.base_url, "bysxxcx/xscjzbdy_cxGswjlx.html") + url_common = urljoin(self.base_url, "common/common_cxJwxtxx.html") + url_file = urljoin(self.base_url, "bysxxcx/xscjzbdy_dyList.html") + url_progress = urljoin(self.base_url, "xtgl/progress_cxProgressStatus.html") + data = { + "gsdygx": "10628-zw-mrgs", + "ids": "", + "bdykcxzDms": "", + "cytjkcxzDms": "", + "cytjkclbDms": "", + "cytjkcgsDms": "", + "bjgbdykcxzDms": "", + "bjgbdyxxkcxzDms": "", + "djksxmDms": "", + "cjbzmcDms": "", + "cjdySzxs": "", + "wjlx": "pdf", + } + + try: + data_view = {"time": str(round(time.time() * 1000)), "gnmkdm": "N558020"} + data_params = data_view + del data_params["time"] + # View接口 + req_view = self.sess.post( + url_view, + headers=self.headers, + data=data_view, + params=data_view, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_view.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_view.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + # Window接口 + data_window = {"xh": ""} + self.sess.post( + url_window, + headers=self.headers, + data=data_window, + params=data_params, + cookies=self.cookies, + timeout=self.timeout, + ) + # 许可接口 + data_policy = data + del data_policy["wjlx"] + self.sess.post( + url_policy, + headers=self.headers, + data=data_policy, + params=data_params, + cookies=self.cookies, + timeout=self.timeout, + ) + # 文件类型接口 + data_filetype = data_policy + self.sess.post( + url_filetype, + headers=self.headers, + data=data_filetype, + params=data_params, + cookies=self.cookies, + timeout=self.timeout, + ) + # Common接口 + self.sess.post( + url_common, + headers=self.headers, + data=data_params, + params=data_params, + cookies=self.cookies, + timeout=self.timeout, + ) + # 获取PDF文件URL + req_file = self.sess.post( + url_file, + headers=self.headers, + data=data, + params=data_params, + cookies=self.cookies, + timeout=self.timeout, + ) + doc = pq(req_file.text) + if "错误" in doc("title").text(): + error = doc("p.error_title").text() + return {"code": 998, "msg": error} + # 进度接口 + data_progress = { + "key": "score_print_processed", + "gnmkdm": "N558020", + } + self.sess.post( + url_progress, + headers=self.headers, + data=data_progress, + params=data_progress, + cookies=self.cookies, + timeout=self.timeout, + ) + # 生成PDF文件URL + pdf = ( + req_file.text.replace("#成功", "") + .replace('"', "") + .replace("/", "\\") + .replace("\\\\", "/") + ) + # 下载PDF文件 + req_pdf = self.sess.get( + urljoin(self.base_url, pdf), + headers=self.headers, + cookies=self.cookies, + timeout=self.timeout + 2, + ) + result = req_pdf.content # 二进制内容 + return {"code": 1000, "msg": "获取学生成绩总表pdf成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取成绩总表pdf超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "获取成绩总表pdf时未记录的错误:" + str(e)} + + def get_schedule_pdf(self, year: int, term: int, name: str = "导出"): + """获取课表pdf""" + url_policy = urljoin(self.base_url, "kbdy/bjkbdy_cxXnxqsfkz.html") + url_file = urljoin(self.base_url, "kbcx/xskbcx_cxXsShcPdf.html") + origin_term = term + term = term**2 * 3 + data = { + "xm": name, + "xnm": str(year), + "xqm": str(term), + "xnmc": f"{year}-{year + 1}", + "xqmmc": str(origin_term), + "jgmc": "undefined", + "xxdm": "", + "xszd.sj": "true", + "xszd.cd": "true", + "xszd.js": "true", + "xszd.jszc": "false", + "xszd.jxb": "true", + "xszd.xkbz": "true", + "xszd.kcxszc": "true", + "xszd.zhxs": "true", + "xszd.zxs": "true", + "xszd.khfs": "true", + "xszd.xf": "true", + "xszd.skfsmc": "false", + "kzlx": "dy", + } + + try: + # 许可接口 + pilicy_params = {"gnmkdm": "N2151"} + req_policy = self.sess.post( + url_policy, + headers=self.headers, + data=data, + params=pilicy_params, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_policy.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_policy.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + # 获取PDF文件URL + file_params = {"doType": "table"} + req_file = self.sess.post( + url_file, + headers=self.headers, + data=data, + params=file_params, + cookies=self.cookies, + timeout=self.timeout, + ) + doc = pq(req_file.text) + if "错误" in doc("title").text(): + error = doc("p.error_title").text() + return {"code": 998, "msg": error} + result = req_file.content # 二进制内容 + return {"code": 1000, "msg": "获取课程表pdf成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取课程表pdf超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "获取课程表pdf时未记录的错误:" + str(e)} + + def get_notifications(self): + """获取通知消息""" + url = urljoin(self.base_url, "xtgl/index_cxDbsy.html?doType=query") + data = { + "sfyy": "0", # 是否已阅,未阅未1,已阅为2 + "flag": "1", + "_search": "false", + "nd": int(time.time() * 1000), + "queryModel.showCount": "1000", # 最多条数 + "queryModel.currentPage": "1", # 当前页数 + "queryModel.sortName": "cjsj", + "queryModel.sortOrder": "desc", # 时间倒序, asc正序 + "time": "0", + } + try: + req_notification = self.sess.post( + url, + headers=self.headers, + data=data, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_notification.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_notification.text) + if doc("h5").text() == "用户登录" or "错误" in doc("title").text(): + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + notifications = req_notification.json() + result = [ + {**self.split_notifications(i), "create_time": i.get("cjsj")} + for i in notifications.get("items") + ] + return {"code": 1000, "msg": "获取消息成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取消息超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": "获取消息时未记录的错误:" + str(e)} + + def get_selected_courses(self, year: int, term: int): + """获取已选课程信息""" + try: + url = urljoin( + self.base_url, + "xsxk/zzxkyzb_cxZzxkYzbChoosedDisplay.html?gnmkdm=N253512", + ) + temp_term = term + term = term**2 * 3 + data = {"xkxnm": str(year), "xkxqm": str(term)} + req_selected = self.sess.post( + url, + data=data, + headers=self.headers, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_selected.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_selected.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + selected = req_selected.json() + result = { + "year": year, + "term": temp_term, + "count": len(selected), + "courses": [ + { + "course_id": i.get("kch"), + "class_id": i.get("jxb_id"), + "do_id": i.get("do_jxb_id"), + "title": i.get("kcmc"), + "teacher_id": (re.findall(r"(.*?\d+)/", i.get("jsxx")))[0], + "teacher": (re.findall(r"/(.*?)/", i.get("jsxx")))[0], + "credit": float(i.get("xf", 0)), + "category": i.get("kklxmc"), + "capacity": int(i.get("jxbrs", 0)), + "selected_number": int(i.get("yxzrs", 0)), + "place": self.get_place(i.get("jxdd")), + "time": self.get_course_time(i.get("sksj")), + "optional": int(i.get("zixf", 0)), + "waiting": i.get("sxbj"), + } + for i in selected + ], + } + return {"code": 1000, "msg": "获取已选课程成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取已选课程超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": f"获取已选课程时未记录的错误:{str(e)}"} + + def get_block_courses(self, year: int, term: int, block: int): + """获取板块课选课列表""" + # TODO: 优化代码 + try: + # 获取head_data + url_head = urljoin( + self.base_url, + "xsxk/zzxkyzb_cxZzxkYzbIndex.html?gnmkdm=N253512&layout=default", + ) + req_head_data = self.sess.get( + url_head, + headers=self.headers, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_head_data.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_head_data.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + if str(doc("div.nodata")) != "": + return {"code": 998, "msg": doc("div.nodata").text()} + got_credit_list = [i for i in doc("font[color='red']").items()] + if len(got_credit_list) == 0: + return {"code": 1005, "msg": "板块课内容为空"} + head_data = {"got_credit": got_credit_list[2].string} + + kklxdm_list = [] + xkkz_id_list = [] + for tab_content in doc("a[role='tab']").items(): + onclick_content = tab_content.attr("onclick") + r = re.findall(r"'(.*?)'", str(onclick_content)) + kklxdm_list.append(r[0].strip()) + xkkz_id_list.append(r[1].strip()) + head_data["bkk1_kklxdm"] = kklxdm_list[0] + head_data["bkk2_kklxdm"] = kklxdm_list[1] + head_data["bkk3_kklxdm"] = kklxdm_list[2] + head_data["bkk1_xkkz_id"] = xkkz_id_list[0] + head_data["bkk2_xkkz_id"] = xkkz_id_list[1] + head_data["bkk3_xkkz_id"] = xkkz_id_list[2] + + for head_data_content in doc("input[type='hidden']"): + name = head_data_content.attr("name") + value = head_data_content.attr("value") + head_data[str(name)] = str(value) + + url_display = urljoin( + self.base_url, "xsxk/zzxkyzb_cxZzxkYzbDisplay.html?gnmkdm=N253512" + ) + display_req_data = { + "xkkz_id": head_data[f"bkk{block}_xkkz_id"], + "xszxzt": "1", + "kspage": "0", + } + req_display_data = self.sess.post( + url_display, + headers=self.headers, + data=display_req_data, + cookies=self.cookies, + timeout=self.timeout, + ) + doc_display = pq(req_display_data.text) + display_data = {} + for display_data_content in doc_display("input[type='hidden']").items(): + name = display_data_content.get("name") + value = display_data_content.get("value") + display_data[str(name)] = str(value) + head_data.update(display_data) + + # 获取课程列表 + url_kch = urljoin( + self.base_url, "xsxk/zzxkyzb_cxZzxkYzbPartDisplay.html?gnmkdm=N253512" + ) + url_bkk = urljoin( + self.base_url, "xsxk/zzxkyzb_cxJxbWithKchZzxkYzb.html?gnmkdm=N253512" + ) + term = term**2 * 3 + kch_data = { + "bklx_id": head_data["bklx_id"], + "xqh_id": head_data["xqh_id"], + "zyfx_id": head_data["zyfx_id"], + "njdm_id": head_data["njdm_id"], + "bh_id": head_data["bh_id"], + "xbm": head_data["xbm"], + "xslbdm": head_data["xslbdm"], + "ccdm": head_data["ccdm"], + "xsbj": head_data["xsbj"], + "xkxnm": str(year), + "xkxqm": str(term), + "kklxdm": head_data[f"bkk{block}_kklxdm"], + "kkbk": head_data["kkbk"], + "rwlx": head_data["rwlx"], + "kspage": "1", + "jspage": "10", + } + kch_res = self.sess.post( + url_kch, + headers=self.headers, + data=kch_data, + cookies=self.cookies, + timeout=self.timeout, + ) + jkch_res = kch_res.json() + bkk_data = { + "bklx_id": head_data["bklx_id"], + "xkxnm": str(year), + "xkxqm": str(term), + "xkkz_id": head_data[f"bkk{block}_xkkz_id"], + "xqh_id": head_data["xqh_id"], + "zyfx_id": head_data["zyfx_id"], + "njdm_id": head_data["njdm_id"], + "bh_id": head_data["bh_id"], + "xbm": head_data["xbm"], + "xslbdm": head_data["xslbdm"], + "ccdm": head_data["ccdm"], + "xsbj": head_data["xsbj"], + "kklxdm": head_data[f"bkk{block}_kklxdm"], + "kch_id": jkch_res["tmpList"][0]["kch_id"], + "kkbk": head_data["kkbk"], + "rwlx": head_data["rwlx"], + "zyh_id": head_data["zyh_id"], + } + bkk_res = self.sess.post( + url_bkk, + headers=self.headers, + data=bkk_data, + cookies=self.cookies, + timeout=self.timeout, + ) + jbkk_res = bkk_res.json() + if block != 3 and (len(jkch_res["tmpList"]) != len(jbkk_res)): + return {"code": 999, "msg": "板块课编号及长度错误"} + temp_list = jkch_res["tmpList"] + block_list = jbkk_res + for i in range(len(temp_list)): + temp_list[i].update(block_list[i]) + + result = { + "count": len(temp_list), + "courses": [ + { + "course_id": j["kch_id"], + "class_id": j.get("jxb_id"), + "do_id": j.get("do_jxb_id"), + "title": j.get("kcmc"), + "teacher_id": (re.findall(r"(.*?\d+)/", j.get("jsxx")))[0], + "teacher": (re.findall(r"/(.*?)/", j.get("jsxx")))[0], + "credit": float(j.get("xf"), 0), + "kklxdm": head_data[f"bkk{block}_kklxdm"], + "capacity": int(i.get("jxbrl", 0)), + "selected_number": int(i.get("yxzrs", 0)), + "place": self.get_place(i.get("jxdd")), + "time": self.get_course_time(i.get("sksj")), + } + for j in temp_list + ], + } + return {"code": 1000, "msg": "获取板块课信息成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "获取板块课信息超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": f"获取板块课信息时未记录的错误:{str(e)}"} + + def select_course( + self, + sid: str, + course_id: str, + do_id: str, + kklxdm: str, + year: int, + term: int, + ): + """选课""" + try: + url_select = urljoin( + self.base_url, "xsxk/zzxkyzb_xkBcZyZzxkYzb.html?gnmkdm=N253512" + ) + term = term**2 * 3 + select_data = { + "jxb_ids": do_id, + "kch_id": course_id, + # 'rwlx': '3', + # 'rlkz': '0', + # 'rlzlkz': '1', + # 'sxbj': '1', + # 'xxkbj': '0', + # 'cxbj': '0', + "qz": "0", + # 'xkkz_id': '9B247F4EFD6291B9E055000000000001', + "xkxnm": str(year), + "xkxqm": str(term), + "njdm_id": str(sid[0:2]), + "zyh_id": str(sid[2:6]), + "kklxdm": str(kklxdm), + # 'xklc': '1', + } + req_select = self.sess.post( + url_select, + headers=self.headers, + data=select_data, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_select.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_select.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + result = req_select.json() + return {"code": 1000, "msg": "选课成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "选课超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": f"选课时未记录的错误:{str(e)}"} + + def cancel_course(self, do_id: str, course_id: str, year: int, term: int): + """取消选课""" + try: + url_cancel = urljoin( + self.base_url, "xsxk/zzxkyzb_tuikBcZzxkYzb.html?gnmkdm=N253512" + ) + term = term**2 * 3 + cancel_data = { + "jxb_ids": do_id, + "kch_id": course_id, + "xkxnm": str(year), + "xkxqm": str(term), + } + req_cancel = self.sess.post( + url_cancel, + headers=self.headers, + data=cancel_data, + cookies=self.cookies, + timeout=self.timeout, + ) + if req_cancel.status_code != 200: + return {"code": 2333, "msg": "教务系统挂了"} + doc = pq(req_cancel.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + result = {"status": re.findall(r"(\d+)", req_cancel.text)[0]} + return {"code": 1000, "msg": "退课成功", "data": result} + except exceptions.Timeout: + return {"code": 1003, "msg": "选课超时"} + except ( + exceptions.RequestException, + json.decoder.JSONDecodeError, + AttributeError, + ): + traceback.print_exc() + return {"code": 2333, "msg": "请重试,若多次失败可能是系统错误维护或需更新接口"} + except Exception as e: + traceback.print_exc() + return {"code": 999, "msg": f"选课时未记录的错误:{str(e)}"} + + # ============= utils ================= + + def get_gpa(self): + """获取GPA""" + url = urljoin( + self.base_url, + "xsxy/xsxyqk_cxXsxyqkIndex.html?gnmkdm=N105515&layout=default", + ) + req_gpa = self.sess.get( + url, + headers=self.headers, + cookies=self.cookies, + timeout=self.timeout, + ) + doc = pq(req_gpa.text) + if doc("h5").text() == "用户登录": + return {"code": 1006, "msg": "未登录或已过期,请重新登录"} + allc_str = [allc.text() for allc in doc("font[size='2px']").items()] + try: + gpa = float(allc_str[2]) + return gpa + except Exception: + return "init" + + def get_course_category(self, type, item): + """根据课程号获取类别""" + if type not in self.detail_category_type: + return item.get("KCLBMC") + if not item.get("KCH"): + return None + url = urljoin(self.base_url, f"jxjhgl/common_cxKcJbxx.html?id={item['KCH']}") + req_category = self.sess.get( + url, + headers=self.headers, + cookies=self.cookies, + timeout=self.timeout, + ) + doc = pq(req_category.text) + ths = doc("th") + try: + data_list = [(th.text).strip() for th in ths] + return data_list[6] + except: + return None + + @classmethod + def encrypt_password(cls, pwd, n, e): + """对密码base64编码""" + message = str(pwd).encode() + rsa_n = binascii.b2a_hex(binascii.a2b_base64(n)) + rsa_e = binascii.b2a_hex(binascii.a2b_base64(e)) + key = rsa.PublicKey(int(rsa_n, 16), int(rsa_e, 16)) + encropy_pwd = rsa.encrypt(message, key) + result = binascii.b2a_base64(encropy_pwd) + return result + + @classmethod + def parse_int(cls, digits): + if not digits: + return None + if not digits.isdigit(): + return digits + return int(digits) + + @classmethod + def align_floats(cls, floats): + if not floats: + return None + if floats == "无": + return "0.0" + return format(float(floats), ".1f") + + @classmethod + def display_course_time(cls, sessions): + if not sessions: + return None + args = re.findall(r"(\d+)", sessions) + start_time = cls.raspisanie[int(args[0]) + 1][0] + end_time = cls.raspisanie[int(args[0]) + 1][1] + return f"{start_time}~{end_time}" + + @classmethod + def list_sessions(cls, sessions): + if not sessions: + return None + args = re.findall(r"(\d+)", sessions) + return [n for n in range(int(args[0]), int(args[1]) + 1)] + + @classmethod + def list_weeks(cls, weeks): + """返回课程所含周列表""" + if not weeks: + return None + args = re.findall(r"[^,]+", weeks) + week_list = [] + for item in args: + if "-" in item: + weeks_pair = re.findall(r"(\d+)", item) + if len(weeks_pair) != 2: + continue + if "单" in item: + for i in range(int(weeks_pair[0]), int(weeks_pair[1]) + 1): + if i % 2 == 1: + week_list.append(i) + elif "双" in item: + for i in range(int(weeks_pair[0]), int(weeks_pair[1]) + 1): + if i % 2 == 0: + week_list.append(i) + else: + for i in range(int(weeks_pair[0]), int(weeks_pair[1]) + 1): + week_list.append(i) + else: + week_num = re.findall(r"(\d+)", item) + if len(week_num) == 1: + week_list.append(int(week_num[0])) + return week_list + + @classmethod + def get_academia_statistics(cls, display_statistics): + display_statistics = "".join(display_statistics.split()) + gpa_list = re.findall(r"([0-9]{1,}[.][0-9]*)", display_statistics) + if len(gpa_list) == 0 or not cls.is_number(gpa_list[0]): + gpa = None + else: + gpa = float(gpa_list[0]) + plan_list = re.findall( + r"计划总课程(\d+)门通过(\d+)门?.*未通过(\d+)门?.*未修(\d+)?.*在读(\d+)门?.*计划外?.*通过(\d+)门?.*未通过(\d+)门", + display_statistics, + ) + if len(plan_list) == 0 or len(plan_list[0]) < 7: + return {"gpa": gpa} + plan_list = plan_list[0] + return { + "gpa": gpa, # 平均学分绩点GPA + "planed_courses": { + "total": int(plan_list[0]), # 计划内总课程数 + "passed": int(plan_list[1]), # 计划内已过课程数 + "failed": int(plan_list[2]), # 计划内未过课程数 + "missed": int(plan_list[3]), # 计划内未修课程数 + "in": int(plan_list[4]), # 计划内在读课程数 + }, + "unplaned_courses": { + "passed": int(plan_list[5]), # 计划外已过课程数 + "failed": int(plan_list[6]), # 计划外未过课程数 + }, + } + + @classmethod + def get_academia_type_statistics(cls, content: str): + finder = re.findall( + r"\"(.*) .*要求学分.*:([0-9]{1,}[.][0-9]*|0| ).*获得学分.*:([0-9]{1,}[.][0-9]*|0| ).*未获得学分.*:([0-9]{1,}[.][0-9]*|0| )[\s\S]*?", + content, + ) + finder_list = list({}.fromkeys(finder).keys()) + academia_list = [ + list(i) + for i in finder_list + if i[0] != "" # 类型名称不为空 + and len(i[0]) <= 20 # 避免正则到首部过长类型名称 + and "span" not in i[-1] # 避免正则到尾部过长类型名称 + and i[0] not in cls.ignore_type # 忽略的类型名称 + ] + result = { + i[0]: { + "id": i[-1], + "credits": { + "required": i[1] if cls.is_number(i[1]) and i[1] != "0" else None, + "earned": i[2] if cls.is_number(i[2]) and i[2] != "0" else None, + "missed": i[3] if cls.is_number(i[3]) and i[3] != "0" else None, + }, + } + for i in academia_list + } + return result + + @classmethod + def get_display_term(cls, sid, year, term): + """ + 计算培养方案具体学期转化成中文 + note: 留级和当兵等情况会不准确 + """ + if (sid and year and term) is None: + return None + grade = int(sid[0:2]) + year = int(year[2:4]) + term = int(term) + dict = { + grade: "大一上" if term == 1 else "大一下", + grade + 1: "大二上" if term == 1 else "大二下", + grade + 2: "大三上" if term == 1 else "大三下", + grade + 3: "大四上" if term == 1 else "大四下", + } + return dict.get(year) + + @classmethod + def split_merge_display(cls, schedule): + """ + 拆分同周同天同课程不同时段数据合并的问题 + """ + repetIndex = [] + count = 0 + for items in schedule["courses"]: + for index in range(len(schedule["courses"])): + if (schedule["courses"]).index(items) == count: # 如果对比到自己就忽略 + continue + elif ( + items["course_id"] + == schedule["courses"][index]["course_id"] # 同周同天同课程 + and items["weekday"] == schedule["courses"][index]["weekday"] + and items["weeks"] == schedule["courses"][index]["weeks"] + ): + repetIndex.append(index) # 满足条件记录索引 + count += 1 # 记录当前对比课程的索引 + if len(repetIndex) % 2 != 0: # 暂时考虑一天两个时段上同一门课,不满足条件不进行修改 + return schedule + for r in range(0, len(repetIndex), 2): # 索引数组两两成对,故步进2循环 + fir = repetIndex[r] + sec = repetIndex[r + 1] + if len(re.findall(r"(\d+)", schedule["courses"][fir]["sessions"])) == 4: + schedule["courses"][fir]["sessions"] = ( + re.findall(r"(\d+)", schedule["courses"][fir]["sessions"])[0] + + "-" + + re.findall(r"(\d+)", schedule["courses"][fir]["sessions"])[1] + + "节" + ) + schedule["courses"][fir]["list_sessions"] = cls.list_sessions( + schedule["courses"][fir]["sessions"] + ) + schedule["courses"][fir]["time"] = cls.display_course_time( + schedule["courses"][fir]["sessions"] + ) + + schedule["courses"][sec]["sessions"] = ( + re.findall(r"(\d+)", schedule["courses"][sec]["sessions"])[2] + + "-" + + re.findall(r"(\d+)", schedule["courses"][sec]["sessions"])[3] + + "节" + ) + schedule["courses"][sec]["list_sessions"] = cls.list_sessions( + schedule["courses"][sec]["sessions"] + ) + schedule["courses"][sec]["time"] = cls.display_course_time( + schedule["courses"][sec]["sessions"] + ) + return schedule + + @classmethod + def split_notifications(cls, item): + if not item.get("xxnr"): + return {"type": None, "content": None} + content_list = re.findall(r"(.*):(.*)", item["xxnr"]) + if len(content_list) == 0: + return {"type": None, "content": item["xxnr"]} + return {"type": content_list[0][0], "content": content_list[0][1]} + + @classmethod + def get_place(cls, place): + return place.split("
")[0] if "
" in place else place + + @classmethod + def get_course_time(cls, time): + return "、".join(time.split("
")) if "
" in time else time + + @classmethod + def is_number(cls, s): + if s == "": + return False + try: + float(s) + return True + except ValueError: + pass + try: + for i in s: + unicodedata.numeric(i) + return True + except (TypeError, ValueError): + pass + return False + + +if __name__ == "__main__": + from pprint import pprint + import json + import base64 + import sys + import os + + base_url = "https://xxxx.xxx.edu.cn" # 教务系统URL + sid = "123456" # 学号 + password = "abc654321" # 密码 + lgn_cookies = ( + { + # "insert_cookie": "", + # "route": "", + "JSESSIONID": "" + } + if False + else None + ) # cookies登录,调整成True使用cookies登录,反之使用密码登录 + test_year = 2022 # 查询学年 + test_term = 2 # 查询学期(1-上|2-下) + + # 初始化 + lgn = Client(lgn_cookies if lgn_cookies is not None else {}, base_url=base_url) + # 判断是否需要使用cookies登录 + if lgn_cookies is None: + # 登录 + pre_login = lgn.login(sid, password) + # 判断登录结果 + if pre_login["code"] == 1001: + # 需要验证码 + pre_dict = pre_login["data"] + with open(os.path.abspath("temp.json"), mode="w", encoding="utf-8") as f: + f.write(json.dumps(pre_dict)) + with open(os.path.abspath("kaptcha.png"), "wb") as pic: + pic.write(base64.b64decode(pre_dict["kaptcha_pic"])) + kaptcha = input("输入验证码:") + result = lgn.login_with_kaptcha( + pre_dict["sid"], + pre_dict["csrf_token"], + pre_dict["cookies"], + pre_dict["password"], + pre_dict["modulus"], + pre_dict["exponent"], + kaptcha, + ) + if result["code"] != 1000: + pprint(result) + sys.exit() + lgn_cookies = lgn.cookies + elif pre_login["code"] == 1000: + # 不需要验证码,直接登录 + lgn_cookies = lgn.cookies + else: + # 出错 + pprint(pre_login) + sys.exit() + + # 下面是各个函数调用,想调用哪个,取消注释即可 + """ 获取个人信息 """ + result = lgn.get_info() + + """ 获取成绩单PDF """ + # result = lgn.get_academia_pdf() + # if result["code"] == 1000: + # with open(os.path.abspath("grade.pdf"), "wb") as pdf: + # pdf.write(result["data"]) + # result = "已保存到本地" + + """ 获取学业情况 """ + # result = lgn.get_academia() + + """ 获取GPA """ + # result = lgn.get_gpa() + + """ 获取课程表 """ + # result = lgn.get_schedule(test_year, test_term) + + """ 获取成绩 """ + # result = lgn.get_grade(test_year, test_term) + + # 输出结果 + pprint(result) diff --git a/src/timemanagerapp/lib/wighets/AddCourseFormWidget.dart b/src/timemanagerapp/lib/wighets/AddCourseFormWidget.dart new file mode 100644 index 0000000..16eb08f --- /dev/null +++ b/src/timemanagerapp/lib/wighets/AddCourseFormWidget.dart @@ -0,0 +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 { + + CourseController courseController = CourseController(); + final GlobalKey _formKey = GlobalKey(); + 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 selectedDays = []; + + List> 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, // 设置globalKey,用于后面获取FormState + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, // 水平方向占满 + children: [ + 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( + 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( + 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( + 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: [ + 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('确定'), + ), + ], + ), + ], + ), + ), + ), + ); + } + +} \ No newline at end of file diff --git a/src/timemanagerapp/lib/wighets/AddScheduleWighet.dart b/src/timemanagerapp/lib/wighets/AddScheduleWighet.dart new file mode 100644 index 0000000..e69de29 diff --git a/src/timemanagerapp/lib/wighets/HomeWighet.dart b/src/timemanagerapp/lib/wighets/HomeWighet.dart new file mode 100644 index 0000000..b76cbde --- /dev/null +++ b/src/timemanagerapp/lib/wighets/HomeWighet.dart @@ -0,0 +1,32 @@ +import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:timemanagerapp/setting/Setting.dart'; +import 'package:timemanagerapp/util/GetCourseByLogin.dart'; +import 'package:timemanagerapp/wighets/AddCourseFormWidget.dart'; +import 'package:timemanagerapp/wighets/LoginWidget.dart'; +import 'package:timemanagerapp/wighets/TestWidget.dart'; +import 'package:timemanagerapp/wighets/TimetableWighet.dart'; + +class HomeWighet extends StatefulWidget { + final double deviceWidth; + const HomeWighet({Key? key, required this.deviceWidth}) : super(key: key); + + @override + _HomePageState createState() => _HomePageState(deviceWidth: deviceWidth); +} + +class _HomePageState extends State { + final double deviceWidth; + + _HomePageState({required this.deviceWidth}); + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + return TimetableWidget(); + + } +} \ No newline at end of file diff --git a/src/timemanagerapp/lib/wighets/LoginWidget.dart b/src/timemanagerapp/lib/wighets/LoginWidget.dart new file mode 100644 index 0000000..c6e0054 --- /dev/null +++ b/src/timemanagerapp/lib/wighets/LoginWidget.dart @@ -0,0 +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: [ + TextFormField( + decoration: InputDecoration( + labelText: '用户名', + ), + ), + SizedBox(height: 16.0), + TextFormField( + obscureText: true, // 密码输入框,隐藏文本 + decoration: InputDecoration( + labelText: '密码', + ), + ), + SizedBox(height: 24.0), + ElevatedButton( + onPressed: () { + // 在这里添加处理登录按钮点击事件的代码 + // 通常会验证用户名和密码,并执行相应的登录逻辑 + }, + child: Text('登录'), + ), + ], + ), + ), + ), + ); + } +} diff --git a/src/timemanagerapp/lib/wighets/RegisterWidget.dart b/src/timemanagerapp/lib/wighets/RegisterWidget.dart new file mode 100644 index 0000000..263b1bd --- /dev/null +++ b/src/timemanagerapp/lib/wighets/RegisterWidget.dart @@ -0,0 +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: [ + 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('注册'), + ), + ], + ), + ), + ), + ); + } +} diff --git a/src/timemanagerapp/lib/wighets/SpaceWidget.dart b/src/timemanagerapp/lib/wighets/SpaceWidget.dart new file mode 100644 index 0000000..1903140 --- /dev/null +++ b/src/timemanagerapp/lib/wighets/SpaceWidget.dart @@ -0,0 +1,27 @@ +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, + ); + } +} diff --git a/src/timemanagerapp/lib/wighets/TestWidget.dart b/src/timemanagerapp/lib/wighets/TestWidget.dart new file mode 100644 index 0000000..aec88c2 --- /dev/null +++ b/src/timemanagerapp/lib/wighets/TestWidget.dart @@ -0,0 +1,275 @@ +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 { + + 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( + 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) { + return AddCourseRoute(); //改成任务 + }, + ), + ); + }, + child: Text('添加任务'), + ), + const SizedBox(height: 10), + ], + ), + ); + }, + ); + }, + ), + IconButton( + icon: const Icon(Icons.more), + onPressed: () {}, + ), + IconButton( + icon: const Icon(Icons.group_add), + onPressed: () {}, + ), + IconButton( + icon: const Icon(Icons.more_horiz), + onPressed: () { + Scaffold.of(context).openEndDrawer(); // Open the right drawer + }, + ), + ], + ), + endDrawer: Drawer( + // Use endDrawer to place the drawer on the right side + child: Column( + children: [ + UserAccountsDrawerHeader( + accountName: Text('Username'), + accountEmail: Text('user@example.com'), + ), + ListTile( + title: Text('删除用户'), + onTap: () { + Navigator.pop(context); // Close the drawer + userController.deleteAllUsers(); + }, + ), + ListTile( + title: Text('插入用户'), + onTap: () { + Navigator.pop(context); // Close the drawer + userController.insertUser(User( + teamId: 3231, + username: "嘉豪急啊急啊", + password: "23243", + role: 2341, + )); + }, + ), + ListTile( + title: Text('获取用户列表'), + onTap: () { + Navigator.pop(context); // Close the drawer + userController.getUsers().then((users) { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text('用户列表'), + content: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + children: users + .map((user) => ListTile( + title: Text(user['username']), + subtitle: Text(user.toString()), + )) + .toList(), + ), + ), + ); + }, + ); + }); + }, + ), + ListTile( + title: Text('删除课程'), + onTap: courseController.deleteAllCourses, + ), + ListTile( + title: Text('导入课程(待开发)'), + onTap: () => courseController.autoImportCours(1, "1", 1, 1), + ), + ListTile( + title: Text('插入课程'), + onTap: () => courseController.insertCourse(Course( + userId: 1, + courseId: 2, + name: "测试课", + credit: 3, + teacher: "嘉豪", + location: "638", + remark: "happy", + start: DateTime.now(), + end: DateTime.now().add(Duration(hours: 2)), + )), + ), + ListTile( + title: Text('获取课程列表'), + onTap: () { + courseController.getCourses().then((courses) { + print(courses.length); + }); + courseController.getCourses().then((courses) { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text('课程列表'), + content: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + children: courses + .map((course) => ListTile( + title: Text(course.getName), + subtitle: Text(course.toString()), + )) + .toList(), + ), + ), + ); + }, + ); + }); + }, + ), + ListTile( + title: Text('查看时间表'), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return TimetableRoute(); + }, + ), + ); + }, + ), + ], + ), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ElevatedButton( + onPressed: () { + Navigator.push( + // 使用 pushReplacement 代替 push + context, + MaterialPageRoute( + builder: (context) { + return TimetableRoute(); + }, + ), + ); + }, + child: Text('直接显示 TimetableRoute()'), // 可以将按钮文本改成适当的描述 + ) + ], + ), + ), + ); + } +} diff --git a/src/timemanagerapp/lib/wighets/TimetableWighet.dart b/src/timemanagerapp/lib/wighets/TimetableWighet.dart new file mode 100644 index 0000000..ea25b5e --- /dev/null +++ b/src/timemanagerapp/lib/wighets/TimetableWighet.dart @@ -0,0 +1,389 @@ +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 createState() => PageState(deviceWidth: deviceWidth); +} + +class PageState extends State { + late double deviceWidth; + //控制器 + late CourseWidgetController courseWidgetController = CourseWidgetController(); + late CourseController courseController = CourseController.getInstance(); + + //第一行显示的周几的数据 + var weekList = ['一', '二', '三', '四', '五', '六', '日']; + //自定义的几个数据,其中信息并不很全,但是目前足够制作课表界面 + List courseList = []; + Map> courseWeekMap = {}; + + //日期的列表,第一行周下面的数据相对应 + var dateListstr = []; + //当前周的下标,会变为蓝色字体 + var currentWeekDayIndex = 0; + + //当前周数 + int weekCount = 0; + int currentWeek = 0; + String weekCountstr = '第1周'; + + final double hourHeight = 60.0 * 1.5; + //预设的时间轴的值,由于时间轴是由课表得来,所以这里是DateTime类型,需要经过一次转换为Piexl的值 + List 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'), + ), + + 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('加载中'), + ); + } +} diff --git a/src/timemanagerapp/linux/.gitignore b/src/timemanagerapp/linux/.gitignore new file mode 100644 index 0000000..d3896c9 --- /dev/null +++ b/src/timemanagerapp/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/src/timemanagerapp/linux/CMakeLists.txt b/src/timemanagerapp/linux/CMakeLists.txt new file mode 100644 index 0000000..71e075b --- /dev/null +++ b/src/timemanagerapp/linux/CMakeLists.txt @@ -0,0 +1,139 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.10) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "timemanagerapp") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.example.timemanagerapp") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Define the application target. To change its name, change BINARY_NAME above, +# not the value here, or `flutter run` will no longer work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/src/timemanagerapp/linux/flutter/CMakeLists.txt b/src/timemanagerapp/linux/flutter/CMakeLists.txt new file mode 100644 index 0000000..d5bd016 --- /dev/null +++ b/src/timemanagerapp/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/src/timemanagerapp/linux/flutter/generated_plugin_registrant.cc b/src/timemanagerapp/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..e71a16d --- /dev/null +++ b/src/timemanagerapp/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void fl_register_plugins(FlPluginRegistry* registry) { +} diff --git a/src/timemanagerapp/linux/flutter/generated_plugin_registrant.h b/src/timemanagerapp/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..e0f0a47 --- /dev/null +++ b/src/timemanagerapp/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/src/timemanagerapp/linux/flutter/generated_plugins.cmake b/src/timemanagerapp/linux/flutter/generated_plugins.cmake new file mode 100644 index 0000000..2e1de87 --- /dev/null +++ b/src/timemanagerapp/linux/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/src/timemanagerapp/linux/main.cc b/src/timemanagerapp/linux/main.cc new file mode 100644 index 0000000..e7c5c54 --- /dev/null +++ b/src/timemanagerapp/linux/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/src/timemanagerapp/linux/my_application.cc b/src/timemanagerapp/linux/my_application.cc new file mode 100644 index 0000000..b2e6f70 --- /dev/null +++ b/src/timemanagerapp/linux/my_application.cc @@ -0,0 +1,104 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "timemanagerapp"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "timemanagerapp"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/src/timemanagerapp/linux/my_application.h b/src/timemanagerapp/linux/my_application.h new file mode 100644 index 0000000..72271d5 --- /dev/null +++ b/src/timemanagerapp/linux/my_application.h @@ -0,0 +1,18 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/src/timemanagerapp/macos/.gitignore b/src/timemanagerapp/macos/.gitignore new file mode 100644 index 0000000..746adbb --- /dev/null +++ b/src/timemanagerapp/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/src/timemanagerapp/macos/Flutter/Flutter-Debug.xcconfig b/src/timemanagerapp/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000..c2efd0b --- /dev/null +++ b/src/timemanagerapp/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/src/timemanagerapp/macos/Flutter/Flutter-Release.xcconfig b/src/timemanagerapp/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000..c2efd0b --- /dev/null +++ b/src/timemanagerapp/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/src/timemanagerapp/macos/Flutter/GeneratedPluginRegistrant.swift b/src/timemanagerapp/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 0000000..eefcc6d --- /dev/null +++ b/src/timemanagerapp/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,16 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import path_provider_foundation +import shared_preferences_foundation +import sqflite + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) + SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) +} diff --git a/src/timemanagerapp/macos/Runner.xcodeproj/project.pbxproj b/src/timemanagerapp/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..2db95cb --- /dev/null +++ b/src/timemanagerapp/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,695 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC10EC2044A3C60003C045; + remoteInfo = Runner; + }; + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* timemanagerapp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "timemanagerapp.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 331C80D2294CF70F00263BE5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C80D6294CF71000263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C80D7294CF71000263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 331C80D6294CF71000263BE5 /* RunnerTests */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* timemanagerapp.app */, + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C80D4294CF70F00263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C80D1294CF70F00263BE5 /* Sources */, + 331C80D2294CF70F00263BE5 /* Frameworks */, + 331C80D3294CF70F00263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C80DA294CF71000263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* timemanagerapp.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1430; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C80D4294CF70F00263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 33CC10EC2044A3C60003C045; + }; + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 331C80D4294CF70F00263BE5 /* RunnerTests */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C80D3294CF70F00263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C80D1294CF70F00263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC10EC2044A3C60003C045 /* Runner */; + targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; + }; + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 331C80DB294CF71000263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.timemanagerapp.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/timemanagerapp.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/timemanagerapp"; + }; + name = Debug; + }; + 331C80DC294CF71000263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.timemanagerapp.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/timemanagerapp.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/timemanagerapp"; + }; + name = Release; + }; + 331C80DD294CF71000263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.timemanagerapp.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/timemanagerapp.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/timemanagerapp"; + }; + name = Profile; + }; + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C80DB294CF71000263BE5 /* Debug */, + 331C80DC294CF71000263BE5 /* Release */, + 331C80DD294CF71000263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/src/timemanagerapp/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/src/timemanagerapp/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/src/timemanagerapp/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/src/timemanagerapp/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/src/timemanagerapp/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..7e76c37 --- /dev/null +++ b/src/timemanagerapp/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/timemanagerapp/macos/Runner.xcworkspace/contents.xcworkspacedata b/src/timemanagerapp/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/src/timemanagerapp/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/src/timemanagerapp/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/src/timemanagerapp/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/src/timemanagerapp/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/src/timemanagerapp/macos/Runner/AppDelegate.swift b/src/timemanagerapp/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000..d53ef64 --- /dev/null +++ b/src/timemanagerapp/macos/Runner/AppDelegate.swift @@ -0,0 +1,9 @@ +import Cocoa +import FlutterMacOS + +@NSApplicationMain +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..a2ec33f --- /dev/null +++ b/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000..82b6f9d Binary files /dev/null and b/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000..13b35eb Binary files /dev/null and b/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 0000000..0a3f5fa Binary files /dev/null and b/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000..bdb5722 Binary files /dev/null and b/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 0000000..f083318 Binary files /dev/null and b/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000..326c0e7 Binary files /dev/null and b/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 0000000..2f1632c Binary files /dev/null and b/src/timemanagerapp/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/src/timemanagerapp/macos/Runner/Base.lproj/MainMenu.xib b/src/timemanagerapp/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000..80e867a --- /dev/null +++ b/src/timemanagerapp/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/timemanagerapp/macos/Runner/Configs/AppInfo.xcconfig b/src/timemanagerapp/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000..7696d90 --- /dev/null +++ b/src/timemanagerapp/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = timemanagerapp + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.example.timemanagerapp + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2023 com.example. All rights reserved. diff --git a/src/timemanagerapp/macos/Runner/Configs/Debug.xcconfig b/src/timemanagerapp/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000..36b0fd9 --- /dev/null +++ b/src/timemanagerapp/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/src/timemanagerapp/macos/Runner/Configs/Release.xcconfig b/src/timemanagerapp/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000..dff4f49 --- /dev/null +++ b/src/timemanagerapp/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/src/timemanagerapp/macos/Runner/Configs/Warnings.xcconfig b/src/timemanagerapp/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000..42bcbf4 --- /dev/null +++ b/src/timemanagerapp/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/src/timemanagerapp/macos/Runner/DebugProfile.entitlements b/src/timemanagerapp/macos/Runner/DebugProfile.entitlements new file mode 100644 index 0000000..dddb8a3 --- /dev/null +++ b/src/timemanagerapp/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/src/timemanagerapp/macos/Runner/Info.plist b/src/timemanagerapp/macos/Runner/Info.plist new file mode 100644 index 0000000..4789daa --- /dev/null +++ b/src/timemanagerapp/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/src/timemanagerapp/macos/Runner/MainFlutterWindow.swift b/src/timemanagerapp/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000..3cc05eb --- /dev/null +++ b/src/timemanagerapp/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/src/timemanagerapp/macos/Runner/Release.entitlements b/src/timemanagerapp/macos/Runner/Release.entitlements new file mode 100644 index 0000000..852fa1a --- /dev/null +++ b/src/timemanagerapp/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/src/timemanagerapp/macos/RunnerTests/RunnerTests.swift b/src/timemanagerapp/macos/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..5418c9f --- /dev/null +++ b/src/timemanagerapp/macos/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import FlutterMacOS +import Cocoa +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/src/timemanagerapp/preview.pdf b/src/timemanagerapp/preview.pdf new file mode 100644 index 0000000..07e5e2a Binary files /dev/null and b/src/timemanagerapp/preview.pdf differ diff --git a/src/timemanagerapp/pubspec.lock b/src/timemanagerapp/pubspec.lock new file mode 100644 index 0000000..9c5c20d --- /dev/null +++ b/src/timemanagerapp/pubspec.lock @@ -0,0 +1,418 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.1" + characters: + dependency: transitive + description: + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.0" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.1" + collection: + dependency: transitive + description: + name: collection + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.17.2" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.6" + device_info: + dependency: "direct main" + description: + name: device_info + sha256: f4a8156cb7b7480d969cb734907d18b333c8f0bc0b1ad0b342cdcecf30d62c48 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.3" + device_info_platform_interface: + dependency: transitive + description: + name: device_info_platform_interface + sha256: b148e0bf9640145d09a4f8dea96614076f889e7f7f8b5ecab1c7e5c2dbc73c1b + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.1" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.0" + file: + dependency: transitive + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.1.4" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.3" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + http: + dependency: "direct main" + description: + name: http + sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.0" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.0.2" + lints: + dependency: transitive + description: + name: lints + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.1" + matcher: + dependency: transitive + description: + name: matcher + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.12.16" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.5.0" + meta: + dependency: transitive + description: + name: meta + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.9.1" + multi_select_flutter: + dependency: "direct main" + description: + name: multi_select_flutter + sha256: "503857b415d390d29159df8a9d92d83c6aac17aaf1c307fb7bcfc77d097d20ed" + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.1.3" + path: + dependency: "direct main" + description: + name: path + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.8.3" + path_provider: + dependency: "direct main" + description: + name: path_provider + sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.1" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: "6b8b19bd80da4f11ce91b2d1fb931f3006911477cec227cce23d3253d80df3f1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.0" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.1" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.1" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.1" + platform: + dependency: transitive + description: + name: platform + sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102 + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.2" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.6" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + sha256: b7f41bad7e521d205998772545de63ff4e6c97714775902c199353f8bf1511ac + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.1" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.1" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + sha256: "7bf53a9f2d007329ee6f3df7268fd498f8373602f943c975598bbb34649b62a7" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.4" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + sha256: c2eb5bf57a2fe9ad6988121609e47d3e07bb3bdca5b6f8444e4cf302428a128a + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.1" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + sha256: d4ec5fc9ebb2f2e056c617112aa75dcf92fc2e4faaf2ae999caa297473f75d8a + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.1" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + sha256: d762709c2bbe80626ecc819143013cc820fa49ca5e363620ee20a8b15a3e3daf + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.1" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + sha256: f763a101313bd3be87edffe0560037500967de9c394a714cd598d945517f694f + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.1" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.10.0" + sqflite: + dependency: "direct main" + description: + name: sqflite + sha256: "591f1602816e9c31377d5f008c2d9ef7b8aca8941c3f89cc5fd9d84da0c38a9a" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.0" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + sha256: "1b92f368f44b0dee2425bb861cfa17b6f6cf3961f762ff6f941d20b33355660a" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.5.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.11.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.0" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: "5fcbd27688af6082f5abd611af56ee575342c30e87541d0245f7ff99faa02c60" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.6.0" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.2" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.4" + web: + dependency: transitive + description: + name: web + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.1.4-beta" + win32: + dependency: transitive + description: + name: win32 + sha256: c97defd418eef4ec88c0d1652cdce84b9f7b63dd7198e266d06ac1710d527067 + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.0.8" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "589ada45ba9e39405c198fe34eb0f607cddb2108527e658136120892beac46d2" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.3" +sdks: + dart: ">=3.1.0 <4.0.0" + flutter: ">=3.7.0" diff --git a/src/timemanagerapp/pubspec.yaml b/src/timemanagerapp/pubspec.yaml new file mode 100644 index 0000000..55d922b --- /dev/null +++ b/src/timemanagerapp/pubspec.yaml @@ -0,0 +1,102 @@ +name: timemanagerapp +description: A new Flutter project. +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +# In Windows, build-name is used as the major, minor, and patch parts +# of the product and file versions while build-number is used as the build suffix. +version: 1.0.0+1 + +environment: + sdk: '>=3.1.0 <4.0.0' + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + shared_preferences: ^2.2.1 + + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + sqflite: ^2.3.0 + path: ^1.8.3 + path_provider: ^2.1.1 + multi_select_flutter: 4.1.3 + http: ^1.1.0 + device_info: + + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + assets: + - assets/pythoncode/zfn_api.py + - assets/pythoncode/getschedule.py + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/src/timemanagerapp/test/Setting_test.dart b/src/timemanagerapp/test/Setting_test.dart new file mode 100644 index 0000000..166d732 --- /dev/null +++ b/src/timemanagerapp/test/Setting_test.dart @@ -0,0 +1,21 @@ +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'; + + +init() async { + await Setting.init(); +} + +void main() async { + await init(); + print("Settong" + Setting.getStartDate().toString()); + Setting.saveStartDate(DateTime(2022,8,12)); + print("Settong" + Setting.getStartDate().toString()); + + + +} diff --git a/src/timemanagerapp/test/main_test.dart b/src/timemanagerapp/test/main_test.dart new file mode 100644 index 0000000..ff69a70 --- /dev/null +++ b/src/timemanagerapp/test/main_test.dart @@ -0,0 +1,31 @@ +import 'package:flutter/material.dart'; +import 'package:timemanagerapp/setting/Setting.dart'; +import 'package:timemanagerapp/wighets/AddCourseFormWidget.dart'; +import 'package:timemanagerapp/wighets/LoginWidget.dart'; + + +void init(){ + Setting.init(); +} + +void main() { + WidgetsFlutterBinding.ensureInitialized(); + init(); + + print("-------------test--------" + Setting.getStartDate().toString()); + runApp(MyApp()); +} + +class MyApp extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: Text('添加课程'), + ), + body: AddCourseFormWidget(), + ), + ); + } +} diff --git a/src/timemanagerapp/test/widget_test.dart b/src/timemanagerapp/test/widget_test.dart new file mode 100644 index 0000000..27d8aed --- /dev/null +++ b/src/timemanagerapp/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:timemanagerapp/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/src/timemanagerapp/web/favicon.png b/src/timemanagerapp/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/src/timemanagerapp/web/favicon.png differ diff --git a/src/timemanagerapp/web/icons/Icon-192.png b/src/timemanagerapp/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/src/timemanagerapp/web/icons/Icon-192.png differ diff --git a/src/timemanagerapp/web/icons/Icon-512.png b/src/timemanagerapp/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/src/timemanagerapp/web/icons/Icon-512.png differ diff --git a/src/timemanagerapp/web/icons/Icon-maskable-192.png b/src/timemanagerapp/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/src/timemanagerapp/web/icons/Icon-maskable-192.png differ diff --git a/src/timemanagerapp/web/icons/Icon-maskable-512.png b/src/timemanagerapp/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/src/timemanagerapp/web/icons/Icon-maskable-512.png differ diff --git a/src/timemanagerapp/web/index.html b/src/timemanagerapp/web/index.html new file mode 100644 index 0000000..2b81798 --- /dev/null +++ b/src/timemanagerapp/web/index.html @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + timemanagerapp + + + + + + + + + + diff --git a/src/timemanagerapp/web/manifest.json b/src/timemanagerapp/web/manifest.json new file mode 100644 index 0000000..5eef234 --- /dev/null +++ b/src/timemanagerapp/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "timemanagerapp", + "short_name": "timemanagerapp", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +}