├── .github
└── workflows
│ └── Release.yml
├── .gitignore
├── .metadata
├── README.md
├── analysis_options.yaml
├── android
├── .gitignore
├── app
│ ├── build.gradle
│ └── src
│ │ ├── debug
│ │ └── AndroidManifest.xml
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── kotlin
│ │ │ └── opensource
│ │ │ │ └── jenny
│ │ │ │ ├── Jni.java
│ │ │ │ └── MainActivity.kt
│ │ └── res
│ │ │ ├── drawable-v21
│ │ │ └── launch_background.xml
│ │ │ ├── drawable
│ │ │ └── launch_background.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ └── ic_launcher.xml
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_background.png
│ │ │ ├── ic_foreground.png
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ ├── ic_background.png
│ │ │ ├── ic_foreground.png
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_background.png
│ │ │ ├── ic_foreground.png
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_background.png
│ │ │ ├── ic_foreground.png
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_background.png
│ │ │ ├── ic_foreground.png
│ │ │ └── ic_launcher.png
│ │ │ ├── values-night
│ │ │ └── styles.xml
│ │ │ └── values
│ │ │ └── styles.xml
│ │ └── profile
│ │ └── AndroidManifest.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
└── settings.gradle
├── ci
├── Cargo.toml
├── src
│ ├── check_asset
│ │ └── main.rs
│ ├── check_release
│ │ └── main.rs
│ ├── community_notify
│ │ └── main.rs
│ ├── main.rs
│ └── upload_asset
│ │ └── main.rs
├── version.code.txt
└── version.info.txt
├── images
└── technologies.png
├── ios
├── .gitignore
├── Flutter
│ ├── AppFrameworkInfo.plist
│ ├── Debug.xcconfig
│ └── Release.xcconfig
├── Podfile
├── Podfile.lock
├── Runner.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ └── WorkspaceSettings.xcsettings
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── Runner.xcscheme
├── Runner.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ ├── IDEWorkspaceChecks.plist
│ │ └── WorkspaceSettings.xcsettings
└── Runner
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ ├── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── Icon-App-1024x1024@1x.png
│ │ ├── Icon-App-20x20@1x.png
│ │ ├── Icon-App-20x20@2x.png
│ │ ├── Icon-App-20x20@3x.png
│ │ ├── Icon-App-29x29@1x.png
│ │ ├── Icon-App-29x29@2x.png
│ │ ├── Icon-App-29x29@3x.png
│ │ ├── Icon-App-40x40@1x.png
│ │ ├── Icon-App-40x40@2x.png
│ │ ├── Icon-App-40x40@3x.png
│ │ ├── Icon-App-60x60@2x.png
│ │ ├── Icon-App-60x60@3x.png
│ │ ├── Icon-App-76x76@1x.png
│ │ ├── Icon-App-76x76@2x.png
│ │ └── Icon-App-83.5x83.5@2x.png
│ └── LaunchImage.imageset
│ │ ├── Contents.json
│ │ ├── LaunchImage.png
│ │ ├── LaunchImage@2x.png
│ │ ├── LaunchImage@3x.png
│ │ └── README.md
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ ├── Info.plist
│ └── Runner-Bridging-Header.h
├── lib
├── assets
│ ├── backpoint.png
│ ├── error.png
│ ├── startup.png
│ └── startup.webp
├── basic
│ ├── commons.dart
│ ├── desktop.dart
│ ├── entities.dart
│ ├── methods.dart
│ ├── navigator.dart
│ └── web_dav_sync.dart
├── configs
│ ├── android_display_mode.dart
│ ├── android_version.dart
│ ├── auto_clean.dart
│ ├── configs.dart
│ ├── display_jmcode.dart
│ ├── download_and_export_to.dart
│ ├── download_thread_count.dart
│ ├── export_path.dart
│ ├── export_rename.dart
│ ├── import_notice.dart
│ ├── is_pro.dart
│ ├── login.dart
│ ├── network_api_host.dart
│ ├── network_cdn_host.dart
│ ├── no_animation.dart
│ ├── pager_column_number.dart
│ ├── pager_controller_mode.dart
│ ├── pager_cover_rate.dart
│ ├── pager_view_mode.dart
│ ├── passed.dart
│ ├── proxy.dart
│ ├── reader_controller_type.dart
│ ├── reader_direction.dart
│ ├── reader_slider_position.dart
│ ├── reader_type.dart
│ ├── search_title_words.dart
│ ├── theme.dart
│ ├── using_right_click_pop.dart
│ ├── versions.dart
│ ├── volume_key_control.dart
│ ├── web_dav_password.dart
│ ├── web_dav_sync_switch.dart
│ ├── web_dav_url.dart
│ └── web_dav_username.dart
├── main.dart
└── screens
│ ├── about_screen.dart
│ ├── app_screen.dart
│ ├── browser_screen.dart
│ ├── calculator_screen.dart
│ ├── comic_download_screen.dart
│ ├── comic_info_screen.dart
│ ├── comic_reader_screen.dart
│ ├── comic_search_screen.dart
│ ├── comments_screen.dart
│ ├── components
│ ├── actions.dart
│ ├── avatar.dart
│ ├── badge.dart
│ ├── browser_bottom_sheet.dart
│ ├── comic_comments_list.dart
│ ├── comic_download_card.dart
│ ├── comic_floating_search_bar.dart
│ ├── comic_info_card.dart
│ ├── comic_list.dart
│ ├── comic_pager.dart
│ ├── content_builder.dart
│ ├── content_error.dart
│ ├── content_loading.dart
│ ├── continue_read_button.dart
│ ├── error_types.dart
│ ├── floating_search_bar.dart
│ ├── images.dart
│ ├── item_builder.dart
│ ├── mouse_and_touch_scroll_behavior.dart
│ ├── my_flat_button.dart
│ └── right_click_pop.dart
│ ├── download_album_screen.dart
│ ├── download_import_screen.dart
│ ├── downloads_exporting_screen.dart
│ ├── downloads_exporting_screen2.dart
│ ├── downloads_exports_screen.dart
│ ├── downloads_exports_screen2.dart
│ ├── downloads_screen.dart
│ ├── favorites_screen.dart
│ ├── file_photo_view_screen.dart
│ ├── first_login_screen.dart
│ ├── init_screen.dart
│ ├── network_setting_screen.dart
│ ├── pro_screen.dart
│ ├── settings_screen.dart
│ ├── user_screen.dart
│ └── view_log_screen.dart
├── linux
├── .gitignore
├── CMakeLists.txt
├── appimage
│ ├── AppRun.desktop
│ └── AppRun.png
├── flutter
│ ├── CMakeLists.txt
│ ├── generated_plugin_registrant.cc
│ ├── generated_plugin_registrant.h
│ └── generated_plugins.cmake
├── main.cc
├── methods_plugin.cc
├── methods_plugin.h
├── my_application.cc
└── my_application.h
├── macos
├── .gitignore
├── Flutter
│ ├── Flutter-Debug.xcconfig
│ ├── Flutter-Release.xcconfig
│ └── GeneratedPluginRegistrant.swift
├── Podfile
├── Podfile.lock
├── Runner.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── Runner.xcscheme
├── Runner.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── Runner
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── app_icon_1024.png
│ │ ├── app_icon_128.png
│ │ ├── app_icon_16.png
│ │ ├── app_icon_256.png
│ │ ├── app_icon_32.png
│ │ ├── app_icon_512.png
│ │ └── app_icon_64.png
│ ├── Base.lproj
│ └── MainMenu.xib
│ ├── Configs
│ ├── AppInfo.xcconfig
│ ├── Debug.xcconfig
│ ├── Release.xcconfig
│ └── Warnings.xcconfig
│ ├── DebugProfile.entitlements
│ ├── Info.plist
│ ├── MainFlutterWindow.swift
│ ├── Release.entitlements
│ └── Runner-Bridging-Header.h
├── native
├── jmbackend
│ ├── .gitignore
│ ├── Cargo.toml
│ ├── platforms
│ │ ├── android
│ │ │ ├── Cargo.toml
│ │ │ └── src
│ │ │ │ └── lib.rs
│ │ ├── ios-sim
│ │ │ ├── Cargo.toml
│ │ │ └── src
│ │ │ │ └── lib.rs
│ │ ├── ios
│ │ │ ├── Cargo.toml
│ │ │ └── src
│ │ │ │ └── lib.rs
│ │ ├── linux
│ │ │ ├── Cargo.toml
│ │ │ └── src
│ │ │ │ └── lib.rs
│ │ ├── macos
│ │ │ ├── Cargo.toml
│ │ │ └── src
│ │ │ │ └── lib.rs
│ │ └── windows
│ │ │ ├── Cargo.toml
│ │ │ └── src
│ │ │ └── lib.rs
│ └── src
│ │ ├── database
│ │ ├── active_db
│ │ │ ├── dl_album.rs
│ │ │ ├── dl_chapter.rs
│ │ │ ├── dl_image.rs
│ │ │ ├── mod.rs
│ │ │ ├── search_history.rs
│ │ │ ├── view_log.rs
│ │ │ └── view_log_tag.rs
│ │ ├── image_cache_db
│ │ │ ├── image_cache.rs
│ │ │ └── mod.rs
│ │ ├── mod.rs
│ │ ├── property_db
│ │ │ ├── migrations.rs
│ │ │ ├── mod.rs
│ │ │ └── property.rs
│ │ ├── utils.rs
│ │ └── web_cache_db
│ │ │ ├── mod.rs
│ │ │ └── web_cache.rs
│ │ ├── define.rs
│ │ ├── download.rs
│ │ ├── export.rs
│ │ ├── lib.rs
│ │ ├── sync.rs
│ │ ├── tests.rs
│ │ ├── tools.rs
│ │ └── types.rs
└── jmcomic-rs
│ ├── .gitignore
│ ├── Cargo.toml
│ └── src
│ ├── entities.rs
│ ├── lib.rs
│ ├── tests.rs
│ └── tools.rs
├── pubspec.yaml
├── scripts
├── sign-apk-github-actions.sh
└── thin-payload.sh
├── test
└── widget_test.dart
└── windows
├── .gitignore
├── CMakeLists.txt
├── flutter
├── CMakeLists.txt
├── generated_plugin_registrant.cc
├── generated_plugin_registrant.h
└── generated_plugins.cmake
└── runner
├── CMakeLists.txt
├── Runner.rc
├── flutter_window.cpp
├── flutter_window.h
├── main.cpp
├── methods_plugin.cpp
├── methods_plugin.h
├── resource.h
├── resources
└── app_icon.ico
├── runner.exe.manifest
├── utils.cpp
├── utils.h
├── win32_window.cpp
└── win32_window.h
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | **/ios/Flutter/.last_build_id
26 | .dart_tool/
27 | .flutter-plugins
28 | .flutter-plugins-dependencies
29 | .packages
30 | .pub-cache/
31 | .pub/
32 | /build/
33 |
34 | # Web related
35 | lib/generated_plugin_registrant.dart
36 |
37 | # Symbolication related
38 | app.*.symbols
39 |
40 | # Obfuscation related
41 | app.*.map.json
42 |
43 | # Android Studio will place build artifacts here
44 | /android/app/debug
45 | /android/app/profile
46 | /android/app/release
47 |
48 |
49 | *.iml
50 | .idea/
51 |
52 | .vscode/
53 |
54 | /android/**/*.so
55 | /macos/rust.h
56 | /macos/librust.a
57 | /ios/rust.h
58 | /ios/librust.a
59 |
60 | /lib/assets/version.txt
61 |
62 | cmake-build-*/
63 | windows/rust.h
64 | windows/rust.lib
65 | windows/rust1.h
66 | /data/
67 |
68 | pubspec.lock
69 | Cargo.lock
70 | target/
71 |
72 | linux/librust.a
73 | linux/rust.h
74 | linux/rust1.h
75 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 77d935af4db863f6abd0b9c31c7e6df2a13de57b
8 | channel: stable
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Jenny Comic
2 | =============
3 |
4 | A comic browser,support Android / iOS / MacOS / Windows / Linux.
5 |
6 |
7 | 1. This APP has restricted content
8 | 2. Please know local laws before using these codes
9 | 3. The owner of the repo will not release these codes and its assets to the community outside github
10 |
11 |
12 | ## Features
13 |
14 | - [x] Comics
15 | - [x] Comic categories
16 | - [x] Comic reader
17 | - [x] Comic search
18 | - [x] Comic favours
19 | - [x] Histories
20 | - [x] Cache comic
21 | - [ ] Games
22 | - [x] Community
23 | - [x] List comments
24 | - [x] Send comments
25 | - [x] User
26 | - [x] Login / Register
27 | - [x] Devices adaptation
28 | - [x] Android's high frequency screen
29 |
30 | ## Technical architecture
31 |
32 | Flutter: high-performance UI
33 |
34 | Rust: High performance service
35 |
36 | 
37 |
38 | ## Please follow the rules
39 |
40 | - These codes can only be learned and used, and are prohibited for commercial use
41 | - Do not send Assets to anyone
42 |
43 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the analyzer, which statically analyzes Dart code to
2 | # check for errors, warnings, and lints.
3 | #
4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6 | # invoked from the command line by running `flutter analyze`.
7 |
8 | # The following line activates a set of recommended lints for Flutter apps,
9 | # packages, and plugins designed to encourage good coding practices.
10 | include: package:flutter_lints/flutter.yaml
11 |
12 | linter:
13 | # The lint rules applied to this project can be customized in the
14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml`
15 | # included above or to enable additional rules. A list of all available lints
16 | # and their documentation is published at
17 | # https://dart-lang.github.io/linter/lints/index.html.
18 | #
19 | # Instead of disabling a lint rule for the entire project in the
20 | # section below, it can also be suppressed for a single line of code
21 | # or a specific dart file by using the `// ignore: name_of_lint` and
22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file
23 | # producing the lint.
24 | rules:
25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule
26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27 |
28 | # Additional information about this file can be found at
29 | # https://dart.dev/guides/language/analysis-options
30 |
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
9 | # Remember to never publicly share your keystore.
10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11 | key.properties
12 | **/*.keystore
13 | **/*.jks
14 |
--------------------------------------------------------------------------------
/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply plugin: 'kotlin-android'
26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 |
28 | android {
29 | compileSdkVersion 33 // flutter.compileSdkVersion
30 | // ndkVersion flutter.ndkVersion
31 |
32 | compileOptions {
33 | sourceCompatibility JavaVersion.VERSION_1_8
34 | targetCompatibility JavaVersion.VERSION_1_8
35 | }
36 |
37 | kotlinOptions {
38 | jvmTarget = '1.8'
39 | }
40 |
41 | sourceSets {
42 | main.java.srcDirs += 'src/main/kotlin'
43 | }
44 |
45 | defaultConfig {
46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
47 | applicationId "opensource.jenny"
48 | // You can update the following values to match your application needs.
49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
50 | minSdkVersion 19 // flutter.minSdkVersion
51 | targetSdkVersion flutter.targetSdkVersion
52 | versionCode flutterVersionCode.toInteger()
53 | versionName flutterVersionName
54 | }
55 |
56 | buildTypes {
57 | release {
58 | // TODO: Add your own signing config for the release build.
59 | // Signing with the debug keys for now, so `flutter run --release` works.
60 | signingConfig signingConfigs.debug
61 | }
62 | }
63 | }
64 |
65 | flutter {
66 | source '../..'
67 | }
68 |
69 | dependencies {
70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
71 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1'
72 | }
73 |
--------------------------------------------------------------------------------
/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
23 |
31 |
35 |
39 |
40 |
41 |
42 |
43 |
44 |
46 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/android/app/src/main/kotlin/opensource/jenny/Jni.java:
--------------------------------------------------------------------------------
1 | package opensource.jenny;
2 |
3 | public class Jni {
4 |
5 | public static native void init(final String path);
6 |
7 | public static native String invoke(final String params);
8 |
9 | static {
10 | System.loadLibrary("rust");
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable-v21/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/android/app/src/main/res/mipmap-hdpi/ic_background.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/android/app/src/main/res/mipmap-hdpi/ic_foreground.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/android/app/src/main/res/mipmap-mdpi/ic_background.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/android/app/src/main/res/mipmap-mdpi/ic_foreground.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/android/app/src/main/res/mipmap-xhdpi/ic_background.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/android/app/src/main/res/mipmap-xhdpi/ic_foreground.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/android/app/src/main/res/mipmap-xxhdpi/ic_background.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/android/app/src/main/res/mipmap-xxhdpi/ic_foreground.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/android/app/src/main/res/mipmap-xxxhdpi/ic_background.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/android/app/src/main/res/mipmap-xxxhdpi/ic_foreground.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
19 |
20 |
--------------------------------------------------------------------------------
/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
19 |
20 |
--------------------------------------------------------------------------------
/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.7.10'
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:7.2.0'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | mavenCentral()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | tasks.register("clean", Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
6 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4 | def properties = new Properties()
5 |
6 | assert localPropertiesFile.exists()
7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
8 |
9 | def flutterSdkPath = properties.getProperty("flutter.sdk")
10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
12 |
--------------------------------------------------------------------------------
/ci/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "ci"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | [[bin]]
7 | name = "check-release"
8 | path = "src/check_release/main.rs"
9 |
10 | [[bin]]
11 | name = "check-asset"
12 | path = "src/check_asset/main.rs"
13 |
14 | [[bin]]
15 | name = "upload-asset"
16 | path = "src/upload_asset/main.rs"
17 |
18 | [[bin]]
19 | name = "community-notify"
20 | path = "src/community_notify/main.rs"
21 |
22 | [dependencies]
23 | anyhow = "1.0.75"
24 | reqwest = { version = "0.11.10", features = ["json"] }
25 | serde = { version = "1.0.190", features = ["derive"] }
26 | serde_derive = "1.0.190"
27 | serde_json = "1.0.108"
28 | tokio = { version = "1.33.0", features = ["full"] }
29 | teloxide = { version = "0.9", features = ["macros", "auto-send"] }
30 | serenity = { version = "0.11", features = ["builder", "cache", "client", "gateway", "http", "model", "utils", "rustls_backend"], default-features = false }
31 |
--------------------------------------------------------------------------------
/ci/src/check_release/main.rs:
--------------------------------------------------------------------------------
1 | use anyhow::Result;
2 | use std::collections::HashMap;
3 | use std::process::exit;
4 |
5 | const OWNER: &str = "niuhuan";
6 | const REPO: &str = "jenny";
7 | const UA: &str = "niuhuan jenny ci";
8 | const MAIN_BRANCH: &str = "main";
9 |
10 | #[tokio::main]
11 | async fn main() -> Result<()> {
12 | // get ghToken
13 | let gh_token = std::env::var("GITHUB_TOKEN")?;
14 | if gh_token.is_empty() {
15 | panic!("Please set GITHUB_TOKEN");
16 | }
17 |
18 | let vs_code_txt = tokio::fs::read_to_string("version.code.txt").await?;
19 | let vs_info_txt = tokio::fs::read_to_string("version.info.txt").await?;
20 |
21 | let code = vs_code_txt.trim();
22 | let info = vs_info_txt.trim();
23 |
24 | let client = reqwest::ClientBuilder::new().user_agent(UA).build()?;
25 |
26 | let check_response = client
27 | .get(format!(
28 | "https://api.github.com/repos/{}/{}/releases/tags/{}",
29 | OWNER, REPO, code
30 | ))
31 | .send()
32 | .await?;
33 |
34 | match check_response.status().as_u16() {
35 | 200 => {
36 | println!("release exists");
37 | exit(0);
38 | }
39 | 404 => (),
40 | code => {
41 | let text = check_response.text().await?;
42 | panic!("error for check release : {} : {}", code, text);
43 | }
44 | }
45 | drop(check_response);
46 |
47 | // 404
48 |
49 | let check_response = client
50 | .post(format!(
51 | "https://api.github.com/repos/{}/{}/releases",
52 | OWNER, REPO
53 | ))
54 | .header("Authorization", format!("token {}", gh_token))
55 | .json(&{
56 | let mut params = HashMap::::new();
57 | params.insert("tag_name".to_string(), code.to_string());
58 | params.insert("target_commitish".to_string(), MAIN_BRANCH.to_string());
59 | params.insert("name".to_string(), code.to_string());
60 | params.insert("body".to_string(), info.to_string());
61 | params
62 | })
63 | .send()
64 | .await?;
65 |
66 | match check_response.status().as_u16() {
67 | 201 => (),
68 | code => {
69 | let text = check_response.text().await?;
70 | panic!("error for create release : {} : {}", code, text);
71 | }
72 | }
73 | Ok(())
74 | }
75 |
--------------------------------------------------------------------------------
/ci/src/community_notify/main.rs:
--------------------------------------------------------------------------------
1 | use anyhow::Result;
2 |
3 | const OWNER: &str = "niuhuan";
4 | const REPO: &str = "jenny";
5 |
6 | #[tokio::main]
7 | async fn main() -> Result<()> {
8 | let vs_code_txt = tokio::fs::read_to_string("version.code.txt").await?;
9 | let vs_info_txt = tokio::fs::read_to_string("version.info.txt").await?;
10 |
11 | let info = format!(
12 | "{REPO} 版本 {vs_code_txt} 发布! \n\n更新内容:\n{vs_info_txt}\n\nhttps://github.com/{OWNER}/{REPO}/releases/tag/{vs_code_txt}",
13 | );
14 |
15 | // get accounts
16 | let tg_token = match std::env::var("TG_BOT_TOKEN") {
17 | Ok(s) => s,
18 | Err(_) => "".to_owned(),
19 | };
20 | let tg_chat_id = match std::env::var("TG_CHAT_IDS") {
21 | Ok(s) => s,
22 | Err(_) => "".to_owned(),
23 | };
24 | let dc_token = match std::env::var("DISCORD_BOT_TOKEN") {
25 | Ok(s) => s,
26 | Err(_) => "".to_owned(),
27 | };
28 | let dc_chat_id = match std::env::var("DISCORD_CHAT_IDS") {
29 | Ok(s) => s,
30 | Err(_) => "".to_owned(),
31 | };
32 |
33 | println!("loaded");
34 |
35 | if !tg_token.is_empty() && !tg_chat_id.is_empty() {
36 | match send_to_tg(tg_token, tg_chat_id, info.clone()).await {
37 | Ok(_) => println!("send to tg OK"),
38 | Err(e) => println!("send to tg err : {}", e.to_string()),
39 | };
40 | }
41 | if !dc_token.is_empty() && !dc_chat_id.is_empty() {
42 | match send_to_dc(dc_token, dc_chat_id, info.clone()).await {
43 | Ok(_) => println!("send to dc OK"),
44 | Err(e) => println!("send to dc err : {}", e.to_string()),
45 | };
46 | }
47 | Ok(())
48 | }
49 |
50 | async fn send_to_tg(tg_token: String, tg_chat_id: String, info: String) -> Result<()> {
51 | use teloxide::prelude::Requester;
52 | use teloxide::prelude::*;
53 | use teloxide::Bot;
54 | let bot = Bot::new(tg_token);
55 | let _ = bot
56 | .send_message(ChatId(tg_chat_id.parse()?), info)
57 | .send()
58 | .await?;
59 | Ok(())
60 | }
61 |
62 | async fn send_to_dc(dc_token: String, dc_chat_id: String, info: String) -> Result<()> {
63 | use serenity::client::ClientBuilder;
64 | use serenity::prelude::GatewayIntents;
65 | let intents = GatewayIntents::GUILDS
66 | | GatewayIntents::GUILD_MEMBERS
67 | | GatewayIntents::GUILD_BANS
68 | | GatewayIntents::GUILD_MESSAGES
69 | | GatewayIntents::GUILD_MESSAGE_REACTIONS;
70 | let client = ClientBuilder::new(dc_token, intents).await?;
71 | let cid = dc_chat_id.parse::()?;
72 | serenity::model::id::ChannelId::from(cid)
73 | .say(client.cache_and_http.http.as_ref(), info)
74 | .await?;
75 | Ok(())
76 | }
77 |
--------------------------------------------------------------------------------
/ci/src/main.rs:
--------------------------------------------------------------------------------
1 | fn main() {
2 | println!("Hello, world!");
3 | }
4 |
--------------------------------------------------------------------------------
/ci/version.code.txt:
--------------------------------------------------------------------------------
1 | v0.2.6
2 |
--------------------------------------------------------------------------------
/ci/version.info.txt:
--------------------------------------------------------------------------------
1 | v0.2.6
2 |
--------------------------------------------------------------------------------
/images/technologies.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/images/technologies.png
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | **/dgph
2 | *.mode1v3
3 | *.mode2v3
4 | *.moved-aside
5 | *.pbxuser
6 | *.perspectivev3
7 | **/*sync/
8 | .sconsign.dblite
9 | .tags*
10 | **/.vagrant/
11 | **/DerivedData/
12 | Icon?
13 | **/Pods/
14 | **/.symlinks/
15 | profile
16 | xcuserdata
17 | **/.generated/
18 | Flutter/App.framework
19 | Flutter/Flutter.framework
20 | Flutter/Flutter.podspec
21 | Flutter/Generated.xcconfig
22 | Flutter/ephemeral/
23 | Flutter/app.flx
24 | Flutter/app.zip
25 | Flutter/flutter_assets/
26 | Flutter/flutter_export_environment.sh
27 | ServiceDefinitions.json
28 | Runner/GeneratedPluginRegistrant.*
29 |
30 | # Exceptions to above rules.
31 | !default.mode1v3
32 | !default.mode2v3
33 | !default.pbxuser
34 | !default.perspectivev3
35 |
--------------------------------------------------------------------------------
/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 11.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment this line to define a global platform for your project
2 | # platform :ios, '11.0'
3 |
4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6 |
7 | project 'Runner', {
8 | 'Debug' => :debug,
9 | 'Profile' => :release,
10 | 'Release' => :release,
11 | }
12 |
13 | def flutter_root
14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15 | unless File.exist?(generated_xcode_build_settings_path)
16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
17 | end
18 |
19 | File.foreach(generated_xcode_build_settings_path) do |line|
20 | matches = line.match(/FLUTTER_ROOT\=(.*)/)
21 | return matches[1].strip if matches
22 | end
23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
24 | end
25 |
26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
27 |
28 | flutter_ios_podfile_setup
29 |
30 | target 'Runner' do
31 | use_frameworks!
32 | use_modular_headers!
33 |
34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
35 | end
36 |
37 | post_install do |installer|
38 | installer.pods_project.targets.each do |target|
39 | flutter_additional_ios_build_settings(target)
40 | end
41 | end
42 |
--------------------------------------------------------------------------------
/ios/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - DKImagePickerController/Core (4.3.4):
3 | - DKImagePickerController/ImageDataManager
4 | - DKImagePickerController/Resource
5 | - DKImagePickerController/ImageDataManager (4.3.4)
6 | - DKImagePickerController/PhotoGallery (4.3.4):
7 | - DKImagePickerController/Core
8 | - DKPhotoGallery
9 | - DKImagePickerController/Resource (4.3.4)
10 | - DKPhotoGallery (0.0.17):
11 | - DKPhotoGallery/Core (= 0.0.17)
12 | - DKPhotoGallery/Model (= 0.0.17)
13 | - DKPhotoGallery/Preview (= 0.0.17)
14 | - DKPhotoGallery/Resource (= 0.0.17)
15 | - SDWebImage
16 | - SwiftyGif
17 | - DKPhotoGallery/Core (0.0.17):
18 | - DKPhotoGallery/Model
19 | - DKPhotoGallery/Preview
20 | - SDWebImage
21 | - SwiftyGif
22 | - DKPhotoGallery/Model (0.0.17):
23 | - SDWebImage
24 | - SwiftyGif
25 | - DKPhotoGallery/Preview (0.0.17):
26 | - DKPhotoGallery/Model
27 | - DKPhotoGallery/Resource
28 | - SDWebImage
29 | - SwiftyGif
30 | - DKPhotoGallery/Resource (0.0.17):
31 | - SDWebImage
32 | - SwiftyGif
33 | - file_picker (0.0.1):
34 | - DKImagePickerController/PhotoGallery
35 | - Flutter
36 | - Flutter (1.0.0)
37 | - permission_handler_apple (9.0.4):
38 | - Flutter
39 | - SDWebImage (5.13.4):
40 | - SDWebImage/Core (= 5.13.4)
41 | - SDWebImage/Core (5.13.4)
42 | - SwiftyGif (5.4.3)
43 | - url_launcher_ios (0.0.1):
44 | - Flutter
45 |
46 | DEPENDENCIES:
47 | - file_picker (from `.symlinks/plugins/file_picker/ios`)
48 | - Flutter (from `Flutter`)
49 | - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
50 | - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
51 |
52 | SPEC REPOS:
53 | trunk:
54 | - DKImagePickerController
55 | - DKPhotoGallery
56 | - SDWebImage
57 | - SwiftyGif
58 |
59 | EXTERNAL SOURCES:
60 | file_picker:
61 | :path: ".symlinks/plugins/file_picker/ios"
62 | Flutter:
63 | :path: Flutter
64 | permission_handler_apple:
65 | :path: ".symlinks/plugins/permission_handler_apple/ios"
66 | url_launcher_ios:
67 | :path: ".symlinks/plugins/url_launcher_ios/ios"
68 |
69 | SPEC CHECKSUMS:
70 | DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac
71 | DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
72 | file_picker: 817ab1d8cd2da9d2da412a417162deee3500fc95
73 | Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
74 | permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce
75 | SDWebImage: e5cc87bf736e60f49592f307bdf9e157189298a3
76 | SwiftyGif: 6c3eafd0ce693cad58bb63d2b2fb9bacb8552780
77 | url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
78 |
79 | PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
80 |
81 | COCOAPODS: 1.12.1
82 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 |
11 | let documentDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
12 | let fromChars = documentDirectory.cString(using: String.Encoding.utf8)
13 |
14 | let applicationSupportDirectory = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true)[0]
15 | let chars = applicationSupportDirectory.cString(using: String.Encoding.utf8)
16 |
17 | migration_ffi(fromChars,chars)
18 | init_ffi(chars!)
19 |
20 |
21 | let controller = self.window.rootViewController as! FlutterViewController
22 | FlutterMethodChannel.init(name: "methods", binaryMessenger: controller as! FlutterBinaryMessenger).setMethodCallHandler { (call, result) in
23 | Thread {
24 | switch (call.method){
25 | case "invoke":
26 | if let params = call.arguments as? String{
27 | let chars = params.cString(using: String.Encoding.utf8)
28 | let rsp = invoke_ffi(chars!)
29 | let response = String.init(utf8String: rsp!)
30 | free_str_ffi(rsp)
31 | result(response)
32 | }
33 | break
34 | case "saveImageFileToGallery":
35 | if let path = call.arguments as? String{
36 | do {
37 | let fileURL: URL = URL(fileURLWithPath: path)
38 | let imageData = try Data(contentsOf: fileURL)
39 | if let uiImage = UIImage(data: imageData) {
40 | UIImageWriteToSavedPhotosAlbum(uiImage, nil, nil, nil)
41 | result("OK")
42 | }else{
43 | result(FlutterError(code: "", message: "Error loading image ", details: ""))
44 | }
45 | } catch {
46 | result(FlutterError(code: "", message: "Error loading image : \(error)", details: ""))
47 | }
48 | }else{
49 | result(FlutterError(code: "", message: "params error", details: ""))
50 | }
51 | case "iosGetDocumentDir" :
52 | result(documentDirectory)
53 | default:
54 | result(FlutterMethodNotImplemented)
55 | }
56 | }.start()
57 | }
58 |
59 |
60 | GeneratedPluginRegistrant.register(with: self)
61 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | 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.
--------------------------------------------------------------------------------
/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CADisableMinimumFrameDurationOnPhone
6 |
7 | CFBundleDevelopmentRegion
8 | $(DEVELOPMENT_LANGUAGE)
9 | CFBundleDisplayName
10 | jenny
11 | CFBundleExecutable
12 | $(EXECUTABLE_NAME)
13 | CFBundleIdentifier
14 | $(PRODUCT_BUNDLE_IDENTIFIER)
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleName
18 | jenny
19 | CFBundlePackageType
20 | APPL
21 | CFBundleShortVersionString
22 | $(FLUTTER_BUILD_NAME)
23 | CFBundleSignature
24 | ????
25 | CFBundleVersion
26 | $(FLUTTER_BUILD_NUMBER)
27 | LSApplicationCategoryType
28 | public.app-category.entertainment
29 | LSRequiresIPhoneOS
30 |
31 | LSSupportsOpeningDocumentsInPlace
32 |
33 | NSPhotoLibraryAddUsageDescription
34 | Usage images
35 | NSPhotoLibraryUsageDescription
36 | Save images
37 | UIApplicationSupportsIndirectInputEvents
38 |
39 | UIFileSharingEnabled
40 |
41 | UILaunchStoryboardName
42 | LaunchScreen
43 | UIMainStoryboardFile
44 | Main
45 | UISupportedInterfaceOrientations
46 |
47 | UIInterfaceOrientationPortrait
48 | UIInterfaceOrientationLandscapeLeft
49 | UIInterfaceOrientationLandscapeRight
50 |
51 | UISupportedInterfaceOrientations~ipad
52 |
53 | UIInterfaceOrientationPortrait
54 | UIInterfaceOrientationPortraitUpsideDown
55 | UIInterfaceOrientationLandscapeLeft
56 | UIInterfaceOrientationLandscapeRight
57 |
58 | UIViewControllerBasedStatusBarAppearance
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
3 | #include "../rust.h"
4 |
--------------------------------------------------------------------------------
/lib/assets/backpoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/lib/assets/backpoint.png
--------------------------------------------------------------------------------
/lib/assets/error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/lib/assets/error.png
--------------------------------------------------------------------------------
/lib/assets/startup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/lib/assets/startup.png
--------------------------------------------------------------------------------
/lib/assets/startup.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/lib/assets/startup.webp
--------------------------------------------------------------------------------
/lib/basic/desktop.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:jenny/basic/methods.dart';
4 | import 'package:window_manager/window_manager.dart';
5 |
6 | onDesktopStart() {
7 | if (Platform.isWindows || Platform.isMacOS || Platform.isLinux) {
8 | windowManager.ensureInitialized();
9 | windowManager.addListener(winListener);
10 | }
11 | }
12 |
13 | onDesktopStop() {
14 | if (Platform.isWindows || Platform.isMacOS || Platform.isLinux) {
15 | windowManager.removeListener(winListener);
16 | }
17 | }
18 |
19 | const winListener = WinListener();
20 |
21 | class WinListener with WindowListener {
22 | const WinListener();
23 |
24 | @override
25 | void onWindowResize() async {
26 | saveSize();
27 | }
28 |
29 | saveSize() async {
30 | final size = await windowManager.getSize();
31 | final windowWidth = size.width.toInt();
32 | final windowHeight = size.height.toInt();
33 | await methods.saveProperty("window_width", "$windowWidth");
34 | await methods.saveProperty("window_height", "$windowHeight");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/lib/basic/navigator.dart:
--------------------------------------------------------------------------------
1 |
2 | import 'package:flutter/material.dart';
3 |
4 | final RouteObserver> routeObserver =
5 | RouteObserver>();
6 |
--------------------------------------------------------------------------------
/lib/basic/web_dav_sync.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jenny/basic/methods.dart';
3 | import 'package:jenny/configs/web_dav_url.dart';
4 |
5 | import '../configs/is_pro.dart';
6 | import '../configs/web_dav_password.dart';
7 | import '../configs/web_dav_sync_switch.dart';
8 | import '../configs/web_dav_username.dart';
9 | import 'commons.dart';
10 |
11 | Future webDavSync(BuildContext context) async {
12 | try {
13 | await methods.webDavSync({
14 | "url": currentWebDavUrl,
15 | "username": currentWebUserName,
16 | "password": currentWebDavPassword,
17 | "direction": "Merge",
18 | });
19 | defaultToast(context, "WebDav 同步成功");
20 | } catch (e, s) {
21 | print("$e\n$s");
22 | defaultToast(context, "WebDav 同步失败 : $e");
23 | }
24 | }
25 |
26 | Future webDavSyncAuto(BuildContext context) async {
27 | if (currentWebDavSyncSwitch() && isPro) {
28 | await webDavSync(context);
29 | }
30 | }
31 |
32 | var syncing = false;
33 |
34 | Widget webDavSyncClick(BuildContext context) {
35 | return ListTile(
36 | title: const Text("立即同步"),
37 | onTap: () async {
38 | if (syncing) return;
39 | syncing = true;
40 | try {
41 | await webDavSync(context);
42 | } finally {
43 | syncing = false;
44 | }
45 | },
46 | );
47 | }
48 |
--------------------------------------------------------------------------------
/lib/configs/android_display_mode.dart:
--------------------------------------------------------------------------------
1 | /// 显示模式, 仅安卓有效
2 |
3 | import 'dart:io';
4 |
5 | import 'package:flutter/material.dart';
6 | import 'package:jenny/basic/methods.dart';
7 | import 'package:jenny/configs/android_version.dart';
8 |
9 | import '../basic/commons.dart';
10 |
11 | const _propertyName = "androidDisplayMode";
12 | List _modes = [];
13 | String _androidDisplayMode = "";
14 |
15 | Future initAndroidDisplayMode() async {
16 | if (Platform.isAndroid) {
17 | _androidDisplayMode = await methods.loadProperty(_propertyName);
18 | _modes = await methods.loadAndroidModes();
19 | await _changeMode();
20 | }
21 | }
22 |
23 | Future _changeMode() async {
24 | await methods.setAndroidMode(_androidDisplayMode);
25 | }
26 |
27 | Future _chooseAndroidDisplayMode(BuildContext context) async {
28 | if (Platform.isAndroid) {
29 | List list = [""];
30 | list.addAll(_modes);
31 | String? result = await chooseListDialog(
32 | context,
33 | title: "安卓屏幕刷新率",
34 | values: list,
35 | );
36 | if (result != null) {
37 | await methods.saveProperty(_propertyName, result);
38 | _androidDisplayMode = result;
39 | await _changeMode();
40 | }
41 | }
42 | }
43 |
44 | Widget androidDisplayModeSetting() {
45 | if (Platform.isAndroid && androidVersion >= 23) {
46 | return StatefulBuilder(
47 | builder: (BuildContext context, void Function(void Function()) setState) {
48 | return ListTile(
49 | title: const Text("屏幕刷新率(安卓)"),
50 | subtitle: Text(_androidDisplayMode),
51 | onTap: () async {
52 | await _chooseAndroidDisplayMode(context);
53 | setState(() {});
54 | },
55 | );
56 | },
57 | );
58 | }
59 | return Container();
60 | }
61 |
--------------------------------------------------------------------------------
/lib/configs/android_version.dart:
--------------------------------------------------------------------------------
1 | import 'package:jenny/basic/methods.dart';
2 |
3 | int _androidVersion = 0;
4 |
5 | int get androidVersion => _androidVersion;
6 |
7 | Future initAndroidVersion() async {
8 | _androidVersion = await methods.androidGetVersion();
9 | }
10 |
--------------------------------------------------------------------------------
/lib/configs/auto_clean.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jenny/basic/commons.dart';
3 | import 'package:jenny/basic/methods.dart';
4 |
5 | const _propertyName = "auto_clean";
6 | late String autoClean;
7 |
8 | Map _nameMap = {
9 | (3600 * 24 * 7).toString(): "一周",
10 | (3600 * 24 * 30).toString(): "一月",
11 | (3600 * 24 * 30 * 12).toString(): "一年",
12 | };
13 |
14 | Future initAutoClean() async {
15 | autoClean = await methods.loadProperty(_propertyName);
16 | }
17 |
18 | String autoCleanName() {
19 | return _nameMap[autoClean] ?? "-";
20 | }
21 |
22 | Future chooseAutoClean(BuildContext context) async {
23 | String? choose = await chooseMapDialog(context,
24 | title: "选择自动清理时间",
25 | values: _nameMap.map((key, value) => MapEntry(value, key)));
26 | if (choose != null) {
27 | await methods.saveProperty(_propertyName, choose);
28 | autoClean = choose;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/lib/configs/configs.dart:
--------------------------------------------------------------------------------
1 | import 'package:jenny/configs/android_display_mode.dart';
2 | import 'package:jenny/configs/android_version.dart';
3 | import 'package:jenny/configs/display_jmcode.dart';
4 | import 'package:jenny/configs/download_thread_count.dart';
5 | import 'package:jenny/configs/no_animation.dart';
6 | import 'package:jenny/configs/pager_column_number.dart';
7 | import 'package:jenny/configs/pager_cover_rate.dart';
8 | import 'package:jenny/configs/passed.dart';
9 | import 'package:jenny/configs/proxy.dart';
10 | import 'package:jenny/configs/search_title_words.dart';
11 | import 'package:jenny/configs/theme.dart';
12 | import 'package:jenny/configs/using_right_click_pop.dart';
13 | import 'package:jenny/configs/volume_key_control.dart';
14 | import 'package:jenny/configs/web_dav_password.dart';
15 | import 'package:jenny/configs/web_dav_sync_switch.dart';
16 | import 'package:jenny/configs/web_dav_url.dart';
17 | import 'package:jenny/configs/web_dav_username.dart';
18 |
19 | import 'auto_clean.dart';
20 | import 'download_and_export_to.dart';
21 | import 'export_path.dart';
22 | import 'export_rename.dart';
23 | import 'is_pro.dart';
24 | import 'network_api_host.dart';
25 | import 'network_cdn_host.dart';
26 | import 'reader_controller_type.dart';
27 | import 'reader_direction.dart';
28 | import 'reader_slider_position.dart';
29 | import 'reader_type.dart';
30 | import 'versions.dart';
31 | import 'login.dart';
32 | import 'pager_controller_mode.dart';
33 | import 'pager_view_mode.dart';
34 |
35 | Future initConfigs() async {
36 | await initPassed();
37 | await initAndroidVersion();
38 | await initAndroidDisplayMode();
39 | await initVersion();
40 | autoCheckNewVersion();
41 | await initApiHost();
42 | await initCdnHost();
43 | await initPagerControllerMode();
44 | await initPagerViewMode();
45 | await initReaderType();
46 | await initReaderDirection();
47 | await initReaderControllerType();
48 | await initReaderSliderPosition();
49 | await initPagerColumnCount();
50 | await initPagerCoverRate();
51 | await initAutoClean();
52 | await initTheme();
53 | await reloadIsPro();
54 | await initExportPath();
55 | await initDownloadThreadCount();
56 | await initProxy();
57 | await initUsingRightClickPop();
58 | await initWebDavSyncSwitch();
59 | await initWebDavUrl();
60 | await initWebDavUserName();
61 | await initWebDavPassword();
62 | await initVolumeKeyControl();
63 | await initNoAnimation();
64 | await initDownloadAndExportTo();
65 | await initExportRename();
66 | await initLogin();
67 | await initDisplayJmcode();
68 | initSearchTitleWords();
69 | }
70 |
--------------------------------------------------------------------------------
/lib/configs/display_jmcode.dart:
--------------------------------------------------------------------------------
1 | /// 自动全屏
2 |
3 | import 'dart:io';
4 |
5 | import 'package:flutter/material.dart';
6 |
7 | import '../basic/commons.dart';
8 | import '../basic/methods.dart';
9 |
10 | const _propertyName = "displayJmcode";
11 | late bool _displayJmcode;
12 |
13 | Future initDisplayJmcode() async {
14 | _displayJmcode =
15 | (await methods.loadProperty(_propertyName)) == "true";
16 | }
17 |
18 | bool currentDisplayJmcode() {
19 | return _displayJmcode;
20 | }
21 |
22 | Future _chooseDisplayJmcode(BuildContext context) async {
23 | String? result = await chooseListDialog(context,
24 | title: "显示漫画代码", values: ["是", "否"]);
25 | if (result != null) {
26 | var target = result == "是";
27 | await methods.saveProperty(_propertyName, "$target");
28 | _displayJmcode = target;
29 | }
30 | }
31 |
32 | Widget displayJmcodeSetting() {
33 | return StatefulBuilder(
34 | builder: (BuildContext context, void Function(void Function()) setState) {
35 | return ListTile(
36 | title: const Text("显示漫画代码"),
37 | subtitle: Text(_displayJmcode ? "是" : "否"),
38 | onTap: () async {
39 | await _chooseDisplayJmcode(context);
40 | setState(() {});
41 | },
42 | );
43 | },
44 | );
45 | }
46 |
--------------------------------------------------------------------------------
/lib/configs/download_and_export_to.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:permission_handler/permission_handler.dart';
5 |
6 | import '../basic/commons.dart';
7 | import '../basic/methods.dart';
8 | import 'android_version.dart';
9 | import 'is_pro.dart';
10 |
11 | late String _currentDownloadAndExportTo;
12 | const _propertyName = "DownloadAndExportTo";
13 |
14 | Future initDownloadAndExportTo() async {
15 | _currentDownloadAndExportTo = await methods.getDownloadAndExportTo();
16 | return null;
17 | }
18 |
19 | String currentDownloadAndExportToName() {
20 | return _currentDownloadAndExportTo == ""
21 | ? "未设置"
22 | : _currentDownloadAndExportTo;
23 | }
24 |
25 | String get currentDownloadAndExportTo => _currentDownloadAndExportTo;
26 |
27 | Widget downloadAndExportToSetting() {
28 | if (!isPro) {
29 | return SwitchListTile(
30 | title: const Text("下载时同时导出", style: TextStyle(color: Colors.grey)),
31 | subtitle: const Text("发电才能使用", style: TextStyle(color: Colors.grey)),
32 | value: false,
33 | onChanged: (_) {},
34 | );
35 | }
36 | if (Platform.isIOS) {
37 | return StatefulBuilder(
38 | builder: (BuildContext context, void Function(void Function()) setState) {
39 | return SwitchListTile(
40 | title: const Text("下载时同时导出"),
41 | subtitle: Text(_currentDownloadAndExportTo),
42 | value: _currentDownloadAndExportTo.isNotEmpty,
43 | onChanged: (e) async {
44 |
45 | var root =
46 | e ? ((await methods.iosGetDocumentDir()) + "/exports") : "";
47 | await methods.setDownloadAndExportTo(root);
48 | _currentDownloadAndExportTo = root;
49 | setState(() {});
50 | },
51 | );
52 | },
53 | );
54 | }
55 | return StatefulBuilder(
56 | builder: (BuildContext context, void Function(void Function()) setState) {
57 | return ListTile(
58 | title: const Text("下载的同时导出到某个目录(填完整路径)"),
59 | subtitle: Text(currentDownloadAndExportToName()),
60 | onTap: () async {
61 | var result = await chooseListDialog(context,
62 | values: ["选择新位置", "清除设置"], title: "下载的时候同时导出");
63 | if (result != null) {
64 | if ("选择新位置" == result) {
65 | if(!await androidMangeStorageRequest()) {
66 | throw Exception("申请权限被拒绝");
67 | }
68 | String? root = await chooseFolder(context);
69 | if (root != null) {
70 | await methods.setDownloadAndExportTo(root);
71 | _currentDownloadAndExportTo = root;
72 | setState(() {});
73 | }
74 | } else if ("清除设置" == result) {
75 | const root = "";
76 | await methods.setDownloadAndExportTo(root);
77 | _currentDownloadAndExportTo = root;
78 | setState(() {});
79 | }
80 | }
81 | },
82 | );
83 | },
84 | );
85 | }
86 |
--------------------------------------------------------------------------------
/lib/configs/download_thread_count.dart:
--------------------------------------------------------------------------------
1 | /// 多线程下载并发数
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:jenny/basic/methods.dart';
5 |
6 | import '../basic/commons.dart';
7 | import 'is_pro.dart';
8 |
9 | late int _downloadThreadCount;
10 | int get downloadThreadCount => _downloadThreadCount;
11 | const _values = [1, 2, 3, 4, 5];
12 |
13 | Future initDownloadThreadCount() async {
14 | _downloadThreadCount = await methods.load_download_thread();
15 | }
16 |
17 | Widget downloadThreadCountSetting() {
18 | return StatefulBuilder(
19 | builder: (BuildContext context, void Function(void Function()) setState) {
20 | return ListTile(
21 | title: Text(
22 | "下载线程数" + (!isPro ? "(发电)" : ""),
23 | style: TextStyle(
24 | color: !isPro ? Colors.grey : null,
25 | ),
26 | ),
27 | subtitle: Text("$_downloadThreadCount"),
28 | onTap: () async {
29 | await chooseDownloadThread(context);
30 | setState(() {});
31 | },
32 | );
33 | },
34 | );
35 | }
36 |
37 | Future chooseDownloadThread(BuildContext context) async {
38 | if (!isPro) {
39 | defaultToast(context, "先发电才能使用多线程嗷");
40 | return;
41 | }
42 | int? value = await chooseListDialog(context,title: "选择下载线程数", values:_values,);
43 | if (value != null) {
44 | await methods.set_download_thread(value);
45 | _downloadThreadCount = value;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/lib/configs/export_rename.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import '../basic/commons.dart';
4 | import '../basic/methods.dart';
5 | import 'is_pro.dart';
6 |
7 | const _propertyName = "exportRename";
8 | late bool _exportRename;
9 |
10 | Future initExportRename() async {
11 | _exportRename = (await methods.loadProperty(_propertyName)) == "true";
12 | }
13 |
14 | bool currentExportRename() {
15 | return _exportRename;
16 | }
17 |
18 | Future _chooseExportRename(BuildContext context) async {
19 | String? result = await chooseListDialog(context,
20 | title: "导出的时候重新命名", values: ["是", "否"]);
21 | if (result != null) {
22 | var target = result == "是";
23 | await methods.saveProperty(_propertyName, "$target");
24 | _exportRename = target;
25 | }
26 | }
27 |
28 | Widget exportRenameSetting() {
29 | return StatefulBuilder(
30 | builder: (BuildContext context, void Function(void Function()) setState) {
31 | return ListTile(
32 | title: Text(
33 | "导出的时候重新命名",
34 | style: TextStyle(
35 | color: !isPro ? Colors.grey : null,
36 | ),
37 | ),
38 | subtitle: Text(
39 | _exportRename ? "是" : "否",
40 | style: TextStyle(
41 | color: !isPro ? Colors.grey : null,
42 | ),
43 | ),
44 | onTap: () async {
45 | if (!isPro) {
46 | return;
47 | }
48 | await _chooseExportRename(context);
49 | setState(() {});
50 | },
51 | );
52 | },
53 | );
54 | }
55 |
--------------------------------------------------------------------------------
/lib/configs/import_notice.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:flutter/material.dart';
4 |
5 | Widget importNotice(BuildContext context) {
6 | if (Platform.isAndroid) {
7 | return Container(
8 | margin: const EdgeInsets.all(15),
9 | padding: const EdgeInsets.all(15),
10 | color: (Theme
11 | .of(context)
12 | .textTheme
13 | .bodyText1
14 | ?.color ?? Colors.black)
15 | .withOpacity(.01),
16 | child: const Text(
17 | "您正在使用安卓设备:\n如果不能导入导出并且提示权限不足, 可以尝试在Download或Document下建立子目录进行导入",
18 | ),
19 | );
20 | }
21 | return Container();
22 | }
23 |
--------------------------------------------------------------------------------
/lib/configs/is_pro.dart:
--------------------------------------------------------------------------------
1 | import 'package:event/event.dart';
2 | import '../basic/methods.dart';
3 |
4 | var isPro = false;
5 | var isProEx = 0;
6 |
7 | final proEvent = Event();
8 |
9 | Future reloadIsPro() async {
10 | final p = await methods.isPro();
11 | isPro = p.isPro;
12 | isProEx = p.expire;
13 | proEvent.broadcast();
14 | }
15 |
--------------------------------------------------------------------------------
/lib/configs/network_cdn_host.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jenny/basic/commons.dart';
3 | import 'package:jenny/basic/methods.dart';
4 |
5 | late String _cdnHost;
6 |
7 | String _cdnHostName(String value) {
8 | return value == "0" ? "随机" : "分流$value";
9 | }
10 |
11 | String get currentCdnHostName => _cdnHostName(_cdnHost);
12 |
13 | Future initCdnHost() async {
14 | _cdnHost = await methods.loadCdnHost();
15 | }
16 |
17 | Future chooseCdnHost(BuildContext context) async {
18 | final choose = await chooseMapDialog(
19 | context,
20 | title: "图片分流",
21 | values: {
22 | "随机": "0",
23 | "分流1": "1",
24 | "分流2": "2",
25 | },
26 | );
27 | if (choose != null) {
28 | await methods.saveCdnHost(choose);
29 | _cdnHost = choose;
30 | }
31 | }
32 |
33 | Widget cdnHostSetting() {
34 | return StatefulBuilder(
35 | builder: (BuildContext context, void Function(void Function()) setState) {
36 | return ListTile(
37 | onTap: () async {
38 | await chooseCdnHost(context);
39 | setState(() {});
40 | },
41 | title: const Text("图片分流"),
42 | subtitle: Text(_cdnHostName(_cdnHost)),
43 | );
44 | },
45 | );
46 | }
47 |
--------------------------------------------------------------------------------
/lib/configs/no_animation.dart:
--------------------------------------------------------------------------------
1 | /// 自动全屏
2 |
3 | import 'dart:io';
4 |
5 | import 'package:flutter/material.dart';
6 |
7 | import '../basic/commons.dart';
8 | import '../basic/methods.dart';
9 |
10 | const _propertyName = "noAnimation";
11 | late bool _noAnimation;
12 |
13 | Future initNoAnimation() async {
14 | _noAnimation =
15 | (await methods.loadProperty(_propertyName)) == "true";
16 | }
17 |
18 | bool currentNoAnimation() {
19 | return _noAnimation;
20 | }
21 |
22 | Future _chooseNoAnimation(BuildContext context) async {
23 | String? result = await chooseListDialog(context,
24 | title: "取消键盘或音量翻页动画", values: ["是", "否"]);
25 | if (result != null) {
26 | var target = result == "是";
27 | await methods.saveProperty(_propertyName, "$target");
28 | _noAnimation = target;
29 | }
30 | }
31 |
32 | Widget noAnimationSetting() {
33 | return StatefulBuilder(
34 | builder: (BuildContext context, void Function(void Function()) setState) {
35 | return ListTile(
36 | title: const Text("取消键盘或音量翻页动画"),
37 | subtitle: Text(_noAnimation ? "是" : "否"),
38 | onTap: () async {
39 | await _chooseNoAnimation(context);
40 | setState(() {});
41 | },
42 | );
43 | },
44 | );
45 | }
46 |
--------------------------------------------------------------------------------
/lib/configs/pager_column_number.dart:
--------------------------------------------------------------------------------
1 | import 'package:event/event.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:jenny/basic/commons.dart';
4 | import 'package:jenny/basic/methods.dart';
5 |
6 | const _propertyName = "pager_column_number";
7 | late int _pagerColumnNumber;
8 |
9 | int get pagerColumnNumber => _pagerColumnNumber;
10 | final pageColumnEvent = Event();
11 |
12 | Future initPagerColumnCount() async {
13 | String numStr = await methods.loadProperty(_propertyName);
14 | if (numStr == "") {
15 | numStr = "4";
16 | }
17 | _pagerColumnNumber = int.parse(numStr);
18 | }
19 |
20 | Future choosePagerColumnCount(BuildContext context) async {
21 | final choose = await chooseListDialog(
22 | context,
23 | title: "分页每行漫画数",
24 | values: List.generate(10, (i) => i + 1),
25 | );
26 | if (choose != null) {
27 | await methods.saveProperty(_propertyName, choose.toString());
28 | _pagerColumnNumber = choose;
29 | pageColumnEvent.broadcast();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/lib/configs/pager_controller_mode.dart:
--------------------------------------------------------------------------------
1 | import 'package:event/event.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:jenny/basic/commons.dart';
4 | import 'package:jenny/basic/methods.dart';
5 |
6 | const _propertyKey = "pager_controller_mode";
7 | late PagerControllerMode _value;
8 | final currentPagerControllerModeEvent = Event();
9 |
10 | PagerControllerMode get currentPagerControllerMode => _value;
11 |
12 | enum PagerControllerMode {
13 | stream,
14 | pager,
15 | }
16 |
17 | Map _nameMap = {
18 | PagerControllerMode.stream: "流式",
19 | PagerControllerMode.pager: "分页器",
20 | };
21 |
22 | String get currentPagerControllerModeName => _nameMap[_value]!;
23 |
24 | Future choosePagerControllerMode(BuildContext context) async {
25 | final target = await chooseMapDialog(context,
26 | title: "请选择分页模式",
27 | values: _nameMap.map((key, value) => MapEntry(value, key)));
28 | if (target != null && target != _value) {
29 | await methods.saveProperty(_propertyKey, "$target");
30 | _value = target;
31 | currentPagerControllerModeEvent.broadcast();
32 | }
33 | }
34 |
35 | PagerControllerMode _parse(String string) {
36 | for (var value in PagerControllerMode.values) {
37 | if ("$value" == string) {
38 | return value;
39 | }
40 | }
41 | return PagerControllerMode.stream;
42 | }
43 |
44 | Future initPagerControllerMode() async {
45 | _value = _parse(await methods.loadProperty(_propertyKey));
46 | }
47 |
--------------------------------------------------------------------------------
/lib/configs/pager_cover_rate.dart:
--------------------------------------------------------------------------------
1 | import 'package:event/event.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:jenny/basic/commons.dart';
4 | import 'package:jenny/basic/methods.dart';
5 |
6 | enum PagerCoverRate {
7 | rate3x4,
8 | rateSquare,
9 | }
10 |
11 | const _propertyName = "pager_cover_rate";
12 | late PagerCoverRate _pagerCoverRate;
13 |
14 | final pagerCoverRateEvent = Event();
15 | PagerCoverRate get currentPagerCoverRate => _pagerCoverRate;
16 |
17 | Future initPagerCoverRate() async {
18 | _pagerCoverRate = _fromString(await methods.loadProperty(_propertyName));
19 | }
20 |
21 | PagerCoverRate _fromString(String valueForm) {
22 | for (var value in PagerCoverRate.values) {
23 | if (value.toString() == valueForm) {
24 | return value;
25 | }
26 | }
27 | return PagerCoverRate.values.first;
28 | }
29 |
30 | String pagerCoverRateName(PagerCoverRate type) {
31 | switch (type) {
32 | case PagerCoverRate.rate3x4:
33 | return "3X4";
34 | case PagerCoverRate.rateSquare:
35 | return "1X1";
36 | }
37 | }
38 |
39 | Future choosePagerCoverRate(BuildContext context) async {
40 | final Map map = {};
41 | for (var element in PagerCoverRate.values) {
42 | map[pagerCoverRateName(element)] = element;
43 | }
44 | final newPagerCoverRate = await chooseMapDialog(
45 | context,
46 | title: "请选择封面比例",
47 | values: map,
48 | );
49 | if (newPagerCoverRate != null) {
50 | await methods.saveProperty(_propertyName, "$newPagerCoverRate");
51 | _pagerCoverRate = newPagerCoverRate;
52 | pagerCoverRateEvent.broadcast();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/lib/configs/pager_view_mode.dart:
--------------------------------------------------------------------------------
1 | import 'package:event/event.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:jenny/basic/commons.dart';
4 | import 'package:jenny/basic/methods.dart';
5 |
6 | const _propertyKey = "pager_view_mode";
7 | late PagerViewMode _value;
8 | final Event currentPagerViewModeEvent = Event();
9 |
10 | PagerViewMode get currentPagerViewMode => _value;
11 |
12 | enum PagerViewMode {
13 | cover,
14 | info,
15 | titleInCover,
16 | titleAndCover,
17 | }
18 |
19 | Map _nameMap = {
20 | PagerViewMode.cover: "封面",
21 | PagerViewMode.info: "详情",
22 | PagerViewMode.titleInCover: "图文1",
23 | PagerViewMode.titleAndCover: "图文2",
24 | };
25 |
26 | String get currentPagerViewModeName => _nameMap[_value]!;
27 |
28 | Future choosePagerViewMode(BuildContext context) async {
29 | final target = await chooseMapDialog(context,
30 | title: "请选择展现形式",
31 | values: _nameMap.map((key, value) => MapEntry(value, key)));
32 | if (target != null && target != _value) {
33 | await methods.saveProperty(_propertyKey, "$target");
34 | _value = target;
35 | currentPagerViewModeEvent.broadcast();
36 | }
37 | }
38 |
39 | PagerViewMode _parse(String string) {
40 | for (var value in PagerViewMode.values) {
41 | if ("$value" == string) {
42 | return value;
43 | }
44 | }
45 | return PagerViewMode.cover;
46 | }
47 |
48 | Future initPagerViewMode() async {
49 | _value = _parse(await methods.loadProperty(_propertyKey));
50 | }
51 |
--------------------------------------------------------------------------------
/lib/configs/passed.dart:
--------------------------------------------------------------------------------
1 | /// 自动全屏
2 |
3 | import 'dart:io';
4 |
5 | import 'package:flutter/material.dart';
6 |
7 | import '../basic/commons.dart';
8 | import '../basic/methods.dart';
9 |
10 | const _propertyName = "passed";
11 | late bool _passed;
12 |
13 | Future initPassed() async {
14 | _passed = (await methods.loadProperty(_propertyName)) == "true";
15 | }
16 |
17 | bool currentPassed() {
18 | return _passed;
19 | }
20 |
21 | Future firstPassed() async {
22 | await methods.saveProperty(_propertyName, "true");
23 | }
24 |
--------------------------------------------------------------------------------
/lib/configs/proxy.dart:
--------------------------------------------------------------------------------
1 | /// 代理设置
2 |
3 | import 'package:flutter/material.dart';
4 |
5 | import '../basic/commons.dart';
6 | import '../basic/methods.dart';
7 |
8 | late String _currentProxy;
9 |
10 | Future initProxy() async {
11 | _currentProxy = await methods.getProxy();
12 | return null;
13 | }
14 |
15 | String currentProxyName() {
16 | return _currentProxy == "" ? "未设置" : _currentProxy;
17 | }
18 |
19 | Future inputProxy(BuildContext context) async {
20 | String? input = await displayTextInputDialog(
21 | context,
22 | src: _currentProxy,
23 | title: '代理服务器',
24 | hint: '请输入代理服务器',
25 | desc: " ( 例如 socks5://127.0.0.1:1080/ ) ",
26 | );
27 | if (input != null) {
28 | await methods.setProxy(input);
29 | _currentProxy = input;
30 | }
31 | }
32 |
33 | Widget proxySetting() {
34 | return StatefulBuilder(
35 | builder: (BuildContext context, void Function(void Function()) setState) {
36 | return ListTile(
37 | title: const Text("代理服务器"),
38 | subtitle: Text(currentProxyName()),
39 | onTap: () async {
40 | await inputProxy(context);
41 | setState(() {});
42 | },
43 | );
44 | },
45 | );
46 | }
47 |
--------------------------------------------------------------------------------
/lib/configs/reader_controller_type.dart:
--------------------------------------------------------------------------------
1 | /// 全屏操作
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:jenny/basic/commons.dart';
5 | import 'package:jenny/basic/methods.dart';
6 |
7 | enum ReaderControllerType {
8 | touchOnce,
9 | controller,
10 | touchDouble,
11 | touchDoubleOnceNext,
12 | threeArea,
13 | }
14 |
15 | Map _readerControllerTypeMap = {
16 | "点击屏幕一次全屏": ReaderControllerType.touchOnce,
17 | "使用控制器全屏": ReaderControllerType.controller,
18 | "双击屏幕全屏": ReaderControllerType.touchDouble,
19 | "双击屏幕全屏 + 单击屏幕下一页": ReaderControllerType.touchDoubleOnceNext,
20 | "将屏幕划分成三个区域 (上一页, 下一页, 全屏)": ReaderControllerType.threeArea,
21 | };
22 |
23 | const _defaultController = ReaderControllerType.touchOnce;
24 | const _propertyName = "reader_controller_type";
25 | late ReaderControllerType _readerControllerType;
26 |
27 | Future initReaderControllerType() async {
28 | _readerControllerType =
29 | _readerControllerTypeFromString(await methods.loadProperty(
30 | _propertyName,
31 | ));
32 | }
33 |
34 | ReaderControllerType get currentReaderControllerType => _readerControllerType;
35 |
36 | ReaderControllerType _readerControllerTypeFromString(String string) {
37 | for (var value in ReaderControllerType.values) {
38 | if (string == value.toString()) {
39 | return value;
40 | }
41 | }
42 | return _defaultController;
43 | }
44 |
45 | String currentReaderControllerTypeName() {
46 | for (var e in _readerControllerTypeMap.entries) {
47 | if (e.value == _readerControllerType) {
48 | return e.key;
49 | }
50 | }
51 | return '';
52 | }
53 |
54 | Future chooseReaderControllerType(BuildContext context) async {
55 | ReaderControllerType? result = await chooseMapDialog(
56 | context,
57 | title: "选择操控方式",
58 | values: _readerControllerTypeMap,
59 | );
60 | if (result != null) {
61 | await methods.saveProperty(_propertyName, result.toString());
62 | _readerControllerType = result;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/lib/configs/reader_direction.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jenny/basic/commons.dart';
3 | import 'package:jenny/basic/methods.dart';
4 |
5 | enum ReaderDirection {
6 | topToBottom,
7 | leftToRight,
8 | rightToLeft,
9 | }
10 |
11 | const _propertyName = "readerDirection";
12 | late ReaderDirection _readerDirection;
13 |
14 | Future initReaderDirection() async {
15 | _readerDirection = _fromString(await methods.loadProperty(_propertyName));
16 | }
17 |
18 | ReaderDirection _fromString(String valueForm) {
19 | for (var value in ReaderDirection.values) {
20 | if (value.toString() == valueForm) {
21 | return value;
22 | }
23 | }
24 | return ReaderDirection.values.first;
25 | }
26 |
27 | ReaderDirection get currentReaderDirection => _readerDirection;
28 |
29 | String readerDirectionName(ReaderDirection direction, BuildContext context) {
30 | switch (direction) {
31 | case ReaderDirection.topToBottom:
32 | return "从上到下";
33 | case ReaderDirection.leftToRight:
34 | return "从左到右";
35 | case ReaderDirection.rightToLeft:
36 | return "从右到左";
37 | }
38 | }
39 |
40 | Future chooseReaderDirection(BuildContext context) async {
41 | final Map map = {};
42 | for (var element in ReaderDirection.values) {
43 | map[readerDirectionName(element, context)] = element;
44 | }
45 | final newReaderDirection = await chooseMapDialog(
46 | context,
47 | title: "请选择阅读器方向",
48 | values: map,
49 | );
50 | if (newReaderDirection != null) {
51 | await methods.saveProperty(_propertyName, "$newReaderDirection");
52 | _readerDirection = newReaderDirection;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/lib/configs/reader_slider_position.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jenny/basic/commons.dart';
3 | import 'package:jenny/basic/methods.dart';
4 |
5 | enum ReaderSliderPosition {
6 | bottom,
7 | right,
8 | left,
9 | }
10 |
11 | const _positionNames = {
12 | ReaderSliderPosition.bottom: '下方',
13 | ReaderSliderPosition.right: '右侧',
14 | ReaderSliderPosition.left: '左侧',
15 | };
16 |
17 | const _propertyName = "reader_slider_position";
18 | late ReaderSliderPosition _readerSliderPosition;
19 |
20 | Future initReaderSliderPosition() async {
21 | _readerSliderPosition = _readerSliderPositionFromString(
22 | await methods.loadProperty(_propertyName),
23 | );
24 | }
25 |
26 | ReaderSliderPosition _readerSliderPositionFromString(String str) {
27 | for (var value in ReaderSliderPosition.values) {
28 | if (str == value.toString()) return value;
29 | }
30 | return ReaderSliderPosition.bottom;
31 | }
32 |
33 | ReaderSliderPosition get currentReaderSliderPosition => _readerSliderPosition;
34 |
35 | String get currentReaderSliderPositionName =>
36 | _positionNames[_readerSliderPosition] ?? "";
37 |
38 | Future chooseReaderSliderPosition(BuildContext context) async {
39 | Map map = {};
40 | _positionNames.forEach((key, value) {
41 | map[value] = key;
42 | });
43 | ReaderSliderPosition? result = await chooseMapDialog(
44 | context,
45 | title: "选择滑动条位置",
46 | values: map,
47 | );
48 | if (result != null) {
49 | await methods.saveProperty(_propertyName, result.toString());
50 | _readerSliderPosition = result;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/lib/configs/reader_type.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jenny/basic/commons.dart';
3 | import 'package:jenny/basic/methods.dart';
4 |
5 | enum ReaderType {
6 | webtoon,
7 | gallery,
8 | webToonFreeZoom,
9 | }
10 |
11 | const _propertyName = "readerType";
12 | late ReaderType _readerType;
13 |
14 | Future initReaderType() async {
15 | _readerType = _fromString(await methods.loadProperty(_propertyName));
16 | }
17 |
18 | ReaderType _fromString(String valueForm) {
19 | for (var value in ReaderType.values) {
20 | if (value.toString() == valueForm) {
21 | return value;
22 | }
23 | }
24 | return ReaderType.values.first;
25 | }
26 |
27 | ReaderType get currentReaderType => _readerType;
28 |
29 | String readerTypeName(ReaderType type, BuildContext context) {
30 | switch (type) {
31 | case ReaderType.webtoon:
32 | return "WebToon";
33 | case ReaderType.gallery:
34 | return "相册";
35 | case ReaderType.webToonFreeZoom:
36 | return "自由放大滚动 无法翻页";
37 | }
38 | }
39 |
40 | Future chooseReaderType(BuildContext context) async {
41 | final Map map = {};
42 | for (var element in ReaderType.values) {
43 | map[readerTypeName(element, context)] = element;
44 | }
45 | final newReaderType = await chooseMapDialog(
46 | context,
47 | title: "请选择阅读器类型",
48 | values: map,
49 | );
50 | if (newReaderType != null) {
51 | await methods.saveProperty(_propertyName, "$newReaderType");
52 | _readerType = newReaderType;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/lib/configs/search_title_words.dart:
--------------------------------------------------------------------------------
1 | /// 自动全屏
2 |
3 | import 'dart:io';
4 |
5 | import 'package:flutter/material.dart';
6 |
7 | import '../basic/commons.dart';
8 | import '../basic/methods.dart';
9 |
10 | const _propertyName = "searchTitleWords";
11 | late bool _searchTitleWords;
12 |
13 | Future initSearchTitleWords() async {
14 | _searchTitleWords =
15 | (await methods.loadProperty(_propertyName)) == "true";
16 | }
17 |
18 | bool currentSearchTitleWords() {
19 | return _searchTitleWords;
20 | }
21 |
22 | Future _chooseSearchTitleWords(BuildContext context) async {
23 | String? result = await chooseListDialog(context,
24 | title: "标题中的关键字", values: ["是", "否"]);
25 | if (result != null) {
26 | var target = result == "是";
27 | await methods.saveProperty(_propertyName, "$target");
28 | _searchTitleWords = target;
29 | }
30 | }
31 |
32 | Widget searchTitleWordsSetting() {
33 | return StatefulBuilder(
34 | builder: (BuildContext context, void Function(void Function()) setState) {
35 | return ListTile(
36 | title: const Text("标题中的关键字"),
37 | subtitle: Text(_searchTitleWords ? "是" : "否"),
38 | onTap: () async {
39 | await _chooseSearchTitleWords(context);
40 | setState(() {});
41 | },
42 | );
43 | },
44 | );
45 | }
46 |
--------------------------------------------------------------------------------
/lib/configs/using_right_click_pop.dart:
--------------------------------------------------------------------------------
1 | /// 自动全屏
2 |
3 | import 'dart:io';
4 |
5 | import 'package:flutter/material.dart';
6 |
7 | import '../basic/commons.dart';
8 | import '../basic/methods.dart';
9 |
10 | const _propertyName = "usingRightClickPop";
11 | late bool _usingRightClickPop;
12 |
13 | Future initUsingRightClickPop() async {
14 | _usingRightClickPop =
15 | (await methods.loadProperty(_propertyName)) == "true";
16 | }
17 |
18 | bool currentUsingRightClickPop() {
19 | return _usingRightClickPop;
20 | }
21 |
22 | Future _chooseUsingRightClickPop(BuildContext context) async {
23 | String? result = await chooseListDialog(context,
24 | title: "鼠标右键返回上一页", values: ["是", "否"]);
25 | if (result != null) {
26 | var target = result == "是";
27 | await methods.saveProperty(_propertyName, "$target");
28 | _usingRightClickPop = target;
29 | }
30 | }
31 |
32 | Widget usingRightClickPopSetting() {
33 | if (!(Platform.isWindows || Platform.isMacOS || Platform.isLinux)) {
34 | return Container();
35 | }
36 | return StatefulBuilder(
37 | builder: (BuildContext context, void Function(void Function()) setState) {
38 | return ListTile(
39 | title: const Text("鼠标右键返回上一页"),
40 | subtitle: Text(_usingRightClickPop ? "是" : "否"),
41 | onTap: () async {
42 | await _chooseUsingRightClickPop(context);
43 | setState(() {});
44 | },
45 | );
46 | },
47 | );
48 | }
49 |
--------------------------------------------------------------------------------
/lib/configs/volume_key_control.dart:
--------------------------------------------------------------------------------
1 | /// 自动全屏
2 |
3 | import 'dart:io';
4 |
5 | import 'package:flutter/material.dart';
6 |
7 | import '../basic/commons.dart';
8 | import '../basic/methods.dart';
9 |
10 | const _propertyName = "volumeKeyControl";
11 | late bool _volumeKeyControl;
12 |
13 | Future initVolumeKeyControl() async {
14 | _volumeKeyControl =
15 | (await methods.loadProperty(_propertyName)) == "true";
16 | }
17 |
18 | bool currentVolumeKeyControl() {
19 | return _volumeKeyControl;
20 | }
21 |
22 | Future _chooseVolumeKeyControl(BuildContext context) async {
23 | String? result = await chooseListDialog(context,
24 | title: "鼠标右键返回上一页", values: ["是", "否"]);
25 | if (result != null) {
26 | var target = result == "是";
27 | await methods.saveProperty(_propertyName, "$target");
28 | _volumeKeyControl = target;
29 | }
30 | }
31 |
32 | Widget volumeKeyControlSetting() {
33 | if (!(Platform.isAndroid)) {
34 | return Container();
35 | }
36 | return StatefulBuilder(
37 | builder: (BuildContext context, void Function(void Function()) setState) {
38 | return ListTile(
39 | title: const Text("音量键翻页"),
40 | subtitle: Text(_volumeKeyControl ? "是" : "否"),
41 | onTap: () async {
42 | await _chooseVolumeKeyControl(context);
43 | setState(() {});
44 | },
45 | );
46 | },
47 | );
48 | }
49 |
--------------------------------------------------------------------------------
/lib/configs/web_dav_password.dart:
--------------------------------------------------------------------------------
1 |
2 | import 'package:flutter/material.dart';
3 |
4 | import '../basic/commons.dart';
5 | import '../basic/methods.dart';
6 |
7 | late String _currentWebDavPassword;
8 | const _propertyName = "WebDavPassword";
9 |
10 | String get currentWebDavPassword => _currentWebDavPassword;
11 |
12 | Future initWebDavPassword() async {
13 | _currentWebDavPassword = await methods.loadProperty(_propertyName);
14 | return null;
15 | }
16 |
17 | String currentWebDavPasswordName() {
18 | return _currentWebDavPassword == "" ? "未设置" : _currentWebDavPassword;
19 | }
20 |
21 | Future inputWebDavPassword(BuildContext context) async {
22 | String? input = await displayTextInputDialog(
23 | context,
24 | src: _currentWebDavPassword,
25 | title: 'WebDAV密码',
26 | hint: '请输入WebDAV密码',
27 | );
28 | if (input != null) {
29 | await methods.saveProperty(_propertyName, input);
30 | _currentWebDavPassword = input;
31 | }
32 | }
33 |
34 | Widget webDavPasswordSetting() {
35 | return StatefulBuilder(
36 | builder: (BuildContext context, void Function(void Function()) setState) {
37 | return ListTile(
38 | title: const Text("WebDAV密码"),
39 | subtitle: Text(currentWebDavPasswordName()),
40 | onTap: () async {
41 | await inputWebDavPassword(context);
42 | setState(() {});
43 | },
44 | );
45 | },
46 | );
47 | }
48 |
--------------------------------------------------------------------------------
/lib/configs/web_dav_sync_switch.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import '../basic/commons.dart';
4 | import '../basic/methods.dart';
5 | import 'is_pro.dart';
6 |
7 | const _propertyName = "webDavSyncSwitch";
8 | late bool _webDavSyncSwitch;
9 |
10 | Future initWebDavSyncSwitch() async {
11 | _webDavSyncSwitch = (await methods.loadProperty(_propertyName)) == "true";
12 | }
13 |
14 | bool currentWebDavSyncSwitch() {
15 | return _webDavSyncSwitch;
16 | }
17 |
18 | Future _chooseWebDavSyncSwitch(BuildContext context) async {
19 | String? result = await chooseListDialog(context,
20 | title: "开开启时自动同步历史记录到WebDAV", values: ["是", "否"]);
21 | if (result != null) {
22 | var target = result == "是";
23 | await methods.saveProperty(_propertyName, "$target");
24 | _webDavSyncSwitch = target;
25 | }
26 | }
27 |
28 | Widget webDavSyncSwitchSetting() {
29 | return StatefulBuilder(
30 | builder: (BuildContext context, void Function(void Function()) setState) {
31 | return ListTile(
32 | title: Text(
33 | "开启时自动同步历史记录到WebDAV",
34 | style: TextStyle(
35 | color: !isPro ? Colors.grey : null,
36 | ),
37 | ),
38 | subtitle: Text(
39 | _webDavSyncSwitch ? "是" : "否",
40 | style: TextStyle(
41 | color: !isPro ? Colors.grey : null,
42 | ),
43 | ),
44 | onTap: () async {
45 | if (!isPro) {
46 | return;
47 | }
48 | await _chooseWebDavSyncSwitch(context);
49 | setState(() {});
50 | },
51 | );
52 | },
53 | );
54 | }
55 |
--------------------------------------------------------------------------------
/lib/configs/web_dav_url.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import '../basic/commons.dart';
4 | import '../basic/methods.dart';
5 |
6 | late String _currentWebDavUrl;
7 | const _propertyName = "WebDavUrl";
8 |
9 | Future initWebDavUrl() async {
10 | _currentWebDavUrl = await methods.loadProperty(_propertyName);
11 | if (_currentWebDavUrl == "") {
12 | _currentWebDavUrl = "http://server/.jenny.history";
13 | }
14 | return null;
15 | }
16 |
17 | String currentWebDavUrlName() {
18 | return _currentWebDavUrl == "" ? "未设置" : _currentWebDavUrl;
19 | }
20 |
21 | String get currentWebDavUrl => _currentWebDavUrl;
22 |
23 | Future inputWebDavUrl(BuildContext context) async {
24 | String? input = await displayTextInputDialog(
25 | context,
26 | src: _currentWebDavUrl,
27 | title: 'WebDAV文件URL',
28 | hint: '请输入WebDAV文件URL',
29 | desc: " ( 例如 http://server/folder/.jenny.history ) ",
30 | );
31 | if (input != null) {
32 | await methods.saveProperty(_propertyName, input);
33 | _currentWebDavUrl = input;
34 | }
35 | }
36 |
37 | Widget webDavUrlSetting() {
38 | return StatefulBuilder(
39 | builder: (BuildContext context, void Function(void Function()) setState) {
40 | return ListTile(
41 | title: const Text("WebDAV文件URL"),
42 | subtitle: Text(currentWebDavUrlName()),
43 | onTap: () async {
44 | await inputWebDavUrl(context);
45 | setState(() {});
46 | },
47 | );
48 | },
49 | );
50 | }
51 |
--------------------------------------------------------------------------------
/lib/configs/web_dav_username.dart:
--------------------------------------------------------------------------------
1 |
2 | import 'package:flutter/material.dart';
3 |
4 | import '../basic/commons.dart';
5 | import '../basic/methods.dart';
6 |
7 | late String _currentWebDavUserName;
8 | const _propertyName = "WebDavUserName";
9 |
10 | String get currentWebUserName => _currentWebDavUserName;
11 |
12 | Future initWebDavUserName() async {
13 | _currentWebDavUserName = await methods.loadProperty(_propertyName);
14 | return null;
15 | }
16 |
17 | String currentWebDavUserNameName() {
18 | return _currentWebDavUserName == "" ? "未设置" : _currentWebDavUserName;
19 | }
20 |
21 | Future inputWebDavUserName(BuildContext context) async {
22 | String? input = await displayTextInputDialog(
23 | context,
24 | src: _currentWebDavUserName,
25 | title: 'WebDAV用户名',
26 | hint: '请输入WebDAV用户名',
27 | );
28 | if (input != null) {
29 | await methods.saveProperty(_propertyName, input);
30 | _currentWebDavUserName = input;
31 | }
32 | }
33 |
34 | Widget webDavUserNameSetting() {
35 | return StatefulBuilder(
36 | builder: (BuildContext context, void Function(void Function()) setState) {
37 | return ListTile(
38 | title: const Text("WebDAV用户名"),
39 | subtitle: Text(currentWebDavUserNameName()),
40 | onTap: () async {
41 | await inputWebDavUserName(context);
42 | setState(() {});
43 | },
44 | );
45 | },
46 | );
47 | }
48 |
--------------------------------------------------------------------------------
/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jenny/screens/components/mouse_and_touch_scroll_behavior.dart';
3 | import 'package:jenny/screens/init_screen.dart';
4 | import 'basic/desktop.dart';
5 | import 'basic/navigator.dart';
6 | import 'configs/theme.dart';
7 |
8 | void main() async {
9 | runApp(const Jenny());
10 | }
11 |
12 | class Jenny extends StatefulWidget {
13 | const Jenny({Key? key}) : super(key: key);
14 |
15 | @override
16 | State createState() => _JennyState();
17 | }
18 |
19 | class _JennyState extends State {
20 |
21 | @override
22 | void initState() {
23 | onDesktopStart();
24 | themeEvent.subscribe(_setState);
25 | super.initState();
26 | }
27 |
28 | @override
29 | void dispose() {
30 | onDesktopStop();
31 | themeEvent.unsubscribe(_setState);
32 | super.dispose();
33 | }
34 |
35 | _setState(_) {
36 | setState(() => {});
37 | }
38 | @override
39 | Widget build(BuildContext context) {
40 | return MaterialApp(
41 | scrollBehavior: mouseAndTouchScrollBehavior,
42 | debugShowCheckedModeBanner: false,
43 | theme: lightTheme,
44 | darkTheme: darkTheme,
45 | navigatorObservers: [routeObserver],
46 | home: const InitScreen(),
47 | );
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/lib/screens/comic_search_screen.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jenny/basic/methods.dart';
3 | import 'package:jenny/screens/components/floating_search_bar.dart';
4 |
5 | import 'components/browser_bottom_sheet.dart';
6 | import 'components/comic_floating_search_bar.dart';
7 | import 'components/comic_pager.dart';
8 | import 'components/actions.dart';
9 | import 'components/right_click_pop.dart';
10 |
11 | class ComicSearchScreen extends StatefulWidget {
12 | final String initKeywords;
13 |
14 | const ComicSearchScreen({required this.initKeywords, Key? key})
15 | : super(key: key);
16 |
17 | @override
18 | State createState() => _ComicSearchScreenState();
19 | }
20 |
21 | class _ComicSearchScreenState extends State {
22 | final _controller = FloatingSearchBarController();
23 | late var _keywords = widget.initKeywords;
24 | SortBy _sortBy = sortByDefault;
25 |
26 | @override
27 | Widget build(BuildContext context) {
28 | return rightClickPop(child: buildScreen(context), context: context);
29 | }
30 |
31 | Widget buildScreen(BuildContext context) {
32 | return ComicFloatingSearchBarScreen(
33 | controller: _controller,
34 | onQuery: (value) {
35 | setState(() {
36 | _keywords = value;
37 | });
38 | },
39 | child: Scaffold(
40 | appBar: AppBar(
41 | title: Text(_keywords),
42 | actions: [
43 | IconButton(
44 | onPressed: () async {
45 | searchHistories = await methods.lastSearchHistories(20);
46 | _controller.display(modifyInput: _keywords);
47 | },
48 | icon: const Icon(Icons.search),
49 | ),
50 | const BrowserBottomSheetAction(),
51 | buildOrderSwitch(context, _sortBy, (value) {
52 | setState(() {
53 | _sortBy = value;
54 | });
55 | }),
56 | ],
57 | ),
58 | body: ComicPager(
59 | key: Key("$_keywords:$_sortBy"),
60 | onPage: (int page) async {
61 | final response = await methods.comicSearch(
62 | _keywords,
63 | _sortBy,
64 | page,
65 | );
66 | return InnerComicPage(
67 | total: response.total,
68 | list: response.content,
69 | redirectAid: response.redirectAid,
70 | );
71 | },
72 | ),
73 | ),
74 | );
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/lib/screens/comments_screen.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jenny/basic/methods.dart';
3 | import 'package:jenny/screens/components/comic_list.dart';
4 |
5 | import 'components/comic_comments_list.dart';
6 | import 'components/right_click_pop.dart';
7 |
8 | class CommentsScreen extends StatefulWidget {
9 | const CommentsScreen({Key? key}) : super(key: key);
10 |
11 | @override
12 | State createState() => _CommentsScreenState();
13 | }
14 |
15 | class _CommentsScreenState extends State {
16 |
17 | @override
18 | Widget build(BuildContext context) {
19 | return rightClickPop(child: buildScreen(context), context: context);
20 | }
21 |
22 | Widget buildScreen(BuildContext context) {
23 | return Scaffold(
24 | appBar: AppBar(
25 | title: const Text("讨论区"),
26 | ),
27 | body: ListView(
28 | children: const [
29 | ComicCommentsList(mode: "manhua", aid: null, gotoComic: true),
30 | ],
31 | ),
32 | );
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/lib/screens/components/actions.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jenny/basic/commons.dart';
3 | import 'package:jenny/basic/entities.dart';
4 |
5 | Widget buildOrderSwitch(
6 | BuildContext context,
7 | SortBy value,
8 | ValueChanged valueChanged,
9 | ) {
10 | final iconColor = Theme.of(context).appBarTheme.iconTheme?.color;
11 | return MaterialButton(
12 | onPressed: () async {
13 | final target = await chooseSortBy(context);
14 | if (target != null) {
15 | valueChanged(target);
16 | }
17 | },
18 | child: Column(
19 | children: [
20 | Expanded(child: Container()),
21 | Icon(
22 | Icons.sort,
23 | color: iconColor,
24 | ),
25 | Expanded(child: Container()),
26 | Text(value.toString(), style: TextStyle(color: iconColor)),
27 | Expanded(child: Container()),
28 | ],
29 | ),
30 | );
31 | }
32 |
--------------------------------------------------------------------------------
/lib/screens/components/avatar.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jenny/screens/components/images.dart';
3 |
4 | const double _avatarMargin = 5;
5 | const double _avatarBorderSize = 1.5;
6 |
7 | // 头像
8 | class Avatar extends StatelessWidget {
9 | final String photoName;
10 | final double size;
11 |
12 | const Avatar(this.photoName, {this.size = 50, Key? key}) : super(key: key);
13 |
14 | @override
15 | Widget build(BuildContext context) {
16 | var theme = Theme.of(context);
17 | return Container(
18 | margin: const EdgeInsets.all(_avatarMargin),
19 | decoration: BoxDecoration(
20 | shape: BoxShape.circle,
21 | border: Border.all(
22 | color: theme.colorScheme.secondary,
23 | style: BorderStyle.solid,
24 | width: _avatarBorderSize,
25 | )),
26 | child: ClipRRect(
27 | borderRadius: BorderRadius.all(Radius.circular(size)),
28 | child: photoName == "?v=0?v="
29 | ? Icon(
30 | Icons.query_builder_sharp,
31 | color: Theme.of(context).brightness == Brightness.light
32 | ? Colors.black54
33 | : Colors.white,
34 | size: size,
35 | )
36 | : JMPhotoImage(
37 | photoName: photoName,
38 | width: size,
39 | height: size,
40 | ),
41 | ),
42 | );
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/lib/screens/components/badge.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jenny/configs/versions.dart';
3 |
4 | // 提示信息, 组件右上角的小红点
5 | class Badged extends StatelessWidget {
6 | final String? badge;
7 | final Widget child;
8 |
9 | const Badged({Key? key, required this.child, this.badge}) : super(key: key);
10 |
11 | @override
12 | Widget build(BuildContext context) {
13 | if (badge == null) {
14 | return child;
15 | }
16 | return Stack(
17 | children: [
18 | child,
19 | Positioned(
20 | right: 0,
21 | child: Container(
22 | padding: const EdgeInsets.all(1),
23 | decoration: BoxDecoration(
24 | color: Colors.red,
25 | borderRadius: BorderRadius.circular(6),
26 | ),
27 | constraints: const BoxConstraints(
28 | minWidth: 12,
29 | minHeight: 12,
30 | ),
31 | child: Text(
32 | badge!,
33 | style: const TextStyle(
34 | color: Colors.white,
35 | fontSize: 8,
36 | ),
37 | textAlign: TextAlign.center,
38 | ),
39 | ),
40 | ),
41 | ],
42 | );
43 | }
44 | }
45 |
46 | class VersionBadged extends StatefulWidget {
47 | final Widget child;
48 |
49 | const VersionBadged({required this.child, Key? key}) : super(key: key);
50 |
51 | @override
52 | State createState() => _VersionBadgedState();
53 | }
54 |
55 | class _VersionBadgedState extends State {
56 | @override
57 | void initState() {
58 | versionEvent.subscribe(_onVersion);
59 | super.initState();
60 | }
61 |
62 | @override
63 | void dispose() {
64 | versionEvent.unsubscribe(_onVersion);
65 | super.dispose();
66 | }
67 |
68 | void _onVersion(dynamic a) {
69 | setState(() {});
70 | }
71 |
72 | @override
73 | Widget build(BuildContext context) {
74 | return Badged(
75 | child: widget.child,
76 | badge: latestVersion == null ? null : "1",
77 | );
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/lib/screens/components/content_builder.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'content_error.dart';
4 | import 'content_loading.dart';
5 |
6 | class ContentBuilder extends StatelessWidget {
7 | final Future future;
8 | final Future Function() onRefresh;
9 | final AsyncWidgetBuilder successBuilder;
10 | final String loadingLabel;
11 |
12 | const ContentBuilder({
13 | required Key? key,
14 | required this.future,
15 | required this.onRefresh,
16 | required this.successBuilder,
17 | this.loadingLabel = '加载中',
18 | }) : super(key: key);
19 |
20 | @override
21 | Widget build(BuildContext context) {
22 | return FutureBuilder(
23 | future: future,
24 | builder: (BuildContext context, AsyncSnapshot snapshot) {
25 | if (snapshot.hasError) {
26 | return ContentError(
27 | error: snapshot.error,
28 | stackTrace: snapshot.stackTrace,
29 | onRefresh: onRefresh,
30 | );
31 | }
32 | if (snapshot.connectionState != ConnectionState.done) {
33 | return ContentLoading(label: loadingLabel);
34 | }
35 | return successBuilder(context, snapshot);
36 | },
37 | );
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/lib/screens/components/content_error.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'error_types.dart';
3 |
4 |
5 | class ContentError extends StatelessWidget {
6 | final Object? error;
7 | final StackTrace? stackTrace;
8 | final Future Function() onRefresh;
9 |
10 | const ContentError({
11 | Key? key,
12 | required this.error,
13 | required this.stackTrace,
14 | required this.onRefresh,
15 | }) : super(key: key);
16 |
17 | @override
18 | Widget build(BuildContext context) {
19 | var type = errorType("$error");
20 | late String message;
21 | late IconData iconData;
22 | switch (type) {
23 | case ERROR_TYPE_NETWORK:
24 | iconData = Icons.wifi_off_rounded;
25 | message = "连接不上啦, 请检查网络";
26 | break;
27 | case ERROR_TYPE_PERMISSION:
28 | iconData = Icons.highlight_off;
29 | message = "没有权限或路径不可用";
30 | break;
31 | case ERROR_TYPE_TIME:
32 | iconData = Icons.timer_off;
33 | message = "请检查设备时间";
34 | break;
35 | case ERROR_TYPE_UNDER_REVIEW:
36 | iconData = Icons.highlight_off;
37 | message = "资源未审核或不可用";
38 | break;
39 | default:
40 | iconData = Icons.highlight_off;
41 | message = "啊哦, 被玩坏了";
42 | break;
43 | }
44 | return LayoutBuilder(
45 | builder: (BuildContext context, BoxConstraints constraints) {
46 | print("$error");
47 | print("$stackTrace");
48 | var width = constraints.maxWidth;
49 | var height = constraints.maxHeight;
50 | var min = width < height ? width : height;
51 | var iconSize = min / 2.3;
52 | var textSize = min / 16;
53 | var tipSize = min / 20;
54 | var infoSize = min / 30;
55 | return GestureDetector(
56 | onTap: onRefresh,
57 | child: ListView(
58 | children: [
59 | Container(
60 | height: height,
61 | child: Column(
62 | children: [
63 | Expanded(child: Container()),
64 | Container(
65 | child: Icon(
66 | iconData,
67 | size: iconSize,
68 | color: Colors.grey.shade600,
69 | ),
70 | ),
71 | Container(height: min / 10),
72 | Container(
73 | padding: const EdgeInsets.only(
74 | left: 30,
75 | right: 30,
76 | ),
77 | child: Text(
78 | message,
79 | style: TextStyle(fontSize: textSize),
80 | textAlign: TextAlign.center,
81 | ),
82 | ),
83 | Text('(点击刷新)', style: TextStyle(fontSize: tipSize)),
84 | Container(height: min / 15),
85 | Text('$error', style: TextStyle(fontSize: infoSize)),
86 | Expanded(child: Container()),
87 | ],
88 | ),
89 | ),
90 | ],
91 | ),
92 | );
93 | },
94 | );
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/lib/screens/components/content_loading.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class ContentLoading extends StatelessWidget {
4 | final String label;
5 |
6 | const ContentLoading({Key? key, this.label = "加载中"}) : super(key: key);
7 |
8 | @override
9 | Widget build(BuildContext context) {
10 | return LayoutBuilder(
11 | builder: (BuildContext context, BoxConstraints constraints) {
12 | var width = constraints.maxWidth;
13 | var height = constraints.maxHeight;
14 | var min = width < height ? width : height;
15 | var theme = Theme.of(context);
16 | return Center(
17 | child: Column(
18 | children: [
19 | Expanded(child: Container()),
20 | SizedBox(
21 | width: min / 2,
22 | height: min / 2,
23 | child: CircularProgressIndicator(
24 | color: theme.colorScheme.secondary,
25 | backgroundColor: Colors.grey[100],
26 | ),
27 | ),
28 | Container(height: min / 10),
29 | Text(label, style: TextStyle(fontSize: min / 15)),
30 | Expanded(child: Container()),
31 | ],
32 | ),
33 | );
34 | },
35 | );
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/lib/screens/components/continue_read_button.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jenny/basic/entities.dart';
3 | import 'package:jenny/basic/methods.dart';
4 | import 'package:jenny/screens/components/my_flat_button.dart';
5 |
6 | // 继续阅读按钮
7 | class ContinueReadButton extends StatefulWidget {
8 | final Future viewFuture;
9 | final AlbumResponse album;
10 | final Function(int epOrder, int pictureRank) onChoose;
11 |
12 | const ContinueReadButton({
13 | Key? key,
14 | required this.album,
15 | required this.onChoose,
16 | required this.viewFuture,
17 | }) : super(key: key);
18 |
19 | @override
20 | State createState() => _ContinueReadButtonState();
21 | }
22 |
23 | class _ContinueReadButtonState extends State {
24 | @override
25 | Widget build(BuildContext context) {
26 | return FutureBuilder(
27 | future: widget.viewFuture,
28 | builder: (BuildContext context, AsyncSnapshot snapshot) {
29 | late void Function() onPressed;
30 | late String text;
31 | if (snapshot.connectionState != ConnectionState.done) {
32 | onPressed = () {};
33 | text = '加载中';
34 | } else {
35 | ViewLog? viewLog = snapshot.data;
36 | if (viewLog == null || viewLog.lastViewChapterId == 0) {
37 | if (widget.album.series.isEmpty) {
38 | return Container();
39 | }
40 | onPressed = () {
41 | if (widget.album.series.isEmpty) {
42 | widget.onChoose(widget.album.id, 0);
43 | } else {
44 | widget.album.series.sort(
45 | (a, b) => int.parse(a.sort).compareTo(int.parse(b.sort)),
46 | );
47 | widget.onChoose(widget.album.series[0].id, 0);
48 | }
49 | };
50 | text = '从头开始';
51 | } else {
52 | onPressed = () {
53 | widget.onChoose(
54 | viewLog.lastViewChapterId,
55 | viewLog.lastViewPage,
56 | );
57 | };
58 | text = '继续阅读'; // todo names and pages
59 | if (widget.album.series.isNotEmpty) {
60 | for (var i = 0; i < widget.album.series.length; i++) {
61 | if (widget.album.series[i].id == viewLog.lastViewChapterId) {
62 | text += " (${i + 1}.";
63 | if (widget.album.series[i].name.isNotEmpty) {
64 | text += widget.album.series[i].name + ".";
65 | }
66 | text += "P${viewLog.lastViewPage + 1})";
67 | break;
68 | }
69 | }
70 | } else {
71 | text += " (P${viewLog.lastViewPage + 1})";
72 | }
73 | }
74 | }
75 | return MyFlatButton(title: text, onPressed: onPressed);
76 | },
77 | );
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/lib/screens/components/error_types.dart:
--------------------------------------------------------------------------------
1 | const ERROR_TYPE_NETWORK = "NETWORK_ERROR";
2 | const ERROR_TYPE_PERMISSION = "PERMISSION_ERROR";
3 | const ERROR_TYPE_TIME = "TIME_ERROR";
4 | const ERROR_TYPE_UNDER_REVIEW = "UNDER_VIEW_ERROR";
5 |
6 | // 错误的类型, 方便照展示和谐的提示
7 | String errorType(String error) {
8 | // EXCEPTION
9 | // Get "https://picaapi.picacomic.com/categories": net/http: TLS handshake timeout
10 | // Get "https://picaapi.picacomic.com/comics?c=%E9%95%B7%E7%AF%87&s=ua&page=1": proxyconnect tcp: dial tcp 192.168.123.217:1080: connect: connection refused
11 | // Get "https://picaapi.picacomic.com/comics?c=%E5%85%A8%E5%BD%A9&s=ua&page=1": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
12 | if (error.contains("timeout") ||
13 | error.contains("connection refused") ||
14 | error.contains("deadline") ||
15 | error.contains("connection abort")) {
16 | return ERROR_TYPE_NETWORK;
17 | }
18 | if (error.contains("permission denied")) {
19 | return ERROR_TYPE_PERMISSION;
20 | }
21 | if (error.contains("time is not synchronize")) {
22 | return ERROR_TYPE_TIME;
23 | }
24 | if (error.contains("under review")) {
25 | return ERROR_TYPE_UNDER_REVIEW;
26 | }
27 | return "";
28 | }
29 |
--------------------------------------------------------------------------------
/lib/screens/components/item_builder.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | // 非全屏FutureBuilder封装
4 | class ItemBuilder extends StatelessWidget {
5 | final Future future;
6 | final AsyncWidgetBuilder successBuilder;
7 | final Future Function() onRefresh;
8 | final double? loadingHeight;
9 | final double? height;
10 |
11 | const ItemBuilder({
12 | Key? key,
13 | required this.future,
14 | required this.successBuilder,
15 | required this.onRefresh,
16 | this.height,
17 | this.loadingHeight,
18 | }) : super(key: key);
19 |
20 | @override
21 | Widget build(BuildContext context) {
22 | return LayoutBuilder(
23 | builder: (BuildContext context, BoxConstraints constraints) {
24 | var _maxWidth = constraints.maxWidth;
25 | var _loadingHeight = height ?? loadingHeight ?? _maxWidth / 2;
26 | return FutureBuilder(
27 | future: future,
28 | builder: (BuildContext context, AsyncSnapshot snapshot) {
29 | if (snapshot.hasError) {
30 | print("${snapshot.error}");
31 | print("${snapshot.stackTrace}");
32 | return InkWell(
33 | onTap: onRefresh,
34 | child: Container(
35 | width: _maxWidth,
36 | height: _loadingHeight,
37 | child: Center(
38 | child:
39 | Icon(Icons.sync_problem, size: _loadingHeight / 1.5),
40 | ),
41 | ),
42 | );
43 | }
44 | if (snapshot.connectionState != ConnectionState.done) {
45 | return SizedBox(
46 | width: _maxWidth,
47 | height: _loadingHeight,
48 | child: Center(
49 | child: Icon(Icons.sync, size: _loadingHeight / 1.5),
50 | ),
51 | );
52 | }
53 | return SizedBox(
54 | width: _maxWidth,
55 | height: height,
56 | child: successBuilder(context, snapshot),
57 | );
58 | });
59 | },
60 | );
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/lib/screens/components/mouse_and_touch_scroll_behavior.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ui';
2 | import 'package:flutter/material.dart';
3 |
4 | final mouseAndTouchScrollBehavior = MouseAndTouchScrollBehavior();
5 |
6 | class MouseAndTouchScrollBehavior extends MaterialScrollBehavior {
7 | @override
8 | Set get dragDevices => {
9 | PointerDeviceKind.touch,
10 | PointerDeviceKind.mouse,
11 | };
12 | }
13 |
--------------------------------------------------------------------------------
/lib/screens/components/my_flat_button.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class MyFlatButton extends StatelessWidget {
4 | final String title;
5 | final VoidCallback? onPressed;
6 |
7 | const MyFlatButton({
8 | required this.title,
9 | required this.onPressed,
10 | Key? key,
11 | }) : super(key: key);
12 |
13 | @override
14 | Widget build(BuildContext context) {
15 | return LayoutBuilder(
16 | builder: (BuildContext context, BoxConstraints constraints) {
17 | var width = constraints.maxWidth;
18 | return Container(
19 | padding: const EdgeInsets.only(left: 10, right: 10),
20 | margin: const EdgeInsets.only(bottom: 10),
21 | width: width,
22 | child: MaterialButton(
23 | onPressed: onPressed,
24 | child: Row(
25 | children: [
26 | Expanded(
27 | child: Container(
28 | color: Theme.of(context)
29 | .textTheme
30 | .bodyText1!
31 | .color!
32 | .withOpacity(.05),
33 | padding: const EdgeInsets.all(10),
34 | child: Text(
35 | title,
36 | textAlign: TextAlign.center,
37 | ),
38 | ),
39 | )
40 | ],
41 | ),
42 | ),
43 | );
44 | });
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/lib/screens/components/right_click_pop.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import '../../configs/using_right_click_pop.dart';
4 |
5 | Widget rightClickPop({
6 | required Widget child,
7 | required BuildContext context,
8 | bool canPop = true,
9 | }) =>
10 | currentUsingRightClickPop()
11 | ? GestureDetector(
12 | onSecondaryTap: () {
13 | if (canPop) {
14 | Navigator.of(context).pop();
15 | }
16 | },
17 | child: child,
18 | )
19 | : child;
20 |
--------------------------------------------------------------------------------
/lib/screens/favorites_screen.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jenny/basic/commons.dart';
3 | import 'package:jenny/basic/methods.dart';
4 | import 'package:jenny/configs/login.dart';
5 | import 'package:jenny/screens/components/comic_pager.dart';
6 |
7 | import 'components/right_click_pop.dart';
8 |
9 | class FavoritesScreen extends StatefulWidget {
10 | const FavoritesScreen({Key? key}) : super(key: key);
11 |
12 | @override
13 | State createState() => _FavoritesScreenState();
14 | }
15 |
16 | class _FavoritesScreenState extends State {
17 | int _folderId = 0;
18 |
19 | final Map _folderMap = {
20 | 0: "全部",
21 | };
22 |
23 | _chooseFolder() async {
24 | int? f = await chooseMapDialog(
25 | context,
26 | values: _folderMap.map((key, value) => MapEntry(value, key)),
27 | title: "选择文件夹",
28 | );
29 | if (f != null) {
30 | setState(() {
31 | _folderId = f;
32 | });
33 | }
34 | }
35 |
36 | final _sortNameMap = {
37 | "mr": "收藏时间",
38 | "mp": "更新时间",
39 | };
40 | String _sort = "mr";
41 |
42 | _chooseSort() async {
43 | String? f = await chooseMapDialog(
44 | context,
45 | values: _sortNameMap.map((key, value) => MapEntry(value, key)),
46 | title: "选择排序",
47 | );
48 | if (f != null) {
49 | setState(() {
50 | _sort = f;
51 | });
52 | }
53 | }
54 |
55 | @override
56 | void initState() {
57 | for (var value in selfInfo.favoriteList) {
58 | try {
59 | _folderMap[int.parse(value.fid)] = value.name;
60 | } catch (e) {}
61 | }
62 | super.initState();
63 | }
64 |
65 | @override
66 | Widget build(BuildContext context) {
67 | return rightClickPop(child: buildScreen(context), context: context);
68 | }
69 |
70 | Widget buildScreen(BuildContext context) {
71 | return Scaffold(
72 | appBar: AppBar(
73 | title: const Text("收藏夹"),
74 | actions: [
75 | MaterialButton(
76 | onPressed: _chooseSort,
77 | child: Row(
78 | children: [
79 | const Icon(Icons.sort, size: 15),
80 | Container(width: 8),
81 | Text(_sortNameMap[_sort] ?? ""),
82 | ],
83 | ),
84 | ),
85 | MaterialButton(
86 | onPressed: _chooseFolder,
87 | child: Row(
88 | children: [
89 | const Icon(Icons.folder_copy_outlined,size: 15),
90 | Container(width: 8),
91 | Text(_folderMap[_folderId] ?? ""),
92 | ],
93 | ),
94 | ),
95 | ],
96 | ),
97 | body: ComicPager(
98 | key: Key("FAVOUR:$_folderId:$_sort"),
99 | onPage: (int page) async {
100 | final response = await methods.favorites(_folderId, page, _sort);
101 | return InnerComicPage(total: response.total, list: response.list);
102 | },
103 | ),
104 | );
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/lib/screens/file_photo_view_screen.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:jenny/basic/commons.dart';
5 | import 'package:photo_view/photo_view.dart';
6 |
7 | import 'components/right_click_pop.dart';
8 |
9 | // 预览图片
10 | class FilePhotoViewScreen extends StatelessWidget {
11 | final String filePath;
12 |
13 | const FilePhotoViewScreen(this.filePath, {Key? key}) : super(key: key);
14 |
15 | @override
16 | Widget build(BuildContext context) {
17 | return rightClickPop(child: buildScreen(context), context: context);
18 | }
19 |
20 | Widget buildScreen(BuildContext context) => Scaffold(
21 | body: Stack(
22 | children: [
23 | GestureDetector(
24 | onLongPress: () async {
25 | String? choose = await chooseListDialog(
26 | context,
27 | title: '请选择',
28 | values: [
29 | ...Platform.isAndroid || Platform.isIOS
30 | ? [
31 | '保存图片到相册',
32 | ]
33 | : [],
34 | '保存图片到文件',
35 | ],
36 | );
37 | switch (choose) {
38 | case '保存图片到相册':
39 | saveImageFileToGallery(context, filePath);
40 | break;
41 | case '保存图片到文件':
42 | saveImageFileToFile(context, filePath);
43 | break;
44 | }
45 | },
46 | child: PhotoView(
47 | imageProvider: FileImage(File(filePath)),
48 | ),
49 | ),
50 | InkWell(
51 | onTap: () => Navigator.of(context).pop(),
52 | child: Container(
53 | margin: const EdgeInsets.only(top: 80),
54 | padding: const EdgeInsets.only(left: 4, right: 4),
55 | decoration: BoxDecoration(
56 | color: Colors.black.withOpacity(.75),
57 | borderRadius: const BorderRadius.only(
58 | topRight: Radius.circular(8),
59 | bottomRight: Radius.circular(8),
60 | ),
61 | ),
62 | child: const Icon(Icons.keyboard_backspace, color: Colors.white),
63 | ),
64 | ),
65 | ],
66 | ),
67 | );
68 | }
69 |
--------------------------------------------------------------------------------
/lib/screens/init_screen.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:flutter/services.dart';
5 | import 'package:jenny/basic/commons.dart';
6 | import 'package:jenny/basic/methods.dart';
7 | import 'package:jenny/configs/configs.dart';
8 | import 'package:jenny/configs/login.dart';
9 | import 'package:jenny/configs/passed.dart';
10 | import 'package:jenny/screens/calculator_screen.dart';
11 |
12 | import '../basic/web_dav_sync.dart';
13 | import 'app_screen.dart';
14 | import 'first_login_screen.dart';
15 | import 'network_setting_screen.dart';
16 |
17 | class InitScreen extends StatefulWidget {
18 | const InitScreen({Key? key}) : super(key: key);
19 |
20 | @override
21 | State createState() => _InitScreenState();
22 | }
23 |
24 | class _InitScreenState extends State {
25 | @override
26 | void initState() {
27 | super.initState();
28 | _init();
29 | }
30 |
31 | @override
32 | Widget build(BuildContext context) {
33 | return Scaffold(
34 | backgroundColor: const Color(0xffeeeeee),
35 | body: Stack(
36 | children: [
37 | Container(
38 | decoration: const BoxDecoration(
39 | image: DecorationImage(
40 | image: AssetImage('lib/assets/backpoint.png'),
41 | repeat: ImageRepeat.repeat,
42 | ),
43 | ),
44 | ),
45 | ConstrainedBox(
46 | constraints: const BoxConstraints.expand(),
47 | child: Container(
48 | padding: const EdgeInsets.all(10),
49 | child: Image.asset(
50 | "lib/assets/startup.png",
51 | fit: BoxFit.contain,
52 | ),
53 | ),
54 | ),
55 | ],
56 | ),
57 | );
58 | }
59 |
60 | Future _init() async {
61 | try {
62 | await methods.init();
63 | await initConfigs();
64 | Future.delayed(Duration.zero, () async {
65 | await webDavSyncAuto(context);
66 | Navigator.of(context).pushReplacement(
67 | MaterialPageRoute(builder: (BuildContext context) {
68 | return const AppScreen();
69 | }),
70 | );
71 | });
72 | } catch (e, st) {
73 | print("$e\n$st");
74 | defaultToast(context, "初始化失败, 请设置网络");
75 | Future.delayed(Duration.zero, () {
76 | Navigator.of(context).pushReplacement(
77 | MaterialPageRoute(builder: (BuildContext context) {
78 | return const NetworkSettingScreen();
79 | }),
80 | );
81 | });
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/lib/screens/network_setting_screen.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jenny/configs/network_api_host.dart';
3 | import 'package:jenny/configs/network_cdn_host.dart';
4 | import 'package:jenny/screens/init_screen.dart';
5 |
6 | import 'components/right_click_pop.dart';
7 |
8 | class NetworkSettingScreen extends StatelessWidget {
9 | const NetworkSettingScreen({Key? key}) : super(key: key);
10 |
11 | @override
12 | Widget build(BuildContext context) {
13 | return rightClickPop(child: buildScreen(context), context: context);
14 | }
15 |
16 | Widget buildScreen(BuildContext context) {
17 | return Scaffold(
18 | appBar: AppBar(
19 | title: const Text("网络设置"),
20 | actions: [
21 | IconButton(
22 | onPressed: () {
23 | Navigator.of(context).pushReplacement(
24 | MaterialPageRoute(builder: (BuildContext context) {
25 | return const InitScreen();
26 | }),
27 | );
28 | },
29 | icon: const Icon(Icons.save),
30 | ),
31 | ],
32 | ),
33 | body: ListView(
34 | children: [
35 | apiHostSetting(),
36 | cdnHostSetting(),
37 | ],
38 | ),
39 | );
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/screens/view_log_screen.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jenny/basic/commons.dart';
3 | import 'package:jenny/basic/methods.dart';
4 | import 'package:jenny/screens/components/floating_search_bar.dart';
5 |
6 | import 'components/browser_bottom_sheet.dart';
7 | import 'components/comic_pager.dart';
8 | import 'components/right_click_pop.dart';
9 |
10 | class ViewLogScreen extends StatefulWidget {
11 | const ViewLogScreen({Key? key}) : super(key: key);
12 |
13 | @override
14 | State createState() => _ViewLogScreenState();
15 | }
16 |
17 | class _ViewLogScreenState extends State {
18 | @override
19 | Widget build(BuildContext context) {
20 | return rightClickPop(child: buildScreen(context), context: context);
21 | }
22 |
23 | Widget buildScreen(BuildContext context) {
24 | return Scaffold(
25 | appBar: AppBar(
26 | title: const Text("浏览记录"),
27 | actions: [
28 | IconButton(
29 | onPressed: () async {
30 | String? choose = await chooseListDialog(
31 | context,
32 | values: ["是", "否"],
33 | title: "清除所有历史记录?",
34 | );
35 | if ("是" == choose) {
36 | await methods.clearViewLog();
37 | Navigator.of(context).pushReplacement(MaterialPageRoute(
38 | builder: (BuildContext context) {
39 | return const ViewLogScreen();
40 | },
41 | ));
42 | }
43 | },
44 | icon: const Icon(Icons.auto_delete),
45 | ),
46 | const BrowserBottomSheetAction(),
47 | ],
48 | ),
49 | body: ComicPager(
50 | key: const Key("HISTORY"),
51 | onPage: (int page) async {
52 | final response = await methods.pageViewLog(page);
53 | return InnerComicPage(
54 | total: response.total,
55 | list: response.content,
56 | );
57 | },
58 | ),
59 | );
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/linux/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral
2 |
--------------------------------------------------------------------------------
/linux/appimage/AppRun.desktop:
--------------------------------------------------------------------------------
1 | [Desktop Entry]
2 | Version=1.0
3 | Type=Application
4 | Terminal=false
5 | Name=jenny
6 | Exec=AppRun %u
7 | Icon=AppRun
8 | Categories=Utility;
9 |
--------------------------------------------------------------------------------
/linux/appimage/AppRun.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/linux/appimage/AppRun.png
--------------------------------------------------------------------------------
/linux/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 |
3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
4 |
5 | # Configuration provided via flutter tool.
6 | include(${EPHEMERAL_DIR}/generated_config.cmake)
7 |
8 | # TODO: Move the rest of this into files in ephemeral. See
9 | # https://github.com/flutter/flutter/issues/57146.
10 |
11 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...),
12 | # which isn't available in 3.10.
13 | function(list_prepend LIST_NAME PREFIX)
14 | set(NEW_LIST "")
15 | foreach(element ${${LIST_NAME}})
16 | list(APPEND NEW_LIST "${PREFIX}${element}")
17 | endforeach(element)
18 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
19 | endfunction()
20 |
21 | # === Flutter Library ===
22 | # System-level dependencies.
23 | find_package(PkgConfig REQUIRED)
24 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
25 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
26 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
27 |
28 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
29 |
30 | # Published to parent scope for install step.
31 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
32 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
33 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
34 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
35 |
36 | list(APPEND FLUTTER_LIBRARY_HEADERS
37 | "fl_basic_message_channel.h"
38 | "fl_binary_codec.h"
39 | "fl_binary_messenger.h"
40 | "fl_dart_project.h"
41 | "fl_engine.h"
42 | "fl_json_message_codec.h"
43 | "fl_json_method_codec.h"
44 | "fl_message_codec.h"
45 | "fl_method_call.h"
46 | "fl_method_channel.h"
47 | "fl_method_codec.h"
48 | "fl_method_response.h"
49 | "fl_plugin_registrar.h"
50 | "fl_plugin_registry.h"
51 | "fl_standard_message_codec.h"
52 | "fl_standard_method_codec.h"
53 | "fl_string_codec.h"
54 | "fl_value.h"
55 | "fl_view.h"
56 | "flutter_linux.h"
57 | )
58 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
59 | add_library(flutter INTERFACE)
60 | target_include_directories(flutter INTERFACE
61 | "${EPHEMERAL_DIR}"
62 | )
63 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
64 | target_link_libraries(flutter INTERFACE
65 | PkgConfig::GTK
66 | PkgConfig::GLIB
67 | PkgConfig::GIO
68 | )
69 | add_dependencies(flutter flutter_assemble)
70 |
71 | # === Flutter tool backend ===
72 | # _phony_ is a non-existent file to force this command to run every time,
73 | # since currently there's no way to get a full input/output list from the
74 | # flutter tool.
75 | add_custom_command(
76 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
77 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_
78 | COMMAND ${CMAKE_COMMAND} -E env
79 | ${FLUTTER_TOOL_ENVIRONMENT}
80 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
81 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
82 | VERBATIM
83 | )
84 | add_custom_target(flutter_assemble DEPENDS
85 | "${FLUTTER_LIBRARY}"
86 | ${FLUTTER_LIBRARY_HEADERS}
87 | )
88 |
--------------------------------------------------------------------------------
/linux/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 | #include
10 | #include
11 | #include
12 |
13 | void fl_register_plugins(FlPluginRegistry* registry) {
14 | g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
15 | fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
16 | screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);
17 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
18 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
19 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
20 | g_autoptr(FlPluginRegistrar) window_manager_registrar =
21 | fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin");
22 | window_manager_plugin_register_with_registrar(window_manager_registrar);
23 | }
24 |
--------------------------------------------------------------------------------
/linux/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void fl_register_plugins(FlPluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/linux/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | screen_retriever
7 | url_launcher_linux
8 | window_manager
9 | )
10 |
11 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
12 | )
13 |
14 | set(PLUGIN_BUNDLED_LIBRARIES)
15 |
16 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
17 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
18 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
20 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
21 | endforeach(plugin)
22 |
23 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
24 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
25 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
26 | endforeach(ffi_plugin)
27 |
--------------------------------------------------------------------------------
/linux/main.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 | #include "rust.h"
3 | #include
4 | #include
5 |
6 | #include "rust1.h"
7 |
8 | int main(int argc, char** argv) {
9 | struct passwd *pw = getpwuid(getuid());
10 | printf("PW_DIR : %s\n",pw->pw_dir);
11 | init_ffi(pw->pw_dir);
12 |
13 | init_http_server();
14 |
15 | g_autoptr(MyApplication) app = my_application_new();
16 | return g_application_run(G_APPLICATION(app), argc, argv);
17 | }
18 |
--------------------------------------------------------------------------------
/linux/methods_plugin.cc:
--------------------------------------------------------------------------------
1 | #include "methods_plugin.h"
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | #include "rust.h"
10 |
11 | #define METHODS_PLUGIN(obj) \
12 | (G_TYPE_CHECK_INSTANCE_CAST((obj), methods_plugin_get_type(), \
13 | MethodsPlugin))
14 |
15 | struct _MethodsPlugin {
16 | GObject parent_instance;
17 | };
18 |
19 | G_DEFINE_TYPE(MethodsPlugin, methods_plugin, g_object_get_type())
20 |
21 | // Called when a method call is received from Flutter.
22 | static void methods_plugin_handle_method_call(
23 | MethodsPlugin* self,
24 | FlMethodCall* method_call) {
25 | g_autoptr(FlMethodResponse) response = nullptr;
26 |
27 | const gchar* method = fl_method_call_get_name(method_call);
28 |
29 | if (strcmp(method, "invoke") == 0) {
30 | FlValue *value = fl_method_call_get_args(method_call);
31 | const char* params = fl_value_get_string(value);
32 | char *rs = invoke_ffi(params);
33 | g_autoptr(FlValue) result = fl_value_new_string(rs);
34 | response = FL_METHOD_RESPONSE(fl_method_success_response_new(result));
35 | fl_method_call_respond(method_call, response, nullptr);
36 | free_str_ffi(rs);
37 | } else if (strcmp(method, "getPlatformVersion") == 0) {
38 | struct utsname uname_data = {};
39 | uname(&uname_data);
40 | g_autofree gchar *version = g_strdup_printf("Linux %s", uname_data.version);
41 | g_autoptr(FlValue) result = fl_value_new_string(version);
42 | response = FL_METHOD_RESPONSE(fl_method_success_response_new(result));
43 | fl_method_call_respond(method_call, response, nullptr);
44 | } else {
45 | response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new());
46 | fl_method_call_respond(method_call, response, nullptr);
47 | }
48 |
49 | }
50 |
51 | static void methods_plugin_dispose(GObject* object) {
52 | G_OBJECT_CLASS(methods_plugin_parent_class)->dispose(object);
53 | }
54 |
55 | static void methods_plugin_class_init(MethodsPluginClass* klass) {
56 | G_OBJECT_CLASS(klass)->dispose = methods_plugin_dispose;
57 | }
58 |
59 | static void methods_plugin_init(MethodsPlugin* self) {}
60 |
61 | static void method_call_cb(FlMethodChannel* channel, FlMethodCall* method_call,
62 | gpointer user_data) {
63 | MethodsPlugin* plugin = METHODS_PLUGIN(user_data);
64 | methods_plugin_handle_method_call(plugin, method_call);
65 | }
66 |
67 | void methods_plugin_register_with_registrar(FlPluginRegistrar* registrar) {
68 | MethodsPlugin* plugin = METHODS_PLUGIN(
69 | g_object_new(methods_plugin_get_type(), nullptr));
70 |
71 | g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
72 | g_autoptr(FlMethodChannel) channel =
73 | fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar),
74 | "methods",
75 | FL_METHOD_CODEC(codec));
76 | fl_method_channel_set_method_call_handler(channel, method_call_cb,
77 | g_object_ref(plugin),
78 | g_object_unref);
79 |
80 | g_object_unref(plugin);
81 | }
82 |
--------------------------------------------------------------------------------
/linux/methods_plugin.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_PLUGIN_METHODS_PLUGIN_H_
2 | #define FLUTTER_PLUGIN_METHODS_PLUGIN_H_
3 |
4 | #include
5 |
6 | G_BEGIN_DECLS
7 |
8 | #ifdef FLUTTER_PLUGIN_IMPL
9 | #define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
10 | #else
11 | #define FLUTTER_PLUGIN_EXPORT
12 | #endif
13 |
14 | typedef struct _MethodsPlugin MethodsPlugin;
15 | typedef struct {
16 | GObjectClass parent_class;
17 | } MethodsPluginClass;
18 |
19 | FLUTTER_PLUGIN_EXPORT GType methods_plugin_get_type();
20 |
21 | FLUTTER_PLUGIN_EXPORT void methods_plugin_register_with_registrar(
22 | FlPluginRegistrar* registrar);
23 |
24 | G_END_DECLS
25 |
26 | #endif // FLUTTER_PLUGIN_METHODS_PLUGIN_H_
27 |
--------------------------------------------------------------------------------
/linux/my_application.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_MY_APPLICATION_H_
2 | #define FLUTTER_MY_APPLICATION_H_
3 |
4 | #include
5 |
6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
7 | GtkApplication)
8 |
9 | /**
10 | * my_application_new:
11 | *
12 | * Creates a new Flutter-based application.
13 | *
14 | * Returns: a new #MyApplication.
15 | */
16 | MyApplication* my_application_new();
17 |
18 | #endif // FLUTTER_MY_APPLICATION_H_
19 |
--------------------------------------------------------------------------------
/macos/.gitignore:
--------------------------------------------------------------------------------
1 | # Flutter-related
2 | **/Flutter/ephemeral/
3 | **/Pods/
4 |
5 | # Xcode-related
6 | **/dgph
7 | **/xcuserdata/
8 |
--------------------------------------------------------------------------------
/macos/Flutter/Flutter-Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "ephemeral/Flutter-Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/macos/Flutter/Flutter-Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "ephemeral/Flutter-Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/macos/Flutter/GeneratedPluginRegistrant.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | import FlutterMacOS
6 | import Foundation
7 |
8 | import screen_retriever
9 | import url_launcher_macos
10 | import window_manager
11 |
12 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
13 | ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
14 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
15 | WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
16 | }
17 |
--------------------------------------------------------------------------------
/macos/Podfile:
--------------------------------------------------------------------------------
1 | platform :osx, '10.14'
2 |
3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
5 |
6 | project 'Runner', {
7 | 'Debug' => :debug,
8 | 'Profile' => :release,
9 | 'Release' => :release,
10 | }
11 |
12 | def flutter_root
13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
14 | unless File.exist?(generated_xcode_build_settings_path)
15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
16 | end
17 |
18 | File.foreach(generated_xcode_build_settings_path) do |line|
19 | matches = line.match(/FLUTTER_ROOT\=(.*)/)
20 | return matches[1].strip if matches
21 | end
22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
23 | end
24 |
25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
26 |
27 | flutter_macos_podfile_setup
28 |
29 | target 'Runner' do
30 | use_frameworks!
31 | use_modular_headers!
32 |
33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
34 | end
35 |
36 | post_install do |installer|
37 | installer.pods_project.targets.each do |target|
38 | flutter_additional_macos_build_settings(target)
39 | end
40 | end
41 |
--------------------------------------------------------------------------------
/macos/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - FlutterMacOS (1.0.0)
3 | - screen_retriever (0.0.1):
4 | - FlutterMacOS
5 | - url_launcher_macos (0.0.1):
6 | - FlutterMacOS
7 | - window_manager (0.2.0):
8 | - FlutterMacOS
9 |
10 | DEPENDENCIES:
11 | - FlutterMacOS (from `Flutter/ephemeral`)
12 | - screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`)
13 | - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
14 | - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`)
15 |
16 | EXTERNAL SOURCES:
17 | FlutterMacOS:
18 | :path: Flutter/ephemeral
19 | screen_retriever:
20 | :path: Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos
21 | url_launcher_macos:
22 | :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
23 | window_manager:
24 | :path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos
25 |
26 | SPEC CHECKSUMS:
27 | FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
28 | screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38
29 | url_launcher_macos: 5335912b679c073563f29d89d33d10d459f95451
30 | window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8
31 |
32 | PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7
33 |
34 | COCOAPODS: 1.12.1
35 |
--------------------------------------------------------------------------------
/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/macos/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/macos/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | @NSApplicationMain
5 | class AppDelegate: FlutterAppDelegate {
6 |
7 | override init() {
8 | super.init()
9 | let folder = NSHomeDirectory()+"/Library/Application Support/jenny"
10 | let chars = folder.cString(using: String.Encoding.utf8)
11 | init_ffi(chars!)
12 | }
13 |
14 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
15 | return true
16 | }
17 |
18 | override func applicationWillFinishLaunching(_ notification: Notification) {
19 | super.applicationWillFinishLaunching(notification)
20 | let width = load_int_property("window_width", 600);
21 | let height = load_int_property("window_height", 800);
22 | mainFlutterWindow?.setContentSize(NSSize.init(width: CGFloat(max(width,50)), height: CGFloat(max(height,50))));
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "16x16",
5 | "idiom" : "mac",
6 | "filename" : "app_icon_16.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "16x16",
11 | "idiom" : "mac",
12 | "filename" : "app_icon_32.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "32x32",
17 | "idiom" : "mac",
18 | "filename" : "app_icon_32.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "32x32",
23 | "idiom" : "mac",
24 | "filename" : "app_icon_64.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "128x128",
29 | "idiom" : "mac",
30 | "filename" : "app_icon_128.png",
31 | "scale" : "1x"
32 | },
33 | {
34 | "size" : "128x128",
35 | "idiom" : "mac",
36 | "filename" : "app_icon_256.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "256x256",
41 | "idiom" : "mac",
42 | "filename" : "app_icon_256.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "size" : "256x256",
47 | "idiom" : "mac",
48 | "filename" : "app_icon_512.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "512x512",
53 | "idiom" : "mac",
54 | "filename" : "app_icon_512.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "size" : "512x512",
59 | "idiom" : "mac",
60 | "filename" : "app_icon_1024.png",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/niuhuan/jenny/3598aaf1d051b95e57ee977e4bfc6d2cc5c22d42/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
--------------------------------------------------------------------------------
/macos/Runner/Configs/AppInfo.xcconfig:
--------------------------------------------------------------------------------
1 | // Application-level settings for the Runner target.
2 | //
3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
4 | // future. If not, the values below would default to using the project name when this becomes a
5 | // 'flutter create' template.
6 |
7 | // The application's name. By default this is also the title of the Flutter window.
8 | PRODUCT_NAME = jenny
9 |
10 | // The application's bundle identifier
11 | PRODUCT_BUNDLE_IDENTIFIER = opensource.jenny
12 |
13 | // The copyright displayed in application information
14 | PRODUCT_COPYRIGHT = Copyright © 2021 com.example. All rights reserved.
15 |
--------------------------------------------------------------------------------
/macos/Runner/Configs/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Debug.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/macos/Runner/Configs/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Release.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/macos/Runner/Configs/Warnings.xcconfig:
--------------------------------------------------------------------------------
1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
2 | GCC_WARN_UNDECLARED_SELECTOR = YES
3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
6 | CLANG_WARN_PRAGMA_PACK = YES
7 | CLANG_WARN_STRICT_PROTOTYPES = YES
8 | CLANG_WARN_COMMA = YES
9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES
10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
12 | GCC_WARN_SHADOW = YES
13 | CLANG_WARN_UNREACHABLE_CODE = YES
14 |
--------------------------------------------------------------------------------
/macos/Runner/DebugProfile.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.network.client
6 |
7 | com.apple.security.app-sandbox
8 |
9 | com.apple.security.cs.allow-jit
10 |
11 | com.apple.security.network.server
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/macos/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | $(PRODUCT_COPYRIGHT)
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/macos/Runner/MainFlutterWindow.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | class MainFlutterWindow: NSWindow {
5 | override func awakeFromNib() {
6 | let flutterViewController = FlutterViewController.init()
7 | let windowFrame = self.frame
8 | self.contentViewController = flutterViewController
9 | self.setFrame(windowFrame, display: true)
10 |
11 | RegisterGeneratedPlugins(registry: flutterViewController)
12 |
13 | MethodsPlugin.register(
14 | with: flutterViewController.registrar(forPlugin:"methods")
15 | )
16 |
17 | super.awakeFromNib()
18 | }
19 | }
20 |
21 |
22 | public class MethodsPlugin: NSObject, FlutterPlugin {
23 |
24 |
25 | public static func register(with registrar: FlutterPluginRegistrar) {
26 | let channel = FlutterMethodChannel(name: "methods", binaryMessenger: registrar.messenger)
27 | let instance = MethodsPlugin()
28 | registrar.addMethodCallDelegate(instance, channel: channel)
29 | }
30 |
31 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
32 | Thread {
33 | switch call.method {
34 | case "invoke":
35 | if let params = call.arguments as? String {
36 | let chars = params.cString(using: String.Encoding.utf8)
37 | let rsp = invoke_ffi(chars!)
38 | let str = String.init(utf8String: rsp!)
39 | free_str_ffi(rsp!)
40 | result(str)
41 | }
42 | default:
43 | result(FlutterMethodNotImplemented)
44 | }
45 | }.start()
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/macos/Runner/Release.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.network.client
6 |
7 | com.apple.security.app-sandbox
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/macos/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | //
2 | // Use this file to import your target's public headers that you would like to expose to Swift.
3 | //
4 |
5 | #include "../rust.h"
6 |
--------------------------------------------------------------------------------
/native/jmbackend/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | Cargo.lock
3 |
4 | platforms/android/jmbackend
5 | platforms/android/jmcomic-rs
6 | platforms/test/
7 |
8 | /.idea/
9 | *.iml
10 |
--------------------------------------------------------------------------------
/native/jmbackend/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "jmbackend"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7 |
8 | [dependencies]
9 | jmcomic = { path = "../jmcomic-rs" }
10 | lazy_static = "1.4.0"
11 | sea-orm = { version = "0.12.4", features = ["sqlx-sqlite", "runtime-tokio-rustls", "macros"], default-features = false }
12 | sea-orm-migration = { version = "0.12.4", features = ["sqlx-sqlite", "runtime-tokio-rustls"], default-features = false }
13 | chrono = "0.4.31"
14 | libc = "0.2.149"
15 | bytes = "1.5.0"
16 | tokio = { version = "1.33.0", features = ["full"] }
17 | reqwest = { version = "0.11.22", features = ["socks", "stream", "rustls", "tokio-rustls", "rustls-tls"], default-features = false }
18 | hex = "0.4.3"
19 | md5 = "0.7.0"
20 | image = { version = "0.24.7", features = ["png", "jpeg", "bmp", "gif", "webp"] }
21 | rand = "0.8.5"
22 | itertools = "0.11.0"
23 | async-trait = "0.1.74"
24 | anyhow = "1.0.75"
25 | rsa = "0.6.1"
26 | base64 = "0.13.0"
27 | once_cell = "1.18.0"
28 | regex = "1.10.2"
29 | num-iter = "0.1.43"
30 | futures-util = "0.3.29"
31 | grouping_by = "0.2.2"
32 | tokio-util = { version = "0.7.10", features = ["full"] }
33 | async_zip = { version = "0.0.9", features = ["deflate"], default-features = false }
34 | serde = { version = "1.0.190", features = ["derive"] }
35 | serde_derive = "1.0.190"
36 | serde_json = "1.0.108"
37 |
38 | [features]
39 |
--------------------------------------------------------------------------------
/native/jmbackend/platforms/android/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "rust"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | [dependencies]
7 | jmbackend = { path = "../../" }
8 | jni = "0.21.0"
9 |
10 | [lib]
11 | crate-type = ["cdylib"]
12 |
--------------------------------------------------------------------------------
/native/jmbackend/platforms/android/src/lib.rs:
--------------------------------------------------------------------------------
1 | pub use jmbackend::*;
2 | use jni::objects::JClass;
3 | use jni::objects::JString;
4 | use jni::JNIEnv;
5 |
6 | #[no_mangle]
7 | pub unsafe extern "system" fn Java_opensource_jenny_Jni_init<'local>(
8 | mut env: JNIEnv<'local>,
9 | _class: JClass<'local>,
10 | params: JString<'local>,
11 | ) {
12 | let params: String = env.get_string(¶ms).unwrap().into();
13 | init_sync(params.as_str());
14 | }
15 |
16 | #[no_mangle]
17 | pub unsafe extern "C" fn Java_opensource_jenny_Jni_invoke<'local>(
18 | mut env: JNIEnv<'local>,
19 | _: JClass<'local>,
20 | params: JString<'local>,
21 | ) -> JString<'local> {
22 | let params: String = env.get_string(¶ms).unwrap().into();
23 | env.new_string(invoke(params.as_str())).unwrap()
24 | }
25 |
--------------------------------------------------------------------------------
/native/jmbackend/platforms/ios-sim/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "rust"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | [dependencies]
7 | jmbackend = { path = "../../" }
8 |
9 | [lib]
10 | crate-type = ["staticlib"]
11 |
--------------------------------------------------------------------------------
/native/jmbackend/platforms/ios-sim/src/lib.rs:
--------------------------------------------------------------------------------
1 | pub use jmbackend::*;
2 |
--------------------------------------------------------------------------------
/native/jmbackend/platforms/ios/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "rust"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | [dependencies]
7 | jmbackend = { path = "../../" }
8 |
9 | [lib]
10 | crate-type = ["staticlib"]
11 |
--------------------------------------------------------------------------------
/native/jmbackend/platforms/ios/src/lib.rs:
--------------------------------------------------------------------------------
1 | pub use jmbackend::*;
2 |
--------------------------------------------------------------------------------
/native/jmbackend/platforms/linux/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "rust"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | [dependencies]
7 | jmbackend = { path = "../../" }
8 | lazy_static = "1.4.0"
9 | reqwest = { version = "0.11.9", features = ["rustls", "tokio-rustls", "rustls-tls"], default-features = false }
10 | serde = { version = "1.0.152", features = ["derive"] }
11 | serde_derive = "1.0.152"
12 | serde_json = "1.0.93"
13 | warp = "0.3.2"
14 | tokio = { version = "1.26.0", features = ["full"] }
15 |
16 | [lib]
17 | crate-type = ["staticlib"]
18 |
--------------------------------------------------------------------------------
/native/jmbackend/platforms/linux/src/lib.rs:
--------------------------------------------------------------------------------
1 | use std::process::exit;
2 | use std::time::Duration;
3 |
4 | use serde_json::to_string;
5 | use warp::Filter;
6 |
7 | pub use jmbackend::*;
8 |
9 | #[derive(Debug, serde::Deserialize, serde::Serialize)]
10 | pub struct DartQuery {
11 | pub method: String,
12 | pub params: String,
13 | }
14 |
15 | #[no_mangle]
16 | pub unsafe extern "C" fn init_http_server() {
17 | let ping = warp::get()
18 | .and(warp::path("ping"))
19 | .map(|| "pong".to_owned());
20 | let invoke = warp::post()
21 | .and(warp::path("invoke"))
22 | .and(warp::body::json())
23 | .map(invoke);
24 | std::thread::spawn(move || {
25 | jmbackend::RUNTIME.block_on(warp::serve(ping.or(invoke)).run(([127, 0, 0, 1], 52764)))
26 | });
27 | jmbackend::RUNTIME.block_on(test_startup());
28 | }
29 |
30 | fn invoke(dq: DartQuery) -> String {
31 | jmbackend::RUNTIME.block_on(jmbackend::invoke_async(to_string(&dq).unwrap().as_str()))
32 | }
33 |
34 | async fn test_startup() {
35 | for i in 0..6 {
36 | if i == 5 {
37 | exit(2);
38 | }
39 | std::thread::sleep(Duration::new(1, 0));
40 | match reqwest::get("http://127.0.0.1:52764/ping").await {
41 | Ok(req) => match req.text().await {
42 | Ok(txt) => {
43 | println!("OK : {}", txt);
44 | break;
45 | }
46 | Err(err) => println!("ERR : {}", err),
47 | },
48 | Err(err) => {
49 | println!("ERR : {}", err)
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/native/jmbackend/platforms/macos/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "rust"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | [dependencies]
7 | jmbackend = { path = "../../" }
8 |
9 | [lib]
10 | crate-type = ["staticlib"]
11 |
--------------------------------------------------------------------------------
/native/jmbackend/platforms/macos/src/lib.rs:
--------------------------------------------------------------------------------
1 | pub use jmbackend::*;
2 |
--------------------------------------------------------------------------------
/native/jmbackend/platforms/windows/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "rust"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | [dependencies]
7 | jmbackend = { path = "../../" }
8 |
9 | [lib]
10 | crate-type = ["staticlib"]
11 |
--------------------------------------------------------------------------------
/native/jmbackend/platforms/windows/src/lib.rs:
--------------------------------------------------------------------------------
1 | pub use jmbackend::*;
2 |
--------------------------------------------------------------------------------
/native/jmbackend/src/database/active_db/search_history.rs:
--------------------------------------------------------------------------------
1 | use crate::database::utils::{create_index, create_table_if_not_exists, index_exists};
2 | use sea_orm::entity::prelude::*;
3 | use sea_orm::EntityTrait;
4 | use serde::{Deserialize, Serialize};
5 |
6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)]
7 | #[sea_orm(table_name = "search_history")]
8 | pub struct Model {
9 | #[sea_orm(primary_key, auto_increment = false)]
10 | pub search_query: String,
11 | pub last_search_time: i64,
12 | }
13 |
14 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
15 | pub enum Relation {}
16 |
17 | impl ActiveModelBehavior for ActiveModel {}
18 |
19 | pub(crate) async fn init(db: &DatabaseConnection) {
20 | create_table_if_not_exists(db, Entity).await;
21 | if !index_exists(db, "search_history", "idx_last_search_time").await {
22 | create_index(
23 | db,
24 | "search_history",
25 | vec!["last_search_time"],
26 | "idx_last_search_time",
27 | )
28 | .await;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/native/jmbackend/src/database/active_db/view_log.rs:
--------------------------------------------------------------------------------
1 | use crate::database::utils::{create_index, create_table_if_not_exists, index_exists};
2 | use sea_orm::entity::prelude::*;
3 | use sea_orm::EntityTrait;
4 | use serde::{Deserialize, Serialize};
5 |
6 | #[derive(Clone, Debug, PartialEq, Eq, Hash, DeriveEntityModel, Deserialize, Serialize)]
7 | #[sea_orm(table_name = "view_log")]
8 | pub struct Model {
9 | // 原漫画id
10 | #[sea_orm(primary_key, auto_increment = false)]
11 | pub id: i64,
12 | pub author: String,
13 | pub description: String,
14 | pub name: String,
15 | // 最后阅读或查看详情的时间
16 | pub last_view_time: i64,
17 | // 0 为没阅读过漫画
18 | pub last_view_chapter_id: i64,
19 | // 最后阅读过了第几页
20 | pub last_view_page: i64,
21 | }
22 |
23 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
24 | pub enum Relation {}
25 |
26 | impl ActiveModelBehavior for ActiveModel {}
27 |
28 | pub(crate) async fn init(db: &DatabaseConnection) {
29 | create_table_if_not_exists(db, Entity).await;
30 | if !index_exists(db, "view_log", "idx_last_view_time").await {
31 | create_index(db, "view_log", vec!["last_view_time"], "idx_last_view_time").await;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/native/jmbackend/src/database/active_db/view_log_tag.rs:
--------------------------------------------------------------------------------
1 | use crate::database::utils::create_table_if_not_exists;
2 | use sea_orm::entity::prelude::*;
3 | use sea_orm::EntityTrait;
4 | use serde::{Deserialize, Serialize};
5 |
6 | #[derive(Clone, Debug, PartialEq, Eq, Hash, DeriveEntityModel, Deserialize, Serialize)]
7 | #[sea_orm(table_name = "view_log_tag")]
8 | pub struct Model {
9 | // 原漫画id
10 | #[sea_orm(primary_key)]
11 | pub id: i64,
12 | #[sea_orm(primary_key)]
13 | pub tag_name: String,
14 | }
15 |
16 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
17 | pub enum Relation {}
18 |
19 | impl ActiveModelBehavior for ActiveModel {}
20 |
21 | pub(crate) async fn init(db: &DatabaseConnection) {
22 | create_table_if_not_exists(db, Entity).await;
23 | }
24 |
--------------------------------------------------------------------------------
/native/jmbackend/src/database/image_cache_db/image_cache.rs:
--------------------------------------------------------------------------------
1 | use crate::database::utils::{create_index, create_table_if_not_exists, index_exists};
2 | use sea_orm::entity::prelude::*;
3 | use sea_orm::EntityTrait;
4 |
5 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
6 | #[sea_orm(table_name = "image_cache")]
7 | pub struct Model {
8 | #[sea_orm(primary_key, auto_increment = false)]
9 | pub cache_key: String,
10 | pub cache_path: String,
11 | pub cache_time: i64,
12 | }
13 |
14 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
15 | pub enum Relation {}
16 |
17 | impl ActiveModelBehavior for ActiveModel {}
18 |
19 | // CREATE INDEX idx_cache_time ON image_cache(cache_time);
20 | // select * from sqlite_master where type='index' AND tbl_name='image_cache' AND name='idx_cache_time';
21 |
22 | pub(crate) async fn init(db: &DatabaseConnection) {
23 | create_table_if_not_exists(db, Entity).await;
24 | if !index_exists(db, "image_cache", "idx_cache_time").await {
25 | create_index(db, "image_cache", vec!["cache_time"], "idx_cache_time").await;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/native/jmbackend/src/database/mod.rs:
--------------------------------------------------------------------------------
1 | pub(crate) mod active_db;
2 | pub(crate) mod image_cache_db;
3 | pub(crate) mod property_db;
4 | pub(crate) mod utils;
5 | pub(crate) mod web_cache_db;
6 |
--------------------------------------------------------------------------------
/native/jmbackend/src/database/property_db/migrations.rs:
--------------------------------------------------------------------------------
1 | use sea_orm::{ConnectionTrait, Statement};
2 | use sea_orm_migration::prelude::*;
3 |
4 | pub struct Migrator;
5 |
6 | #[async_trait::async_trait]
7 | impl MigratorTrait for Migrator {
8 | fn migrations() -> Vec> {
9 | vec![Box::new(M20220305V100CleanCookie)]
10 | }
11 | }
12 |
13 | pub struct M20220305V100CleanCookie;
14 |
15 | impl MigrationName for M20220305V100CleanCookie {
16 | fn name(&self) -> &str {
17 | "M20220305V100CleanCookie"
18 | }
19 | }
20 |
21 | #[async_trait::async_trait]
22 | impl MigrationTrait for M20220305V100CleanCookie {
23 | async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
24 | let sql = "DELETE FROM property WHERE k = 'cookie'";
25 | let stmt = Statement::from_string(manager.get_database_backend(), sql.to_owned());
26 | manager.get_connection().execute(stmt).await.map(|_| ())
27 | }
28 |
29 | async fn down(&self, _: &SchemaManager) -> Result<(), DbErr> {
30 | Ok(())
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/native/jmbackend/src/database/property_db/mod.rs:
--------------------------------------------------------------------------------
1 | use std::ops::Deref;
2 |
3 | use once_cell::sync::OnceCell;
4 | use sea_orm::ActiveModelTrait;
5 | use sea_orm::DatabaseConnection;
6 | use sea_orm::EntityTrait;
7 | use sea_orm::Set;
8 | use sea_orm_migration::MigratorTrait;
9 | use tokio::sync::Mutex;
10 |
11 | use crate::database::utils::connect_db;
12 | use crate::tools::join_paths;
13 | use crate::Result;
14 |
15 | pub(crate) mod property;
16 |
17 | pub(crate) mod migrations;
18 |
19 | static PROPERTY_DB: OnceCell> = OnceCell::new();
20 |
21 | pub(crate) async fn init_db() {
22 | let path = join_paths(vec![crate::FOLDER.lock().await.deref(), "property.db"]);
23 | let db = connect_db(&path).await;
24 | property::init(&db).await;
25 | migrations::Migrator::up(&db, None).await.unwrap();
26 | PROPERTY_DB.set(Mutex::new(db)).expect("INIT ACTIVE DB DUP");
27 | }
28 |
29 | pub(crate) async fn save_property(k: String, v: String) -> Result {
30 | let db = PROPERTY_DB.get().unwrap().lock().await;
31 | let in_db = property::Entity::find_by_id(k.clone())
32 | .one(db.deref())
33 | .await?;
34 | match in_db {
35 | Some(in_db) => {
36 | let mut data: property::ActiveModel = in_db.into();
37 | data.k = Set(k.clone());
38 | data.v = Set(v.clone());
39 | data.update(db.deref()).await?;
40 | }
41 | None => {
42 | let insert = property::ActiveModel {
43 | k: Set(k.clone()),
44 | v: Set(v.clone()),
45 | ..Default::default()
46 | };
47 | insert.insert(db.deref()).await?;
48 | }
49 | };
50 | drop(db);
51 | Ok("".to_string())
52 | }
53 |
54 | pub(crate) async fn load_property(k: String) -> Result {
55 | let db = PROPERTY_DB.get().unwrap().lock().await;
56 | let in_db = property::Entity::find_by_id(k.clone())
57 | .one(db.deref())
58 | .await?;
59 | let v = match in_db {
60 | Some(in_db) => in_db.v,
61 | None => String::default(),
62 | };
63 | drop(db);
64 | Ok(v)
65 | }
66 |
67 | pub(crate) async fn load_int_property(k: String, default: i64) -> i64 {
68 | match load_property(k).await {
69 | Ok(p) => match p.parse::() {
70 | Ok(data) => data,
71 | Err(_) => default,
72 | },
73 | Err(_) => default,
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/native/jmbackend/src/database/property_db/property.rs:
--------------------------------------------------------------------------------
1 | use sea_orm::entity::prelude::*;
2 | use sea_orm::EntityTrait;
3 |
4 | use crate::database::utils::{create_index, create_table_if_not_exists, index_exists};
5 |
6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
7 | #[sea_orm(table_name = "property")]
8 | pub struct Model {
9 | #[sea_orm(primary_key, auto_increment = false)]
10 | pub k: String,
11 | pub v: String,
12 | }
13 |
14 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
15 | pub enum Relation {}
16 |
17 | impl ActiveModelBehavior for ActiveModel {}
18 |
19 | pub(crate) async fn init(db: &DatabaseConnection) {
20 | create_table_if_not_exists(&db, Entity).await;
21 | if !index_exists(db, "property", "idx_k").await {
22 | create_index(db, "property", vec!["k"], "idx_k").await;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/native/jmbackend/src/database/utils.rs:
--------------------------------------------------------------------------------
1 | use std::time::Duration;
2 |
3 | use sea_orm::ConnectionTrait;
4 | use sea_orm::DatabaseConnection;
5 | use sea_orm::EntityTrait;
6 | use sea_orm::Schema;
7 | use sea_orm::Statement;
8 |
9 | pub(crate) async fn connect_db(path: &str) -> DatabaseConnection {
10 | let url = format!("sqlite:{}?mode=rwc", path);
11 | let mut opt = sea_orm::ConnectOptions::new(url);
12 | opt.max_connections(20)
13 | .min_connections(5)
14 | .connect_timeout(Duration::from_secs(8))
15 | .idle_timeout(Duration::from_secs(8))
16 | .sqlx_logging(true);
17 | sea_orm::Database::connect(opt).await.unwrap()
18 | }
19 |
20 | pub(crate) async fn create_table_if_not_exists(db: &DatabaseConnection, entity: E)
21 | where
22 | E: EntityTrait,
23 | {
24 | if !has_table(db, entity.table_name()).await {
25 | create_table(db, entity).await;
26 | };
27 | }
28 |
29 | pub(crate) async fn has_table(db: &DatabaseConnection, table_name: &str) -> bool {
30 | let stmt = Statement::from_string(
31 | db.get_database_backend(),
32 | format!(
33 | "SELECT COUNT(*) AS c FROM sqlite_master WHERE type='table' AND name='{}';",
34 | table_name,
35 | ),
36 | );
37 | let rsp = db.query_one(stmt).await.unwrap().unwrap();
38 | let count: i32 = rsp.try_get("", "c").unwrap();
39 | count > 0
40 | }
41 |
42 | pub(crate) async fn create_table(db: &DatabaseConnection, entity: E)
43 | where
44 | E: EntityTrait,
45 | {
46 | let builder = db.get_database_backend();
47 | let schema = Schema::new(builder);
48 | let stmt = &schema.create_table_from_entity(entity);
49 | let stmt = builder.build(stmt);
50 | db.execute(stmt).await.unwrap();
51 | }
52 |
53 | pub(crate) async fn index_exists(
54 | db: &DatabaseConnection,
55 | table_name: &str,
56 | index_name: &str,
57 | ) -> bool {
58 | let stmt = Statement::from_string(
59 | db.get_database_backend(),
60 | format!(
61 | "select COUNT(*) AS c from sqlite_master where type='index' AND tbl_name='{}' AND name='{}';",
62 | table_name, index_name,
63 | ),
64 | );
65 | db.query_one(stmt)
66 | .await
67 | .unwrap()
68 | .unwrap()
69 | .try_get::("", "c")
70 | .unwrap()
71 | > 0
72 | }
73 |
74 | pub(crate) async fn create_index_a(
75 | db: &DatabaseConnection,
76 | table_name: &str,
77 | columns: Vec<&str>,
78 | index_name: &str,
79 | uk: bool,
80 | ) {
81 | let stmt = Statement::from_string(
82 | db.get_database_backend(),
83 | format!(
84 | "CREATE {} INDEX {} ON {}({});",
85 | if uk { "UNIQUE" } else { "" },
86 | index_name,
87 | table_name,
88 | columns.join(","),
89 | ),
90 | );
91 | db.execute(stmt).await.unwrap();
92 | }
93 |
94 | pub(crate) async fn create_index(
95 | db: &DatabaseConnection,
96 | table_name: &str,
97 | columns: Vec<&str>,
98 | index_name: &str,
99 | ) {
100 | create_index_a(db, table_name, columns, index_name, false).await
101 | }
102 |
--------------------------------------------------------------------------------
/native/jmbackend/src/database/web_cache_db/web_cache.rs:
--------------------------------------------------------------------------------
1 | use sea_orm::entity::prelude::*;
2 | use sea_orm::EntityTrait;
3 |
4 | use crate::database::utils::{create_index, create_table_if_not_exists, index_exists};
5 |
6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
7 | #[sea_orm(table_name = "web_cache")]
8 | pub struct Model {
9 | #[sea_orm(primary_key, auto_increment = false)]
10 | pub cache_key: String,
11 | pub cache_content: String,
12 | pub cache_time: i64,
13 | }
14 |
15 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
16 | pub enum Relation {}
17 |
18 | impl ActiveModelBehavior for ActiveModel {}
19 |
20 | pub(crate) async fn init(db: &DatabaseConnection) {
21 | create_table_if_not_exists(db, Entity).await;
22 | if !index_exists(db, "web_cache", "idx_cache_time").await {
23 | create_index(db, "web_cache", vec!["cache_time"], "idx_cache_time").await;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/native/jmbackend/src/define.rs:
--------------------------------------------------------------------------------
1 | use jmcomic::Client;
2 | use std::collections::hash_map::DefaultHasher;
3 | use std::hash::Hasher;
4 | use std::time::Duration;
5 |
6 | use lazy_static::lazy_static;
7 | use tokio::runtime::Runtime;
8 | use tokio::sync::Mutex;
9 | use tokio::sync::MutexGuard;
10 |
11 | use crate::types::*;
12 |
13 | pub const HASH_LOCK_COUNT: u64 = 64;
14 |
15 | lazy_static! {
16 |
17 | pub static ref UA:&'static str = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36";
18 |
19 | pub static ref RUNTIME: Runtime = tokio::runtime::Builder::new_multi_thread()
20 | .enable_all()
21 | .thread_keep_alive(Duration::new(60, 0))
22 | .worker_threads(30)
23 | .max_blocking_threads(30)
24 | .build()
25 | .unwrap();
26 |
27 | pub(crate) static ref CONTEXT: Mutex =
28 | Mutex::::new(BackendContext {
29 | login: false,
30 | last_login: 0,
31 | });
32 |
33 | pub(crate) static ref FIRST_LOGIN: Mutex = Mutex::new(false);
34 |
35 | pub(crate) static ref CLIENT :Client = Client::new();
36 | }
37 |
38 | lazy_static! {
39 | pub(crate) static ref INITED: Mutex = Mutex::::new(false);
40 | pub(crate) static ref FOLDER: Mutex = Mutex::::new(String::new());
41 | }
42 |
43 | lazy_static::lazy_static! {
44 | static ref HASH_LOCK: Vec> = {
45 | let mut mutex_vec = vec![];
46 | for _ in 0..HASH_LOCK_COUNT {
47 | mutex_vec.push(Mutex::<()>::new(()));
48 | }
49 | mutex_vec
50 | };
51 | }
52 |
53 | pub(crate) async fn take_hash_lock(url: String) -> MutexGuard<'static, ()> {
54 | let mut s = DefaultHasher::new();
55 | s.write(url.as_bytes());
56 | HASH_LOCK[(s.finish() % HASH_LOCK_COUNT) as usize]
57 | .lock()
58 | .await
59 | }
60 |
--------------------------------------------------------------------------------
/native/jmbackend/src/tests.rs:
--------------------------------------------------------------------------------
1 | #[test]
2 | fn it_works() {}
3 |
--------------------------------------------------------------------------------
/native/jmbackend/src/tools.rs:
--------------------------------------------------------------------------------
1 | use std::path::PathBuf;
2 |
3 | pub(crate) fn join_paths(paths: Vec<&str>) -> String {
4 | match paths.len() {
5 | 0 => String::default(),
6 | _ => {
7 | let mut path: PathBuf = PathBuf::new();
8 | for x in 0..paths.len() {
9 | path = path.join(paths[x]);
10 | }
11 | return path.to_str().unwrap().to_string();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/native/jmcomic-rs/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | Cargo.lock
3 |
4 | /.idea/
5 | *.iml
6 | /data.txt
7 |
--------------------------------------------------------------------------------
/native/jmcomic-rs/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "jmcomic"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7 |
8 | [dependencies]
9 | anyhow = "1.0.75"
10 | base64 = "0.13.0"
11 | block-modes = "0.8.1"
12 | aes = "0.7.5"
13 | hex = "0.4.3"
14 | lazy_static = "1.4.0"
15 | md5 = "0.7.0"
16 | rand = "0.8.5"
17 | reqwest = { version = "0.11.22", features = ["tokio-rustls", "rustls", "rustls-tls"], default-features = false }
18 | serde = { version = "1.0.190", features = ["derive"] }
19 | serde_derive = "1.0.190"
20 | serde_json = "1.0.108"
21 | serde_path_to_error = "0.1.14"
22 | tokio = { version = "1.33.0", features = ["macros"] }
23 |
--------------------------------------------------------------------------------
/native/jmcomic-rs/src/tests.rs:
--------------------------------------------------------------------------------
1 | use serde_json::json;
2 |
3 | use crate::{Client, FavoritesOrder, SortBy};
4 | use crate::{Method, Result};
5 |
6 | /// 打印结果
7 | fn print(result: Result) {
8 | match result {
9 | Ok(data) => println!("{}", serde_json::to_string(&data).unwrap()),
10 | Err(err) => panic!("{}", err),
11 | }
12 | }
13 |
14 | async fn client() -> Client {
15 | let client = Client::new();
16 | client.set_user_agent(Client::rand_user_agent()).await;
17 | client
18 | }
19 |
20 | #[tokio::test]
21 | async fn request_data() {
22 | let rsp = client().await
23 | .request_data(Method::GET, "setting", json!({}))
24 | .await;
25 | match rsp {
26 | Ok(text) => println!("{}", text),
27 | Err(err) => panic!("{}", err),
28 | }
29 | }
30 |
31 | async fn login_client() -> Client {
32 | let client = client().await;
33 | client
34 | .login("username".to_owned(), "password".to_owned())
35 | .await
36 | .unwrap();
37 | client
38 | }
39 |
40 | #[tokio::test]
41 | async fn login_request_data() {
42 | match login_client()
43 | .await
44 | .request_data(Method::GET, "favorite", json!({"page":1}))
45 | .await
46 | {
47 | Ok(text) => println!("{}", text),
48 | Err(err) => panic!("{}", err),
49 | }
50 | }
51 |
52 | #[tokio::test]
53 | async fn categories() {
54 | print(client().await.categories().await)
55 | }
56 |
57 | #[tokio::test]
58 | async fn latest() {
59 | print(client().await.latest().await)
60 | }
61 |
62 | #[tokio::test]
63 | async fn comics() {
64 | print(client().await.comics("".to_string(), SortBy::Default, 1).await)
65 | }
66 |
67 | #[tokio::test]
68 | async fn album() {
69 | print(client().await.album(215435).await)
70 | }
71 |
72 | #[tokio::test]
73 | async fn chapter() {
74 | print(client().await.chapter(215435).await)
75 | }
76 |
77 | #[tokio::test]
78 | async fn videos() {
79 | print(client().await.videos(SortBy::View, 2).await)
80 | }
81 |
82 | #[tokio::test]
83 | async fn forum() {
84 | print(client().await.forum(None, None, 100).await)
85 | }
86 |
87 | #[tokio::test]
88 | async fn set_favorite() {
89 | print(login_client().await.set_favorite(302608).await);
90 | }
91 |
92 | #[tokio::test]
93 | async fn favorites() {
94 | print(
95 | login_client()
96 | .await
97 | .favorites(0, 1, FavoritesOrder::Mp)
98 | .await,
99 | );
100 | }
101 |
102 | #[tokio::test]
103 | async fn favorites_intro() {
104 | print(login_client().await.favorites_intro().await);
105 | }
106 |
107 | #[tokio::test]
108 | async fn create_favorite_folder() {
109 | print(
110 | login_client()
111 | .await
112 | .create_favorite_folder("MY_FOLDER".to_string())
113 | .await,
114 | );
115 | }
116 |
117 | #[tokio::test]
118 | async fn games() {
119 | print(client().await.games(1).await);
120 | }
121 |
122 | #[tokio::test]
123 | async fn comics_search() {
124 | print(
125 | client().await
126 | .comics_search("ABC".to_owned(), SortBy::Default, 1)
127 | .await,
128 | );
129 | }
130 |
131 | #[tokio::test]
132 | async fn test() {}
133 |
--------------------------------------------------------------------------------
/native/jmcomic-rs/src/tools.rs:
--------------------------------------------------------------------------------
1 | use aes::Aes256;
2 | use block_modes::block_padding::Pkcs7;
3 | use block_modes::{BlockMode, Ecb};
4 |
5 | type AesEcb = Ecb;
6 |
7 | pub(crate) fn decrypt_jm(data: &str, key: &[u8]) -> anyhow::Result {
8 | let data = base64::decode(data)?;
9 | let data = aes_decrypt_ecb(data, key)?;
10 | let data = std::str::from_utf8(data.as_slice())?;
11 | Ok(data.to_string())
12 | }
13 |
14 | fn aes_decrypt_ecb(data: Vec, key: &[u8]) -> anyhow::Result> {
15 | Ok(AesEcb::new_from_slices(key, "".as_bytes())?.decrypt_vec(data.as_slice())?)
16 | }
17 |
18 | /// FROM STRING 并打印出错的位置
19 | pub fn from_str serde::Deserialize<'de>>(json: &str) -> anyhow::Result {
20 | Ok(serde_path_to_error::deserialize(
21 | &mut serde_json::Deserializer::from_str(json),
22 | )?)
23 | }
24 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: jenny
2 | description: jenny comic browser
3 |
4 | publish_to: 'none'
5 |
6 | version: 0.2.5+25
7 |
8 | environment:
9 | sdk: ">=2.15.1 <3.0.0"
10 |
11 | dependencies:
12 | flutter:
13 | sdk: flutter
14 | cupertino_icons: ^1.0.2
15 | flutter_svg: ^1.0.0
16 | permission_handler: ^10.1.0
17 | flutter_styled_toast: ^2.0.0
18 | photo_view: ^0.14.0
19 | event: ^2.1.2
20 | modal_bottom_sheet: ^3.0.0-pre
21 | another_xlider: ^1.0.1+2
22 | scrollable_positioned_list: ^0.2.3
23 | url_launcher: ^6.0.20
24 | clipboard: ^0.1.3
25 | file_picker: 5.2.1
26 | filesystem_picker: ^3.1.0
27 | window_manager: ^0.3.1
28 | flutter_screenutil: ^5.7.0
29 |
30 | dev_dependencies:
31 | flutter_test:
32 | sdk: flutter
33 | flutter_lints: ^1.0.0
34 |
35 | flutter:
36 | uses-material-design: true
37 | assets:
38 | - lib/assets/
39 |
--------------------------------------------------------------------------------
/scripts/sign-apk-github-actions.sh:
--------------------------------------------------------------------------------
1 | cd "$( cd "$( dirname "$0" )" && pwd )/.."
2 |
3 | echo $KEY_FILE_BASE64 > key.jks.base64
4 | base64 -d key.jks.base64 > key.jks
5 | echo $KEY_PASSWORD | $ANDROID_HOME/build-tools/30.0.2/apksigner sign --ks key.jks build/app/outputs/flutter-apk/app-release.apk
6 |
--------------------------------------------------------------------------------
/scripts/thin-payload.sh:
--------------------------------------------------------------------------------
1 | # 精简Payload文件夹 (上传到AppStore会自动区分平台, 此代码仅用于构建非签名ipa)
2 |
3 | foreachThin(){
4 | for file in $1/*
5 | do
6 | if test -f $file
7 | then
8 | mime=$(file --mime-type -b $file)
9 | if [ "$mime" == 'application/x-mach-binary' ] || [ "${file##*.}"x = "dylib"x ]
10 | then
11 | echo thin $file
12 | xcrun -sdk iphoneos lipo "$file" -thin arm64 -output "$file"
13 | xcrun -sdk iphoneos bitcode_strip "$file" -r -o "$file"
14 | strip -S -x "$file" -o "$file"
15 | fi
16 | fi
17 | if test -d $file
18 | then
19 | foreachThin $file
20 | fi
21 | done
22 | }
23 |
24 | foreachThin ./Payload
25 |
--------------------------------------------------------------------------------
/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility that Flutter provides. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | import 'package:flutter/material.dart';
9 | import 'package:flutter_test/flutter_test.dart';
10 |
11 | import 'package:jenny/main.dart';
12 |
13 | void main() {
14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async {
15 | // Build our app and trigger a frame.
16 | await tester.pumpWidget(const Jenny());
17 |
18 | // Verify that our counter starts at 0.
19 | expect(find.text('0'), findsOneWidget);
20 | expect(find.text('1'), findsNothing);
21 |
22 | // Tap the '+' icon and trigger a frame.
23 | await tester.tap(find.byIcon(Icons.add));
24 | await tester.pump();
25 |
26 | // Verify that our counter has incremented.
27 | expect(find.text('0'), findsNothing);
28 | expect(find.text('1'), findsOneWidget);
29 | });
30 | }
31 |
--------------------------------------------------------------------------------
/windows/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral/
2 |
3 | # Visual Studio user-specific files.
4 | *.suo
5 | *.user
6 | *.userosscache
7 | *.sln.docstates
8 |
9 | # Visual Studio build-related files.
10 | x64/
11 | x86/
12 |
13 | # Visual Studio cache files
14 | # files ending in .cache can be ignored
15 | *.[Cc]ache
16 | # but keep track of directories ending in .cache
17 | !*.[Cc]ache/
18 |
--------------------------------------------------------------------------------
/windows/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | void RegisterPlugins(flutter::PluginRegistry* registry) {
15 | PermissionHandlerWindowsPluginRegisterWithRegistrar(
16 | registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
17 | ScreenRetrieverPluginRegisterWithRegistrar(
18 | registry->GetRegistrarForPlugin("ScreenRetrieverPlugin"));
19 | UrlLauncherWindowsRegisterWithRegistrar(
20 | registry->GetRegistrarForPlugin("UrlLauncherWindows"));
21 | WindowManagerPluginRegisterWithRegistrar(
22 | registry->GetRegistrarForPlugin("WindowManagerPlugin"));
23 | }
24 |
--------------------------------------------------------------------------------
/windows/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void RegisterPlugins(flutter::PluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/windows/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | permission_handler_windows
7 | screen_retriever
8 | url_launcher_windows
9 | window_manager
10 | )
11 |
12 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
13 | )
14 |
15 | set(PLUGIN_BUNDLED_LIBRARIES)
16 |
17 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
18 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
19 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
20 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
21 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
22 | endforeach(plugin)
23 |
24 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
25 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
26 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
27 | endforeach(ffi_plugin)
28 |
--------------------------------------------------------------------------------
/windows/runner/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.14)
2 | project(runner LANGUAGES CXX)
3 |
4 | link_directories("../")
5 |
6 | add_executable(${BINARY_NAME} WIN32
7 | "flutter_window.cpp"
8 | "main.cpp"
9 | "utils.cpp"
10 | "win32_window.cpp"
11 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
12 | "Runner.rc"
13 | "runner.exe.manifest"
14 | "methods_plugin.cpp"
15 | )
16 | apply_standard_settings(${BINARY_NAME})
17 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
18 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app flutter_wrapper_plugin rust
19 | ntdll.lib advapi32.lib bcrypt.lib cfgmgr32.lib credui.lib crypt32.lib cryptnet.lib fwpuclnt.lib kernel32.lib mswsock.lib ncrypt.lib ntdll.lib secur32.lib synchronization.lib user32.lib ws2_32.lib kernel32.lib ws2_32.lib bcrypt.lib advapi32.lib userenv.lib kernel32.lib msvcrt.lib)
20 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
21 | add_dependencies(${BINARY_NAME} flutter_assemble)
22 |
--------------------------------------------------------------------------------
/windows/runner/flutter_window.cpp:
--------------------------------------------------------------------------------
1 | #include "flutter_window.h"
2 |
3 | #include
4 |
5 | #include "flutter/generated_plugin_registrant.h"
6 | #include "methods_plugin.h"
7 |
8 | FlutterWindow::FlutterWindow(const flutter::DartProject& project)
9 | : project_(project) {}
10 |
11 | FlutterWindow::~FlutterWindow() {}
12 |
13 | bool FlutterWindow::OnCreate() {
14 | if (!Win32Window::OnCreate()) {
15 | return false;
16 | }
17 |
18 | RECT frame = GetClientArea();
19 |
20 | // The size here must match the window dimensions to avoid unnecessary surface
21 | // creation / destruction in the startup path.
22 | flutter_controller_ = std::make_unique(
23 | frame.right - frame.left, frame.bottom - frame.top, project_);
24 | // Ensure that basic setup of the controller was successful.
25 | if (!flutter_controller_->engine() || !flutter_controller_->view()) {
26 | return false;
27 | }
28 | RegisterPlugins(flutter_controller_->engine());
29 | MethodsPluginRegisterWithRegistrar(flutter_controller_->engine()->GetRegistrarForPlugin("methods"));
30 | SetChildContent(flutter_controller_->view()->GetNativeWindow());
31 | return true;
32 | }
33 |
34 | void FlutterWindow::OnDestroy() {
35 | if (flutter_controller_) {
36 | flutter_controller_ = nullptr;
37 | }
38 |
39 | Win32Window::OnDestroy();
40 | }
41 |
42 | LRESULT
43 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
44 | WPARAM const wparam,
45 | LPARAM const lparam) noexcept {
46 | // Give Flutter, including plugins, an opportunity to handle window messages.
47 | if (flutter_controller_) {
48 | std::optional result =
49 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
50 | lparam);
51 | if (result) {
52 | return *result;
53 | }
54 | }
55 |
56 | switch (message) {
57 | case WM_FONTCHANGE:
58 | flutter_controller_->engine()->ReloadSystemFonts();
59 | break;
60 | }
61 |
62 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
63 | }
64 |
--------------------------------------------------------------------------------
/windows/runner/flutter_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_FLUTTER_WINDOW_H_
2 | #define RUNNER_FLUTTER_WINDOW_H_
3 |
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | #include "win32_window.h"
10 |
11 | // A window that does nothing but host a Flutter view.
12 | class FlutterWindow : public Win32Window {
13 | public:
14 | // Creates a new FlutterWindow hosting a Flutter view running |project|.
15 | explicit FlutterWindow(const flutter::DartProject& project);
16 | virtual ~FlutterWindow();
17 |
18 | protected:
19 | // Win32Window:
20 | bool OnCreate() override;
21 | void OnDestroy() override;
22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
23 | LPARAM const lparam) noexcept override;
24 |
25 | private:
26 | // The project to run.
27 | flutter::DartProject project_;
28 |
29 | // The Flutter instance hosted by this window.
30 | std::unique_ptr flutter_controller_;
31 | };
32 |
33 | #endif // RUNNER_FLUTTER_WINDOW_H_
34 |
--------------------------------------------------------------------------------
/windows/runner/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "flutter_window.h"
6 | #include "utils.h"
7 | #include "../rust.h"
8 |
9 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
10 | _In_ wchar_t *command_line, _In_ int show_command) {
11 |
12 | wchar_t awBuffer[2048];
13 | GetCurrentDirectory(2048, awBuffer) ;
14 | if (awBuffer[wcslen(awBuffer) - 1] != L'\\') {
15 | wcscat_s(awBuffer, 2048, L"\\");
16 | }
17 | wcscat_s(awBuffer, 2048, L"data/application");
18 | char buffer[4096];
19 | size_t i;
20 | wcstombs_s(&i,buffer, 4096, awBuffer, 2048);
21 | init_ffi(buffer);
22 |
23 | // Attach to console when present (e.g., 'flutter run') or create a
24 | // new console when running with a debugger.
25 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
26 | CreateAndAttachConsole();
27 | }
28 |
29 | // Initialize COM, so that it is available for use in the library and/or
30 | // plugins.
31 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
32 |
33 | flutter::DartProject project(L"data");
34 |
35 | std::vector command_line_arguments =
36 | GetCommandLineArguments();
37 |
38 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
39 |
40 | int width = load_int_property("window_width", 600);
41 | int height = load_int_property("window_height", 800);
42 | FlutterWindow window(project);
43 | Win32Window::Point origin(10, 10);
44 | Win32Window::Size size(std::max(width, 50), std::max(height, 50));
45 | if (!window.CreateAndShow(L"jenny", origin, size)) {
46 | return EXIT_FAILURE;
47 | }
48 | window.SetQuitOnClose(true);
49 |
50 | ::MSG msg;
51 | while (::GetMessage(&msg, nullptr, 0, 0)) {
52 | ::TranslateMessage(&msg);
53 | ::DispatchMessage(&msg);
54 | }
55 |
56 | ::CoUninitialize();
57 | return EXIT_SUCCESS;
58 | }
59 |
--------------------------------------------------------------------------------
/windows/runner/methods_plugin.cpp:
--------------------------------------------------------------------------------
1 | #include "methods_plugin.h"
2 | #include
3 | #include
4 | #include
5 | #include "../rust.h"
6 |
7 |
8 | void InvokeThread(std::string params, std::unique_ptr> result) {
9 | char* result_chars = invoke_ffi(params.c_str());
10 | result->Success(flutter::EncodableValue(std::string(result_chars)));
11 | free_str_ffi(result_chars);
12 | }
13 |
14 | namespace {
15 |
16 | class MethodsPlugin : public flutter::Plugin {
17 | public:
18 | static void RegisterWithRegistrar(flutter::PluginRegistrarWindows *registrar);
19 |
20 | MethodsPlugin();
21 |
22 | virtual ~MethodsPlugin();
23 |
24 | private:
25 | // Called when a method is called on this plugin's channel from Dart.
26 | void HandleMethodCall(
27 | const flutter::MethodCall &method_call,
28 | std::unique_ptr> result);
29 | };
30 |
31 | // static
32 | void MethodsPlugin::RegisterWithRegistrar(
33 | flutter::PluginRegistrarWindows *registrar) {
34 | auto channel =
35 | std::make_unique>(
36 | registrar->messenger(), "methods",
37 | &flutter::StandardMethodCodec::GetInstance());
38 |
39 | auto plugin = std::make_unique();
40 |
41 | channel->SetMethodCallHandler(
42 | [plugin_pointer = plugin.get()](const auto &call, auto result) {
43 | plugin_pointer->HandleMethodCall(call, std::move(result));
44 | });
45 |
46 | registrar->AddPlugin(std::move(plugin));
47 | }
48 |
49 | MethodsPlugin::MethodsPlugin() {}
50 |
51 | MethodsPlugin::~MethodsPlugin() {}
52 |
53 | void MethodsPlugin::HandleMethodCall(
54 | const flutter::MethodCall &method_call,
55 | std::unique_ptr> result) {
56 |
57 | if (method_call.method_name().compare("invoke") == 0) {
58 | const auto *arguments = std::get_if(method_call.arguments());
59 | std::thread t(InvokeThread, std::string(*arguments),std::move(result));
60 | t.detach();
61 | return;
62 | } else {
63 | result->NotImplemented();
64 | }
65 |
66 | }
67 |
68 | } // namespace
69 |
70 |
71 | void MethodsPluginRegisterWithRegistrar(
72 | FlutterDesktopPluginRegistrarRef registrar) {
73 | MethodsPlugin::RegisterWithRegistrar(
74 | flutter::PluginRegistrarManager::GetInstance()
75 | ->GetRegistrar(registrar));
76 | }
77 |
--------------------------------------------------------------------------------
/windows/runner/methods_plugin.h:
--------------------------------------------------------------------------------
1 | #ifndef JENNY_METHODS_PLUGIN_H
2 | #define JENNY_METHODS_PLUGIN_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include