Compare commits
116 Commits
v1.0.2
...
558832d188
Author | SHA1 | Date | |
---|---|---|---|
558832d188 | |||
2be88895ed | |||
1a110e711d | |||
1ad8329797 | |||
1cf4da66ad | |||
5dad6910fc | |||
72eb4a51ea | |||
3d49bebc44 | |||
e86f8b7f51 | |||
![]() |
20130ef89e | ||
![]() |
b76fbf040b | ||
018fb11ca5 | |||
cbc69b4707 | |||
1e53e374e4 | |||
0756ebe4e5 | |||
47ebe9deec | |||
37f84efe05 | |||
6530f2c57d | |||
a3e758831b | |||
3e5ae0a39a | |||
974f739900 | |||
deb866da63 | |||
eea77b297a | |||
264c2b0e20 | |||
513e716608 | |||
8364b56178 | |||
0d0122be3a | |||
4f1fd8530a | |||
82b8eac989 | |||
95815131fe | |||
f8439a3cb2 | |||
f7a6eb1ac9 | |||
a10e8c05d5 | |||
bd15053c2f | |||
![]() |
86c6f13282 | ||
![]() |
b69d2a0950 | ||
![]() |
c897891b2a | ||
![]() |
3c73439588 | ||
![]() |
2d16502154 | ||
![]() |
294498d8a7 | ||
![]() |
20dfbf5125 | ||
![]() |
63aa4ee8b0 | ||
![]() |
c8d4b3db88 | ||
![]() |
b1e7adb1c5 | ||
![]() |
0143a67fa0 | ||
![]() |
eee1141970 | ||
![]() |
50a69f77b6 | ||
![]() |
790ed54d5b | ||
![]() |
21fe14f88b | ||
![]() |
a03ad12837 | ||
![]() |
426257716f | ||
![]() |
67e01ea69f | ||
![]() |
6cf9ce9c96 | ||
![]() |
593899af8c | ||
![]() |
908c26d764 | ||
![]() |
eef1af3ad1 | ||
![]() |
b97c7cde25 | ||
![]() |
6118fc30f8 | ||
![]() |
4476ad7f90 | ||
![]() |
7c8fabf52c | ||
![]() |
70da478044 | ||
![]() |
b14c2682a7 | ||
![]() |
54b64fb19b | ||
![]() |
d247455c19 | ||
![]() |
759d6959b5 | ||
![]() |
488be5fb1a | ||
![]() |
62b50c466e | ||
![]() |
49da2b772b | ||
![]() |
4dc1ec8784 | ||
![]() |
1fad3694cf | ||
![]() |
39eb5c836e | ||
![]() |
9603706fc6 | ||
![]() |
343e993627 | ||
![]() |
246f96bdbf | ||
![]() |
61c6ed0e1b | ||
![]() |
fd63b02b60 | ||
![]() |
9275024050 | ||
![]() |
5e53c57755 | ||
![]() |
6a95fb37ed | ||
![]() |
20829e1ad5 | ||
![]() |
cb356dbf71 | ||
![]() |
9ad6207bd5 | ||
![]() |
676e7508c7 | ||
![]() |
1652a93772 | ||
![]() |
e6d015a2bc | ||
![]() |
35dd9dee5f | ||
![]() |
b34a8342d2 | ||
![]() |
0ed17edd3e | ||
![]() |
187e5f9a09 | ||
![]() |
9505b78ae4 | ||
![]() |
1d49f1c387 | ||
![]() |
7641cc8f5c | ||
![]() |
de26cba0fa | ||
![]() |
471b319891 | ||
![]() |
1a224114fc | ||
![]() |
5ae73bd7c8 | ||
![]() |
013e509ebf | ||
![]() |
974e2f0cc6 | ||
![]() |
1d649ebde2 | ||
![]() |
dd1ed690e1 | ||
![]() |
f33df47cd6 | ||
![]() |
c51df1efde | ||
![]() |
93ce4eb94b | ||
![]() |
a3868b1969 | ||
![]() |
2a1a668c25 | ||
![]() |
b0d740a174 | ||
![]() |
811b7b4ed8 | ||
![]() |
1fecb8d55d | ||
![]() |
67ebe4e50b | ||
![]() |
a9bddd7def | ||
![]() |
4b8acfc3ff | ||
![]() |
38f57584b6 | ||
![]() |
8ff269c8a8 | ||
![]() |
dde518ab6b | ||
![]() |
bfad0dc176 | ||
![]() |
ed9213b12e |
6
.github/generate_ipa.sh
vendored
@@ -1,6 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir -p build/ios/iphoneos/Payload
|
||||
mv build/ios/iphoneos/Runner.app build/ios/iphoneos/Payload
|
||||
cd build/ios/iphoneos/
|
||||
zip -r app-ios.ipa Payload
|
20
.github/workflows/ios_simulator.yml
vendored
@@ -1,20 +0,0 @@
|
||||
name: Build IOS SIMULATOR
|
||||
run-name: Build IOS SIMULATOR
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
jobs:
|
||||
Build_IOS_SIMULATOR:
|
||||
runs-on: macos-13
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable'
|
||||
architecture: x64
|
||||
- run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app
|
||||
- run: flutter pub get
|
||||
- run: flutter build ios --simulator --no-codesign
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: build_files
|
||||
path: build/ios/iphonesimulator
|
218
.github/workflows/main.yml
vendored
@@ -1,40 +1,188 @@
|
||||
name: Build IOS
|
||||
run-name: Build IOS
|
||||
name: Build ALL
|
||||
run-name: Build ALL
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
Build_IOS:
|
||||
runs-on: macos-13
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable'
|
||||
architecture: x64
|
||||
- run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app
|
||||
- run: flutter pub get
|
||||
- run: flutter build ios --release --no-codesign
|
||||
- run: bash .github/generate_ipa.sh
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: app-ios.ipa
|
||||
path: build/ios/iphoneos/app-ios.ipa
|
||||
Build_MacOS:
|
||||
runs-on: macos-13
|
||||
runs-on: macos-15
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable'
|
||||
architecture: x64
|
||||
- run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app
|
||||
- run: flutter pub get
|
||||
- run: flutter build macos --release
|
||||
- run: |
|
||||
cd build/macos/Build/Products/Release
|
||||
zip -r macos-build.zip pixes.app
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: macos-build.zip
|
||||
path: build/macos/Build/Products/Release/macos-build.zip
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable'
|
||||
architecture: x64
|
||||
flutter-version-file: pubspec.yaml
|
||||
- run: sudo xcode-select --switch /Applications/Xcode_16.0.app
|
||||
- run: flutter pub get
|
||||
- run: flutter build macos --release
|
||||
- run: |
|
||||
cd build/macos/Build/Products/Release
|
||||
chmod +x pixes.app/Contents/MacOS/pixes
|
||||
zip -r macos.zip pixes.app
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: macos.zip
|
||||
path: build/macos/Build/Products/Release/macos.zip
|
||||
Build_IOS:
|
||||
runs-on: macos-15
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: "stable"
|
||||
flutter-version-file: pubspec.yaml
|
||||
architecture: x64
|
||||
- run: sudo xcode-select --switch /Applications/Xcode_16.0.app
|
||||
- run: flutter pub get
|
||||
- run: flutter build ios --release --no-codesign
|
||||
- run: |
|
||||
mkdir -p /Users/runner/work/pixes/pixes/build/ios/iphoneos/Payload
|
||||
mv /Users/runner/work/pixes/pixes/build/ios/iphoneos/Runner.app /Users/runner/work/pixes/pixes/build/ios/iphoneos/Payload
|
||||
cd /Users/runner/work/pixes/pixes/build/ios/iphoneos/
|
||||
zip -r pixes-ios.ipa Payload
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: app-ios.ipa
|
||||
path: /Users/runner/work/pixes/pixes/build/ios/iphoneos/pixes-ios.ipa
|
||||
Build_Android:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: "stable"
|
||||
flutter-version-file: pubspec.yaml
|
||||
architecture: x64
|
||||
- name: Decode and install certificate
|
||||
env:
|
||||
STORE_FILE: ${{ secrets.ANDROID_KEYSTORE }}
|
||||
PROPERTY_FILE: ${{ secrets.ANDROID_KEY_PROPERTIES }}
|
||||
run: |
|
||||
echo "$STORE_FILE" | base64 --decode > android/keystore.jks
|
||||
echo "$PROPERTY_FILE" > android/key.properties
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'oracle'
|
||||
java-version: '17'
|
||||
- run: flutter pub get
|
||||
- run: flutter build apk --release
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: apks
|
||||
path: build/app/outputs/apk/release
|
||||
Build_Windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: install dependencies
|
||||
run: |
|
||||
choco install yq -y
|
||||
pip install httpx
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: "stable"
|
||||
flutter-version-file: pubspec.yaml
|
||||
architecture: x64
|
||||
- name: build
|
||||
run: |
|
||||
flutter pub get
|
||||
python windows/build.py
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows_build
|
||||
path: build/windows/pixes-*
|
||||
Build_Linux:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable'
|
||||
flutter-version-file: pubspec.yaml
|
||||
architecture: x64
|
||||
- run: |
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y ninja-build libgtk-3-dev webkit2gtk-4.1
|
||||
dart pub global activate flutter_to_debian
|
||||
- run: python3 debian/build.py x64
|
||||
- run: dart run flutter_to_arch
|
||||
- run: |
|
||||
sudo rm -rf build/linux/arch/app.tar.gz
|
||||
sudo rm -rf build/linux/arch/pkg
|
||||
sudo rm -rf build/linux/arch/src
|
||||
sudo rm -rf build/linux/arch/PKGBUILD
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: deb_build
|
||||
path: build/linux/x64/release/debian
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: arch_build
|
||||
path: build/linux/arch/
|
||||
Build_Linux_ARM64:
|
||||
runs-on: ubuntu-22.04-arm
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'master'
|
||||
flutter-version-file: pubspec.yaml
|
||||
- run: |
|
||||
flutter pub get
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y ninja-build libgtk-3-dev webkit2gtk-4.1
|
||||
dart pub global activate flutter_to_debian
|
||||
- run: python3 debian/build.py arm64
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: deb_arm64_build
|
||||
path: build/linux/x64/release/debian # This is a bug related to flutter_to_debian, but it's not a big deal.
|
||||
Release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [Build_MacOS, Build_IOS, Build_Android, Build_Windows, Build_Linux, Build_Linux_ARM64]
|
||||
if: github.event_name == 'release' # 仅在 push 事件时执行
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: macos.zip
|
||||
path: outputs
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: app-ios.ipa
|
||||
path: outputs
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: apks
|
||||
path: outputs
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: windows_build
|
||||
path: outputs
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: deb_build
|
||||
path: outputs
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: arch_build
|
||||
path: outputs
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: deb_arm64_build
|
||||
path: outputs
|
||||
- uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ github.ref_name }}
|
||||
files: |
|
||||
outputs/*.ipa
|
||||
outputs/*.dmg
|
||||
outputs/*.apk
|
||||
outputs/*.zip
|
||||
outputs/*.exe
|
||||
outputs/*.deb
|
||||
outputs/*.zst
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ACTION_GITHUB_TOKEN }}
|
||||
|
15
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"appdata",
|
||||
"Bungo",
|
||||
"gjzr",
|
||||
"microtask",
|
||||
"mypixiv",
|
||||
"pawoo",
|
||||
"Rorigod",
|
||||
"sleepinglife",
|
||||
"Ugoira",
|
||||
"vocaloidhm",
|
||||
"vsync"
|
||||
]
|
||||
}
|
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 nyne
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
43
README.md
@@ -1,5 +1,44 @@
|
||||
# pixes
|
||||
|
||||
Unofficial pixiv app
|
||||
[](https://flutter.dev/)
|
||||
[](https://github.com/wgh136/pixes/blob/master/LICENSE)
|
||||
[](https://github.com/wgh136/pixes)
|
||||
[](https://github.com/wgh136/pixes/stargazers)
|
||||
|
||||
This project is under development.
|
||||
Unofficial Pixiv app, support Windows, Android, iOS, macOS, linux
|
||||
|
||||
All main features are implemented.
|
||||
|
||||
## Download
|
||||
|
||||
Download from [Release](https://github.com/wgh136/pixes/releases)
|
||||
|
||||
## Build from source
|
||||
|
||||
### Install Flutter
|
||||
|
||||
View [Flutter Document](https://flutter.dev/docs/get-started/install)
|
||||
|
||||
### Build Android
|
||||
|
||||
Put your keystore file (`key.jks`, `key.properties`) in `android/`
|
||||
|
||||
Run `flutter build apk`
|
||||
|
||||
### Build iOS/Windows/macOS
|
||||
|
||||
Run `flutter build ios/windows/macos`
|
||||
|
||||
### Build Linux
|
||||
|
||||
Use`python3 debian/build.py {ARCH}` to build deb package. Replace {ARCH} with `x64` or `arm64`.
|
||||
|
||||
For other linux distributions, you can use `flutter build linux` to build.
|
||||
You must register the `pixiv` scheme in the `.desktop` file, otherwise the login will not work.
|
||||
|
||||
## Screenshots
|
||||
|
||||
<img src="screenshots/1.png" style="width: 400px">
|
||||
<img src="screenshots/2.png" style="width: 400px">
|
||||
<img src="screenshots/3.png" style="width: 400px">
|
||||
<img src="screenshots/4.png" style="width: 400px">
|
||||
|
@@ -4,6 +4,8 @@ plugins {
|
||||
id "dev.flutter.flutter-gradle-plugin"
|
||||
}
|
||||
|
||||
ext.abiCodes = ["armeabi-v7a": 1, "arm64-v8a": 2, "x86_64": 3]
|
||||
|
||||
def localProperties = new Properties()
|
||||
def localPropertiesFile = rootProject.file('local.properties')
|
||||
if (localPropertiesFile.exists()) {
|
||||
@@ -33,26 +35,29 @@ android {
|
||||
compileSdk flutter.compileSdkVersion
|
||||
ndkVersion flutter.ndkVersion
|
||||
|
||||
splits{
|
||||
abi {
|
||||
reset()
|
||||
include 'armeabi-v7a', 'arm64-v8a', 'x86_64'
|
||||
enable true
|
||||
universalApk true
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
kotlinOptions{
|
||||
jvmTarget = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId "com.github.wgh136.pixes"
|
||||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||||
minSdkVersion flutter.minSdkVersion
|
||||
targetSdkVersion 34
|
||||
targetSdk = flutter.targetSdkVersion
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
}
|
||||
@@ -74,9 +79,25 @@ android {
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig signingConfigs.debug
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a", "arm64-v8a", "x86_64"
|
||||
}
|
||||
signingConfig signingConfigs.release
|
||||
applicationVariants.all { variant ->
|
||||
variant.outputs.all { output ->
|
||||
def abi = output.getFilter(com.android.build.OutputFile.ABI)
|
||||
if (abi != null) {
|
||||
outputFileName = "pixes-${variant.versionName}-${abi}.apk"
|
||||
def abiVersionCode = project.ext.abiCodes.get(abi)
|
||||
if (abiVersionCode != null) {
|
||||
versionCodeOverride = variant.versionCode * 10 + abiVersionCode
|
||||
}
|
||||
} else {
|
||||
outputFileName = "pixes-${variant.versionName}.apk"
|
||||
versionCodeOverride = variant.versionCode * 10
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
<application
|
||||
android:label="pixes"
|
||||
android:name="${applicationName}"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
@@ -33,12 +34,22 @@
|
||||
<!-- Accepts URIs that begin with "example://gizmos” -->
|
||||
<data android:scheme="pixiv"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="https" android:host="www.pixiv.net" android:pathPrefix="/users"/>
|
||||
<data android:scheme="https" android:host="www.pixiv.net" android:pathPrefix="/novel"/>
|
||||
<data android:scheme="https" android:host="www.pixiv.net" android:pathPrefix="/tags"/>
|
||||
<data android:scheme="https" android:host="www.pixiv.net" android:pathPrefix="/artworks"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- Don't delete the meta-data below.
|
||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
<meta-data android:name="io.flutter.embedding.android.EnableImpeller" android:value="false"/>
|
||||
</application>
|
||||
<!-- Required to query activities that can process text, see:
|
||||
https://developer.android.com/training/package-visibility?hl=en and
|
||||
|
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
|
@@ -19,8 +19,8 @@ pluginManagement {
|
||||
|
||||
plugins {
|
||||
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
|
||||
id "com.android.application" version "7.3.0" apply false
|
||||
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
|
||||
id "com.android.application" version "8.9.0" apply false
|
||||
id "org.jetbrains.kotlin.android" version "2.1.0" apply false
|
||||
}
|
||||
|
||||
include ":app"
|
||||
|
142
assets/tr.json
@@ -3,7 +3,7 @@
|
||||
"Search": "搜索",
|
||||
"Downloading": "下载中",
|
||||
"Downloaded": "已下载",
|
||||
"Artwork": "作品",
|
||||
"Artwork": "插画",
|
||||
"Explore": "探索",
|
||||
"Bookmarks": "收藏",
|
||||
"Following": "关注",
|
||||
@@ -64,9 +64,9 @@
|
||||
"Weekly Manga": "每周漫画",
|
||||
"Monthly Manga": "每月漫画",
|
||||
"R18": "R18",
|
||||
"Account": "账户",
|
||||
"Account": "账号",
|
||||
"Logout": "登出",
|
||||
"Account Settings": "账户设置",
|
||||
"Account Settings": "账号设置",
|
||||
"Edit": "编辑",
|
||||
"Download": "下载",
|
||||
"Manage": "管理",
|
||||
@@ -112,7 +112,6 @@
|
||||
"Multiple path separators will be automatically replaced with a single": "多个路径分隔符将被自动替换为单个",
|
||||
"Login": "登录",
|
||||
"You need to complete the login operation in the browser window that will open.": "您需要在打开的浏览器窗口中完成登录操作",
|
||||
"I have read and agree to the Terms of Use": "我已阅读并同意使用条款",
|
||||
"Waiting..." : "等待中...",
|
||||
"Waiting for authentication. Please finished in the browser." : "等待验证. 请在浏览器中完成.",
|
||||
"Back" : "返回",
|
||||
@@ -121,7 +120,72 @@
|
||||
"Proxy": "代理",
|
||||
"Appearance": "外观",
|
||||
"Language": "语言",
|
||||
"Theme": "主题"
|
||||
"Theme": "主题",
|
||||
"Pause": "暂停",
|
||||
"Resume": "继续",
|
||||
"Paused": "已暂停",
|
||||
"Delete all": "删除全部",
|
||||
"Related": "相关",
|
||||
"Related artworks": "相关作品",
|
||||
"Related users": "相关用户",
|
||||
"Replace with '-p${index}' if the work have more than one images, otherwise replace with blank.": "替换为'-p${index}'如果作品有多张图片, 否则替换为空白",
|
||||
"Recommendation": "推荐",
|
||||
"Novel": "小说",
|
||||
"Novels": "小说",
|
||||
"Reading Settings": "阅读设置",
|
||||
"Font Size": "字体大小",
|
||||
"Line Height": "行高",
|
||||
"Paragraph Spacing": "段间距",
|
||||
"light": "浅色",
|
||||
"dark": "深色",
|
||||
"block": "屏蔽",
|
||||
"Block": "屏蔽",
|
||||
"Block(Account)": "屏蔽(账号)",
|
||||
"Block(Local)": "屏蔽(本地)",
|
||||
"Add": "添加",
|
||||
"Submit": "提交",
|
||||
"Local": "本地",
|
||||
"Both": "同时",
|
||||
"This artwork is blocked": "此作品已被屏蔽",
|
||||
"Delete Invalid Items": "删除无效项目",
|
||||
"Private Favorite": "私人收藏",
|
||||
"Shortcuts": "快捷键",
|
||||
"Page down": "向下翻页",
|
||||
"Page up": "向上翻页",
|
||||
"Next work": "下一作品",
|
||||
"Previous work": "上一作品",
|
||||
"Add to favorites": "添加收藏",
|
||||
"Follow the artist": "关注画师",
|
||||
"Manga": "漫画",
|
||||
"Actions": "操作",
|
||||
"Current quantity": "当前数量",
|
||||
"Display the original image on the details page": "在详情页显示原图",
|
||||
"Open link": "打开链接",
|
||||
"Read": "阅读",
|
||||
"Error": "错误",
|
||||
"Failed to register URL scheme.": "注册URL协议失败",
|
||||
"Retry": "重试",
|
||||
"Network": "网络",
|
||||
"Save to gallery": "保存到相册",
|
||||
"Choose a way to login": "选择登录方式",
|
||||
"Use Webview: you cannot sign in with Google.": "使用Webview: 无法使用Google登录",
|
||||
"Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application": "使用外部浏览器: 可以使用Google登录. 但是, 一些浏览器可能与应用程序不兼容",
|
||||
"External browser": "外部浏览器",
|
||||
"Show comments": "显示评论",
|
||||
"Show original image": "显示原图",
|
||||
"Illustrations": "插画",
|
||||
"New version available": "新版本可用",
|
||||
"A new version of Pixes is available. Do you want to update now?" : "Pixes有新版本可用. 您要立即更新吗?",
|
||||
"Update": "更新",
|
||||
"Check for updates": "检查更新",
|
||||
"Check for updates on startup": "启动时检查更新",
|
||||
"I understand pixes is a free unofficial application.": "我了解Pixes是一个免费的非官方应用程序",
|
||||
"Related Artworks": "相关作品",
|
||||
"Emphasize artworks from following artists": "强调关注画师的作品",
|
||||
"The border of the artworks will be darker": "作品的边框将被加深",
|
||||
"Initial Page": "初始页面",
|
||||
"Close the pane to apply the settings": "关闭面板以应用设置",
|
||||
"No results found": "未找到结果"
|
||||
},
|
||||
"zh_TW": {
|
||||
"Search": "搜索",
|
||||
@@ -236,7 +300,6 @@
|
||||
"Multiple path separators will be automatically replaced with a single": "多個路徑分隔符號將自動替換為單一",
|
||||
"Login": "登錄",
|
||||
"You need to complete the login operation in the browser window that will open.": "您需要在打開的瀏覽器窗口中完成登錄操作",
|
||||
"I have read and agree to the Terms of Use": "我已閱讀並同意使用條款",
|
||||
"Waiting..." : "等待中...",
|
||||
"Waiting for authentication. Please finished in the browser." : "等待驗證. 請在瀏覽器中完成.",
|
||||
"Back" : "返回",
|
||||
@@ -245,6 +308,71 @@
|
||||
"Proxy": "代理",
|
||||
"Appearance": "外觀",
|
||||
"Language": "語言",
|
||||
"Theme": "主題"
|
||||
"Theme": "主題",
|
||||
"Pause": "暫停",
|
||||
"Resume": "繼續",
|
||||
"Paused": "已暫停",
|
||||
"Delete all": "刪除全部",
|
||||
"Related": "相關",
|
||||
"Related artworks": "相關作品",
|
||||
"Related users": "相關用戶",
|
||||
"Replace with '-p${index}' if the work have more than one images, otherwise replace with blank.": "替換為'-p${index}'如果作品有多張圖片, 否則替換為空白",
|
||||
"Recommendation": "推薦",
|
||||
"Novel": "小說",
|
||||
"Novels": "小說",
|
||||
"Reading Settings": "閱讀設置",
|
||||
"Font Size": "字體大小",
|
||||
"Line Height": "行高",
|
||||
"Paragraph Spacing": "段間距",
|
||||
"light": "淺色",
|
||||
"dark": "深色",
|
||||
"block": "屏蔽",
|
||||
"Block": "屏蔽",
|
||||
"Block(Account)": "屏蔽(賬戶)",
|
||||
"Block(Local)": "屏蔽(本地)",
|
||||
"Add": "添加",
|
||||
"Submit": "提交",
|
||||
"Local": "本地",
|
||||
"Both": "同時",
|
||||
"This artwork is blocked": "此作品已被屏蔽",
|
||||
"Delete Invalid Items": "刪除無效項目",
|
||||
"Private Favorite": "私人收藏",
|
||||
"Shortcuts": "快捷鍵",
|
||||
"Page down": "向下翻頁",
|
||||
"Page up": "向上翻頁",
|
||||
"Next work": "下一作品",
|
||||
"Previous work": "上一作品",
|
||||
"Add to favorites": "添加收藏",
|
||||
"Follow the artist": "關注畫師",
|
||||
"Manga": "漫畫",
|
||||
"Actions": "操作",
|
||||
"Current quantity": "當前數量",
|
||||
"Display the original image on the details page": "在詳情頁顯示原圖",
|
||||
"Open link": "打開鏈接",
|
||||
"Read": "閱讀",
|
||||
"Error": "錯誤",
|
||||
"Failed to register URL scheme.": "註冊URL協議失敗",
|
||||
"Retry": "重試",
|
||||
"Network": "網絡",
|
||||
"Save to gallery": "保存到相冊",
|
||||
"Choose a way to login": "選擇登錄方式",
|
||||
"Use Webview: you cannot sign in with Google.": "使用Webview: 無法使用Google登錄",
|
||||
"Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application": "使用外部瀏覽器: 可以使用Google登錄. 但是, 一些瀏覽器可能與應用程序不兼容",
|
||||
"External browser": "外部瀏覽器",
|
||||
"Show comments": "顯示評論",
|
||||
"Show original image": "顯示原圖",
|
||||
"Illustrations": "插畫",
|
||||
"New version available": "新版本可用",
|
||||
"A new version of Pixes is available. Do you want to update now?" : "Pixes有新版本可用. 您要立即更新嗎?",
|
||||
"Update": "更新",
|
||||
"Check for updates": "檢查更新",
|
||||
"Check for updates on startup": "啟動時檢查更新",
|
||||
"I understand pixes is a free unofficial application.": "我了解Pixes是一個免費的非官方應用程序",
|
||||
"Related Artworks": "相關作品",
|
||||
"Emphasize artworks from following artists": "強調關注畫師的作品",
|
||||
"The border of the artworks will be darker": "作品的邊框將被加深",
|
||||
"Initial Page": "初始頁面",
|
||||
"Close the pane to apply the settings": "關閉面板以應用設置",
|
||||
"No results found": "未找到結果"
|
||||
}
|
||||
}
|
@@ -1,29 +0,0 @@
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
fontUse = '''
|
||||
fonts:
|
||||
- family: font
|
||||
fonts:
|
||||
- asset: assets/SourceHanSansSC-Regular.otf
|
||||
'''
|
||||
|
||||
file = open('pubspec.yaml', 'r')
|
||||
content = file.read()
|
||||
file.close()
|
||||
file = open('pubspec.yaml', 'a')
|
||||
file.write(fontUse)
|
||||
file.close()
|
||||
|
||||
subprocess.run(["flutter", "build", "windows"], shell=True)
|
||||
|
||||
file = open('pubspec.yaml', 'w')
|
||||
file.write(content)
|
||||
|
||||
if os.path.exists("build/app-windows.zip"):
|
||||
os.remove("build/app-windows.zip")
|
||||
|
||||
subprocess.run(["tar", "-a", "-c", "-f", "build/windows/x64/app-windows.zip", "-C", "build/windows/x64/runner/Release", "."]
|
||||
, shell=True)
|
||||
|
||||
subprocess.run(["iscc", "build/windows/build.iss"], shell=True)
|
35
debian/build.py
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
arch = sys.argv[1]
|
||||
debianContent = ''
|
||||
desktopContent = ''
|
||||
version = ''
|
||||
|
||||
with open('debian/debian.yaml', 'r') as f:
|
||||
debianContent = f.read()
|
||||
with open('debian/gui/pixes.desktop', 'r') as f:
|
||||
desktopContent = f.read()
|
||||
with open('pubspec.yaml', 'r') as f:
|
||||
version = str.split(str.split(f.read(), 'version: ')[1], '+')[0]
|
||||
|
||||
with open('debian/debian.yaml', 'w') as f:
|
||||
content = debianContent.replace('{{Version}}', version)
|
||||
if arch == 'x64':
|
||||
content = content.replace('{{Arch}}', 'x64')
|
||||
content = content.replace('{{Architecture}}', 'amd64')
|
||||
elif arch == 'arm64':
|
||||
content = content.replace('{{Arch}}', 'arm64')
|
||||
content = content.replace('{{Architecture}}', 'arm64')
|
||||
f.write(content)
|
||||
with open('debian/gui/pixes.desktop', 'w') as f:
|
||||
f.write(desktopContent.replace('{{Version}}', version))
|
||||
|
||||
subprocess.run(["flutter", "build", "linux"])
|
||||
|
||||
subprocess.run(["$HOME/.pub-cache/bin/flutter_to_debian"], shell=True)
|
||||
|
||||
with open('debian/debian.yaml', 'w') as f:
|
||||
f.write(debianContent)
|
||||
with open('debian/gui/pixes.desktop', 'w') as f:
|
||||
f.write(desktopContent)
|
18
debian/debian.yaml
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
flutter_app:
|
||||
command: pixes
|
||||
arch: {{Arch}}
|
||||
parent: /usr/local/lib
|
||||
nonInteractive: true
|
||||
execFieldCodes: u
|
||||
|
||||
control:
|
||||
Package: pixes
|
||||
Version: {{Version}}
|
||||
Architecture: {{Architecture}}
|
||||
Priority: optional
|
||||
Depends: libwebkit2gtk-4.1-0, libgtk-3-0
|
||||
Maintainer: nyne
|
||||
Description: Unofficial pixiv application
|
||||
|
||||
#options:
|
||||
# exec_out_dir: debian/packages
|
10
debian/gui/pixes.desktop
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Name=Pixes
|
||||
GenericName=Pixes
|
||||
Comment=Unofficial pixiv application
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Utility
|
||||
Keywords=Flutter;share;images;
|
||||
MimeType=x-scheme-handler/pixiv;
|
||||
Icon=pixes
|
BIN
debian/gui/pixes.png
vendored
Normal file
After Width: | Height: | Size: 11 KiB |
@@ -17,7 +17,7 @@ import Flutter
|
||||
let proxyConfig = "\(host):\(port)"
|
||||
result(proxyConfig)
|
||||
} else {
|
||||
result("")
|
||||
result("no proxy")
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -56,5 +56,9 @@
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>NSPhotoLibraryAddUsageDescription</key>
|
||||
<string>photo</string>
|
||||
<key>NSPhotoLibraryUsageDescription</key>
|
||||
<string>photo</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@@ -20,6 +20,25 @@ class _Appdata {
|
||||
"proxy": "",
|
||||
"darkMode": "System",
|
||||
"language": "System",
|
||||
"readingFontSize": 16.0,
|
||||
"readingLineHeight": 1.5,
|
||||
"readingParagraphSpacing": 8.0,
|
||||
"blockTags": [],
|
||||
"shortcuts": <int>[
|
||||
LogicalKeyboardKey.arrowDown.keyId,
|
||||
LogicalKeyboardKey.arrowUp.keyId,
|
||||
LogicalKeyboardKey.arrowRight.keyId,
|
||||
LogicalKeyboardKey.arrowLeft.keyId,
|
||||
LogicalKeyboardKey.enter.keyId,
|
||||
LogicalKeyboardKey.keyD.keyId,
|
||||
LogicalKeyboardKey.keyF.keyId,
|
||||
LogicalKeyboardKey.keyC.keyId,
|
||||
LogicalKeyboardKey.keyG.keyId,
|
||||
],
|
||||
"showOriginalImage": false,
|
||||
"checkUpdate": true,
|
||||
"emphasizeArtworksFromFollowingArtists": true,
|
||||
"initialPage": 4,
|
||||
};
|
||||
|
||||
bool lock = false;
|
||||
@@ -49,14 +68,25 @@ class _Appdata {
|
||||
Future<void> readData() async {
|
||||
final file = File("${App.dataPath}/account.json");
|
||||
if (file.existsSync()) {
|
||||
account = Account.fromJson(jsonDecode(await file.readAsString()));
|
||||
var json = jsonDecode(await file.readAsString());
|
||||
if (json != null) {
|
||||
account = Account.fromJson(json);
|
||||
}
|
||||
}
|
||||
final settingsFile = File("${App.dataPath}/settings.json");
|
||||
if (settingsFile.existsSync()) {
|
||||
var json = jsonDecode(await settingsFile.readAsString());
|
||||
for (var key in json.keys) {
|
||||
if(json[key] != null) {
|
||||
settings[key] = json[key];
|
||||
if (json[key] != null) {
|
||||
if (json[key] is List && settings[key] is List) {
|
||||
for (int i = 0;
|
||||
i < json[key].length && i < settings[key].length;
|
||||
i++) {
|
||||
settings[key][i] = json[key][i];
|
||||
}
|
||||
} else {
|
||||
settings[key] = json[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,10 @@ class BatchDownloadButton extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Button(
|
||||
child: const Icon(MdIcons.download, size: 20,),
|
||||
child: const Icon(
|
||||
MdIcons.download,
|
||||
size: 20,
|
||||
),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -40,6 +43,8 @@ class _DownloadDialog extends StatefulWidget {
|
||||
class _DownloadDialogState extends State<_DownloadDialog> {
|
||||
int maxCount = 30;
|
||||
|
||||
int currentCount = 0;
|
||||
|
||||
bool loading = false;
|
||||
|
||||
bool cancel = false;
|
||||
@@ -53,15 +58,18 @@ class _DownloadDialogState extends State<_DownloadDialog> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('${"Maximum number of downloads".tl}:'),
|
||||
const SizedBox(height: 16,),
|
||||
if (!loading) Text('${"Maximum number of downloads".tl}:'),
|
||||
if (loading) Text("${"Current quantity".tl}: $currentCount"),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
SizedBox(
|
||||
height: 42,
|
||||
width: 196,
|
||||
child: NumberBox(
|
||||
value: maxCount,
|
||||
onChanged: (value) {
|
||||
if(!loading) {
|
||||
if (!loading) {
|
||||
setState(() => maxCount = value ?? maxCount);
|
||||
}
|
||||
},
|
||||
@@ -71,35 +79,39 @@ class _DownloadDialogState extends State<_DownloadDialog> {
|
||||
largeChange: 30,
|
||||
clearButton: false,
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
).paddingVertical(8),
|
||||
),
|
||||
actions: [
|
||||
Button(child: Text("Cancel".tl), onPressed: () {
|
||||
cancel = true;
|
||||
context.pop();
|
||||
}),
|
||||
if(!loading)
|
||||
Button(
|
||||
child: Text("Cancel".tl),
|
||||
onPressed: () {
|
||||
cancel = true;
|
||||
context.pop();
|
||||
}),
|
||||
if (!loading)
|
||||
FilledButton(onPressed: load, child: Text("Continue".tl))
|
||||
else
|
||||
FilledButton(onPressed: (){}, child: const SizedBox(
|
||||
height: 20,
|
||||
width: 64,
|
||||
child: Center(
|
||||
child: SizedBox.square(
|
||||
dimension: 18,
|
||||
child: ProgressRing(
|
||||
strokeWidth: 1.6,
|
||||
FilledButton(
|
||||
onPressed: () {},
|
||||
child: const SizedBox(
|
||||
height: 20,
|
||||
width: 64,
|
||||
child: Center(
|
||||
child: SizedBox.square(
|
||||
dimension: 18,
|
||||
child: ProgressRing(
|
||||
strokeWidth: 1.6,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
))
|
||||
))
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void load() async{
|
||||
void load() async {
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
@@ -109,17 +121,17 @@ class _DownloadDialogState extends State<_DownloadDialog> {
|
||||
List<Illust> all = [];
|
||||
String? nextUrl;
|
||||
int retryCount = 0;
|
||||
while(nextUrl != "end" && all.length < maxCount) {
|
||||
if(nextUrl != null) {
|
||||
while (nextUrl != "end" && all.length < maxCount) {
|
||||
if (nextUrl != null) {
|
||||
request = Network().getIllustsWithNextUrl(nextUrl);
|
||||
}
|
||||
var res = await request;
|
||||
if(cancel || !mounted) {
|
||||
if (cancel || !mounted) {
|
||||
return;
|
||||
}
|
||||
if(res.error) {
|
||||
if (res.error) {
|
||||
retryCount++;
|
||||
if(retryCount > 3) {
|
||||
if (retryCount > 3) {
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
@@ -130,15 +142,17 @@ class _DownloadDialogState extends State<_DownloadDialog> {
|
||||
continue;
|
||||
}
|
||||
all.addAll(res.data);
|
||||
setState(() {
|
||||
currentCount = all.length;
|
||||
});
|
||||
nextUrl = res.subData ?? "end";
|
||||
}
|
||||
int i = 0;
|
||||
for(var illust in all) {
|
||||
if(i > maxCount) return;
|
||||
for (var illust in all) {
|
||||
if (i > maxCount) break;
|
||||
DownloadManager().addDownloadingTask(illust);
|
||||
i++;
|
||||
}
|
||||
context.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
100
lib/components/button.dart
Normal file
@@ -0,0 +1,100 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
|
||||
abstract class BaseButton extends StatelessWidget {
|
||||
const BaseButton({this.enabled = true, this.isLoading = false, super.key});
|
||||
|
||||
final bool enabled;
|
||||
|
||||
final bool isLoading;
|
||||
|
||||
Widget buildNormal(BuildContext context);
|
||||
|
||||
Widget buildLoading(BuildContext context);
|
||||
|
||||
Widget buildDisabled(BuildContext context);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (isLoading) {
|
||||
return buildLoading(context);
|
||||
} else if (enabled) {
|
||||
return buildNormal(context);
|
||||
} else {
|
||||
return buildDisabled(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FluentButton extends BaseButton {
|
||||
const FluentButton({
|
||||
required this.onPressed,
|
||||
required this.child,
|
||||
this.width,
|
||||
super.enabled,
|
||||
super.isLoading,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final void Function() onPressed;
|
||||
|
||||
final Widget child;
|
||||
|
||||
final double? width;
|
||||
|
||||
static const _kFluentButtonPadding = 12.0;
|
||||
|
||||
@override
|
||||
Widget buildNormal(BuildContext context) {
|
||||
Widget child = this.child;
|
||||
if (width != null) {
|
||||
child = child.fixWidth(width! - _kFluentButtonPadding * 2);
|
||||
}
|
||||
return FilledButton(
|
||||
onPressed: onPressed,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildLoading(BuildContext context) {
|
||||
Widget child = Center(
|
||||
widthFactor: 1,
|
||||
heightFactor: 1,
|
||||
child: const ProgressRing(
|
||||
strokeWidth: 1.6,
|
||||
).fixWidth(14).fixHeight(14),
|
||||
);
|
||||
if (width != null) {
|
||||
child = child.fixWidth(width! - _kFluentButtonPadding * 2);
|
||||
}
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: _kFluentButtonPadding, vertical: 6.5),
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context).inactiveBackgroundColor,
|
||||
borderRadius: BorderRadius.circular(4)),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildDisabled(BuildContext context) {
|
||||
Widget child = Center(
|
||||
widthFactor: 1,
|
||||
heightFactor: 1,
|
||||
child: this.child,
|
||||
);
|
||||
if (width != null) {
|
||||
child = child.fixWidth(width! - _kFluentButtonPadding * 2);
|
||||
}
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: _kFluentButtonPadding, vertical: 6.5),
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context).inactiveBackgroundColor,
|
||||
borderRadius: BorderRadius.circular(4)),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,48 +1,43 @@
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
|
||||
class SliverGridViewWithFixedItemHeight extends StatelessWidget {
|
||||
const SliverGridViewWithFixedItemHeight(
|
||||
{required this.delegate,
|
||||
required this.maxCrossAxisExtent,
|
||||
required this.itemHeight,
|
||||
super.key});
|
||||
this.maxCrossAxisExtent = double.infinity,
|
||||
this.minCrossAxisExtent = 0,
|
||||
required this.itemHeight,
|
||||
super.key});
|
||||
|
||||
final SliverChildDelegate delegate;
|
||||
|
||||
final double maxCrossAxisExtent;
|
||||
|
||||
final double minCrossAxisExtent;
|
||||
|
||||
final double itemHeight;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SliverLayoutBuilder(
|
||||
builder: ((context, constraints) => SliverGrid(
|
||||
delegate: delegate,
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: maxCrossAxisExtent,
|
||||
childAspectRatio:
|
||||
calcChildAspectRatio(constraints.crossAxisExtent)),
|
||||
).sliverPadding(EdgeInsets.only(bottom: context.padding.bottom))));
|
||||
}
|
||||
|
||||
double calcChildAspectRatio(double width) {
|
||||
var crossItems = width ~/ maxCrossAxisExtent;
|
||||
if (width % maxCrossAxisExtent != 0) {
|
||||
crossItems += 1;
|
||||
}
|
||||
final itemWidth = width / crossItems;
|
||||
return itemWidth / itemHeight;
|
||||
return SliverGrid(
|
||||
delegate: delegate,
|
||||
gridDelegate: SliverGridDelegateWithFixedHeight(
|
||||
itemHeight: itemHeight,
|
||||
maxCrossAxisExtent: maxCrossAxisExtent,
|
||||
minCrossAxisExtent: minCrossAxisExtent),
|
||||
).sliverPadding(EdgeInsets.only(bottom: context.padding.bottom));
|
||||
}
|
||||
}
|
||||
|
||||
class GridViewWithFixedItemHeight extends StatelessWidget {
|
||||
const GridViewWithFixedItemHeight(
|
||||
{ required this.builder,
|
||||
required this.itemCount,
|
||||
required this.maxCrossAxisExtent,
|
||||
required this.itemHeight,
|
||||
super.key});
|
||||
{required this.builder,
|
||||
required this.itemCount,
|
||||
this.maxCrossAxisExtent = double.infinity,
|
||||
this.minCrossAxisExtent = 0,
|
||||
required this.itemHeight,
|
||||
super.key});
|
||||
|
||||
final Widget Function(BuildContext, int) builder;
|
||||
|
||||
@@ -50,28 +45,80 @@ class GridViewWithFixedItemHeight extends StatelessWidget {
|
||||
|
||||
final double maxCrossAxisExtent;
|
||||
|
||||
final double minCrossAxisExtent;
|
||||
|
||||
final double itemHeight;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: ((context, constraints) => GridView.builder(
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: maxCrossAxisExtent,
|
||||
childAspectRatio:
|
||||
calcChildAspectRatio(constraints.maxWidth)),
|
||||
itemBuilder: builder,
|
||||
itemCount: itemCount,
|
||||
padding: EdgeInsets.only(bottom: context.padding.bottom),
|
||||
)));
|
||||
gridDelegate: SliverGridDelegateWithFixedHeight(
|
||||
itemHeight: itemHeight,
|
||||
maxCrossAxisExtent: maxCrossAxisExtent,
|
||||
minCrossAxisExtent: minCrossAxisExtent),
|
||||
itemBuilder: builder,
|
||||
itemCount: itemCount,
|
||||
padding: EdgeInsets.only(bottom: context.padding.bottom),
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
class SliverGridDelegateWithFixedHeight extends SliverGridDelegate {
|
||||
const SliverGridDelegateWithFixedHeight({
|
||||
this.maxCrossAxisExtent = double.infinity,
|
||||
this.minCrossAxisExtent = 0,
|
||||
required this.itemHeight,
|
||||
});
|
||||
|
||||
final double maxCrossAxisExtent;
|
||||
|
||||
final double minCrossAxisExtent;
|
||||
|
||||
final double itemHeight;
|
||||
|
||||
@override
|
||||
SliverGridLayout getLayout(SliverConstraints constraints) {
|
||||
var crossItemsCount = calcCrossItemsCount(constraints.crossAxisExtent);
|
||||
return SliverGridRegularTileLayout(
|
||||
crossAxisCount: crossItemsCount,
|
||||
mainAxisStride: itemHeight,
|
||||
childMainAxisExtent: itemHeight,
|
||||
crossAxisStride: constraints.crossAxisExtent / crossItemsCount,
|
||||
childCrossAxisExtent: constraints.crossAxisExtent / crossItemsCount,
|
||||
reverseCrossAxis: false);
|
||||
}
|
||||
|
||||
double calcChildAspectRatio(double width) {
|
||||
var crossItems = width ~/ maxCrossAxisExtent;
|
||||
if (width % maxCrossAxisExtent != 0) {
|
||||
crossItems += 1;
|
||||
int calcCrossItemsCount(double width) {
|
||||
int count = 20;
|
||||
var itemWidth = width / 20;
|
||||
|
||||
if(minCrossAxisExtent == 0) {
|
||||
count = 1;
|
||||
itemWidth = width;
|
||||
while(itemWidth > maxCrossAxisExtent) {
|
||||
count++;
|
||||
itemWidth = width / count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
final itemWidth = width / crossItems;
|
||||
return itemWidth / itemHeight;
|
||||
|
||||
while (
|
||||
!(itemWidth > minCrossAxisExtent && itemWidth < maxCrossAxisExtent)) {
|
||||
count--;
|
||||
itemWidth = width / count;
|
||||
if (count == 1) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRelayout(covariant SliverGridDelegate oldDelegate) {
|
||||
return oldDelegate is! SliverGridDelegateWithFixedHeight ||
|
||||
oldDelegate.maxCrossAxisExtent != maxCrossAxisExtent ||
|
||||
oldDelegate.minCrossAxisExtent != minCrossAxisExtent ||
|
||||
oldDelegate.itemHeight != itemHeight;
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,28 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/appdata.dart';
|
||||
import 'package:pixes/components/animated_image.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/foundation/history.dart';
|
||||
import 'package:pixes/foundation/image_provider.dart';
|
||||
import 'package:pixes/network/download.dart';
|
||||
import 'package:pixes/pages/related_page.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../network/network.dart';
|
||||
import '../pages/illust_page.dart';
|
||||
import 'md.dart';
|
||||
|
||||
typedef UpdateFavoriteFunc = void Function(bool v);
|
||||
|
||||
class IllustWidget extends StatefulWidget {
|
||||
const IllustWidget(this.illust, {super.key});
|
||||
const IllustWidget(this.illust, {this.onTap, super.key});
|
||||
|
||||
final Illust illust;
|
||||
|
||||
final void Function()? onTap;
|
||||
|
||||
static Map<String, UpdateFavoriteFunc> favoriteCallbacks = {};
|
||||
|
||||
@override
|
||||
State<IllustWidget> createState() => _IllustWidgetState();
|
||||
}
|
||||
@@ -24,6 +33,22 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
final contextController = FlyoutController();
|
||||
final contextAttachKey = GlobalKey();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
IllustWidget.favoriteCallbacks[widget.illust.id.toString()] = (v) {
|
||||
setState(() {
|
||||
widget.illust.isBookmarked = v;
|
||||
});
|
||||
};
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
IllustWidget.favoriteCallbacks.remove(widget.illust.id.toString());
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(builder: (context, constrains) {
|
||||
@@ -37,52 +62,78 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
height: height,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(child: Container(
|
||||
width: width,
|
||||
height: height,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
|
||||
child: Card(
|
||||
padding: EdgeInsets.zero,
|
||||
margin: EdgeInsets.zero,
|
||||
child: GestureDetector(
|
||||
onTap: (){
|
||||
context.to(() => IllustPage(widget.illust, favoriteCallback: (v) {
|
||||
setState(() {
|
||||
widget.illust.isBookmarked = v;
|
||||
});
|
||||
},));
|
||||
},
|
||||
onSecondaryTapUp: showMenu,
|
||||
child: ClipRRect(
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
width: width,
|
||||
height: height,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8.0, vertical: 8.0),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
padding: EdgeInsets.zero,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(4.0),
|
||||
child: AnimatedImage(
|
||||
image: CachedImageProvider(widget.illust.images.first.medium),
|
||||
fit: BoxFit.cover,
|
||||
width: width-16.0,
|
||||
height: height-16.0,
|
||||
color: FluentTheme.of(context).cardColor,
|
||||
border: () {
|
||||
var emphasis = widget.illust.author.isFollowed &&
|
||||
appdata.settings[
|
||||
'emphasizeArtworksFromFollowingArtists'];
|
||||
var color = emphasis
|
||||
? ColorScheme.of(context).primary
|
||||
: ColorScheme.of(context)
|
||||
.outlineVariant
|
||||
.toOpacity(0.64);
|
||||
var width = emphasis ? 1.6 : 1.0;
|
||||
return Border.all(color: color, width: width);
|
||||
}(),
|
||||
),
|
||||
margin: EdgeInsets.zero,
|
||||
child: GestureDetector(
|
||||
onTap: widget.onTap ??
|
||||
() {
|
||||
context.to(() => IllustPage(widget.illust));
|
||||
},
|
||||
onSecondaryTapUp: showMenu,
|
||||
onLongPress: showMenu,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(4.0),
|
||||
child: AnimatedImage(
|
||||
image: CachedImageProvider(
|
||||
widget.illust.images.first.medium),
|
||||
fit: BoxFit.cover,
|
||||
width: width - 16.0,
|
||||
height: height - 16.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
if(widget.illust.images.length > 1)
|
||||
),
|
||||
if (widget.illust.images.length > 1)
|
||||
Positioned(
|
||||
top: 12,
|
||||
left: 12,
|
||||
child: Container(
|
||||
width: 28,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context).cardColor,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6),
|
||||
),
|
||||
child: Center(
|
||||
child: Text("${widget.illust.images.length}P",
|
||||
style: const TextStyle(fontSize: 12),),
|
||||
)),
|
||||
width: 28,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context)
|
||||
.micaBackgroundColor
|
||||
.toOpacity(0.72),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
width: 0.6),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${widget.illust.images.length}P",
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
)),
|
||||
),
|
||||
if(widget.illust.isAi)
|
||||
if (widget.illust.isAi)
|
||||
Positioned(
|
||||
bottom: 12,
|
||||
left: 12,
|
||||
@@ -90,16 +141,22 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
width: 28,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context).errorContainer.withOpacity(0.8),
|
||||
color: ColorScheme.of(context)
|
||||
.errorContainer
|
||||
.toOpacity(0.8),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
width: 0.6),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text("AI",
|
||||
style: TextStyle(fontSize: 12),),
|
||||
child: Text(
|
||||
"AI",
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
)),
|
||||
),
|
||||
if(widget.illust.isUgoira)
|
||||
if (widget.illust.isUgoira)
|
||||
Positioned(
|
||||
bottom: 12,
|
||||
left: 12,
|
||||
@@ -107,16 +164,22 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
width: 28,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context).primaryContainer.withOpacity(0.8),
|
||||
color: ColorScheme.of(context)
|
||||
.primaryContainer
|
||||
.toOpacity(0.8),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
width: 0.6),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text("GIF",
|
||||
style: TextStyle(fontSize: 12),),
|
||||
child: Text(
|
||||
"GIF",
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
)),
|
||||
),
|
||||
if(widget.illust.isR18)
|
||||
if (widget.illust.isR18)
|
||||
Positioned(
|
||||
bottom: 12,
|
||||
right: 12,
|
||||
@@ -126,14 +189,18 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context).errorContainer,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
width: 0.6),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text("R18",
|
||||
style: TextStyle(fontSize: 12),),
|
||||
child: Text(
|
||||
"R18",
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
)),
|
||||
),
|
||||
if(widget.illust.isR18G)
|
||||
if (widget.illust.isR18G)
|
||||
Positioned(
|
||||
bottom: 12,
|
||||
right: 12,
|
||||
@@ -143,11 +210,15 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context).errorContainer,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
width: 0.6),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text("R18G",
|
||||
style: TextStyle(fontSize: 12),),
|
||||
child: Text(
|
||||
"R18G",
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
)),
|
||||
),
|
||||
Positioned(
|
||||
@@ -162,13 +233,13 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
});
|
||||
}
|
||||
|
||||
void showMenu(TapUpDetails details) {
|
||||
void showMenu([TapUpDetails? details]) {
|
||||
// This calculates the position of the flyout according to the parent navigator
|
||||
final targetContext = contextAttachKey.currentContext;
|
||||
if (targetContext == null) return;
|
||||
final box = targetContext.findRenderObject() as RenderBox;
|
||||
final position = box.localToGlobal(
|
||||
details.localPosition,
|
||||
Offset? position = box.localToGlobal(
|
||||
details?.localPosition ?? box.size.center(Offset.zero),
|
||||
ancestor: Navigator.of(context).context.findRenderObject(),
|
||||
);
|
||||
|
||||
@@ -178,35 +249,44 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
builder: (context) {
|
||||
return MenuFlyout(
|
||||
items: [
|
||||
MenuFlyoutItem(text: Text("View".tl), onPressed: (){
|
||||
context.to(() => IllustPage(widget.illust, favoriteCallback: (v) {
|
||||
setState(() {
|
||||
widget.illust.isBookmarked = v;
|
||||
});
|
||||
},));
|
||||
}),
|
||||
MenuFlyoutItem(text: Text("Private Favorite".tl), onPressed: (){
|
||||
favorite("private");
|
||||
}),
|
||||
MenuFlyoutItem(text: Text("Download".tl), onPressed: (){
|
||||
context.showToast(message: "Added");
|
||||
DownloadManager().addDownloadingTask(widget.illust);
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: Text("View".tl),
|
||||
onPressed: () {
|
||||
context.to(() => IllustPage(widget.illust));
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: Text("Private Favorite".tl),
|
||||
onPressed: () {
|
||||
favorite("private");
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: Text("Download".tl),
|
||||
onPressed: () {
|
||||
context.showToast(message: "Added");
|
||||
DownloadManager().addDownloadingTask(widget.illust);
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: Text("Related Artworks".tl),
|
||||
onPressed: () {
|
||||
context.to(
|
||||
() => RelatedIllustsPage(widget.illust.id.toString()));
|
||||
}),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void favorite([String type = "public"]) async{
|
||||
if(isBookmarking) return;
|
||||
void favorite([String type = "public"]) async {
|
||||
if (isBookmarking) return;
|
||||
setState(() {
|
||||
isBookmarking = true;
|
||||
});
|
||||
var method = widget.illust.isBookmarked ? "delete" : "add";
|
||||
var res = await Network().addBookmark(widget.illust.id.toString(), method, type);
|
||||
if(res.error) {
|
||||
if(mounted) {
|
||||
var res =
|
||||
await Network().addBookmark(widget.illust.id.toString(), method, type);
|
||||
if (res.error) {
|
||||
if (mounted) {
|
||||
context.showToast(message: "Network Error");
|
||||
}
|
||||
} else {
|
||||
@@ -219,16 +299,18 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
|
||||
Widget buildButton() {
|
||||
Widget child;
|
||||
if(isBookmarking) {
|
||||
if (isBookmarking) {
|
||||
child = const SizedBox(
|
||||
width: 14,
|
||||
height: 14,
|
||||
child: ProgressRing(strokeWidth: 1.6,),
|
||||
child: ProgressRing(
|
||||
strokeWidth: 1.6,
|
||||
),
|
||||
);
|
||||
} else if(widget.illust.isBookmarked) {
|
||||
} else if (widget.illust.isBookmarked) {
|
||||
child = Icon(
|
||||
MdIcons.favorite,
|
||||
color: ColorScheme.of(context).error,
|
||||
color: Colors.red,
|
||||
size: 22,
|
||||
);
|
||||
} else {
|
||||
@@ -254,3 +336,161 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class IllustHistoryWidget extends StatelessWidget {
|
||||
const IllustHistoryWidget(this.illust, {super.key});
|
||||
|
||||
final IllustHistory illust;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(builder: (context, constrains) {
|
||||
final width = constrains.maxWidth;
|
||||
final height = illust.height * width / illust.width;
|
||||
return SizedBox(
|
||||
width: width,
|
||||
height: height,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
width: width,
|
||||
height: height,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
|
||||
child: Card(
|
||||
padding: EdgeInsets.zero,
|
||||
margin: EdgeInsets.zero,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
context.to(() => IllustPageWithId(illust.id.toString()));
|
||||
},
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(4.0),
|
||||
child: AnimatedImage(
|
||||
image: CachedImageProvider(illust.imgPath),
|
||||
fit: BoxFit.cover,
|
||||
width: width - 16.0,
|
||||
height: height - 16.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
if (illust.imageCount > 1)
|
||||
Positioned(
|
||||
top: 12,
|
||||
left: 12,
|
||||
child: Container(
|
||||
width: 28,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context)
|
||||
.micaBackgroundColor
|
||||
.toOpacity(0.72),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
width: 0.6),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${illust.imageCount}P",
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
)),
|
||||
),
|
||||
if (illust.isAi)
|
||||
Positioned(
|
||||
bottom: 12,
|
||||
left: 12,
|
||||
child: Container(
|
||||
width: 28,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context)
|
||||
.errorContainer
|
||||
.toOpacity(0.8),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
width: 0.6),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
"AI",
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
)),
|
||||
),
|
||||
if (illust.isGif)
|
||||
Positioned(
|
||||
bottom: 12,
|
||||
left: 12,
|
||||
child: Container(
|
||||
width: 28,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context)
|
||||
.primaryContainer
|
||||
.toOpacity(0.8),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
width: 0.6),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
"GIF",
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
)),
|
||||
),
|
||||
if (illust.isR18)
|
||||
Positioned(
|
||||
bottom: 12,
|
||||
right: 12,
|
||||
child: Container(
|
||||
width: 28,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context).errorContainer,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
width: 0.6),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
"R18",
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
)),
|
||||
),
|
||||
if (illust.isR18G)
|
||||
Positioned(
|
||||
bottom: 12,
|
||||
right: 12,
|
||||
child: Container(
|
||||
width: 28,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context).errorContainer,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
width: 0.6),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
"R18G",
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
60
lib/components/keyboard.dart
Normal file
@@ -0,0 +1,60 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
|
||||
typedef KeyEventHandler = void Function(LogicalKeyboardKey key);
|
||||
|
||||
class KeyEventListener extends StatefulWidget {
|
||||
const KeyEventListener({required this.child, super.key});
|
||||
|
||||
final Widget child;
|
||||
|
||||
static KeyEventListenerState? of(BuildContext context) {
|
||||
return context.findAncestorStateOfType<KeyEventListenerState>();
|
||||
}
|
||||
|
||||
@override
|
||||
State<KeyEventListener> createState() => KeyEventListenerState();
|
||||
}
|
||||
|
||||
class KeyEventListenerState extends State<KeyEventListener> {
|
||||
final focusNode = FocusNode();
|
||||
|
||||
final List<KeyEventHandler> _handlers = [];
|
||||
|
||||
void addHandler(KeyEventHandler handler) {
|
||||
_handlers.add(handler);
|
||||
}
|
||||
|
||||
void removeHandler(KeyEventHandler handler) {
|
||||
_handlers.remove(handler);
|
||||
}
|
||||
|
||||
void removeAll() {
|
||||
_handlers.clear();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Focus(
|
||||
focusNode: focusNode,
|
||||
autofocus: true,
|
||||
onKeyEvent: (node, event) {
|
||||
if (event is! KeyUpEvent) return KeyEventResult.ignored;
|
||||
if (event.logicalKey == LogicalKeyboardKey.escape) {
|
||||
if (App.rootNavigatorKey.currentState?.canPop() ?? false) {
|
||||
App.rootNavigatorKey.currentState?.pop();
|
||||
} else if (App.mainNavigatorKey?.currentState?.canPop() ?? false) {
|
||||
App.mainNavigatorKey?.currentState?.pop();
|
||||
}
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
for (var handler in _handlers) {
|
||||
handler(event.logicalKey);
|
||||
}
|
||||
return KeyEventResult.ignored;
|
||||
},
|
||||
child: widget.child,
|
||||
);
|
||||
}
|
||||
}
|
@@ -13,6 +13,34 @@ abstract class LoadingState<T extends StatefulWidget, S extends Object> extends
|
||||
|
||||
Widget buildContent(BuildContext context, S data);
|
||||
|
||||
Widget? buildFrame(BuildContext context, Widget child) => null;
|
||||
|
||||
Widget buildLoading() {
|
||||
return const Center(
|
||||
child: ProgressRing(),
|
||||
);
|
||||
}
|
||||
|
||||
void retry() {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
error = null;
|
||||
});
|
||||
loadData().then((value) {
|
||||
if(value.success) {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
data = value.data;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
error = value.errorMessage!;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Widget buildError() {
|
||||
return Center(
|
||||
child: Column(
|
||||
@@ -21,25 +49,7 @@ abstract class LoadingState<T extends StatefulWidget, S extends Object> extends
|
||||
Text(error!),
|
||||
const SizedBox(height: 12),
|
||||
Button(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
error = null;
|
||||
});
|
||||
loadData().then((value) {
|
||||
if(value.success) {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
data = value.data;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
error = value.errorMessage!;
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
onPressed: retry,
|
||||
child: const Text("Retry"),
|
||||
)
|
||||
],
|
||||
@@ -69,15 +79,17 @@ abstract class LoadingState<T extends StatefulWidget, S extends Object> extends
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget child;
|
||||
|
||||
if(isLoading){
|
||||
return const Center(
|
||||
child: ProgressRing(),
|
||||
);
|
||||
child = buildLoading();
|
||||
} else if (error != null){
|
||||
return buildError();
|
||||
child = buildError();
|
||||
} else {
|
||||
return buildContent(context, data!);
|
||||
child = buildContent(context, data!);
|
||||
}
|
||||
|
||||
return buildFrame(context, child) ?? child;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,10 +106,14 @@ abstract class MultiPageLoadingState<T extends StatefulWidget, S extends Object>
|
||||
|
||||
Future<Res<List<S>>> loadData(int page);
|
||||
|
||||
Widget buildContent(BuildContext context, final List<S> data);
|
||||
Widget? buildFrame(BuildContext context, Widget child) => null;
|
||||
|
||||
Widget buildContent(BuildContext context, List<S> data);
|
||||
|
||||
bool get isLoading => _isLoading || _isFirstLoading;
|
||||
|
||||
bool get isFirstLoading => _isFirstLoading;
|
||||
|
||||
void nextPage() {
|
||||
if(_isLoading) return;
|
||||
_isLoading = true;
|
||||
@@ -116,7 +132,9 @@ abstract class MultiPageLoadingState<T extends StatefulWidget, S extends Object>
|
||||
if(message.length > 20) {
|
||||
message = "${message.substring(0, 20)}...";
|
||||
}
|
||||
context.showToast(message: message);
|
||||
if (mounted) {
|
||||
context.showToast(message: message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -134,6 +152,7 @@ abstract class MultiPageLoadingState<T extends StatefulWidget, S extends Object>
|
||||
|
||||
void firstLoad() {
|
||||
loadData(_page).then((value) {
|
||||
if (!mounted) return;
|
||||
if(value.success) {
|
||||
_page++;
|
||||
setState(() {
|
||||
@@ -181,12 +200,16 @@ abstract class MultiPageLoadingState<T extends StatefulWidget, S extends Object>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget child;
|
||||
|
||||
if(_isFirstLoading){
|
||||
return buildLoading(context);
|
||||
child = buildLoading(context);
|
||||
} else if (_error != null){
|
||||
return buildError(context, _error!);
|
||||
child = buildError(context, _error!);
|
||||
} else {
|
||||
return buildContent(context, _data!);
|
||||
child = buildContent(context, _data!);
|
||||
}
|
||||
|
||||
return buildFrame(context, child) ?? child;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,10 @@
|
||||
import 'package:flutter/material.dart' as md;
|
||||
|
||||
typedef MdIcons = md.Icons;
|
||||
typedef MdTheme = md.Theme;
|
||||
typedef MdThemeData = md.ThemeData;
|
||||
typedef MdColorScheme = md.ColorScheme;
|
||||
typedef TextField = md.TextField;
|
||||
|
||||
class ColorScheme {
|
||||
static md.ColorScheme of(md.BuildContext context) {
|
||||
|
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/components/md.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
|
||||
void showToast(BuildContext context, {required String message, IconData? icon}) {
|
||||
var newEntry = OverlayEntry(
|
||||
@@ -30,7 +31,7 @@ class ToastOverlay extends StatelessWidget {
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: PhysicalModel(
|
||||
color: ColorScheme.of(context).surface.withOpacity(1),
|
||||
color: ColorScheme.of(context).surface.toOpacity(1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
elevation: 1,
|
||||
child: Container(
|
||||
|
84
lib/components/novel.dart
Normal file
@@ -0,0 +1,84 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/components/animated_image.dart';
|
||||
import 'package:pixes/components/md.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/foundation/image_provider.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/pages/novel_page.dart';
|
||||
|
||||
class NovelWidget extends StatefulWidget {
|
||||
const NovelWidget(this.novel, {super.key});
|
||||
|
||||
final Novel novel;
|
||||
|
||||
@override
|
||||
State<NovelWidget> createState() => _NovelWidgetState();
|
||||
}
|
||||
|
||||
class _NovelWidgetState extends State<NovelWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
context.to(() => NovelPage(widget.novel));
|
||||
},
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 96,
|
||||
height: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context).secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: AnimatedImage(
|
||||
fit: BoxFit.cover,
|
||||
filterQuality: FilterQuality.medium,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
image: CachedImageProvider(widget.novel.image),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.novel.title,
|
||||
maxLines: 2,
|
||||
style: const TextStyle(
|
||||
fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.novel.caption.trim().replaceAll('<br />', '\n'),
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Text(
|
||||
widget.novel.author.name,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@@ -20,6 +20,7 @@ class AppPageRoute<T> extends PageRoute<T> with _AppRouteTransitionMixin {
|
||||
super.barrierDismissible = false,
|
||||
this.enableIOSGesture = true,
|
||||
this.preventRebuild = true,
|
||||
this.isRoot = false,
|
||||
}) {
|
||||
assert(opaque);
|
||||
}
|
||||
@@ -44,6 +45,9 @@ class AppPageRoute<T> extends PageRoute<T> with _AppRouteTransitionMixin {
|
||||
@override
|
||||
final bool preventRebuild;
|
||||
|
||||
@override
|
||||
final bool isRoot;
|
||||
|
||||
static void updateBackButton() {
|
||||
Future.delayed(const Duration(milliseconds: 300), () {
|
||||
StateController.findOrNull(tag: "back_button")?.update();
|
||||
@@ -77,6 +81,8 @@ mixin _AppRouteTransitionMixin<T> on PageRoute<T> {
|
||||
|
||||
Widget? _child;
|
||||
|
||||
bool get isRoot;
|
||||
|
||||
@override
|
||||
Widget buildPage(
|
||||
BuildContext context,
|
||||
@@ -115,19 +121,44 @@ mixin _AppRouteTransitionMixin<T> on PageRoute<T> {
|
||||
@override
|
||||
Widget buildTransitions(BuildContext context, Animation<double> animation,
|
||||
Animation<double> secondaryAnimation, Widget child) {
|
||||
return DrillInPageTransition(
|
||||
animation: CurvedAnimation(
|
||||
parent: animation,
|
||||
curve: FluentTheme.of(context).animationCurve,
|
||||
),
|
||||
child: enableIOSGesture && App.isIOS
|
||||
? IOSBackGestureDetector(
|
||||
gestureWidth: _kBackGestureWidth,
|
||||
enabledCallback: () => _isPopGestureEnabled<T>(this),
|
||||
onStartPopGesture: () => _startPopGesture(this),
|
||||
child: child)
|
||||
: child,
|
||||
child = ColoredBox(
|
||||
color: FluentTheme.of(context).micaBackgroundColor,
|
||||
child: child,
|
||||
);
|
||||
|
||||
if (isRoot) {
|
||||
child = EntrancePageTransition(
|
||||
animation: CurvedAnimation(
|
||||
parent: animation,
|
||||
curve: FluentTheme.of(context).animationCurve,
|
||||
),
|
||||
child: enableIOSGesture && App.isIOS
|
||||
? IOSBackGestureDetector(
|
||||
gestureWidth: _kBackGestureWidth,
|
||||
enabledCallback: () => _isPopGestureEnabled<T>(this),
|
||||
onStartPopGesture: () => _startPopGesture(this),
|
||||
child: child)
|
||||
: child,
|
||||
);
|
||||
} else {
|
||||
child = DrillInPageTransition(
|
||||
animation: CurvedAnimation(
|
||||
parent: animation,
|
||||
curve: FluentTheme
|
||||
.of(context)
|
||||
.animationCurve,
|
||||
),
|
||||
child: enableIOSGesture && App.isIOS
|
||||
? IOSBackGestureDetector(
|
||||
gestureWidth: _kBackGestureWidth,
|
||||
enabledCallback: () => _isPopGestureEnabled<T>(this),
|
||||
onStartPopGesture: () => _startPopGesture(this),
|
||||
child: child)
|
||||
: child,
|
||||
);
|
||||
}
|
||||
|
||||
return child;
|
||||
}
|
||||
|
||||
IOSBackGestureController _startPopGesture(PageRoute<T> route) {
|
||||
@@ -328,11 +359,15 @@ class SideBarRoute<T> extends PopupRoute<T> {
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context).micaBackgroundColor.withOpacity(0.98),
|
||||
borderRadius: const BorderRadius.only(topLeft: Radius.circular(4), bottomLeft: Radius.circular(4))
|
||||
),
|
||||
constraints: BoxConstraints(maxWidth: min(_kSideBarWidth,
|
||||
MediaQuery.of(context).size.width)),
|
||||
color: FluentTheme.of(context)
|
||||
.micaBackgroundColor
|
||||
.toOpacity(0.98),
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(4),
|
||||
bottomLeft: Radius.circular(4))),
|
||||
constraints: BoxConstraints(
|
||||
maxWidth:
|
||||
min(_kSideBarWidth, MediaQuery.of(context).size.width)),
|
||||
width: double.infinity,
|
||||
child: child,
|
||||
),
|
||||
@@ -384,3 +419,32 @@ class SideBarRoute<T> extends PopupRoute<T> {
|
||||
return IOSBackGestureController(route.controller!, route.navigator!);
|
||||
}
|
||||
}
|
||||
|
||||
class EntrancePageTransition extends StatelessWidget {
|
||||
/// Creates an entrance page transition
|
||||
const EntrancePageTransition({
|
||||
super.key,
|
||||
required this.child,
|
||||
required this.animation,
|
||||
});
|
||||
|
||||
/// The widget to be animated
|
||||
final Widget child;
|
||||
|
||||
/// The animation to drive this transition
|
||||
final Animation<double> animation;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0, 0.1),
|
||||
end: Offset.zero,
|
||||
).animate(animation),
|
||||
child: FadeTransition(
|
||||
opacity: animation,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
315
lib/components/search_field.dart
Normal file
@@ -0,0 +1,315 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
|
||||
class AutoCompleteItem {
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const AutoCompleteItem({
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
required this.onTap,
|
||||
});
|
||||
}
|
||||
|
||||
class AutoCompleteData {
|
||||
final List<AutoCompleteItem> items;
|
||||
final bool isLoading;
|
||||
|
||||
const AutoCompleteData({
|
||||
this.items = const <AutoCompleteItem>[],
|
||||
this.isLoading = false,
|
||||
});
|
||||
}
|
||||
|
||||
class SearchField extends StatefulWidget {
|
||||
const SearchField({
|
||||
super.key,
|
||||
this.autoCompleteItems = const <AutoCompleteItem>[],
|
||||
this.isLoadingAutoCompleteItems = false,
|
||||
this.enableAutoComplete = true,
|
||||
this.textEditingController,
|
||||
this.placeholder,
|
||||
this.leading,
|
||||
this.trailing,
|
||||
this.foregroundDecoration,
|
||||
this.onChanged,
|
||||
this.onSubmitted,
|
||||
this.padding,
|
||||
this.focusNode,
|
||||
this.autoCompleteNoResultsText,
|
||||
});
|
||||
|
||||
final List<AutoCompleteItem> autoCompleteItems;
|
||||
|
||||
final bool isLoadingAutoCompleteItems;
|
||||
|
||||
final bool enableAutoComplete;
|
||||
|
||||
final TextEditingController? textEditingController;
|
||||
|
||||
final String? placeholder;
|
||||
|
||||
final Widget? leading;
|
||||
|
||||
final Widget? trailing;
|
||||
|
||||
final WidgetStatePropertyAll<BoxDecoration>? foregroundDecoration;
|
||||
|
||||
final void Function(String)? onChanged;
|
||||
|
||||
final void Function(String)? onSubmitted;
|
||||
|
||||
final EdgeInsets? padding;
|
||||
|
||||
final FocusNode? focusNode;
|
||||
|
||||
final String? autoCompleteNoResultsText;
|
||||
|
||||
@override
|
||||
State<SearchField> createState() => _SearchFieldState();
|
||||
}
|
||||
|
||||
class _SearchFieldState extends State<SearchField> with TickerProviderStateMixin {
|
||||
late final ValueNotifier<AutoCompleteData> autoCompleteItems;
|
||||
|
||||
late final FocusNode focusNode;
|
||||
|
||||
final boxKey = GlobalKey();
|
||||
|
||||
OverlayEntry? _overlayEntry;
|
||||
|
||||
AnimationController? _animationController;
|
||||
Animation<double>? _fadeAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
autoCompleteItems = ValueNotifier(AutoCompleteData(
|
||||
items: widget.autoCompleteItems,
|
||||
isLoading: widget.isLoadingAutoCompleteItems,
|
||||
));
|
||||
focusNode = widget.focusNode ?? FocusNode();
|
||||
focusNode.addListener(onfocusChange);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_animationController?.dispose();
|
||||
focusNode.removeListener(onfocusChange);
|
||||
if (widget.focusNode == null) {
|
||||
focusNode.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant SearchField oldWidget) {
|
||||
if (widget.autoCompleteItems != oldWidget.autoCompleteItems ||
|
||||
widget.isLoadingAutoCompleteItems !=
|
||||
oldWidget.isLoadingAutoCompleteItems) {
|
||||
Future.microtask(() {
|
||||
autoCompleteItems.value = AutoCompleteData(
|
||||
items: widget.autoCompleteItems,
|
||||
isLoading: widget.isLoadingAutoCompleteItems,
|
||||
);
|
||||
});
|
||||
}
|
||||
super.didUpdateWidget(oldWidget);
|
||||
}
|
||||
|
||||
void onfocusChange() {
|
||||
if (focusNode.hasFocus && widget.enableAutoComplete) {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
if (box == null) return;
|
||||
final overlay = Overlay.of(context);
|
||||
final position = box.localToGlobal(
|
||||
Offset.zero,
|
||||
ancestor: overlay.context.findRenderObject(),
|
||||
);
|
||||
|
||||
if (_overlayEntry != null) {
|
||||
_removeOverlayWithAnimation();
|
||||
}
|
||||
|
||||
_animationController = AnimationController(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
vsync: this,
|
||||
);
|
||||
|
||||
_fadeAnimation = Tween<double>(
|
||||
begin: 0.0,
|
||||
end: 1.0,
|
||||
).animate(CurvedAnimation(
|
||||
parent: _animationController!,
|
||||
curve: Curves.easeOut,
|
||||
));
|
||||
|
||||
_overlayEntry = OverlayEntry(
|
||||
builder: (context) {
|
||||
return Positioned(
|
||||
left: position.dx,
|
||||
width: box.size.width,
|
||||
top: position.dy + box.size.height,
|
||||
child: _AnimatedOverlayWrapper(
|
||||
animation: _fadeAnimation!,
|
||||
child: _AutoCompleteOverlay(
|
||||
data: autoCompleteItems,
|
||||
noResultsText: widget.autoCompleteNoResultsText,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
overlay.insert(_overlayEntry!);
|
||||
_animationController!.forward();
|
||||
} else {
|
||||
_removeOverlayWithAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
void _removeOverlayWithAnimation() {
|
||||
if (_overlayEntry != null && _animationController != null) {
|
||||
_animationController!.reverse().then((_) {
|
||||
_overlayEntry?.remove();
|
||||
_overlayEntry = null;
|
||||
_animationController?.dispose();
|
||||
_animationController = null;
|
||||
_fadeAnimation = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextBox(
|
||||
controller: widget.textEditingController,
|
||||
key: boxKey,
|
||||
focusNode: focusNode,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
placeholder: widget.placeholder,
|
||||
onChanged: widget.onChanged,
|
||||
onSubmitted: widget.onSubmitted,
|
||||
foregroundDecoration: widget.foregroundDecoration,
|
||||
prefix: widget.leading,
|
||||
suffix: widget.trailing,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _AutoCompleteOverlay extends StatefulWidget {
|
||||
const _AutoCompleteOverlay({required this.data, this.noResultsText});
|
||||
|
||||
final ValueNotifier<AutoCompleteData> data;
|
||||
|
||||
final String? noResultsText;
|
||||
|
||||
@override
|
||||
State<_AutoCompleteOverlay> createState() => _AutoCompleteOverlayState();
|
||||
}
|
||||
|
||||
class _AutoCompleteOverlayState extends State<_AutoCompleteOverlay> {
|
||||
late final notifier = widget.data;
|
||||
|
||||
var items = <AutoCompleteItem>[];
|
||||
|
||||
var isLoading = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
items = notifier.value.items;
|
||||
isLoading = notifier.value.isLoading;
|
||||
notifier.addListener(onItemsChanged);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
notifier.removeListener(onItemsChanged);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void onItemsChanged() {
|
||||
setState(() {
|
||||
items = notifier.value.items;
|
||||
isLoading = notifier.value.isLoading;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var items = List<AutoCompleteItem>.from(this.items);
|
||||
|
||||
Widget? content;
|
||||
|
||||
if (isLoading) {
|
||||
content = SizedBox(
|
||||
height: 44,
|
||||
child: Center(
|
||||
child: ProgressRing(
|
||||
activeColor: FluentTheme.of(context).accentColor,
|
||||
strokeWidth: 2,
|
||||
).fixWidth(24).fixHeight(24),
|
||||
),
|
||||
);
|
||||
} else if (items.isEmpty) {
|
||||
content = ListTile(
|
||||
title: Text(widget.noResultsText ?? 'No results found'),
|
||||
onPressed: () {},
|
||||
);
|
||||
} else {
|
||||
if (items.length > 8) {
|
||||
items = items.sublist(0, 8);
|
||||
}
|
||||
content = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: items.map((item) {
|
||||
return ListTile(
|
||||
title: Text(item.title),
|
||||
subtitle: item.subtitle != null ? Text(item.subtitle!) : null,
|
||||
onPressed: item.onTap,
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
return Card(
|
||||
backgroundColor: FluentTheme.of(context).micaBackgroundColor,
|
||||
child: AnimatedSize(
|
||||
alignment: Alignment.topCenter,
|
||||
duration: const Duration(milliseconds: 160),
|
||||
child: content,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _AnimatedOverlayWrapper extends StatelessWidget {
|
||||
const _AnimatedOverlayWrapper({
|
||||
required this.animation,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
final Animation<double> animation;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedBuilder(
|
||||
animation: animation,
|
||||
builder: (context, child) {
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child: Transform.scale(
|
||||
scale: 0.9 + (0.1 * animation.value),
|
||||
alignment: Alignment.topCenter,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
@@ -40,7 +40,7 @@ class SegmentedButton<T> extends StatelessWidget {
|
||||
onPressed: () => onPressed(e.key),
|
||||
builder: (context, states) {
|
||||
var textColor = active ? null : ColorScheme.of(context).outline;
|
||||
var backgroundColor = active ? null : ButtonState.resolveWith((states) {
|
||||
var backgroundColor = active ? null : WidgetStateProperty.resolveWith((states) {
|
||||
return ButtonThemeData.buttonColor(context, states);
|
||||
}).resolve(states);
|
||||
|
||||
|
@@ -1,34 +1,57 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/components/animated_image.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/foundation/image_provider.dart';
|
||||
import 'package:pixes/pages/illust_page.dart';
|
||||
import 'package:pixes/pages/user_info_page.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../network/network.dart';
|
||||
import 'md.dart';
|
||||
|
||||
typedef UpdateFollowCallback = void Function(bool isFollowed);
|
||||
|
||||
class UserPreviewWidget extends StatefulWidget {
|
||||
const UserPreviewWidget(this.user, {super.key});
|
||||
|
||||
final UserPreview user;
|
||||
|
||||
static Map<String, UpdateFollowCallback> followCallbacks = {};
|
||||
|
||||
@override
|
||||
State<UserPreviewWidget> createState() => _UserPreviewWidgetState();
|
||||
}
|
||||
|
||||
class _UserPreviewWidgetState extends State<UserPreviewWidget> {
|
||||
@override
|
||||
void initState() {
|
||||
UserPreviewWidget.followCallbacks[widget.user.id.toString()] = (v) {
|
||||
setState(() {
|
||||
widget.user.isFollowed = v;
|
||||
});
|
||||
};
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
UserPreviewWidget.followCallbacks.remove(widget.user.id.toString());
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
bool isFollowing = false;
|
||||
|
||||
void follow() async{
|
||||
if(isFollowing) return;
|
||||
void follow() async {
|
||||
if (isFollowing) return;
|
||||
setState(() {
|
||||
isFollowing = true;
|
||||
});
|
||||
var method = widget.user.isFollowed ? "delete" : "add";
|
||||
var res = await Network().follow(widget.user.id.toString(), method);
|
||||
if(res.error) {
|
||||
if(mounted) {
|
||||
if (res.error) {
|
||||
if (mounted) {
|
||||
context.showToast(message: "Network Error");
|
||||
}
|
||||
} else {
|
||||
@@ -37,71 +60,129 @@ class _UserPreviewWidgetState extends State<UserPreviewWidget> {
|
||||
setState(() {
|
||||
isFollowing = false;
|
||||
});
|
||||
UserInfoPage.followCallbacks[widget.user.id.toString()]
|
||||
?.call(widget.user.isFollowed);
|
||||
IllustPage.updateFollow(widget.user.id.toString(), widget.user.isFollowed);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 64,
|
||||
height: 64,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(64),
|
||||
child: ColoredBox(
|
||||
color: ColorScheme.of(context).secondaryContainer,
|
||||
child: AnimatedImage(
|
||||
image: CachedImageProvider(widget.user.avatar),
|
||||
fit: BoxFit.cover,
|
||||
filterQuality: FilterQuality.medium,
|
||||
child: GestureDetector(
|
||||
onTap: () => context.to(() => UserInfoPage(widget.user.id.toString())),
|
||||
behavior: HitTestBehavior.translucent,
|
||||
child: SizedBox.expand(
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 64,
|
||||
height: 64,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(64),
|
||||
child: ColoredBox(
|
||||
color: ColorScheme.of(context).secondaryContainer,
|
||||
child: AnimatedImage(
|
||||
image: CachedImageProvider(widget.user.avatar),
|
||||
fit: BoxFit.cover,
|
||||
filterQuality: FilterQuality.medium,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
SizedBox(
|
||||
width: 96,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Spacer(),
|
||||
Text(widget.user.name,
|
||||
maxLines: 1,
|
||||
style: const TextStyle(
|
||||
fontSize: 16, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
if (isFollowing)
|
||||
Button(
|
||||
onPressed: follow,
|
||||
child: const SizedBox(
|
||||
width: 42,
|
||||
height: 24,
|
||||
child: Center(
|
||||
child: SizedBox.square(
|
||||
dimension: 18,
|
||||
child: ProgressRing(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
))
|
||||
else if (!widget.user.isFollowed)
|
||||
Button(onPressed: follow, child: Text("Follow".tl))
|
||||
else
|
||||
Button(
|
||||
onPressed: follow,
|
||||
child: Text(
|
||||
"Unfollow".tl,
|
||||
style: TextStyle(
|
||||
color: ColorScheme.of(context).error),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
var count = constraints.maxWidth.toInt() ~/ 96;
|
||||
var images = List.generate(
|
||||
min(count, widget.user.artworks.length),
|
||||
(index) => buildIllust(widget.user.artworks[index]));
|
||||
return Row(
|
||||
children: images,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
FluentIcons.chevron_right,
|
||||
size: 14,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildIllust(Illust illust) {
|
||||
return SizedBox(
|
||||
width: 96,
|
||||
height: double.infinity,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: ColoredBox(
|
||||
color: ColorScheme.of(context).secondaryContainer,
|
||||
child: AnimatedImage(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
fit: BoxFit.cover,
|
||||
filterQuality: FilterQuality.medium,
|
||||
image: CachedImageProvider(illust.images.first.medium),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12,),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(widget.user.name, maxLines: 1, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
Button(
|
||||
onPressed: () => context.to(() => UserInfoPage(widget.user.id.toString(), followCallback: (v){
|
||||
setState(() {
|
||||
widget.user.isFollowed = v;
|
||||
});
|
||||
},)),
|
||||
child: Text("View".tl,),
|
||||
),
|
||||
const SizedBox(width: 8,),
|
||||
if(isFollowing)
|
||||
Button(onPressed: follow, child: const SizedBox(
|
||||
width: 42,
|
||||
height: 24,
|
||||
child: Center(
|
||||
child: SizedBox.square(
|
||||
dimension: 18,
|
||||
child: ProgressRing(strokeWidth: 2,),
|
||||
),
|
||||
),
|
||||
))
|
||||
else if (!widget.user.isFollowed)
|
||||
Button(onPressed: follow, child: Text("Follow".tl))
|
||||
else
|
||||
Button(
|
||||
onPressed: follow,
|
||||
child: Text("Unfollow".tl, style: TextStyle(color: ColorScheme.of(context).error),),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
).paddingVertical(8),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import 'dart:io';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
@@ -11,11 +12,13 @@ export "state_controller.dart";
|
||||
export "navigation.dart";
|
||||
|
||||
class _App {
|
||||
final version = "1.0.2";
|
||||
final version = "1.2.0";
|
||||
|
||||
bool get isAndroid => Platform.isAndroid;
|
||||
bool get isIOS => Platform.isIOS;
|
||||
bool get isWindows => Platform.isWindows;
|
||||
int? _windowsVersion;
|
||||
int get windowsVersion => _windowsVersion!;
|
||||
bool get isLinux => Platform.isLinux;
|
||||
bool get isMacOS => Platform.isMacOS;
|
||||
bool get isDesktop =>
|
||||
@@ -23,16 +26,17 @@ class _App {
|
||||
bool get isMobile => Platform.isAndroid || Platform.isIOS;
|
||||
|
||||
Locale get locale {
|
||||
if(appdata.settings["language"] != "System"){
|
||||
return switch(appdata.settings["language"]){
|
||||
if (appdata.settings["language"] != "System") {
|
||||
return switch (appdata.settings["language"]) {
|
||||
"English" => const Locale("en"),
|
||||
"简体中文" => const Locale("zh"),
|
||||
"繁體中文" => const Locale("zh", "Hant"),
|
||||
"简体中文" => const Locale("zh", "CN"),
|
||||
"繁體中文" => const Locale("zh", "TW"),
|
||||
_ => const Locale("en"),
|
||||
};
|
||||
}
|
||||
Locale deviceLocale = PlatformDispatcher.instance.locale;
|
||||
if (deviceLocale.languageCode == "zh" && deviceLocale.scriptCode == "Hant") {
|
||||
if (deviceLocale.languageCode == "zh" &&
|
||||
deviceLocale.scriptCode == "Hant") {
|
||||
deviceLocale = const Locale("zh", "TW");
|
||||
}
|
||||
return deviceLocale;
|
||||
@@ -41,12 +45,29 @@ class _App {
|
||||
late String dataPath;
|
||||
late String cachePath;
|
||||
|
||||
init() async{
|
||||
init() async {
|
||||
cachePath = (await getApplicationCacheDirectory()).path;
|
||||
dataPath = (await getApplicationSupportDirectory()).path;
|
||||
if (App.isWindows) {
|
||||
final deviceInfoPlugin = DeviceInfoPlugin();
|
||||
final deviceInfo = await deviceInfoPlugin.windowsInfo;
|
||||
if (deviceInfo.majorVersion <= 6) {
|
||||
if (deviceInfo.minorVersion < 2) {
|
||||
_windowsVersion = 7;
|
||||
} else {
|
||||
_windowsVersion = 8;
|
||||
}
|
||||
} else if (deviceInfo.buildNumber < 22000) {
|
||||
_windowsVersion = 10;
|
||||
} else {
|
||||
_windowsVersion = 11;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final rootNavigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
GlobalKey<NavigatorState>? mainNavigatorKey;
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
|
102
lib/foundation/history.dart
Normal file
@@ -0,0 +1,102 @@
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:sqlite3/sqlite3.dart';
|
||||
import 'package:pixes/network/models.dart';
|
||||
|
||||
class IllustHistory {
|
||||
final int id;
|
||||
final String imgPath;
|
||||
final DateTime time;
|
||||
final int imageCount;
|
||||
final bool isR18;
|
||||
final bool isR18G;
|
||||
final bool isAi;
|
||||
final bool isGif;
|
||||
final int width;
|
||||
final int height;
|
||||
|
||||
IllustHistory(this.id, this.imgPath, this.time, this.imageCount, this.isR18,
|
||||
this.isR18G, this.isAi, this.isGif, this.width, this.height);
|
||||
}
|
||||
|
||||
class HistoryManager {
|
||||
static HistoryManager? instance;
|
||||
|
||||
factory HistoryManager() => instance ??= HistoryManager._create();
|
||||
|
||||
HistoryManager._create();
|
||||
|
||||
late Database _db;
|
||||
|
||||
init() {
|
||||
_db = sqlite3.open("${App.dataPath}/history.db");
|
||||
_db.execute('''
|
||||
create table if not exists history (
|
||||
id integer primary key not null,
|
||||
imgPath text not null,
|
||||
time integer not null,
|
||||
imageCount integer not null,
|
||||
isR18 integer not null,
|
||||
isR18g integer not null,
|
||||
isAi integer not null,
|
||||
isGif integer not null,
|
||||
width integer not null,
|
||||
height integer not null
|
||||
)
|
||||
''');
|
||||
}
|
||||
|
||||
void addHistory(Illust illust) {
|
||||
var time = DateTime.now();
|
||||
_db.execute('''
|
||||
insert or replace into history (id, imgPath, time, imageCount, isR18, isR18g, isAi, isGif, width, height)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
''', [
|
||||
illust.id,
|
||||
illust.images.first.medium,
|
||||
time.millisecondsSinceEpoch,
|
||||
illust.pageCount,
|
||||
illust.isR18 ? 1 : 0,
|
||||
illust.isR18G ? 1 : 0,
|
||||
illust.isAi ? 1 : 0,
|
||||
illust.isUgoira ? 1 : 0,
|
||||
illust.width,
|
||||
illust.height
|
||||
]);
|
||||
if(length > 1000) {
|
||||
_db.execute('''
|
||||
delete from history where id in (
|
||||
select id from history order by time asc limit 100
|
||||
)
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
||||
List<IllustHistory> getHistories(int page) {
|
||||
var rows = _db.select('''
|
||||
select * from history order by time desc
|
||||
limit 20 offset ?
|
||||
''', [(page - 1) * 20]);
|
||||
List<IllustHistory> res = [];
|
||||
for (var row in rows) {
|
||||
res.add(IllustHistory(
|
||||
row['id'],
|
||||
row['imgPath'],
|
||||
DateTime.fromMillisecondsSinceEpoch(row['time']),
|
||||
row['imageCount'],
|
||||
row['isR18'] == 1,
|
||||
row['isR18g'] == 1,
|
||||
row['isAi'] == 1,
|
||||
row['isGif'] == 1,
|
||||
row['width'],
|
||||
row['height']));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
int get length {
|
||||
var rows = _db.select('''
|
||||
select count(*) from history
|
||||
''');
|
||||
return rows.first.values.first! as int;
|
||||
}
|
||||
}
|
@@ -45,10 +45,10 @@ abstract class BaseImageProvider<T extends BaseImageProvider<T>>
|
||||
}
|
||||
|
||||
Future<ui.Codec> _loadBufferAsync(
|
||||
T key,
|
||||
StreamController<ImageChunkEvent> chunkEvents,
|
||||
ImageDecoderCallback decode,
|
||||
) async {
|
||||
T key,
|
||||
StreamController<ImageChunkEvent> chunkEvents,
|
||||
ImageDecoderCallback decode,
|
||||
) async {
|
||||
try {
|
||||
int retryTime = 1;
|
||||
|
||||
@@ -83,11 +83,11 @@ abstract class BaseImageProvider<T extends BaseImageProvider<T>>
|
||||
}
|
||||
}
|
||||
|
||||
if(stop) {
|
||||
if (stop) {
|
||||
throw Exception("Image loading is stopped");
|
||||
}
|
||||
|
||||
if(data!.isEmpty) {
|
||||
if (data!.isEmpty) {
|
||||
throw Exception("Empty image data");
|
||||
}
|
||||
|
||||
@@ -147,13 +147,13 @@ class CachedImageProvider extends BaseImageProvider<CachedImageProvider> {
|
||||
String get key => url;
|
||||
|
||||
@override
|
||||
Future<Uint8List> load(StreamController<ImageChunkEvent> chunkEvents) async{
|
||||
Future<Uint8List> load(StreamController<ImageChunkEvent> chunkEvents) async {
|
||||
chunkEvents.add(const ImageChunkEvent(
|
||||
cumulativeBytesLoaded: 0,
|
||||
expectedTotalBytes: 1,
|
||||
));
|
||||
var cached = await CacheManager().findCache(key);
|
||||
if(cached != null) {
|
||||
if (cached != null) {
|
||||
chunkEvents.add(const ImageChunkEvent(
|
||||
cumulativeBytesLoaded: 1,
|
||||
expectedTotalBytes: 1,
|
||||
@@ -161,30 +161,28 @@ class CachedImageProvider extends BaseImageProvider<CachedImageProvider> {
|
||||
return await File(cached).readAsBytes();
|
||||
}
|
||||
var dio = AppDio();
|
||||
final time = DateFormat("yyyy-MM-dd'T'HH:mm:ss'+00:00'").format(DateTime.now());
|
||||
final time =
|
||||
DateFormat("yyyy-MM-dd'T'HH:mm:ss'+00:00'").format(DateTime.now());
|
||||
final hash = md5.convert(utf8.encode(time + Network.hashSalt)).toString();
|
||||
var res = await dio.get<ResponseBody>(
|
||||
url,
|
||||
options: Options(
|
||||
responseType: ResponseType.stream,
|
||||
validateStatus: (status) => status != null && status < 500,
|
||||
headers: {
|
||||
"referer": "https://app-api.pixiv.net/",
|
||||
"user-agent": "PixivAndroidApp/5.0.234 (Android 14; Pixes)",
|
||||
"x-client-time": time,
|
||||
"x-client-hash": hash,
|
||||
"accept-enconding": "gzip",
|
||||
}
|
||||
)
|
||||
);
|
||||
if(res.statusCode != 200) {
|
||||
var res = await dio.get<ResponseBody>(url,
|
||||
options: Options(
|
||||
responseType: ResponseType.stream,
|
||||
validateStatus: (status) => status != null && status < 500,
|
||||
headers: {
|
||||
"referer": "https://app-api.pixiv.net/",
|
||||
"user-agent": "PixivAndroidApp/5.0.234 (Android 14; Pixes)",
|
||||
"x-client-time": time,
|
||||
"x-client-hash": hash,
|
||||
"accept-enconding": "gzip",
|
||||
}));
|
||||
if (res.statusCode != 200) {
|
||||
throw BadRequestException("Failed to load image: ${res.statusCode}");
|
||||
}
|
||||
var data = <int>[];
|
||||
var cachingFile = await CacheManager().openWrite(key);
|
||||
await for (var chunk in res.data!.stream) {
|
||||
var length = res.data!.contentLength+1;
|
||||
if(length < data.length) {
|
||||
var length = res.data!.contentLength + 1;
|
||||
if (length < data.length) {
|
||||
length = data.length + 1;
|
||||
}
|
||||
data.addAll(chunk);
|
||||
@@ -203,3 +201,71 @@ class CachedImageProvider extends BaseImageProvider<CachedImageProvider> {
|
||||
return SynchronousFuture<CachedImageProvider>(this);
|
||||
}
|
||||
}
|
||||
|
||||
class CachedNovelImageProvider
|
||||
extends BaseImageProvider<CachedNovelImageProvider> {
|
||||
final String novelId;
|
||||
final String imageId;
|
||||
|
||||
CachedNovelImageProvider(this.novelId, this.imageId);
|
||||
|
||||
@override
|
||||
String get key => "$novelId/$imageId";
|
||||
|
||||
@override
|
||||
Future<Uint8List> load(StreamController<ImageChunkEvent> chunkEvents) async {
|
||||
chunkEvents.add(const ImageChunkEvent(
|
||||
cumulativeBytesLoaded: 0,
|
||||
expectedTotalBytes: 1,
|
||||
));
|
||||
var cached = await CacheManager().findCache(key);
|
||||
if (cached != null) {
|
||||
chunkEvents.add(const ImageChunkEvent(
|
||||
cumulativeBytesLoaded: 1,
|
||||
expectedTotalBytes: 1,
|
||||
));
|
||||
return await File(cached).readAsBytes();
|
||||
}
|
||||
var urlRes = await Network().getNovelImage(novelId, imageId);
|
||||
var url = urlRes.data;
|
||||
var dio = AppDio();
|
||||
final time =
|
||||
DateFormat("yyyy-MM-dd'T'HH:mm:ss'+00:00'").format(DateTime.now());
|
||||
final hash = md5.convert(utf8.encode(time + Network.hashSalt)).toString();
|
||||
var res = await dio.get<ResponseBody>(url,
|
||||
options: Options(
|
||||
responseType: ResponseType.stream,
|
||||
validateStatus: (status) => status != null && status < 500,
|
||||
headers: {
|
||||
"referer": "https://app-api.pixiv.net/",
|
||||
"user-agent": "PixivAndroidApp/5.0.234 (Android 14; Pixes)",
|
||||
"x-client-time": time,
|
||||
"x-client-hash": hash,
|
||||
"accept-enconding": "gzip",
|
||||
}));
|
||||
if (res.statusCode != 200) {
|
||||
throw BadRequestException("Failed to load image: ${res.statusCode}");
|
||||
}
|
||||
var data = <int>[];
|
||||
var cachingFile = await CacheManager().openWrite(key);
|
||||
await for (var chunk in res.data!.stream) {
|
||||
var length = res.data!.contentLength + 1;
|
||||
if (length < data.length) {
|
||||
length = data.length + 1;
|
||||
}
|
||||
data.addAll(chunk);
|
||||
await cachingFile.writeBytes(chunk);
|
||||
chunkEvents.add(ImageChunkEvent(
|
||||
cumulativeBytesLoaded: data.length,
|
||||
expectedTotalBytes: length,
|
||||
));
|
||||
}
|
||||
await cachingFile.close();
|
||||
return Uint8List.fromList(data);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CachedNovelImageProvider> obtainKey(ImageConfiguration configuration) {
|
||||
return SynchronousFuture<CachedNovelImageProvider>(this);
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:pixes/utils/ext.dart';
|
||||
|
||||
@@ -26,12 +28,15 @@ class Log {
|
||||
|
||||
static bool ignoreLimitation = false;
|
||||
|
||||
/// only for debug
|
||||
static const String? logFile = null;
|
||||
|
||||
static void printWarning(String text) {
|
||||
print('\x1B[33m$text\x1B[0m');
|
||||
debugPrint('\x1B[33m$text\x1B[0m');
|
||||
}
|
||||
|
||||
static void printError(String text) {
|
||||
print('\x1B[31m$text\x1B[0m');
|
||||
debugPrint('\x1B[31m$text\x1B[0m');
|
||||
}
|
||||
|
||||
static void addLog(LogLevel level, String title, String content) {
|
||||
@@ -39,15 +44,13 @@ class Log {
|
||||
content = "${content.substring(0, maxLogLength)}...";
|
||||
}
|
||||
|
||||
if (kDebugMode) {
|
||||
switch (level) {
|
||||
case LogLevel.error:
|
||||
printError(content);
|
||||
case LogLevel.warning:
|
||||
printWarning(content);
|
||||
case LogLevel.info:
|
||||
print(content);
|
||||
}
|
||||
switch (level) {
|
||||
case LogLevel.error:
|
||||
printError(content);
|
||||
case LogLevel.warning:
|
||||
printWarning(content);
|
||||
case LogLevel.info:
|
||||
debugPrint(content);
|
||||
}
|
||||
|
||||
var newLog = LogItem(level, title, content);
|
||||
@@ -57,6 +60,9 @@ class Log {
|
||||
}
|
||||
|
||||
_logs.add(newLog);
|
||||
if(logFile != null) {
|
||||
File(logFile!).writeAsString(newLog.toString(), mode: FileMode.append);
|
||||
}
|
||||
if (_logs.length > maxLogNumber) {
|
||||
var res = _logs.remove(
|
||||
_logs.firstWhereOrNull((element) => element.level == LogLevel.info));
|
||||
|
@@ -20,4 +20,6 @@ extension Navigation on BuildContext {
|
||||
Size get size => MediaQuery.of(this).size;
|
||||
|
||||
EdgeInsets get padding => MediaQuery.of(this).padding;
|
||||
|
||||
EdgeInsets get viewInsets => MediaQuery.of(this).viewInsets;
|
||||
}
|
||||
|
@@ -64,4 +64,10 @@ extension WidgetExtension on Widget{
|
||||
Widget fixHeight(double height){
|
||||
return SizedBox(height: height, child: this);
|
||||
}
|
||||
}
|
||||
|
||||
extension ColorExt on Color {
|
||||
Color toOpacity(double opacity){
|
||||
return withValues(alpha: opacity);
|
||||
}
|
||||
}
|
245
lib/main.dart
@@ -1,46 +1,69 @@
|
||||
import "dart:async";
|
||||
import "dart:ui";
|
||||
|
||||
import "package:dynamic_color/dynamic_color.dart";
|
||||
import "package:fluent_ui/fluent_ui.dart";
|
||||
import "package:flutter/foundation.dart";
|
||||
import "package:flutter/material.dart" as md;
|
||||
import "package:flutter/services.dart";
|
||||
import "package:flutter_acrylic/flutter_acrylic.dart" as flutter_acrylic;
|
||||
import "package:pixes/appdata.dart";
|
||||
import "package:pixes/components/keyboard.dart";
|
||||
import "package:pixes/components/md.dart";
|
||||
import "package:pixes/components/message.dart";
|
||||
import "package:pixes/foundation/app.dart";
|
||||
import "package:pixes/foundation/history.dart";
|
||||
import "package:pixes/foundation/log.dart";
|
||||
import "package:pixes/network/app_dio.dart";
|
||||
import "package:pixes/pages/main_page.dart";
|
||||
import "package:pixes/utils/app_links.dart";
|
||||
import "package:pixes/utils/loop.dart";
|
||||
import "package:pixes/utils/translation.dart";
|
||||
import "package:pixes/utils/update.dart";
|
||||
import "package:pixes/utils/window.dart";
|
||||
import "package:window_manager/window_manager.dart";
|
||||
import 'package:system_theme/system_theme.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
FlutterError.onError = (details) {
|
||||
Log.error("Unhandled", "${details.exception}\n${details.stack}");
|
||||
};
|
||||
setSystemProxy();
|
||||
SystemTheme.fallbackColor = Colors.blue;
|
||||
await SystemTheme.accentColor.load();
|
||||
await App.init();
|
||||
await appdata.readData();
|
||||
await Translation.init();
|
||||
handleLinks();
|
||||
SystemTheme.onChange.listen((event) {
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
void main() {
|
||||
runZonedGuarded(() async {
|
||||
Future.delayed(const Duration(seconds: 3), checkUpdate);
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
FlutterError.onError = (details) {
|
||||
Log.error("Unhandled", "${details.exception}\n${details.stack}");
|
||||
};
|
||||
setSystemProxy();
|
||||
await App.init();
|
||||
await appdata.readData();
|
||||
await Translation.init();
|
||||
HistoryManager().init();
|
||||
handleLinks();
|
||||
if (App.isDesktop) {
|
||||
await flutter_acrylic.Window.initialize();
|
||||
if (App.isWindows) {
|
||||
await flutter_acrylic.Window.hideWindowControls();
|
||||
}
|
||||
await WindowManager.instance.ensureInitialized();
|
||||
windowManager.waitUntilReadyToShow().then((_) async {
|
||||
await windowManager.setTitleBarStyle(
|
||||
TitleBarStyle.hidden,
|
||||
windowButtonVisibility: false,
|
||||
);
|
||||
if (App.isLinux) {
|
||||
// https://github.com/leanflutter/window_manager/issues/460
|
||||
return;
|
||||
}
|
||||
await windowManager.setMinimumSize(const Size(500, 600));
|
||||
var placement = await WindowPlacement.loadFromFile();
|
||||
await placement.applyToWindow();
|
||||
await windowManager.show();
|
||||
Loop.register(WindowPlacement.loop);
|
||||
});
|
||||
}
|
||||
Loop.start();
|
||||
Log.info("APP", "Application started");
|
||||
runApp(const MyApp());
|
||||
}, (error, stack) {
|
||||
Log.error("Unhandled Exception", "$error\n$stack");
|
||||
});
|
||||
if (App.isDesktop) {
|
||||
await WindowManager.instance.ensureInitialized();
|
||||
windowManager.waitUntilReadyToShow().then((_) async {
|
||||
await windowManager.setTitleBarStyle(
|
||||
TitleBarStyle.hidden,
|
||||
windowButtonVisibility: false,
|
||||
);
|
||||
await windowManager.setMinimumSize(const Size(500, 600));
|
||||
await windowManager.show();
|
||||
await windowManager.setSkipTaskbar(false);
|
||||
});
|
||||
}
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@@ -53,11 +76,12 @@ class MyApp extends StatelessWidget {
|
||||
init: SimpleController(),
|
||||
tag: "MyApp",
|
||||
builder: (controller) {
|
||||
Brightness brightness = PlatformDispatcher.instance.platformBrightness;
|
||||
Brightness brightness =
|
||||
PlatformDispatcher.instance.platformBrightness;
|
||||
|
||||
if(appdata.settings["theme"] == "Dark") {
|
||||
if (appdata.settings["theme"] == "Dark") {
|
||||
brightness = Brightness.dark;
|
||||
} else if(appdata.settings["theme"] == "Light") {
|
||||
} else if (appdata.settings["theme"] == "Light") {
|
||||
brightness = Brightness.light;
|
||||
}
|
||||
|
||||
@@ -68,40 +92,135 @@ class MyApp extends StatelessWidget {
|
||||
statusBarIconBrightness: brightness.opposite,
|
||||
systemNavigationBarIconBrightness: brightness.opposite,
|
||||
),
|
||||
child: FluentApp(
|
||||
navigatorKey: App.rootNavigatorKey,
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'pixes',
|
||||
theme: FluentThemeData(
|
||||
brightness: brightness,
|
||||
fontFamily: App.isWindows ? 'font' : null,
|
||||
accentColor: AccentColor.swatch({
|
||||
'darkest': SystemTheme.accentColor.darkest,
|
||||
'darker': SystemTheme.accentColor.darker,
|
||||
'dark': SystemTheme.accentColor.dark,
|
||||
'normal': SystemTheme.accentColor.accent,
|
||||
'light': SystemTheme.accentColor.light,
|
||||
'lighter': SystemTheme.accentColor.lighter,
|
||||
'lightest': SystemTheme.accentColor.lightest,
|
||||
})),
|
||||
home: const MainPage(),
|
||||
builder: (context, child) {
|
||||
ErrorWidget.builder = (details) {
|
||||
if (details.exception
|
||||
.toString()
|
||||
.contains("RenderFlex overflowed")) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
Log.error("UI", "${details.exception}\n${details.stack}");
|
||||
return Text(details.exception.toString());
|
||||
};
|
||||
if (child == null) {
|
||||
throw "widget is null";
|
||||
}
|
||||
child: DynamicColorBuilder(
|
||||
builder: (light, dark) {
|
||||
final colorScheme =
|
||||
(brightness == Brightness.light ? light : dark) ??
|
||||
md.ColorScheme.fromSeed(
|
||||
seedColor: Colors.blue, brightness: brightness);
|
||||
return FluentApp(
|
||||
navigatorKey: App.rootNavigatorKey,
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'pixes',
|
||||
theme: FluentThemeData(
|
||||
brightness: brightness,
|
||||
fontFamily: App.isWindows ? "Microsoft YaHei UI" : null,
|
||||
accentColor: AccentColor.swatch({
|
||||
'darkest': darken(colorScheme.primary, 30),
|
||||
'darker': darken(colorScheme.primary, 20),
|
||||
'dark': darken(colorScheme.primary, 10),
|
||||
'normal': colorScheme.primary,
|
||||
'light': lighten(colorScheme.primary, 10),
|
||||
'lighter': lighten(colorScheme.primary, 20),
|
||||
'lightest': lighten(colorScheme.primary, 30)
|
||||
}),
|
||||
focusTheme: const FocusThemeData(
|
||||
primaryBorder: BorderSide.none,
|
||||
secondaryBorder: BorderSide.none,
|
||||
)),
|
||||
home: const MainPage(),
|
||||
builder: (context, child) {
|
||||
ErrorWidget.builder = (details) {
|
||||
if (details.exception
|
||||
.toString()
|
||||
.contains("RenderFlex overflowed")) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
Log.error(
|
||||
"UI", "${details.exception}\n${details.stack}");
|
||||
return Text(details.exception.toString());
|
||||
};
|
||||
if (child == null) {
|
||||
throw "widget is null";
|
||||
}
|
||||
|
||||
return OverlayWidget(child);
|
||||
}),
|
||||
String? font;
|
||||
List<String>? fallback;
|
||||
if (App.isLinux || App.isWindows) {
|
||||
font = 'Noto Sans CJK';
|
||||
fallback = [
|
||||
'Segoe UI',
|
||||
'Noto Sans SC',
|
||||
'Noto Sans TC',
|
||||
'Noto Sans',
|
||||
'Microsoft YaHei',
|
||||
'PingFang SC',
|
||||
'Arial',
|
||||
'sans-serif'
|
||||
];
|
||||
}
|
||||
|
||||
Widget widget = MdTheme(
|
||||
data: MdThemeData.from(
|
||||
colorScheme: colorScheme, useMaterial3: true),
|
||||
child: DefaultTextStyle.merge(
|
||||
style: TextStyle(
|
||||
fontFamily: font,
|
||||
fontFamilyFallback: fallback,
|
||||
),
|
||||
child: OverlayWidget(child),
|
||||
),
|
||||
);
|
||||
|
||||
if (App.isWindows) {
|
||||
if (App.windowsVersion == 11) {
|
||||
flutter_acrylic.Window.setEffect(
|
||||
effect: flutter_acrylic.WindowEffect.mica,
|
||||
dark: FluentTheme.of(context).brightness ==
|
||||
Brightness.dark);
|
||||
widget = NavigationPaneTheme(
|
||||
data: const NavigationPaneThemeData(
|
||||
backgroundColor: Colors.transparent,
|
||||
),
|
||||
child: widget,
|
||||
);
|
||||
} /* else if (App.windowsVersion == 10) {
|
||||
flutter_acrylic.Window.setEffect(
|
||||
effect: flutter_acrylic.WindowEffect.acrylic,
|
||||
dark: FluentTheme.of(context).brightness ==
|
||||
Brightness.dark);
|
||||
widget = NavigationPaneTheme(
|
||||
data: NavigationPaneThemeData(
|
||||
backgroundColor: FluentTheme.of(context)
|
||||
.micaBackgroundColor
|
||||
.withOpacity(0.72),
|
||||
),
|
||||
child: widget,
|
||||
);
|
||||
}*/
|
||||
}
|
||||
|
||||
return KeyEventListener(child: widget);
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
int _floatToInt8(double x) {
|
||||
return (x * 255.0).round() & 0xff;
|
||||
}
|
||||
|
||||
Color darken(Color c, [int percent = 10]) {
|
||||
assert(1 <= percent && percent <= 100);
|
||||
var f = 1 - percent / 100;
|
||||
return Color.fromARGB(
|
||||
_floatToInt8(c.a),
|
||||
_floatToInt8(c.r * f),
|
||||
_floatToInt8(c.g * f),
|
||||
_floatToInt8(c.b * f),
|
||||
);
|
||||
}
|
||||
|
||||
Color lighten(Color c, [int percent = 10]) {
|
||||
assert(1 <= percent && percent <= 100);
|
||||
var p = percent / 100;
|
||||
return Color.fromARGB(
|
||||
_floatToInt8(c.a),
|
||||
_floatToInt8(c.r + (1 - c.r) * p),
|
||||
_floatToInt8(c.g + (1 - c.g) * p),
|
||||
_floatToInt8(c.b + (1 - c.b) * p),
|
||||
);
|
||||
}
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
@@ -109,12 +110,53 @@ class AppDio extends DioForNative {
|
||||
CancelToken? cancelToken,
|
||||
Options? options,
|
||||
ProgressCallback? onSendProgress,
|
||||
ProgressCallback? onReceiveProgress}) {
|
||||
ProgressCallback? onReceiveProgress}) async{
|
||||
if (!isInitialized) {
|
||||
isInitialized = true;
|
||||
interceptors.add(MyLogInterceptor());
|
||||
}
|
||||
return super.request(path,
|
||||
if(T == Map<String, dynamic>) {
|
||||
var res = await super.request<String>(path,
|
||||
data: data,
|
||||
queryParameters: queryParameters,
|
||||
cancelToken: cancelToken,
|
||||
options: options,
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress);
|
||||
if(res.data == null) {
|
||||
return Response(
|
||||
data: null,
|
||||
requestOptions: res.requestOptions,
|
||||
statusCode: res.statusCode,
|
||||
statusMessage: res.statusMessage,
|
||||
isRedirect: res.isRedirect,
|
||||
redirects: res.redirects,
|
||||
extra: res.extra,
|
||||
headers: res.headers
|
||||
);
|
||||
}
|
||||
try {
|
||||
var json = jsonDecode(res.data!);
|
||||
return Response(
|
||||
data: json,
|
||||
requestOptions: res.requestOptions,
|
||||
statusCode: res.statusCode,
|
||||
statusMessage: res.statusMessage,
|
||||
isRedirect: res.isRedirect,
|
||||
redirects: res.redirects,
|
||||
extra: res.extra,
|
||||
headers: res.headers
|
||||
);
|
||||
}
|
||||
catch(e) {
|
||||
var data = res.data!;
|
||||
if(data.length > 50) {
|
||||
data = "${data.substring(0, 50)}...";
|
||||
}
|
||||
throw "Failed to decode response: $e\n$data";
|
||||
}
|
||||
}
|
||||
return super.request<T>(path,
|
||||
data: data,
|
||||
queryParameters: queryParameters,
|
||||
cancelToken: cancelToken,
|
||||
@@ -125,23 +167,22 @@ class AppDio extends DioForNative {
|
||||
}
|
||||
|
||||
void setSystemProxy() {
|
||||
HttpOverrides.global = _ProxyHttpOverrides()
|
||||
..findProxy(Uri());
|
||||
HttpOverrides.global = _ProxyHttpOverrides()..findProxy(Uri());
|
||||
}
|
||||
|
||||
class _ProxyHttpOverrides extends HttpOverrides {
|
||||
String proxy = "DIRECT";
|
||||
|
||||
String findProxy(Uri uri) {
|
||||
var haveUserProxy = appdata.settings["proxy"] != null
|
||||
&& appdata.settings["proxy"].toString().isNotEmpty;
|
||||
if(!App.isLinux && !haveUserProxy){
|
||||
var haveUserProxy = appdata.settings["proxy"] != null &&
|
||||
appdata.settings["proxy"].toString().removeAllBlank.isNotEmpty;
|
||||
if (!App.isLinux && !haveUserProxy) {
|
||||
var channel = const MethodChannel("pixes/proxy");
|
||||
channel.invokeMethod("getProxy").then((value) {
|
||||
if(value.toString().toLowerCase() == "no proxy"){
|
||||
if (value.toString().toLowerCase() == "no proxy") {
|
||||
proxy = "DIRECT";
|
||||
} else {
|
||||
if(proxy.contains("https")){
|
||||
if (proxy.contains("https")) {
|
||||
var proxies = value.split(";");
|
||||
for (String proxy in proxies) {
|
||||
proxy = proxy.removeAllBlank;
|
||||
@@ -154,10 +195,20 @@ class _ProxyHttpOverrides extends HttpOverrides {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if(haveUserProxy){
|
||||
if (haveUserProxy) {
|
||||
proxy = "PROXY ${appdata.settings["proxy"]}";
|
||||
}
|
||||
}
|
||||
// check validation
|
||||
if (proxy.startsWith("PROXY")) {
|
||||
var uri = proxy.replaceFirst("PROXY", "").removeAllBlank;
|
||||
if (!uri.startsWith("http")) {
|
||||
uri += "http://";
|
||||
}
|
||||
if (!uri.isURL) {
|
||||
return "DIRECT";
|
||||
}
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
|
||||
|
@@ -131,6 +131,8 @@ class DownloadingTask {
|
||||
subPathPatten = subPathPatten.replaceAll(r"${title}", illust.title);
|
||||
subPathPatten = subPathPatten.replaceAll(r"${author}", illust.author.name);
|
||||
subPathPatten = subPathPatten.replaceAll(r"${index}", index.toString());
|
||||
subPathPatten = subPathPatten.replaceAll(r"${page}",
|
||||
illust.images.length == 1 ? "" : "-p$index");
|
||||
subPathPatten = subPathPatten.replaceAll(r"${ext}", ext);
|
||||
subPathPatten = subPathPatten.replaceAll(r"${AI}", illust.isAi ? "AI" : "");
|
||||
List<String> extractTags(String input) {
|
||||
@@ -163,6 +165,10 @@ class DownloadingTask {
|
||||
_stop = false;
|
||||
_download();
|
||||
}
|
||||
|
||||
void pause() {
|
||||
_stop = true;
|
||||
}
|
||||
}
|
||||
|
||||
class DownloadManager {
|
||||
@@ -276,8 +282,20 @@ class DownloadManager {
|
||||
|
||||
int get maxConcurrentTasks => appdata.settings["maxParallels"];
|
||||
|
||||
bool _paused = false;
|
||||
|
||||
bool get paused => _paused;
|
||||
|
||||
void pause() {
|
||||
_paused = true;
|
||||
for(var task in tasks) {
|
||||
task.pause();
|
||||
}
|
||||
}
|
||||
|
||||
void run() {
|
||||
_loop ??= Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
if(_paused) return;
|
||||
_bytesPerSecond = _currentBytes;
|
||||
_currentBytes = 0;
|
||||
uiUpdateCallback?.call();
|
||||
@@ -306,7 +324,7 @@ class DownloadManager {
|
||||
where illust_id = ?;
|
||||
''', [illust.illustId]);
|
||||
for(var image in images) {
|
||||
File(image["path"] as String).deleteIfExists();
|
||||
File(image["path"] as String).deleteIgnoreError();
|
||||
}
|
||||
_db.execute('''
|
||||
delete from images
|
||||
@@ -349,4 +367,28 @@ class DownloadManager {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> checkAndClearInvalidItems() async{
|
||||
var illusts = listAll();
|
||||
var shouldDelete = <DownloadedIllust>[];
|
||||
for(var item in illusts) {
|
||||
var paths = getImagePaths(item.illustId);
|
||||
var validPaths = <String>[];
|
||||
for(var path in paths) {
|
||||
if(await File(path).exists()) {
|
||||
validPaths.add(path);
|
||||
}
|
||||
}
|
||||
if(validPaths.isEmpty) {
|
||||
shouldDelete.add(item);
|
||||
}
|
||||
}
|
||||
for(var item in shouldDelete) {
|
||||
delete(item);
|
||||
}
|
||||
}
|
||||
|
||||
void resume() {
|
||||
_paused = false;
|
||||
}
|
||||
}
|
@@ -121,15 +121,14 @@ class UserDetails {
|
||||
pawooUrl = json['profile']['pawoo_url'];
|
||||
}
|
||||
|
||||
class IllustAuthor {
|
||||
class Author {
|
||||
final int id;
|
||||
final String name;
|
||||
final String account;
|
||||
final String avatar;
|
||||
bool isFollowed;
|
||||
|
||||
IllustAuthor(
|
||||
this.id, this.name, this.account, this.avatar, this.isFollowed);
|
||||
Author(this.id, this.name, this.account, this.avatar, this.isFollowed);
|
||||
}
|
||||
|
||||
class Tag {
|
||||
@@ -153,6 +152,10 @@ class Tag {
|
||||
|
||||
@override
|
||||
int get hashCode => name.hashCode;
|
||||
|
||||
static Tag fromJson(Map<String, dynamic> json) {
|
||||
return Tag(json['name'] ?? "", json['translated_name']);
|
||||
}
|
||||
}
|
||||
|
||||
class IllustImage {
|
||||
@@ -171,9 +174,9 @@ class Illust {
|
||||
final List<IllustImage> images;
|
||||
final String caption;
|
||||
final int restrict;
|
||||
final IllustAuthor author;
|
||||
final Author author;
|
||||
final List<Tag> tags;
|
||||
final String createDate;
|
||||
final DateTime createDate;
|
||||
final int pageCount;
|
||||
final int width;
|
||||
final int height;
|
||||
@@ -182,6 +185,7 @@ class Illust {
|
||||
bool isBookmarked;
|
||||
final bool isAi;
|
||||
final bool isUgoira;
|
||||
final bool isBlocked;
|
||||
|
||||
bool get isR18 => tags.contains(const Tag("R-18", null));
|
||||
|
||||
@@ -211,7 +215,7 @@ class Illust {
|
||||
}()),
|
||||
caption = json['caption'],
|
||||
restrict = json['restrict'],
|
||||
author = IllustAuthor(
|
||||
author = Author(
|
||||
json['user']['id'],
|
||||
json['user']['name'],
|
||||
json['user']['account'],
|
||||
@@ -220,7 +224,7 @@ class Illust {
|
||||
tags = (json['tags'] as List)
|
||||
.map((e) => Tag(e['name'], e['translated_name']))
|
||||
.toList(),
|
||||
createDate = json['create_date'],
|
||||
createDate = DateTime.parse(json['create_date']),
|
||||
pageCount = json['page_count'],
|
||||
width = json['width'],
|
||||
height = json['height'],
|
||||
@@ -228,7 +232,8 @@ class Illust {
|
||||
totalBookmarks = json['total_bookmarks'],
|
||||
isBookmarked = json['is_bookmarked'],
|
||||
isAi = json['illust_ai_type'] == 2,
|
||||
isUgoira = json['type'] == "ugoira";
|
||||
isUgoira = json['type'] == "ugoira",
|
||||
isBlocked = json['is_muted'] ?? false;
|
||||
}
|
||||
|
||||
class TrendingTag {
|
||||
@@ -250,11 +255,11 @@ enum KeywordMatchType {
|
||||
@override
|
||||
toString() => text;
|
||||
|
||||
String toParam() => switch(this) {
|
||||
KeywordMatchType.tagsPartialMatches => "partial_match_for_tags",
|
||||
KeywordMatchType.tagsExactMatch => "exact_match_for_tags",
|
||||
KeywordMatchType.titleOrDescriptionSearch => "title_and_caption"
|
||||
};
|
||||
String toParam() => switch (this) {
|
||||
KeywordMatchType.tagsPartialMatches => "partial_match_for_tags",
|
||||
KeywordMatchType.tagsExactMatch => "exact_match_for_tags",
|
||||
KeywordMatchType.titleOrDescriptionSearch => "title_and_caption"
|
||||
};
|
||||
}
|
||||
|
||||
enum FavoriteNumber {
|
||||
@@ -273,9 +278,11 @@ enum FavoriteNumber {
|
||||
const FavoriteNumber(this.number);
|
||||
|
||||
@override
|
||||
toString() => this == FavoriteNumber.unlimited ? "Unlimited" : "$number Bookmarks";
|
||||
toString() =>
|
||||
this == FavoriteNumber.unlimited ? "Unlimited" : "$number Bookmarks";
|
||||
|
||||
String toParam() => this == FavoriteNumber.unlimited ? "" : " ${number}users入り";
|
||||
String toParam() =>
|
||||
this == FavoriteNumber.unlimited ? "" : " ${number}users入り";
|
||||
}
|
||||
|
||||
enum SearchSort {
|
||||
@@ -288,37 +295,35 @@ enum SearchSort {
|
||||
bool get isPremium => appdata.account?.user.isPremium == true;
|
||||
|
||||
static List<SearchSort> get availableValues => [
|
||||
SearchSort.newToOld,
|
||||
SearchSort.oldToNew,
|
||||
SearchSort.popular,
|
||||
if(appdata.account?.user.isPremium == true)
|
||||
SearchSort.popularMale,
|
||||
if(appdata.account?.user.isPremium == true)
|
||||
SearchSort.popularFemale
|
||||
];
|
||||
SearchSort.newToOld,
|
||||
SearchSort.oldToNew,
|
||||
SearchSort.popular,
|
||||
if (appdata.account?.user.isPremium == true) SearchSort.popularMale,
|
||||
if (appdata.account?.user.isPremium == true) SearchSort.popularFemale
|
||||
];
|
||||
|
||||
@override
|
||||
toString() {
|
||||
if(this == SearchSort.popular) {
|
||||
if (this == SearchSort.popular) {
|
||||
return isPremium ? "Popular" : "Popular(limited)";
|
||||
} else if(this == SearchSort.newToOld) {
|
||||
} else if (this == SearchSort.newToOld) {
|
||||
return "New to old";
|
||||
} else if(this == SearchSort.oldToNew){
|
||||
} else if (this == SearchSort.oldToNew) {
|
||||
return "Old to new";
|
||||
} else if(this == SearchSort.popularMale){
|
||||
} else if (this == SearchSort.popularMale) {
|
||||
return "Popular(Male)";
|
||||
} else {
|
||||
return "Popular(Female)";
|
||||
}
|
||||
}
|
||||
|
||||
String toParam() => switch(this) {
|
||||
SearchSort.newToOld => "date_desc",
|
||||
SearchSort.oldToNew => "date_asc",
|
||||
SearchSort.popular => "popular_desc",
|
||||
SearchSort.popularMale => "popular_male_desc",
|
||||
SearchSort.popularFemale => "popular_female_desc",
|
||||
};
|
||||
String toParam() => switch (this) {
|
||||
SearchSort.newToOld => "date_desc",
|
||||
SearchSort.oldToNew => "date_asc",
|
||||
SearchSort.popular => "popular_desc",
|
||||
SearchSort.popularMale => "popular_male_desc",
|
||||
SearchSort.popularFemale => "popular_female_desc",
|
||||
};
|
||||
}
|
||||
|
||||
enum AgeLimit {
|
||||
@@ -333,11 +338,11 @@ enum AgeLimit {
|
||||
@override
|
||||
toString() => text;
|
||||
|
||||
String toParam() => switch(this) {
|
||||
AgeLimit.unlimited => "",
|
||||
AgeLimit.allAges => " -R-18",
|
||||
AgeLimit.r18 => "R-18",
|
||||
};
|
||||
String toParam() => switch (this) {
|
||||
AgeLimit.unlimited => "",
|
||||
AgeLimit.allAges => " -R-18",
|
||||
AgeLimit.r18 => "R-18",
|
||||
};
|
||||
}
|
||||
|
||||
class SearchOptions {
|
||||
@@ -369,17 +374,20 @@ class UserPreview {
|
||||
final String avatar;
|
||||
bool isFollowed;
|
||||
final bool isBlocking;
|
||||
final List<Illust> artworks;
|
||||
|
||||
UserPreview(this.id, this.name, this.account, this.avatar, this.isFollowed,
|
||||
this.isBlocking);
|
||||
this.isBlocking, this.artworks);
|
||||
|
||||
UserPreview.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
name = json['name'],
|
||||
account = json['account'],
|
||||
avatar = json['profile_image_urls']['medium'],
|
||||
isFollowed = json['is_followed'],
|
||||
isBlocking = json['is_access_blocking_user'] ?? false;
|
||||
: id = json['user']['id'],
|
||||
name = json['user']['name'],
|
||||
account = json['user']['account'],
|
||||
avatar = json['user']['profile_image_urls']['medium'],
|
||||
isFollowed = json['user']['is_followed'],
|
||||
isBlocking = json['user']['is_access_blocking_user'] ?? false,
|
||||
artworks =
|
||||
(json['illusts'] as List).map((e) => Illust.fromJson(e)).toList();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -402,7 +410,7 @@ class UserPreview {
|
||||
}
|
||||
}
|
||||
*/
|
||||
class Comment{
|
||||
class Comment {
|
||||
final String id;
|
||||
final String comment;
|
||||
final DateTime date;
|
||||
@@ -419,6 +427,129 @@ class Comment{
|
||||
uid = json['user']['id'].toString(),
|
||||
name = json['user']['name'],
|
||||
avatar = json['user']['profile_image_urls']['medium'],
|
||||
hasReplies = json['has_replies'],
|
||||
hasReplies = json['has_replies'] ?? false,
|
||||
stampUrl = json['stamp']?['stamp_url'];
|
||||
}
|
||||
|
||||
/*
|
||||
{
|
||||
"id": 20741342,
|
||||
"title": "中身が一般人のやつがれくん",
|
||||
"caption": "なんか思いついたので書いてみた。<br />よくある芥川成り代わり。<br />3年くらい前の書きかけのやつをサルベージ。<br />じっくりは書いてないので抜け抜け。<br /><br />デイリー1位ありがとうございます✨<br /><br />※※※※※※※※<br />※※※※※※※※<br /><br />以下読了後推奨の蛇足<br /><br />「芥川くん」<br />「なんですかボス」<br />「君は将来的にどんな地位につきたいとかある?」<br />「僕はしがない一構成員ゆえ」<br />「ほら幹部とか隊長とか人事部とかさ。君あれこれオールマイティにできるから希望を聞いておこうと思って」<br />「ございます」<br />「なにかな?」<br />「僕は将来的にポートマフィア直営のいちじく農家になりたいと思います」<br />「なんて?」<br />「さらに、ゆくゆくはいちじく農家兼、いちじくの素晴らしさを世に知らしめるポートマフィア直営いちじくレストランを開きたいと」<br />「なんて???」",
|
||||
"restrict": 0,
|
||||
"x_restrict": 0,
|
||||
"is_original": false,
|
||||
"image_urls": {
|
||||
"square_medium": "https://i.pximg.net/c/128x128/novel-cover-master/img/2023/09/27/16/14/45/ci20741342_db401e9b27afbf96f772d30759e1d104_square1200.jpg",
|
||||
"medium": "https://i.pximg.net/c/176x352/novel-cover-master/img/2023/09/27/16/14/45/ci20741342_db401e9b27afbf96f772d30759e1d104_master1200.jpg",
|
||||
"large": "https://i.pximg.net/c/240x480_80/novel-cover-master/img/2023/09/27/16/14/45/ci20741342_db401e9b27afbf96f772d30759e1d104_master1200.jpg"
|
||||
},
|
||||
"create_date": "2023-09-27T16:14:45+09:00",
|
||||
"tags": [
|
||||
{
|
||||
"name": "文スト夢",
|
||||
"translated_name": "Bungo Stray Dogs original/self-insert",
|
||||
"added_by_uploaded_user": true
|
||||
},
|
||||
{
|
||||
"name": "成り代わり",
|
||||
"translated_name": "取代即有角色",
|
||||
"added_by_uploaded_user": true
|
||||
},
|
||||
],
|
||||
"page_count": 6,
|
||||
"text_length": 12550,
|
||||
"user": {
|
||||
"id": 9275134,
|
||||
"name": "もろろ",
|
||||
"account": "sleepinglife",
|
||||
"profile_image_urls": {
|
||||
"medium": "https://s.pximg.net/common/images/no_profile.png"
|
||||
},
|
||||
"is_followed": false
|
||||
},
|
||||
"series": {
|
||||
"id": 11897059,
|
||||
"title": "文スト夢"
|
||||
},
|
||||
"is_bookmarked": false,
|
||||
"total_bookmarks": 8099,
|
||||
"total_view": 76112,
|
||||
"visible": true,
|
||||
"total_comments": 146,
|
||||
"is_muted": false,
|
||||
"is_mypixiv_only": false,
|
||||
"is_x_restricted": false,
|
||||
"novel_ai_type": 1
|
||||
}
|
||||
*/
|
||||
class Novel {
|
||||
final int id;
|
||||
final String title;
|
||||
final String caption;
|
||||
final bool isOriginal;
|
||||
final String image;
|
||||
final DateTime createDate;
|
||||
final List<Tag> tags;
|
||||
final int pages;
|
||||
final int length;
|
||||
final Author author;
|
||||
final int? seriesId;
|
||||
final String? seriesTitle;
|
||||
bool isBookmarked;
|
||||
final int totalBookmarks;
|
||||
final int totalViews;
|
||||
final int commentsCount;
|
||||
final bool isAi;
|
||||
|
||||
Novel.fromJson(Map<String, dynamic> json)
|
||||
: id = json["id"],
|
||||
title = json["title"],
|
||||
caption = json["caption"],
|
||||
isOriginal = json["is_original"],
|
||||
image = json["image_urls"]["large"] ??
|
||||
json["image_urls"]["medium"] ??
|
||||
json["image_urls"]["square_medium"] ??
|
||||
"",
|
||||
createDate = DateTime.parse(json["create_date"]),
|
||||
tags = (json['tags'] as List)
|
||||
.map((e) => Tag(e['name'], e['translated_name']))
|
||||
.toList(),
|
||||
pages = json["page_count"],
|
||||
length = json["text_length"],
|
||||
author = Author(
|
||||
json['user']['id'],
|
||||
json['user']['name'],
|
||||
json['user']['account'],
|
||||
json['user']['profile_image_urls']['medium'],
|
||||
json['user']['is_followed'] ?? false),
|
||||
seriesId = json["series"]?["id"],
|
||||
seriesTitle = json["series"]?["title"],
|
||||
isBookmarked = json["is_bookmarked"],
|
||||
totalBookmarks = json["total_bookmarks"],
|
||||
totalViews = json["total_view"],
|
||||
commentsCount = json["total_comments"],
|
||||
isAi = json["novel_ai_type"] == 2;
|
||||
}
|
||||
|
||||
class MuteList {
|
||||
List<Tag> tags;
|
||||
|
||||
List<Author> authors;
|
||||
|
||||
int limit;
|
||||
|
||||
MuteList(this.tags, this.authors, this.limit);
|
||||
|
||||
static MuteList? fromJson(Map<String, dynamic> data) {
|
||||
return MuteList(
|
||||
(data['muted_tags'] as List)
|
||||
.map((e) => Tag(e['tag'], e['tag_translation']))
|
||||
.toList(),
|
||||
(data['muted_users'] as List)
|
||||
.map((e) => Author(e['user_id'], e['user_name'], e['user_account'],
|
||||
e['user_profile_image_urls']['medium'], false))
|
||||
.toList(),
|
||||
data['mute_limit_count']);
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@ import 'models.dart';
|
||||
export 'models.dart';
|
||||
export 'res.dart';
|
||||
|
||||
part 'novel.dart';
|
||||
|
||||
class Network {
|
||||
static const hashSalt =
|
||||
"28c1fdd170a5204386cb1313c7077b34f83e4aaf4aa829ce78c231e05b0bae2c";
|
||||
@@ -108,9 +110,9 @@ class Network {
|
||||
contentType: Headers.formUrlEncodedContentType,
|
||||
validateStatus: (i) => true,
|
||||
headers: headers));
|
||||
if(res.statusCode != 200) {
|
||||
if (res.statusCode != 200) {
|
||||
var data = res.data ?? "";
|
||||
if(data.contains("Invalid refresh token")) {
|
||||
if (data.contains("Invalid refresh token")) {
|
||||
throw "Failed to refresh token. Please log out.";
|
||||
}
|
||||
}
|
||||
@@ -132,8 +134,7 @@ class Network {
|
||||
}
|
||||
final res = await dio.get<Map<String, dynamic>>(path,
|
||||
queryParameters: query,
|
||||
options:
|
||||
Options(headers: headers, validateStatus: (status) => true));
|
||||
options: Options(headers: headers, validateStatus: (status) => true));
|
||||
if (res.statusCode == 200) {
|
||||
return Res(res.data!);
|
||||
} else if (res.statusCode == 400) {
|
||||
@@ -159,6 +160,52 @@ class Network {
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<String>> apiGetPlain(String path,
|
||||
{Map<String, dynamic>? query}) async {
|
||||
try {
|
||||
if (!path.startsWith("http")) {
|
||||
path = "$baseUrl$path";
|
||||
}
|
||||
final res = await dio.get<String>(path,
|
||||
queryParameters: query,
|
||||
options: Options(headers: headers, validateStatus: (status) => true));
|
||||
if (res.statusCode == 200) {
|
||||
return Res(res.data!);
|
||||
} else if (res.statusCode == 400) {
|
||||
if (res.data.toString().contains("Access Token")) {
|
||||
var refresh = await refreshToken();
|
||||
if (refresh.success) {
|
||||
return apiGetPlain(path, query: query);
|
||||
} else {
|
||||
return Res.error(refresh.errorMessage);
|
||||
}
|
||||
} else {
|
||||
return Res.error("Invalid Status Code: ${res.statusCode}");
|
||||
}
|
||||
} else {
|
||||
return Res.error("Invalid Status Code: ${res.statusCode}");
|
||||
}
|
||||
} catch (e, s) {
|
||||
Log.error("Network", "$e\n$s");
|
||||
return Res.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
String? encodeFormData(Map<String, dynamic>? data) {
|
||||
if (data == null) return null;
|
||||
StringBuffer buffer = StringBuffer();
|
||||
data.forEach((key, value) {
|
||||
if (value is List) {
|
||||
for (var element in value) {
|
||||
buffer.write("$key[]=$element&");
|
||||
}
|
||||
} else {
|
||||
buffer.write("$key=$value&");
|
||||
}
|
||||
});
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
Future<Res<Map<String, dynamic>>> apiPost(String path,
|
||||
{Map<String, dynamic>? query, Map<String, dynamic>? data}) async {
|
||||
try {
|
||||
@@ -167,7 +214,7 @@ class Network {
|
||||
}
|
||||
final res = await dio.post<Map<String, dynamic>>(path,
|
||||
queryParameters: query,
|
||||
data: data,
|
||||
data: encodeFormData(data),
|
||||
options: Options(
|
||||
headers: headers,
|
||||
validateStatus: (status) => true,
|
||||
@@ -208,13 +255,15 @@ class Network {
|
||||
}
|
||||
}
|
||||
|
||||
static const recommendationUrl =
|
||||
"/v1/illust/recommended?include_privacy_policy=true&filter=for_android&include_ranking_illusts=true";
|
||||
|
||||
Future<Res<List<Illust>>> getRecommendedIllusts() async {
|
||||
var res = await apiGet(
|
||||
"/v1/illust/recommended?include_privacy_policy=true&filter=for_android&include_ranking_illusts=true");
|
||||
var res = await apiGet(recommendationUrl);
|
||||
if (res.success) {
|
||||
return Res((res.data["illusts"] as List)
|
||||
.map((e) => Illust.fromJson(e))
|
||||
.toList());
|
||||
return Res(
|
||||
(res.data["illusts"] as List).map((e) => Illust.fromJson(e)).toList(),
|
||||
subData: recommendationUrl);
|
||||
} else {
|
||||
return Res.error(res.errorMessage);
|
||||
}
|
||||
@@ -233,6 +282,19 @@ class Network {
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<List<Illust>>> getUserBookmarks(String uid,
|
||||
[String? nextUrl]) async {
|
||||
var res = await apiGet(
|
||||
nextUrl ?? "/v1/user/bookmarks/illust?user_id=$uid&restrict=public");
|
||||
if (res.success) {
|
||||
return Res(
|
||||
(res.data["illusts"] as List).map((e) => Illust.fromJson(e)).toList(),
|
||||
subData: res.data["next_url"]);
|
||||
} else {
|
||||
return Res.error(res.errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<bool>> addBookmark(String id, String method,
|
||||
[String type = "public"]) async {
|
||||
var res = method == "add"
|
||||
@@ -298,7 +360,7 @@ class Network {
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<List<Illust>>> getIllustsWithNextUrl(String nextUrl) async{
|
||||
Future<Res<List<Illust>>> getIllustsWithNextUrl(String nextUrl) async {
|
||||
var res = await apiGet(nextUrl);
|
||||
if (res.success) {
|
||||
return Res(
|
||||
@@ -309,20 +371,25 @@ class Network {
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<List<UserPreview>>> searchUsers(String keyword, [String? nextUrl]) async{
|
||||
var path = nextUrl ?? "/v1/search/user?filter=for_android&word=${Uri.encodeComponent(keyword)}";
|
||||
Future<Res<List<UserPreview>>> searchUsers(String keyword,
|
||||
[String? nextUrl]) async {
|
||||
var path = nextUrl ??
|
||||
"/v1/search/user?filter=for_android&word=${Uri.encodeComponent(keyword)}";
|
||||
var res = await apiGet(path);
|
||||
if (res.success) {
|
||||
return Res(
|
||||
(res.data["user_previews"] as List).map((e) => UserPreview.fromJson(e["user"])).toList(),
|
||||
(res.data["user_previews"] as List)
|
||||
.map((e) => UserPreview.fromJson(e))
|
||||
.toList(),
|
||||
subData: res.data["next_url"]);
|
||||
} else {
|
||||
return Res.error(res.errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<List<Illust>>> getUserIllusts(String uid) async {
|
||||
var res = await apiGet("/v1/user/illusts?filter=for_android&user_id=$uid&type=illust");
|
||||
Future<Res<List<Illust>>> getUserIllusts(String uid, String? type) async {
|
||||
var res = await apiGet(
|
||||
"/v1/user/illusts?filter=for_android&user_id=$uid${type != null ? "&type=$type" : ""}");
|
||||
if (res.success) {
|
||||
return Res(
|
||||
(res.data["illusts"] as List).map((e) => Illust.fromJson(e)).toList(),
|
||||
@@ -332,19 +399,24 @@ class Network {
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<List<UserPreview>>> getFollowing(String uid, String type, [String? nextUrl]) async {
|
||||
var path = nextUrl ?? "/v1/user/following?filter=for_android&user_id=$uid&restrict=$type";
|
||||
Future<Res<List<UserPreview>>> getFollowing(String uid, String type,
|
||||
[String? nextUrl]) async {
|
||||
var path = nextUrl ??
|
||||
"/v1/user/following?filter=for_android&user_id=$uid&restrict=$type";
|
||||
var res = await apiGet(path);
|
||||
if (res.success) {
|
||||
return Res(
|
||||
(res.data["user_previews"] as List).map((e) => UserPreview.fromJson(e["user"])).toList(),
|
||||
(res.data["user_previews"] as List)
|
||||
.map((e) => UserPreview.fromJson(e))
|
||||
.toList(),
|
||||
subData: res.data["next_url"]);
|
||||
} else {
|
||||
return Res.error(res.errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<List<Illust>>> getFollowingArtworks(String restrict, [String? nextUrl]) async {
|
||||
Future<Res<List<Illust>>> getFollowingArtworks(String restrict,
|
||||
[String? nextUrl]) async {
|
||||
var res = await apiGet(nextUrl ?? "/v2/illust/follow?restrict=$restrict");
|
||||
if (res.success) {
|
||||
return Res(
|
||||
@@ -359,7 +431,9 @@ class Network {
|
||||
var res = await apiGet("/v1/user/recommended?filter=for_android");
|
||||
if (res.success) {
|
||||
return Res(
|
||||
(res.data["user_previews"] as List).map((e) => UserPreview.fromJson(e["user"])).toList(),
|
||||
(res.data["user_previews"] as List)
|
||||
.map((e) => UserPreview.fromJson(e))
|
||||
.toList(),
|
||||
subData: res.data["next_url"]);
|
||||
} else {
|
||||
return Res.error(res.errorMessage);
|
||||
@@ -368,7 +442,8 @@ class Network {
|
||||
|
||||
/// mode: day, week, month, day_male, day_female, week_original, week_rookie, day_manga, week_manga, month_manga, day_r18_manga, day_r18
|
||||
Future<Res<List<Illust>>> getRanking(String mode, [String? nextUrl]) async {
|
||||
var res = await apiGet(nextUrl ?? "/v1/illust/ranking?filter=for_android&mode=$mode");
|
||||
var res = await apiGet(
|
||||
nextUrl ?? "/v1/illust/ranking?filter=for_android&mode=$mode");
|
||||
if (res.success) {
|
||||
return Res(
|
||||
(res.data["illusts"] as List).map((e) => Illust.fromJson(e)).toList(),
|
||||
@@ -382,7 +457,9 @@ class Network {
|
||||
var res = await apiGet(nextUrl ?? "/v3/illust/comments?illust_id=$id");
|
||||
if (res.success) {
|
||||
return Res(
|
||||
(res.data["comments"] as List).map((e) => Comment.fromJson(e)).toList(),
|
||||
(res.data["comments"] as List)
|
||||
.map((e) => Comment.fromJson(e))
|
||||
.toList(),
|
||||
subData: res.data["next_url"]);
|
||||
} else {
|
||||
return Res.error(res.errorMessage);
|
||||
@@ -409,7 +486,8 @@ class Network {
|
||||
}
|
||||
|
||||
Future<Res<List<Illust>>> getRecommendedMangas() async {
|
||||
var res = await apiGet("/v1/manga/recommended?filter=for_android&include_ranking_illusts=true&include_privacy_policy=true");
|
||||
var res = await apiGet(
|
||||
"/v1/manga/recommended?filter=for_android&include_ranking_illusts=true&include_privacy_policy=true");
|
||||
if (res.success) {
|
||||
return Res(
|
||||
(res.data["illusts"] as List).map((e) => Illust.fromJson(e)).toList(),
|
||||
@@ -421,38 +499,97 @@ class Network {
|
||||
|
||||
Future<Res<List<Illust>>> getHistory(int page) async {
|
||||
String param = "";
|
||||
if(page > 1) {
|
||||
param = "?offset=${30*(page-1)}";
|
||||
if (page > 1) {
|
||||
param = "?offset=${30 * (page - 1)}";
|
||||
}
|
||||
var res = await apiGet("/v1/user/browsing-history/illusts$param");
|
||||
if (res.success) {
|
||||
return Res((res.data["illusts"] as List)
|
||||
.map((e) => Illust.fromJson(e)).toList());
|
||||
.map((e) => Illust.fromJson(e))
|
||||
.toList());
|
||||
} else {
|
||||
return Res.error(res.errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<Tag>> getMutedTags() async {
|
||||
Future<Res<MuteList>> getMuteList() async {
|
||||
var res = await apiGet("/v1/mute/list");
|
||||
if (res.success) {
|
||||
return res.data["mute_tags"].map<Tag>((e) =>
|
||||
Tag(e["tag"]["name"], e["tag"]["translated_name"]))
|
||||
.toList();
|
||||
return Res(MuteList.fromJson(res.data));
|
||||
} else {
|
||||
return [];
|
||||
return Res.error(res.errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<bool>> muteTags(List<String> muteTags, List<String> unmuteTags) async {
|
||||
var res = await apiPost("/v1/mute/edit", data: {
|
||||
"add_tags": muteTags,
|
||||
"delete_tags": unmuteTags
|
||||
});
|
||||
Future<Res<bool>> editMute(List<String> addTags, List<String> addUsers,
|
||||
List<String> deleteTags, List<String> deleteUsers) async {
|
||||
var res = await apiPost("/v1/mute/edit",
|
||||
data: {
|
||||
"add_tags": addTags,
|
||||
"add_user_ids": addUsers,
|
||||
"delete_tags": deleteTags,
|
||||
"delete_user_ids": deleteUsers
|
||||
}..removeWhere((key, value) => value.isEmpty));
|
||||
if (res.success) {
|
||||
return const Res(true);
|
||||
} else {
|
||||
return Res.fromErrorRes(res);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<List<UserPreview>>> relatedUsers(String id) async {
|
||||
var res =
|
||||
await apiGet("/v1/user/related?filter=for_android&seed_user_id=$id");
|
||||
if (res.success) {
|
||||
return Res((res.data["user_previews"] as List)
|
||||
.map((e) => UserPreview.fromJson(e))
|
||||
.toList());
|
||||
} else {
|
||||
return Res.error(res.errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<List<Illust>>> relatedIllusts(String id) async {
|
||||
var res =
|
||||
await apiGet("/v2/illust/related?filter=for_android&illust_id=$id");
|
||||
if (res.success) {
|
||||
return Res((res.data["illusts"] as List)
|
||||
.map((e) => Illust.fromJson(e))
|
||||
.toList());
|
||||
} else {
|
||||
return Res.error(res.errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<String>> getNovelImage(String novelId, String imageId) async {
|
||||
var res = await apiGetPlain(
|
||||
"/web/v1/novel/image?novel_id=$novelId&uploaded_image_id=$imageId");
|
||||
if (res.success) {
|
||||
var html = res.data;
|
||||
int start = html.indexOf('<img src="') + 10;
|
||||
int end = html.indexOf('"', start);
|
||||
return Res(html.substring(start, end));
|
||||
} else {
|
||||
return Res.error(res.errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<bool>> sendHistory(List<int> ids) async {
|
||||
var res = await apiPost("/v2/user/browsing-history/illust/add",
|
||||
data: {"illust_ids": ids});
|
||||
if (res.success) {
|
||||
return const Res(true);
|
||||
} else {
|
||||
return Res.fromErrorRes(res);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<List<Tag>>> getAutoCompleteTags(String keyword) async {
|
||||
var res = await apiGet("/v2/search/autocomplete?merge_plain_keyword_results=true&word=${Uri.encodeComponent(keyword)}");
|
||||
if (res.success) {
|
||||
return Res((res.data["tags"] as List).map((e) => Tag.fromJson(e)).toList());
|
||||
} else {
|
||||
return Res.error(res.errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
165
lib/network/novel.dart
Normal file
@@ -0,0 +1,165 @@
|
||||
part of "network.dart";
|
||||
|
||||
extension NovelExt on Network {
|
||||
Future<Res<List<Novel>>> getRecommendNovels() {
|
||||
return getNovelsWithNextUrl("/v1/novel/recommended");
|
||||
}
|
||||
|
||||
Future<Res<List<Novel>>> getNovelsWithNextUrl(String nextUrl) async {
|
||||
var res = await apiGet(nextUrl);
|
||||
if (res.error) {
|
||||
return Res.fromErrorRes(res);
|
||||
}
|
||||
return Res(
|
||||
(res.data["novels"] as List).map((e) => Novel.fromJson(e)).toList(),
|
||||
subData: res.data["next_url"]);
|
||||
}
|
||||
|
||||
Future<Res<List<Novel>>> searchNovels(String keyword, SearchOptions options) {
|
||||
var url = "/v1/search/novel?"
|
||||
"include_translated_tag_results=true&"
|
||||
"merge_plain_keyword_results=true&"
|
||||
"word=${Uri.encodeComponent(keyword)}&"
|
||||
"sort=${options.sort.toParam()}&"
|
||||
"search_target=${options.matchType.toParam()}&"
|
||||
"search_ai_type=0";
|
||||
return getNovelsWithNextUrl(url);
|
||||
}
|
||||
|
||||
/// mode: day, day_male, day_female, week_rookie, week, week_ai
|
||||
Future<Res<List<Novel>>> getNovelRanking(String mode, DateTime? date) {
|
||||
var url = "/v1/novel/ranking?mode=$mode";
|
||||
if (date != null) {
|
||||
url += "&date=${date.year}-${date.month}-${date.day}";
|
||||
}
|
||||
return getNovelsWithNextUrl(url);
|
||||
}
|
||||
|
||||
Future<Res<List<Novel>>> getBookmarkedNovels(String uid, bool public) {
|
||||
return getNovelsWithNextUrl(
|
||||
"/v1/user/bookmarks/novel?user_id=$uid&restrict=${public ? "public" : "private"}");
|
||||
}
|
||||
|
||||
Future<Res<bool>> favoriteNovel(String id, bool public) async {
|
||||
var res = await apiPost("/v2/novel/bookmark/add", data: {
|
||||
"novel_id": id,
|
||||
"restrict": public ? "public" : "private",
|
||||
});
|
||||
if (res.error) {
|
||||
return Res.fromErrorRes(res);
|
||||
}
|
||||
return const Res(true);
|
||||
}
|
||||
|
||||
Future<Res<bool>> deleteFavoriteNovel(String id) async {
|
||||
var res = await apiPost("/v1/novel/bookmark/delete", data: {
|
||||
"novel_id": id,
|
||||
});
|
||||
if (res.error) {
|
||||
return Res.fromErrorRes(res);
|
||||
}
|
||||
return const Res(true);
|
||||
}
|
||||
|
||||
Future<Res<String>> getNovelContent(String id) async {
|
||||
var res = await apiGetPlain(
|
||||
"/webview/v2/novel?id=$id&font=default&font_size=16.0px&line_height=1.75&color=%23101010&background_color=%23EFEFEF&margin_top=56px&margin_bottom=48px&theme=light&use_block=true&viewer_version=20221031_ai");
|
||||
if (res.error) {
|
||||
return Res.fromErrorRes(res);
|
||||
}
|
||||
try {
|
||||
var html = res.data;
|
||||
int start = html.indexOf("novel:");
|
||||
while (html[start] != '{') {
|
||||
start++;
|
||||
}
|
||||
int leftCount = 0;
|
||||
int end = start;
|
||||
for (end = start; end < html.length; end++) {
|
||||
if (html[end] == '{') {
|
||||
leftCount++;
|
||||
} else if (html[end] == '}') {
|
||||
leftCount--;
|
||||
}
|
||||
if (leftCount == 0) {
|
||||
end++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var json = jsonDecode(html.substring(start, end));
|
||||
return Res(json['text']);
|
||||
} catch (e, s) {
|
||||
Log.error(
|
||||
"Data Convert", "Failed to analyze html novel content: \n$e\n$s");
|
||||
return Res.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<List<Novel>>> relatedNovels(String id) async {
|
||||
var res = await apiPost("/v1/novel/related", data: {
|
||||
"novel_id": id,
|
||||
});
|
||||
if (res.error) {
|
||||
return Res.fromErrorRes(res);
|
||||
}
|
||||
return Res(
|
||||
(res.data["novels"] as List).map((e) => Novel.fromJson(e)).toList());
|
||||
}
|
||||
|
||||
Future<Res<List<Novel>>> getUserNovels(String uid) {
|
||||
return getNovelsWithNextUrl("/v1/user/novels?user_id=$uid");
|
||||
}
|
||||
|
||||
Future<Res<List<Novel>>> getNovelSeries(String id, [String? nextUrl]) async {
|
||||
var res = await apiGet(nextUrl ?? "/v2/novel/series?series_id=$id");
|
||||
if (res.error) {
|
||||
return Res.fromErrorRes(res);
|
||||
}
|
||||
return Res(
|
||||
(res.data["novels"] as List).map((e) => Novel.fromJson(e)).toList(),
|
||||
subData: res.data["next_url"]);
|
||||
}
|
||||
|
||||
Future<Res<List<Comment>>> getNovelComments(String id,
|
||||
[String? nextUrl]) async {
|
||||
var res = await apiGet(nextUrl ?? "/v1/novel/comments?novel_id=$id");
|
||||
if (res.error) {
|
||||
return Res.fromErrorRes(res);
|
||||
}
|
||||
return Res(
|
||||
(res.data["comments"] as List).map((e) => Comment.fromJson(e)).toList(),
|
||||
subData: res.data["next_url"]);
|
||||
}
|
||||
|
||||
Future<Res<bool>> commentNovel(String id, String content) async {
|
||||
var res = await apiPost("/v1/novel/comment/add", data: {
|
||||
"novel_id": id,
|
||||
"content": content,
|
||||
});
|
||||
if (res.error) {
|
||||
return Res.fromErrorRes(res);
|
||||
}
|
||||
return const Res(true);
|
||||
}
|
||||
|
||||
Future<Res<Novel>> getNovelDetail(String id) async {
|
||||
var res = await apiGet("/v2/novel/detail?novel_id=$id");
|
||||
if (res.error) {
|
||||
return Res.fromErrorRes(res);
|
||||
}
|
||||
return Res(Novel.fromJson(res.data["novel"]));
|
||||
}
|
||||
|
||||
Future<Res<List<Novel>>> getFollowingNovels(String restrict,
|
||||
[String? nextUrl]) async {
|
||||
var res = await apiGet(nextUrl ?? "/v1/novel/follow?restrict=$restrict");
|
||||
if (res.success) {
|
||||
return Res(
|
||||
(res.data["novels"] as List).map((e) => Novel.fromJson(e)).toList(),
|
||||
subData: res.data["next_url"],
|
||||
);
|
||||
} else {
|
||||
return Res.error(res.errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
75
lib/network/translator.dart
Normal file
@@ -0,0 +1,75 @@
|
||||
import 'package:pixes/network/app_dio.dart';
|
||||
|
||||
abstract class Translator {
|
||||
static Translator? _instance;
|
||||
|
||||
static Translator get instance {
|
||||
if (_instance == null) {
|
||||
init();
|
||||
}
|
||||
return _instance!;
|
||||
}
|
||||
|
||||
static void init() {
|
||||
_instance = GoogleTranslator();
|
||||
}
|
||||
|
||||
/// Translates the given [text] to the given [to] language.
|
||||
Future<String> translate(String text, String to);
|
||||
}
|
||||
|
||||
class GoogleTranslator implements Translator {
|
||||
final Dio _dio = AppDio();
|
||||
|
||||
String get url => 'https://translate.google.com/translate_a/single';
|
||||
|
||||
Map<String, dynamic> buildBody(String text, String to) {
|
||||
return {
|
||||
'q': text,
|
||||
'client': 'at',
|
||||
'sl': 'auto',
|
||||
'tl': to,
|
||||
'dt': 't',
|
||||
'ie': 'UTF-8',
|
||||
'oe': 'UTF-8',
|
||||
'dj': '1',
|
||||
};
|
||||
}
|
||||
|
||||
Future<String> translatePart(String part, String to) async {
|
||||
final response = await _dio.post(
|
||||
url,
|
||||
data: buildBody(part, to),
|
||||
options: Options(
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
|
||||
},
|
||||
),
|
||||
);
|
||||
var buffer = StringBuffer();
|
||||
for(var e in response.data['sentences']) {
|
||||
buffer.write(e['trans']);
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> translate(String text, String to) async {
|
||||
final lines = text.split('\n');
|
||||
var buffer = StringBuffer();
|
||||
var result = '';
|
||||
for(int i=0; i<lines.length; i++) {
|
||||
final line = lines[i];
|
||||
if (buffer.length + line.length > 5000) {
|
||||
result += await translatePart(buffer.toString(), to);
|
||||
buffer.clear();
|
||||
}
|
||||
buffer.write(line);
|
||||
buffer.write('\n');
|
||||
}
|
||||
if (buffer.isNotEmpty) {
|
||||
result += await translatePart(buffer.toString(), to);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -5,6 +5,7 @@ import 'package:pixes/components/segmented_button.dart';
|
||||
import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/pages/illust_page.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../components/illust_widget.dart';
|
||||
@@ -83,7 +84,13 @@ class _OneBookmarkedPageState extends MultiPageLoadingState<_OneBookmarkedPage,
|
||||
if(index == data.length - 1){
|
||||
nextPage();
|
||||
}
|
||||
return IllustWidget(data[index]);
|
||||
return IllustWidget(data[index], onTap: () {
|
||||
context.to(() => IllustGalleryPage(
|
||||
illusts: data,
|
||||
initialPage: index,
|
||||
nextUrl: nextUrl
|
||||
));
|
||||
},);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
214
lib/pages/comments_page.dart
Normal file
@@ -0,0 +1,214 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/components/animated_image.dart';
|
||||
import 'package:pixes/components/loading.dart';
|
||||
import 'package:pixes/components/page_route.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/foundation/image_provider.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/pages/user_info_page.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../components/md.dart';
|
||||
import '../components/message.dart';
|
||||
|
||||
class CommentsPage extends StatefulWidget {
|
||||
const CommentsPage(this.id, {this.isNovel = false, super.key});
|
||||
|
||||
final String id;
|
||||
|
||||
final bool isNovel;
|
||||
|
||||
static void show(BuildContext context, String id, {bool isNovel = false}) {
|
||||
Navigator.of(context)
|
||||
.push(SideBarRoute(CommentsPage(id, isNovel: isNovel)));
|
||||
}
|
||||
|
||||
@override
|
||||
State<CommentsPage> createState() => _CommentsPageState();
|
||||
}
|
||||
|
||||
class _CommentsPageState extends MultiPageLoadingState<CommentsPage, Comment> {
|
||||
bool isCommenting = false;
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, List<Comment> data) {
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned.fill(child: buildBody(context, data)),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: buildBottom(context),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildBody(BuildContext context, List<Comment> data) {
|
||||
return ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: data.length + 2,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return Text("Comments".tl, style: const TextStyle(fontSize: 20))
|
||||
.paddingVertical(16)
|
||||
.paddingHorizontal(12);
|
||||
} else if (index == data.length + 1) {
|
||||
return const SizedBox(
|
||||
height: 64,
|
||||
);
|
||||
}
|
||||
index--;
|
||||
var date = data[index].date;
|
||||
var dateText = "${date.year}/${date.month}/${date.day}";
|
||||
return Card(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 12),
|
||||
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 38,
|
||||
width: 38,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(38),
|
||||
child: ColoredBox(
|
||||
color: ColorScheme.of(context).secondaryContainer,
|
||||
child: GestureDetector(
|
||||
onTap: () => context.to(
|
||||
() => UserInfoPage(data[index].id.toString())),
|
||||
child: AnimatedImage(
|
||||
image: CachedImageProvider(data[index].avatar),
|
||||
width: 38,
|
||||
height: 38,
|
||||
fit: BoxFit.cover,
|
||||
filterQuality: FilterQuality.medium,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
data[index].name,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
Text(
|
||||
dateText,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: ColorScheme.of(context).outline),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
if (data[index].comment.isNotEmpty)
|
||||
Text(
|
||||
data[index].comment,
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
if (data[index].stampUrl != null)
|
||||
SizedBox(
|
||||
height: 64,
|
||||
width: 64,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: AnimatedImage(
|
||||
image: CachedImageProvider(data[index].stampUrl!),
|
||||
width: 64,
|
||||
height: 64,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget buildBottom(BuildContext context) {
|
||||
return Card(
|
||||
padding: EdgeInsets.zero,
|
||||
backgroundColor:
|
||||
FluentTheme.of(context).micaBackgroundColor.toOpacity(0.96),
|
||||
child: SizedBox(
|
||||
height: 52,
|
||||
child: TextBox(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
placeholder: "Comment".tl,
|
||||
foregroundDecoration: WidgetStatePropertyAll(BoxDecoration(
|
||||
border: Border.all(color: Colors.transparent),
|
||||
)),
|
||||
onSubmitted: (s) {
|
||||
showToast(context, message: "Sending".tl);
|
||||
if (isCommenting) return;
|
||||
setState(() {
|
||||
isCommenting = true;
|
||||
});
|
||||
if (widget.isNovel) {
|
||||
Network().commentNovel(widget.id, s).then((value) {
|
||||
if (value.error) {
|
||||
if (context.mounted) {
|
||||
context.showToast(message: "Network Error");
|
||||
setState(() {
|
||||
isCommenting = false;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
isCommenting = false;
|
||||
nextUrl = null;
|
||||
reset();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Network().comment(widget.id, s).then((value) {
|
||||
if (value.error) {
|
||||
if(context.mounted) {
|
||||
context.showToast(message: "Network Error");
|
||||
setState(() {
|
||||
isCommenting = false;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
isCommenting = false;
|
||||
nextUrl = null;
|
||||
reset();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
).paddingVertical(8).paddingHorizontal(12),
|
||||
).paddingBottom(context.padding.bottom + context.viewInsets.bottom),
|
||||
);
|
||||
}
|
||||
|
||||
String? nextUrl;
|
||||
|
||||
@override
|
||||
Future<Res<List<Comment>>> loadData(int page) async {
|
||||
if (nextUrl == "end") {
|
||||
return Res.error("No more data");
|
||||
}
|
||||
var res = widget.isNovel
|
||||
? await Network().getNovelComments(widget.id, nextUrl)
|
||||
: await Network().getComments(widget.id, nextUrl);
|
||||
if (!res.error) {
|
||||
nextUrl = res.subData;
|
||||
nextUrl ??= "end";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@@ -4,10 +4,9 @@ import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:photo_view/photo_view_gallery.dart';
|
||||
import 'package:pixes/components/animated_image.dart';
|
||||
import 'package:pixes/components/grid.dart';
|
||||
import 'package:pixes/components/md.dart';
|
||||
import 'package:pixes/components/message.dart';
|
||||
import 'package:pixes/components/page_route.dart';
|
||||
import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/network/download.dart';
|
||||
@@ -32,7 +31,8 @@ class _DownloadedPageState extends State<DownloadedPage> {
|
||||
|
||||
void loadData() {
|
||||
illusts = DownloadManager().listAll();
|
||||
flyoutControllers = List.generate(illusts.length, (index) => FlyoutController());
|
||||
flyoutControllers =
|
||||
List.generate(illusts.length, (index) => FlyoutController());
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -45,7 +45,18 @@ class _DownloadedPageState extends State<DownloadedPage> {
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
TitleBar(title: "Downloaded".tl),
|
||||
TitleBar(
|
||||
title: "Downloaded".tl,
|
||||
action: Button(
|
||||
child: Text("Delete Invalid Items".tl),
|
||||
onPressed: () async {
|
||||
await DownloadManager().checkAndClearInvalidItems();
|
||||
setState(() {
|
||||
loadData();
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: buildBody(),
|
||||
),
|
||||
@@ -55,133 +66,134 @@ class _DownloadedPageState extends State<DownloadedPage> {
|
||||
|
||||
Widget buildBody() {
|
||||
return GridViewWithFixedItemHeight(
|
||||
itemCount: illusts.length,
|
||||
itemHeight: 152,
|
||||
maxCrossAxisExtent: 742,
|
||||
builder: (context, index) {
|
||||
var image = DownloadManager().getImage(illusts[index].illustId, 0);
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 96,
|
||||
height: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
color: ColorScheme.of(context).secondaryContainer
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: image == null ? null : Image(
|
||||
image: FileImage(image),
|
||||
fit: BoxFit.cover,
|
||||
filterQuality: FilterQuality.medium,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
illusts[index].title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
illusts[index].author,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
"${illusts[index].imageCount}P",
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Button(
|
||||
child: Text("View".tl).fixWidth(42),
|
||||
onPressed: () {
|
||||
var images = DownloadManager().getImagePaths(
|
||||
illusts[index].illustId);
|
||||
if(images.isEmpty) {
|
||||
showToast(context, message: "No images found".tl);
|
||||
return;
|
||||
}
|
||||
App.rootNavigatorKey.currentState?.push(
|
||||
AppPageRoute(builder: (context) {
|
||||
return _DownloadedIllustViewPage(images);
|
||||
}));
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Button(
|
||||
child: Text("Info".tl).fixWidth(42),
|
||||
onPressed: () {
|
||||
context.to(() => IllustPageWithId(
|
||||
illusts[index].illustId.toString()));
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
FlyoutTarget(
|
||||
controller: flyoutControllers[index],
|
||||
child: Button(
|
||||
child: Text("Delete".tl).fixWidth(42),
|
||||
onPressed: () {
|
||||
flyoutControllers[index].showFlyout(
|
||||
navigatorKey: App.rootNavigatorKey.currentState,
|
||||
builder: (context) {
|
||||
return FlyoutContent(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Are you sure you want to delete?'.tl,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 12.0),
|
||||
Button(
|
||||
onPressed: () {
|
||||
Flyout.of(context).close();
|
||||
DownloadManager().delete(illusts[index]);
|
||||
setState(() {
|
||||
illusts.removeAt(index);
|
||||
flyoutControllers.removeAt(index);
|
||||
});
|
||||
},
|
||||
child: Text('Yes'.tl),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
itemCount: illusts.length,
|
||||
itemHeight: 152,
|
||||
maxCrossAxisExtent: 742,
|
||||
builder: (context, index) {
|
||||
var image = DownloadManager().getImage(illusts[index].illustId, 0);
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
App.rootNavigatorKey.currentContext?.to(() =>
|
||||
_DownloadedIllustViewPage(DownloadManager()
|
||||
.getImagePaths(illusts[index].illustId)));
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 96,
|
||||
height: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
color: ColorScheme.of(context).secondaryContainer),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: image == null
|
||||
? null
|
||||
: AnimatedImage(
|
||||
image: FileImage(image),
|
||||
fit: BoxFit.cover,
|
||||
width: 96,
|
||||
height: double.infinity,
|
||||
filterQuality: FilterQuality.medium,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
illusts[index].title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
illusts[index].author,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
"${illusts[index].imageCount}P",
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Button(
|
||||
child: Text("Info".tl).fixWidth(42),
|
||||
onPressed: () {
|
||||
context.to(() => IllustPageWithId(
|
||||
illusts[index].illustId.toString()));
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
FlyoutTarget(
|
||||
controller: flyoutControllers[index],
|
||||
child: Button(
|
||||
child: Text("Delete".tl).fixWidth(42),
|
||||
onPressed: () {
|
||||
flyoutControllers[index].showFlyout(
|
||||
navigatorKey:
|
||||
App.rootNavigatorKey.currentState,
|
||||
builder: (context) {
|
||||
return FlyoutContent(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Are you sure you want to delete?'
|
||||
.tl,
|
||||
style: const TextStyle(
|
||||
fontWeight:
|
||||
FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 12.0),
|
||||
Button(
|
||||
onPressed: () {
|
||||
Flyout.of(context).close();
|
||||
DownloadManager()
|
||||
.delete(illusts[index]);
|
||||
setState(() {
|
||||
illusts.removeAt(index);
|
||||
flyoutControllers
|
||||
.removeAt(index);
|
||||
});
|
||||
},
|
||||
child: Text('Yes'.tl),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
).paddingHorizontal(8);
|
||||
),
|
||||
);
|
||||
}).paddingHorizontal(8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,10 +203,12 @@ class _DownloadedIllustViewPage extends StatefulWidget {
|
||||
final List<String> imagePaths;
|
||||
|
||||
@override
|
||||
State<_DownloadedIllustViewPage> createState() => _DownloadedIllustViewPageState();
|
||||
State<_DownloadedIllustViewPage> createState() =>
|
||||
_DownloadedIllustViewPageState();
|
||||
}
|
||||
|
||||
class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> with WindowListener{
|
||||
class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage>
|
||||
with WindowListener {
|
||||
int windowButtonKey = 0;
|
||||
|
||||
@override
|
||||
@@ -231,38 +245,47 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
||||
|
||||
Future<File?> getFile() async {
|
||||
var file = File(widget.imagePaths[currentPage]);
|
||||
if(file.existsSync()) {
|
||||
if (file.existsSync()) {
|
||||
return file;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void showMenu() {
|
||||
menuController.showFlyout(builder: (context) => MenuFlyout(
|
||||
items: [
|
||||
MenuFlyoutItem(text: Text("Save to".tl), onPressed: () async{
|
||||
var file = await getFile();
|
||||
if(file != null){
|
||||
saveFile(file);
|
||||
}
|
||||
}),
|
||||
MenuFlyoutItem(text: Text("Share".tl), onPressed: () async{
|
||||
var file = await getFile();
|
||||
if(file != null){
|
||||
var ext = file.path.split('.').last;
|
||||
var mediaType = switch(ext){
|
||||
'jpg' => 'image/jpeg',
|
||||
'jpeg' => 'image/jpeg',
|
||||
'png' => 'image/png',
|
||||
'gif' => 'image/gif',
|
||||
'webp' => 'image/webp',
|
||||
_ => 'application/octet-stream'
|
||||
};
|
||||
Share.shareXFiles([XFile(file.path, mimeType: mediaType, name: file.path.split('/').last)]);
|
||||
}
|
||||
}),
|
||||
],
|
||||
));
|
||||
menuController.showFlyout(
|
||||
builder: (context) => MenuFlyout(
|
||||
items: [
|
||||
MenuFlyoutItem(
|
||||
text: Text("Save to".tl),
|
||||
onPressed: () async {
|
||||
var file = await getFile();
|
||||
if (file != null) {
|
||||
saveFile(file);
|
||||
}
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: Text("Share".tl),
|
||||
onPressed: () async {
|
||||
var file = await getFile();
|
||||
if (file != null) {
|
||||
var ext = file.path.split('.').last;
|
||||
var mediaType = switch (ext) {
|
||||
'jpg' => 'image/jpeg',
|
||||
'jpeg' => 'image/jpeg',
|
||||
'png' => 'image/png',
|
||||
'gif' => 'image/gif',
|
||||
'webp' => 'image/webp',
|
||||
_ => 'application/octet-stream'
|
||||
};
|
||||
Share.shareXFiles([
|
||||
XFile(file.path,
|
||||
mimeType: mediaType,
|
||||
name: file.path.split('/').last)
|
||||
]);
|
||||
}
|
||||
}),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -272,12 +295,13 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
||||
color: FluentTheme.of(context).micaBackgroundColor,
|
||||
child: Listener(
|
||||
onPointerSignal: (event) {
|
||||
if(event is PointerScrollEvent &&
|
||||
if (event is PointerScrollEvent &&
|
||||
!HardwareKeyboard.instance.isControlPressed) {
|
||||
if(event.scrollDelta.dy > 0
|
||||
&& controller.page!.toInt() < widget.imagePaths.length - 1) {
|
||||
if (event.scrollDelta.dy > 0 &&
|
||||
controller.page!.toInt() < widget.imagePaths.length - 1) {
|
||||
controller.jumpToPage(controller.page!.toInt() + 1);
|
||||
} else if(event.scrollDelta.dy < 0 && controller.page!.toInt() > 0){
|
||||
} else if (event.scrollDelta.dy < 0 &&
|
||||
controller.page!.toInt() > 0) {
|
||||
controller.jumpToPage(controller.page!.toInt() - 1);
|
||||
}
|
||||
}
|
||||
@@ -287,11 +311,11 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
||||
var height = constrains.maxHeight;
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned.fill(child: PhotoViewGallery.builder(
|
||||
Positioned.fill(
|
||||
child: PhotoViewGallery.builder(
|
||||
pageController: controller,
|
||||
backgroundDecoration: const BoxDecoration(
|
||||
color: Colors.transparent
|
||||
),
|
||||
backgroundDecoration:
|
||||
const BoxDecoration(color: Colors.transparent),
|
||||
itemCount: widget.imagePaths.length,
|
||||
builder: (context, index) {
|
||||
return PhotoViewGalleryPageOptions(
|
||||
@@ -312,17 +336,22 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
||||
height: 36,
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(width: 6,),
|
||||
const SizedBox(
|
||||
width: 6,
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(FluentIcons.back).paddingAll(2),
|
||||
onPressed: () => context.pop()
|
||||
),
|
||||
onPressed: () => context.pop()),
|
||||
const Expanded(
|
||||
child: DragToMoveArea(child: SizedBox.expand(),),
|
||||
child: DragToMoveArea(
|
||||
child: SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
buildActions(),
|
||||
if(App.isDesktop)
|
||||
WindowButtons(key: ValueKey(windowButtonKey),),
|
||||
if (App.isDesktop)
|
||||
WindowButtons(
|
||||
key: ValueKey(windowButtonKey),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -331,7 +360,10 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
||||
left: 0,
|
||||
top: height / 2 - 9,
|
||||
child: IconButton(
|
||||
icon: const Icon(FluentIcons.chevron_left, size: 18,),
|
||||
icon: const Icon(
|
||||
FluentIcons.chevron_left,
|
||||
size: 18,
|
||||
),
|
||||
onPressed: () {
|
||||
controller.previousPage(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
@@ -374,26 +406,25 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
||||
controller: menuController,
|
||||
child: width > 600
|
||||
? Button(
|
||||
onPressed: showMenu,
|
||||
child: const Row(
|
||||
children: [
|
||||
Icon(
|
||||
MdIcons.menu,
|
||||
size: 18,
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Text('Actions'),
|
||||
],
|
||||
))
|
||||
onPressed: showMenu,
|
||||
child: const Row(
|
||||
children: [
|
||||
Icon(
|
||||
MdIcons.menu,
|
||||
size: 18,
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Text('Actions'),
|
||||
],
|
||||
))
|
||||
: IconButton(
|
||||
icon: const Icon(
|
||||
MdIcons.more_horiz,
|
||||
size: 20,
|
||||
),
|
||||
onPressed: showMenu),
|
||||
icon: const Icon(
|
||||
MdIcons.more_horiz,
|
||||
size: 20,
|
||||
),
|
||||
onPressed: showMenu),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -47,7 +47,38 @@ class _DownloadingPageState extends State<DownloadingPage> {
|
||||
Widget buildTop() {
|
||||
int bytesPerSecond = DownloadManager().bytesPerSecond;
|
||||
|
||||
return SliverTitleBar(title: "${"Speed".tl}: ${bytesToText(bytesPerSecond)}/s");
|
||||
bool paused = DownloadManager().paused;
|
||||
|
||||
return SliverTitleBar(
|
||||
title: paused
|
||||
? "Paused".tl
|
||||
:"${"Speed".tl}: ${bytesToText(bytesPerSecond)}/s",
|
||||
action: SplitButton(
|
||||
onInvoked: (){
|
||||
if(!paused) {
|
||||
DownloadManager().pause();
|
||||
setState(() {});
|
||||
} else {
|
||||
DownloadManager().resume();
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
flyout: MenuFlyout(
|
||||
items: [
|
||||
MenuFlyoutItem(text: Text("Cancel All".tl), onPressed: (){
|
||||
var tasks = List.from(DownloadManager().tasks);
|
||||
DownloadManager().tasks.clear();
|
||||
for(var task in tasks) {
|
||||
task.cancel();
|
||||
}
|
||||
setState(() {});
|
||||
})
|
||||
],
|
||||
),
|
||||
child: Text(paused ? "Resume".tl : "Pause".tl)
|
||||
.toCenter().fixWidth(56).fixHeight(32),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildContent() {
|
||||
|
@@ -2,6 +2,7 @@ import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/utils/block.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../components/batch_download.dart';
|
||||
@@ -9,6 +10,7 @@ import '../components/illust_widget.dart';
|
||||
import '../components/loading.dart';
|
||||
import '../components/segmented_button.dart';
|
||||
import '../network/network.dart';
|
||||
import 'illust_page.dart';
|
||||
|
||||
class FollowingArtworksPage extends StatefulWidget {
|
||||
const FollowingArtworksPage({super.key});
|
||||
@@ -26,7 +28,10 @@ class _FollowingArtworksPageState extends State<FollowingArtworksPage> {
|
||||
children: [
|
||||
buildTab(),
|
||||
Expanded(
|
||||
child: _OneFollowingPage(restrict, key: Key(restrict),),
|
||||
child: _OneFollowingPage(
|
||||
restrict,
|
||||
key: Key(restrict),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
@@ -37,8 +42,11 @@ class _FollowingArtworksPageState extends State<FollowingArtworksPage> {
|
||||
title: "Following".tl,
|
||||
action: Row(
|
||||
children: [
|
||||
BatchDownloadButton(request: () => Network().getFollowingArtworks(restrict)),
|
||||
const SizedBox(width: 8,),
|
||||
BatchDownloadButton(
|
||||
request: () => Network().getFollowingArtworks(restrict)),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
SegmentedButton(
|
||||
options: [
|
||||
SegmentedButtonOption("all", "All".tl),
|
||||
@@ -46,7 +54,7 @@ class _FollowingArtworksPageState extends State<FollowingArtworksPage> {
|
||||
SegmentedButtonOption("private", "Private".tl),
|
||||
],
|
||||
onPressed: (key) {
|
||||
if(key != restrict) {
|
||||
if (key != restrict) {
|
||||
setState(() {
|
||||
restrict = key;
|
||||
});
|
||||
@@ -69,22 +77,27 @@ class _OneFollowingPage extends StatefulWidget {
|
||||
State<_OneFollowingPage> createState() => _OneFollowingPageState();
|
||||
}
|
||||
|
||||
class _OneFollowingPageState extends MultiPageLoadingState<_OneFollowingPage, Illust> {
|
||||
class _OneFollowingPageState
|
||||
extends MultiPageLoadingState<_OneFollowingPage, Illust> {
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
return LayoutBuilder(builder: (context, constrains){
|
||||
Widget buildContent(BuildContext context, List<Illust> data) {
|
||||
checkIllusts(data);
|
||||
return LayoutBuilder(builder: (context, constrains) {
|
||||
return MasonryGridView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8)
|
||||
+ EdgeInsets.only(bottom: context.padding.bottom),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8) +
|
||||
EdgeInsets.only(bottom: context.padding.bottom),
|
||||
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 240,
|
||||
),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, index) {
|
||||
if(index == data.length - 1){
|
||||
if (index == data.length - 1) {
|
||||
nextPage();
|
||||
}
|
||||
return IllustWidget(data[index]);
|
||||
return IllustWidget(data[index], onTap: () {
|
||||
context.to(() => IllustGalleryPage(
|
||||
illusts: data, initialPage: index, nextUrl: nextUrl));
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -93,16 +106,15 @@ class _OneFollowingPageState extends MultiPageLoadingState<_OneFollowingPage, Il
|
||||
String? nextUrl;
|
||||
|
||||
@override
|
||||
Future<Res<List<Illust>>> loadData(page) async{
|
||||
if(nextUrl == "end") {
|
||||
Future<Res<List<Illust>>> loadData(page) async {
|
||||
if (nextUrl == "end") {
|
||||
return Res.error("No more data");
|
||||
}
|
||||
var res = await Network().getFollowingArtworks(widget.restrict, nextUrl);
|
||||
if(!res.error) {
|
||||
if (!res.error) {
|
||||
nextUrl = res.subData;
|
||||
nextUrl ??= "end";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
83
lib/pages/following_novels_page.dart
Normal file
@@ -0,0 +1,83 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/components/grid.dart';
|
||||
import 'package:pixes/components/loading.dart';
|
||||
import 'package:pixes/components/novel.dart';
|
||||
import 'package:pixes/components/segmented_button.dart';
|
||||
import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/widget_utils.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
class FollowingNovelsPage extends StatefulWidget {
|
||||
const FollowingNovelsPage({super.key});
|
||||
|
||||
@override
|
||||
State<FollowingNovelsPage> createState() => _FollowingNovelsPageState();
|
||||
}
|
||||
|
||||
class _FollowingNovelsPageState
|
||||
extends MultiPageLoadingState<FollowingNovelsPage, Novel> {
|
||||
bool public = true;
|
||||
|
||||
@override
|
||||
Widget? buildFrame(BuildContext context, Widget child) {
|
||||
return Column(
|
||||
children: [
|
||||
TitleBar(
|
||||
title: "Following".tl,
|
||||
action: SegmentedButton(
|
||||
options: [
|
||||
SegmentedButtonOption("public", "Public".tl),
|
||||
SegmentedButtonOption("private", "Private".tl),
|
||||
],
|
||||
onPressed: (key) {
|
||||
var newPublic = key == "public";
|
||||
if (newPublic != public) {
|
||||
public = newPublic;
|
||||
nextUrl = null;
|
||||
reset();
|
||||
}
|
||||
},
|
||||
value: public ? "public" : "private",
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: child,
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, List<Novel> data) {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: GridViewWithFixedItemHeight(
|
||||
itemCount: data.length,
|
||||
itemHeight: 164,
|
||||
minCrossAxisExtent: 400,
|
||||
builder: (context, index) {
|
||||
if (index == data.length - 1) {
|
||||
nextPage();
|
||||
}
|
||||
return NovelWidget(data[index]);
|
||||
},
|
||||
).paddingHorizontal(8),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
String? nextUrl;
|
||||
|
||||
@override
|
||||
Future<Res<List<Novel>>> loadData(int page) async {
|
||||
if (nextUrl == "end") return Res.error("No more data");
|
||||
var res = nextUrl == null
|
||||
? await Network().getFollowingNovels(public ? "public" : "private")
|
||||
: await Network().getNovelsWithNextUrl(nextUrl!);
|
||||
nextUrl = res.subData ?? "end";
|
||||
return res;
|
||||
}
|
||||
}
|
@@ -18,7 +18,8 @@ class FollowingUsersPage extends StatefulWidget {
|
||||
State<FollowingUsersPage> createState() => _FollowingUsersPageState();
|
||||
}
|
||||
|
||||
class _FollowingUsersPageState extends MultiPageLoadingState<FollowingUsersPage, UserPreview> {
|
||||
class _FollowingUsersPageState
|
||||
extends MultiPageLoadingState<FollowingUsersPage, UserPreview> {
|
||||
String type = "public";
|
||||
|
||||
@override
|
||||
@@ -28,11 +29,13 @@ class _FollowingUsersPageState extends MultiPageLoadingState<FollowingUsersPage,
|
||||
SliverToBoxAdapter(
|
||||
child: Row(
|
||||
children: [
|
||||
Text("Following".tl,
|
||||
style: const TextStyle(fontSize: 22, fontWeight: FontWeight.bold),)
|
||||
.paddingVertical(12).paddingLeft(16),
|
||||
Text(
|
||||
"Following".tl,
|
||||
style:
|
||||
const TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
|
||||
).paddingVertical(12).paddingLeft(16),
|
||||
const Spacer(),
|
||||
if(widget.uid == appdata.account?.user.id)
|
||||
if (widget.uid == appdata.account?.user.id)
|
||||
SegmentedButton(
|
||||
value: type,
|
||||
options: [
|
||||
@@ -44,22 +47,21 @@ class _FollowingUsersPageState extends MultiPageLoadingState<FollowingUsersPage,
|
||||
reset();
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 16,)
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SliverGridViewWithFixedItemHeight(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if(index == data.length - 1){
|
||||
nextPage();
|
||||
}
|
||||
return UserPreviewWidget(data[index]);
|
||||
},
|
||||
childCount: data.length
|
||||
),
|
||||
maxCrossAxisExtent: 520,
|
||||
itemHeight: 114,
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
if (index == data.length - 1) {
|
||||
nextPage();
|
||||
}
|
||||
return UserPreviewWidget(data[index]);
|
||||
}, childCount: data.length),
|
||||
minCrossAxisExtent: 440,
|
||||
itemHeight: 136,
|
||||
).sliverPaddingHorizontal(8)
|
||||
],
|
||||
);
|
||||
@@ -68,12 +70,12 @@ class _FollowingUsersPageState extends MultiPageLoadingState<FollowingUsersPage,
|
||||
String? nextUrl;
|
||||
|
||||
@override
|
||||
Future<Res<List<UserPreview>>> loadData(page) async{
|
||||
if(nextUrl == "end") {
|
||||
Future<Res<List<UserPreview>>> loadData(page) async {
|
||||
if (nextUrl == "end") {
|
||||
return Res.error("No more data");
|
||||
}
|
||||
var res = await Network().getFollowing(widget.uid, type, nextUrl);
|
||||
if(!res.error) {
|
||||
if (!res.error) {
|
||||
nextUrl = res.subData;
|
||||
nextUrl ??= "end";
|
||||
}
|
||||
|
@@ -2,13 +2,15 @@ import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
import 'package:pixes/appdata.dart';
|
||||
import 'package:pixes/components/loading.dart';
|
||||
import 'package:pixes/components/segmented_button.dart';
|
||||
import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/network/models.dart';
|
||||
import 'package:pixes/foundation/history.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../components/illust_widget.dart';
|
||||
import 'illust_page.dart';
|
||||
|
||||
class HistoryPage extends StatefulWidget {
|
||||
const HistoryPage({super.key});
|
||||
@@ -17,37 +19,109 @@ class HistoryPage extends StatefulWidget {
|
||||
State<HistoryPage> createState() => _HistoryPageState();
|
||||
}
|
||||
|
||||
class _HistoryPageState extends MultiPageLoadingState<HistoryPage, Illust> {
|
||||
class _HistoryPageState extends State<HistoryPage> {
|
||||
int page = 0;
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
TitleBar(title: "History".tl),
|
||||
TitleBar(
|
||||
title: "History".tl,
|
||||
action: SegmentedButton<int>(
|
||||
options: [
|
||||
SegmentedButtonOption(0, "Local".tl,),
|
||||
SegmentedButtonOption(1, "Network".tl,),
|
||||
],
|
||||
value: page,
|
||||
onPressed: (key) {
|
||||
setState(() {
|
||||
page = key;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: LayoutBuilder(builder: (context, constrains){
|
||||
return MasonryGridView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8)
|
||||
+ EdgeInsets.only(bottom: context.padding.bottom),
|
||||
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 240,
|
||||
),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, index) {
|
||||
if(index == data.length - 1){
|
||||
nextPage();
|
||||
}
|
||||
return IllustWidget(data[index]);
|
||||
},
|
||||
);
|
||||
}),
|
||||
)
|
||||
child: page == 0
|
||||
? const LocalHistoryPage()
|
||||
: const NetworkHistoryPage(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LocalHistoryPage extends StatefulWidget {
|
||||
const LocalHistoryPage({super.key});
|
||||
|
||||
@override
|
||||
State<LocalHistoryPage> createState() => _LocalHistoryPageState();
|
||||
}
|
||||
|
||||
class _LocalHistoryPageState extends State<LocalHistoryPage> {
|
||||
int page = 1;
|
||||
|
||||
var data = <IllustHistory>[];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(builder: (context, constrains) {
|
||||
return MasonryGridView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8) +
|
||||
EdgeInsets.only(bottom: context.padding.bottom),
|
||||
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 240,
|
||||
),
|
||||
itemCount: HistoryManager().length,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == data.length) {
|
||||
data.addAll(HistoryManager().getHistories(page));
|
||||
page++;
|
||||
}
|
||||
return IllustHistoryWidget(data[index]);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class NetworkHistoryPage extends StatefulWidget {
|
||||
const NetworkHistoryPage({super.key});
|
||||
|
||||
@override
|
||||
State<NetworkHistoryPage> createState() => _NetworkHistoryPageState();
|
||||
}
|
||||
|
||||
class _NetworkHistoryPageState
|
||||
extends MultiPageLoadingState<NetworkHistoryPage, Illust> {
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
return LayoutBuilder(builder: (context, constrains) {
|
||||
return MasonryGridView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8) +
|
||||
EdgeInsets.only(bottom: context.padding.bottom),
|
||||
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 240,
|
||||
),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == data.length - 1) {
|
||||
nextPage();
|
||||
}
|
||||
return IllustWidget(data[index], onTap: () {
|
||||
context.to(() => IllustGalleryPage(
|
||||
illusts: data,
|
||||
initialPage: index,
|
||||
));
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Res<List<Illust>>> loadData(page) {
|
||||
if(appdata.account?.user.isPremium != true) {
|
||||
if (appdata.account?.user.isPremium != true) {
|
||||
return Future.value(Res.error("Premium Required".tl));
|
||||
}
|
||||
return Network().getHistory(page);
|
||||
|
@@ -3,8 +3,10 @@ import 'dart:io';
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:image_gallery_saver_plus/image_gallery_saver_plus.dart';
|
||||
import 'package:photo_view/photo_view_gallery.dart';
|
||||
import 'package:pixes/components/md.dart';
|
||||
import 'package:pixes/components/message.dart';
|
||||
import 'package:pixes/components/page_route.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/foundation/cache_manager.dart';
|
||||
@@ -16,15 +18,14 @@ import 'package:share_plus/share_plus.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
class ImagePage extends StatefulWidget {
|
||||
const ImagePage(this.urls, {this.initialPage = 1, super.key});
|
||||
const ImagePage(this.urls, {this.initialPage = 0, super.key});
|
||||
|
||||
final List<String> urls;
|
||||
|
||||
final int initialPage;
|
||||
|
||||
static show(List<String> urls, {int initialPage = 1}) {
|
||||
App.rootNavigatorKey.currentState
|
||||
?.push(AppPageRoute(
|
||||
static show(List<String> urls, {int initialPage = 0}) {
|
||||
App.rootNavigatorKey.currentState?.push(AppPageRoute(
|
||||
builder: (context) => ImagePage(urls, initialPage: initialPage)));
|
||||
}
|
||||
|
||||
@@ -69,61 +70,90 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
||||
|
||||
Future<File?> getFile() async {
|
||||
var image = widget.urls[currentPage];
|
||||
if(image.startsWith("file://")){
|
||||
if (image.startsWith("file://")) {
|
||||
return File(image.replaceFirst("file://", ""));
|
||||
}
|
||||
var file = await CacheManager().findCache(image);
|
||||
return file == null
|
||||
? null
|
||||
: File(file);
|
||||
var key = image;
|
||||
if (key.startsWith("novel:")) {
|
||||
key = key.split(':').last;
|
||||
}
|
||||
var file = await CacheManager().findCache(key);
|
||||
return file == null ? null : File(file);
|
||||
}
|
||||
|
||||
String getExtensionName() {
|
||||
var fileName = widget.urls[currentPage].split('/').last;
|
||||
if(fileName.contains('.')){
|
||||
if (fileName.contains('.')) {
|
||||
return '.${fileName.split('.').last}';
|
||||
}
|
||||
return '.jpg';
|
||||
}
|
||||
|
||||
void showMenu() {
|
||||
menuController.showFlyout(builder: (context) => MenuFlyout(
|
||||
items: [
|
||||
MenuFlyoutItem(text: Text("Save to".tl), onPressed: () async{
|
||||
var file = await getFile();
|
||||
if(file != null){
|
||||
var fileName = file.path.split('/').last;
|
||||
if(!fileName.contains('.')){
|
||||
fileName += getExtensionName();
|
||||
}
|
||||
saveFile(file, fileName);
|
||||
}
|
||||
}),
|
||||
MenuFlyoutItem(text: Text("Share".tl), onPressed: () async{
|
||||
var file = await getFile();
|
||||
if(file != null){
|
||||
var ext = getExtensionName();
|
||||
var fileName = file.path.split('/').last;
|
||||
if(!fileName.contains('.')){
|
||||
fileName += ext;
|
||||
}
|
||||
var mediaType = switch(ext){
|
||||
'.jpg' => 'image/jpeg',
|
||||
'.jpeg' => 'image/jpeg',
|
||||
'.png' => 'image/png',
|
||||
'.gif' => 'image/gif',
|
||||
'.webp' => 'image/webp',
|
||||
_ => 'application/octet-stream'
|
||||
};
|
||||
Share.shareXFiles([XFile.fromData(
|
||||
await file.readAsBytes(),
|
||||
mimeType: mediaType,
|
||||
name: fileName)]
|
||||
);
|
||||
}
|
||||
}),
|
||||
],
|
||||
));
|
||||
menuController.showFlyout(
|
||||
barrierColor: Colors.transparent,
|
||||
position: App.isMobile ? Offset(context.size!.width, 0) : null,
|
||||
builder: (context) => MenuFlyout(
|
||||
items: [
|
||||
MenuFlyoutItem(
|
||||
text: Text("Save to".tl),
|
||||
onPressed: () async {
|
||||
var file = await getFile();
|
||||
if (file != null) {
|
||||
var fileName = widget.urls[currentPage].split('/').last;
|
||||
if (!fileName.contains('.')) {
|
||||
fileName += getExtensionName();
|
||||
}
|
||||
saveFile(file, fileName);
|
||||
}
|
||||
}),
|
||||
if (App.isMobile)
|
||||
MenuFlyoutItem(
|
||||
text: Text("Save to gallery".tl),
|
||||
onPressed: () async {
|
||||
var file = await getFile();
|
||||
if (file != null) {
|
||||
var fileName =
|
||||
widget.urls[currentPage].split('/').last;
|
||||
if (!fileName.contains('.')) {
|
||||
fileName += getExtensionName();
|
||||
}
|
||||
await ImageGallerySaverPlus.saveImage(
|
||||
await file.readAsBytes(),
|
||||
quality: 100,
|
||||
name: fileName,
|
||||
);
|
||||
if (context.mounted) {
|
||||
showToast(context, message: "Saved".tl);
|
||||
}
|
||||
}
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: Text("Share".tl),
|
||||
onPressed: () async {
|
||||
var file = await getFile();
|
||||
if (file != null) {
|
||||
var ext = getExtensionName();
|
||||
var fileName = widget.urls[currentPage].split('/').last;
|
||||
if (!fileName.contains('.')) {
|
||||
fileName += ext;
|
||||
}
|
||||
var mediaType = switch (ext) {
|
||||
'.jpg' => 'image/jpeg',
|
||||
'.jpeg' => 'image/jpeg',
|
||||
'.png' => 'image/png',
|
||||
'.gif' => 'image/gif',
|
||||
'.webp' => 'image/webp',
|
||||
_ => 'application/octet-stream'
|
||||
};
|
||||
Share.shareXFiles([
|
||||
XFile.fromData(await file.readAsBytes(),
|
||||
mimeType: mediaType, name: fileName)
|
||||
]);
|
||||
}
|
||||
}),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -133,12 +163,13 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
||||
color: FluentTheme.of(context).micaBackgroundColor,
|
||||
child: Listener(
|
||||
onPointerSignal: (event) {
|
||||
if(event is PointerScrollEvent &&
|
||||
if (event is PointerScrollEvent &&
|
||||
!HardwareKeyboard.instance.isControlPressed) {
|
||||
if(event.scrollDelta.dy > 0
|
||||
&& controller.page!.toInt() < widget.urls.length - 1) {
|
||||
if (event.scrollDelta.dy > 0 &&
|
||||
controller.page!.toInt() < widget.urls.length - 1) {
|
||||
controller.jumpToPage(controller.page!.toInt() + 1);
|
||||
} else if(event.scrollDelta.dy < 0 && controller.page!.toInt() > 0){
|
||||
} else if (event.scrollDelta.dy < 0 &&
|
||||
controller.page!.toInt() > 0) {
|
||||
controller.jumpToPage(controller.page!.toInt() - 1);
|
||||
}
|
||||
}
|
||||
@@ -148,19 +179,18 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
||||
var height = constrains.maxHeight;
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned.fill(child: PhotoViewGallery.builder(
|
||||
Positioned.fill(
|
||||
child: PhotoViewGallery.builder(
|
||||
pageController: controller,
|
||||
backgroundDecoration: const BoxDecoration(
|
||||
color: Colors.transparent
|
||||
),
|
||||
backgroundDecoration:
|
||||
const BoxDecoration(color: Colors.transparent),
|
||||
itemCount: widget.urls.length,
|
||||
builder: (context, index) {
|
||||
var image = widget.urls[index];
|
||||
|
||||
return PhotoViewGalleryPageOptions(
|
||||
imageProvider: image.startsWith("file://")
|
||||
? FileImage(File(image.replaceFirst("file://", "")))
|
||||
: CachedImageProvider(image) as ImageProvider,
|
||||
filterQuality: FilterQuality.medium,
|
||||
imageProvider: getImageProvider(image),
|
||||
);
|
||||
},
|
||||
onPageChanged: (index) {
|
||||
@@ -177,47 +207,57 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
||||
height: 36,
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(width: 6,),
|
||||
const SizedBox(
|
||||
width: 6,
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(FluentIcons.back).paddingAll(2),
|
||||
onPressed: () => context.pop()
|
||||
),
|
||||
onPressed: () => context.pop()),
|
||||
const Expanded(
|
||||
child: DragToMoveArea(child: SizedBox.expand(),),
|
||||
child: DragToMoveArea(
|
||||
child: SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
buildActions(),
|
||||
if(App.isDesktop)
|
||||
WindowButtons(key: ValueKey(windowButtonKey),),
|
||||
if (App.isDesktop)
|
||||
WindowButtons(
|
||||
key: ValueKey(windowButtonKey),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 0,
|
||||
top: height / 2 - 9,
|
||||
child: IconButton(
|
||||
icon: const Icon(FluentIcons.chevron_left, size: 18,),
|
||||
onPressed: () {
|
||||
controller.previousPage(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
},
|
||||
).paddingAll(8),
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
top: height / 2 - 9,
|
||||
child: IconButton(
|
||||
icon: const Icon(FluentIcons.chevron_right, size: 18),
|
||||
onPressed: () {
|
||||
controller.nextPage(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
},
|
||||
).paddingAll(8),
|
||||
),
|
||||
if (currentPage != 0)
|
||||
Positioned(
|
||||
left: 0,
|
||||
top: height / 2 - 9,
|
||||
child: IconButton(
|
||||
icon: const Icon(
|
||||
FluentIcons.chevron_left,
|
||||
size: 18,
|
||||
),
|
||||
onPressed: () {
|
||||
controller.previousPage(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
},
|
||||
).paddingAll(8),
|
||||
),
|
||||
if (currentPage != widget.urls.length - 1)
|
||||
Positioned(
|
||||
right: 0,
|
||||
top: height / 2 - 9,
|
||||
child: IconButton(
|
||||
icon: const Icon(FluentIcons.chevron_right, size: 18),
|
||||
onPressed: () {
|
||||
controller.nextPage(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
},
|
||||
).paddingAll(8),
|
||||
),
|
||||
Positioned(
|
||||
left: 12,
|
||||
bottom: 8,
|
||||
@@ -239,25 +279,35 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
||||
controller: menuController,
|
||||
child: width > 600
|
||||
? Button(
|
||||
onPressed: showMenu,
|
||||
child: const Row(
|
||||
children: [
|
||||
Icon(
|
||||
MdIcons.menu,
|
||||
size: 18,
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Text('Actions'),
|
||||
],
|
||||
))
|
||||
onPressed: showMenu,
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
MdIcons.menu,
|
||||
size: 18,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Text('Actions'.tl),
|
||||
],
|
||||
))
|
||||
: IconButton(
|
||||
icon: const Icon(
|
||||
MdIcons.more_horiz,
|
||||
size: 20,
|
||||
),
|
||||
onPressed: showMenu),
|
||||
icon: const Icon(
|
||||
MdIcons.more_horiz,
|
||||
size: 20,
|
||||
),
|
||||
onPressed: showMenu),
|
||||
);
|
||||
}
|
||||
|
||||
ImageProvider getImageProvider(String url) {
|
||||
if (url.startsWith("file://")) {
|
||||
return FileImage(File(url.replaceFirst("file://", "")));
|
||||
} else if (url.startsWith("novel:")) {
|
||||
var ids = url.split(':').last.split('/');
|
||||
return CachedNovelImageProvider(ids[0], ids[1]);
|
||||
}
|
||||
return CachedImageProvider(url) as ImageProvider;
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/components/button.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/pages/webview_page.dart';
|
||||
@@ -24,7 +25,7 @@ class _LoginPageState extends State<LoginPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if(isLogging) {
|
||||
if (isLogging) {
|
||||
return buildLoading(context);
|
||||
} else if (!waitingForAuth) {
|
||||
return buildLogin(context);
|
||||
@@ -56,23 +57,12 @@ class _LoginPageState extends State<LoginPage> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (checked)
|
||||
FilledButton(
|
||||
onPressed: onContinue,
|
||||
child: Text("Continue".tl),
|
||||
)
|
||||
else
|
||||
Container(
|
||||
height: 28,
|
||||
width: 78,
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context)
|
||||
.inactiveBackgroundColor,
|
||||
borderRadius: BorderRadius.circular(4)),
|
||||
child: Center(
|
||||
child: Text("Continue".tl),
|
||||
),
|
||||
),
|
||||
FluentButton(
|
||||
onPressed: onContinue,
|
||||
enabled: checked,
|
||||
width: 96,
|
||||
child: Text("Continue".tl),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
@@ -97,7 +87,9 @@ class _LoginPageState extends State<LoginPage> {
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Text("I have read and agree to the Terms of Use".tl)
|
||||
Expanded(
|
||||
child: Text("I understand pixes is a free unofficial application.".tl),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
@@ -186,6 +178,39 @@ class _LoginPageState extends State<LoginPage> {
|
||||
}
|
||||
|
||||
void onContinue() async {
|
||||
bool? useExternal;
|
||||
if (App.isMobile) {
|
||||
await showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (context) => ContentDialog(
|
||||
title: Text("Choose a way to login".tl),
|
||||
content: Text("${"Use Webview: you cannot sign in with Google.".tl}"
|
||||
"\n\n"
|
||||
"${"Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application".tl}"),
|
||||
actions: [
|
||||
Button(
|
||||
child: Text("Webview".tl),
|
||||
onPressed: () {
|
||||
useExternal = false;
|
||||
App.rootNavigatorKey.currentState!.pop();
|
||||
},
|
||||
),
|
||||
Button(
|
||||
child: Text("External browser".tl),
|
||||
onPressed: () {
|
||||
useExternal = true;
|
||||
App.rootNavigatorKey.currentState!.pop();
|
||||
},
|
||||
)
|
||||
]),
|
||||
);
|
||||
} else {
|
||||
useExternal = true;
|
||||
}
|
||||
if (useExternal == null) {
|
||||
return;
|
||||
}
|
||||
var url = await Network().generateWebviewUrl();
|
||||
onLink = (uri) {
|
||||
if (uri.scheme == "pixiv") {
|
||||
@@ -198,15 +223,18 @@ class _LoginPageState extends State<LoginPage> {
|
||||
setState(() {
|
||||
waitingForAuth = true;
|
||||
});
|
||||
if(App.isMobile && mounted) {
|
||||
context.to(() => WebviewPage(url, onNavigation: (req) {
|
||||
if(req.url.startsWith("pixiv://")) {
|
||||
App.rootNavigatorKey.currentState!.pop();
|
||||
onLink?.call(Uri.parse(req.url));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},));
|
||||
if (!useExternal! && mounted) {
|
||||
context.to(() => WebviewPage(
|
||||
url,
|
||||
onNavigation: (req) {
|
||||
if (req.url.startsWith("pixiv://")) {
|
||||
App.rootNavigatorKey.currentState!.pop();
|
||||
onLink?.call(Uri.parse(req.url));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
));
|
||||
} else {
|
||||
launchUrlString(url);
|
||||
}
|
||||
@@ -219,7 +247,7 @@ class _LoginPageState extends State<LoginPage> {
|
||||
});
|
||||
var res = await Network().loginWithCode(code);
|
||||
if (res.error) {
|
||||
if(mounted) {
|
||||
if (mounted) {
|
||||
context.showToast(message: res.errorMessage!);
|
||||
}
|
||||
setState(() {
|
||||
|
@@ -34,7 +34,7 @@ class _LogsPageState extends State<LogsPage> {
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context).surfaceVariant,
|
||||
color: ColorScheme.of(context).surfaceContainerHighest,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||
),
|
||||
child: Padding(
|
||||
|
@@ -2,7 +2,7 @@ import "dart:async";
|
||||
|
||||
import "package:fluent_ui/fluent_ui.dart";
|
||||
import "package:flutter/foundation.dart";
|
||||
import "package:flutter/material.dart" as md;
|
||||
import "package:flutter/services.dart";
|
||||
import "package:pixes/appdata.dart";
|
||||
import "package:pixes/components/md.dart";
|
||||
import "package:pixes/foundation/app.dart";
|
||||
@@ -11,13 +11,18 @@ import "package:pixes/network/network.dart";
|
||||
import "package:pixes/pages/bookmarks.dart";
|
||||
import "package:pixes/pages/downloaded_page.dart";
|
||||
import "package:pixes/pages/following_artworks.dart";
|
||||
import "package:pixes/pages/following_novels_page.dart";
|
||||
import "package:pixes/pages/history.dart";
|
||||
import "package:pixes/pages/novel_bookmarks_page.dart";
|
||||
import "package:pixes/pages/novel_ranking_page.dart";
|
||||
import "package:pixes/pages/novel_recommendation_page.dart";
|
||||
import "package:pixes/pages/ranking.dart";
|
||||
import "package:pixes/pages/recommendation_page.dart";
|
||||
import "package:pixes/pages/login_page.dart";
|
||||
import "package:pixes/pages/search_page.dart";
|
||||
import "package:pixes/pages/settings_page.dart";
|
||||
import "package:pixes/pages/user_info_page.dart";
|
||||
import "package:pixes/utils/loop.dart";
|
||||
import "package:pixes/utils/mouse_listener.dart";
|
||||
import "package:pixes/utils/translation.dart";
|
||||
import "package:window_manager/window_manager.dart";
|
||||
@@ -28,6 +33,32 @@ import "downloading_page.dart";
|
||||
|
||||
double get _appBarHeight => App.isDesktop ? 36.0 : 48.0;
|
||||
|
||||
class TitleBarAction {
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final void Function() onPressed;
|
||||
|
||||
TitleBarAction(this.icon, this.title, this.onPressed);
|
||||
}
|
||||
|
||||
class TitleBarController extends StateController {
|
||||
TitleBarController();
|
||||
|
||||
final List<TitleBarAction> actions = [
|
||||
if (kDebugMode) TitleBarAction(MdIcons.bug_report, "Debug", debug)
|
||||
];
|
||||
|
||||
void addAction(TitleBarAction action) {
|
||||
actions.add(action);
|
||||
update();
|
||||
}
|
||||
|
||||
void removeAction(TitleBarAction action) {
|
||||
actions.remove(action);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
class MainPage extends StatefulWidget {
|
||||
const MainPage({super.key});
|
||||
|
||||
@@ -35,23 +66,43 @@ class MainPage extends StatefulWidget {
|
||||
State<MainPage> createState() => _MainPageState();
|
||||
}
|
||||
|
||||
class _MainPageState extends State<MainPage> with WindowListener {
|
||||
class _MainPageState extends State<MainPage>
|
||||
with WindowListener
|
||||
implements PopEntry {
|
||||
final navigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
int index = 4;
|
||||
|
||||
int windowButtonKey = 0;
|
||||
|
||||
ModalRoute<dynamic>? _route;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
StateController.put<TitleBarController>(TitleBarController());
|
||||
windowManager.addListener(this);
|
||||
listenMouseSideButtonToBack(navigatorKey);
|
||||
App.mainNavigatorKey = navigatorKey;
|
||||
index = appdata.settings["initialPage"] ?? 4;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
final ModalRoute<dynamic>? nextRoute = ModalRoute.of(context);
|
||||
if (nextRoute != _route) {
|
||||
_route?.unregisterPopEntry(this);
|
||||
_route = nextRoute;
|
||||
_route?.registerPopEntry(this);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
StateController.remove<TitleBarController>();
|
||||
windowManager.removeListener(this);
|
||||
ModalRoute.of(context)!.unregisterPopEntry(this);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -79,91 +130,124 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
content: LoginPage(() => setState(() {})),
|
||||
);
|
||||
}
|
||||
return md.Theme(
|
||||
data: md.ThemeData.from(
|
||||
useMaterial3: true,
|
||||
colorScheme: md.ColorScheme.fromSeed(
|
||||
seedColor: FluentTheme.of(context).accentColor.withOpacity(1),
|
||||
brightness: FluentTheme.of(context).brightness,
|
||||
)),
|
||||
child: DefaultSelectionStyle.merge(
|
||||
selectionColor: FluentTheme.of(context).selectionColor.withOpacity(0.4),
|
||||
child: NavigationView(
|
||||
appBar: buildAppBar(context, navigatorKey),
|
||||
pane: NavigationPane(
|
||||
selected: index,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
index = value;
|
||||
});
|
||||
navigate(value);
|
||||
},
|
||||
items: [
|
||||
UserPane(),
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.search, size: 20,),
|
||||
title: Text('Search'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.downloading, size: 20,),
|
||||
title: Text('Downloading'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.download, size: 20,),
|
||||
title: Text('Downloaded'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItemSeparator(),
|
||||
PaneItemHeader(header: Text("Artwork".tl).paddingBottom(4).paddingLeft(8)),
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.explore_outlined, size: 20,),
|
||||
title: Text('Explore'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.bookmark_outline, size: 20),
|
||||
title: Text('Bookmarks'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.interests_outlined, size: 20),
|
||||
title: Text('Following'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.history, size: 20),
|
||||
title: Text('History'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.leaderboard_outlined, size: 20),
|
||||
title: Text('Ranking'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
],
|
||||
footerItems: [
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.settings_outlined, size: 20),
|
||||
title: Text('Settings'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
],
|
||||
return DefaultSelectionStyle.merge(
|
||||
selectionColor: FluentTheme.of(context).selectionColor.toOpacity(0.4),
|
||||
child: NavigationView(
|
||||
appBar: buildAppBar(context, navigatorKey),
|
||||
pane: NavigationPane(
|
||||
selected: index,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
index = value;
|
||||
});
|
||||
navigate(value);
|
||||
},
|
||||
items: [
|
||||
UserPane(),
|
||||
PaneItem(
|
||||
icon: const Icon(
|
||||
MdIcons.search,
|
||||
size: 20,
|
||||
),
|
||||
paneBodyBuilder: (pane, child) => NavigatorPopHandler(
|
||||
key: const Key("navigator"),
|
||||
onPop: () => navigatorKey.currentState?.pop(),
|
||||
child: MediaQuery.removePadding(
|
||||
context: context,
|
||||
removeTop: true,
|
||||
child: Navigator(
|
||||
key: navigatorKey,
|
||||
onGenerateRoute: (settings) => AppPageRoute(
|
||||
builder: (context) => const RecommendationPage()),
|
||||
),
|
||||
))),
|
||||
));
|
||||
title: Text('Search'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItem(
|
||||
icon: const Icon(
|
||||
MdIcons.downloading,
|
||||
size: 20,
|
||||
),
|
||||
title: Text('Downloading'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItem(
|
||||
icon: const Icon(
|
||||
MdIcons.download,
|
||||
size: 20,
|
||||
),
|
||||
title: Text('Downloaded'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItemSeparator(),
|
||||
PaneItemHeader(
|
||||
header: Text('${"Illustrations".tl}/${"Manga".tl}')
|
||||
.paddingBottom(4)
|
||||
.paddingLeft(8)),
|
||||
PaneItem(
|
||||
icon: const Icon(
|
||||
MdIcons.explore_outlined,
|
||||
size: 20,
|
||||
),
|
||||
title: Text('Explore'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.bookmark_outline, size: 20),
|
||||
title: Text('Bookmarks'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.interests_outlined, size: 20),
|
||||
title: Text('Following'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.history, size: 20),
|
||||
title: Text('History'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.leaderboard_outlined, size: 20),
|
||||
title: Text('Ranking'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItemSeparator(),
|
||||
PaneItemHeader(
|
||||
header: Text("Novel".tl).paddingBottom(4).paddingLeft(8)),
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.featured_play_list_outlined, size: 20),
|
||||
title: Text('Recommendation'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.collections_bookmark_outlined, size: 20),
|
||||
title: Text('Bookmarks'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.interests_outlined, size: 20),
|
||||
title: Text('Following'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItem(
|
||||
icon: const Icon(MdIcons.leaderboard_outlined, size: 20),
|
||||
title: Text('Ranking'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
),
|
||||
PaneItemSeparator(),
|
||||
PaneItemAction(
|
||||
icon: const Icon(MdIcons.settings_outlined, size: 20),
|
||||
title: Text('Settings'.tl),
|
||||
body: const SizedBox.shrink(),
|
||||
onTap: () {
|
||||
navigatorKey.currentContext?.to(() => const SettingsPage());
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
paneBodyBuilder: (pane, child) => MediaQuery.removePadding(
|
||||
context: context,
|
||||
removeTop: true,
|
||||
child: Navigator(
|
||||
key: navigatorKey,
|
||||
onGenerateRoute: (settings) => AppPageRoute(
|
||||
isRoot: true,
|
||||
builder: (context) => pageBuilders.elementAtOrNull(index)!(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static final pageBuilders = <Widget Function()>[
|
||||
@@ -176,7 +260,10 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
() => const FollowingArtworksPage(),
|
||||
() => const HistoryPage(),
|
||||
() => const RankingPage(),
|
||||
() => const SettingsPage(),
|
||||
() => const NovelRecommendationPage(),
|
||||
() => const NovelBookmarksPage(),
|
||||
() => const FollowingNovelsPage(),
|
||||
() => const NovelRankingPage(),
|
||||
];
|
||||
|
||||
void navigate(int index) {
|
||||
@@ -185,7 +272,12 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
child: Text("Invalid Page: $index"),
|
||||
);
|
||||
navigatorKey.currentState!.pushAndRemoveUntil(
|
||||
AppPageRoute(builder: (context) => page()), (route) => false);
|
||||
AppPageRoute(
|
||||
builder: (context) => page(),
|
||||
isRoot: true,
|
||||
),
|
||||
(route) => false,
|
||||
);
|
||||
}
|
||||
|
||||
NavigationAppBar buildAppBar(
|
||||
@@ -194,41 +286,104 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
automaticallyImplyLeading: false,
|
||||
height: _appBarHeight,
|
||||
title: () {
|
||||
if (!App.isDesktop) {
|
||||
return const Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Text("pixes"),
|
||||
);
|
||||
}
|
||||
return const DragToMoveArea(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(bottom: 4),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Pixes",
|
||||
style: TextStyle(fontSize: 13),
|
||||
),
|
||||
Spacer(),
|
||||
if(kDebugMode)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 138),
|
||||
child: Button(onPressed: debug, child: Text("Debug")),
|
||||
)
|
||||
],
|
||||
return StateBuilder<TitleBarController>(
|
||||
builder: (controller) {
|
||||
Widget content = Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Row(
|
||||
children: [
|
||||
if (!App.isDesktop)
|
||||
const Text(
|
||||
"Pixes",
|
||||
style: TextStyle(fontSize: 13),
|
||||
),
|
||||
if (!App.isDesktop) const Spacer(),
|
||||
if (App.isDesktop)
|
||||
const Expanded(
|
||||
child: SizedBox(
|
||||
height: double.infinity,
|
||||
child: DragToMoveArea(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Pixes",
|
||||
style: TextStyle(fontSize: 13),
|
||||
),
|
||||
)),
|
||||
),
|
||||
),
|
||||
for (var action in controller.actions)
|
||||
Button(
|
||||
onPressed: action.onPressed,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
action.icon,
|
||||
size: 18,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(action.title),
|
||||
],
|
||||
),
|
||||
).paddingTop(4).paddingLeft(4),
|
||||
if (App.isDesktop)
|
||||
const SizedBox(width: 128)
|
||||
else
|
||||
Tooltip(
|
||||
message: "Search".tl,
|
||||
child: IconButton(
|
||||
icon: const Icon(
|
||||
MdIcons.search,
|
||||
size: 18,
|
||||
),
|
||||
onPressed: () {
|
||||
if (index == 1) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
index = 1;
|
||||
});
|
||||
navigate(1);
|
||||
},
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return content;
|
||||
},
|
||||
);
|
||||
}(),
|
||||
leading: _BackButton(navigatorKey),
|
||||
actions: App.isDesktop ? WindowButtons(
|
||||
key: ValueKey(windowButtonKey),
|
||||
) : null,
|
||||
actions: App.isDesktop
|
||||
? WindowButtons(
|
||||
key: ValueKey(windowButtonKey),
|
||||
)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
final popValue = ValueNotifier(false);
|
||||
|
||||
@override
|
||||
ValueListenable<bool> get canPopNotifier => popValue;
|
||||
|
||||
@override
|
||||
void onPopInvokedWithResult(bool didPop, result) {
|
||||
if (App.rootNavigatorKey.currentState?.canPop() ?? false) {
|
||||
App.rootNavigatorKey.currentState?.pop();
|
||||
} else if (App.mainNavigatorKey?.currentState?.canPop() ?? false) {
|
||||
App.mainNavigatorKey?.currentState?.pop();
|
||||
} else {
|
||||
SystemNavigator.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onPopInvoked(bool didPop) {}
|
||||
}
|
||||
|
||||
class _BackButton extends StatefulWidget {
|
||||
@@ -250,28 +405,22 @@ class _BackButtonState extends State<_BackButton> {
|
||||
@override
|
||||
void initState() {
|
||||
enabled = navigatorKey.currentState?.canPop() == true;
|
||||
loop();
|
||||
Loop.register(loop);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
timer = Timer.periodic(const Duration(milliseconds: 100), (timer) {
|
||||
if(!mounted) {
|
||||
timer.cancel();
|
||||
} else {
|
||||
bool enabled = navigatorKey.currentState?.canPop() == true;
|
||||
if(enabled != this.enabled) {
|
||||
setState(() {
|
||||
this.enabled = enabled;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
bool enabled = navigatorKey.currentState?.canPop() == true;
|
||||
if (enabled != this.enabled) {
|
||||
setState(() {
|
||||
this.enabled = enabled;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
timer?.cancel();
|
||||
Loop.remove(loop);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -285,7 +434,7 @@ class _BackButtonState extends State<_BackButton> {
|
||||
|
||||
return NavigationPaneTheme(
|
||||
data: NavigationPaneTheme.of(context).merge(NavigationPaneThemeData(
|
||||
unselectedIconColor: ButtonState.resolveWith((states) {
|
||||
unselectedIconColor: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.isDisabled) {
|
||||
return ButtonThemeData.buttonColor(context, states);
|
||||
}
|
||||
@@ -301,18 +450,19 @@ class _BackButtonState extends State<_BackButton> {
|
||||
title: const Text("Back"),
|
||||
body: const SizedBox.shrink(),
|
||||
enabled: enabled,
|
||||
).build(
|
||||
context,
|
||||
false,
|
||||
onPressed,
|
||||
displayMode: PaneDisplayMode.compact,
|
||||
).paddingTop(2),
|
||||
)
|
||||
.build(
|
||||
context,
|
||||
false,
|
||||
onPressed,
|
||||
displayMode: PaneDisplayMode.compact,
|
||||
)
|
||||
.paddingTop(2),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class WindowButtons extends StatelessWidget {
|
||||
const WindowButtons({super.key});
|
||||
|
||||
@@ -466,7 +616,8 @@ class UserPane extends PaneItem {
|
||||
child: Image(
|
||||
height: 48,
|
||||
width: 48,
|
||||
image: CachedImageProvider(appdata.account!.user.profile),
|
||||
image:
|
||||
CachedImageProvider(appdata.account!.user.profile),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
@@ -489,7 +640,9 @@ class UserPane extends PaneItem {
|
||||
fontSize: 16, fontWeight: FontWeight.w500),
|
||||
),
|
||||
Text(
|
||||
kDebugMode ? "<hide due to debug>" : appdata.account!.user.email,
|
||||
kDebugMode
|
||||
? "<hide due to debug>"
|
||||
: appdata.account!.user.email,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
)
|
||||
],
|
||||
@@ -534,16 +687,16 @@ class UserPane extends PaneItem {
|
||||
final tileColor = this.tileColor ??
|
||||
theme.tileColor ??
|
||||
kDefaultPaneItemColor(context, mode == PaneDisplayMode.top);
|
||||
final newStates = states.toSet()..remove(ButtonStates.disabled);
|
||||
final newStates = states.toSet()..remove(WidgetState.disabled);
|
||||
if (selected && selectedTileColor != null) {
|
||||
return selectedTileColor!.resolve(newStates);
|
||||
}
|
||||
return tileColor.resolve(
|
||||
selected
|
||||
? {
|
||||
states.isHovering
|
||||
? ButtonStates.pressing
|
||||
: ButtonStates.hovering,
|
||||
states.isHovered
|
||||
? WidgetState.pressed
|
||||
: WidgetState.hovered,
|
||||
}
|
||||
: newStates,
|
||||
);
|
||||
@@ -571,13 +724,16 @@ class UserPane extends PaneItem {
|
||||
/// Close
|
||||
class CloseIcon extends StatelessWidget {
|
||||
final Color color;
|
||||
|
||||
const CloseIcon({super.key, required this.color});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => _AlignedPaint(_ClosePainter(color));
|
||||
}
|
||||
|
||||
class _ClosePainter extends _IconPainter {
|
||||
_ClosePainter(super.color);
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
Paint p = getPaint(color, true);
|
||||
@@ -589,13 +745,16 @@ class _ClosePainter extends _IconPainter {
|
||||
/// Maximize
|
||||
class MaximizeIcon extends StatelessWidget {
|
||||
final Color color;
|
||||
|
||||
const MaximizeIcon({super.key, required this.color});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => _AlignedPaint(_MaximizePainter(color));
|
||||
}
|
||||
|
||||
class _MaximizePainter extends _IconPainter {
|
||||
_MaximizePainter(super.color);
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
Paint p = getPaint(color);
|
||||
@@ -606,16 +765,19 @@ class _MaximizePainter extends _IconPainter {
|
||||
/// Restore
|
||||
class RestoreIcon extends StatelessWidget {
|
||||
final Color color;
|
||||
|
||||
const RestoreIcon({
|
||||
super.key,
|
||||
required this.color,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => _AlignedPaint(_RestorePainter(color));
|
||||
}
|
||||
|
||||
class _RestorePainter extends _IconPainter {
|
||||
_RestorePainter(super.color);
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
Paint p = getPaint(color);
|
||||
@@ -632,13 +794,16 @@ class _RestorePainter extends _IconPainter {
|
||||
/// Minimize
|
||||
class MinimizeIcon extends StatelessWidget {
|
||||
final Color color;
|
||||
|
||||
const MinimizeIcon({super.key, required this.color});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => _AlignedPaint(_MinimizePainter(color));
|
||||
}
|
||||
|
||||
class _MinimizePainter extends _IconPainter {
|
||||
_MinimizePainter(super.color);
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
Paint p = getPaint(color);
|
||||
@@ -650,6 +815,7 @@ class _MinimizePainter extends _IconPainter {
|
||||
/// Helpers
|
||||
abstract class _IconPainter extends CustomPainter {
|
||||
_IconPainter(this.color);
|
||||
|
||||
final Color color;
|
||||
|
||||
@override
|
||||
@@ -658,6 +824,7 @@ abstract class _IconPainter extends CustomPainter {
|
||||
|
||||
class _AlignedPaint extends StatelessWidget {
|
||||
const _AlignedPaint(this.painter);
|
||||
|
||||
final CustomPainter painter;
|
||||
|
||||
@override
|
||||
|
84
lib/pages/novel_bookmarks_page.dart
Normal file
@@ -0,0 +1,84 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/appdata.dart';
|
||||
import 'package:pixes/components/grid.dart';
|
||||
import 'package:pixes/components/loading.dart';
|
||||
import 'package:pixes/components/novel.dart';
|
||||
import 'package:pixes/components/segmented_button.dart';
|
||||
import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/widget_utils.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
class NovelBookmarksPage extends StatefulWidget {
|
||||
const NovelBookmarksPage({super.key});
|
||||
|
||||
@override
|
||||
State<NovelBookmarksPage> createState() => _NovelBookmarksPageState();
|
||||
}
|
||||
|
||||
class _NovelBookmarksPageState
|
||||
extends MultiPageLoadingState<NovelBookmarksPage, Novel> {
|
||||
bool public = true;
|
||||
|
||||
@override
|
||||
Widget? buildFrame(BuildContext context, Widget child) {
|
||||
return Column(
|
||||
children: [
|
||||
TitleBar(
|
||||
title: "Bookmarks".tl,
|
||||
action: SegmentedButton(
|
||||
options: [
|
||||
SegmentedButtonOption("public", "Public".tl),
|
||||
SegmentedButtonOption("private", "Private".tl),
|
||||
],
|
||||
onPressed: (key) {
|
||||
var newPublic = key == "public";
|
||||
if (newPublic != public) {
|
||||
public = newPublic;
|
||||
nextUrl = null;
|
||||
reset();
|
||||
}
|
||||
},
|
||||
value: public ? "public" : "private",
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: child,
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, List<Novel> data) {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: GridViewWithFixedItemHeight(
|
||||
itemCount: data.length,
|
||||
itemHeight: 164,
|
||||
minCrossAxisExtent: 400,
|
||||
builder: (context, index) {
|
||||
if (index == data.length - 1) {
|
||||
nextPage();
|
||||
}
|
||||
return NovelWidget(data[index]);
|
||||
},
|
||||
).paddingHorizontal(8),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
String? nextUrl;
|
||||
|
||||
@override
|
||||
Future<Res<List<Novel>>> loadData(int page) async {
|
||||
if (nextUrl == "end") return Res.error("No more data");
|
||||
var res = nextUrl == null
|
||||
? await Network().getBookmarkedNovels(appdata.account!.user.id, public)
|
||||
: await Network().getNovelsWithNextUrl(nextUrl!);
|
||||
nextUrl = res.subData ?? "end";
|
||||
return res;
|
||||
}
|
||||
}
|
715
lib/pages/novel_page.dart
Normal file
@@ -0,0 +1,715 @@
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:pixes/components/animated_image.dart';
|
||||
import 'package:pixes/components/grid.dart';
|
||||
import 'package:pixes/components/loading.dart';
|
||||
import 'package:pixes/components/md.dart';
|
||||
import 'package:pixes/components/novel.dart';
|
||||
import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/foundation/image_provider.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/pages/comments_page.dart';
|
||||
import 'package:pixes/pages/novel_reading_page.dart';
|
||||
import 'package:pixes/pages/search_page.dart';
|
||||
import 'package:pixes/pages/user_info_page.dart';
|
||||
import 'package:pixes/utils/app_links.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
const kFluentButtonPadding = 28.0;
|
||||
|
||||
class NovelPage extends StatefulWidget {
|
||||
const NovelPage(this.novel, {super.key});
|
||||
|
||||
final Novel novel;
|
||||
|
||||
@override
|
||||
State<NovelPage> createState() => _NovelPageState();
|
||||
}
|
||||
|
||||
class _NovelPageState extends State<NovelPage> {
|
||||
final scrollController = ScrollController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scrollbar(
|
||||
controller: scrollController,
|
||||
child: ScrollConfiguration(
|
||||
behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),
|
||||
child: CustomScrollView(
|
||||
controller: scrollController,
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: buildTop(),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: buildActions(),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: buildDescription(),
|
||||
),
|
||||
if (widget.novel.seriesId != null)
|
||||
NovelSeriesWidget(
|
||||
widget.novel.seriesId!, widget.novel.seriesTitle!),
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 16 + MediaQuery.of(context).padding.bottom)),
|
||||
],
|
||||
),
|
||||
).padding(const EdgeInsets.symmetric(horizontal: 16)));
|
||||
}
|
||||
|
||||
Widget buildTop() {
|
||||
return Card(
|
||||
child: SizedBox(
|
||||
height: 128,
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 96,
|
||||
height: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context).secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: AnimatedImage(
|
||||
fit: BoxFit.cover,
|
||||
filterQuality: FilterQuality.medium,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
image: CachedImageProvider(widget.novel.image)),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(widget.novel.title,
|
||||
maxLines: 3,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
)),
|
||||
const SizedBox(height: 4),
|
||||
const Spacer(),
|
||||
if (widget.novel.seriesId != null)
|
||||
Text(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
"${"Series".tl}: ${widget.novel.seriesTitle!}",
|
||||
style: TextStyle(
|
||||
color: ColorScheme.of(context).primary,
|
||||
fontSize: 12,
|
||||
),
|
||||
).paddingVertical(4)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)).paddingTop(12);
|
||||
}
|
||||
|
||||
Widget buildStats() {
|
||||
return Container(
|
||||
height: 74,
|
||||
constraints: const BoxConstraints(maxWidth: 560),
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(width: 2),
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 68,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
width: 0.6,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(
|
||||
FluentIcons.view,
|
||||
size: 20,
|
||||
),
|
||||
Text(
|
||||
"Views".tl,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
widget.novel.totalViews.toString(),
|
||||
style: TextStyle(
|
||||
color: ColorScheme.of(context).primary,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 18,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 68,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant,
|
||||
width: 0.6,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(
|
||||
FluentIcons.six_point_star,
|
||||
size: 20,
|
||||
),
|
||||
Text(
|
||||
"Favorites".tl,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
widget.novel.totalBookmarks.toString(),
|
||||
style: TextStyle(
|
||||
color: ColorScheme.of(context).primary,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 18,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)),
|
||||
const SizedBox(width: 2),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildAuthor() {
|
||||
return ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 560),
|
||||
child: Card(
|
||||
margin: const EdgeInsets.only(left: 2, right: 2, bottom: 12),
|
||||
borderColor: ColorScheme.of(context).outlineVariant.toOpacity(0.52),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
context.to(() => UserInfoPage(widget.novel.author.id.toString()));
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 38,
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context).secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(36),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: AnimatedImage(
|
||||
fit: BoxFit.cover,
|
||||
width: 36,
|
||||
height: 36,
|
||||
filterQuality: FilterQuality.medium,
|
||||
image: CachedImageProvider(widget.novel.author.avatar),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
widget.novel.author.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
widget.novel.createDate.toString().substring(0, 10),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: ColorScheme.of(context).outline,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Icon(MdIcons.chevron_right)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
bool isAddingFavorite = false;
|
||||
|
||||
var favoriteFlyout = FlyoutController();
|
||||
|
||||
Widget buildActions() {
|
||||
void favorite() async {
|
||||
if (isAddingFavorite) return;
|
||||
bool? public;
|
||||
if (!widget.novel.isBookmarked) {
|
||||
await favoriteFlyout.showFlyout(
|
||||
navigatorKey: App.rootNavigatorKey.currentState!,
|
||||
builder: (context) {
|
||||
return MenuFlyout(
|
||||
items: [
|
||||
MenuFlyoutItem(
|
||||
text: Text("Public".tl),
|
||||
onPressed: () {
|
||||
public = true;
|
||||
},
|
||||
),
|
||||
MenuFlyoutItem(
|
||||
text: Text("Private".tl),
|
||||
onPressed: () {
|
||||
public = false;
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
if (public == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
setState(() {
|
||||
isAddingFavorite = true;
|
||||
});
|
||||
var res = widget.novel.isBookmarked
|
||||
? await Network().deleteFavoriteNovel(widget.novel.id.toString())
|
||||
: await Network().favoriteNovel(widget.novel.id.toString(), public!);
|
||||
if (res.error) {
|
||||
if (mounted) {
|
||||
context.showToast(message: res.errorMessage ?? "Network Error");
|
||||
}
|
||||
} else {
|
||||
widget.novel.isBookmarked = !widget.novel.isBookmarked;
|
||||
}
|
||||
setState(() {
|
||||
isAddingFavorite = false;
|
||||
});
|
||||
}
|
||||
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
final width = constraints.maxWidth;
|
||||
return Card(
|
||||
margin: const EdgeInsets.only(top: 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (width < 560) buildAuthor().toAlign(Alignment.centerLeft),
|
||||
if (width < 560) buildStats().toAlign(Alignment.centerLeft),
|
||||
if (width >= 560)
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 1132),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: buildAuthor()),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: buildStats()),
|
||||
],
|
||||
),
|
||||
).toAlign(Alignment.centerLeft),
|
||||
LayoutBuilder(
|
||||
builder: (context, constrains) {
|
||||
var width = constrains.maxWidth;
|
||||
bool shouldFillSpace = width < 500;
|
||||
return Row(
|
||||
children: [
|
||||
FilledButton(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(MdIcons.menu_book_outlined, size: 18),
|
||||
const SizedBox(width: 12),
|
||||
Text("Read".tl),
|
||||
const Spacer(),
|
||||
const Icon(MdIcons.chevron_right, size: 18)
|
||||
.paddingTop(2),
|
||||
],
|
||||
)
|
||||
.fixWidth(shouldFillSpace
|
||||
? width / 2 - 4 - kFluentButtonPadding
|
||||
: 220)
|
||||
.fixHeight(32),
|
||||
onPressed: () {
|
||||
context.to(() => NovelReadingPage(widget.novel));
|
||||
}),
|
||||
const SizedBox(width: 16),
|
||||
FlyoutTarget(
|
||||
controller: favoriteFlyout,
|
||||
child: Button(
|
||||
onPressed: favorite,
|
||||
child: Row(
|
||||
mainAxisAlignment: constrains.maxWidth > 420
|
||||
? MainAxisAlignment.start
|
||||
: MainAxisAlignment.center,
|
||||
children: [
|
||||
if (isAddingFavorite)
|
||||
const SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: ProgressRing(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
else if (widget.novel.isBookmarked)
|
||||
Icon(
|
||||
MdIcons.favorite,
|
||||
size: 18,
|
||||
color: ColorScheme.of(context).error,
|
||||
)
|
||||
else
|
||||
const Icon(MdIcons.favorite_outline, size: 18),
|
||||
if (constrains.maxWidth > 420)
|
||||
const SizedBox(width: 12),
|
||||
if (constrains.maxWidth > 420) Text("Favorite".tl)
|
||||
],
|
||||
)
|
||||
.fixWidth(shouldFillSpace
|
||||
? width / 4 - 4 - kFluentButtonPadding
|
||||
: 64)
|
||||
.fixHeight(32),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Button(
|
||||
child: Row(
|
||||
mainAxisAlignment: constrains.maxWidth > 420
|
||||
? MainAxisAlignment.start
|
||||
: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(MdIcons.comment, size: 18),
|
||||
if (constrains.maxWidth > 420)
|
||||
const SizedBox(width: 12),
|
||||
if (constrains.maxWidth > 420) Text("Comments".tl)
|
||||
],
|
||||
)
|
||||
.fixWidth(shouldFillSpace
|
||||
? width / 4 - 4 - kFluentButtonPadding
|
||||
: 64)
|
||||
.fixHeight(32),
|
||||
onPressed: () {
|
||||
CommentsPage.show(context, widget.novel.id.toString(),
|
||||
isNovel: true);
|
||||
}),
|
||||
],
|
||||
);
|
||||
},
|
||||
).paddingHorizontal(2),
|
||||
SelectableText(
|
||||
"ID: ${widget.novel.id}",
|
||||
style: TextStyle(
|
||||
fontSize: 13, color: ColorScheme.of(context).outline),
|
||||
).paddingTop(8).paddingLeft(2),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget buildDescription() {
|
||||
return Card(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Description".tl,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SelectableText.rich(
|
||||
TextSpan(children: buildDescriptionText().toList())),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.start,
|
||||
children: [
|
||||
for (final tag in widget.novel.tags)
|
||||
MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
context.to(() => SearchNovelResultPage(tag.name));
|
||||
},
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(right: 8, bottom: 6),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorScheme.of(context).primaryContainer,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
tag.name,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Button(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(MdIcons.bookmark_outline, size: 18),
|
||||
const SizedBox(width: 12),
|
||||
Text("Related".tl)
|
||||
],
|
||||
).fixWidth(64).fixHeight(32),
|
||||
onPressed: () {
|
||||
context
|
||||
.to(() => _RelatedNovelsPage(widget.novel.id.toString()));
|
||||
}),
|
||||
],
|
||||
),
|
||||
).paddingTop(12);
|
||||
}
|
||||
|
||||
Iterable<TextSpan> buildDescriptionText() sync* {
|
||||
var text = widget.novel.caption;
|
||||
text = text.replaceAll("<br />", "\n");
|
||||
text = text.replaceAll('\n\n', '\n');
|
||||
var labels = Queue<String>();
|
||||
var buffer = StringBuffer();
|
||||
var style = const TextStyle();
|
||||
String? link;
|
||||
Map<String, String> attributes = {};
|
||||
for (int i = 0; i < text.length; i++) {
|
||||
if (text[i] == '<' && text[i + 1] != '/') {
|
||||
var label =
|
||||
text.substring(i + 1, text.indexOf('>', i)).split(' ').first;
|
||||
labels.addLast(label);
|
||||
for (var part
|
||||
in text.substring(i + 1, text.indexOf('>', i)).split(' ')) {
|
||||
var kv = part.split('=');
|
||||
if (kv.length >= 2) {
|
||||
attributes[kv[0]] =
|
||||
kv.join('=').substring(kv[0].length + 2).replaceAll('"', '');
|
||||
}
|
||||
}
|
||||
i = text.indexOf('>', i);
|
||||
} else if (text[i] == '<' && text[i + 1] == '/') {
|
||||
var label = text.substring(i + 2, text.indexOf('>', i));
|
||||
if (label == labels.last) {
|
||||
switch (label) {
|
||||
case "strong":
|
||||
style = style.copyWith(fontWeight: FontWeight.bold);
|
||||
case "a":
|
||||
style = style.copyWith(color: ColorScheme.of(context).primary);
|
||||
link = attributes["href"];
|
||||
}
|
||||
labels.removeLast();
|
||||
}
|
||||
i = text.indexOf('>', i);
|
||||
} else {
|
||||
buffer.write(text[i]);
|
||||
}
|
||||
|
||||
if (i + 1 >= text.length ||
|
||||
(labels.isEmpty &&
|
||||
(text[i + 1] == '<' || (i != 0 && text[i - 1] == '>')))) {
|
||||
var content = buffer.toString();
|
||||
var url = link;
|
||||
yield TextSpan(
|
||||
text: content,
|
||||
style: style,
|
||||
recognizer: url != null
|
||||
? (TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
if (!handleLink(Uri.parse(url))) {
|
||||
launchUrlString(url);
|
||||
}
|
||||
})
|
||||
: null);
|
||||
buffer.clear();
|
||||
link = null;
|
||||
attributes.clear();
|
||||
style = const TextStyle();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class NovelSeriesWidget extends StatefulWidget {
|
||||
const NovelSeriesWidget(this.seriesId, this.title, {super.key});
|
||||
|
||||
final int seriesId;
|
||||
|
||||
final String title;
|
||||
|
||||
@override
|
||||
State<NovelSeriesWidget> createState() => _NovelSeriesWidgetState();
|
||||
}
|
||||
|
||||
class _NovelSeriesWidgetState
|
||||
extends MultiPageLoadingState<NovelSeriesWidget, Novel> {
|
||||
@override
|
||||
Widget? buildFrame(BuildContext context, Widget child) {
|
||||
return DecoratedSliver(
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context).cardColor,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant.toOpacity(0.6),
|
||||
width: 0.5,
|
||||
)),
|
||||
sliver: SliverMainAxisGroup(slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: Text(widget.title.trim(),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
)).paddingTop(16).paddingLeft(12).paddingRight(12),
|
||||
),
|
||||
const SliverPadding(padding: EdgeInsets.only(top: 8)),
|
||||
child
|
||||
]),
|
||||
).sliverPadding(const EdgeInsets.only(top: 16));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildLoading(BuildContext context) {
|
||||
return SliverToBoxAdapter(
|
||||
child: const Center(
|
||||
child: ProgressRing(),
|
||||
).fixHeight(124),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildError(BuildContext context, String error) {
|
||||
return SliverToBoxAdapter(
|
||||
child: Center(
|
||||
child: Text(error),
|
||||
).fixHeight(124),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Novel> data) {
|
||||
return SliverGridViewWithFixedItemHeight(
|
||||
itemHeight: 164,
|
||||
minCrossAxisExtent: 400,
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index == data.length - 1) {
|
||||
nextPage();
|
||||
}
|
||||
return NovelWidget(data[index]);
|
||||
},
|
||||
childCount: data.length,
|
||||
),
|
||||
).sliverPadding(const EdgeInsets.symmetric(horizontal: 8));
|
||||
}
|
||||
|
||||
String? nextUrl;
|
||||
|
||||
@override
|
||||
Future<Res<List<Novel>>> loadData(page) async {
|
||||
if (nextUrl == "end") {
|
||||
return Res.error("No more data");
|
||||
}
|
||||
var res =
|
||||
await Network().getNovelSeries(widget.seriesId.toString(), nextUrl);
|
||||
if (!res.error) {
|
||||
nextUrl = res.subData;
|
||||
nextUrl ??= "end";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
class NovelPageWithId extends StatefulWidget {
|
||||
const NovelPageWithId(this.id, {super.key});
|
||||
|
||||
final String id;
|
||||
|
||||
@override
|
||||
State<NovelPageWithId> createState() => _NovelPageWithIdState();
|
||||
}
|
||||
|
||||
class _NovelPageWithIdState extends LoadingState<NovelPageWithId, Novel> {
|
||||
@override
|
||||
Future<Res<Novel>> loadData() async {
|
||||
return Network().getNovelDetail(widget.id);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, Novel data) {
|
||||
return NovelPage(data);
|
||||
}
|
||||
}
|
||||
|
||||
class _RelatedNovelsPage extends StatefulWidget {
|
||||
const _RelatedNovelsPage(this.id);
|
||||
|
||||
final String id;
|
||||
|
||||
@override
|
||||
State<_RelatedNovelsPage> createState() => __RelatedNovelsPageState();
|
||||
}
|
||||
|
||||
class __RelatedNovelsPageState
|
||||
extends LoadingState<_RelatedNovelsPage, List<Novel>> {
|
||||
@override
|
||||
Widget buildContent(BuildContext context, List<Novel> data) {
|
||||
return Column(
|
||||
children: [
|
||||
TitleBar(title: "Related Novels".tl),
|
||||
Expanded(
|
||||
child: GridViewWithFixedItemHeight(
|
||||
itemHeight: 164,
|
||||
itemCount: data.length,
|
||||
minCrossAxisExtent: 400,
|
||||
builder: (context, index) {
|
||||
return NovelWidget(data[index]);
|
||||
},
|
||||
)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Res<List<Novel>>> loadData() async {
|
||||
return Network().relatedNovels(widget.id);
|
||||
}
|
||||
}
|
102
lib/pages/novel_ranking_page.dart
Normal file
@@ -0,0 +1,102 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/components/loading.dart';
|
||||
import 'package:pixes/components/novel.dart';
|
||||
import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../components/grid.dart';
|
||||
|
||||
class NovelRankingPage extends StatefulWidget {
|
||||
const NovelRankingPage({super.key});
|
||||
|
||||
@override
|
||||
State<NovelRankingPage> createState() => _NovelRankingPageState();
|
||||
}
|
||||
|
||||
class _NovelRankingPageState extends State<NovelRankingPage> {
|
||||
String type = "day";
|
||||
|
||||
/// mode: day, day_male, day_female, week_rookie, week, week_ai
|
||||
static const types = {
|
||||
"day": "Daily",
|
||||
"week": "Weekly",
|
||||
"day_male": "For male",
|
||||
"day_female": "For female",
|
||||
"week_rookie": "Rookies",
|
||||
};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ScaffoldPage(
|
||||
padding: EdgeInsets.zero,
|
||||
content: Column(
|
||||
children: [
|
||||
buildHeader(),
|
||||
Expanded(
|
||||
child: _OneRankingPage(type, key: Key(type),),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildHeader() {
|
||||
return TitleBar(
|
||||
title: "Ranking".tl,
|
||||
action: DropDownButton(
|
||||
title: Text(types[type]!.tl),
|
||||
items: types.entries.map((e) => MenuFlyoutItem(
|
||||
text: Text(e.value.tl),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
type = e.key;
|
||||
});
|
||||
},
|
||||
)).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _OneRankingPage extends StatefulWidget {
|
||||
const _OneRankingPage(this.type, {super.key});
|
||||
|
||||
final String type;
|
||||
|
||||
@override
|
||||
State<_OneRankingPage> createState() => _OneRankingPageState();
|
||||
}
|
||||
|
||||
class _OneRankingPageState extends MultiPageLoadingState<_OneRankingPage, Novel> {
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Novel> data) {
|
||||
return GridViewWithFixedItemHeight(
|
||||
itemCount: data.length,
|
||||
itemHeight: 164,
|
||||
minCrossAxisExtent: 400,
|
||||
builder: (context, index) {
|
||||
if (index == data.length - 1) {
|
||||
nextPage();
|
||||
}
|
||||
return NovelWidget(data[index]);
|
||||
},
|
||||
).paddingHorizontal(8);
|
||||
}
|
||||
|
||||
String? nextUrl;
|
||||
|
||||
@override
|
||||
Future<Res<List<Novel>>> loadData(page) async{
|
||||
if(nextUrl == "end") {
|
||||
return Res.error("No more data");
|
||||
}
|
||||
var res = await Network().getNovelRanking(widget.type, null);
|
||||
if(!res.error) {
|
||||
nextUrl = res.subData;
|
||||
nextUrl ??= "end";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
366
lib/pages/novel_reading_page.dart
Normal file
@@ -0,0 +1,366 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/appdata.dart';
|
||||
import 'package:pixes/components/animated_image.dart';
|
||||
import 'package:pixes/components/loading.dart';
|
||||
import 'package:pixes/components/md.dart';
|
||||
import 'package:pixes/components/page_route.dart';
|
||||
import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/foundation/image_provider.dart';
|
||||
import 'package:pixes/foundation/log.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/network/translator.dart';
|
||||
import 'package:pixes/pages/image_page.dart';
|
||||
import 'package:pixes/pages/main_page.dart';
|
||||
import 'package:pixes/utils/ext.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
class NovelReadingPage extends StatefulWidget {
|
||||
const NovelReadingPage(this.novel, {super.key});
|
||||
|
||||
final Novel novel;
|
||||
|
||||
@override
|
||||
State<NovelReadingPage> createState() => _NovelReadingPageState();
|
||||
}
|
||||
|
||||
class _NovelReadingPageState extends LoadingState<NovelReadingPage, String> {
|
||||
TitleBarAction? action;
|
||||
|
||||
bool isShowingSettings = false;
|
||||
|
||||
String? translatedContent;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
action = TitleBarAction(MdIcons.tune, "Settings".tl, () {
|
||||
if (!isShowingSettings) {
|
||||
_NovelReadingSettings.show(
|
||||
context,
|
||||
() {
|
||||
setState(() {});
|
||||
},
|
||||
TranslationController(
|
||||
content: data!,
|
||||
isTranslated: translatedContent != null,
|
||||
onTranslated: (s) {
|
||||
setState(() {
|
||||
translatedContent = s;
|
||||
});
|
||||
},
|
||||
revert: () {
|
||||
setState(() {
|
||||
translatedContent = null;
|
||||
});
|
||||
},
|
||||
),
|
||||
).then(
|
||||
(value) {
|
||||
isShowingSettings = false;
|
||||
},
|
||||
);
|
||||
isShowingSettings = true;
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
});
|
||||
Future.delayed(const Duration(milliseconds: 200), () {
|
||||
StateController.find<TitleBarController>().addAction(action!);
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
Future.delayed(const Duration(milliseconds: 200), () {
|
||||
StateController.find<TitleBarController>().removeAction(action!);
|
||||
});
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, String data) {
|
||||
var content = buildList(context).toList();
|
||||
return ScaffoldPage(
|
||||
padding: EdgeInsets.zero,
|
||||
content: SelectionArea(
|
||||
child: DefaultTextStyle.merge(
|
||||
style: const TextStyle(fontSize: 16.0, height: 1.6),
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
itemBuilder: (context, index) {
|
||||
return content[index];
|
||||
},
|
||||
itemCount: content.length,
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Res<String>> loadData() {
|
||||
return Network().getNovelContent(widget.novel.id.toString());
|
||||
}
|
||||
|
||||
Iterable<Widget> buildList(BuildContext context) sync* {
|
||||
double fontSizeAdd = appdata.settings["readingFontSize"] - 16.0;
|
||||
double fontHeight = appdata.settings["readingLineHeight"];
|
||||
|
||||
yield Text(widget.novel.title,
|
||||
style: TextStyle(
|
||||
fontSize: 24.0 + fontSizeAdd, fontWeight: FontWeight.bold));
|
||||
yield const SizedBox(height: 12.0);
|
||||
yield const Divider(
|
||||
style: DividerThemeData(horizontalMargin: EdgeInsets.all(0)),
|
||||
);
|
||||
yield const SizedBox(height: 12.0);
|
||||
|
||||
var novelContent = (translatedContent ?? data!).split('\n');
|
||||
for (var content in novelContent) {
|
||||
if (content.isEmpty) continue;
|
||||
if (content.startsWith('[uploadedimage:')) {
|
||||
var imageId = content.nums;
|
||||
yield GestureDetector(
|
||||
onTap: () {
|
||||
ImagePage.show(["novel:${widget.novel.id.toString()}/$imageId"]);
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 300,
|
||||
width: double.infinity,
|
||||
child: AnimatedImage(
|
||||
image:
|
||||
CachedNovelImageProvider(widget.novel.id.toString(), imageId),
|
||||
filterQuality: FilterQuality.medium,
|
||||
fit: BoxFit.contain,
|
||||
height: 300,
|
||||
width: double.infinity,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (content.startsWith('[chapter:')) {
|
||||
var title = content.replaceLast(']', '').split(':')[1];
|
||||
yield Text(title,
|
||||
style: TextStyle(
|
||||
fontSize: 20.0 + fontSizeAdd,
|
||||
fontWeight: FontWeight.bold,
|
||||
height: fontHeight))
|
||||
.paddingBottom(8);
|
||||
} else {
|
||||
yield Text(content,
|
||||
style:
|
||||
TextStyle(fontSize: 16.0 + fontSizeAdd, height: fontHeight))
|
||||
.paddingBottom(appdata.settings["readingParagraphSpacing"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TranslationController {
|
||||
final String content;
|
||||
|
||||
final bool isTranslated;
|
||||
|
||||
final void Function(String translated) onTranslated;
|
||||
|
||||
final void Function() revert;
|
||||
|
||||
const TranslationController({
|
||||
required this.content,
|
||||
required this.isTranslated,
|
||||
required this.onTranslated,
|
||||
required this.revert,
|
||||
});
|
||||
}
|
||||
|
||||
class _NovelReadingSettings extends StatefulWidget {
|
||||
const _NovelReadingSettings(this.callback, this.controller);
|
||||
|
||||
final void Function() callback;
|
||||
|
||||
final TranslationController controller;
|
||||
|
||||
static Future show(
|
||||
BuildContext context,
|
||||
void Function() callback,
|
||||
TranslationController controller,
|
||||
) {
|
||||
return Navigator.of(context).push(
|
||||
SideBarRoute(_NovelReadingSettings(callback, controller)),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
State<_NovelReadingSettings> createState() => __NovelReadingSettingsState();
|
||||
}
|
||||
|
||||
class __NovelReadingSettingsState extends State<_NovelReadingSettings> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
TitleBar(title: "Reading Settings".tl),
|
||||
const SizedBox(height: 8),
|
||||
Card(
|
||||
padding: EdgeInsets.zero,
|
||||
child: ListTile(
|
||||
title: Text("Font Size".tl),
|
||||
subtitle: Slider(
|
||||
value: appdata.settings["readingFontSize"],
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
appdata.settings["readingFontSize"] = value;
|
||||
});
|
||||
appdata.writeSettings();
|
||||
widget.callback();
|
||||
},
|
||||
min: 12.0,
|
||||
max: 24.0,
|
||||
divisions: 12,
|
||||
label: appdata.settings["readingFontSize"].toString(),
|
||||
),
|
||||
trailing: Text(appdata.settings["readingFontSize"].toString()),
|
||||
),
|
||||
).paddingHorizontal(8).paddingBottom(8),
|
||||
Card(
|
||||
padding: EdgeInsets.zero,
|
||||
child: ListTile(
|
||||
title: Text("Line Height".tl),
|
||||
subtitle: Slider(
|
||||
value: appdata.settings["readingLineHeight"],
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
appdata.settings["readingLineHeight"] = value;
|
||||
});
|
||||
appdata.writeSettings();
|
||||
widget.callback();
|
||||
},
|
||||
min: 1.0,
|
||||
max: 2.0,
|
||||
divisions: 10,
|
||||
label: appdata.settings["readingLineHeight"].toString(),
|
||||
),
|
||||
trailing: Text(appdata.settings["readingLineHeight"].toString()),
|
||||
),
|
||||
).paddingHorizontal(8).paddingBottom(8),
|
||||
Card(
|
||||
padding: EdgeInsets.zero,
|
||||
child: ListTile(
|
||||
title: Text("Paragraph Spacing".tl),
|
||||
subtitle: Slider(
|
||||
value: appdata.settings["readingParagraphSpacing"],
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
appdata.settings["readingParagraphSpacing"] = value;
|
||||
});
|
||||
appdata.writeSettings();
|
||||
widget.callback();
|
||||
},
|
||||
min: 0.0,
|
||||
max: 16.0,
|
||||
divisions: 8,
|
||||
label: appdata.settings["readingParagraphSpacing"].toString(),
|
||||
),
|
||||
trailing:
|
||||
Text(appdata.settings["readingParagraphSpacing"].toString()),
|
||||
),
|
||||
).paddingHorizontal(8).paddingBottom(8),
|
||||
// 深色模式
|
||||
Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8),
|
||||
padding: EdgeInsets.zero,
|
||||
child: ListTile(
|
||||
title: Text("Theme".tl),
|
||||
trailing: DropDownButton(
|
||||
title: Text(appdata.settings["theme"] ?? "System".tl),
|
||||
items: [
|
||||
MenuFlyoutItem(
|
||||
text: Text("System".tl),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "System";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: Text("light".tl),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "Light";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: Text("dark".tl),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "Dark";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
]),
|
||||
),
|
||||
).paddingBottom(8),
|
||||
Card(
|
||||
padding: EdgeInsets.zero,
|
||||
child: ListTile(
|
||||
title: Text("Translate Novel".tl),
|
||||
trailing: widget.controller.isTranslated
|
||||
? Button(
|
||||
onPressed: () {
|
||||
widget.controller.revert();
|
||||
context.pop();
|
||||
},
|
||||
child: Text("Revert".tl),
|
||||
)
|
||||
: Button(
|
||||
onPressed: translate,
|
||||
child: isTranslating
|
||||
? const SizedBox(
|
||||
width: 42,
|
||||
height: 18,
|
||||
child: Center(
|
||||
child: SizedBox.square(
|
||||
dimension: 18,
|
||||
child: ProgressRing(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: Text("Translate".tl),
|
||||
),
|
||||
),
|
||||
).paddingHorizontal(8).paddingBottom(8),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
bool isTranslating = false;
|
||||
|
||||
void translate() async {
|
||||
setState(() {
|
||||
isTranslating = true;
|
||||
});
|
||||
try {
|
||||
var translated = await Translator.instance
|
||||
.translate(widget.controller.content, "zh-CN");
|
||||
widget.controller.onTranslated(translated);
|
||||
if (mounted) {
|
||||
context.pop();
|
||||
}
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
isTranslating = false;
|
||||
});
|
||||
if (mounted) {
|
||||
context.showToast(message: "Failed to translate".tl);
|
||||
}
|
||||
Log.error("Translate", e.toString());
|
||||
}
|
||||
}
|
||||
}
|
46
lib/pages/novel_recommendation_page.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/components/grid.dart';
|
||||
import 'package:pixes/components/loading.dart';
|
||||
import 'package:pixes/components/novel.dart';
|
||||
import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
class NovelRecommendationPage extends StatefulWidget {
|
||||
const NovelRecommendationPage({super.key});
|
||||
|
||||
@override
|
||||
State<NovelRecommendationPage> createState() =>
|
||||
_NovelRecommendationPageState();
|
||||
}
|
||||
|
||||
class _NovelRecommendationPageState
|
||||
extends MultiPageLoadingState<NovelRecommendationPage, Novel> {
|
||||
@override
|
||||
Widget buildContent(BuildContext context, List<Novel> data) {
|
||||
return Column(
|
||||
children: [
|
||||
TitleBar(title: "Recommendation".tl),
|
||||
Expanded(
|
||||
child: GridViewWithFixedItemHeight(
|
||||
itemCount: data.length,
|
||||
itemHeight: 164,
|
||||
minCrossAxisExtent: 400,
|
||||
builder: (context, index) {
|
||||
if (index == data.length - 1) {
|
||||
nextPage();
|
||||
}
|
||||
return NovelWidget(data[index]);
|
||||
},
|
||||
).paddingHorizontal(8),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Res<List<Novel>>> loadData(int page) {
|
||||
return Network().getRecommendNovels();
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/utils/block.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../components/batch_download.dart';
|
||||
@@ -8,6 +9,7 @@ import '../components/illust_widget.dart';
|
||||
import '../components/loading.dart';
|
||||
import '../components/title_bar.dart';
|
||||
import '../network/network.dart';
|
||||
import 'illust_page.dart';
|
||||
|
||||
class RankingPage extends StatefulWidget {
|
||||
const RankingPage({super.key});
|
||||
@@ -85,6 +87,7 @@ class _OneRankingPage extends StatefulWidget {
|
||||
class _OneRankingPageState extends MultiPageLoadingState<_OneRankingPage, Illust> {
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
checkIllusts(data);
|
||||
return LayoutBuilder(builder: (context, constrains){
|
||||
return MasonryGridView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8)
|
||||
@@ -97,7 +100,13 @@ class _OneRankingPageState extends MultiPageLoadingState<_OneRankingPage, Illust
|
||||
if(index == data.length - 1){
|
||||
nextPage();
|
||||
}
|
||||
return IllustWidget(data[index]);
|
||||
return IllustWidget(data[index], onTap: () {
|
||||
context.to(() => IllustGalleryPage(
|
||||
illusts: data,
|
||||
initialPage: index,
|
||||
nextUrl: nextUrl
|
||||
));
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
@@ -5,6 +5,8 @@ import 'package:pixes/components/loading.dart';
|
||||
import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/pages/illust_page.dart';
|
||||
import 'package:pixes/utils/block.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../components/grid.dart';
|
||||
@@ -28,8 +30,11 @@ class _RecommendationPageState extends State<RecommendationPage> {
|
||||
buildTab(),
|
||||
Expanded(
|
||||
child: type != 2
|
||||
? _RecommendationArtworksPage(type, key: Key(type.toString()),)
|
||||
: const _RecommendationUsersPage(),
|
||||
? _RecommendationArtworksPage(
|
||||
type,
|
||||
key: Key(type.toString()),
|
||||
)
|
||||
: const _RecommendationUsersPage(),
|
||||
)
|
||||
],
|
||||
);
|
||||
@@ -40,12 +45,12 @@ class _RecommendationPageState extends State<RecommendationPage> {
|
||||
title: "Explore".tl,
|
||||
action: SegmentedButton<int>(
|
||||
options: [
|
||||
SegmentedButtonOption(0, "Artworks".tl),
|
||||
SegmentedButtonOption(0, "Illustrations".tl),
|
||||
SegmentedButtonOption(1, "Mangas".tl),
|
||||
SegmentedButtonOption(2, "Users".tl),
|
||||
],
|
||||
onPressed: (key) {
|
||||
if(key != type) {
|
||||
if (key != type) {
|
||||
setState(() {
|
||||
type = key;
|
||||
});
|
||||
@@ -57,32 +62,43 @@ class _RecommendationPageState extends State<RecommendationPage> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class _RecommendationArtworksPage extends StatefulWidget {
|
||||
const _RecommendationArtworksPage(this.type, {super.key});
|
||||
|
||||
final int type;
|
||||
|
||||
@override
|
||||
State<_RecommendationArtworksPage> createState() => _RecommendationArtworksPageState();
|
||||
State<_RecommendationArtworksPage> createState() =>
|
||||
_RecommendationArtworksPageState();
|
||||
}
|
||||
|
||||
class _RecommendationArtworksPageState extends MultiPageLoadingState<_RecommendationArtworksPage, Illust> {
|
||||
class _RecommendationArtworksPageState
|
||||
extends MultiPageLoadingState<_RecommendationArtworksPage, Illust> {
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
return LayoutBuilder(builder: (context, constrains){
|
||||
checkIllusts(data);
|
||||
return LayoutBuilder(builder: (context, constrains) {
|
||||
return MasonryGridView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8)
|
||||
+ EdgeInsets.only(bottom: context.padding.bottom),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8) +
|
||||
EdgeInsets.only(bottom: context.padding.bottom),
|
||||
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 240,
|
||||
),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, index) {
|
||||
if(index == data.length - 1){
|
||||
if (index == data.length - 1) {
|
||||
nextPage();
|
||||
}
|
||||
return IllustWidget(data[index]);
|
||||
return IllustWidget(
|
||||
data[index],
|
||||
onTap: () {
|
||||
context.to(() => IllustGalleryPage(
|
||||
illusts: data,
|
||||
initialPage: index,
|
||||
nextUrl: Network.recommendationUrl,
|
||||
));
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -100,33 +116,32 @@ class _RecommendationUsersPage extends StatefulWidget {
|
||||
const _RecommendationUsersPage();
|
||||
|
||||
@override
|
||||
State<_RecommendationUsersPage> createState() => _RecommendationUsersPageState();
|
||||
State<_RecommendationUsersPage> createState() =>
|
||||
_RecommendationUsersPageState();
|
||||
}
|
||||
|
||||
class _RecommendationUsersPageState extends MultiPageLoadingState<_RecommendationUsersPage, UserPreview> {
|
||||
class _RecommendationUsersPageState
|
||||
extends MultiPageLoadingState<_RecommendationUsersPage, UserPreview> {
|
||||
@override
|
||||
Widget buildContent(BuildContext context, List<UserPreview> data) {
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
SliverGridViewWithFixedItemHeight(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if(index == data.length - 1){
|
||||
nextPage();
|
||||
}
|
||||
return UserPreviewWidget(data[index]);
|
||||
},
|
||||
childCount: data.length
|
||||
),
|
||||
maxCrossAxisExtent: 520,
|
||||
itemHeight: 114,
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
if (index == data.length - 1) {
|
||||
nextPage();
|
||||
}
|
||||
return UserPreviewWidget(data[index]);
|
||||
}, childCount: data.length),
|
||||
minCrossAxisExtent: 440,
|
||||
itemHeight: 136,
|
||||
).sliverPaddingHorizontal(8)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Res<List<UserPreview>>> loadData(page) async{
|
||||
Future<Res<List<UserPreview>>> loadData(page) async {
|
||||
var res = await Network().getRecommendationUsers();
|
||||
return res;
|
||||
}
|
||||
|
69
lib/pages/related_page.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
import 'package:pixes/components/illust_widget.dart';
|
||||
import 'package:pixes/components/loading.dart';
|
||||
import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
class RelatedIllustsPage extends StatefulWidget {
|
||||
const RelatedIllustsPage(this.id, {super.key});
|
||||
|
||||
final String id;
|
||||
|
||||
@override
|
||||
State<RelatedIllustsPage> createState() => _RelatedIllustsPageState();
|
||||
}
|
||||
|
||||
class _RelatedIllustsPageState
|
||||
extends MultiPageLoadingState<RelatedIllustsPage, Illust> {
|
||||
@override
|
||||
Widget? buildFrame(BuildContext context, Widget child) {
|
||||
return Column(
|
||||
children: [
|
||||
TitleBar(title: "Related artworks".tl),
|
||||
Expanded(
|
||||
child: child,
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
return LayoutBuilder(builder: (context, constrains) {
|
||||
return MasonryGridView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8) +
|
||||
EdgeInsets.only(bottom: context.padding.bottom),
|
||||
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 240,
|
||||
),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == data.length - 1) {
|
||||
nextPage();
|
||||
}
|
||||
return IllustWidget(data[index]);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
String? nextUrl;
|
||||
|
||||
@override
|
||||
Future<Res<List<Illust>>> loadData(page) async {
|
||||
if (nextUrl == "end") {
|
||||
return Res.error("No more data");
|
||||
}
|
||||
var res = nextUrl == null
|
||||
? await Network().relatedIllusts(widget.id)
|
||||
: await Network().getIllustsWithNextUrl(nextUrl!);
|
||||
if (!res.error) {
|
||||
nextUrl = res.subData;
|
||||
nextUrl ??= "end";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@@ -1,7 +1,9 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:pixes/appdata.dart';
|
||||
import 'package:pixes/components/keyboard.dart';
|
||||
import 'package:pixes/components/md.dart';
|
||||
import 'package:pixes/components/message.dart';
|
||||
import 'package:pixes/components/page_route.dart';
|
||||
@@ -86,6 +88,7 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
child: Text('Continue'.tl),
|
||||
onPressed: () {
|
||||
appdata.account = null;
|
||||
appdata.writeData();
|
||||
App.rootNavigatorKey.currentState!.pushAndRemoveUntil(
|
||||
AppPageRoute(
|
||||
builder: (context) => const MainPage()),
|
||||
@@ -131,16 +134,16 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
return;
|
||||
}
|
||||
context.to(() => _SetSingleFieldPage(
|
||||
"Download Path".tl,
|
||||
"downloadPath",
|
||||
check: (text) {
|
||||
if(!Directory(text).havePermission()) {
|
||||
return "No permission".tl;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
));
|
||||
"Download Path".tl,
|
||||
"downloadPath",
|
||||
check: (text) {
|
||||
if (!Directory(text).havePermission()) {
|
||||
return "No permission".tl;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
));
|
||||
}),
|
||||
),
|
||||
buildItem(
|
||||
@@ -179,26 +182,43 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
child: Column(
|
||||
children: [
|
||||
buildItem(title: "Version", subtitle: App.version),
|
||||
buildItem(
|
||||
title: "Check for updates on startup".tl,
|
||||
action: ToggleSwitch(
|
||||
checked: appdata.settings["checkUpdate"],
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
appdata.settings["checkUpdate"] = value;
|
||||
});
|
||||
appdata.writeData();
|
||||
})),
|
||||
buildItem(
|
||||
title: "Github",
|
||||
action: IconButton(
|
||||
icon: const Icon(MdIcons.open_in_new, size: 18,),
|
||||
icon: const Icon(
|
||||
MdIcons.open_in_new,
|
||||
size: 18,
|
||||
),
|
||||
onPressed: () =>
|
||||
launchUrlString("https://github.com/wgh136/pixes"),
|
||||
)),
|
||||
buildItem(
|
||||
title: "Telegram",
|
||||
action: IconButton(
|
||||
icon: const Icon(MdIcons.open_in_new, size: 18,),
|
||||
onPressed: () =>
|
||||
launchUrlString("https://t.me/pica_group"),
|
||||
icon: const Icon(
|
||||
MdIcons.open_in_new,
|
||||
size: 18,
|
||||
),
|
||||
onPressed: () => launchUrlString("https://t.me/venera_dev"),
|
||||
)),
|
||||
buildItem(
|
||||
title: "Logs",
|
||||
action: IconButton(
|
||||
icon: const Icon(MdIcons.open_in_new, size: 18,),
|
||||
onPressed: () => context.to(() => const LogsPage())
|
||||
)),
|
||||
icon: const Icon(
|
||||
MdIcons.open_in_new,
|
||||
size: 18,
|
||||
),
|
||||
onPressed: () => context.to(() => const LogsPage()))),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -208,17 +228,72 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
return SliverToBoxAdapter(
|
||||
child: Column(
|
||||
children: [
|
||||
buildItem(
|
||||
title: "Initial Page".tl,
|
||||
action: Button(
|
||||
child: Text("Edit".tl).fixWidth(64),
|
||||
onPressed: () {
|
||||
context.to(() => const _SetInitialPageWidget());
|
||||
},
|
||||
)),
|
||||
buildItem(
|
||||
title: "Proxy".tl,
|
||||
action: Button(
|
||||
child: Text("Edit".tl).fixWidth(64),
|
||||
onPressed: () {
|
||||
context.to(() => _SetSingleFieldPage(
|
||||
"Http ${"Proxy".tl}",
|
||||
"proxy",
|
||||
));
|
||||
"Http ${"Proxy".tl}",
|
||||
"proxy",
|
||||
));
|
||||
},
|
||||
)),
|
||||
buildItem(
|
||||
title: "Block(Account)".tl,
|
||||
action: Button(
|
||||
child: Text("Edit".tl).fixWidth(64),
|
||||
onPressed: () {
|
||||
launchUrlString("https://www.pixiv.net/setting_mute.php");
|
||||
},
|
||||
)),
|
||||
buildItem(
|
||||
title: "Block(Local)".tl,
|
||||
action: Button(
|
||||
child: Text("Edit".tl).fixWidth(64),
|
||||
onPressed: () {
|
||||
context.to(() => const _BlockTagsPage());
|
||||
},
|
||||
)),
|
||||
buildItem(
|
||||
title: "Shortcuts".tl,
|
||||
action: Button(
|
||||
child: Text("Edit".tl).fixWidth(64),
|
||||
onPressed: () {
|
||||
context.to(() => const ShortcutsSettings());
|
||||
},
|
||||
)),
|
||||
buildItem(
|
||||
title: "Display the original image on the details page".tl,
|
||||
action: ToggleSwitch(
|
||||
checked: appdata.settings['showOriginalImage'],
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
appdata.settings['showOriginalImage'] = value;
|
||||
});
|
||||
appdata.writeData();
|
||||
})),
|
||||
buildItem(
|
||||
title: "Emphasize artworks from following artists".tl,
|
||||
subtitle: "The border of the artworks will be darker".tl,
|
||||
action: ToggleSwitch(
|
||||
checked:
|
||||
appdata.settings['emphasizeArtworksFromFollowingArtists'],
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
appdata.settings[
|
||||
'emphasizeArtworksFromFollowingArtists'] = value;
|
||||
});
|
||||
appdata.writeData();
|
||||
})),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -231,63 +306,77 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
buildItem(
|
||||
title: "Theme".tl,
|
||||
action: DropDownButton(
|
||||
title: Text(appdata.settings["theme"] ?? "System".tl),
|
||||
items: [
|
||||
MenuFlyoutItem(text: Text("System".tl), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "System";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(text: Text("light".tl), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "Light";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(text: Text("dark".tl), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "Dark";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
])),
|
||||
title: Text(appdata.settings["theme"] ?? "System".tl),
|
||||
items: [
|
||||
MenuFlyoutItem(
|
||||
text: Text("System".tl),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "System";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: Text("light".tl),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "Light";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: Text("dark".tl),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "Dark";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
])),
|
||||
buildItem(
|
||||
title: "Language".tl,
|
||||
action: DropDownButton(
|
||||
title: Text(appdata.settings["language"] ?? "System"),
|
||||
items: [
|
||||
MenuFlyoutItem(text: const Text("System"), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "System";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(text: const Text("English"), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "English";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(text: const Text("简体中文"), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "简体中文";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(text: const Text("繁體中文"), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "繁體中文";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: const Text("System"),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "System";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: const Text("English"),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "English";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: const Text("简体中文"),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "简体中文";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: const Text("繁體中文"),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "繁體中文";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
])),
|
||||
],
|
||||
),
|
||||
@@ -408,10 +497,242 @@ ${"Some keywords will be replaced by the following rule:".tl}
|
||||
\${author} -> ${"Name of the author".tl}
|
||||
\${id} -> ${"Artwork ID".tl}
|
||||
\${index} -> ${"Index of the image in the artwork".tl}
|
||||
\${page} -> ${"Replace with '-p\${index}' if the work have more than one images, otherwise replace with blank.".tl}
|
||||
\${ext} -> ${"File extension".tl}
|
||||
\${AI} -> ${"Replace with 'AI' if the work was generated by AI, otherwise replace with blank".tl}
|
||||
\${tag{*}} -> ${"Replace with * if the work have tag *, otherwise replace with blank.".tl}
|
||||
\${tag(*)} -> ${"Replace with * if the work have tag *, otherwise replace with blank.".tl}
|
||||
|
||||
${"Multiple path separators will be automatically replaced with a single".tl}
|
||||
""";
|
||||
}
|
||||
|
||||
class _BlockTagsPage extends StatefulWidget {
|
||||
const _BlockTagsPage();
|
||||
|
||||
@override
|
||||
State<_BlockTagsPage> createState() => __BlockTagsPageState();
|
||||
}
|
||||
|
||||
class __BlockTagsPageState extends State<_BlockTagsPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
TitleBar(
|
||||
title: "Block".tl,
|
||||
action: FilledButton(
|
||||
child: Text("Add".tl),
|
||||
onPressed: () {
|
||||
var controller = TextEditingController();
|
||||
|
||||
void finish(BuildContext context) {
|
||||
var text = controller.text;
|
||||
if (text.isNotEmpty &&
|
||||
!(appdata.settings["blockTags"] as List).contains(text)) {
|
||||
setState(() {
|
||||
appdata.settings["blockTags"].add(text);
|
||||
});
|
||||
appdata.writeSettings();
|
||||
}
|
||||
context.pop();
|
||||
}
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (context) {
|
||||
return ContentDialog(
|
||||
title: Text("Add".tl),
|
||||
content: SizedBox(
|
||||
width: 300,
|
||||
height: 32,
|
||||
child: TextBox(
|
||||
controller: controller,
|
||||
onSubmitted: (v) => finish(context),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
FilledButton(
|
||||
child: Text("Submit".tl),
|
||||
onPressed: () {
|
||||
finish(context);
|
||||
})
|
||||
],
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: appdata.settings["blockTags"].length,
|
||||
itemBuilder: (context, index) {
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
padding: EdgeInsets.zero,
|
||||
child: ListTile(
|
||||
title: Text(appdata.settings["blockTags"][index]),
|
||||
trailing: Button(
|
||||
child: Text("Delete".tl),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
(appdata.settings["blockTags"] as List).removeAt(index);
|
||||
});
|
||||
appdata.writeSettings();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ShortcutsSettings extends StatefulWidget {
|
||||
const ShortcutsSettings({super.key});
|
||||
|
||||
@override
|
||||
State<ShortcutsSettings> createState() => _ShortcutsSettingsState();
|
||||
}
|
||||
|
||||
class _ShortcutsSettingsState extends State<ShortcutsSettings> {
|
||||
int listening = -1;
|
||||
|
||||
KeyEventListenerState? listener;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
listener = KeyEventListener.of(context);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
listener?.removeAll();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
final settings = <String>[
|
||||
"Page down",
|
||||
"Page up",
|
||||
"Next work",
|
||||
"Previous work",
|
||||
"Add to favorites",
|
||||
"Download",
|
||||
"Follow the artist",
|
||||
"Show comments",
|
||||
"Show original image"
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
child: Column(children: [
|
||||
TitleBar(title: "Shortcuts".tl),
|
||||
...settings.map((e) => buildItem(e, settings.indexOf(e)))
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildItem(String text, int index) {
|
||||
var keyText = listening == index
|
||||
? "Waiting..."
|
||||
: LogicalKeyboardKey(appdata.settings['shortcuts'][index]).keyLabel;
|
||||
return Card(
|
||||
padding: EdgeInsets.zero,
|
||||
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 12),
|
||||
child: ListTile(
|
||||
title: Text(text.tl),
|
||||
trailing: Button(
|
||||
child: Text(keyText),
|
||||
onPressed: () {
|
||||
if (listening != -1) {
|
||||
listener?.removeAll();
|
||||
}
|
||||
setState(() {
|
||||
listening = index;
|
||||
});
|
||||
listener?.addHandler((key) {
|
||||
if (key == LogicalKeyboardKey.escape) return;
|
||||
setState(() {
|
||||
appdata.settings['shortcuts'][index] = key.keyId;
|
||||
listening = -1;
|
||||
appdata.writeData();
|
||||
});
|
||||
Future.microtask(() => listener?.removeAll());
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SetInitialPageWidget extends StatefulWidget {
|
||||
const _SetInitialPageWidget();
|
||||
|
||||
@override
|
||||
State<_SetInitialPageWidget> createState() => _SetInitialPageWidgetState();
|
||||
}
|
||||
|
||||
class _SetInitialPageWidgetState extends State<_SetInitialPageWidget> {
|
||||
int index = appdata.settings["initialPage"] ?? 4;
|
||||
|
||||
static const pageNames = [
|
||||
"Search",
|
||||
"Downloading",
|
||||
"Downloaded",
|
||||
"Explore",
|
||||
"Bookmarks",
|
||||
"Following",
|
||||
"History",
|
||||
"Ranking",
|
||||
"Recommendation",
|
||||
"Bookmarks",
|
||||
"Following",
|
||||
"Ranking",
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ScaffoldPage(
|
||||
header: TitleBar(title: "Initial Page".tl),
|
||||
content: ListView.builder(
|
||||
itemCount: pageNames.length + 2,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 3) {
|
||||
return Text('${"Illustrations".tl}/${"Manga".tl}').paddingHorizontal(16).paddingVertical(8);
|
||||
} else if (index > 3) {
|
||||
index--;
|
||||
}
|
||||
if (index == 8) {
|
||||
return Text("Novel".tl).paddingHorizontal(16).paddingVertical(8);
|
||||
} else if (index > 8) {
|
||||
index--;
|
||||
}
|
||||
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
padding: EdgeInsets.zero,
|
||||
child: ListTile(
|
||||
title: Text(pageNames[index].tl),
|
||||
trailing: RadioButton(
|
||||
checked: this.index - 1 == index,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
this.index = index + 1;
|
||||
appdata.settings["initialPage"] = index + 1;
|
||||
appdata.writeData();
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -3,44 +3,76 @@ import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
import 'package:pixes/appdata.dart';
|
||||
import 'package:pixes/components/batch_download.dart';
|
||||
import 'package:pixes/components/grid.dart';
|
||||
import 'package:pixes/components/loading.dart';
|
||||
import 'package:pixes/components/md.dart';
|
||||
import 'package:pixes/components/novel.dart';
|
||||
import 'package:pixes/components/segmented_button.dart';
|
||||
import 'package:pixes/components/user_preview.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/foundation/image_provider.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/pages/following_users_page.dart';
|
||||
import 'package:pixes/utils/block.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import '../components/illust_widget.dart';
|
||||
import 'illust_page.dart';
|
||||
|
||||
class UserInfoPage extends StatefulWidget {
|
||||
const UserInfoPage(this.id, {this.followCallback, super.key});
|
||||
const UserInfoPage(this.id, {super.key});
|
||||
|
||||
final String id;
|
||||
|
||||
final void Function(bool)? followCallback;
|
||||
static Map<String, UpdateFollowCallback> followCallbacks = {};
|
||||
|
||||
@override
|
||||
State<UserInfoPage> createState() => _UserInfoPageState();
|
||||
}
|
||||
|
||||
class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||
@override
|
||||
void initState() {
|
||||
UserInfoPage.followCallbacks[widget.id] = (v) {
|
||||
if (data == null) return;
|
||||
setState(() {
|
||||
data!.isFollowed = v;
|
||||
});
|
||||
};
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
UserInfoPage.followCallbacks.remove(widget.id);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
int page = 0;
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, UserDetails data) {
|
||||
return ScaffoldPage(
|
||||
content: CustomScrollView(
|
||||
slivers: [
|
||||
buildUser(),
|
||||
buildInformation(),
|
||||
SliverToBoxAdapter(
|
||||
child: buildHeader(
|
||||
"Artworks",
|
||||
action: BatchDownloadButton(
|
||||
request: () => Network().getUserIllusts(widget.id))
|
||||
),),
|
||||
_UserArtworks(data.id.toString(), key: ValueKey(data.id),),
|
||||
SliverPadding(padding: EdgeInsets.only(bottom: context.padding.bottom)),
|
||||
child: buildHeader("Related users".tl),
|
||||
),
|
||||
_RelatedUsers(widget.id),
|
||||
buildInformation(),
|
||||
buildArtworkHeader(),
|
||||
if (page == 4)
|
||||
_UserNovels(widget.id)
|
||||
else
|
||||
_UserArtworks(
|
||||
data.id.toString(),
|
||||
page,
|
||||
key: ValueKey(data.id + page),
|
||||
),
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(bottom: context.padding.bottom)),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -48,23 +80,24 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||
|
||||
bool isFollowing = false;
|
||||
|
||||
void follow() async{
|
||||
if(isFollowing) return;
|
||||
void follow() async {
|
||||
if (isFollowing) return;
|
||||
String type = "";
|
||||
if(!data!.isFollowed) {
|
||||
if (!data!.isFollowed) {
|
||||
await flyoutController.showFlyout(
|
||||
navigatorKey: App.rootNavigatorKey.currentState,
|
||||
builder: (context) =>
|
||||
MenuFlyout(
|
||||
builder: (context) => MenuFlyout(
|
||||
items: [
|
||||
MenuFlyoutItem(text: Text("Public".tl),
|
||||
MenuFlyoutItem(
|
||||
text: Text("Public".tl),
|
||||
onPressed: () => type = "public"),
|
||||
MenuFlyoutItem(text: Text("Private".tl),
|
||||
MenuFlyoutItem(
|
||||
text: Text("Private".tl),
|
||||
onPressed: () => type = "private"),
|
||||
],
|
||||
));
|
||||
}
|
||||
if(type.isEmpty && !data!.isFollowed) {
|
||||
if (type.isEmpty && !data!.isFollowed) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
@@ -72,13 +105,15 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||
});
|
||||
var method = data!.isFollowed ? "delete" : "add";
|
||||
var res = await Network().follow(data!.id.toString(), method, type);
|
||||
if(res.error) {
|
||||
if(mounted) {
|
||||
if (res.error) {
|
||||
if (mounted) {
|
||||
context.showToast(message: "Network Error");
|
||||
}
|
||||
} else {
|
||||
data!.isFollowed = !data!.isFollowed;
|
||||
widget.followCallback?.call(data!.isFollowed);
|
||||
UserPreviewWidget.followCallbacks[data!.id.toString()]
|
||||
?.call(data!.isFollowed);
|
||||
IllustPage.updateFollow(data!.id.toString(), data!.isFollowed);
|
||||
}
|
||||
setState(() {
|
||||
isFollowing = false;
|
||||
@@ -96,7 +131,8 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||
height: 64,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(64),
|
||||
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6)),
|
||||
border: Border.all(
|
||||
color: ColorScheme.of(context).outlineVariant, width: 0.6)),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(64),
|
||||
child: Image(
|
||||
@@ -105,47 +141,60 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||
height: 64,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(data!.name, style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
Text(data!.name,
|
||||
style:
|
||||
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 4),
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(text: 'Follows: '.tl),
|
||||
TextSpan(
|
||||
text: '${data!.totalFollowUsers}',
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = (() => context.to(() => FollowingUsersPage(widget.id))),
|
||||
style: TextStyle(fontWeight: FontWeight.bold, color: FluentTheme.of(context).accentColor)
|
||||
),
|
||||
text: '${data!.totalFollowUsers}',
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = (() =>
|
||||
context.to(() => FollowingUsersPage(widget.id))),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: FluentTheme.of(context).accentColor)),
|
||||
],
|
||||
),
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
if(widget.id != appdata.account?.user.id)
|
||||
const SizedBox(height: 8,),
|
||||
if(widget.id != appdata.account?.user.id)
|
||||
if(isFollowing)
|
||||
Button(onPressed: follow, child: const SizedBox(
|
||||
width: 42,
|
||||
height: 24,
|
||||
child: Center(
|
||||
child: SizedBox.square(
|
||||
dimension: 18,
|
||||
child: ProgressRing(strokeWidth: 2,),
|
||||
),
|
||||
),
|
||||
))
|
||||
if (widget.id != appdata.account?.user.id)
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
if (widget.id != appdata.account?.user.id)
|
||||
if (isFollowing)
|
||||
Button(
|
||||
onPressed: follow,
|
||||
child: const SizedBox(
|
||||
width: 42,
|
||||
height: 24,
|
||||
child: Center(
|
||||
child: SizedBox.square(
|
||||
dimension: 18,
|
||||
child: ProgressRing(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
))
|
||||
else if (!data!.isFollowed)
|
||||
FlyoutTarget(
|
||||
controller: flyoutController,
|
||||
child: Button(onPressed: follow, child: Text("Follow".tl))
|
||||
)
|
||||
controller: flyoutController,
|
||||
child: Button(onPressed: follow, child: Text("Follow".tl)))
|
||||
else
|
||||
Button(
|
||||
onPressed: follow,
|
||||
child: Text("Unfollow".tl, style: TextStyle(color: ColorScheme.of(context).error),),
|
||||
child: Text(
|
||||
"Unfollow".tl,
|
||||
style: TextStyle(color: ColorScheme.of(context).error),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -154,33 +203,91 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||
|
||||
Widget buildHeader(String title, {Widget? action}) {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
height: 38,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
).toAlign(Alignment.centerLeft),
|
||||
const Spacer(),
|
||||
if(action != null)
|
||||
action.toAlign(Alignment.centerRight)
|
||||
],
|
||||
).paddingHorizontal(16)).paddingTop(8);
|
||||
width: double.infinity,
|
||||
height: 38,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
).toAlign(Alignment.centerLeft),
|
||||
const Spacer(),
|
||||
if (action != null) action.toAlign(Alignment.centerRight)
|
||||
],
|
||||
).paddingHorizontal(16))
|
||||
.paddingTop(8);
|
||||
}
|
||||
|
||||
Widget buildArtworkHeader() {
|
||||
return SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
height: 38,
|
||||
child: Row(
|
||||
children: [
|
||||
SegmentedButton<int>(
|
||||
options: [
|
||||
SegmentedButtonOption(0, "Artworks".tl),
|
||||
SegmentedButtonOption(1, "Illustrations".tl),
|
||||
SegmentedButtonOption(2, "Mangas".tl),
|
||||
SegmentedButtonOption(3, "Bookmarks".tl),
|
||||
SegmentedButtonOption(4, "Novels".tl),
|
||||
],
|
||||
value: page,
|
||||
onPressed: (value) {
|
||||
setState(() {
|
||||
page = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
const Spacer(),
|
||||
if (page != 4)
|
||||
BatchDownloadButton(
|
||||
request: () {
|
||||
switch (page) {
|
||||
case 0:
|
||||
return Network()
|
||||
.getUserIllusts(data!.id.toString(), null);
|
||||
case 1:
|
||||
return Network()
|
||||
.getUserIllusts(data!.id.toString(), "illust");
|
||||
case 2:
|
||||
return Network()
|
||||
.getUserIllusts(data!.id.toString(), "manga");
|
||||
case 3:
|
||||
return Network()
|
||||
.getUserBookmarks(data!.id.toString());
|
||||
}
|
||||
throw "Invalid page";
|
||||
},
|
||||
),
|
||||
],
|
||||
).paddingHorizontal(16))
|
||||
.paddingTop(12),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildInformation() {
|
||||
Widget buildItem({IconData? icon, required String title, required String? content, Widget? trailing}) {
|
||||
if(content == null || content.isEmpty) {
|
||||
Widget buildItem(
|
||||
{IconData? icon,
|
||||
required String title,
|
||||
required String? content,
|
||||
Widget? trailing}) {
|
||||
if (content == null || content.isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 2),
|
||||
padding: EdgeInsets.zero,
|
||||
child: ListTile(
|
||||
leading: icon == null ? null : Icon(icon, size: 20,),
|
||||
title: Text(title),
|
||||
subtitle: SelectableText(content),
|
||||
title: Row(
|
||||
children: [
|
||||
Icon(icon, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Text(title)
|
||||
],
|
||||
),
|
||||
subtitle: SelectableText(content).paddingLeft(icon == null ? 0 : 28),
|
||||
trailing: trailing,
|
||||
),
|
||||
);
|
||||
@@ -190,30 +297,46 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||
child: Column(
|
||||
children: [
|
||||
buildHeader("Information".tl),
|
||||
buildItem(icon: MdIcons.comment_outlined, title: "Introduction".tl, content: data!.comment),
|
||||
buildItem(icon: MdIcons.cake_outlined, title: "Birthday".tl, content: data!.birth),
|
||||
buildItem(icon: MdIcons.location_city_outlined, title: "Region", content: data!.region),
|
||||
buildItem(icon: MdIcons.work_outline, title: "Job".tl, content: data!.job),
|
||||
buildItem(icon: MdIcons.person_2_outlined, title: "Gender".tl, content: data!.gender),
|
||||
buildItem(
|
||||
icon: MdIcons.comment_outlined,
|
||||
title: "Introduction".tl,
|
||||
content: data!.comment),
|
||||
buildItem(
|
||||
icon: MdIcons.cake_outlined,
|
||||
title: "Birthday".tl,
|
||||
content: data!.birth),
|
||||
buildItem(
|
||||
icon: MdIcons.location_city_outlined,
|
||||
title: "Region",
|
||||
content: data!.region),
|
||||
buildItem(
|
||||
icon: MdIcons.work_outline, title: "Job".tl, content: data!.job),
|
||||
buildItem(
|
||||
icon: MdIcons.person_2_outlined,
|
||||
title: "Gender".tl,
|
||||
content: data!.gender),
|
||||
buildHeader("Social Network".tl),
|
||||
buildItem(title: "Webpage",
|
||||
buildItem(
|
||||
title: "Webpage",
|
||||
content: data!.webpage,
|
||||
trailing: IconButton(
|
||||
icon: const Icon(MdIcons.open_in_new, size: 18),
|
||||
onPressed: () => launchUrlString(data!.twitterUrl!)
|
||||
)),
|
||||
buildItem(title: "Twitter",
|
||||
onPressed: () => launchUrlString(data!.twitterUrl!))),
|
||||
buildItem(
|
||||
title: "Twitter",
|
||||
content: data!.twitterUrl,
|
||||
trailing: IconButton(
|
||||
icon: const Icon(MdIcons.open_in_new, size: 18),
|
||||
onPressed: () => launchUrlString(data!.twitterUrl!)
|
||||
)),
|
||||
buildItem(title: "pawoo",
|
||||
onPressed: () => launchUrlString(data!.twitterUrl!))),
|
||||
buildItem(
|
||||
title: "pawoo",
|
||||
content: data!.pawooUrl,
|
||||
trailing: IconButton(
|
||||
icon: const Icon(MdIcons.open_in_new, size: 18,),
|
||||
onPressed: () => launchUrlString(data!.pawooUrl!)
|
||||
)),
|
||||
icon: const Icon(
|
||||
MdIcons.open_in_new,
|
||||
size: 18,
|
||||
),
|
||||
onPressed: () => launchUrlString(data!.pawooUrl!))),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -226,10 +349,12 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||
}
|
||||
|
||||
class _UserArtworks extends StatefulWidget {
|
||||
const _UserArtworks(this.uid, {super.key});
|
||||
const _UserArtworks(this.uid, this.type, {super.key});
|
||||
|
||||
final String uid;
|
||||
|
||||
final int type;
|
||||
|
||||
@override
|
||||
State<_UserArtworks> createState() => _UserArtworksState();
|
||||
}
|
||||
@@ -254,7 +379,9 @@ class _UserArtworksState extends MultiPageLoadingState<_UserArtworks, Illust> {
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(FluentIcons.info),
|
||||
const SizedBox(width: 4,),
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
Text(error)
|
||||
],
|
||||
),
|
||||
@@ -264,17 +391,21 @@ class _UserArtworksState extends MultiPageLoadingState<_UserArtworks, Illust> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
Widget buildContent(BuildContext context, List<Illust> data) {
|
||||
checkIllusts(data);
|
||||
return SliverMasonryGrid(
|
||||
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 240,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if(index == data.length - 1){
|
||||
(context, index) {
|
||||
if (index == data.length - 1) {
|
||||
nextPage();
|
||||
}
|
||||
return IllustWidget(data[index]);
|
||||
return IllustWidget(data[index], onTap: () {
|
||||
context.to(() => IllustGalleryPage(
|
||||
illusts: data, initialPage: index, nextUrl: nextUrl));
|
||||
});
|
||||
},
|
||||
childCount: data.length,
|
||||
),
|
||||
@@ -284,14 +415,17 @@ class _UserArtworksState extends MultiPageLoadingState<_UserArtworks, Illust> {
|
||||
String? nextUrl;
|
||||
|
||||
@override
|
||||
Future<Res<List<Illust>>> loadData(page) async{
|
||||
if(nextUrl == "end") {
|
||||
Future<Res<List<Illust>>> loadData(page) async {
|
||||
if (nextUrl == "end") {
|
||||
return Res.error("No more data");
|
||||
}
|
||||
var res = nextUrl == null
|
||||
? await Network().getUserIllusts(widget.uid)
|
||||
? (widget.type != 3
|
||||
? await Network().getUserIllusts(
|
||||
widget.uid, [null, "illust", "manga"][widget.type])
|
||||
: await Network().getUserBookmarks(widget.uid))
|
||||
: await Network().getIllustsWithNextUrl(nextUrl!);
|
||||
if(!res.error) {
|
||||
if (!res.error) {
|
||||
nextUrl = res.subData;
|
||||
nextUrl ??= "end";
|
||||
}
|
||||
@@ -299,3 +433,150 @@ class _UserArtworksState extends MultiPageLoadingState<_UserArtworks, Illust> {
|
||||
}
|
||||
}
|
||||
|
||||
class _UserNovels extends StatefulWidget {
|
||||
const _UserNovels(this.uid);
|
||||
|
||||
final String uid;
|
||||
|
||||
@override
|
||||
State<_UserNovels> createState() => _UserNovelsState();
|
||||
}
|
||||
|
||||
class _UserNovelsState extends MultiPageLoadingState<_UserNovels, Novel> {
|
||||
@override
|
||||
Widget buildLoading(BuildContext context) {
|
||||
return const SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
child: Center(
|
||||
child: ProgressRing(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildError(context, error) {
|
||||
return SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
child: Center(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(FluentIcons.info),
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
Text(error)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, List<Novel> data) {
|
||||
return SliverGridViewWithFixedItemHeight(
|
||||
itemHeight: 164,
|
||||
minCrossAxisExtent: 400,
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index == data.length - 1) {
|
||||
nextPage();
|
||||
}
|
||||
return NovelWidget(data[index]);
|
||||
},
|
||||
childCount: data.length,
|
||||
),
|
||||
).sliverPaddingHorizontal(8);
|
||||
}
|
||||
|
||||
String? nextUrl;
|
||||
|
||||
@override
|
||||
Future<Res<List<Novel>>> loadData(page) async {
|
||||
if (nextUrl == "end") {
|
||||
return Res.error("No more data");
|
||||
}
|
||||
var res = nextUrl == null
|
||||
? await Network().getUserNovels(widget.uid)
|
||||
: await Network().getNovelsWithNextUrl(nextUrl!);
|
||||
if (!res.error) {
|
||||
nextUrl = res.subData;
|
||||
nextUrl ??= "end";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
class _RelatedUsers extends StatefulWidget {
|
||||
const _RelatedUsers(this.uid);
|
||||
|
||||
final String uid;
|
||||
|
||||
@override
|
||||
State<_RelatedUsers> createState() => _RelatedUsersState();
|
||||
}
|
||||
|
||||
class _RelatedUsersState
|
||||
extends LoadingState<_RelatedUsers, List<UserPreview>> {
|
||||
@override
|
||||
Widget buildFrame(BuildContext context, Widget child) {
|
||||
return SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
height: 146,
|
||||
width: double.infinity,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final ScrollController _controller = ScrollController();
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, List<UserPreview> data) {
|
||||
Widget content = Scrollbar(
|
||||
controller: _controller,
|
||||
child: ListView.builder(
|
||||
controller: _controller,
|
||||
padding: const EdgeInsets.only(bottom: 8, left: 8),
|
||||
primary: false,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, index) {
|
||||
return UserPreviewWidget(data[index]).fixWidth(342);
|
||||
},
|
||||
));
|
||||
if (App.isDesktop) {
|
||||
content = ScrollbarTheme.merge(
|
||||
data: const ScrollbarThemeData(
|
||||
thickness: 6,
|
||||
hoveringThickness: 6,
|
||||
mainAxisMargin: 4,
|
||||
hoveringPadding: EdgeInsets.zero,
|
||||
padding: EdgeInsets.zero,
|
||||
hoveringMainAxisMargin: 4,
|
||||
crossAxisMargin: 0,
|
||||
hoveringCrossAxisMargin: 0),
|
||||
child: content);
|
||||
} else {
|
||||
content = ScrollbarTheme.merge(
|
||||
data: const ScrollbarThemeData(
|
||||
thickness: 4,
|
||||
hoveringThickness: 4,
|
||||
mainAxisMargin: 4,
|
||||
hoveringPadding: EdgeInsets.zero,
|
||||
padding: EdgeInsets.zero,
|
||||
hoveringMainAxisMargin: 4,
|
||||
crossAxisMargin: 0,
|
||||
hoveringCrossAxisMargin: 0),
|
||||
child: content);
|
||||
}
|
||||
return MediaQuery.removePadding(
|
||||
context: context, removeBottom: true, child: content);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Res<List<UserPreview>>> loadData() {
|
||||
return Network().relatedUsers(widget.uid);
|
||||
}
|
||||
}
|
||||
|
@@ -1,23 +1,28 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:app_links/app_links.dart';
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/foundation/log.dart';
|
||||
import 'package:pixes/pages/illust_page.dart';
|
||||
import 'package:pixes/pages/novel_page.dart';
|
||||
import 'package:pixes/pages/search_page.dart';
|
||||
import 'package:pixes/pages/user_info_page.dart';
|
||||
import 'package:pixes/utils/ext.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
import 'package:win32_registry/win32_registry.dart';
|
||||
|
||||
Future<void> _register(String scheme) async {
|
||||
String appPath = Platform.resolvedExecutable;
|
||||
|
||||
String protocolRegKey = 'Software\\Classes\\$scheme';
|
||||
RegistryValue protocolRegValue = const RegistryValue(
|
||||
RegistryValue protocolRegValue = const RegistryValue.string(
|
||||
'URL Protocol',
|
||||
RegistryValueType.string,
|
||||
'',
|
||||
);
|
||||
String protocolCmdRegKey = 'shell\\open\\command';
|
||||
RegistryValue protocolCmdRegValue = RegistryValue(
|
||||
RegistryValue protocolCmdRegValue = RegistryValue.string(
|
||||
'',
|
||||
RegistryValueType.string,
|
||||
'"$appPath" "%1"',
|
||||
);
|
||||
|
||||
@@ -26,16 +31,107 @@ Future<void> _register(String scheme) async {
|
||||
regKey.createKey(protocolCmdRegKey).createValue(protocolCmdRegValue);
|
||||
}
|
||||
|
||||
void _registerPixiv() async {
|
||||
try {
|
||||
await _register("pixiv");
|
||||
} catch (e) {
|
||||
// 注册失败会导致登录不可用
|
||||
while (App.mainNavigatorKey == null) {
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
}
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
showDialog(
|
||||
context: App.rootNavigatorKey.currentContext!,
|
||||
builder: (context) => ContentDialog(
|
||||
title: Text("Error".tl),
|
||||
content: Text("${"Failed to register URL scheme.".tl}\n$e"),
|
||||
actions: [
|
||||
FilledButton(
|
||||
child: Text("Retry".tl),
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
_registerPixiv();
|
||||
})
|
||||
],
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
bool Function(Uri uri)? onLink;
|
||||
|
||||
bool _firstLink = true;
|
||||
|
||||
void handleLinks() async {
|
||||
if (App.isWindows) {
|
||||
await _register("pixiv");
|
||||
_registerPixiv();
|
||||
}
|
||||
AppLinks().uriLinkStream.listen((uri) {
|
||||
AppLinks().uriLinkStream.listen((uri) async {
|
||||
if (_firstLink) {
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
}
|
||||
_firstLink = false;
|
||||
Log.info("App Link", uri.toString());
|
||||
if (onLink?.call(uri) == true) {
|
||||
return;
|
||||
}
|
||||
handleLink(uri);
|
||||
});
|
||||
}
|
||||
|
||||
bool handleLink(Uri uri) {
|
||||
if (uri.scheme == "pixiv") {
|
||||
var path = uri.toString().split("/").sublist(2);
|
||||
if (path.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
switch (path[0]) {
|
||||
case "users":
|
||||
if (path.length == 2) {
|
||||
App.mainNavigatorKey?.currentContext?.to(() => UserInfoPage(path[1]));
|
||||
return true;
|
||||
}
|
||||
case "novels":
|
||||
if (path.length == 2) {
|
||||
App.mainNavigatorKey?.currentContext
|
||||
?.to(() => NovelPageWithId(path[1]));
|
||||
return true;
|
||||
}
|
||||
case "illusts":
|
||||
if (path.length == 2) {
|
||||
App.mainNavigatorKey?.currentContext
|
||||
?.to(() => IllustPageWithId(path[1]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (uri.scheme == "https") {
|
||||
var path = uri.toString().split("/").sublist(3);
|
||||
switch (path[0]) {
|
||||
case "users":
|
||||
if (path.length >= 2) {
|
||||
App.mainNavigatorKey?.currentContext?.to(() => UserInfoPage(path[1]));
|
||||
return true;
|
||||
}
|
||||
case "novel":
|
||||
if (path.length == 2) {
|
||||
App.mainNavigatorKey?.currentContext
|
||||
?.to(() => NovelPageWithId(path[1].nums));
|
||||
return true;
|
||||
}
|
||||
case "artworks":
|
||||
if (path.length == 2) {
|
||||
App.mainNavigatorKey?.currentContext
|
||||
?.to(() => IllustPageWithId(path[1]));
|
||||
return true;
|
||||
}
|
||||
case "tags":
|
||||
if (path.length == 2) {
|
||||
App.mainNavigatorKey?.currentContext
|
||||
?.to(() => SearchResultPage(path[1]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
23
lib/utils/block.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:pixes/appdata.dart';
|
||||
import 'package:pixes/network/models.dart';
|
||||
|
||||
List<Illust> checkIllusts(List<Illust> illusts) {
|
||||
illusts.removeWhere((illust) {
|
||||
if (illust.isBlocked) {
|
||||
return true;
|
||||
}
|
||||
if (appdata.settings["blockTags"] == null) {
|
||||
return false;
|
||||
}
|
||||
if (appdata.settings["blockTags"].contains("user:${illust.author.name}")) {
|
||||
return true;
|
||||
}
|
||||
for (var tag in illust.tags) {
|
||||
if ((appdata.settings["blockTags"] as List).contains(tag.name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return illusts;
|
||||
}
|
28
lib/utils/debounce.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ui';
|
||||
|
||||
class Debounce {
|
||||
final Duration delay;
|
||||
VoidCallback? _action;
|
||||
Timer? _timer;
|
||||
|
||||
Debounce({required this.delay});
|
||||
|
||||
void call(VoidCallback action) {
|
||||
_action = action;
|
||||
_timer?.cancel();
|
||||
_timer = Timer(delay, _execute);
|
||||
}
|
||||
|
||||
void _execute() {
|
||||
if (_action != null) {
|
||||
_action!();
|
||||
_action = null;
|
||||
}
|
||||
}
|
||||
|
||||
void cancel() {
|
||||
_timer?.cancel();
|
||||
_action = null;
|
||||
}
|
||||
}
|
@@ -12,6 +12,14 @@ extension FSExt on FileSystemEntity {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteIgnoreError() async {
|
||||
try {
|
||||
await delete();
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
int get size {
|
||||
if (this is File) {
|
||||
return (this as File).lengthSync();
|
||||
|
21
lib/utils/loop.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'dart:async';
|
||||
|
||||
class Loop {
|
||||
static final List<void Function()> _callbacks = [];
|
||||
|
||||
static void start() {
|
||||
Timer.periodic(const Duration(milliseconds: 100), (timer) {
|
||||
for(var func in _callbacks) {
|
||||
func.call();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static void register(void Function() func) {
|
||||
_callbacks.add(func);
|
||||
}
|
||||
|
||||
static void remove(void Function() func) {
|
||||
_callbacks.remove(func);
|
||||
}
|
||||
}
|
69
lib/utils/update.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/appdata.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/network/app_dio.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
Future<String> getLatestVersion() async {
|
||||
var dio = AppDio();
|
||||
var res = await dio
|
||||
.get("https://raw.githubusercontent.com/wgh136/pixes/refs/heads/master/pubspec.yaml");
|
||||
var lines = (res.data as String).split("\n");
|
||||
for (var line in lines) {
|
||||
if (line.startsWith("version:")) {
|
||||
return line.split(":")[1].split('+')[0].trim();
|
||||
}
|
||||
}
|
||||
throw "Failed to get latest version";
|
||||
}
|
||||
|
||||
/// Compare two versions.
|
||||
/// Return `true` if `a` is greater than `b`.
|
||||
bool compareVersion(String a, String b) {
|
||||
var aList = a.split(".").map(int.parse).toList();
|
||||
var bList = b.split(".").map(int.parse).toList();
|
||||
for (var i = 0; i < aList.length; i++) {
|
||||
if (aList[i] > bList[i]) {
|
||||
return true;
|
||||
} else if (aList[i] < bList[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Future<void> checkUpdate() async {
|
||||
if (appdata.account == null) return;
|
||||
try {
|
||||
var latestVersion = await getLatestVersion();
|
||||
if (compareVersion(latestVersion, App.version)) {
|
||||
showDialog(
|
||||
context: App.rootNavigatorKey.currentContext!,
|
||||
builder: (context) => ContentDialog(
|
||||
title: Text("New version available".tl),
|
||||
content: Text(
|
||||
"A new version of Pixes is available. Do you want to update now?"
|
||||
.tl,
|
||||
),
|
||||
actions: [
|
||||
Button(
|
||||
child: Text("Cancel".tl),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
FilledButton(
|
||||
child: Text("Update".tl),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
launchUrlString(
|
||||
"https://github.com/wgh136/pixes/releases/latest");
|
||||
})
|
||||
],
|
||||
));
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
75
lib/utils/window.dart
Normal file
@@ -0,0 +1,75 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:ui';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
class WindowPlacement {
|
||||
final Rect rect;
|
||||
|
||||
final bool isMaximized;
|
||||
|
||||
const WindowPlacement(this.rect, this.isMaximized);
|
||||
|
||||
Future<void> applyToWindow() async {
|
||||
await windowManager.setBounds(rect);
|
||||
|
||||
if(!validate(rect)){
|
||||
await windowManager.center();
|
||||
}
|
||||
|
||||
if (isMaximized) {
|
||||
await windowManager.maximize();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> writeToFile() async {
|
||||
var file = File("${App.dataPath}/window_placement");
|
||||
await file.writeAsString(jsonEncode({
|
||||
'width': rect.width,
|
||||
'height': rect.height,
|
||||
'x': rect.topLeft.dx,
|
||||
'y': rect.topLeft.dy,
|
||||
'isMaximized': isMaximized
|
||||
}));
|
||||
}
|
||||
|
||||
static Future<WindowPlacement> loadFromFile() async {
|
||||
var file = File("${App.dataPath}/window_placement");
|
||||
if (!file.existsSync()) {
|
||||
return defaultPlacement;
|
||||
}
|
||||
var json = jsonDecode(await file.readAsString());
|
||||
var rect =
|
||||
Rect.fromLTWH(json['x'], json['y'], json['width'], json['height']);
|
||||
return WindowPlacement(rect, json['isMaximized']);
|
||||
}
|
||||
|
||||
static Future<WindowPlacement> get current async {
|
||||
var rect = await windowManager.getBounds();
|
||||
var isMaximized = await windowManager.isMaximized();
|
||||
return WindowPlacement(rect, isMaximized);
|
||||
}
|
||||
|
||||
static const defaultPlacement =
|
||||
WindowPlacement(Rect.fromLTWH(10, 10, 900, 600), false);
|
||||
|
||||
static WindowPlacement cache = defaultPlacement;
|
||||
|
||||
static void loop() async {
|
||||
var placement = await WindowPlacement.current;
|
||||
if(!validate(placement.rect)){
|
||||
return;
|
||||
}
|
||||
if (placement.rect != cache.rect ||
|
||||
placement.isMaximized != cache.isMaximized) {
|
||||
cache = placement;
|
||||
await placement.writeToFile();
|
||||
}
|
||||
}
|
||||
|
||||
static bool validate(Rect rect){
|
||||
return rect.topLeft.dx >= 0 && rect.topLeft.dy >= 0;
|
||||
}
|
||||
}
|
@@ -6,26 +6,34 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <dynamic_color/dynamic_color_plugin.h>
|
||||
#include <file_selector_linux/file_selector_plugin.h>
|
||||
#include <flutter_acrylic/flutter_acrylic_plugin.h>
|
||||
#include <gtk/gtk_plugin.h>
|
||||
#include <screen_retriever/screen_retriever_plugin.h>
|
||||
#include <screen_retriever_linux/screen_retriever_linux_plugin.h>
|
||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
||||
#include <system_theme/system_theme_plugin.h>
|
||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||
#include <window_manager/window_manager_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) dynamic_color_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "DynamicColorPlugin");
|
||||
dynamic_color_plugin_register_with_registrar(dynamic_color_registrar);
|
||||
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
|
||||
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
|
||||
g_autoptr(FlPluginRegistrar) flutter_acrylic_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterAcrylicPlugin");
|
||||
flutter_acrylic_plugin_register_with_registrar(flutter_acrylic_registrar);
|
||||
g_autoptr(FlPluginRegistrar) gtk_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin");
|
||||
gtk_plugin_register_with_registrar(gtk_registrar);
|
||||
g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
|
||||
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);
|
||||
g_autoptr(FlPluginRegistrar) screen_retriever_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverLinuxPlugin");
|
||||
screen_retriever_linux_plugin_register_with_registrar(screen_retriever_linux_registrar);
|
||||
g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin");
|
||||
sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar);
|
||||
g_autoptr(FlPluginRegistrar) system_theme_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "SystemThemePlugin");
|
||||
system_theme_plugin_register_with_registrar(system_theme_registrar);
|
||||
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||
|
@@ -3,10 +3,12 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
dynamic_color
|
||||
file_selector_linux
|
||||
flutter_acrylic
|
||||
gtk
|
||||
screen_retriever
|
||||
screen_retriever_linux
|
||||
sqlite3_flutter_libs
|
||||
system_theme
|
||||
url_launcher_linux
|
||||
window_manager
|
||||
)
|
||||
|
@@ -55,7 +55,7 @@ static void my_application_activate(GApplication* application) {
|
||||
}
|
||||
|
||||
gtk_window_set_default_size(window, 1280, 720);
|
||||
gtk_widget_realize(GTK_WIDGET(window));
|
||||
gtk_widget_show(GTK_WIDGET(window));
|
||||
|
||||
g_autoptr(FlDartProject) project = fl_dart_project_new();
|
||||
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
|
||||
|
@@ -6,19 +6,29 @@ import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import app_links
|
||||
import device_info_plus
|
||||
import dynamic_color
|
||||
import file_selector_macos
|
||||
import flutter_acrylic
|
||||
import path_provider_foundation
|
||||
import screen_retriever
|
||||
import screen_retriever_macos
|
||||
import share_plus
|
||||
import sqlite3_flutter_libs
|
||||
import system_theme
|
||||
import url_launcher_macos
|
||||
import webview_flutter_wkwebview
|
||||
import window_manager
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin"))
|
||||
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||
DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin"))
|
||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
||||
FlutterAcrylicPlugin.register(with: registry.registrar(forPlugin: "FlutterAcrylicPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
|
||||
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
|
||||
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
|
||||
Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin"))
|
||||
SystemThemePlugin.register(with: registry.registrar(forPlugin: "SystemThemePlugin"))
|
||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||
WebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "WebViewFlutterPlugin"))
|
||||
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
|
||||
}
|
||||
|
46
macos/Podfile
Normal file
@@ -0,0 +1,46 @@
|
||||
platform :osx, '10.14.6'
|
||||
|
||||
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
||||
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
||||
|
||||
project 'Runner', {
|
||||
'Debug' => :debug,
|
||||
'Profile' => :release,
|
||||
'Release' => :release,
|
||||
}
|
||||
|
||||
def flutter_root
|
||||
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
|
||||
unless File.exist?(generated_xcode_build_settings_path)
|
||||
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
|
||||
end
|
||||
|
||||
File.foreach(generated_xcode_build_settings_path) do |line|
|
||||
matches = line.match(/FLUTTER_ROOT\=(.*)/)
|
||||
return matches[1].strip if matches
|
||||
end
|
||||
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
|
||||
end
|
||||
|
||||
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
|
||||
|
||||
flutter_macos_podfile_setup
|
||||
|
||||
target 'Runner' do
|
||||
use_frameworks!
|
||||
use_modular_headers!
|
||||
|
||||
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
|
||||
# target 'RunnerTests' do
|
||||
# inherit! :search_paths
|
||||
# end
|
||||
end
|
||||
|
||||
post_install do |installer|
|
||||
installer.pods_project.targets.each do |target|
|
||||
flutter_additional_macos_build_settings(target)
|
||||
target.build_configurations.each do |config|
|
||||
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.14.6'
|
||||
end
|
||||
end
|
||||
end
|
@@ -461,7 +461,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.14.6;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
@@ -543,7 +543,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.14.6;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
@@ -593,7 +593,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.14.6;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
|
@@ -3,10 +3,14 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<false/>
|
||||
<key>com.apple.security.cs.allow-jit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.server</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-write</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@@ -3,7 +3,7 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<false/>
|
||||
<key>com.apple.security.files.user-selected.read-write</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
|
450
pubspec.lock
@@ -5,106 +5,162 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: app_links
|
||||
sha256: "1c2b9e9c56d80d17610bcbd111b37187875c5d0ded8654caa1bda14ea753d001"
|
||||
sha256: "85ed8fc1d25a76475914fff28cc994653bd900bc2c26e4b57a49e097febb54ba"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.1"
|
||||
version: "6.4.0"
|
||||
app_links_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: app_links_linux
|
||||
sha256: f5f7173a78609f3dfd4c2ff2c95bd559ab43c80a87dc6a095921d96c05688c81
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.3"
|
||||
app_links_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: app_links_platform_interface
|
||||
sha256: "05f5379577c513b534a29ddea68176a4d4802c46180ee8e2e966257158772a3f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
app_links_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: app_links_web
|
||||
sha256: af060ed76183f9e2b87510a9480e56a5352b6c249778d07bd2c95fc35632a555
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
archive:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: archive
|
||||
sha256: ecf4273855368121b1caed0d10d4513c7241dfc813f7d3c8933b36622ae9b265
|
||||
sha256: "2fde1607386ab523f7a36bb3e7edb43bd58e6edaf2ffb29d8a6d578b297fdbbd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.5.1"
|
||||
version: "4.0.7"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
|
||||
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.11.0"
|
||||
version: "2.13.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
|
||||
sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
version: "2.1.2"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: characters
|
||||
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
|
||||
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
version: "1.4.0"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: clock
|
||||
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
|
||||
sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
version: "1.1.2"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
|
||||
sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.18.0"
|
||||
version: "1.19.1"
|
||||
cross_file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: cross_file
|
||||
sha256: "55d7b444feb71301ef6b8838dbc1ae02e63dd48c8773f3810ff53bb1e2945b32"
|
||||
sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.4+1"
|
||||
version: "0.3.4+2"
|
||||
crypto:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: crypto
|
||||
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
|
||||
sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
version: "3.0.6"
|
||||
device_info_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: device_info_plus
|
||||
sha256: "98f28b42168cc509abc92f88518882fd58061ea372d7999aecc424345c7bff6a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "11.5.0"
|
||||
device_info_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: device_info_plus_platform_interface
|
||||
sha256: e1ea89119e34903dca74b883d0dd78eb762814f97fb6c76f35e9ff74d261a18f
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.3"
|
||||
dio:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: dio
|
||||
sha256: "11e40df547d418cc0c4900a9318b26304e665da6fa4755399a9ff9efd09034b5"
|
||||
sha256: "253a18bbd4851fecba42f7343a1df3a9a4c1d31a2c1b37e221086b4fa8c8dbc9"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.4.3+1"
|
||||
version: "5.8.0+1"
|
||||
dio_web_adapter:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dio_web_adapter
|
||||
sha256: "7586e476d70caecaf1686d21eee7247ea43ef5c345eab9e0cc3583ff13378d78"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
dynamic_color:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: dynamic_color
|
||||
sha256: eae98052fa6e2826bdac3dd2e921c6ce2903be15c6b7f8b6d8a5d49b5086298d
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fake_async
|
||||
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
|
||||
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
version: "1.3.3"
|
||||
ffi:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ffi
|
||||
sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21"
|
||||
sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
version: "2.1.4"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
|
||||
sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.0"
|
||||
version: "7.0.1"
|
||||
file_selector:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -117,34 +173,34 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_android
|
||||
sha256: "57265ec9591e8fd8508f613544cde6f7d045731f6b09644057e49a4c9c672b7c"
|
||||
sha256: "6bba3d590ee9462758879741abc132a19133600dd31832f55627442f1ebd7b54"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.1+1"
|
||||
version: "0.5.1+14"
|
||||
file_selector_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_ios
|
||||
sha256: "7160121e434910ec23717bde3a0c514ca039e8c97b791ff35d1786da38abcb4a"
|
||||
sha256: "94b98ad950b8d40d96fee8fa88640c2e4bd8afcdd4817993bd04e20310f45420"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.2"
|
||||
version: "0.5.3+1"
|
||||
file_selector_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_linux
|
||||
sha256: "045d372bf19b02aeb69cacf8b4009555fb5f6f0b7ad8016e5f46dd1387ddd492"
|
||||
sha256: "54cbbd957e1156d29548c7d9b9ec0c0ebb6de0a90452198683a7d23aed617a33"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.2+1"
|
||||
version: "0.9.3+2"
|
||||
file_selector_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_macos
|
||||
sha256: f42eacb83b318e183b1ae24eead1373ab1334084404c8c16e0354f9a3e55d385
|
||||
sha256: "8c9250b2bd2d8d4268e39c82543bacbaca0fda7d29e0728c3c4bbb7c820fd711"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.4"
|
||||
version: "0.9.4+3"
|
||||
file_selector_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -157,47 +213,55 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_web
|
||||
sha256: "619e431b224711a3869e30dbd7d516f5f5a4f04b265013a50912f39e1abc88c8"
|
||||
sha256: c4c0ea4224d97a60a7067eca0c8fd419e708ff830e0c83b11a48faf566cec3e7
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.4+1"
|
||||
version: "0.9.4+2"
|
||||
file_selector_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_windows
|
||||
sha256: d3547240c20cabf205c7c7f01a50ecdbc413755814d6677f3cb366f04abcead0
|
||||
sha256: "320fcfb6f33caa90f0b58380489fc5ac05d99ee94b61aa96ec2bff0ba81d3c2b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.3+1"
|
||||
version: "0.9.3+4"
|
||||
fixnum:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fixnum
|
||||
sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1"
|
||||
sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.1.1"
|
||||
fluent_ui:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: fluent_ui
|
||||
sha256: a8c76cb501303d108cb9bd33e516da7cfd078031ff427d68eab6069bf4492a2c
|
||||
sha256: "8645eabacb46bfc9632fadc6e106756cdc6f2a4efb5a4fed4410bd3131306fe8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.8.7"
|
||||
version: "4.12.0"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_acrylic:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_acrylic
|
||||
sha256: "646200d98e8dd2bd4ab931d4ba4f6b4cb899475d6401414017ba5d71b0fac42b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0+2"
|
||||
flutter_file_dialog:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_file_dialog
|
||||
sha256: "5a1507833473b38839056d63c5125750a6d12e904f78131324fa4632504de513"
|
||||
sha256: "9344b8f07be6a1b6f9854b723fb0cf84a8094ba94761af1d213589d3cb087488"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
version: "3.0.2"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@@ -224,6 +288,14 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_to_arch:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_to_arch
|
||||
sha256: b68b2757a89a517ae2141cbc672acdd1f69721dd686cacad03876b6f436ff040
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
flutter_web_plugins:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@@ -241,42 +313,66 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http
|
||||
sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938"
|
||||
sha256: "2c11f3f94c687ee9bad77c171151672986360b2b001d109814ee7140b2cf261b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
version: "1.4.0"
|
||||
http_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_parser
|
||||
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
|
||||
sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.0.2"
|
||||
version: "4.1.2"
|
||||
image_gallery_saver_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: image_gallery_saver_plus
|
||||
sha256: "199b9e24f8d85e98f11e3d35571ab68ae50626ad40e2bb85c84383f69a6950ad"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.0.1"
|
||||
intl:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: intl
|
||||
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
|
||||
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.19.0"
|
||||
version: "0.20.2"
|
||||
io:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: io
|
||||
sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
json_annotation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: json_annotation
|
||||
sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.9.0"
|
||||
leak_tracker:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker
|
||||
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
|
||||
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.0.4"
|
||||
version: "10.0.9"
|
||||
leak_tracker_flutter_testing:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker_flutter_testing
|
||||
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
|
||||
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
version: "3.0.9"
|
||||
leak_tracker_testing:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -297,74 +393,74 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
|
||||
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.12.16+1"
|
||||
version: "0.12.17"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
|
||||
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.8.0"
|
||||
version: "0.11.1"
|
||||
math_expressions:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: math_expressions
|
||||
sha256: db0b72d867491c4e53a1c773e2708d5d6e94bbe06be07080fc9f896766b9cd3d
|
||||
sha256: "218dc65bed4726562bb31c53d8daa3cc824664b26fb72d77bc592757edf74ba0"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.5.0"
|
||||
version: "2.7.0"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
|
||||
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.12.0"
|
||||
version: "1.16.0"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: mime
|
||||
sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2"
|
||||
sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
version: "2.0.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
|
||||
sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.0"
|
||||
version: "1.9.1"
|
||||
path_provider:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: path_provider
|
||||
sha256: c9e7d3a4cd1410877472158bee69963a4579f78b68c65a2b7d40d1a7a88bb161
|
||||
sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.3"
|
||||
version: "2.1.5"
|
||||
path_provider_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_android
|
||||
sha256: a248d8146ee5983446bf03ed5ea8f6533129a12b11f12057ad1b4a67a2b3b41d
|
||||
sha256: d0d310befe2c8ab9e7f393288ccbb11b60c019c6b5afc21973eeee4dda2b35e9
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.4"
|
||||
version: "2.2.17"
|
||||
path_provider_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_foundation
|
||||
sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16
|
||||
sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.0"
|
||||
version: "2.4.1"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -385,16 +481,24 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_windows
|
||||
sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170"
|
||||
sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
version: "2.3.0"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: petitparser
|
||||
sha256: "07c8f0b1913bcde1ff0d26e57ace2f3012ccbf2b204e070290dad3bb22797646"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.0"
|
||||
photo_view:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: main
|
||||
resolved-ref: "97de36fa8c500c18037f675c122785b193559e09"
|
||||
resolved-ref: a1255d1b5945aad4b7323303ec2ecdf0c90ffc4c
|
||||
url: "https://github.com/wgh136/photo_view"
|
||||
source: git
|
||||
version: "0.14.0"
|
||||
@@ -402,10 +506,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: platform
|
||||
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
|
||||
sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.4"
|
||||
version: "3.1.6"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -414,6 +518,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.8"
|
||||
posix:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: posix
|
||||
sha256: "6323a5b0fa688b6a010df4905a56b00181479e6d10534cecfecede2aa55add61"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.3"
|
||||
recase:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -426,10 +538,42 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: screen_retriever
|
||||
sha256: "6ee02c8a1158e6dae7ca430da79436e3b1c9563c8cf02f524af997c201ac2b90"
|
||||
sha256: "570dbc8e4f70bac451e0efc9c9bb19fa2d6799a11e6ef04f946d7886d2e23d0c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.9"
|
||||
version: "0.2.0"
|
||||
screen_retriever_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: screen_retriever_linux
|
||||
sha256: f7f8120c92ef0784e58491ab664d01efda79a922b025ff286e29aa123ea3dd18
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
screen_retriever_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: screen_retriever_macos
|
||||
sha256: "71f956e65c97315dd661d71f828708bd97b6d358e776f1a30d5aa7d22d78a149"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
screen_retriever_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: screen_retriever_platform_interface
|
||||
sha256: ee197f4581ff0d5608587819af40490748e1e39e648d7680ecf95c05197240c0
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
screen_retriever_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: screen_retriever_windows
|
||||
sha256: "449ee257f03ca98a57288ee526a301a430a344a161f9202b4fcc38576716fe13"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
scroll_pos:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -442,31 +586,31 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: share_plus
|
||||
sha256: ef3489a969683c4f3d0239010cc8b7a2a46543a8d139e111c06c558875083544
|
||||
sha256: fce43200aa03ea87b91ce4c3ac79f0cecd52e2a7a56c7a4185023c271fbfa6da
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "9.0.0"
|
||||
version: "10.1.4"
|
||||
share_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: share_plus_platform_interface
|
||||
sha256: "0f9e4418835d1b2c3ae78fdb918251959106cefdbc4dd43526e182f80e82f6d4"
|
||||
sha256: cc012a23fc2d479854e6c80150696c4a5f5bb62cb89af4de1c505cf78d0a5d0b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.0.0"
|
||||
version: "5.0.2"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.99"
|
||||
version: "0.0.0"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_span
|
||||
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
|
||||
sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
version: "1.10.1"
|
||||
sprintf:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -479,122 +623,106 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: sqlite3
|
||||
sha256: b384f598b813b347c5a7e5ffad82cbaff1bec3d1561af267041e66f6f0899295
|
||||
sha256: c0503c69b44d5714e6abbf4c1f51a3c3cc42b75ce785f44404765e4635481d38
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.3"
|
||||
version: "2.7.6"
|
||||
sqlite3_flutter_libs:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: sqlite3_flutter_libs
|
||||
sha256: fb2a106a2ea6042fe57de2c47074cc31539a941819c91e105b864744605da3f5
|
||||
sha256: e07232b998755fe795655c56d1f5426e0190c9c435e1752d39e7b1cd33699c71
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.21"
|
||||
version: "0.5.34"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
|
||||
sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.11.1"
|
||||
version: "1.12.1"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
|
||||
sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
version: "2.1.4"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
|
||||
sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
system_theme:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: system_theme
|
||||
sha256: "1f208db140a3d1e1eac2034b54920d95699c1534df576ced44b3312c5de3975f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
system_theme_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: system_theme_web
|
||||
sha256: "7566f5a928f6d28d7a60c97bea8a851d1c6bc9b86a4df2366230a97458489219"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.0.2"
|
||||
version: "1.4.1"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
|
||||
sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
version: "1.2.2"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
|
||||
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.0"
|
||||
version: "0.7.4"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
|
||||
sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.2"
|
||||
version: "1.4.0"
|
||||
url_launcher:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: url_launcher
|
||||
sha256: "6ce1e04375be4eed30548f10a315826fd933c1e493206eab82eed01f438c8d2e"
|
||||
sha256: "9d06212b1362abc2f0f0d78e6f09f726608c74e3b9462e8368bb03314aa8d603"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.2.6"
|
||||
version: "6.3.1"
|
||||
url_launcher_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_android
|
||||
sha256: "360a6ed2027f18b73c8d98e159dda67a61b7f2e0f6ec26e86c3ada33b0621775"
|
||||
sha256: "8582d7f6fe14d2652b4c45c9b6c14c0b678c2af2d083a11b604caeba51930d79"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.3.1"
|
||||
version: "6.3.16"
|
||||
url_launcher_ios:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: url_launcher_ios
|
||||
sha256: "7068716403343f6ba4969b4173cbf3b84fc768042124bc2c011e5d782b24fe89"
|
||||
sha256: "7f2022359d4c099eea7df3fdf739f7d3d3b9faf3166fb1dd390775176e0b76cb"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.3.0"
|
||||
version: "6.3.3"
|
||||
url_launcher_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_linux
|
||||
sha256: ab360eb661f8879369acac07b6bb3ff09d9471155357da8443fd5d3cf7363811
|
||||
sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.1"
|
||||
version: "3.2.1"
|
||||
url_launcher_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_macos
|
||||
sha256: "9a1a42d5d2d95400c795b2914c36fdcb525870c752569438e4ebb09a2b5d90de"
|
||||
sha256: "17ba2000b847f334f16626a574c702b196723af2a289e7a93ffcb79acff855c2"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.0"
|
||||
version: "3.2.2"
|
||||
url_launcher_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -607,26 +735,26 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_web
|
||||
sha256: "8d9e750d8c9338601e709cd0885f95825086bd8b642547f26bda435aade95d8a"
|
||||
sha256: "4bd2b7b4dc4d4d0b94e5babfffbca8eac1a126c7f3d6ecbc1a11013faa3abba2"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
version: "2.4.1"
|
||||
url_launcher_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_windows
|
||||
sha256: ecf9725510600aa2bb6d7ddabe16357691b6d2805f66216a97d1b881e21beff7
|
||||
sha256: "3284b6d2ac454cf34f114e1d3319866fdd1e19cdc329999057e44ffe936cfa77"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.1"
|
||||
version: "3.1.4"
|
||||
uuid:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: uuid
|
||||
sha256: "814e9e88f21a176ae1359149021870e87f7cddaf633ab678a5d2b0bff7fd1ba8"
|
||||
sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.4.0"
|
||||
version: "4.5.1"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -639,82 +767,90 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vm_service
|
||||
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
|
||||
sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "14.2.1"
|
||||
version: "15.0.0"
|
||||
web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web
|
||||
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
|
||||
sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.1"
|
||||
version: "1.1.1"
|
||||
webview_flutter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: webview_flutter
|
||||
sha256: "25e1b6e839e8cbfbd708abc6f85ed09d1727e24e08e08c6b8590d7c65c9a8932"
|
||||
sha256: c3e4fe614b1c814950ad07186007eff2f2e5dd2935eba7b9a9a1af8e5885f1ba
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.7.0"
|
||||
version: "4.13.0"
|
||||
webview_flutter_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_android
|
||||
sha256: dad3313c9ead95517bb1cae5e1c9d20ba83729d5a59e5e83c0a2d66203f27f91
|
||||
sha256: f6e6afef6e234801da77170f7a1847ded8450778caf2fe13979d140484be3678
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.16.1"
|
||||
version: "4.7.0"
|
||||
webview_flutter_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_platform_interface
|
||||
sha256: d937581d6e558908d7ae3dc1989c4f87b786891ab47bb9df7de548a151779d8d
|
||||
sha256: f0dc2dc3a2b1e3a6abdd6801b9355ebfeb3b8f6cde6b9dc7c9235909c4a1f147
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.10.0"
|
||||
version: "2.13.1"
|
||||
webview_flutter_wkwebview:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_wkwebview
|
||||
sha256: "7affdf9d680c015b11587181171d3cad8093e449db1f7d9f0f08f4f33d24f9a0"
|
||||
sha256: a3d461fe3467014e05f3ac4962e5fdde2a4bf44c561cb53e9ae5c586600fdbc3
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.13.1"
|
||||
version: "3.22.0"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
sha256: "0eaf06e3446824099858367950a813472af675116bf63f008a4c2a75ae13e9cb"
|
||||
sha256: "66814138c3562338d05613a6e368ed8cfb237ad6d64a9e9334be3f309acfca03"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.5.0"
|
||||
version: "5.14.0"
|
||||
win32_registry:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: win32_registry
|
||||
sha256: "10589e0d7f4e053f2c61023a31c9ce01146656a70b7b7f0828c0b46d7da2a9bb"
|
||||
sha256: "6f1b564492d0147b330dd794fee8f512cec4977957f310f9951b5f9d83618dae"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.3"
|
||||
version: "2.1.0"
|
||||
window_manager:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: window_manager
|
||||
sha256: b3c895bdf936c77b83c5254bec2e6b3f066710c1f89c38b20b8acc382b525494
|
||||
sha256: "732896e1416297c63c9e3fb95aea72d0355f61390263982a47fd519169dc5059"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.8"
|
||||
version: "0.4.3"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xdg_directories
|
||||
sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d
|
||||
sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
version: "1.1.0"
|
||||
yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: yaml
|
||||
sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.3"
|
||||
sdks:
|
||||
dart: ">=3.3.4 <4.0.0"
|
||||
flutter: ">=3.19.0"
|
||||
dart: ">=3.8.0 <4.0.0"
|
||||
flutter: ">=3.32.5"
|
||||
|
45
pubspec.yaml
@@ -16,10 +16,11 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.0.2+3
|
||||
version: 1.2.0+120
|
||||
|
||||
environment:
|
||||
sdk: '>=3.3.4 <4.0.0'
|
||||
flutter: 3.32.5
|
||||
|
||||
# Dependencies specify other packages that your package needs in order to work.
|
||||
# To automatically upgrade your package dependencies to the latest versions
|
||||
@@ -34,28 +35,32 @@ dependencies:
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
window_manager: ^0.3.8
|
||||
fluent_ui: ^4.8.7
|
||||
system_theme: ^2.3.1
|
||||
dio: ^5.4.3
|
||||
crypto:
|
||||
window_manager: ^0.4.3
|
||||
fluent_ui: ^4.12.0
|
||||
dynamic_color: ^1.7.0
|
||||
dio: ^5.8.0
|
||||
crypto: ^3.0.6
|
||||
intl:
|
||||
path_provider:
|
||||
url_launcher: ^6.1.8
|
||||
app_links: ^6.0.1
|
||||
win32_registry: ^1.1.3
|
||||
path_provider: ^2.1.5
|
||||
url_launcher: ^6.3.1
|
||||
url_launcher_ios: ^6.3.2
|
||||
app_links: ^6.4.0
|
||||
win32_registry: ^2.1.0
|
||||
flutter_staggered_grid_view: ^0.7.0
|
||||
sqlite3: ^2.4.3
|
||||
sqlite3: ^2.7.6
|
||||
sqlite3_flutter_libs: any
|
||||
photo_view:
|
||||
git:
|
||||
url: https://github.com/wgh136/photo_view
|
||||
ref: main
|
||||
share_plus: ^9.0.0
|
||||
share_plus: ^10.1.3
|
||||
file_selector: ^1.0.1
|
||||
flutter_file_dialog: 3.0.1
|
||||
archive: ^3.5.1
|
||||
webview_flutter: ^4.7.0
|
||||
flutter_file_dialog: ^3.0.2
|
||||
archive: ^4.0.7
|
||||
webview_flutter: ^4.13.0
|
||||
flutter_acrylic: 1.0.0+2
|
||||
device_info_plus: ^11.5.0
|
||||
image_gallery_saver_plus: ^4.0.1
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
@@ -66,10 +71,20 @@ dev_dependencies:
|
||||
# package. See that file for information about deactivating specific lint
|
||||
# rules and activating additional ones.
|
||||
flutter_lints: ^3.0.0
|
||||
flutter_to_arch: ^1.0.1
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
flutter_to_arch:
|
||||
name: Pixes
|
||||
icon: debian/gui/pixes.png
|
||||
categories: Utility
|
||||
keywords: Flutter;pixiv;images;
|
||||
url: https://github.com/wgh136/pixes
|
||||
depends:
|
||||
- gtk3
|
||||
|
||||
# The following section is specific to Flutter packages.
|
||||
flutter:
|
||||
|
||||
|
BIN
screenshots/1.png
Normal file
After Width: | Height: | Size: 520 KiB |
BIN
screenshots/2.png
Normal file
After Width: | Height: | Size: 169 KiB |
BIN
screenshots/3.png
Normal file
After Width: | Height: | Size: 492 KiB |
BIN
screenshots/4.png
Normal file
After Width: | Height: | Size: 637 KiB |
64
windows/build.iss
Normal file
@@ -0,0 +1,64 @@
|
||||
; Script generated by the Inno Setup Script Wizard.
|
||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
#define MyAppName "pixes"
|
||||
#define MyAppVersion "{{version}}"
|
||||
#define MyAppPublisher "Nyne"
|
||||
#define MyAppURL "https://github.com/wgh136/pixes"
|
||||
#define MyAppExeName "pixes.exe"
|
||||
#define RootPath "{{root_path}}"
|
||||
|
||||
[Setup]
|
||||
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
|
||||
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
|
||||
AppId={{88521115-48B7-4AF3-BF49-2BC6AF90B8D3}
|
||||
AppName={#MyAppName}
|
||||
AppVersion={#MyAppVersion}
|
||||
;AppVerName={#MyAppName} {#MyAppVersion}
|
||||
AppPublisher={#MyAppPublisher}
|
||||
AppPublisherURL={#MyAppURL}
|
||||
AppSupportURL={#MyAppURL}
|
||||
AppUpdatesURL={#MyAppURL}
|
||||
DefaultDirName={autopf}\{#MyAppName}
|
||||
DisableProgramGroupPage=yes
|
||||
; Uncomment the following line to run in non administrative install mode (install for current user only.)
|
||||
;PrivilegesRequired=lowest
|
||||
PrivilegesRequiredOverridesAllowed=dialog
|
||||
OutputDir={#RootPath}\build\windows
|
||||
OutputBaseFilename=pixes-{#MyAppVersion}-windows-installer
|
||||
SetupIconFile={#RootPath}\windows\runner\resources\app_icon.ico
|
||||
Compression=lzma
|
||||
SolidCompression=yes
|
||||
WizardStyle=modern
|
||||
ArchitecturesInstallIn64BitMode=x64 arm64
|
||||
ArchitecturesAllowed=x64 arm64
|
||||
|
||||
[Languages]
|
||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||
Name: "chinesesimplified"; MessagesFile: "{#RootPath}\windows\ChineseSimplified.isl"
|
||||
|
||||
[Tasks]
|
||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
||||
|
||||
[Files]
|
||||
Source: "{#RootPath}\build\windows\x64\runner\Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#RootPath}\build\windows\x64\runner\Release\app_links_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#RootPath}\build\windows\x64\runner\Release\dynamic_color_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#RootPath}\build\windows\x64\runner\Release\file_selector_windows_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#RootPath}\build\windows\x64\runner\Release\flutter_windows.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#RootPath}\build\windows\x64\runner\Release\screen_retriever_windows_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#RootPath}\build\windows\x64\runner\Release\share_plus_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#RootPath}\build\windows\x64\runner\Release\sqlite3.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#RootPath}\build\windows\x64\runner\Release\sqlite3_flutter_libs_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#RootPath}\build\windows\x64\runner\Release\url_launcher_windows_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#RootPath}\build\windows\x64\runner\Release\window_manager_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#RootPath}\build\windows\x64\runner\Release\flutter_acrylic_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#RootPath}\build\windows\x64\runner\Release\data\*"; DestDir: "{app}\data"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||
|
||||
[Icons]
|
||||
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
||||
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
||||
|
||||
[Run]
|
||||
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall
|
37
windows/build.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import subprocess
|
||||
import os
|
||||
import httpx
|
||||
|
||||
file = open('pubspec.yaml', 'r')
|
||||
content = file.read()
|
||||
file.close()
|
||||
|
||||
subprocess.run(["flutter", "build", "windows"], shell=True)
|
||||
|
||||
version = str.split(str.split(content, 'version: ')[1], '+')[0]
|
||||
|
||||
subprocess.run(["tar", "-a", "-c", "-f", f"build/windows/pixes-{version}-windows.zip", "-C", "build/windows/x64/runner/Release", "*"]
|
||||
, shell=True)
|
||||
|
||||
issContent = ""
|
||||
file = open('windows/build.iss', 'r')
|
||||
issContent = file.read()
|
||||
newContent = issContent
|
||||
newContent = newContent.replace("{{version}}", version)
|
||||
newContent = newContent.replace("{{root_path}}", os.getcwd())
|
||||
file.close()
|
||||
file = open('windows/build.iss', 'w')
|
||||
file.write(newContent)
|
||||
file.close()
|
||||
|
||||
if not os.path.exists("windows/ChineseSimplified.isl"):
|
||||
# download ChineseSimplified.isl
|
||||
url = "https://raw.githubusercontent.com/kira-96/Inno-Setup-Chinese-Simplified-Translation/refs/heads/main/ChineseSimplified.isl"
|
||||
response = httpx.get(url)
|
||||
with open('windows/ChineseSimplified.isl', 'wb') as file:
|
||||
file.write(response.content)
|
||||
|
||||
subprocess.run(["iscc", "windows/build.iss"], shell=True)
|
||||
|
||||
with open('windows/build.iss', 'w') as file:
|
||||
file.write(issContent)
|
@@ -7,21 +7,30 @@
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <app_links/app_links_plugin_c_api.h>
|
||||
#include <screen_retriever/screen_retriever_plugin.h>
|
||||
#include <dynamic_color/dynamic_color_plugin_c_api.h>
|
||||
#include <file_selector_windows/file_selector_windows.h>
|
||||
#include <flutter_acrylic/flutter_acrylic_plugin.h>
|
||||
#include <screen_retriever_windows/screen_retriever_windows_plugin_c_api.h>
|
||||
#include <share_plus/share_plus_windows_plugin_c_api.h>
|
||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
||||
#include <system_theme/system_theme_plugin.h>
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
#include <window_manager/window_manager_plugin.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
AppLinksPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("AppLinksPluginCApi"));
|
||||
ScreenRetrieverPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("ScreenRetrieverPlugin"));
|
||||
DynamicColorPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("DynamicColorPluginCApi"));
|
||||
FileSelectorWindowsRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FileSelectorWindows"));
|
||||
FlutterAcrylicPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FlutterAcrylicPlugin"));
|
||||
ScreenRetrieverWindowsPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("ScreenRetrieverWindowsPluginCApi"));
|
||||
SharePlusWindowsPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
|
||||
Sqlite3FlutterLibsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin"));
|
||||
SystemThemePluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("SystemThemePlugin"));
|
||||
UrlLauncherWindowsRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
|
||||
WindowManagerPluginRegisterWithRegistrar(
|
||||
|
@@ -4,9 +4,12 @@
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
app_links
|
||||
screen_retriever
|
||||
dynamic_color
|
||||
file_selector_windows
|
||||
flutter_acrylic
|
||||
screen_retriever_windows
|
||||
share_plus
|
||||
sqlite3_flutter_libs
|
||||
system_theme
|
||||
url_launcher_windows
|
||||
window_manager
|
||||
)
|
||||
|
BIN
windows/runner/RCa14464
Normal file
BIN
windows/runner/Runner.aps
Normal file
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 121 KiB |