Compare commits
38 Commits
8b592e2e48
...
v2.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
484e1eeee3 | ||
|
|
e2a2ae55ec | ||
|
|
558b780235 | ||
|
|
1cd3724805 | ||
|
|
7e3a63169e | ||
|
|
1298dba590 | ||
|
|
2005083d2e | ||
|
|
4e3f8a0df9 | ||
|
|
5698277301 | ||
|
|
02be737264 | ||
|
|
9558f3d235 | ||
|
|
14c3b1a965 | ||
|
|
b89de1414a | ||
|
|
9759caf9b8 | ||
|
|
c7824c920b | ||
|
|
817ad978e2 | ||
|
|
1d59128e47 | ||
|
|
62537f5814 | ||
|
|
5f91160d9a | ||
|
|
64ee8189b1 | ||
|
|
665a51f962 | ||
|
|
bd77beb60a | ||
|
|
578bb926fa | ||
|
|
2c64038fda | ||
|
|
9a27ae8e69 | ||
|
|
6716456b04 | ||
|
|
ec3440a0fb | ||
|
|
598c0cbde4 | ||
|
|
bce68681ac | ||
|
|
85bc4635bc | ||
|
|
c94abdb3c5 | ||
|
|
4ed9c029ca | ||
|
|
ba7352d26e | ||
|
|
b8c370893a | ||
|
|
faaf254f2c | ||
|
|
bdce0ecf70 | ||
|
|
6e09c6012d | ||
|
|
851a9173af |
1
.gitignore
vendored
@@ -44,3 +44,4 @@ app.*.map.json
|
|||||||
/android/app/debug
|
/android/app/debug
|
||||||
/android/app/profile
|
/android/app/profile
|
||||||
/android/app/release
|
/android/app/release
|
||||||
|
.fvm/
|
||||||
30
.metadata
@@ -1,10 +1,36 @@
|
|||||||
# This file tracks properties of this Flutter project.
|
# This file tracks properties of this Flutter project.
|
||||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||||
#
|
#
|
||||||
# This file should be version controlled and should not be manually edited.
|
# This file should be version controlled.
|
||||||
|
|
||||||
version:
|
version:
|
||||||
revision: 77d935af4db863f6abd0b9c31c7e6df2a13de57b
|
revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||||
channel: stable
|
channel: stable
|
||||||
|
|
||||||
project_type: app
|
project_type: app
|
||||||
|
|
||||||
|
# Tracks metadata for the flutter migrate command
|
||||||
|
migration:
|
||||||
|
platforms:
|
||||||
|
- platform: root
|
||||||
|
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||||
|
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||||
|
- platform: linux
|
||||||
|
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||||
|
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||||
|
- platform: macos
|
||||||
|
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||||
|
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||||
|
- platform: windows
|
||||||
|
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||||
|
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
|
||||||
|
|
||||||
|
# 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'
|
||||||
|
|||||||
17
README.md
@@ -44,3 +44,20 @@ iOS端暂无上架打算,用户自行下载main分支源码编译安装
|
|||||||
### 不支持的功能
|
### 不支持的功能
|
||||||
>* 应用设置
|
>* 应用设置
|
||||||
>* 通知设置
|
>* 通知设置
|
||||||
|
|
||||||
|
|
||||||
|
版本更新通知 https://t.me/qinglongapp
|
||||||
|
|
||||||
|
用于生成app的图标
|
||||||
|
|
||||||
|
flutter pub run flutter_launcher_icons:main
|
||||||
|
生成原生的启动页面
|
||||||
|
|
||||||
|
flutter pub run flutter_native_splash:create
|
||||||
|
修改app名称
|
||||||
|
|
||||||
|
flutter pub run flutter_app_name
|
||||||
|
|
||||||
|
生成json.jc.dart文件
|
||||||
|
flutter pub run build_runner build --delete-conflicting-outputs
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="work.master.qinglongapp">
|
package="work.master.qinglongapp">
|
||||||
<application
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
android:label="青龙"
|
|
||||||
|
<application
|
||||||
|
android:label="青龙客户端"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/img">
|
android:icon="@mipmap/ic_launcher">
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package work.master.qinglong_app
|
||||||
|
|
||||||
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
|
|
||||||
|
class MainActivity: FlutterActivity() {
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 16 KiB |
BIN
android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 14 KiB |
BIN
android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 7.1 KiB |
BIN
android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 24 KiB |
BIN
android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 49 KiB |
BIN
android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 82 KiB |
BIN
apk/app-release-v1.0.8.apk
Normal file
BIN
assets/images/add_btn_svip.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 19 KiB |
BIN
assets/images/dark.png
Normal file
|
After Width: | Height: | Size: 608 B |
BIN
assets/images/faceid.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/images/figure.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
assets/images/icon_a.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/images/icon_about.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
assets/images/icon_add_file.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
assets/images/icon_app_set.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/images/icon_b.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
assets/images/icon_check.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/images/icon_cron.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/images/icon_cron_checked.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
assets/images/icon_d.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
assets/images/icon_default_user.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
BIN
assets/images/icon_disabled.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
assets/images/icon_enable.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/images/icon_env.png
Normal file
|
After Width: | Height: | Size: 960 B |
BIN
assets/images/icon_env_checked.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
assets/images/icon_fail.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
assets/images/icon_file.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/images/icon_file_checked.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
assets/images/icon_history.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
assets/images/icon_idle.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
assets/images/icon_install_fail.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
assets/images/icon_install_success.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
assets/images/icon_login_icon.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
assets/images/icon_other.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
assets/images/icon_other_bg.png
Normal file
|
After Width: | Height: | Size: 400 KiB |
BIN
assets/images/icon_other_checked.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
assets/images/icon_right.png
Normal file
|
After Width: | Height: | Size: 491 B |
BIN
assets/images/icon_running.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
assets/images/icon_s.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
assets/images/icon_safety.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
assets/images/icon_search.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
assets/images/icon_setting.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
assets/images/icon_subsctibe.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/images/icon_success.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
assets/images/icon_task_disable.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
assets/images/icon_task_log.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
assets/images/icon_uncheck.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
assets/images/icon_vip_bg.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
assets/images/icon_vip_bg_check.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
assets/images/js.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
assets/images/json.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 19 KiB |
BIN
assets/images/light.png
Normal file
|
After Width: | Height: | Size: 863 B |
BIN
assets/images/normal.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/images/other.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
assets/images/py.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 115 KiB After Width: | Height: | Size: 16 KiB |
BIN
assets/images/ql_splash.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 16 KiB |
BIN
assets/images/shell.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/images/svip.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
assets/images/svip_logo.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
assets/images/ts.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/images/vip.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
assets/images/vip_logo.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 20 KiB |
@@ -1,52 +0,0 @@
|
|||||||
{
|
|
||||||
"images" : [
|
|
||||||
{
|
|
||||||
"filename" : "background.png",
|
|
||||||
"idiom" : "universal",
|
|
||||||
"scale" : "1x"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"appearances" : [
|
|
||||||
{
|
|
||||||
"appearance" : "luminosity",
|
|
||||||
"value" : "dark"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"filename" : "darkbackground.png",
|
|
||||||
"idiom" : "universal",
|
|
||||||
"scale" : "1x"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "universal",
|
|
||||||
"scale" : "2x"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"appearances" : [
|
|
||||||
{
|
|
||||||
"appearance" : "luminosity",
|
|
||||||
"value" : "dark"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"idiom" : "universal",
|
|
||||||
"scale" : "2x"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "universal",
|
|
||||||
"scale" : "3x"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"appearances" : [
|
|
||||||
{
|
|
||||||
"appearance" : "luminosity",
|
|
||||||
"value" : "dark"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"idiom" : "universal",
|
|
||||||
"scale" : "3x"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"info" : {
|
|
||||||
"author" : "xcode",
|
|
||||||
"version" : 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 68 B |
|
Before Width: | Height: | Size: 70 B |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 71 KiB |
@@ -1,49 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
|
||||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
||||||
<key>CFBundleDisplayName</key>
|
|
||||||
<string>Qinglong App</string>
|
|
||||||
<key>CFBundleExecutable</key>
|
|
||||||
<string>$(EXECUTABLE_NAME)</string>
|
|
||||||
<key>CFBundleIdentifier</key>
|
|
||||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
|
||||||
<string>6.0</string>
|
|
||||||
<key>CFBundleName</key>
|
|
||||||
<string>qinglong_app</string>
|
|
||||||
<key>CFBundlePackageType</key>
|
|
||||||
<string>APPL</string>
|
|
||||||
<key>CFBundleShortVersionString</key>
|
|
||||||
<string>$(FLUTTER_BUILD_NAME)</string>
|
|
||||||
<key>CFBundleSignature</key>
|
|
||||||
<string>????</string>
|
|
||||||
<key>CFBundleVersion</key>
|
|
||||||
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
|
||||||
<key>LSRequiresIPhoneOS</key>
|
|
||||||
<true/>
|
|
||||||
<key>UILaunchStoryboardName</key>
|
|
||||||
<string>LaunchScreen</string>
|
|
||||||
<key>UIMainStoryboardFile</key>
|
|
||||||
<string>Main</string>
|
|
||||||
<key>UISupportedInterfaceOrientations</key>
|
|
||||||
<array>
|
|
||||||
<string>UIInterfaceOrientationPortrait</string>
|
|
||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
|
||||||
</array>
|
|
||||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
|
||||||
<array>
|
|
||||||
<string>UIInterfaceOrientationPortrait</string>
|
|
||||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
|
||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
|
||||||
</array>
|
|
||||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
|
||||||
<false/>
|
|
||||||
<key>UIStatusBarHidden</key>
|
|
||||||
<false/>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
||||||
@@ -24,12 +24,14 @@ class BaseStateWidget<T extends BaseViewModel> extends ConsumerStatefulWidget {
|
|||||||
_BaseStateWidgetState<T> createState() => _BaseStateWidgetState<T>();
|
_BaseStateWidgetState<T> createState() => _BaseStateWidgetState<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _BaseStateWidgetState<T extends BaseViewModel> extends ConsumerState<BaseStateWidget<T>> with LazyLoadState<BaseStateWidget<T>> {
|
class _BaseStateWidgetState<T extends BaseViewModel>
|
||||||
|
extends ConsumerState<BaseStateWidget<T>>
|
||||||
|
with LazyLoadState<BaseStateWidget<T>> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var viewModel = ref.watch<T>(widget.model);
|
var viewModel = ref.watch<T>(widget.model);
|
||||||
if (viewModel.failedToast != null) {
|
if (viewModel.failedToast != null) {
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||||
(viewModel.failedToast ?? "").toast();
|
(viewModel.failedToast ?? "").toast();
|
||||||
viewModel.clearToast();
|
viewModel.clearToast();
|
||||||
});
|
});
|
||||||
@@ -72,7 +74,7 @@ class _BaseStateWidgetState<T extends BaseViewModel> extends ConsumerState<BaseS
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||||
if (widget.onReady != null && !widget.lazyLoad) {
|
if (widget.onReady != null && !widget.lazyLoad) {
|
||||||
widget.onReady!(ref.read<T>(widget.model));
|
widget.onReady!(ref.read<T>(widget.model));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import 'package:qinglong_app/base/http/http.dart';
|
import 'package:qinglong_app/base/http/http.dart';
|
||||||
|
import 'package:qinglong_app/base/http/url.dart';
|
||||||
|
import 'package:qinglong_app/main.dart';
|
||||||
import 'package:qinglong_app/module/config/config_bean.dart';
|
import 'package:qinglong_app/module/config/config_bean.dart';
|
||||||
import 'package:qinglong_app/module/env/env_bean.dart';
|
import 'package:qinglong_app/module/env/env_bean.dart';
|
||||||
import 'package:qinglong_app/module/home/system_bean.dart';
|
import 'package:qinglong_app/module/home/system_bean.dart';
|
||||||
@@ -7,11 +9,10 @@ import 'package:qinglong_app/module/login/user_bean.dart';
|
|||||||
import 'package:qinglong_app/module/others/dependencies/dependency_bean.dart';
|
import 'package:qinglong_app/module/others/dependencies/dependency_bean.dart';
|
||||||
import 'package:qinglong_app/module/others/login_log/login_log_bean.dart';
|
import 'package:qinglong_app/module/others/login_log/login_log_bean.dart';
|
||||||
import 'package:qinglong_app/module/others/scripts/script_bean.dart';
|
import 'package:qinglong_app/module/others/scripts/script_bean.dart';
|
||||||
|
import 'package:qinglong_app/module/others/subscription/subscription_bean.dart';
|
||||||
import 'package:qinglong_app/module/others/task_log/task_log_bean.dart';
|
import 'package:qinglong_app/module/others/task_log/task_log_bean.dart';
|
||||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||||
|
import 'package:qinglong_app/utils/utils.dart';
|
||||||
import '../../utils/utils.dart';
|
|
||||||
import 'url.dart';
|
|
||||||
|
|
||||||
class Api {
|
class Api {
|
||||||
static Future<HttpResponse<SystemBean>> system() async {
|
static Future<HttpResponse<SystemBean>> system() async {
|
||||||
@@ -89,24 +90,21 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> startTasks(
|
static Future<HttpResponse<NullResponse>> startTasks(List<String> crons) async {
|
||||||
List<String> crons) async {
|
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.runTasks,
|
Url.runTasks,
|
||||||
crons,
|
crons,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> stopTasks(
|
static Future<HttpResponse<NullResponse>> stopTasks(List<String> crons) async {
|
||||||
List<String> crons) async {
|
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.stopTasks,
|
Url.stopTasks,
|
||||||
crons,
|
crons,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> updatePassword(
|
static Future<HttpResponse<NullResponse>> updatePassword(String name, String password) async {
|
||||||
String name, String password) async {
|
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.updatePassword,
|
Url.updatePassword,
|
||||||
{
|
{
|
||||||
@@ -124,15 +122,19 @@ class Api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> addTask(
|
static Future<HttpResponse<NullResponse>> addTask(
|
||||||
String name, String command, String cron,
|
String name,
|
||||||
{String? id}) async {
|
String command,
|
||||||
var data = {"name": name, "command": command, "schedule": cron};
|
String cron, {
|
||||||
|
int? id,
|
||||||
|
String? nId,
|
||||||
|
}) async {
|
||||||
|
var data = <String, dynamic>{"name": name, "command": command, "schedule": cron};
|
||||||
|
|
||||||
if (id != null) {
|
if (id != null || nId != null) {
|
||||||
if (Utils.isUpperVersion()) {
|
if (id != null) {
|
||||||
data["id"] = id;
|
data["id"] = id;
|
||||||
} else {
|
} else if (nId != null) {
|
||||||
data["_id"] = id;
|
data["_id"] = nId;
|
||||||
}
|
}
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.addTask,
|
Url.addTask,
|
||||||
@@ -194,8 +196,7 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> saveFile(
|
static Future<HttpResponse<NullResponse>> saveFile(String name, String content) async {
|
||||||
String name, String content) async {
|
|
||||||
return await Http.post<NullResponse>(
|
return await Http.post<NullResponse>(
|
||||||
Url.saveFile,
|
Url.saveFile,
|
||||||
{"content": content, "name": name},
|
{"content": content, "name": name},
|
||||||
@@ -231,21 +232,24 @@ class Api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> addEnv(
|
static Future<HttpResponse<NullResponse>> addEnv(
|
||||||
String name, String value, String remarks,
|
String name,
|
||||||
{String? id}) async {
|
String value,
|
||||||
var data = {
|
String remarks, {
|
||||||
|
int? id,
|
||||||
|
String? nId,
|
||||||
|
}) async {
|
||||||
|
var data = <String, dynamic>{
|
||||||
"value": value,
|
"value": value,
|
||||||
"remarks": remarks,
|
"remarks": remarks,
|
||||||
"name": name,
|
"name": name,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (id != null) {
|
if (id != null || nId != null) {
|
||||||
if (Utils.isUpperVersion()) {
|
if (id != null) {
|
||||||
data["id"] = id;
|
data["id"] = id;
|
||||||
} else {
|
} else if (nId != null) {
|
||||||
data["_id"] = id;
|
data["_id"] = nId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.addEnv,
|
Url.addEnv,
|
||||||
data,
|
data,
|
||||||
@@ -257,8 +261,7 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> moveEnv(
|
static Future<HttpResponse<NullResponse>> moveEnv(String id, int fromIndex, int toIndex) async {
|
||||||
String id, int fromIndex, int toIndex) async {
|
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.envMove(id),
|
Url.envMove(id),
|
||||||
{"fromIndex": fromIndex, "toIndex": toIndex},
|
{"fromIndex": fromIndex, "toIndex": toIndex},
|
||||||
@@ -273,26 +276,32 @@ class Api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<List<TaskLogBean>>> taskLog() async {
|
static Future<HttpResponse<List<TaskLogBean>>> taskLog() async {
|
||||||
return await Http.get<List<TaskLogBean>>(Url.taskLog, null,
|
return await Http.get<List<TaskLogBean>>(Url.taskLog, null, serializationName: Utils.isUpperVersion2_12_2() ? "data" : "dirs");
|
||||||
serializationName: "dirs");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<String>> taskLogDetail(String name) async {
|
static Future<HttpResponse<String>> taskLogDetail(String name, String path) async {
|
||||||
return await Http.get<String>(
|
if (Utils.isUpperVersion2_13_0()) {
|
||||||
Url.taskLogDetail + name,
|
return await Http.get<String>(
|
||||||
null,
|
Url.taskLogDetail + name + "?path=" + path,
|
||||||
);
|
null,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return await Http.get<String>(
|
||||||
|
Url.taskLogDetail + path + "/" + name,
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<List<ScriptBean>>> scripts() async {
|
static Future<HttpResponse<List<ScriptBean>>> scripts() async {
|
||||||
|
//2.12.2以及以上版本,脚本路径url做了修改
|
||||||
return await Http.get<List<ScriptBean>>(
|
return await Http.get<List<ScriptBean>>(
|
||||||
Url.scripts,
|
Utils.isUpperVersion2_13_0() ? Url.scripts2 : Url.scripts,
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> updateScript(
|
static Future<HttpResponse<NullResponse>> updateScript(String name, String path, String content) async {
|
||||||
String name, String path, String content) async {
|
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.scriptDetail,
|
Url.scriptDetail,
|
||||||
{
|
{
|
||||||
@@ -303,8 +312,7 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> delScript(
|
static Future<HttpResponse<NullResponse>> delScript(String name, String path) async {
|
||||||
String name, String path) async {
|
|
||||||
return await Http.delete<NullResponse>(
|
return await Http.delete<NullResponse>(
|
||||||
Url.scriptDetail,
|
Url.scriptDetail,
|
||||||
{
|
{
|
||||||
@@ -314,8 +322,7 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<String>> scriptDetail(
|
static Future<HttpResponse<String>> scriptDetail(String name, String? path) async {
|
||||||
String name, String? path) async {
|
|
||||||
return await Http.get<String>(
|
return await Http.get<String>(
|
||||||
Url.scriptDetail + name,
|
Url.scriptDetail + name,
|
||||||
{
|
{
|
||||||
@@ -324,8 +331,7 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<List<DependencyBean>>> dependencies(
|
static Future<HttpResponse<List<DependencyBean>>> dependencies(String type) async {
|
||||||
String type) async {
|
|
||||||
return await Http.get<List<DependencyBean>>(
|
return await Http.get<List<DependencyBean>>(
|
||||||
Url.dependencies,
|
Url.dependencies,
|
||||||
{
|
{
|
||||||
@@ -334,8 +340,7 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> dependencyReinstall(
|
static Future<HttpResponse<NullResponse>> dependencyReinstall(String id) async {
|
||||||
String id) async {
|
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.dependencies,
|
Url.dependencies,
|
||||||
[id],
|
[id],
|
||||||
@@ -349,16 +354,21 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> addDependency(
|
static Future<HttpResponse<NullResponse>> addDependency(List<Map<String, dynamic>> list) async {
|
||||||
String name, int type) async {
|
|
||||||
return await Http.post<NullResponse>(
|
return await Http.post<NullResponse>(
|
||||||
Url.dependencies,
|
Url.dependencies,
|
||||||
[
|
list,
|
||||||
{
|
);
|
||||||
"name": name,
|
}
|
||||||
"type": type,
|
|
||||||
}
|
static Future<HttpResponse<NullResponse>> addScript(String name, String path, String content) async {
|
||||||
],
|
return await Http.post<NullResponse>(
|
||||||
|
Url.addScript,
|
||||||
|
{
|
||||||
|
"filename": name,
|
||||||
|
"path": path,
|
||||||
|
"content": content,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,4 +378,89 @@ class Api {
|
|||||||
[id],
|
[id],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 获取订阅
|
||||||
|
static Future<HttpResponse<List<Subscription>>> getSubscription()async{
|
||||||
|
return await Http.get<List<Subscription>>(
|
||||||
|
Url.subscriptions,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增订阅
|
||||||
|
static Future<HttpResponse<Subscription>> postSubscription(Subscription subscription)async{
|
||||||
|
var data = subscription.toJson();
|
||||||
|
data.remove("id");
|
||||||
|
data.remove("status");
|
||||||
|
data.remove("pid");
|
||||||
|
data.remove("log_path");
|
||||||
|
data.remove("is_disabled");
|
||||||
|
data.remove("createdAt");
|
||||||
|
data.remove("updatedAt");
|
||||||
|
data.remove("pullType");
|
||||||
|
data.remove("pullOption");
|
||||||
|
return await Http.post<Subscription>(
|
||||||
|
Url.subscriptions,
|
||||||
|
data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改订阅
|
||||||
|
static Future<HttpResponse<Subscription>> putSubscription(Subscription subscription)async{
|
||||||
|
return await Http.put<Subscription>(
|
||||||
|
Url.subscriptions,
|
||||||
|
subscription.toJson()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除订阅 参数未一个id数组
|
||||||
|
static Future<HttpResponse<NullResponse>> deleteSubscription(List<int> ids)async{
|
||||||
|
return await Http.delete<NullResponse>(
|
||||||
|
Url.subscriptions,
|
||||||
|
ids
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除订阅 参数未一个id数组
|
||||||
|
static Future<HttpResponse<NullResponse>> disableSubscription(List<int> ids)async{
|
||||||
|
return await Http.put<NullResponse>(
|
||||||
|
Url.disableSubscriptions,
|
||||||
|
ids
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除订阅 参数未一个id数组
|
||||||
|
static Future<HttpResponse<NullResponse>> enableSubscription(List<int> ids)async{
|
||||||
|
return await Http.put<NullResponse>(
|
||||||
|
Url.enableSubscriptions,
|
||||||
|
ids
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开始执行订阅
|
||||||
|
static Future<HttpResponse<NullResponse>> startSubscription(
|
||||||
|
List<int> subscriptions) async {
|
||||||
|
return await Http.put<NullResponse>(
|
||||||
|
Url.runSubscriptions,
|
||||||
|
subscriptions,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 暂停订阅执行
|
||||||
|
static Future<HttpResponse<NullResponse>> stopSubscription(
|
||||||
|
List<int> subscriptions) async {
|
||||||
|
return await Http.put<NullResponse>(
|
||||||
|
Url.stopSubscriptions,
|
||||||
|
subscriptions,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取订阅的日志
|
||||||
|
static Future<HttpResponse<String>> subTimeLog(int subId) async {
|
||||||
|
return await Http.get<String>(
|
||||||
|
Url.subtimeLog(subId),
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,8 @@ class Http {
|
|||||||
if (!pushedLoginPage) {
|
if (!pushedLoginPage) {
|
||||||
"身份已过期,请重新登录".toast();
|
"身份已过期,请重新登录".toast();
|
||||||
pushedLoginPage = true;
|
pushedLoginPage = true;
|
||||||
navigatorState.currentState?.pushNamedAndRemoveUntil(Routes.routeLogin, (route) => false);
|
navigatorState.currentState
|
||||||
|
?.pushNamedAndRemoveUntil(Routes.routeLogin, (route) => false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,9 +137,15 @@ class Http {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (e.response != null && e.response!.data != null) {
|
if (e.response != null && e.response!.data != null) {
|
||||||
return HttpResponse(success: false, message: e.response?.data["message"] ?? e.message, code: e.response?.data["code"] ?? 0);
|
return HttpResponse(
|
||||||
|
success: false,
|
||||||
|
message: e.response?.data["message"] ?? e.message,
|
||||||
|
code: e.response?.data["code"] ?? 0);
|
||||||
} else {
|
} else {
|
||||||
return HttpResponse(success: false, message: e.message, code: e.response?.statusCode ?? 0);
|
return HttpResponse(
|
||||||
|
success: false,
|
||||||
|
message: e.message,
|
||||||
|
code: e.response?.statusCode ?? 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,7 +230,8 @@ class HttpResponse<T> {
|
|||||||
late int code;
|
late int code;
|
||||||
T? bean;
|
T? bean;
|
||||||
|
|
||||||
HttpResponse({required this.success, this.message, required this.code, this.bean});
|
HttpResponse(
|
||||||
|
{required this.success, this.message, required this.code, this.bean});
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeserializeAction<T> {
|
class DeserializeAction<T> {
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import '../userinfo_viewmodel.dart';
|
|||||||
class TokenInterceptor extends Interceptor {
|
class TokenInterceptor extends Interceptor {
|
||||||
@override
|
@override
|
||||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
||||||
options.headers["User-Agent"] =
|
options.headers["User-Agent"] = "qinglong_client";
|
||||||
"Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1";
|
|
||||||
|
|
||||||
options.headers["Content-Type"] = "application/json;charset=UTF-8";
|
options.headers["Content-Type"] = "application/json;charset=UTF-8";
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import '../../main.dart';
|
import 'package:qinglong_app/base/userinfo_viewmodel.dart';
|
||||||
import '../userinfo_viewmodel.dart';
|
import 'package:qinglong_app/main.dart';
|
||||||
|
|
||||||
class Url {
|
class Url {
|
||||||
static get system => "/api/system";
|
|
||||||
|
|
||||||
static get login => "/api/user/login";
|
static get login => "/api/user/login";
|
||||||
|
|
||||||
|
static get system => "/api/system";
|
||||||
|
|
||||||
static get loginOld => "/api/login";
|
static get loginOld => "/api/login";
|
||||||
|
|
||||||
static get loginTwo => "/api/user/two-factor/login";
|
static get loginTwo => "/api/user/two-factor/login";
|
||||||
@@ -94,6 +94,10 @@ class Url {
|
|||||||
? "/open/scripts/files"
|
? "/open/scripts/files"
|
||||||
: "/api/scripts/files";
|
: "/api/scripts/files";
|
||||||
|
|
||||||
|
static get scripts2 => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/scripts"
|
||||||
|
: "/api/scripts";
|
||||||
|
|
||||||
static get scriptUpdate => getIt<UserInfoViewModel>().useSecretLogined
|
static get scriptUpdate => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
? "/open/scripts"
|
? "/open/scripts"
|
||||||
: "/api/scripts";
|
: "/api/scripts";
|
||||||
@@ -106,6 +110,10 @@ class Url {
|
|||||||
? "/open/dependencies"
|
? "/open/dependencies"
|
||||||
: "/api/dependencies";
|
: "/api/dependencies";
|
||||||
|
|
||||||
|
static get addScript => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/scripts"
|
||||||
|
: "/api/scripts";
|
||||||
|
|
||||||
static get dependencyReinstall => getIt<UserInfoViewModel>().useSecretLogined
|
static get dependencyReinstall => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
? "/open/dependencies/reinstall"
|
? "/open/dependencies/reinstall"
|
||||||
: "/api/dependencies/reinstall";
|
: "/api/dependencies/reinstall";
|
||||||
@@ -122,6 +130,38 @@ class Url {
|
|||||||
: "/api/envs/$envId/move";
|
: "/api/envs/$envId/move";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 运行订阅
|
||||||
|
static get runSubscriptions => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/subscriptions/run"
|
||||||
|
: "/api/subscriptions/run";
|
||||||
|
|
||||||
|
// 停止订阅
|
||||||
|
static get stopSubscriptions => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/subscriptions/stop"
|
||||||
|
: "/api/subscriptions/stop";
|
||||||
|
|
||||||
|
// 启用订阅
|
||||||
|
static get enableSubscriptions => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/subscriptions/enable"
|
||||||
|
: "/api/subscriptions/enable";
|
||||||
|
|
||||||
|
// 禁用订阅
|
||||||
|
static get disableSubscriptions => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/subscriptions/disable"
|
||||||
|
: "/api/subscriptions/disable";
|
||||||
|
|
||||||
|
// GET 获取订阅 POST 提交订阅 PUT 修改订阅 DELETE 删除订阅
|
||||||
|
static get subscriptions => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/subscriptions"
|
||||||
|
: "/api/subscriptions";
|
||||||
|
|
||||||
|
// 获取订阅日志
|
||||||
|
static subtimeLog(int cronId) {
|
||||||
|
return getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/subscriptions/$cronId/log"
|
||||||
|
: "/api/subscriptions/$cronId/log";
|
||||||
|
}
|
||||||
|
|
||||||
static bool inWhiteList(String path) {
|
static bool inWhiteList(String path) {
|
||||||
if (path == login ||
|
if (path == login ||
|
||||||
path == loginByClientId ||
|
path == loginByClientId ||
|
||||||
@@ -138,7 +178,4 @@ class Url {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String checkUpdateUrl =
|
|
||||||
"https://raw.githubusercontent.com/qinglong-app/qinglong_app/main/version";
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:qinglong_app/module/change_account_page.dart';
|
||||||
import 'package:qinglong_app/module/config/config_edit_page.dart';
|
import 'package:qinglong_app/module/config/config_edit_page.dart';
|
||||||
import 'package:qinglong_app/module/env/add_env_page.dart';
|
import 'package:qinglong_app/module/env/add_env_page.dart';
|
||||||
import 'package:qinglong_app/module/env/env_bean.dart';
|
import 'package:qinglong_app/module/env/env_bean.dart';
|
||||||
@@ -7,13 +8,17 @@ import 'package:qinglong_app/module/env/env_detail_page.dart';
|
|||||||
import 'package:qinglong_app/module/home/home_page.dart';
|
import 'package:qinglong_app/module/home/home_page.dart';
|
||||||
import 'package:qinglong_app/module/login/login_page.dart';
|
import 'package:qinglong_app/module/login/login_page.dart';
|
||||||
import 'package:qinglong_app/module/others/about_page.dart';
|
import 'package:qinglong_app/module/others/about_page.dart';
|
||||||
import 'package:qinglong_app/module/others/change_account_page.dart';
|
import 'package:qinglong_app/module/others/backup/backup_page.dart';
|
||||||
import 'package:qinglong_app/module/others/dependencies/add_dependency_page.dart';
|
import 'package:qinglong_app/module/others/dependencies/add_dependency_page.dart';
|
||||||
import 'package:qinglong_app/module/others/dependencies/dependency_page.dart';
|
import 'package:qinglong_app/module/others/dependencies/dependency_page.dart';
|
||||||
import 'package:qinglong_app/module/others/login_log/login_log_page.dart';
|
import 'package:qinglong_app/module/others/login_log/login_log_page.dart';
|
||||||
import 'package:qinglong_app/module/others/scripts/script_detail_page.dart';
|
import 'package:qinglong_app/module/others/scripts/script_detail_page.dart';
|
||||||
import 'package:qinglong_app/module/others/scripts/script_edit_page.dart';
|
import 'package:qinglong_app/module/others/scripts/script_edit_page.dart';
|
||||||
import 'package:qinglong_app/module/others/scripts/script_page.dart';
|
import 'package:qinglong_app/module/others/scripts/script_page.dart';
|
||||||
|
import 'package:qinglong_app/module/others/subscription/subscription_add_page.dart';
|
||||||
|
import 'package:qinglong_app/module/others/subscription/subscription_bean.dart';
|
||||||
|
import 'package:qinglong_app/module/others/subscription/subscription_detail_page.dart';
|
||||||
|
import 'package:qinglong_app/module/others/subscription/subscription_page.dart';
|
||||||
import 'package:qinglong_app/module/others/task_log/task_log_detail_page.dart';
|
import 'package:qinglong_app/module/others/task_log/task_log_detail_page.dart';
|
||||||
import 'package:qinglong_app/module/others/task_log/task_log_page.dart';
|
import 'package:qinglong_app/module/others/task_log/task_log_page.dart';
|
||||||
import 'package:qinglong_app/module/others/theme_page.dart';
|
import 'package:qinglong_app/module/others/theme_page.dart';
|
||||||
@@ -22,6 +27,8 @@ import 'package:qinglong_app/module/task/add_task_page.dart';
|
|||||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||||
import 'package:qinglong_app/module/task/task_detail/task_detail_page.dart';
|
import 'package:qinglong_app/module/task/task_detail/task_detail_page.dart';
|
||||||
|
|
||||||
|
import '../module/others/scripts/script_add_page.dart';
|
||||||
|
|
||||||
class Routes {
|
class Routes {
|
||||||
static const String routeHomePage = "/home/homepage";
|
static const String routeHomePage = "/home/homepage";
|
||||||
static const String routeLogin = "/login";
|
static const String routeLogin = "/login";
|
||||||
@@ -43,6 +50,12 @@ class Routes {
|
|||||||
static const String routeAbout = "/about";
|
static const String routeAbout = "/about";
|
||||||
static const String routeTheme = "/theme";
|
static const String routeTheme = "/theme";
|
||||||
static const String routeChangeAccount = "/changeAccount";
|
static const String routeChangeAccount = "/changeAccount";
|
||||||
|
static const String routerAddScript = "/script/add";
|
||||||
|
static const String routerSubscription = "/subscription";
|
||||||
|
static const String routerSubscriptionDetail = "/subscription/detail";
|
||||||
|
static const String routerSubscriptionAdd = "/subscription/add";
|
||||||
|
|
||||||
|
static const String routerBackup = "/backup";
|
||||||
|
|
||||||
static Route<dynamic>? generateRoute(RouteSettings settings) {
|
static Route<dynamic>? generateRoute(RouteSettings settings) {
|
||||||
switch (settings.name) {
|
switch (settings.name) {
|
||||||
@@ -57,100 +70,130 @@ class Routes {
|
|||||||
} else {
|
} else {
|
||||||
return MaterialPageRoute(builder: (context) => const LoginPage());
|
return MaterialPageRoute(builder: (context) => const LoginPage());
|
||||||
}
|
}
|
||||||
|
case routeChangeAccount:
|
||||||
|
return MaterialPageRoute(
|
||||||
|
builder: (context) => const ChangeAccountPage(),
|
||||||
|
);
|
||||||
case routeAddTask:
|
case routeAddTask:
|
||||||
if (settings.arguments != null) {
|
if (settings.arguments != null) {
|
||||||
return CupertinoPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (context) => AddTaskPage(
|
builder: (context) => AddTaskPage(
|
||||||
taskBean: settings.arguments as TaskBean,
|
taskBean: settings.arguments as TaskBean,
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
return CupertinoPageRoute(builder: (context) => const AddTaskPage());
|
return MaterialPageRoute(builder: (context) => const AddTaskPage());
|
||||||
}
|
}
|
||||||
case routeAddDependency:
|
case routeAddDependency:
|
||||||
return CupertinoPageRoute(
|
return MaterialPageRoute(builder: (context) => const AddDependencyPage());
|
||||||
builder: (context) => const AddDependencyPage());
|
|
||||||
case routeAddEnv:
|
case routeAddEnv:
|
||||||
if (settings.arguments != null) {
|
if (settings.arguments != null) {
|
||||||
return CupertinoPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (context) => AddEnvPage(
|
builder: (context) => AddEnvPage(
|
||||||
envBean: settings.arguments as EnvBean,
|
envBean: settings.arguments as EnvBean,
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
return CupertinoPageRoute(builder: (context) => const AddEnvPage());
|
return MaterialPageRoute(builder: (context) => const AddEnvPage());
|
||||||
}
|
}
|
||||||
case routeConfigEdit:
|
case routeConfigEdit:
|
||||||
return CupertinoPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (context) => ConfigEditPage(
|
builder: (context) => ConfigEditPage(
|
||||||
(settings.arguments as Map)["title"],
|
(settings.arguments as Map)["title"],
|
||||||
(settings.arguments as Map)["content"],
|
(settings.arguments as Map)["content"],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
case routeLoginLog:
|
case routeLoginLog:
|
||||||
return CupertinoPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (context) => const LoginLogPage(),
|
builder: (context) => const LoginLogPage(),
|
||||||
);
|
);
|
||||||
case routeTaskLog:
|
case routeTaskLog:
|
||||||
return CupertinoPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (context) => const TaskLogPage(),
|
builder: (context) => const TaskLogPage(),
|
||||||
);
|
);
|
||||||
case routeScript:
|
case routeScript:
|
||||||
return CupertinoPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (context) => const ScriptPage(),
|
builder: (context) => const ScriptPage(),
|
||||||
);
|
);
|
||||||
case routeDependency:
|
case routeDependency:
|
||||||
return CupertinoPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (context) => const DependencyPage(),
|
builder: (context) => const DependencyPage(),
|
||||||
);
|
);
|
||||||
case routeTaskLogDetail:
|
case routeTaskLogDetail:
|
||||||
return CupertinoPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (context) => TaskLogDetailPage(
|
builder: (context) => TaskLogDetailPage(
|
||||||
title: settings.arguments as String,
|
title: (settings.arguments as Map)['title'],
|
||||||
|
path: (settings.arguments as Map)['path'],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
case routeScriptDetail:
|
case routeScriptDetail:
|
||||||
return CupertinoPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (context) => ScriptDetailPage(
|
builder: (context) => ScriptDetailPage(
|
||||||
title: (settings.arguments as Map)["title"],
|
title: (settings.arguments as Map)["title"],
|
||||||
path: (settings.arguments as Map)["path"],
|
path: (settings.arguments as Map)["path"],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
case routeTaskDetail:
|
case routeTaskDetail:
|
||||||
return CupertinoPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (context) => TaskDetailPage(
|
builder: (context) => TaskDetailPage(
|
||||||
settings.arguments as TaskBean,
|
settings.arguments as TaskBean,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
case routeEnvDetail:
|
case routeEnvDetail:
|
||||||
return CupertinoPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (context) => EnvDetailPage(
|
builder: (context) => EnvDetailPage(
|
||||||
settings.arguments as EnvBean,
|
settings.arguments as EnvBean,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
case routeUpdatePassword:
|
case routeUpdatePassword:
|
||||||
return CupertinoPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (context) => const UpdatePasswordPage(),
|
builder: (context) => const UpdatePasswordPage(),
|
||||||
);
|
);
|
||||||
case routeAbout:
|
case routeAbout:
|
||||||
return CupertinoPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (context) => const AboutPage(),
|
builder: (context) => const AboutPage(),
|
||||||
);
|
);
|
||||||
case routeTheme:
|
case routeTheme:
|
||||||
return CupertinoPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (context) => const ThemePage(),
|
builder: (context) => const ThemePage(),
|
||||||
);
|
);
|
||||||
case routeChangeAccount:
|
|
||||||
return CupertinoPageRoute(
|
|
||||||
builder: (context) => const ChangeAccountPage(),
|
|
||||||
);
|
|
||||||
case routeScriptUpdate:
|
case routeScriptUpdate:
|
||||||
return CupertinoPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (context) => ScriptEditPage(
|
builder: (context) => ScriptEditPage(
|
||||||
(settings.arguments as Map)["title"],
|
(settings.arguments as Map)["title"],
|
||||||
(settings.arguments as Map)["path"],
|
(settings.arguments as Map)["path"],
|
||||||
(settings.arguments as Map)["content"],
|
(settings.arguments as Map)["content"],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
case routeScriptAdd:
|
||||||
|
return MaterialPageRoute(
|
||||||
|
builder: (context) => ScriptAddPage(
|
||||||
|
(settings.arguments as Map)["title"],
|
||||||
|
(settings.arguments as Map)["path"],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
case routerSubscription:
|
||||||
|
//部分低端手机用Cupertino滑动时掉帧,左侧会出现白色空白
|
||||||
|
return MaterialPageRoute(
|
||||||
|
builder: (context) => const SubscriptionPage(),
|
||||||
|
);
|
||||||
|
case routerSubscriptionDetail:
|
||||||
|
return MaterialPageRoute(
|
||||||
|
builder: (context) => SubscriptionDetailPage(
|
||||||
|
settings.arguments as Subscription,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
case routerSubscriptionAdd:
|
||||||
|
if (settings.arguments != null) {
|
||||||
|
return MaterialPageRoute(
|
||||||
|
builder: (context) => SubscriptionAddPage(
|
||||||
|
settings.arguments as Subscription,
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
return MaterialPageRoute(builder: (context) => const SubscriptionAddPage(null));
|
||||||
|
}
|
||||||
|
case routerBackup:
|
||||||
|
return MaterialPageRoute(
|
||||||
|
builder: (context) => const BackUpPage(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -6,3 +6,4 @@ String spTheme = "dart_mode";
|
|||||||
String spSecretLogined = "secret_logined";
|
String spSecretLogined = "secret_logined";
|
||||||
String spCustomColor = "customColor";
|
String spCustomColor = "customColor";
|
||||||
String spLoginHistory = "loginHistory";
|
String spLoginHistory = "loginHistory";
|
||||||
|
String spShowLine = "spShowLine";
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import 'package:qinglong_app/utils/sp_utils.dart';
|
|||||||
|
|
||||||
var themeProvider = ChangeNotifierProvider((ref) => ThemeViewModel());
|
var themeProvider = ChangeNotifierProvider((ref) => ThemeViewModel());
|
||||||
|
|
||||||
const commonColor = Color(0xFF299343);
|
Color commonColor = const Color(0xFF299343);
|
||||||
Color _primaryColor = commonColor;
|
Color _primaryColor = commonColor;
|
||||||
|
|
||||||
class ThemeViewModel extends ChangeNotifier {
|
class ThemeViewModel extends ChangeNotifier {
|
||||||
@@ -24,7 +24,7 @@ class ThemeViewModel extends ChangeNotifier {
|
|||||||
ThemeViewModel() {
|
ThemeViewModel() {
|
||||||
_primaryColor = Color(getIt<UserInfoViewModel>().primaryColor);
|
_primaryColor = Color(getIt<UserInfoViewModel>().primaryColor);
|
||||||
primaryColor = Color(getIt<UserInfoViewModel>().primaryColor);
|
primaryColor = Color(getIt<UserInfoViewModel>().primaryColor);
|
||||||
var brightness = SchedulerBinding.instance!.window.platformBrightness;
|
var brightness = SchedulerBinding.instance.window.platformBrightness;
|
||||||
_isInDarkMode = brightness == Brightness.dark;
|
_isInDarkMode = brightness == Brightness.dark;
|
||||||
changeThemeReal(_isInDarkMode, false);
|
changeThemeReal(_isInDarkMode, false);
|
||||||
}
|
}
|
||||||
@@ -69,9 +69,12 @@ class ThemeViewModel extends ChangeNotifier {
|
|||||||
secondary: _primaryColor,
|
secondary: _primaryColor,
|
||||||
primary: _primaryColor,
|
primary: _primaryColor,
|
||||||
),
|
),
|
||||||
scaffoldBackgroundColor: const Color(0xfff5f5f5),
|
scaffoldBackgroundColor: const Color(0xffffffff),
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
labelStyle: TextStyle(color: _primaryColor),
|
labelStyle: TextStyle(
|
||||||
|
color: _primaryColor,
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
focusedBorder: UnderlineInputBorder(
|
focusedBorder: UnderlineInputBorder(
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
color: _primaryColor,
|
color: _primaryColor,
|
||||||
@@ -152,7 +155,10 @@ class ThemeViewModel extends ChangeNotifier {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
labelStyle: TextStyle(color: _primaryColor),
|
labelStyle: TextStyle(
|
||||||
|
color: _primaryColor,
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
focusedBorder: UnderlineInputBorder(
|
focusedBorder: UnderlineInputBorder(
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
color: _primaryColor,
|
color: _primaryColor,
|
||||||
@@ -208,12 +214,17 @@ class ThemeViewModel extends ChangeNotifier {
|
|||||||
|
|
||||||
abstract class ThemeColors {
|
abstract class ThemeColors {
|
||||||
Color settingBgColor();
|
Color settingBgColor();
|
||||||
|
|
||||||
Color settingBordorColor();
|
Color settingBordorColor();
|
||||||
|
|
||||||
Color titleColor();
|
Color titleColor();
|
||||||
|
|
||||||
Color descColor();
|
Color descColor();
|
||||||
|
|
||||||
|
Color tabBarColor();
|
||||||
|
|
||||||
|
Color blackAndWhite();
|
||||||
|
|
||||||
Color pinColor();
|
Color pinColor();
|
||||||
|
|
||||||
Color buttonBgColor();
|
Color buttonBgColor();
|
||||||
@@ -232,6 +243,11 @@ class LightThemeColors extends ThemeColors {
|
|||||||
return const Color(0xffF7F7F7);
|
return const Color(0xffF7F7F7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color blackAndWhite() {
|
||||||
|
return Colors.white;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, TextStyle> codeEditorTheme() {
|
Map<String, TextStyle> codeEditorTheme() {
|
||||||
return qinglongLightTheme;
|
return qinglongLightTheme;
|
||||||
@@ -256,6 +272,11 @@ class LightThemeColors extends ThemeColors {
|
|||||||
Color settingBordorColor() {
|
Color settingBordorColor() {
|
||||||
return Colors.white;
|
return Colors.white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color tabBarColor() {
|
||||||
|
return const Color(0xffF7F7F7);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DartThemeColors extends ThemeColors {
|
class DartThemeColors extends ThemeColors {
|
||||||
@@ -274,6 +295,11 @@ class DartThemeColors extends ThemeColors {
|
|||||||
return qinglongDarkTheme;
|
return qinglongDarkTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color blackAndWhite() {
|
||||||
|
return Colors.black;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Color descColor() {
|
Color descColor() {
|
||||||
return const Color(0xff999999);
|
return const Color(0xff999999);
|
||||||
@@ -293,4 +319,9 @@ class DartThemeColors extends ThemeColors {
|
|||||||
Color settingBordorColor() {
|
Color settingBordorColor() {
|
||||||
return Color(0xff333333);
|
return Color(0xff333333);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color tabBarColor() {
|
||||||
|
return Colors.black;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mixin LazyLoadState<T extends StatefulWidget> on State<T> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||||
var route = ModalRoute.of(context);
|
var route = ModalRoute.of(context);
|
||||||
void handler(status) {
|
void handler(status) {
|
||||||
if (status == AnimationStatus.completed) {
|
if (status == AnimationStatus.completed) {
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
import 'package:flutter/gestures.dart' show kMinFlingVelocity, kLongPressTimeout;
|
import 'package:flutter/gestures.dart'
|
||||||
|
show kMinFlingVelocity, kLongPressTimeout;
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@@ -42,7 +43,8 @@ typedef _ContextMenuPreviewBuilderChildless = Widget Function(
|
|||||||
// paintBounds in global coordinates.
|
// paintBounds in global coordinates.
|
||||||
Rect _getRect(GlobalKey globalKey) {
|
Rect _getRect(GlobalKey globalKey) {
|
||||||
assert(globalKey.currentContext != null);
|
assert(globalKey.currentContext != null);
|
||||||
final RenderBox renderBoxContainer = globalKey.currentContext!.findRenderObject()! as RenderBox;
|
final RenderBox renderBoxContainer =
|
||||||
|
globalKey.currentContext!.findRenderObject()! as RenderBox;
|
||||||
final Offset containerOffset = renderBoxContainer.localToGlobal(
|
final Offset containerOffset = renderBoxContainer.localToGlobal(
|
||||||
renderBoxContainer.paintBounds.topLeft,
|
renderBoxContainer.paintBounds.topLeft,
|
||||||
);
|
);
|
||||||
@@ -87,7 +89,7 @@ enum _ContextMenuLocation {
|
|||||||
/// See also:
|
/// See also:
|
||||||
///
|
///
|
||||||
/// * [Apple's HIG for Context Menus](https://developer.apple.com/design/human-interface-guidelines/ios/controls/context-menus/)
|
/// * [Apple's HIG for Context Menus](https://developer.apple.com/design/human-interface-guidelines/ios/controls/context-menus/)
|
||||||
class QlCupertinoContextMenu extends StatefulWidget {
|
class QlCupertinoContextMenu<T> extends StatefulWidget {
|
||||||
/// Create a context menu.
|
/// Create a context menu.
|
||||||
///
|
///
|
||||||
/// [actions] is required and cannot be null or empty.
|
/// [actions] is required and cannot be null or empty.
|
||||||
@@ -103,7 +105,7 @@ class QlCupertinoContextMenu extends StatefulWidget {
|
|||||||
assert(child != null),
|
assert(child != null),
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
final TaskBean bean;
|
final T bean;
|
||||||
|
|
||||||
/// The widget that can be "opened" with the [QlCupertinoContextMenu].
|
/// The widget that can be "opened" with the [QlCupertinoContextMenu].
|
||||||
///
|
///
|
||||||
@@ -194,7 +196,8 @@ class QlCupertinoContextMenu extends StatefulWidget {
|
|||||||
State<QlCupertinoContextMenu> createState() => _QlCupertinoContextMenuState();
|
State<QlCupertinoContextMenu> createState() => _QlCupertinoContextMenuState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu> with TickerProviderStateMixin {
|
class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu>
|
||||||
|
with TickerProviderStateMixin {
|
||||||
final GlobalKey _childGlobalKey = GlobalKey();
|
final GlobalKey _childGlobalKey = GlobalKey();
|
||||||
bool _childHidden = false;
|
bool _childHidden = false;
|
||||||
|
|
||||||
@@ -227,7 +230,8 @@ class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu> with Ti
|
|||||||
final double screenWidth = MediaQuery.of(context).size.width;
|
final double screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
|
||||||
final double center = screenWidth / 2;
|
final double center = screenWidth / 2;
|
||||||
final bool centerDividesChild = childRect.left < center && childRect.right > center;
|
final bool centerDividesChild =
|
||||||
|
childRect.left < center && childRect.right > center;
|
||||||
final double distanceFromCenter = (center - childRect.center.dx).abs();
|
final double distanceFromCenter = (center - childRect.center.dx).abs();
|
||||||
if (centerDividesChild && distanceFromCenter <= childRect.width / 4) {
|
if (centerDividesChild && distanceFromCenter <= childRect.width / 4) {
|
||||||
return _ContextMenuLocation.center;
|
return _ContextMenuLocation.center;
|
||||||
@@ -318,7 +322,14 @@ class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu> with Ti
|
|||||||
_openController.reverse();
|
_openController.reverse();
|
||||||
} else {
|
} else {
|
||||||
if (_openController.isDismissed) {
|
if (_openController.isDismissed) {
|
||||||
Navigator.of(context).pushNamed(Routes.routeTaskDetail, arguments: widget.bean);
|
if (widget.bean is TaskBean){
|
||||||
|
Navigator.of(context)
|
||||||
|
.pushNamed(Routes.routeTaskDetail, arguments: widget.bean);
|
||||||
|
}else{
|
||||||
|
Navigator.of(context)
|
||||||
|
.pushNamed(Routes.routerSubscriptionDetail, arguments: widget.bean);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -419,7 +430,8 @@ class _DecoyChild extends StatefulWidget {
|
|||||||
_DecoyChildState createState() => _DecoyChildState();
|
_DecoyChildState createState() => _DecoyChildState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DecoyChildState extends State<_DecoyChild> with TickerProviderStateMixin {
|
class _DecoyChildState extends State<_DecoyChild>
|
||||||
|
with TickerProviderStateMixin {
|
||||||
// TODO(justinmc): Dark mode support.
|
// TODO(justinmc): Dark mode support.
|
||||||
// See https://github.com/flutter/flutter/issues/43211.
|
// See https://github.com/flutter/flutter/issues/43211.
|
||||||
static const Color _lightModeMaskColor = Color(0xFF888888);
|
static const Color _lightModeMaskColor = Color(0xFF888888);
|
||||||
@@ -481,7 +493,9 @@ class _DecoyChildState extends State<_DecoyChild> with TickerProviderStateMixin
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAnimation(BuildContext context, Widget? child) {
|
Widget _buildAnimation(BuildContext context, Widget? child) {
|
||||||
final Color color = widget.controller.status == AnimationStatus.reverse ? _masklessColor : _mask.value;
|
final Color color = widget.controller.status == AnimationStatus.reverse
|
||||||
|
? _masklessColor
|
||||||
|
: _mask.value;
|
||||||
return Positioned.fromRect(
|
return Positioned.fromRect(
|
||||||
rect: _rect.value!,
|
rect: _rect.value!,
|
||||||
child: ShaderMask(
|
child: ShaderMask(
|
||||||
@@ -538,7 +552,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
|
|
||||||
// The duration of the transition used when a modal popup is shown. Eyeballed
|
// The duration of the transition used when a modal popup is shown. Eyeballed
|
||||||
// from a physical device running iOS 13.1.2.
|
// from a physical device running iOS 13.1.2.
|
||||||
static const Duration _kModalPopupTransitionDuration = Duration(milliseconds: 335);
|
static const Duration _kModalPopupTransitionDuration =
|
||||||
|
Duration(milliseconds: 335);
|
||||||
|
|
||||||
final List<Widget> _actions;
|
final List<Widget> _actions;
|
||||||
final _ContextMenuPreviewBuilderChildless? _builder;
|
final _ContextMenuPreviewBuilderChildless? _builder;
|
||||||
@@ -562,7 +577,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
static final RectTween _rectTween = RectTween();
|
static final RectTween _rectTween = RectTween();
|
||||||
static final Animatable<Rect?> _rectAnimatable = _rectTween.chain(_curve);
|
static final Animatable<Rect?> _rectAnimatable = _rectTween.chain(_curve);
|
||||||
static final RectTween _rectTweenReverse = RectTween();
|
static final RectTween _rectTweenReverse = RectTween();
|
||||||
static final Animatable<Rect?> _rectAnimatableReverse = _rectTweenReverse.chain(
|
static final Animatable<Rect?> _rectAnimatableReverse =
|
||||||
|
_rectTweenReverse.chain(
|
||||||
_curveReverse,
|
_curveReverse,
|
||||||
);
|
);
|
||||||
static final RectTween _sheetRectTween = RectTween();
|
static final RectTween _sheetRectTween = RectTween();
|
||||||
@@ -573,10 +589,12 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
_curveReverse,
|
_curveReverse,
|
||||||
);
|
);
|
||||||
static final Tween<double> _sheetScaleTween = Tween<double>();
|
static final Tween<double> _sheetScaleTween = Tween<double>();
|
||||||
static final Animatable<double> _sheetScaleAnimatable = _sheetScaleTween.chain(
|
static final Animatable<double> _sheetScaleAnimatable =
|
||||||
|
_sheetScaleTween.chain(
|
||||||
_curve,
|
_curve,
|
||||||
);
|
);
|
||||||
static final Animatable<double> _sheetScaleAnimatableReverse = _sheetScaleTween.chain(
|
static final Animatable<double> _sheetScaleAnimatableReverse =
|
||||||
|
_sheetScaleTween.chain(
|
||||||
_curveReverse,
|
_curveReverse,
|
||||||
);
|
);
|
||||||
final Tween<double> _opacityTween = Tween<double>(begin: 0.0, end: 1.0);
|
final Tween<double> _opacityTween = Tween<double>(begin: 0.0, end: 1.0);
|
||||||
@@ -611,7 +629,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
|
|
||||||
// Get the alignment for the _ContextMenuSheet's Transform.scale based on the
|
// Get the alignment for the _ContextMenuSheet's Transform.scale based on the
|
||||||
// contextMenuLocation.
|
// contextMenuLocation.
|
||||||
static AlignmentDirectional getSheetAlignment(_ContextMenuLocation contextMenuLocation) {
|
static AlignmentDirectional getSheetAlignment(
|
||||||
|
_ContextMenuLocation contextMenuLocation) {
|
||||||
switch (contextMenuLocation) {
|
switch (contextMenuLocation) {
|
||||||
case _ContextMenuLocation.center:
|
case _ContextMenuLocation.center:
|
||||||
return AlignmentDirectional.topCenter;
|
return AlignmentDirectional.topCenter;
|
||||||
@@ -623,17 +642,27 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The place to start the sheetRect animation from.
|
// The place to start the sheetRect animation from.
|
||||||
static Rect _getSheetRectBegin(Orientation? orientation, _ContextMenuLocation contextMenuLocation, Rect childRect, Rect sheetRect) {
|
static Rect _getSheetRectBegin(
|
||||||
|
Orientation? orientation,
|
||||||
|
_ContextMenuLocation contextMenuLocation,
|
||||||
|
Rect childRect,
|
||||||
|
Rect sheetRect) {
|
||||||
switch (contextMenuLocation) {
|
switch (contextMenuLocation) {
|
||||||
case _ContextMenuLocation.center:
|
case _ContextMenuLocation.center:
|
||||||
final Offset target = orientation == Orientation.portrait ? childRect.bottomCenter : childRect.topCenter;
|
final Offset target = orientation == Orientation.portrait
|
||||||
|
? childRect.bottomCenter
|
||||||
|
: childRect.topCenter;
|
||||||
final Offset centered = target - Offset(sheetRect.width / 2, 0.0);
|
final Offset centered = target - Offset(sheetRect.width / 2, 0.0);
|
||||||
return centered & sheetRect.size;
|
return centered & sheetRect.size;
|
||||||
case _ContextMenuLocation.right:
|
case _ContextMenuLocation.right:
|
||||||
final Offset target = orientation == Orientation.portrait ? childRect.bottomRight : childRect.topRight;
|
final Offset target = orientation == Orientation.portrait
|
||||||
|
? childRect.bottomRight
|
||||||
|
: childRect.topRight;
|
||||||
return (target - Offset(sheetRect.width, 0.0)) & sheetRect.size;
|
return (target - Offset(sheetRect.width, 0.0)) & sheetRect.size;
|
||||||
case _ContextMenuLocation.left:
|
case _ContextMenuLocation.left:
|
||||||
final Offset target = orientation == Orientation.portrait ? childRect.bottomLeft : childRect.topLeft;
|
final Offset target = orientation == Orientation.portrait
|
||||||
|
? childRect.bottomLeft
|
||||||
|
: childRect.topLeft;
|
||||||
return target & sheetRect.size;
|
return target & sheetRect.size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -651,7 +680,9 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
// Take measurements on the child and _ContextMenuSheet and update the
|
// Take measurements on the child and _ContextMenuSheet and update the
|
||||||
// animation tweens to match.
|
// animation tweens to match.
|
||||||
void _updateTweenRects() {
|
void _updateTweenRects() {
|
||||||
final Rect childRect = _scale == null ? _getRect(_childGlobalKey) : _getScaledRect(_childGlobalKey, _scale!);
|
final Rect childRect = _scale == null
|
||||||
|
? _getRect(_childGlobalKey)
|
||||||
|
: _getScaledRect(_childGlobalKey, _scale!);
|
||||||
_rectTween.begin = _previousChildRect;
|
_rectTween.begin = _previousChildRect;
|
||||||
_rectTween.end = childRect;
|
_rectTween.end = childRect;
|
||||||
|
|
||||||
@@ -725,7 +756,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
|
Widget buildPage(BuildContext context, Animation<double> animation,
|
||||||
|
Animation<double> secondaryAnimation) {
|
||||||
// This is usually used to build the "page", which is then passed to
|
// This is usually used to build the "page", which is then passed to
|
||||||
// buildTransitions as child, the idea being that buildTransitions will
|
// buildTransitions as child, the idea being that buildTransitions will
|
||||||
// animate the entire page into the scene. In the case of _ContextMenuRoute,
|
// animate the entire page into the scene. In the case of _ContextMenuRoute,
|
||||||
@@ -735,7 +767,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget buildTransitions(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
|
Widget buildTransitions(BuildContext context, Animation<double> animation,
|
||||||
|
Animation<double> secondaryAnimation, Widget child) {
|
||||||
return OrientationBuilder(
|
return OrientationBuilder(
|
||||||
builder: (BuildContext context, Orientation orientation) {
|
builder: (BuildContext context, Orientation orientation) {
|
||||||
_lastOrientation = orientation;
|
_lastOrientation = orientation;
|
||||||
@@ -744,9 +777,15 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
// they're movable.
|
// they're movable.
|
||||||
if (!animation.isCompleted) {
|
if (!animation.isCompleted) {
|
||||||
final bool reverse = animation.status == AnimationStatus.reverse;
|
final bool reverse = animation.status == AnimationStatus.reverse;
|
||||||
final Rect rect = reverse ? _rectAnimatableReverse.evaluate(animation)! : _rectAnimatable.evaluate(animation)!;
|
final Rect rect = reverse
|
||||||
final Rect sheetRect = reverse ? _sheetRectAnimatableReverse.evaluate(animation)! : _sheetRectAnimatable.evaluate(animation)!;
|
? _rectAnimatableReverse.evaluate(animation)!
|
||||||
final double sheetScale = reverse ? _sheetScaleAnimatableReverse.evaluate(animation) : _sheetScaleAnimatable.evaluate(animation);
|
: _rectAnimatable.evaluate(animation)!;
|
||||||
|
final Rect sheetRect = reverse
|
||||||
|
? _sheetRectAnimatableReverse.evaluate(animation)!
|
||||||
|
: _sheetRectAnimatable.evaluate(animation)!;
|
||||||
|
final double sheetScale = reverse
|
||||||
|
? _sheetScaleAnimatableReverse.evaluate(animation)
|
||||||
|
: _sheetScaleAnimatable.evaluate(animation);
|
||||||
return Stack(
|
return Stack(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Positioned.fromRect(
|
Positioned.fromRect(
|
||||||
@@ -818,7 +857,8 @@ class _ContextMenuRouteStatic extends StatefulWidget {
|
|||||||
_ContextMenuRouteStaticState createState() => _ContextMenuRouteStaticState();
|
_ContextMenuRouteStaticState createState() => _ContextMenuRouteStaticState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with TickerProviderStateMixin {
|
class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic>
|
||||||
|
with TickerProviderStateMixin {
|
||||||
// The child is scaled down as it is dragged down until it hits this minimum
|
// The child is scaled down as it is dragged down until it hits this minimum
|
||||||
// value.
|
// value.
|
||||||
static const double _kMinScale = 0.8;
|
static const double _kMinScale = 0.8;
|
||||||
@@ -838,7 +878,8 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
|||||||
late Animation<double> _sheetOpacityAnimation;
|
late Animation<double> _sheetOpacityAnimation;
|
||||||
|
|
||||||
// The scale of the child changes as a function of the distance it is dragged.
|
// The scale of the child changes as a function of the distance it is dragged.
|
||||||
static double _getScale(Orientation orientation, double maxDragDistance, double dy) {
|
static double _getScale(
|
||||||
|
Orientation orientation, double maxDragDistance, double dy) {
|
||||||
final double dyDirectional = dy <= 0.0 ? dy : -dy;
|
final double dyDirectional = dy <= 0.0 ? dy : -dy;
|
||||||
return math.max(
|
return math.max(
|
||||||
_kMinScale,
|
_kMinScale,
|
||||||
@@ -859,11 +900,13 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
|||||||
// If flung, animate a bit before handling the potential dismiss.
|
// If flung, animate a bit before handling the potential dismiss.
|
||||||
if (details.velocity.pixelsPerSecond.dy.abs() >= kMinFlingVelocity) {
|
if (details.velocity.pixelsPerSecond.dy.abs() >= kMinFlingVelocity) {
|
||||||
final bool flingIsAway = details.velocity.pixelsPerSecond.dy > 0;
|
final bool flingIsAway = details.velocity.pixelsPerSecond.dy > 0;
|
||||||
final double finalPosition = flingIsAway ? _moveAnimation.value.dy + 100.0 : 0.0;
|
final double finalPosition =
|
||||||
|
flingIsAway ? _moveAnimation.value.dy + 100.0 : 0.0;
|
||||||
|
|
||||||
if (flingIsAway && _sheetController.status != AnimationStatus.forward) {
|
if (flingIsAway && _sheetController.status != AnimationStatus.forward) {
|
||||||
_sheetController.forward();
|
_sheetController.forward();
|
||||||
} else if (!flingIsAway && _sheetController.status != AnimationStatus.reverse) {
|
} else if (!flingIsAway &&
|
||||||
|
_sheetController.status != AnimationStatus.reverse) {
|
||||||
_sheetController.reverse();
|
_sheetController.reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -918,21 +961,30 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
|||||||
widget.onDismiss!(context, _lastScale, _sheetOpacityAnimation.value);
|
widget.onDismiss!(context, _lastScale, _sheetOpacityAnimation.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Alignment _getChildAlignment(Orientation orientation, _ContextMenuLocation contextMenuLocation) {
|
Alignment _getChildAlignment(
|
||||||
|
Orientation orientation, _ContextMenuLocation contextMenuLocation) {
|
||||||
switch (contextMenuLocation) {
|
switch (contextMenuLocation) {
|
||||||
case _ContextMenuLocation.center:
|
case _ContextMenuLocation.center:
|
||||||
return orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.topRight;
|
return orientation == Orientation.portrait
|
||||||
|
? Alignment.bottomCenter
|
||||||
|
: Alignment.topRight;
|
||||||
case _ContextMenuLocation.right:
|
case _ContextMenuLocation.right:
|
||||||
return orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.topLeft;
|
return orientation == Orientation.portrait
|
||||||
|
? Alignment.bottomCenter
|
||||||
|
: Alignment.topLeft;
|
||||||
case _ContextMenuLocation.left:
|
case _ContextMenuLocation.left:
|
||||||
return orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.topRight;
|
return orientation == Orientation.portrait
|
||||||
|
? Alignment.bottomCenter
|
||||||
|
: Alignment.topRight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setDragOffset(Offset dragOffset) {
|
void _setDragOffset(Offset dragOffset) {
|
||||||
// Allow horizontal and negative vertical movement, but damp it.
|
// Allow horizontal and negative vertical movement, but damp it.
|
||||||
final double endX = _kPadding * dragOffset.dx / _kDamping;
|
final double endX = _kPadding * dragOffset.dx / _kDamping;
|
||||||
final double endY = dragOffset.dy >= 0.0 ? dragOffset.dy : _kPadding * dragOffset.dy / _kDamping;
|
final double endY = dragOffset.dy >= 0.0
|
||||||
|
? dragOffset.dy
|
||||||
|
: _kPadding * dragOffset.dy / _kDamping;
|
||||||
setState(() {
|
setState(() {
|
||||||
_dragOffset = dragOffset;
|
_dragOffset = dragOffset;
|
||||||
_moveAnimation = Tween<Offset>(
|
_moveAnimation = Tween<Offset>(
|
||||||
@@ -949,9 +1001,13 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Fade the _ContextMenuSheet out or in, if needed.
|
// Fade the _ContextMenuSheet out or in, if needed.
|
||||||
if (_lastScale <= _kSheetScaleThreshold && _sheetController.status != AnimationStatus.forward && _sheetScaleAnimation.value != 0.0) {
|
if (_lastScale <= _kSheetScaleThreshold &&
|
||||||
|
_sheetController.status != AnimationStatus.forward &&
|
||||||
|
_sheetScaleAnimation.value != 0.0) {
|
||||||
_sheetController.forward();
|
_sheetController.forward();
|
||||||
} else if (_lastScale > _kSheetScaleThreshold && _sheetController.status != AnimationStatus.reverse && _sheetScaleAnimation.value != 1.0) {
|
} else if (_lastScale > _kSheetScaleThreshold &&
|
||||||
|
_sheetController.status != AnimationStatus.reverse &&
|
||||||
|
_sheetScaleAnimation.value != 1.0) {
|
||||||
_sheetController.reverse();
|
_sheetController.reverse();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -960,7 +1016,8 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
|||||||
// The order and alignment of the _ContextMenuSheet and the child depend on
|
// The order and alignment of the _ContextMenuSheet and the child depend on
|
||||||
// both the orientation of the screen as well as the position on the screen of
|
// both the orientation of the screen as well as the position on the screen of
|
||||||
// the original child.
|
// the original child.
|
||||||
List<Widget> _getChildren(Orientation orientation, _ContextMenuLocation contextMenuLocation) {
|
List<Widget> _getChildren(
|
||||||
|
Orientation orientation, _ContextMenuLocation contextMenuLocation) {
|
||||||
final Expanded child = Expanded(
|
final Expanded child = Expanded(
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: _getChildAlignment(
|
alignment: _getChildAlignment(
|
||||||
@@ -995,7 +1052,9 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
|||||||
case _ContextMenuLocation.center:
|
case _ContextMenuLocation.center:
|
||||||
return <Widget>[child, spacer, sheet];
|
return <Widget>[child, spacer, sheet];
|
||||||
case _ContextMenuLocation.right:
|
case _ContextMenuLocation.right:
|
||||||
return orientation == Orientation.portrait ? <Widget>[child, spacer, sheet] : <Widget>[sheet, spacer, child];
|
return orientation == Orientation.portrait
|
||||||
|
? <Widget>[child, spacer, sheet]
|
||||||
|
: <Widget>[sheet, spacer, child];
|
||||||
case _ContextMenuLocation.left:
|
case _ContextMenuLocation.left:
|
||||||
return <Widget>[child, spacer, sheet];
|
return <Widget>[child, spacer, sheet];
|
||||||
}
|
}
|
||||||
@@ -1004,7 +1063,8 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
|||||||
// Build the animation for the _ContextMenuSheet.
|
// Build the animation for the _ContextMenuSheet.
|
||||||
Widget _buildSheetAnimation(BuildContext context, Widget? child) {
|
Widget _buildSheetAnimation(BuildContext context, Widget? child) {
|
||||||
return Transform.scale(
|
return Transform.scale(
|
||||||
alignment: _ContextMenuRoute.getSheetAlignment(widget.contextMenuLocation),
|
alignment:
|
||||||
|
_ContextMenuRoute.getSheetAlignment(widget.contextMenuLocation),
|
||||||
scale: _sheetScaleAnimation.value,
|
scale: _sheetScaleAnimation.value,
|
||||||
child: FadeTransition(
|
child: FadeTransition(
|
||||||
opacity: _sheetOpacityAnimation,
|
opacity: _sheetOpacityAnimation,
|
||||||
|
|||||||
66
lib/base/ui/search_cell.dart
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
|
import '../theme.dart';
|
||||||
|
|
||||||
|
class SearchCell extends ConsumerStatefulWidget {
|
||||||
|
final TextEditingController controller;
|
||||||
|
|
||||||
|
const SearchCell({
|
||||||
|
Key? key,
|
||||||
|
required this.controller,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState createState() => _SearchCellState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SearchCellState extends ConsumerState<SearchCell> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return CupertinoSearchTextField(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: ref.watch(themeProvider).themeColor.blackAndWhite(),
|
||||||
|
border: Border.all(width: 1, color: const Color(0xffC0C4CC)),
|
||||||
|
borderRadius: BorderRadius.circular(
|
||||||
|
7,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onSuffixTap: () {
|
||||||
|
widget.controller.text = "";
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
controller: widget.controller,
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 5,
|
||||||
|
vertical: 5,
|
||||||
|
),
|
||||||
|
suffixInsets: const EdgeInsets.only(
|
||||||
|
right: 15,
|
||||||
|
),
|
||||||
|
prefixIcon: Image.asset(
|
||||||
|
"assets/images/icon_search.png",
|
||||||
|
width: 18,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
prefixInsets: const EdgeInsets.only(
|
||||||
|
left: 10,
|
||||||
|
top: 2,
|
||||||
|
),
|
||||||
|
placeholderStyle: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
placeholder: "请输入内容",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||