71 Commits

Author SHA1 Message Date
513e716608 update windows build script 2024-12-14 21:38:34 +08:00
8364b56178 fix android 2024-12-14 21:26:51 +08:00
0d0122be3a Update version code 2024-12-14 18:26:32 +08:00
4f1fd8530a Update build script 2024-12-14 18:24:05 +08:00
82b8eac989 fix #6 2024-12-14 18:08:54 +08:00
95815131fe fix #4 2024-12-14 17:52:12 +08:00
f8439a3cb2 Update README.md 2024-12-14 17:27:16 +08:00
f7a6eb1ac9 fix #8 2024-12-14 17:20:23 +08:00
a10e8c05d5 update font 2024-12-14 17:15:56 +08:00
bd15053c2f Migrate to flutter 3.27.0 2024-12-14 17:08:55 +08:00
nyne
86c6f13282 fix workflow 2024-10-02 21:40:09 +08:00
nyne
b69d2a0950 update workflow 2024-10-02 21:30:45 +08:00
nyne
c897891b2a add archlinux build 2024-10-02 21:15:55 +08:00
nyne
3c73439588 update version code 2024-10-02 21:12:10 +08:00
nyne
2d16502154 add translator for novel 2024-10-02 21:10:22 +08:00
nyne
294498d8a7 update README.md 2024-10-02 16:47:23 +08:00
nyne
20dfbf5125 improve code 2024-10-02 16:45:25 +08:00
nyne
63aa4ee8b0 improve ui 2024-10-02 16:29:45 +08:00
nyne
c8d4b3db88 fix input 2024-10-02 16:26:15 +08:00
wgh19
b1e7adb1c5 verify response data 2024-06-29 19:15:58 +08:00
wgh19
0143a67fa0 add search button for mobile platform 2024-06-18 19:56:52 +08:00
wgh19
eee1141970 update readme.md 2024-06-14 13:09:37 +08:00
wgh19
50a69f77b6 improve ui 2024-06-14 12:50:27 +08:00
wgh19
790ed54d5b Emphasize artworks from following artists 2024-06-14 12:38:50 +08:00
wgh19
21fe14f88b improve ui; update version code 2024-06-14 12:22:37 +08:00
wgh19
a03ad12837 check update 2024-06-13 23:01:01 +08:00
wgh19
426257716f fix save_to_gallery 2024-06-13 22:48:52 +08:00
wgh19
67e01ea69f catch error 2024-06-13 22:24:21 +08:00
wgh19
6cf9ce9c96 improve ui 2024-06-13 20:54:31 +08:00
wgh19
593899af8c disable acrylic effect for windows 10 2024-06-13 12:40:34 +08:00
wgh19
908c26d764 update readme.md 2024-06-12 22:34:53 +08:00
wgh19
eef1af3ad1 update build script 2024-06-12 22:09:29 +08:00
nyne
b97c7cde25 add linux workflow 2024-06-12 21:58:26 +08:00
nyne
6118fc30f8 update version code; add linux build script 2024-06-12 21:51:20 +08:00
nyne
4476ad7f90 linux support 2024-06-12 21:30:23 +08:00
wgh19
7c8fabf52c add shortcuts 2024-06-12 19:17:32 +08:00
wgh19
70da478044 improve login 2024-06-12 17:03:45 +08:00
wgh19
b14c2682a7 save to gallery 2024-06-12 16:45:39 +08:00
wgh19
54b64fb19b improve ui 2024-06-12 16:05:50 +08:00
wgh19
d247455c19 local history 2024-06-12 15:43:06 +08:00
wgh19
759d6959b5 improve login and logout 2024-06-11 17:27:48 +08:00
wgh19
488be5fb1a add retry 2024-06-05 22:54:42 +08:00
wgh19
62b50c466e update readme 2024-06-01 22:47:28 +08:00
wgh19
49da2b772b fix display error 2024-06-01 22:13:22 +08:00
wgh19
4dc1ec8784 improve ui 2024-06-01 22:03:31 +08:00
wgh19
1fad3694cf open link 2024-06-01 16:44:25 +08:00
wgh136
39eb5c836e fix macos build 2024-05-31 23:52:14 +08:00
wgh136
9603706fc6 fix macos build 2024-05-31 23:41:15 +08:00
wgh19
343e993627 fix macos build 2024-05-31 20:26:42 +08:00
wgh19
246f96bdbf update macos&windows build 2024-05-31 20:06:28 +08:00
wgh19
61c6ed0e1b fix init 2024-05-31 19:58:06 +08:00
wgh19
fd63b02b60 update version code 2024-05-31 19:40:03 +08:00
wgh19
9275024050 add a setting for original image 2024-05-31 19:32:46 +08:00
wgh19
5e53c57755 improve progress display 2024-05-31 18:39:28 +08:00
wgh19
6a95fb37ed font 2024-05-31 17:46:59 +08:00
wgh19
20829e1ad5 improve text 2024-05-31 17:44:50 +08:00
wgh19
cb356dbf71 shortcuts 2024-05-31 17:38:27 +08:00
wgh19
9ad6207bd5 fix drag issue 2024-05-31 15:28:04 +08:00
wgh19
676e7508c7 update icon 2024-05-31 15:23:26 +08:00
wgh19
1652a93772 window effect for windows 2024-05-31 15:21:58 +08:00
wgh19
e6d015a2bc deep link for android 2024-05-31 11:45:54 +08:00
wgh19
35dd9dee5f fix window placement 2024-05-27 14:48:07 +08:00
wgh19
b34a8342d2 fix ui 2024-05-23 13:55:44 +08:00
nyne
0ed17edd3e Create LICENSE 2024-05-23 13:17:02 +08:00
wgh19
187e5f9a09 fix ui; update windows build 2024-05-23 11:56:49 +08:00
wgh19
9505b78ae4 update version code 2024-05-22 20:59:52 +08:00
wgh19
1d49f1c387 follow and favorite callbacks 2024-05-22 20:59:15 +08:00
wgh19
7641cc8f5c block tags and authors 2024-05-22 20:40:35 +08:00
wgh19
de26cba0fa Restore window placement on startup 2024-05-22 12:49:58 +08:00
wgh19
471b319891 block tags 2024-05-22 09:30:31 +08:00
wgh136
1a224114fc fix & improve DownloadedPage 2024-05-21 14:59:09 +08:00
83 changed files with 3935 additions and 1070 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -1,40 +1,167 @@
name: Build IOS name: Build ALL
run-name: Build IOS run-name: Build ALL
on: on:
workflow_dispatch: {} workflow_dispatch: {}
release:
types: [published]
jobs: 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: Build_MacOS:
runs-on: macos-13 runs-on: macos-15
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: subosito/flutter-action@v2 - uses: subosito/flutter-action@v2
with: with:
channel: 'stable' channel: 'stable'
architecture: x64 architecture: x64
- run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app flutter-version-file: pubspec.yaml
- run: flutter pub get - run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app
- run: flutter build macos --release - run: flutter pub get
- run: | - run: flutter build macos --release
cd build/macos/Build/Products/Release - run: |
zip -r macos-build.zip pixes.app cd build/macos/Build/Products/Release
- uses: actions/upload-artifact@v4 chmod +x pixes.app/Contents/MacOS/pixes
with: zip -r macos.zip pixes.app
name: macos-build.zip - uses: actions/upload-artifact@v4
path: build/macos/Build/Products/Release/macos-build.zip 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
- 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/
Release:
runs-on: ubuntu-latest
needs: [Build_MacOS, Build_IOS, Build_Android, Build_Windows, Build_Linux]
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: 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
View File

@@ -0,0 +1,15 @@
{
"cSpell.words": [
"appdata",
"Bungo",
"gjzr",
"microtask",
"mypixiv",
"pawoo",
"Rorigod",
"sleepinglife",
"Ugoira",
"vocaloidhm",
"vsync"
]
}

21
LICENSE Normal file
View 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.

View File

@@ -1,9 +1,44 @@
# pixes # pixes
非官方 Pixiv app, 支持 Windows, Android, iOS, macOS [![flutter](https://img.shields.io/badge/flutter-3.27.0-blue)](https://flutter.dev/)
[![License](https://img.shields.io/github/license/wgh136/pixes)](https://github.com/wgh136/pixes/blob/master/LICENSE)
[![Download](https://img.shields.io/github/v/release/wgh136/pixes)](https://github.com/wgh136/pixes)
[![stars](https://img.shields.io/github/stars/wgh136/pixes)](https://github.com/wgh136/pixes/stargazers)
主要功能均已实现 Unofficial Pixiv app, support Windows, Android, iOS, macOS, linux
## 屏幕截图 All main features are implemented.
<img src="screenshots/1.png" style="width: 400px"> ## 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` to build deb package
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">

View File

@@ -34,25 +34,19 @@ android {
ndkVersion flutter.ndkVersion ndkVersion flutter.ndkVersion
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_17
} }
kotlinOptions{
kotlinOptions { jvmTarget = JavaVersion.VERSION_17
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
} }
defaultConfig { defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.github.wgh136.pixes" applicationId "com.github.wgh136.pixes"
// You can update the following values to match your application needs. // 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. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion minSdkVersion flutter.minSdkVersion
targetSdkVersion 34 targetSdk = flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName
} }
@@ -74,9 +68,7 @@ android {
buildTypes { buildTypes {
release { release {
// TODO: Add your own signing config for the release build. signingConfig signingConfigs.release
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
} }
} }
} }

View File

@@ -5,6 +5,7 @@
<application <application
android:label="pixes" android:label="pixes"
android:name="${applicationName}" android:name="${applicationName}"
android:enableOnBackInvokedCallback="true"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/ic_launcher">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
@@ -33,12 +34,22 @@
<!-- Accepts URIs that begin with "example://gizmos” --> <!-- Accepts URIs that begin with "example://gizmos” -->
<data android:scheme="pixiv"/> <data android:scheme="pixiv"/>
</intent-filter> </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> </activity>
<!-- Don't delete the meta-data below. <!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data <meta-data
android:name="flutterEmbedding" android:name="flutterEmbedding"
android:value="2" /> android:value="2" />
<meta-data android:name="io.flutter.embedding.android.EnableImpeller" android:value="false"/>
</application> </application>
<!-- Required to query activities that can process text, see: <!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility?hl=en and https://developer.android.com/training/package-visibility?hl=en and

View File

@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip

View File

@@ -19,8 +19,8 @@ pluginManagement {
plugins { plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false id "com.android.application" version "8.2.1" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false id "org.jetbrains.kotlin.android" version "2.1.0" apply false
} }
include ":app" include ":app"

Binary file not shown.

View File

@@ -3,7 +3,7 @@
"Search": "搜索", "Search": "搜索",
"Downloading": "下载中", "Downloading": "下载中",
"Downloaded": "已下载", "Downloaded": "已下载",
"Artwork": "作品", "Artwork": "插画",
"Explore": "探索", "Explore": "探索",
"Bookmarks": "收藏", "Bookmarks": "收藏",
"Following": "关注", "Following": "关注",
@@ -64,9 +64,9 @@
"Weekly Manga": "每周漫画", "Weekly Manga": "每周漫画",
"Monthly Manga": "每月漫画", "Monthly Manga": "每月漫画",
"R18": "R18", "R18": "R18",
"Account": "账", "Account": "账",
"Logout": "登出", "Logout": "登出",
"Account Settings": "账设置", "Account Settings": "账设置",
"Edit": "编辑", "Edit": "编辑",
"Download": "下载", "Download": "下载",
"Manage": "管理", "Manage": "管理",
@@ -112,7 +112,6 @@
"Multiple path separators will be automatically replaced with a single": "多个路径分隔符将被自动替换为单个", "Multiple path separators will be automatically replaced with a single": "多个路径分隔符将被自动替换为单个",
"Login": "登录", "Login": "登录",
"You need to complete the login operation in the browser window that will open.": "您需要在打开的浏览器窗口中完成登录操作", "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..." : "等待中...",
"Waiting for authentication. Please finished in the browser." : "等待验证. 请在浏览器中完成.", "Waiting for authentication. Please finished in the browser." : "等待验证. 请在浏览器中完成.",
"Back" : "返回", "Back" : "返回",
@@ -138,7 +137,54 @@
"Line Height": "行高", "Line Height": "行高",
"Paragraph Spacing": "段间距", "Paragraph Spacing": "段间距",
"light": "浅色", "light": "浅色",
"dark": "深色" "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": "关闭面板以应用设置"
}, },
"zh_TW": { "zh_TW": {
"Search": "搜索", "Search": "搜索",
@@ -253,7 +299,6 @@
"Multiple path separators will be automatically replaced with a single": "多個路徑分隔符號將自動替換為單一", "Multiple path separators will be automatically replaced with a single": "多個路徑分隔符號將自動替換為單一",
"Login": "登錄", "Login": "登錄",
"You need to complete the login operation in the browser window that will open.": "您需要在打開的瀏覽器窗口中完成登錄操作", "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..." : "等待中...",
"Waiting for authentication. Please finished in the browser." : "等待驗證. 請在瀏覽器中完成.", "Waiting for authentication. Please finished in the browser." : "等待驗證. 請在瀏覽器中完成.",
"Back" : "返回", "Back" : "返回",
@@ -279,6 +324,53 @@
"Line Height": "行高", "Line Height": "行高",
"Paragraph Spacing": "段間距", "Paragraph Spacing": "段間距",
"light": "淺色", "light": "淺色",
"dark": "深色" "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": "關閉面板以應用設置"
} }
} }

View File

@@ -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)

27
debian/build.py vendored Normal file
View File

@@ -0,0 +1,27 @@
import subprocess
import os
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:
f.write(debianContent.replace('{{Version}}', version))
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
View File

@@ -0,0 +1,18 @@
flutter_app:
command: pixes
arch: x64
parent: /usr/local/lib
nonInteractive: true
execFieldCodes: u
control:
Package: pixes
Version: {{Version}}
Architecture: amd64
Priority: optional
Depends:
Maintainer: nyne
Description: Unofficial pixiv application
#options:
# exec_out_dir: debian/packages

10
debian/gui/pixes.desktop vendored Normal file
View File

@@ -0,0 +1,10 @@
[Desktop Entry]
Version={{Version}}
Name=Pixes
GenericName=Pixes
Comment=Unofficial pixiv application
Terminal=false
Type=Application
Categories=Utility
Keywords=Flutter;share;images;
MimeType=x-scheme-handler/pixiv;

BIN
debian/gui/pixes.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -56,5 +56,9 @@
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
</dict> </dict>
</array> </array>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>photo</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>photo</string>
</dict> </dict>
</plist> </plist>

View File

@@ -23,6 +23,22 @@ class _Appdata {
"readingFontSize": 16.0, "readingFontSize": 16.0,
"readingLineHeight": 1.5, "readingLineHeight": 1.5,
"readingParagraphSpacing": 8.0, "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; bool lock = false;
@@ -52,14 +68,25 @@ class _Appdata {
Future<void> readData() async { Future<void> readData() async {
final file = File("${App.dataPath}/account.json"); final file = File("${App.dataPath}/account.json");
if (file.existsSync()) { 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"); final settingsFile = File("${App.dataPath}/settings.json");
if (settingsFile.existsSync()) { if (settingsFile.existsSync()) {
var json = jsonDecode(await settingsFile.readAsString()); var json = jsonDecode(await settingsFile.readAsString());
for (var key in json.keys) { for (var key in json.keys) {
if(json[key] != null) { if (json[key] != null) {
settings[key] = json[key]; 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];
}
} }
} }
} }

View File

@@ -15,7 +15,10 @@ class BatchDownloadButton extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Button( return Button(
child: const Icon(MdIcons.download, size: 20,), child: const Icon(
MdIcons.download,
size: 20,
),
onPressed: () { onPressed: () {
showDialog( showDialog(
context: context, context: context,
@@ -40,6 +43,8 @@ class _DownloadDialog extends StatefulWidget {
class _DownloadDialogState extends State<_DownloadDialog> { class _DownloadDialogState extends State<_DownloadDialog> {
int maxCount = 30; int maxCount = 30;
int currentCount = 0;
bool loading = false; bool loading = false;
bool cancel = false; bool cancel = false;
@@ -53,15 +58,18 @@ class _DownloadDialogState extends State<_DownloadDialog> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text('${"Maximum number of downloads".tl}:'), if (!loading) Text('${"Maximum number of downloads".tl}:'),
const SizedBox(height: 16,), if (loading) Text("${"Current quantity".tl}: $currentCount"),
const SizedBox(
height: 16,
),
SizedBox( SizedBox(
height: 42, height: 42,
width: 196, width: 196,
child: NumberBox( child: NumberBox(
value: maxCount, value: maxCount,
onChanged: (value) { onChanged: (value) {
if(!loading) { if (!loading) {
setState(() => maxCount = value ?? maxCount); setState(() => maxCount = value ?? maxCount);
} }
}, },
@@ -71,35 +79,39 @@ class _DownloadDialogState extends State<_DownloadDialog> {
largeChange: 30, largeChange: 30,
clearButton: false, clearButton: false,
), ),
) ),
], ],
).paddingVertical(8), ).paddingVertical(8),
), ),
actions: [ actions: [
Button(child: Text("Cancel".tl), onPressed: () { Button(
cancel = true; child: Text("Cancel".tl),
context.pop(); onPressed: () {
}), cancel = true;
if(!loading) context.pop();
}),
if (!loading)
FilledButton(onPressed: load, child: Text("Continue".tl)) FilledButton(onPressed: load, child: Text("Continue".tl))
else else
FilledButton(onPressed: (){}, child: const SizedBox( FilledButton(
height: 20, onPressed: () {},
width: 64, child: const SizedBox(
child: Center( height: 20,
child: SizedBox.square( width: 64,
dimension: 18, child: Center(
child: ProgressRing( child: SizedBox.square(
strokeWidth: 1.6, dimension: 18,
child: ProgressRing(
strokeWidth: 1.6,
),
),
), ),
), ))
),
))
], ],
); );
} }
void load() async{ void load() async {
setState(() { setState(() {
loading = true; loading = true;
}); });
@@ -109,17 +121,17 @@ class _DownloadDialogState extends State<_DownloadDialog> {
List<Illust> all = []; List<Illust> all = [];
String? nextUrl; String? nextUrl;
int retryCount = 0; int retryCount = 0;
while(nextUrl != "end" && all.length < maxCount) { while (nextUrl != "end" && all.length < maxCount) {
if(nextUrl != null) { if (nextUrl != null) {
request = Network().getIllustsWithNextUrl(nextUrl); request = Network().getIllustsWithNextUrl(nextUrl);
} }
var res = await request; var res = await request;
if(cancel || !mounted) { if (cancel || !mounted) {
return; return;
} }
if(res.error) { if (res.error) {
retryCount++; retryCount++;
if(retryCount > 3) { if (retryCount > 3) {
setState(() { setState(() {
loading = false; loading = false;
}); });
@@ -130,15 +142,17 @@ class _DownloadDialogState extends State<_DownloadDialog> {
continue; continue;
} }
all.addAll(res.data); all.addAll(res.data);
setState(() {
currentCount = all.length;
});
nextUrl = res.subData ?? "end"; nextUrl = res.subData ?? "end";
} }
int i = 0; int i = 0;
for(var illust in all) { for (var illust in all) {
if(i > maxCount) return; if (i > maxCount) break;
DownloadManager().addDownloadingTask(illust); DownloadManager().addDownloadingTask(illust);
i++; i++;
} }
context.pop(); context.pop();
} }
} }

100
lib/components/button.dart Normal file
View 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,
);
}
}

View File

@@ -92,6 +92,17 @@ class SliverGridDelegateWithFixedHeight extends SliverGridDelegate {
int calcCrossItemsCount(double width) { int calcCrossItemsCount(double width) {
int count = 20; int count = 20;
var itemWidth = width / 20; var itemWidth = width / 20;
if(minCrossAxisExtent == 0) {
count = 1;
itemWidth = width;
while(itemWidth > maxCrossAxisExtent) {
count++;
itemWidth = width / count;
}
return count;
}
while ( while (
!(itemWidth > minCrossAxisExtent && itemWidth < maxCrossAxisExtent)) { !(itemWidth > minCrossAxisExtent && itemWidth < maxCrossAxisExtent)) {
count--; count--;

View File

@@ -1,14 +1,19 @@
import 'package:fluent_ui/fluent_ui.dart'; import 'package:fluent_ui/fluent_ui.dart';
import 'package:pixes/appdata.dart';
import 'package:pixes/components/animated_image.dart'; import 'package:pixes/components/animated_image.dart';
import 'package:pixes/foundation/app.dart'; import 'package:pixes/foundation/app.dart';
import 'package:pixes/foundation/history.dart';
import 'package:pixes/foundation/image_provider.dart'; import 'package:pixes/foundation/image_provider.dart';
import 'package:pixes/network/download.dart'; import 'package:pixes/network/download.dart';
import 'package:pixes/pages/related_page.dart';
import 'package:pixes/utils/translation.dart'; import 'package:pixes/utils/translation.dart';
import '../network/network.dart'; import '../network/network.dart';
import '../pages/illust_page.dart'; import '../pages/illust_page.dart';
import 'md.dart'; import 'md.dart';
typedef UpdateFavoriteFunc = void Function(bool v);
class IllustWidget extends StatefulWidget { class IllustWidget extends StatefulWidget {
const IllustWidget(this.illust, {this.onTap, super.key}); const IllustWidget(this.illust, {this.onTap, super.key});
@@ -16,6 +21,8 @@ class IllustWidget extends StatefulWidget {
final void Function()? onTap; final void Function()? onTap;
static Map<String, UpdateFavoriteFunc> favoriteCallbacks = {};
@override @override
State<IllustWidget> createState() => _IllustWidgetState(); State<IllustWidget> createState() => _IllustWidgetState();
} }
@@ -26,6 +33,22 @@ class _IllustWidgetState extends State<IllustWidget> {
final contextController = FlyoutController(); final contextController = FlyoutController();
final contextAttachKey = GlobalKey(); 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, constrains) { return LayoutBuilder(builder: (context, constrains) {
@@ -39,52 +62,78 @@ class _IllustWidgetState extends State<IllustWidget> {
height: height, height: height,
child: Stack( child: Stack(
children: [ children: [
Positioned.fill(child: Container( Positioned.fill(
width: width, child: Container(
height: height, width: width,
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0), height: height,
child: Card( padding: const EdgeInsets.symmetric(
padding: EdgeInsets.zero, horizontal: 8.0, vertical: 8.0),
margin: EdgeInsets.zero, child: Container(
child: GestureDetector( width: double.infinity,
onTap: widget.onTap ?? (){ height: double.infinity,
context.to(() => IllustPage(widget.illust, favoriteCallback: (v) { padding: EdgeInsets.zero,
setState(() { decoration: BoxDecoration(
widget.illust.isBookmarked = v;
});
},));
},
onSecondaryTapUp: showMenu,
child: ClipRRect(
borderRadius: BorderRadius.circular(4.0), borderRadius: BorderRadius.circular(4.0),
child: AnimatedImage( color: FluentTheme.of(context).cardColor,
image: CachedImageProvider(widget.illust.images.first.medium), border: () {
fit: BoxFit.cover, var emphasis = widget.illust.author.isFollowed &&
width: width-16.0, appdata.settings[
height: height-16.0, '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( Positioned(
top: 12, top: 12,
left: 12, left: 12,
child: Container( child: Container(
width: 28, width: 28,
height: 20, height: 20,
decoration: BoxDecoration( decoration: BoxDecoration(
color: FluentTheme.of(context).cardColor, color: FluentTheme.of(context)
borderRadius: BorderRadius.circular(4), .micaBackgroundColor
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6), .toOpacity(0.72),
), borderRadius: BorderRadius.circular(4),
child: Center( border: Border.all(
child: Text("${widget.illust.images.length}P", color: ColorScheme.of(context).outlineVariant,
style: const TextStyle(fontSize: 12),), 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( Positioned(
bottom: 12, bottom: 12,
left: 12, left: 12,
@@ -92,16 +141,22 @@ class _IllustWidgetState extends State<IllustWidget> {
width: 28, width: 28,
height: 20, height: 20,
decoration: BoxDecoration( decoration: BoxDecoration(
color: ColorScheme.of(context).errorContainer.withOpacity(0.8), color: ColorScheme.of(context)
.errorContainer
.toOpacity(0.8),
borderRadius: BorderRadius.circular(4), 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: const Center(
child: Text("AI", child: Text(
style: TextStyle(fontSize: 12),), "AI",
style: TextStyle(fontSize: 12),
),
)), )),
), ),
if(widget.illust.isUgoira) if (widget.illust.isUgoira)
Positioned( Positioned(
bottom: 12, bottom: 12,
left: 12, left: 12,
@@ -109,16 +164,22 @@ class _IllustWidgetState extends State<IllustWidget> {
width: 28, width: 28,
height: 20, height: 20,
decoration: BoxDecoration( decoration: BoxDecoration(
color: ColorScheme.of(context).primaryContainer.withOpacity(0.8), color: ColorScheme.of(context)
.primaryContainer
.toOpacity(0.8),
borderRadius: BorderRadius.circular(4), 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: const Center(
child: Text("GIF", child: Text(
style: TextStyle(fontSize: 12),), "GIF",
style: TextStyle(fontSize: 12),
),
)), )),
), ),
if(widget.illust.isR18) if (widget.illust.isR18)
Positioned( Positioned(
bottom: 12, bottom: 12,
right: 12, right: 12,
@@ -128,14 +189,18 @@ class _IllustWidgetState extends State<IllustWidget> {
decoration: BoxDecoration( decoration: BoxDecoration(
color: ColorScheme.of(context).errorContainer, color: ColorScheme.of(context).errorContainer,
borderRadius: BorderRadius.circular(4), 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: const Center(
child: Text("R18", child: Text(
style: TextStyle(fontSize: 12),), "R18",
style: TextStyle(fontSize: 12),
),
)), )),
), ),
if(widget.illust.isR18G) if (widget.illust.isR18G)
Positioned( Positioned(
bottom: 12, bottom: 12,
right: 12, right: 12,
@@ -145,11 +210,15 @@ class _IllustWidgetState extends State<IllustWidget> {
decoration: BoxDecoration( decoration: BoxDecoration(
color: ColorScheme.of(context).errorContainer, color: ColorScheme.of(context).errorContainer,
borderRadius: BorderRadius.circular(4), 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: const Center(
child: Text("R18G", child: Text(
style: TextStyle(fontSize: 12),), "R18G",
style: TextStyle(fontSize: 12),
),
)), )),
), ),
Positioned( Positioned(
@@ -164,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 // This calculates the position of the flyout according to the parent navigator
final targetContext = contextAttachKey.currentContext; final targetContext = contextAttachKey.currentContext;
if (targetContext == null) return; if (targetContext == null) return;
final box = targetContext.findRenderObject() as RenderBox; final box = targetContext.findRenderObject() as RenderBox;
final position = box.localToGlobal( Offset? position = box.localToGlobal(
details.localPosition, details?.localPosition ?? box.size.center(Offset.zero),
ancestor: Navigator.of(context).context.findRenderObject(), ancestor: Navigator.of(context).context.findRenderObject(),
); );
@@ -180,35 +249,44 @@ class _IllustWidgetState extends State<IllustWidget> {
builder: (context) { builder: (context) {
return MenuFlyout( return MenuFlyout(
items: [ items: [
MenuFlyoutItem(text: Text("View".tl), onPressed: (){ MenuFlyoutItem(
context.to(() => IllustPage(widget.illust, favoriteCallback: (v) { text: Text("View".tl),
setState(() { onPressed: () {
widget.illust.isBookmarked = v; context.to(() => IllustPage(widget.illust));
}); }),
},)); MenuFlyoutItem(
}), text: Text("Private Favorite".tl),
MenuFlyoutItem(text: Text("Private Favorite".tl), onPressed: (){ onPressed: () {
favorite("private"); favorite("private");
}), }),
MenuFlyoutItem(text: Text("Download".tl), onPressed: (){ MenuFlyoutItem(
context.showToast(message: "Added"); text: Text("Download".tl),
DownloadManager().addDownloadingTask(widget.illust); 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{ void favorite([String type = "public"]) async {
if(isBookmarking) return; if (isBookmarking) return;
setState(() { setState(() {
isBookmarking = true; isBookmarking = true;
}); });
var method = widget.illust.isBookmarked ? "delete" : "add"; var method = widget.illust.isBookmarked ? "delete" : "add";
var res = await Network().addBookmark(widget.illust.id.toString(), method, type); var res =
if(res.error) { await Network().addBookmark(widget.illust.id.toString(), method, type);
if(mounted) { if (res.error) {
if (mounted) {
context.showToast(message: "Network Error"); context.showToast(message: "Network Error");
} }
} else { } else {
@@ -221,16 +299,18 @@ class _IllustWidgetState extends State<IllustWidget> {
Widget buildButton() { Widget buildButton() {
Widget child; Widget child;
if(isBookmarking) { if (isBookmarking) {
child = const SizedBox( child = const SizedBox(
width: 14, width: 14,
height: 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( child = Icon(
MdIcons.favorite, MdIcons.favorite,
color: ColorScheme.of(context).error, color: Colors.red,
size: 22, size: 22,
); );
} else { } else {
@@ -256,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),
),
)),
),
],
),
);
});
}
}

View 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,
);
}
}

View File

@@ -108,7 +108,7 @@ abstract class MultiPageLoadingState<T extends StatefulWidget, S extends Object>
Widget? buildFrame(BuildContext context, Widget child) => null; Widget? buildFrame(BuildContext context, Widget child) => null;
Widget buildContent(BuildContext context, final List<S> data); Widget buildContent(BuildContext context, List<S> data);
bool get isLoading => _isLoading || _isFirstLoading; bool get isLoading => _isLoading || _isFirstLoading;
@@ -132,7 +132,9 @@ abstract class MultiPageLoadingState<T extends StatefulWidget, S extends Object>
if(message.length > 20) { if(message.length > 20) {
message = "${message.substring(0, 20)}..."; message = "${message.substring(0, 20)}...";
} }
context.showToast(message: message); if (mounted) {
context.showToast(message: message);
}
} }
}); });
} }

View File

@@ -4,6 +4,7 @@ typedef MdIcons = md.Icons;
typedef MdTheme = md.Theme; typedef MdTheme = md.Theme;
typedef MdThemeData = md.ThemeData; typedef MdThemeData = md.ThemeData;
typedef MdColorScheme = md.ColorScheme; typedef MdColorScheme = md.ColorScheme;
typedef TextField = md.TextField;
class ColorScheme { class ColorScheme {
static md.ColorScheme of(md.BuildContext context) { static md.ColorScheme of(md.BuildContext context) {

View File

@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:fluent_ui/fluent_ui.dart'; import 'package:fluent_ui/fluent_ui.dart';
import 'package:pixes/components/md.dart'; import 'package:pixes/components/md.dart';
import 'package:pixes/foundation/app.dart';
void showToast(BuildContext context, {required String message, IconData? icon}) { void showToast(BuildContext context, {required String message, IconData? icon}) {
var newEntry = OverlayEntry( var newEntry = OverlayEntry(
@@ -30,7 +31,7 @@ class ToastOverlay extends StatelessWidget {
child: Align( child: Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: PhysicalModel( child: PhysicalModel(
color: ColorScheme.of(context).surface.withOpacity(1), color: ColorScheme.of(context).surface.toOpacity(1),
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
elevation: 1, elevation: 1,
child: Container( child: Container(

View File

@@ -328,11 +328,15 @@ class SideBarRoute<T> extends PopupRoute<T> {
bottom: 0, bottom: 0,
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: FluentTheme.of(context).micaBackgroundColor.withOpacity(0.98), color: FluentTheme.of(context)
borderRadius: const BorderRadius.only(topLeft: Radius.circular(4), bottomLeft: Radius.circular(4)) .micaBackgroundColor
), .toOpacity(0.98),
constraints: BoxConstraints(maxWidth: min(_kSideBarWidth, borderRadius: const BorderRadius.only(
MediaQuery.of(context).size.width)), topLeft: Radius.circular(4),
bottomLeft: Radius.circular(4))),
constraints: BoxConstraints(
maxWidth:
min(_kSideBarWidth, MediaQuery.of(context).size.width)),
width: double.infinity, width: double.infinity,
child: child, child: child,
), ),

View File

@@ -40,7 +40,7 @@ class SegmentedButton<T> extends StatelessWidget {
onPressed: () => onPressed(e.key), onPressed: () => onPressed(e.key),
builder: (context, states) { builder: (context, states) {
var textColor = active ? null : ColorScheme.of(context).outline; 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); return ButtonThemeData.buttonColor(context, states);
}).resolve(states); }).resolve(states);

View File

@@ -4,22 +4,43 @@ import 'package:fluent_ui/fluent_ui.dart';
import 'package:pixes/components/animated_image.dart'; import 'package:pixes/components/animated_image.dart';
import 'package:pixes/foundation/app.dart'; import 'package:pixes/foundation/app.dart';
import 'package:pixes/foundation/image_provider.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/pages/user_info_page.dart';
import 'package:pixes/utils/translation.dart'; import 'package:pixes/utils/translation.dart';
import '../network/network.dart'; import '../network/network.dart';
import 'md.dart'; import 'md.dart';
typedef UpdateFollowCallback = void Function(bool isFollowed);
class UserPreviewWidget extends StatefulWidget { class UserPreviewWidget extends StatefulWidget {
const UserPreviewWidget(this.user, {super.key}); const UserPreviewWidget(this.user, {super.key});
final UserPreview user; final UserPreview user;
static Map<String, UpdateFollowCallback> followCallbacks = {};
@override @override
State<UserPreviewWidget> createState() => _UserPreviewWidgetState(); State<UserPreviewWidget> createState() => _UserPreviewWidgetState();
} }
class _UserPreviewWidgetState extends State<UserPreviewWidget> { 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; bool isFollowing = false;
void follow() async { void follow() async {
@@ -39,6 +60,9 @@ class _UserPreviewWidgetState extends State<UserPreviewWidget> {
setState(() { setState(() {
isFollowing = false; isFollowing = false;
}); });
UserInfoPage.followCallbacks[widget.user.id.toString()]
?.call(widget.user.isFollowed);
IllustPage.updateFollow(widget.user.id.toString(), widget.user.isFollowed);
} }
@override @override

View File

@@ -1,6 +1,7 @@
import 'dart:io'; import 'dart:io';
import 'dart:ui'; import 'dart:ui';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:fluent_ui/fluent_ui.dart'; import 'package:fluent_ui/fluent_ui.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
@@ -11,11 +12,13 @@ export "state_controller.dart";
export "navigation.dart"; export "navigation.dart";
class _App { class _App {
final version = "1.0.4"; final version = "1.1.0";
bool get isAndroid => Platform.isAndroid; bool get isAndroid => Platform.isAndroid;
bool get isIOS => Platform.isIOS; bool get isIOS => Platform.isIOS;
bool get isWindows => Platform.isWindows; bool get isWindows => Platform.isWindows;
int? _windowsVersion;
int get windowsVersion => _windowsVersion!;
bool get isLinux => Platform.isLinux; bool get isLinux => Platform.isLinux;
bool get isMacOS => Platform.isMacOS; bool get isMacOS => Platform.isMacOS;
bool get isDesktop => bool get isDesktop =>
@@ -23,8 +26,8 @@ class _App {
bool get isMobile => Platform.isAndroid || Platform.isIOS; bool get isMobile => Platform.isAndroid || Platform.isIOS;
Locale get locale { Locale get locale {
if(appdata.settings["language"] != "System"){ if (appdata.settings["language"] != "System") {
return switch(appdata.settings["language"]){ return switch (appdata.settings["language"]) {
"English" => const Locale("en"), "English" => const Locale("en"),
"简体中文" => const Locale("zh", "CN"), "简体中文" => const Locale("zh", "CN"),
"繁體中文" => const Locale("zh", "TW"), "繁體中文" => const Locale("zh", "TW"),
@@ -32,7 +35,8 @@ class _App {
}; };
} }
Locale deviceLocale = PlatformDispatcher.instance.locale; Locale deviceLocale = PlatformDispatcher.instance.locale;
if (deviceLocale.languageCode == "zh" && deviceLocale.scriptCode == "Hant") { if (deviceLocale.languageCode == "zh" &&
deviceLocale.scriptCode == "Hant") {
deviceLocale = const Locale("zh", "TW"); deviceLocale = const Locale("zh", "TW");
} }
return deviceLocale; return deviceLocale;
@@ -41,9 +45,24 @@ class _App {
late String dataPath; late String dataPath;
late String cachePath; late String cachePath;
init() async{ init() async {
cachePath = (await getApplicationCacheDirectory()).path; cachePath = (await getApplicationCacheDirectory()).path;
dataPath = (await getApplicationSupportDirectory()).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>(); final rootNavigatorKey = GlobalKey<NavigatorState>();

102
lib/foundation/history.dart Normal file
View 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;
}
}

View File

@@ -1,3 +1,5 @@
import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:pixes/utils/ext.dart'; import 'package:pixes/utils/ext.dart';
@@ -26,12 +28,15 @@ class Log {
static bool ignoreLimitation = false; static bool ignoreLimitation = false;
/// only for debug
static const String? logFile = null;
static void printWarning(String text) { static void printWarning(String text) {
print('\x1B[33m$text\x1B[0m'); debugPrint('\x1B[33m$text\x1B[0m');
} }
static void printError(String text) { 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) { static void addLog(LogLevel level, String title, String content) {
@@ -39,15 +44,13 @@ class Log {
content = "${content.substring(0, maxLogLength)}..."; content = "${content.substring(0, maxLogLength)}...";
} }
if (kDebugMode) { switch (level) {
switch (level) { case LogLevel.error:
case LogLevel.error: printError(content);
printError(content); case LogLevel.warning:
case LogLevel.warning: printWarning(content);
printWarning(content); case LogLevel.info:
case LogLevel.info: debugPrint(content);
print(content);
}
} }
var newLog = LogItem(level, title, content); var newLog = LogItem(level, title, content);
@@ -57,6 +60,9 @@ class Log {
} }
_logs.add(newLog); _logs.add(newLog);
if(logFile != null) {
File(logFile!).writeAsString(newLog.toString(), mode: FileMode.append);
}
if (_logs.length > maxLogNumber) { if (_logs.length > maxLogNumber) {
var res = _logs.remove( var res = _logs.remove(
_logs.firstWhereOrNull((element) => element.level == LogLevel.info)); _logs.firstWhereOrNull((element) => element.level == LogLevel.info));

View File

@@ -64,4 +64,10 @@ extension WidgetExtension on Widget{
Widget fixHeight(double height){ Widget fixHeight(double height){
return SizedBox(height: height, child: this); return SizedBox(height: height, child: this);
} }
}
extension ColorExt on Color {
Color toOpacity(double opacity){
return withValues(alpha: opacity);
}
} }

View File

@@ -1,43 +1,69 @@
import "dart:async";
import "dart:ui"; import "dart:ui";
import "package:dynamic_color/dynamic_color.dart"; import "package:dynamic_color/dynamic_color.dart";
import "package:fluent_ui/fluent_ui.dart"; import "package:fluent_ui/fluent_ui.dart";
import "package:flutter/foundation.dart";
import "package:flutter/material.dart" as md; import "package:flutter/material.dart" as md;
import "package:flutter/services.dart"; import "package:flutter/services.dart";
import "package:flutter_acrylic/flutter_acrylic.dart" as flutter_acrylic;
import "package:pixes/appdata.dart"; import "package:pixes/appdata.dart";
import "package:pixes/components/keyboard.dart";
import "package:pixes/components/md.dart"; import "package:pixes/components/md.dart";
import "package:pixes/components/message.dart"; import "package:pixes/components/message.dart";
import "package:pixes/foundation/app.dart"; import "package:pixes/foundation/app.dart";
import "package:pixes/foundation/history.dart";
import "package:pixes/foundation/log.dart"; import "package:pixes/foundation/log.dart";
import "package:pixes/network/app_dio.dart"; import "package:pixes/network/app_dio.dart";
import "package:pixes/pages/main_page.dart"; import "package:pixes/pages/main_page.dart";
import "package:pixes/utils/app_links.dart"; import "package:pixes/utils/app_links.dart";
import "package:pixes/utils/loop.dart";
import "package:pixes/utils/translation.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:window_manager/window_manager.dart";
void main() async { void main() {
WidgetsFlutterBinding.ensureInitialized(); runZonedGuarded(() async {
FlutterError.onError = (details) { Future.delayed(const Duration(seconds: 3), checkUpdate);
Log.error("Unhandled", "${details.exception}\n${details.stack}"); WidgetsFlutterBinding.ensureInitialized();
}; FlutterError.onError = (details) {
setSystemProxy(); Log.error("Unhandled", "${details.exception}\n${details.stack}");
await App.init(); };
await appdata.readData(); setSystemProxy();
await Translation.init(); await App.init();
handleLinks(); await appdata.readData();
if (App.isDesktop) { await Translation.init();
await WindowManager.instance.ensureInitialized(); HistoryManager().init();
windowManager.waitUntilReadyToShow().then((_) async { handleLinks();
await windowManager.setTitleBarStyle( if (App.isDesktop) {
TitleBarStyle.hidden, await flutter_acrylic.Window.initialize();
windowButtonVisibility: false, if (App.isWindows) {
); await flutter_acrylic.Window.hideWindowControls();
await windowManager.setMinimumSize(const Size(500, 600)); }
await windowManager.show(); await WindowManager.instance.ensureInitialized();
await windowManager.setSkipTaskbar(false); windowManager.waitUntilReadyToShow().then((_) async {
}); await windowManager.setTitleBarStyle(
} TitleBarStyle.hidden,
runApp(const MyApp()); 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");
});
} }
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
@@ -78,7 +104,7 @@ class MyApp extends StatelessWidget {
title: 'pixes', title: 'pixes',
theme: FluentThemeData( theme: FluentThemeData(
brightness: brightness, brightness: brightness,
fontFamily: App.isWindows ? 'font' : null, fontFamily: App.isWindows ? "Microsoft YaHei UI" : null,
accentColor: AccentColor.swatch({ accentColor: AccentColor.swatch({
'darkest': darken(colorScheme.primary, 30), 'darkest': darken(colorScheme.primary, 30),
'darker': darken(colorScheme.primary, 20), 'darker': darken(colorScheme.primary, 20),
@@ -87,7 +113,11 @@ class MyApp extends StatelessWidget {
'light': lighten(colorScheme.primary, 10), 'light': lighten(colorScheme.primary, 10),
'lighter': lighten(colorScheme.primary, 20), 'lighter': lighten(colorScheme.primary, 20),
'lightest': lighten(colorScheme.primary, 30) 'lightest': lighten(colorScheme.primary, 30)
})), }),
focusTheme: const FocusThemeData(
primaryBorder: BorderSide.none,
secondaryBorder: BorderSide.none,
)),
home: const MainPage(), home: const MainPage(),
builder: (context, child) { builder: (context, child) {
ErrorWidget.builder = (details) { ErrorWidget.builder = (details) {
@@ -104,16 +134,46 @@ class MyApp extends StatelessWidget {
throw "widget is null"; throw "widget is null";
} }
return MdTheme( Widget widget = MdTheme(
data: MdThemeData.from( data: MdThemeData.from(
colorScheme: colorScheme, useMaterial3: true), colorScheme: colorScheme, useMaterial3: true),
child: DefaultTextStyle.merge( child: DefaultTextStyle.merge(
style: TextStyle( style: TextStyle(
fontFamily: App.isWindows ? 'font' : null, fontFamily: App.isWindows ? "Microsoft YaHei UI" : null,
), ),
child: OverlayWidget(child), 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);
}); });
}, },
), ),
@@ -122,21 +182,28 @@ class MyApp extends StatelessWidget {
} }
} }
/// from https://stackoverflow.com/a/60191441 int _floatToInt8(double x) {
return (x * 255.0).round() & 0xff;
}
Color darken(Color c, [int percent = 10]) { Color darken(Color c, [int percent = 10]) {
assert(1 <= percent && percent <= 100); assert(1 <= percent && percent <= 100);
var f = 1 - percent / 100; var f = 1 - percent / 100;
return Color.fromARGB(c.alpha, (c.red * f).round(), (c.green * f).round(), return Color.fromARGB(
(c.blue * f).round()); _floatToInt8(c.a),
_floatToInt8(c.r * f),
_floatToInt8(c.g * f),
_floatToInt8(c.b * f),
);
} }
/// from https://stackoverflow.com/a/60191441
Color lighten(Color c, [int percent = 10]) { Color lighten(Color c, [int percent = 10]) {
assert(1 <= percent && percent <= 100); assert(1 <= percent && percent <= 100);
var p = percent / 100; var p = percent / 100;
return Color.fromARGB( return Color.fromARGB(
c.alpha, _floatToInt8(c.a),
c.red + ((255 - c.red) * p).round(), _floatToInt8(c.r + (1 - c.r) * p),
c.green + ((255 - c.green) * p).round(), _floatToInt8(c.g + (1 - c.g) * p),
c.blue + ((255 - c.blue) * p).round()); _floatToInt8(c.b + (1 - c.b) * p),
);
} }

View File

@@ -1,3 +1,4 @@
import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
@@ -109,12 +110,53 @@ class AppDio extends DioForNative {
CancelToken? cancelToken, CancelToken? cancelToken,
Options? options, Options? options,
ProgressCallback? onSendProgress, ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress}) { ProgressCallback? onReceiveProgress}) async{
if (!isInitialized) { if (!isInitialized) {
isInitialized = true; isInitialized = true;
interceptors.add(MyLogInterceptor()); 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, data: data,
queryParameters: queryParameters, queryParameters: queryParameters,
cancelToken: cancelToken, cancelToken: cancelToken,

View File

@@ -324,7 +324,7 @@ class DownloadManager {
where illust_id = ?; where illust_id = ?;
''', [illust.illustId]); ''', [illust.illustId]);
for(var image in images) { for(var image in images) {
File(image["path"] as String).deleteIfExists(); File(image["path"] as String).deleteIgnoreError();
} }
_db.execute(''' _db.execute('''
delete from images delete from images
@@ -368,6 +368,26 @@ class DownloadManager {
} }
} }
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() { void resume() {
_paused = false; _paused = false;
} }

View File

@@ -181,6 +181,7 @@ class Illust {
bool isBookmarked; bool isBookmarked;
final bool isAi; final bool isAi;
final bool isUgoira; final bool isUgoira;
final bool isBlocked;
bool get isR18 => tags.contains(const Tag("R-18", null)); bool get isR18 => tags.contains(const Tag("R-18", null));
@@ -227,7 +228,8 @@ class Illust {
totalBookmarks = json['total_bookmarks'], totalBookmarks = json['total_bookmarks'],
isBookmarked = json['is_bookmarked'], isBookmarked = json['is_bookmarked'],
isAi = json['illust_ai_type'] == 2, isAi = json['illust_ai_type'] == 2,
isUgoira = json['type'] == "ugoira"; isUgoira = json['type'] == "ugoira",
isBlocked = json['is_muted'] ?? false;
} }
class TrendingTag { class TrendingTag {
@@ -525,3 +527,25 @@ class Novel {
commentsCount = json["total_comments"], commentsCount = json["total_comments"],
isAi = json["novel_ai_type"] == 2; 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']);
}
}

View File

@@ -191,6 +191,21 @@ class Network {
} }
} }
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, Future<Res<Map<String, dynamic>>> apiPost(String path,
{Map<String, dynamic>? query, Map<String, dynamic>? data}) async { {Map<String, dynamic>? query, Map<String, dynamic>? data}) async {
try { try {
@@ -199,7 +214,7 @@ class Network {
} }
final res = await dio.post<Map<String, dynamic>>(path, final res = await dio.post<Map<String, dynamic>>(path,
queryParameters: query, queryParameters: query,
data: data, data: encodeFormData(data),
options: Options( options: Options(
headers: headers, headers: headers,
validateStatus: (status) => true, validateStatus: (status) => true,
@@ -372,9 +387,9 @@ class Network {
} }
} }
Future<Res<List<Illust>>> getUserIllusts(String uid) async { Future<Res<List<Illust>>> getUserIllusts(String uid, String? type) async {
var res = await apiGet( var res = await apiGet(
"/v1/user/illusts?filter=for_android&user_id=$uid&type=illust"); "/v1/user/illusts?filter=for_android&user_id=$uid${type != null ? "&type=$type" : ""}");
if (res.success) { if (res.success) {
return Res( return Res(
(res.data["illusts"] as List).map((e) => Illust.fromJson(e)).toList(), (res.data["illusts"] as List).map((e) => Illust.fromJson(e)).toList(),
@@ -497,21 +512,24 @@ class Network {
} }
} }
Future<List<Tag>> getMutedTags() async { Future<Res<MuteList>> getMuteList() async {
var res = await apiGet("/v1/mute/list"); var res = await apiGet("/v1/mute/list");
if (res.success) { if (res.success) {
return res.data["mute_tags"] return Res(MuteList.fromJson(res.data));
.map<Tag>((e) => Tag(e["tag"]["name"], e["tag"]["translated_name"]))
.toList();
} else { } else {
return []; return Res.error(res.errorMessage);
} }
} }
Future<Res<bool>> muteTags( Future<Res<bool>> editMute(List<String> addTags, List<String> addUsers,
List<String> muteTags, List<String> unmuteTags) async { List<String> deleteTags, List<String> deleteUsers) async {
var res = await apiPost("/v1/mute/edit", var res = await apiPost("/v1/mute/edit",
data: {"add_tags": muteTags, "delete_tags": unmuteTags}); data: {
"add_tags": addTags,
"add_user_ids": addUsers,
"delete_tags": deleteTags,
"delete_user_ids": deleteUsers
}..removeWhere((key, value) => value.isEmpty));
if (res.success) { if (res.success) {
return const Res(true); return const Res(true);
} else { } else {
@@ -555,4 +573,14 @@ class Network {
return Res.error(res.errorMessage); 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);
}
}
} }

View 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;
}
}

View File

@@ -143,15 +143,15 @@ class _CommentsPageState extends MultiPageLoadingState<CommentsPage, Comment> {
return Card( return Card(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
backgroundColor: backgroundColor:
FluentTheme.of(context).micaBackgroundColor.withOpacity(0.96), FluentTheme.of(context).micaBackgroundColor.toOpacity(0.96),
child: SizedBox( child: SizedBox(
height: 52, height: 52,
child: TextBox( child: TextBox(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
placeholder: "Comment".tl, placeholder: "Comment".tl,
foregroundDecoration: BoxDecoration( foregroundDecoration: WidgetStatePropertyAll(BoxDecoration(
border: Border.all(color: Colors.transparent), border: Border.all(color: Colors.transparent),
), )),
onSubmitted: (s) { onSubmitted: (s) {
showToast(context, message: "Sending".tl); showToast(context, message: "Sending".tl);
if (isCommenting) return; if (isCommenting) return;
@@ -161,10 +161,12 @@ class _CommentsPageState extends MultiPageLoadingState<CommentsPage, Comment> {
if (widget.isNovel) { if (widget.isNovel) {
Network().commentNovel(widget.id, s).then((value) { Network().commentNovel(widget.id, s).then((value) {
if (value.error) { if (value.error) {
context.showToast(message: "Network Error"); if (context.mounted) {
setState(() { context.showToast(message: "Network Error");
isCommenting = false; setState(() {
}); isCommenting = false;
});
}
} else { } else {
isCommenting = false; isCommenting = false;
nextUrl = null; nextUrl = null;
@@ -174,10 +176,12 @@ class _CommentsPageState extends MultiPageLoadingState<CommentsPage, Comment> {
} else { } else {
Network().comment(widget.id, s).then((value) { Network().comment(widget.id, s).then((value) {
if (value.error) { if (value.error) {
context.showToast(message: "Network Error"); if(context.mounted) {
setState(() { context.showToast(message: "Network Error");
isCommenting = false; setState(() {
}); isCommenting = false;
});
}
} else { } else {
isCommenting = false; isCommenting = false;
nextUrl = null; nextUrl = null;

View File

@@ -7,8 +7,6 @@ import 'package:photo_view/photo_view_gallery.dart';
import 'package:pixes/components/animated_image.dart'; import 'package:pixes/components/animated_image.dart';
import 'package:pixes/components/grid.dart'; import 'package:pixes/components/grid.dart';
import 'package:pixes/components/md.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/components/title_bar.dart';
import 'package:pixes/foundation/app.dart'; import 'package:pixes/foundation/app.dart';
import 'package:pixes/network/download.dart'; import 'package:pixes/network/download.dart';
@@ -33,7 +31,8 @@ class _DownloadedPageState extends State<DownloadedPage> {
void loadData() { void loadData() {
illusts = DownloadManager().listAll(); illusts = DownloadManager().listAll();
flyoutControllers = List.generate(illusts.length, (index) => FlyoutController()); flyoutControllers =
List.generate(illusts.length, (index) => FlyoutController());
} }
@override @override
@@ -46,7 +45,18 @@ class _DownloadedPageState extends State<DownloadedPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(
children: [ 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( Expanded(
child: buildBody(), child: buildBody(),
), ),
@@ -56,135 +66,134 @@ class _DownloadedPageState extends State<DownloadedPage> {
Widget buildBody() { Widget buildBody() {
return GridViewWithFixedItemHeight( return GridViewWithFixedItemHeight(
itemCount: illusts.length, itemCount: illusts.length,
itemHeight: 152, itemHeight: 152,
maxCrossAxisExtent: 742, maxCrossAxisExtent: 742,
builder: (context, index) { builder: (context, index) {
var image = DownloadManager().getImage(illusts[index].illustId, 0); var image = DownloadManager().getImage(illusts[index].illustId, 0);
return Card( return Card(
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8), margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
child: Row( child: GestureDetector(
children: [ behavior: HitTestBehavior.opaque,
Container( onTap: () {
width: 96, App.rootNavigatorKey.currentContext?.to(() =>
height: double.infinity, _DownloadedIllustViewPage(DownloadManager()
decoration: BoxDecoration( .getImagePaths(illusts[index].illustId)));
borderRadius: BorderRadius.circular(4), },
color: ColorScheme.of(context).secondaryContainer child: Row(
), children: [
clipBehavior: Clip.antiAlias, Container(
child: image == null ? null : AnimatedImage( width: 96,
image: FileImage(image), height: double.infinity,
fit: BoxFit.cover, decoration: BoxDecoration(
width: 96, borderRadius: BorderRadius.circular(4),
height: double.infinity, color: ColorScheme.of(context).secondaryContainer),
filterQuality: FilterQuality.medium, clipBehavior: Clip.antiAlias,
), child: image == null
), ? null
const SizedBox(width: 16), : AnimatedImage(
Expanded( image: FileImage(image),
child: Column( fit: BoxFit.cover,
crossAxisAlignment: CrossAxisAlignment.start, width: 96,
children: [ height: double.infinity,
Text( filterQuality: FilterQuality.medium,
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),
),
],
),
);
});
},
), ),
),
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);
} }
} }
@@ -194,10 +203,12 @@ class _DownloadedIllustViewPage extends StatefulWidget {
final List<String> imagePaths; final List<String> imagePaths;
@override @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; int windowButtonKey = 0;
@override @override
@@ -234,38 +245,47 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
Future<File?> getFile() async { Future<File?> getFile() async {
var file = File(widget.imagePaths[currentPage]); var file = File(widget.imagePaths[currentPage]);
if(file.existsSync()) { if (file.existsSync()) {
return file; return file;
} }
return null; return null;
} }
void showMenu() { void showMenu() {
menuController.showFlyout(builder: (context) => MenuFlyout( menuController.showFlyout(
items: [ builder: (context) => MenuFlyout(
MenuFlyoutItem(text: Text("Save to".tl), onPressed: () async{ items: [
var file = await getFile(); MenuFlyoutItem(
if(file != null){ text: Text("Save to".tl),
saveFile(file); onPressed: () async {
} var file = await getFile();
}), if (file != null) {
MenuFlyoutItem(text: Text("Share".tl), onPressed: () async{ saveFile(file);
var file = await getFile(); }
if(file != null){ }),
var ext = file.path.split('.').last; MenuFlyoutItem(
var mediaType = switch(ext){ text: Text("Share".tl),
'jpg' => 'image/jpeg', onPressed: () async {
'jpeg' => 'image/jpeg', var file = await getFile();
'png' => 'image/png', if (file != null) {
'gif' => 'image/gif', var ext = file.path.split('.').last;
'webp' => 'image/webp', var mediaType = switch (ext) {
_ => 'application/octet-stream' 'jpg' => 'image/jpeg',
}; 'jpeg' => 'image/jpeg',
Share.shareXFiles([XFile(file.path, mimeType: mediaType, name: file.path.split('/').last)]); '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 @override
@@ -275,12 +295,13 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
color: FluentTheme.of(context).micaBackgroundColor, color: FluentTheme.of(context).micaBackgroundColor,
child: Listener( child: Listener(
onPointerSignal: (event) { onPointerSignal: (event) {
if(event is PointerScrollEvent && if (event is PointerScrollEvent &&
!HardwareKeyboard.instance.isControlPressed) { !HardwareKeyboard.instance.isControlPressed) {
if(event.scrollDelta.dy > 0 if (event.scrollDelta.dy > 0 &&
&& controller.page!.toInt() < widget.imagePaths.length - 1) { controller.page!.toInt() < widget.imagePaths.length - 1) {
controller.jumpToPage(controller.page!.toInt() + 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); controller.jumpToPage(controller.page!.toInt() - 1);
} }
} }
@@ -290,11 +311,11 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
var height = constrains.maxHeight; var height = constrains.maxHeight;
return Stack( return Stack(
children: [ children: [
Positioned.fill(child: PhotoViewGallery.builder( Positioned.fill(
child: PhotoViewGallery.builder(
pageController: controller, pageController: controller,
backgroundDecoration: const BoxDecoration( backgroundDecoration:
color: Colors.transparent const BoxDecoration(color: Colors.transparent),
),
itemCount: widget.imagePaths.length, itemCount: widget.imagePaths.length,
builder: (context, index) { builder: (context, index) {
return PhotoViewGalleryPageOptions( return PhotoViewGalleryPageOptions(
@@ -315,17 +336,22 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
height: 36, height: 36,
child: Row( child: Row(
children: [ children: [
const SizedBox(width: 6,), const SizedBox(
width: 6,
),
IconButton( IconButton(
icon: const Icon(FluentIcons.back).paddingAll(2), icon: const Icon(FluentIcons.back).paddingAll(2),
onPressed: () => context.pop() onPressed: () => context.pop()),
),
const Expanded( const Expanded(
child: DragToMoveArea(child: SizedBox.expand(),), child: DragToMoveArea(
child: SizedBox.expand(),
),
), ),
buildActions(), buildActions(),
if(App.isDesktop) if (App.isDesktop)
WindowButtons(key: ValueKey(windowButtonKey),), WindowButtons(
key: ValueKey(windowButtonKey),
),
], ],
), ),
), ),
@@ -334,7 +360,10 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
left: 0, left: 0,
top: height / 2 - 9, top: height / 2 - 9,
child: IconButton( child: IconButton(
icon: const Icon(FluentIcons.chevron_left, size: 18,), icon: const Icon(
FluentIcons.chevron_left,
size: 18,
),
onPressed: () { onPressed: () {
controller.previousPage( controller.previousPage(
duration: const Duration(milliseconds: 300), duration: const Duration(milliseconds: 300),
@@ -377,26 +406,25 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
controller: menuController, controller: menuController,
child: width > 600 child: width > 600
? Button( ? Button(
onPressed: showMenu, onPressed: showMenu,
child: const Row( child: const Row(
children: [ children: [
Icon( Icon(
MdIcons.menu, MdIcons.menu,
size: 18, size: 18,
), ),
SizedBox( SizedBox(
width: 8, width: 8,
), ),
Text('Actions'), Text('Actions'),
], ],
)) ))
: IconButton( : IconButton(
icon: const Icon( icon: const Icon(
MdIcons.more_horiz, MdIcons.more_horiz,
size: 20, size: 20,
), ),
onPressed: showMenu), onPressed: showMenu),
); );
} }
} }

View File

@@ -2,6 +2,7 @@ import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:pixes/components/title_bar.dart'; import 'package:pixes/components/title_bar.dart';
import 'package:pixes/foundation/app.dart'; import 'package:pixes/foundation/app.dart';
import 'package:pixes/utils/block.dart';
import 'package:pixes/utils/translation.dart'; import 'package:pixes/utils/translation.dart';
import '../components/batch_download.dart'; import '../components/batch_download.dart';
@@ -27,7 +28,10 @@ class _FollowingArtworksPageState extends State<FollowingArtworksPage> {
children: [ children: [
buildTab(), buildTab(),
Expanded( Expanded(
child: _OneFollowingPage(restrict, key: Key(restrict),), child: _OneFollowingPage(
restrict,
key: Key(restrict),
),
) )
], ],
); );
@@ -38,8 +42,11 @@ class _FollowingArtworksPageState extends State<FollowingArtworksPage> {
title: "Following".tl, title: "Following".tl,
action: Row( action: Row(
children: [ children: [
BatchDownloadButton(request: () => Network().getFollowingArtworks(restrict)), BatchDownloadButton(
const SizedBox(width: 8,), request: () => Network().getFollowingArtworks(restrict)),
const SizedBox(
width: 8,
),
SegmentedButton( SegmentedButton(
options: [ options: [
SegmentedButtonOption("all", "All".tl), SegmentedButtonOption("all", "All".tl),
@@ -47,7 +54,7 @@ class _FollowingArtworksPageState extends State<FollowingArtworksPage> {
SegmentedButtonOption("private", "Private".tl), SegmentedButtonOption("private", "Private".tl),
], ],
onPressed: (key) { onPressed: (key) {
if(key != restrict) { if (key != restrict) {
setState(() { setState(() {
restrict = key; restrict = key;
}); });
@@ -70,27 +77,26 @@ class _OneFollowingPage extends StatefulWidget {
State<_OneFollowingPage> createState() => _OneFollowingPageState(); State<_OneFollowingPage> createState() => _OneFollowingPageState();
} }
class _OneFollowingPageState extends MultiPageLoadingState<_OneFollowingPage, Illust> { class _OneFollowingPageState
extends MultiPageLoadingState<_OneFollowingPage, Illust> {
@override @override
Widget buildContent(BuildContext context, final List<Illust> data) { Widget buildContent(BuildContext context, List<Illust> data) {
return LayoutBuilder(builder: (context, constrains){ checkIllusts(data);
return LayoutBuilder(builder: (context, constrains) {
return MasonryGridView.builder( return MasonryGridView.builder(
padding: const EdgeInsets.symmetric(horizontal: 8) padding: const EdgeInsets.symmetric(horizontal: 8) +
+ EdgeInsets.only(bottom: context.padding.bottom), EdgeInsets.only(bottom: context.padding.bottom),
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent( gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 240, maxCrossAxisExtent: 240,
), ),
itemCount: data.length, itemCount: data.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
if(index == data.length - 1){ if (index == data.length - 1) {
nextPage(); nextPage();
} }
return IllustWidget(data[index], onTap: () { return IllustWidget(data[index], onTap: () {
context.to(() => IllustGalleryPage( context.to(() => IllustGalleryPage(
illusts: data, illusts: data, initialPage: index, nextUrl: nextUrl));
initialPage: index,
nextUrl: nextUrl
));
}); });
}, },
); );
@@ -100,16 +106,15 @@ class _OneFollowingPageState extends MultiPageLoadingState<_OneFollowingPage, Il
String? nextUrl; String? nextUrl;
@override @override
Future<Res<List<Illust>>> loadData(page) async{ Future<Res<List<Illust>>> loadData(page) async {
if(nextUrl == "end") { if (nextUrl == "end") {
return Res.error("No more data"); return Res.error("No more data");
} }
var res = await Network().getFollowingArtworks(widget.restrict, nextUrl); var res = await Network().getFollowingArtworks(widget.restrict, nextUrl);
if(!res.error) { if (!res.error) {
nextUrl = res.subData; nextUrl = res.subData;
nextUrl ??= "end"; nextUrl ??= "end";
} }
return res; return res;
} }
} }

View File

@@ -2,8 +2,10 @@ import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:pixes/appdata.dart'; import 'package:pixes/appdata.dart';
import 'package:pixes/components/loading.dart'; import 'package:pixes/components/loading.dart';
import 'package:pixes/components/segmented_button.dart';
import 'package:pixes/components/title_bar.dart'; import 'package:pixes/components/title_bar.dart';
import 'package:pixes/foundation/app.dart'; import 'package:pixes/foundation/app.dart';
import 'package:pixes/foundation/history.dart';
import 'package:pixes/network/network.dart'; import 'package:pixes/network/network.dart';
import 'package:pixes/utils/translation.dart'; import 'package:pixes/utils/translation.dart';
@@ -17,42 +19,109 @@ class HistoryPage extends StatefulWidget {
State<HistoryPage> createState() => _HistoryPageState(); State<HistoryPage> createState() => _HistoryPageState();
} }
class _HistoryPageState extends MultiPageLoadingState<HistoryPage, Illust> { class _HistoryPageState extends State<HistoryPage> {
int page = 0;
@override @override
Widget buildContent(BuildContext context, final List<Illust> data) { Widget build(BuildContext context) {
return Column( return Column(
children: [ 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( Expanded(
child: LayoutBuilder(builder: (context, constrains){ child: page == 0
return MasonryGridView.builder( ? const LocalHistoryPage()
padding: const EdgeInsets.symmetric(horizontal: 8) : const NetworkHistoryPage(),
+ 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,
));
});
},
);
}),
)
], ],
); );
} }
}
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 @override
Future<Res<List<Illust>>> loadData(page) { 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 Future.value(Res.error("Premium Required".tl));
} }
return Network().getHistory(page); return Network().getHistory(page);

View File

@@ -4,19 +4,25 @@ import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart' show Icons; import 'package:flutter/material.dart' show Icons;
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:pixes/appdata.dart';
import 'package:pixes/components/animated_image.dart'; import 'package:pixes/components/animated_image.dart';
import 'package:pixes/components/keyboard.dart';
import 'package:pixes/components/loading.dart'; import 'package:pixes/components/loading.dart';
import 'package:pixes/components/message.dart'; import 'package:pixes/components/message.dart';
import 'package:pixes/components/page_route.dart';
import 'package:pixes/components/title_bar.dart'; import 'package:pixes/components/title_bar.dart';
import 'package:pixes/components/user_preview.dart';
import 'package:pixes/foundation/app.dart'; import 'package:pixes/foundation/app.dart';
import 'package:pixes/foundation/history.dart';
import 'package:pixes/foundation/image_provider.dart'; import 'package:pixes/foundation/image_provider.dart';
import 'package:pixes/network/download.dart'; import 'package:pixes/network/download.dart';
import 'package:pixes/network/network.dart'; import 'package:pixes/network/network.dart';
import 'package:pixes/pages/comments_page.dart'; import 'package:pixes/pages/comments_page.dart';
import 'package:pixes/pages/image_page.dart'; import 'package:pixes/pages/image_page.dart';
import 'package:pixes/pages/related_page.dart';
import 'package:pixes/pages/search_page.dart'; import 'package:pixes/pages/search_page.dart';
import 'package:pixes/pages/user_info_page.dart'; import 'package:pixes/pages/user_info_page.dart';
import 'package:pixes/utils/block.dart';
import 'package:pixes/utils/translation.dart'; import 'package:pixes/utils/translation.dart';
import 'package:share_plus/share_plus.dart'; import 'package:share_plus/share_plus.dart';
@@ -39,6 +45,8 @@ class IllustGalleryPage extends StatefulWidget {
final String? nextUrl; final String? nextUrl;
static var cachedHistoryIds = <int>{};
@override @override
State<IllustGalleryPage> createState() => _IllustGalleryPageState(); State<IllustGalleryPage> createState() => _IllustGalleryPageState();
} }
@@ -52,6 +60,8 @@ class _IllustGalleryPageState extends State<IllustGalleryPage> {
bool loading = false; bool loading = false;
late int page = widget.initialPage;
@override @override
void initState() { void initState() {
illusts = List.from(widget.illusts); illusts = List.from(widget.illusts);
@@ -63,6 +73,16 @@ class _IllustGalleryPageState extends State<IllustGalleryPage> {
super.initState(); super.initState();
} }
@override
void dispose() {
if (IllustGalleryPage.cachedHistoryIds.length > 5) {
Network().sendHistory(
IllustGalleryPage.cachedHistoryIds.toList().reversed.toList());
IllustGalleryPage.cachedHistoryIds.clear();
}
super.dispose();
}
void nextPage() { void nextPage() {
var length = illusts.length; var length = illusts.length;
if (controller.page == length - 1) return; if (controller.page == length - 1) return;
@@ -83,16 +103,51 @@ class _IllustGalleryPageState extends State<IllustGalleryPage> {
length++; length++;
} }
return PageView.builder( return Stack(
controller: controller, children: [
itemCount: length, Positioned.fill(
itemBuilder: (context, index) { child: PageView.builder(
if (index == illusts.length) { controller: controller,
return buildLast(); itemCount: length,
} itemBuilder: (context, index) {
return IllustPage(illusts[index], if (index == illusts.length) {
nextPage: nextPage, previousPage: previousPage); return buildLast();
}, }
return IllustPage(illusts[index],
nextPage: nextPage, previousPage: previousPage);
},
onPageChanged: (value) => setState(() {
page = value;
}),
),
),
if (page < length - 1 && length > 1 && App.isDesktop)
Positioned(
right: 0,
top: 0,
bottom: 32,
child: Center(
child: IconButton(
icon: const Icon(FluentIcons.chevron_right),
onPressed: () {
nextPage();
},
)),
),
if (page != 0 && length > 1 && App.isDesktop)
Positioned(
left: 0,
top: 0,
bottom: 32,
child: Center(
child: IconButton(
icon: const Icon(FluentIcons.chevron_left),
onPressed: () {
previousPage();
},
)),
),
],
); );
} }
@@ -125,25 +180,63 @@ class _IllustGalleryPageState extends State<IllustGalleryPage> {
} }
class IllustPage extends StatefulWidget { class IllustPage extends StatefulWidget {
const IllustPage(this.illust, const IllustPage(this.illust, {this.nextPage, this.previousPage, super.key});
{this.favoriteCallback, this.nextPage, this.previousPage, super.key});
final Illust illust; final Illust illust;
final void Function(bool)? favoriteCallback;
final void Function()? nextPage; final void Function()? nextPage;
final void Function()? previousPage; final void Function()? previousPage;
static Map<String, UpdateFollowCallback> followCallbacks = {};
static void updateFollow(String uid, bool isFollowed) {
followCallbacks.forEach((key, value) {
if (key.startsWith("$uid#")) {
value(isFollowed);
}
});
}
@override @override
State<IllustPage> createState() => _IllustPageState(); State<IllustPage> createState() => _IllustPageState();
} }
class _IllustPageState extends State<IllustPage> { class _IllustPageState extends State<IllustPage> {
String get id => "${widget.illust.author.id}#${widget.illust.id}";
final _bottomBarController = _BottomBarController();
KeyEventListenerState? keyboardListener;
@override
void initState() {
keyboardListener = KeyEventListener.of(context);
keyboardListener?.removeAll();
keyboardListener?.addHandler(handleKey);
IllustPage.followCallbacks[id] = (v) {
setState(() {
widget.illust.author.isFollowed = v;
});
};
HistoryManager().addHistory(widget.illust);
if (appdata.account!.user.isPremium) {
IllustGalleryPage.cachedHistoryIds.add(widget.illust.id);
}
super.initState();
}
@override
void dispose() {
keyboardListener?.removeHandler(handleKey);
IllustPage.followCallbacks.remove(id);
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return buildKeyboardListener(ColoredBox( var isBlocked = checkIllusts([widget.illust]).isEmpty;
return ColoredBox(
color: FluentTheme.of(context).micaBackgroundColor, color: FluentTheme.of(context).micaBackgroundColor,
child: SizedBox.expand( child: SizedBox.expand(
child: ColoredBox( child: ColoredBox(
@@ -151,54 +244,90 @@ class _IllustPageState extends State<IllustPage> {
child: LayoutBuilder(builder: (context, constrains) { child: LayoutBuilder(builder: (context, constrains) {
return Stack( return Stack(
children: [ children: [
Positioned( if (!isBlocked)
bottom: 0, Positioned(
left: 0, bottom: 0,
right: 0, left: 0,
top: 0, right: 0,
child: buildBody(constrains.maxWidth, constrains.maxHeight), top: 0,
), child: buildBody(constrains.maxWidth, constrains.maxHeight),
_BottomBar( ),
widget.illust, if (!isBlocked)
constrains.maxHeight, _BottomBar(
constrains.maxWidth, widget.illust,
favoriteCallback: widget.favoriteCallback, constrains.maxHeight,
), constrains.maxWidth,
updateCallback: () => setState(() {}),
controller: _bottomBarController,
),
if (isBlocked)
const Positioned.fill(
child: Center(
child: Center(
child: Text(
"This artwork is blocked",
)),
))
], ],
); );
}), }),
), ),
), ),
)); );
} }
final scrollController = ScrollController(); final scrollController = ScrollController();
Widget buildKeyboardListener(Widget child) { void handleKey(LogicalKeyboardKey key) {
return KeyboardListener( const kShortcutScrollOffset = 200;
focusNode: FocusNode(),
autofocus: true, var shortcuts = appdata.settings["shortcuts"] as List;
onKeyEvent: (event) {
if (event is! KeyUpEvent) return; switch (shortcuts.indexOf(key.keyId)) {
const kShortcutScrollOffset = 200; case 0:
if (event.logicalKey == LogicalKeyboardKey.arrowDown) { if (scrollController.position.pixels >=
scrollController.position.maxScrollExtent) {
_bottomBarController.openOrClose();
} else {
scrollController.animateTo( scrollController.animateTo(
scrollController.offset + kShortcutScrollOffset, scrollController.offset + kShortcutScrollOffset,
duration: const Duration(milliseconds: 200), duration: const Duration(milliseconds: 200),
curve: Curves.easeOut); curve: Curves.easeOut,
} else if (event.logicalKey == LogicalKeyboardKey.arrowUp) { );
scrollController.animateTo(
scrollController.offset - kShortcutScrollOffset,
duration: const Duration(milliseconds: 200),
curve: Curves.easeOut);
} else if (event.logicalKey == LogicalKeyboardKey.arrowRight) {
widget.nextPage?.call();
} else if (event.logicalKey == LogicalKeyboardKey.arrowLeft) {
widget.previousPage?.call();
} }
}, break;
child: child, case 1:
); if (_bottomBarController.isOpen()) {
_bottomBarController.openOrClose();
break;
}
scrollController.animateTo(
scrollController.offset - kShortcutScrollOffset,
duration: const Duration(milliseconds: 200),
curve: Curves.easeOut,
);
break;
case 2:
widget.nextPage?.call();
break;
case 3:
widget.previousPage?.call();
break;
case 4:
_bottomBarController.favorite();
case 5:
_bottomBarController.download();
case 6:
_bottomBarController.follow();
case 7:
if (ModalRoute.of(context)?.isCurrent ?? true) {
CommentsPage.show(context, widget.illust.id.toString());
} else {
context.pop();
}
case 8:
openImage(0);
}
} }
Widget buildBody(double width, double height) { Widget buildBody(double width, double height) {
@@ -251,6 +380,10 @@ class _IllustPageState extends State<IllustPage> {
} }
Widget image; Widget image;
var imageUrl = appdata.settings["showOriginalImage"]
? widget.illust.images[index].original
: widget.illust.images[index].large;
if (!widget.illust.isUgoira) { if (!widget.illust.isUgoira) {
image = SizedBox( image = SizedBox(
width: imageWidth, width: imageWidth,
@@ -260,8 +393,7 @@ class _IllustPageState extends State<IllustPage> {
child: Image( child: Image(
key: ValueKey(index), key: ValueKey(index),
image: downloadFile == null image: downloadFile == null
? CachedImageProvider(widget.illust.images[index].large) ? CachedImageProvider(imageUrl) as ImageProvider
as ImageProvider
: FileImage(downloadFile) as ImageProvider, : FileImage(downloadFile) as ImageProvider,
width: imageWidth, width: imageWidth,
fit: BoxFit.cover, fit: BoxFit.cover,
@@ -304,11 +436,33 @@ class _IllustPageState extends State<IllustPage> {
} }
} }
class _BottomBarController {
VoidCallback? _openOrClose;
VoidCallback get openOrClose => _openOrClose!;
bool Function()? _isOpen;
bool isOpen() => _isOpen!();
VoidCallback? _favorite;
VoidCallback get favorite => _favorite!;
VoidCallback? _download;
VoidCallback get download => _download!;
VoidCallback? _follow;
VoidCallback get follow => _follow!;
}
class _BottomBar extends StatefulWidget { class _BottomBar extends StatefulWidget {
const _BottomBar(this.illust, this.height, this.width, const _BottomBar(this.illust, this.height, this.width,
{this.favoriteCallback}); {this.updateCallback, this.controller});
final void Function(bool)? favoriteCallback; final void Function()? updateCallback;
final Illust illust; final Illust illust;
@@ -316,6 +470,8 @@ class _BottomBar extends StatefulWidget {
final double width; final double width;
final _BottomBarController? controller;
@override @override
State<_BottomBar> createState() => _BottomBarState(); State<_BottomBar> createState() => _BottomBarState();
} }
@@ -352,9 +508,32 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
..onCancel = _handlePointerCancel; ..onCancel = _handlePointerCancel;
animationController = AnimationController( animationController = AnimationController(
vsync: this, duration: const Duration(milliseconds: 180), value: 1); vsync: this, duration: const Duration(milliseconds: 180), value: 1);
if (widget.controller != null) {
widget.controller!._openOrClose = () {
if (animationController.value == 0) {
animationController.animateTo(1);
} else if (animationController.value == 1) {
animationController.animateTo(0);
}
};
widget.controller!._isOpen = () => animationController.value == 0;
widget.controller!._favorite = favorite;
widget.controller!._download = () {
DownloadManager().addDownloadingTask(widget.illust);
setState(() {});
};
widget.controller!._follow = follow;
}
super.initState(); super.initState();
} }
@override
void dispose() {
animationController.dispose();
_recognizer.dispose();
super.dispose();
}
void _handlePointerDown(DragStartDetails details) {} void _handlePointerDown(DragStartDetails details) {}
void _handlePointerMove(DragUpdateDetails details) { void _handlePointerMove(DragUpdateDetails details) {
var offset = details.primaryDelta ?? 0; var offset = details.primaryDelta ?? 0;
@@ -378,8 +557,9 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
} }
void _handlePointerCancel() { void _handlePointerCancel() {
if (animationController.value == 1 || animationController.value == 0) if (animationController.value == 1 || animationController.value == 0) {
return; return;
}
if (animationController.value >= 0.5) { if (animationController.value >= 0.5) {
animationController.forward(); animationController.forward();
} else { } else {
@@ -440,7 +620,7 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
borderRadius: borderRadius:
const BorderRadius.vertical(top: Radius.circular(8)), const BorderRadius.vertical(top: Radius.circular(8)),
backgroundColor: backgroundColor:
FluentTheme.of(context).micaBackgroundColor.withOpacity(0.96), FluentTheme.of(context).micaBackgroundColor.toOpacity(0.96),
padding: const EdgeInsets.symmetric(horizontal: 8), padding: const EdgeInsets.symmetric(horizontal: 8),
child: SizedBox( child: SizedBox(
width: double.infinity, width: double.infinity,
@@ -501,27 +681,31 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
bool isFollowing = false; bool isFollowing = false;
Widget buildAuthor() { void follow() async {
void follow() async { if (isFollowing) return;
if (isFollowing) return; setState(() {
setState(() { isFollowing = true;
isFollowing = true; });
}); var method = widget.illust.author.isFollowed ? "delete" : "add";
var method = widget.illust.author.isFollowed ? "delete" : "add"; var res =
var res = await Network().follow(widget.illust.author.id.toString(), method);
await Network().follow(widget.illust.author.id.toString(), method); if (res.error) {
if (res.error) { if (mounted) {
if (mounted) { context.showToast(message: "Network Error");
context.showToast(message: "Network Error");
}
} else {
widget.illust.author.isFollowed = !widget.illust.author.isFollowed;
} }
setState(() { } else {
isFollowing = false; widget.illust.author.isFollowed = !widget.illust.author.isFollowed;
});
} }
setState(() {
isFollowing = false;
});
UserInfoPage.followCallbacks[widget.illust.author.id.toString()]
?.call(widget.illust.author.isFollowed);
UserPreviewWidget.followCallbacks[widget.illust.author.id.toString()]
?.call(widget.illust.author.isFollowed);
}
Widget buildAuthor() {
final bool showUserName = MediaQuery.of(context).size.width > 640; final bool showUserName = MediaQuery.of(context).size.width > 640;
return Card( return Card(
@@ -543,9 +727,6 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
child: GestureDetector( child: GestureDetector(
onTap: () => context.to(() => UserInfoPage( onTap: () => context.to(() => UserInfoPage(
widget.illust.author.id.toString(), widget.illust.author.id.toString(),
followCallback: (b) => setState(() {
widget.illust.author.isFollowed = b;
}),
)), )),
child: AnimatedImage( child: AnimatedImage(
image: CachedImageProvider(widget.illust.author.avatar), image: CachedImageProvider(widget.illust.author.avatar),
@@ -615,7 +796,8 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
} }
} else { } else {
widget.illust.isBookmarked = !widget.illust.isBookmarked; widget.illust.isBookmarked = !widget.illust.isBookmarked;
widget.favoriteCallback?.call(widget.illust.isBookmarked); IllustWidget.favoriteCallbacks[widget.illust.id.toString()]
?.call(widget.illust.isBookmarked);
} }
setState(() { setState(() {
isBookmarking = false; isBookmarking = false;
@@ -876,7 +1058,9 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
} }
Widget buildMoreActions() { Widget buildMoreActions() {
return Row( return Wrap(
runSpacing: 8,
spacing: 8,
children: [ children: [
Button( Button(
onPressed: () => favorite("private"), onPressed: () => favorite("private"),
@@ -913,10 +1097,7 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
], ],
), ),
), ),
), ).fixWidth(96),
const SizedBox(
width: 6,
),
Button( Button(
onPressed: () { onPressed: () {
Share.share( Share.share(
@@ -937,10 +1118,7 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
], ],
), ),
), ),
), ).fixWidth(96),
const SizedBox(
width: 6,
),
Button( Button(
onPressed: () { onPressed: () {
var text = "https://pixiv.net/artworks/${widget.illust.id}"; var text = "https://pixiv.net/artworks/${widget.illust.id}";
@@ -959,13 +1137,10 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
], ],
), ),
), ),
), ).fixWidth(96),
const SizedBox(
width: 6,
),
Button( Button(
onPressed: () { onPressed: () {
context.to(() => _RelatedIllustsPage(widget.illust.id.toString())); context.to(() => RelatedIllustsPage(widget.illust.id.toString()));
}, },
child: SizedBox( child: SizedBox(
height: 28, height: 28,
@@ -979,12 +1154,189 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
], ],
), ),
), ),
), ).fixWidth(96),
Button(
onPressed: () async {
await Navigator.of(context)
.push(SideBarRoute(_BlockingPage(widget.illust)));
if (mounted) {
widget.updateCallback?.call();
}
},
child: SizedBox(
height: 28,
child: Row(
children: [
const Icon(MdIcons.block, size: 18),
const SizedBox(
width: 8,
),
Text("Block".tl)
],
),
),
).fixWidth(96),
], ],
).paddingHorizontal(2).paddingBottom(4); ).paddingHorizontal(2).paddingBottom(4);
} }
} }
class _BlockingPage extends StatefulWidget {
const _BlockingPage(this.illust);
final Illust illust;
@override
State<_BlockingPage> createState() => __BlockingPageState();
}
class __BlockingPageState extends State<_BlockingPage> {
List<int> blockedTags = [];
@override
Widget build(BuildContext context) {
return Column(
children: [
TitleBar(title: "Block".tl),
Expanded(
child: ListView.builder(
padding: EdgeInsets.only(bottom: context.padding.bottom),
itemCount: widget.illust.tags.length + 2,
itemBuilder: (context, index) {
if (index == widget.illust.tags.length + 1) {
return buildSubmit();
}
var text = index == 0
? widget.illust.author.name
: widget.illust.tags[index - 1].name;
var subTitle = index == 0
? "author"
: widget.illust.tags[index - 1].translatedName ?? "";
return Card(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
borderColor: blockedTags.contains(index)
? ColorScheme.of(context).outlineVariant
: ColorScheme.of(context).outlineVariant.toOpacity(0.2),
padding: EdgeInsets.zero,
child: ListTile(
title: Text(text),
subtitle: Text(subTitle),
trailing: Button(
onPressed: () {
if (blockedTags.contains(index)) {
blockedTags.remove(index);
} else {
blockedTags.add(index);
}
setState(() {});
},
child: blockedTags.contains(index)
? Text("Cancel".tl)
: Text("Block".tl))
.fixWidth(72),
),
);
},
),
)
],
);
}
var flyout = FlyoutController();
bool isSubmitting = false;
Widget buildSubmit() {
return FlyoutTarget(
controller: flyout,
child: FilledButton(
onPressed: () async {
if (this.blockedTags.isEmpty) {
return;
}
if (isSubmitting) return;
var blockedTags = <String>[];
var blockedUsers = <String>[];
for (var i in this.blockedTags) {
if (i == 0) {
blockedUsers.add(widget.illust.author.id.toString());
} else {
blockedTags.add(widget.illust.tags[i - 1].name);
}
}
bool addToAccount = false;
bool addToLocal = false;
if (appdata.account!.user.isPremium) {
await flyout.showFlyout(
navigatorKey: App.rootNavigatorKey.currentState,
builder: (context) {
return MenuFlyout(
items: [
MenuFlyoutItem(
text: Text("Local".tl),
onPressed: () {
addToLocal = true;
}),
MenuFlyoutItem(
text: Text("Account".tl),
onPressed: () {
addToAccount = true;
}),
MenuFlyoutItem(
text: Text("Both".tl),
onPressed: () {
addToLocal = true;
addToAccount = true;
}),
],
);
});
} else {
addToLocal = true;
}
if (addToAccount) {
setState(() {
isSubmitting = true;
});
var res =
await Network().editMute(blockedTags, blockedUsers, [], []);
setState(() {
isSubmitting = false;
});
if (res.error) {
if (mounted) {
context.showToast(message: "Network Error");
}
return;
}
}
if (addToLocal) {
for (var tag in blockedTags) {
appdata.settings['blockTags'].add(tag);
}
for (var user in blockedUsers) {
appdata.settings['blockTags'].add('user:$user');
}
appdata.writeSettings();
}
if (mounted) {
context.pop();
}
},
child: isSubmitting
? const ProgressRing(
strokeWidth: 1.6,
).fixWidth(18).fixHeight(18).toAlign(Alignment.center)
: Text("Submit".tl),
).fixWidth(96).fixHeight(32),
).toAlign(Alignment.center).paddingTop(16);
}
}
class IllustPageWithId extends StatefulWidget { class IllustPageWithId extends StatefulWidget {
const IllustPageWithId(this.id, {super.key}); const IllustPageWithId(this.id, {super.key});
@@ -1005,64 +1357,3 @@ class _IllustPageWithIdState extends LoadingState<IllustPageWithId, Illust> {
return Network().getIllustByID(widget.id); return Network().getIllustByID(widget.id);
} }
} }
class _RelatedIllustsPage extends StatefulWidget {
const _RelatedIllustsPage(this.id);
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;
}
}

View File

@@ -3,8 +3,10 @@ import 'dart:io';
import 'package:fluent_ui/fluent_ui.dart'; import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:photo_view/photo_view_gallery.dart'; import 'package:photo_view/photo_view_gallery.dart';
import 'package:pixes/components/md.dart'; import 'package:pixes/components/md.dart';
import 'package:pixes/components/message.dart';
import 'package:pixes/components/page_route.dart'; import 'package:pixes/components/page_route.dart';
import 'package:pixes/foundation/app.dart'; import 'package:pixes/foundation/app.dart';
import 'package:pixes/foundation/cache_manager.dart'; import 'package:pixes/foundation/cache_manager.dart';
@@ -89,6 +91,8 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
void showMenu() { void showMenu() {
menuController.showFlyout( menuController.showFlyout(
barrierColor: Colors.transparent,
position: App.isMobile ? Offset(context.size!.width, 0) : null,
builder: (context) => MenuFlyout( builder: (context) => MenuFlyout(
items: [ items: [
MenuFlyoutItem( MenuFlyoutItem(
@@ -96,20 +100,40 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
onPressed: () async { onPressed: () async {
var file = await getFile(); var file = await getFile();
if (file != null) { if (file != null) {
var fileName = file.path.split('/').last; var fileName = widget.urls[currentPage].split('/').last;
if (!fileName.contains('.')) { if (!fileName.contains('.')) {
fileName += getExtensionName(); fileName += getExtensionName();
} }
saveFile(file, fileName); 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 ImageGallerySaver.saveImage(
await file.readAsBytes(),
quality: 100,
name: fileName);
if (context.mounted) {
showToast(context, message: "Saved".tl);
}
}
}),
MenuFlyoutItem( MenuFlyoutItem(
text: Text("Share".tl), text: Text("Share".tl),
onPressed: () async { onPressed: () async {
var file = await getFile(); var file = await getFile();
if (file != null) { if (file != null) {
var ext = getExtensionName(); var ext = getExtensionName();
var fileName = file.path.split('/').last; var fileName = widget.urls[currentPage].split('/').last;
if (!fileName.contains('.')) { if (!fileName.contains('.')) {
fileName += ext; fileName += ext;
} }
@@ -164,6 +188,7 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
var image = widget.urls[index]; var image = widget.urls[index];
return PhotoViewGalleryPageOptions( return PhotoViewGalleryPageOptions(
filterQuality: FilterQuality.medium,
imageProvider: getImageProvider(image), imageProvider: getImageProvider(image),
); );
}, },
@@ -201,35 +226,37 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
), ),
), ),
), ),
Positioned( if (currentPage != 0)
left: 0, Positioned(
top: height / 2 - 9, left: 0,
child: IconButton( top: height / 2 - 9,
icon: const Icon( child: IconButton(
FluentIcons.chevron_left, icon: const Icon(
size: 18, FluentIcons.chevron_left,
), size: 18,
onPressed: () { ),
controller.previousPage( onPressed: () {
duration: const Duration(milliseconds: 300), controller.previousPage(
curve: Curves.easeInOut, duration: const Duration(milliseconds: 300),
); curve: Curves.easeInOut,
}, );
).paddingAll(8), },
), ).paddingAll(8),
Positioned( ),
right: 0, if (currentPage != widget.urls.length - 1)
top: height / 2 - 9, Positioned(
child: IconButton( right: 0,
icon: const Icon(FluentIcons.chevron_right, size: 18), top: height / 2 - 9,
onPressed: () { child: IconButton(
controller.nextPage( icon: const Icon(FluentIcons.chevron_right, size: 18),
duration: const Duration(milliseconds: 300), onPressed: () {
curve: Curves.easeInOut, controller.nextPage(
); duration: const Duration(milliseconds: 300),
}, curve: Curves.easeInOut,
).paddingAll(8), );
), },
).paddingAll(8),
),
Positioned( Positioned(
left: 12, left: 12,
bottom: 8, bottom: 8,
@@ -252,16 +279,16 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
child: width > 600 child: width > 600
? Button( ? Button(
onPressed: showMenu, onPressed: showMenu,
child: const Row( child: Row(
children: [ children: [
Icon( const Icon(
MdIcons.menu, MdIcons.menu,
size: 18, size: 18,
), ),
SizedBox( const SizedBox(
width: 8, width: 8,
), ),
Text('Actions'), Text('Actions'.tl),
], ],
)) ))
: IconButton( : IconButton(

View File

@@ -1,4 +1,5 @@
import 'package:fluent_ui/fluent_ui.dart'; import 'package:fluent_ui/fluent_ui.dart';
import 'package:pixes/components/button.dart';
import 'package:pixes/foundation/app.dart'; import 'package:pixes/foundation/app.dart';
import 'package:pixes/network/network.dart'; import 'package:pixes/network/network.dart';
import 'package:pixes/pages/webview_page.dart'; import 'package:pixes/pages/webview_page.dart';
@@ -24,7 +25,7 @@ class _LoginPageState extends State<LoginPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if(isLogging) { if (isLogging) {
return buildLoading(context); return buildLoading(context);
} else if (!waitingForAuth) { } else if (!waitingForAuth) {
return buildLogin(context); return buildLogin(context);
@@ -56,23 +57,12 @@ class _LoginPageState extends State<LoginPage> {
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
if (checked) FluentButton(
FilledButton( onPressed: onContinue,
onPressed: onContinue, enabled: checked,
child: Text("Continue".tl), width: 96,
) 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),
),
),
const SizedBox( const SizedBox(
height: 16, height: 16,
), ),
@@ -97,7 +87,9 @@ class _LoginPageState extends State<LoginPage> {
const SizedBox( const SizedBox(
width: 8, 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 { 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(); var url = await Network().generateWebviewUrl();
onLink = (uri) { onLink = (uri) {
if (uri.scheme == "pixiv") { if (uri.scheme == "pixiv") {
@@ -198,15 +223,18 @@ class _LoginPageState extends State<LoginPage> {
setState(() { setState(() {
waitingForAuth = true; waitingForAuth = true;
}); });
if(App.isMobile && mounted) { if (!useExternal! && mounted) {
context.to(() => WebviewPage(url, onNavigation: (req) { context.to(() => WebviewPage(
if(req.url.startsWith("pixiv://")) { url,
App.rootNavigatorKey.currentState!.pop(); onNavigation: (req) {
onLink?.call(Uri.parse(req.url)); if (req.url.startsWith("pixiv://")) {
return false; App.rootNavigatorKey.currentState!.pop();
} onLink?.call(Uri.parse(req.url));
return true; return false;
},)); }
return true;
},
));
} else { } else {
launchUrlString(url); launchUrlString(url);
} }
@@ -219,7 +247,7 @@ class _LoginPageState extends State<LoginPage> {
}); });
var res = await Network().loginWithCode(code); var res = await Network().loginWithCode(code);
if (res.error) { if (res.error) {
if(mounted) { if (mounted) {
context.showToast(message: res.errorMessage!); context.showToast(message: res.errorMessage!);
} }
setState(() { setState(() {

View File

@@ -34,7 +34,7 @@ class _LogsPageState extends State<LogsPage> {
children: [ children: [
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: ColorScheme.of(context).surfaceVariant, color: ColorScheme.of(context).surfaceContainerHighest,
borderRadius: const BorderRadius.all(Radius.circular(16)), borderRadius: const BorderRadius.all(Radius.circular(16)),
), ),
child: Padding( child: Padding(

View File

@@ -2,6 +2,7 @@ import "dart:async";
import "package:fluent_ui/fluent_ui.dart"; import "package:fluent_ui/fluent_ui.dart";
import "package:flutter/foundation.dart"; import "package:flutter/foundation.dart";
import "package:flutter/services.dart";
import "package:pixes/appdata.dart"; import "package:pixes/appdata.dart";
import "package:pixes/components/md.dart"; import "package:pixes/components/md.dart";
import "package:pixes/foundation/app.dart"; import "package:pixes/foundation/app.dart";
@@ -20,6 +21,7 @@ import "package:pixes/pages/login_page.dart";
import "package:pixes/pages/search_page.dart"; import "package:pixes/pages/search_page.dart";
import "package:pixes/pages/settings_page.dart"; import "package:pixes/pages/settings_page.dart";
import "package:pixes/pages/user_info_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/mouse_listener.dart";
import "package:pixes/utils/translation.dart"; import "package:pixes/utils/translation.dart";
import "package:window_manager/window_manager.dart"; import "package:window_manager/window_manager.dart";
@@ -63,26 +65,43 @@ class MainPage extends StatefulWidget {
State<MainPage> createState() => _MainPageState(); State<MainPage> createState() => _MainPageState();
} }
class _MainPageState extends State<MainPage> with WindowListener { class _MainPageState extends State<MainPage>
with WindowListener
implements PopEntry {
final navigatorKey = GlobalKey<NavigatorState>(); final navigatorKey = GlobalKey<NavigatorState>();
int index = 4; int index = 4;
int windowButtonKey = 0; int windowButtonKey = 0;
ModalRoute<dynamic>? _route;
@override @override
void initState() { void initState() {
StateController.put<TitleBarController>(TitleBarController()); StateController.put<TitleBarController>(TitleBarController());
windowManager.addListener(this); windowManager.addListener(this);
listenMouseSideButtonToBack(navigatorKey); listenMouseSideButtonToBack(navigatorKey);
App.mainNavigatorKey = navigatorKey; App.mainNavigatorKey = navigatorKey;
index = appdata.settings["initialPage"] ?? 4;
super.initState(); 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 @override
void dispose() { void dispose() {
StateController.remove<TitleBarController>(); StateController.remove<TitleBarController>();
windowManager.removeListener(this); windowManager.removeListener(this);
ModalRoute.of(context)!.unregisterPopEntry(this);
super.dispose(); super.dispose();
} }
@@ -111,7 +130,7 @@ class _MainPageState extends State<MainPage> with WindowListener {
); );
} }
return DefaultSelectionStyle.merge( return DefaultSelectionStyle.merge(
selectionColor: FluentTheme.of(context).selectionColor.withOpacity(0.4), selectionColor: FluentTheme.of(context).selectionColor.toOpacity(0.4),
child: NavigationView( child: NavigationView(
appBar: buildAppBar(context, navigatorKey), appBar: buildAppBar(context, navigatorKey),
pane: NavigationPane( pane: NavigationPane(
@@ -150,7 +169,9 @@ class _MainPageState extends State<MainPage> with WindowListener {
), ),
PaneItemSeparator(), PaneItemSeparator(),
PaneItemHeader( PaneItemHeader(
header: Text("Artwork".tl).paddingBottom(4).paddingLeft(8)), header: Text('${"Illustrations".tl}/${"Manga".tl}')
.paddingBottom(4)
.paddingLeft(8)),
PaneItem( PaneItem(
icon: const Icon( icon: const Icon(
MdIcons.explore_outlined, MdIcons.explore_outlined,
@@ -206,18 +227,17 @@ class _MainPageState extends State<MainPage> with WindowListener {
), ),
], ],
), ),
paneBodyBuilder: (pane, child) => NavigatorPopHandler( paneBodyBuilder: (pane, child) => MediaQuery.removePadding(
key: const Key("navigator"),
onPop: () => navigatorKey.currentState?.pop(),
child: MediaQuery.removePadding(
context: context, context: context,
removeTop: true, removeTop: true,
child: Navigator( child: Navigator(
key: navigatorKey, key: navigatorKey,
onGenerateRoute: (settings) => AppPageRoute( onGenerateRoute: (settings) => AppPageRoute(
builder: (context) => const RecommendationPage()), builder: (context) =>
pageBuilders.elementAtOrNull(index)!(),
),
), ),
))), )),
); );
} }
@@ -268,11 +288,17 @@ class _MainPageState extends State<MainPage> with WindowListener {
if (!App.isDesktop) const Spacer(), if (!App.isDesktop) const Spacer(),
if (App.isDesktop) if (App.isDesktop)
const Expanded( const Expanded(
child: DragToMoveArea( child: SizedBox(
height: double.infinity,
child: DragToMoveArea(
child: Align(
alignment: Alignment.centerLeft,
child: Text( child: Text(
"Pixes", "Pixes",
style: TextStyle(fontSize: 13), style: TextStyle(fontSize: 13),
)), ),
)),
),
), ),
for (var action in controller.actions) for (var action in controller.actions)
Button( Button(
@@ -288,7 +314,26 @@ class _MainPageState extends State<MainPage> with WindowListener {
], ],
), ),
).paddingTop(4).paddingLeft(4), ).paddingTop(4).paddingLeft(4),
if (App.isDesktop) const SizedBox(width: 128), 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);
},
)),
], ],
), ),
), ),
@@ -306,6 +351,25 @@ class _MainPageState extends State<MainPage> with WindowListener {
: null, : 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 { class _BackButton extends StatefulWidget {
@@ -327,28 +391,22 @@ class _BackButtonState extends State<_BackButton> {
@override @override
void initState() { void initState() {
enabled = navigatorKey.currentState?.canPop() == true; enabled = navigatorKey.currentState?.canPop() == true;
loop(); Loop.register(loop);
super.initState(); super.initState();
} }
void loop() { void loop() {
timer = Timer.periodic(const Duration(milliseconds: 100), (timer) { bool enabled = navigatorKey.currentState?.canPop() == true;
if (!mounted) { if (enabled != this.enabled) {
timer.cancel(); setState(() {
} else { this.enabled = enabled;
bool enabled = navigatorKey.currentState?.canPop() == true; });
if (enabled != this.enabled) { }
setState(() {
this.enabled = enabled;
});
}
}
});
} }
@override @override
void dispose() { void dispose() {
timer?.cancel(); Loop.remove(loop);
super.dispose(); super.dispose();
} }
@@ -362,7 +420,7 @@ class _BackButtonState extends State<_BackButton> {
return NavigationPaneTheme( return NavigationPaneTheme(
data: NavigationPaneTheme.of(context).merge(NavigationPaneThemeData( data: NavigationPaneTheme.of(context).merge(NavigationPaneThemeData(
unselectedIconColor: ButtonState.resolveWith((states) { unselectedIconColor: WidgetStateProperty.resolveWith((states) {
if (states.isDisabled) { if (states.isDisabled) {
return ButtonThemeData.buttonColor(context, states); return ButtonThemeData.buttonColor(context, states);
} }
@@ -615,16 +673,16 @@ class UserPane extends PaneItem {
final tileColor = this.tileColor ?? final tileColor = this.tileColor ??
theme.tileColor ?? theme.tileColor ??
kDefaultPaneItemColor(context, mode == PaneDisplayMode.top); kDefaultPaneItemColor(context, mode == PaneDisplayMode.top);
final newStates = states.toSet()..remove(ButtonStates.disabled); final newStates = states.toSet()..remove(WidgetState.disabled);
if (selected && selectedTileColor != null) { if (selected && selectedTileColor != null) {
return selectedTileColor!.resolve(newStates); return selectedTileColor!.resolve(newStates);
} }
return tileColor.resolve( return tileColor.resolve(
selected selected
? { ? {
states.isHovering states.isHovered
? ButtonStates.pressing ? WidgetState.pressed
: ButtonStates.hovering, : WidgetState.hovered,
} }
: newStates, : newStates,
); );
@@ -652,13 +710,16 @@ class UserPane extends PaneItem {
/// Close /// Close
class CloseIcon extends StatelessWidget { class CloseIcon extends StatelessWidget {
final Color color; final Color color;
const CloseIcon({super.key, required this.color}); const CloseIcon({super.key, required this.color});
@override @override
Widget build(BuildContext context) => _AlignedPaint(_ClosePainter(color)); Widget build(BuildContext context) => _AlignedPaint(_ClosePainter(color));
} }
class _ClosePainter extends _IconPainter { class _ClosePainter extends _IconPainter {
_ClosePainter(super.color); _ClosePainter(super.color);
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
Paint p = getPaint(color, true); Paint p = getPaint(color, true);
@@ -670,13 +731,16 @@ class _ClosePainter extends _IconPainter {
/// Maximize /// Maximize
class MaximizeIcon extends StatelessWidget { class MaximizeIcon extends StatelessWidget {
final Color color; final Color color;
const MaximizeIcon({super.key, required this.color}); const MaximizeIcon({super.key, required this.color});
@override @override
Widget build(BuildContext context) => _AlignedPaint(_MaximizePainter(color)); Widget build(BuildContext context) => _AlignedPaint(_MaximizePainter(color));
} }
class _MaximizePainter extends _IconPainter { class _MaximizePainter extends _IconPainter {
_MaximizePainter(super.color); _MaximizePainter(super.color);
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
Paint p = getPaint(color); Paint p = getPaint(color);
@@ -687,16 +751,19 @@ class _MaximizePainter extends _IconPainter {
/// Restore /// Restore
class RestoreIcon extends StatelessWidget { class RestoreIcon extends StatelessWidget {
final Color color; final Color color;
const RestoreIcon({ const RestoreIcon({
super.key, super.key,
required this.color, required this.color,
}); });
@override @override
Widget build(BuildContext context) => _AlignedPaint(_RestorePainter(color)); Widget build(BuildContext context) => _AlignedPaint(_RestorePainter(color));
} }
class _RestorePainter extends _IconPainter { class _RestorePainter extends _IconPainter {
_RestorePainter(super.color); _RestorePainter(super.color);
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
Paint p = getPaint(color); Paint p = getPaint(color);
@@ -713,13 +780,16 @@ class _RestorePainter extends _IconPainter {
/// Minimize /// Minimize
class MinimizeIcon extends StatelessWidget { class MinimizeIcon extends StatelessWidget {
final Color color; final Color color;
const MinimizeIcon({super.key, required this.color}); const MinimizeIcon({super.key, required this.color});
@override @override
Widget build(BuildContext context) => _AlignedPaint(_MinimizePainter(color)); Widget build(BuildContext context) => _AlignedPaint(_MinimizePainter(color));
} }
class _MinimizePainter extends _IconPainter { class _MinimizePainter extends _IconPainter {
_MinimizePainter(super.color); _MinimizePainter(super.color);
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
Paint p = getPaint(color); Paint p = getPaint(color);
@@ -731,6 +801,7 @@ class _MinimizePainter extends _IconPainter {
/// Helpers /// Helpers
abstract class _IconPainter extends CustomPainter { abstract class _IconPainter extends CustomPainter {
_IconPainter(this.color); _IconPainter(this.color);
final Color color; final Color color;
@override @override
@@ -739,6 +810,7 @@ abstract class _IconPainter extends CustomPainter {
class _AlignedPaint extends StatelessWidget { class _AlignedPaint extends StatelessWidget {
const _AlignedPaint(this.painter); const _AlignedPaint(this.painter);
final CustomPainter painter; final CustomPainter painter;
@override @override

View File

@@ -214,7 +214,7 @@ class _NovelPageState extends State<NovelPage> {
constraints: const BoxConstraints(maxWidth: 560), constraints: const BoxConstraints(maxWidth: 560),
child: Card( child: Card(
margin: const EdgeInsets.only(left: 2, right: 2, bottom: 12), margin: const EdgeInsets.only(left: 2, right: 2, bottom: 12),
borderColor: ColorScheme.of(context).outlineVariant.withOpacity(0.52), borderColor: ColorScheme.of(context).outlineVariant.toOpacity(0.52),
child: GestureDetector( child: GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () { onTap: () {
@@ -555,7 +555,7 @@ class _NovelSeriesWidgetState
color: FluentTheme.of(context).cardColor, color: FluentTheme.of(context).cardColor,
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
border: Border.all( border: Border.all(
color: ColorScheme.of(context).outlineVariant.withOpacity(0.6), color: ColorScheme.of(context).outlineVariant.toOpacity(0.6),
width: 0.5, width: 0.5,
)), )),
sliver: SliverMainAxisGroup(slivers: [ sliver: SliverMainAxisGroup(slivers: [
@@ -646,7 +646,7 @@ class _NovelPageWithIdState extends LoadingState<NovelPageWithId, Novel> {
} }
class _RelatedNovelsPage extends StatefulWidget { class _RelatedNovelsPage extends StatefulWidget {
const _RelatedNovelsPage(this.id, {super.key}); const _RelatedNovelsPage(this.id);
final String id; final String id;

View File

@@ -7,7 +7,9 @@ import 'package:pixes/components/page_route.dart';
import 'package:pixes/components/title_bar.dart'; import 'package:pixes/components/title_bar.dart';
import 'package:pixes/foundation/app.dart'; import 'package:pixes/foundation/app.dart';
import 'package:pixes/foundation/image_provider.dart'; import 'package:pixes/foundation/image_provider.dart';
import 'package:pixes/foundation/log.dart';
import 'package:pixes/network/network.dart'; import 'package:pixes/network/network.dart';
import 'package:pixes/network/translator.dart';
import 'package:pixes/pages/image_page.dart'; import 'package:pixes/pages/image_page.dart';
import 'package:pixes/pages/main_page.dart'; import 'package:pixes/pages/main_page.dart';
import 'package:pixes/utils/ext.dart'; import 'package:pixes/utils/ext.dart';
@@ -27,17 +29,39 @@ class _NovelReadingPageState extends LoadingState<NovelReadingPage, String> {
bool isShowingSettings = false; bool isShowingSettings = false;
String? translatedContent;
@override @override
void initState() { void initState() {
action = TitleBarAction(MdIcons.tune, "Settings", () { action = TitleBarAction(MdIcons.tune, "Settings".tl, () {
if (!isShowingSettings) { if (!isShowingSettings) {
_NovelReadingSettings.show(context, () { _NovelReadingSettings.show(
setState(() {}); context,
}); () {
setState(() {});
},
TranslationController(
content: data!,
isTranslated: translatedContent != null,
onTranslated: (s) {
setState(() {
translatedContent = s;
});
},
revert: () {
setState(() {
translatedContent = null;
});
},
),
).then(
(value) {
isShowingSettings = false;
},
);
isShowingSettings = true; isShowingSettings = true;
} else { } else {
Navigator.of(context).pop(); Navigator.of(context).pop();
isShowingSettings = false;
} }
}); });
Future.delayed(const Duration(milliseconds: 200), () { Future.delayed(const Duration(milliseconds: 200), () {
@@ -91,7 +115,7 @@ class _NovelReadingPageState extends LoadingState<NovelReadingPage, String> {
); );
yield const SizedBox(height: 12.0); yield const SizedBox(height: 12.0);
var novelContent = data!.split('\n'); var novelContent = (translatedContent ?? data!).split('\n');
for (var content in novelContent) { for (var content in novelContent) {
if (content.isEmpty) continue; if (content.isEmpty) continue;
if (content.startsWith('[uploadedimage:')) { if (content.startsWith('[uploadedimage:')) {
@@ -131,13 +155,38 @@ class _NovelReadingPageState extends LoadingState<NovelReadingPage, String> {
} }
} }
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 { class _NovelReadingSettings extends StatefulWidget {
const _NovelReadingSettings(this.callback); const _NovelReadingSettings(this.callback, this.controller);
final void Function() callback; final void Function() callback;
static void show(BuildContext context, void Function() callback) { final TranslationController controller;
Navigator.of(context).push(SideBarRoute(_NovelReadingSettings(callback)));
static Future show(
BuildContext context,
void Function() callback,
TranslationController controller,
) {
return Navigator.of(context).push(
SideBarRoute(_NovelReadingSettings(callback, controller)),
);
} }
@override @override
@@ -254,9 +303,64 @@ class __NovelReadingSettingsState extends State<_NovelReadingSettings> {
}), }),
]), ]),
), ),
), ).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());
}
}
} }

View File

@@ -1,6 +1,7 @@
import 'package:fluent_ui/fluent_ui.dart'; import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:pixes/foundation/app.dart'; import 'package:pixes/foundation/app.dart';
import 'package:pixes/utils/block.dart';
import 'package:pixes/utils/translation.dart'; import 'package:pixes/utils/translation.dart';
import '../components/batch_download.dart'; import '../components/batch_download.dart';
@@ -86,6 +87,7 @@ class _OneRankingPage extends StatefulWidget {
class _OneRankingPageState extends MultiPageLoadingState<_OneRankingPage, Illust> { class _OneRankingPageState extends MultiPageLoadingState<_OneRankingPage, Illust> {
@override @override
Widget buildContent(BuildContext context, final List<Illust> data) { Widget buildContent(BuildContext context, final List<Illust> data) {
checkIllusts(data);
return LayoutBuilder(builder: (context, constrains){ return LayoutBuilder(builder: (context, constrains){
return MasonryGridView.builder( return MasonryGridView.builder(
padding: const EdgeInsets.symmetric(horizontal: 8) padding: const EdgeInsets.symmetric(horizontal: 8)

View File

@@ -6,6 +6,7 @@ import 'package:pixes/components/title_bar.dart';
import 'package:pixes/foundation/app.dart'; import 'package:pixes/foundation/app.dart';
import 'package:pixes/network/network.dart'; import 'package:pixes/network/network.dart';
import 'package:pixes/pages/illust_page.dart'; import 'package:pixes/pages/illust_page.dart';
import 'package:pixes/utils/block.dart';
import 'package:pixes/utils/translation.dart'; import 'package:pixes/utils/translation.dart';
import '../components/grid.dart'; import '../components/grid.dart';
@@ -44,7 +45,7 @@ class _RecommendationPageState extends State<RecommendationPage> {
title: "Explore".tl, title: "Explore".tl,
action: SegmentedButton<int>( action: SegmentedButton<int>(
options: [ options: [
SegmentedButtonOption(0, "Artworks".tl), SegmentedButtonOption(0, "Illustrations".tl),
SegmentedButtonOption(1, "Mangas".tl), SegmentedButtonOption(1, "Mangas".tl),
SegmentedButtonOption(2, "Users".tl), SegmentedButtonOption(2, "Users".tl),
], ],
@@ -75,6 +76,7 @@ class _RecommendationArtworksPageState
extends MultiPageLoadingState<_RecommendationArtworksPage, Illust> { extends MultiPageLoadingState<_RecommendationArtworksPage, Illust> {
@override @override
Widget buildContent(BuildContext context, final List<Illust> data) { Widget buildContent(BuildContext context, final List<Illust> data) {
checkIllusts(data);
return LayoutBuilder(builder: (context, constrains) { return LayoutBuilder(builder: (context, constrains) {
return MasonryGridView.builder( return MasonryGridView.builder(
padding: const EdgeInsets.symmetric(horizontal: 8) + padding: const EdgeInsets.symmetric(horizontal: 8) +

View 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;
}
}

View File

@@ -2,7 +2,6 @@ import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:pixes/appdata.dart'; import 'package:pixes/appdata.dart';
import 'package:pixes/components/loading.dart'; import 'package:pixes/components/loading.dart';
import 'package:pixes/components/message.dart';
import 'package:pixes/components/novel.dart'; import 'package:pixes/components/novel.dart';
import 'package:pixes/components/page_route.dart'; import 'package:pixes/components/page_route.dart';
import 'package:pixes/components/user_preview.dart'; import 'package:pixes/components/user_preview.dart';
@@ -11,6 +10,9 @@ import 'package:pixes/network/network.dart';
import 'package:pixes/pages/illust_page.dart'; import 'package:pixes/pages/illust_page.dart';
import 'package:pixes/pages/novel_page.dart'; import 'package:pixes/pages/novel_page.dart';
import 'package:pixes/pages/user_info_page.dart'; import 'package:pixes/pages/user_info_page.dart';
import 'package:pixes/utils/app_links.dart';
import 'package:pixes/utils/block.dart';
import 'package:pixes/utils/ext.dart';
import 'package:pixes/utils/translation.dart'; import 'package:pixes/utils/translation.dart';
import '../components/animated_image.dart'; import '../components/animated_image.dart';
@@ -41,6 +43,12 @@ class _SearchPageState extends State<SearchPage> {
]; ];
void search() { void search() {
if (text.isURL && handleLink(Uri.parse(text))) {
return;
} else if ("https://$text".isURL &&
handleLink(Uri.parse("https://$text"))) {
return;
}
switch (searchType) { switch (searchType) {
case 0: case 0:
context.to(() => SearchResultPage(text)); context.to(() => SearchResultPage(text));
@@ -92,15 +100,18 @@ class _SearchPageState extends State<SearchPage> {
children: [ children: [
Expanded( Expanded(
child: TextBox( child: TextBox(
placeholder: searchTypes[searchType].tl, padding: const EdgeInsets.symmetric(horizontal: 12),
placeholder:
'${searchTypes[searchType].tl} / ${"Open link".tl}',
onChanged: (s) => text = s, onChanged: (s) => text = s,
onSubmitted: (s) => search(), onSubmitted: (s) => search(),
foregroundDecoration: BoxDecoration( foregroundDecoration: WidgetStatePropertyAll(
border: Border.all( BoxDecoration(
color: ColorScheme.of(context) border: Border.all(
.outlineVariant color: ColorScheme.of(context)
.withOpacity(0.6)), .outlineVariant
borderRadius: BorderRadius.circular(4)), .toOpacity(0.6)),
borderRadius: BorderRadius.circular(4))),
suffix: MouseRegion( suffix: MouseRegion(
cursor: SystemMouseCursors.click, cursor: SystemMouseCursors.click,
child: GestureDetector( child: GestureDetector(
@@ -127,10 +138,9 @@ class _SearchPageState extends State<SearchPage> {
), ),
onPressed: () { onPressed: () {
optionController.showFlyout( optionController.showFlyout(
navigatorKey: App.rootNavigatorKey.currentState, placementMode: FlyoutPlacementMode.bottomCenter,
placementMode: FlyoutPlacementMode.bottomCenter, builder: buildSearchOption,
builder: buildSearchOption, barrierColor: Colors.transparent);
);
}, },
), ),
), ),
@@ -238,7 +248,7 @@ class _TrendingTagsViewState
decoration: BoxDecoration( decoration: BoxDecoration(
color: FluentTheme.of(context) color: FluentTheme.of(context)
.micaBackgroundColor .micaBackgroundColor
.withOpacity(0.84), .toOpacity(0.84),
borderRadius: BorderRadius.circular(4)), borderRadius: BorderRadius.circular(4)),
child: Text(text) child: Text(text)
.paddingHorizontal(4) .paddingHorizontal(4)
@@ -410,6 +420,19 @@ class _SearchSettingsState extends State<SearchSettings> {
})) }))
.toList(), .toList(),
)), )),
const SizedBox(height: 4),
Center(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(FluentIcons.info, size: 16),
const SizedBox(
width: 4,
),
Text("Close the pane to apply the settings".tl)
],
),
),
SizedBox( SizedBox(
height: context.padding.bottom, height: context.padding.bottom,
) )
@@ -447,6 +470,12 @@ class _SearchResultPageState
late final controller = TextEditingController(text: widget.keyword); late final controller = TextEditingController(text: widget.keyword);
@override
void reset() {
nextUrl = null;
super.reset();
}
void search() { void search() {
if (keyword != oldKeyword) { if (keyword != oldKeyword) {
oldKeyword = keyword; oldKeyword = keyword;
@@ -456,6 +485,7 @@ class _SearchResultPageState
@override @override
Widget buildContent(BuildContext context, final List<Illust> data) { Widget buildContent(BuildContext context, final List<Illust> data) {
checkIllusts(data);
return CustomScrollView( return CustomScrollView(
slivers: [ slivers: [
buildSearchBar(), buildSearchBar(),
@@ -507,12 +537,16 @@ class _SearchResultPageState
placeholder: "Search artworks".tl, placeholder: "Search artworks".tl,
onChanged: (s) => keyword = s, onChanged: (s) => keyword = s,
onSubmitted: (s) => search(), onSubmitted: (s) => search(),
foregroundDecoration: BoxDecoration( foregroundDecoration: WidgetStatePropertyAll(
BoxDecoration(
border: Border.all( border: Border.all(
color: ColorScheme.of(context) color: ColorScheme.of(context)
.outlineVariant .outlineVariant
.withOpacity(0.6)), .toOpacity(0.6),
borderRadius: BorderRadius.circular(4)), ),
borderRadius: BorderRadius.circular(4),
),
),
suffix: MouseRegion( suffix: MouseRegion(
cursor: SystemMouseCursors.click, cursor: SystemMouseCursors.click,
child: GestureDetector( child: GestureDetector(
@@ -699,12 +733,14 @@ class _SearchNovelResultPageState
placeholder: "Search artworks".tl, placeholder: "Search artworks".tl,
onChanged: (s) => keyword = s, onChanged: (s) => keyword = s,
onSubmitted: (s) => search(), onSubmitted: (s) => search(),
foregroundDecoration: BoxDecoration( foregroundDecoration: WidgetStatePropertyAll(
border: Border.all( BoxDecoration(
color: ColorScheme.of(context) border: Border.all(
.outlineVariant color: ColorScheme.of(context)
.withOpacity(0.6)), .outlineVariant
borderRadius: BorderRadius.circular(4)), .toOpacity(0.6)),
borderRadius: BorderRadius.circular(4)),
),
suffix: MouseRegion( suffix: MouseRegion(
cursor: SystemMouseCursors.click, cursor: SystemMouseCursors.click,
child: GestureDetector( child: GestureDetector(

View File

@@ -1,7 +1,9 @@
import 'dart:io'; import 'dart:io';
import 'package:fluent_ui/fluent_ui.dart'; import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/services.dart';
import 'package:pixes/appdata.dart'; import 'package:pixes/appdata.dart';
import 'package:pixes/components/keyboard.dart';
import 'package:pixes/components/md.dart'; import 'package:pixes/components/md.dart';
import 'package:pixes/components/message.dart'; import 'package:pixes/components/message.dart';
import 'package:pixes/components/page_route.dart'; import 'package:pixes/components/page_route.dart';
@@ -86,6 +88,7 @@ class _SettingsPageState extends State<SettingsPage> {
child: Text('Continue'.tl), child: Text('Continue'.tl),
onPressed: () { onPressed: () {
appdata.account = null; appdata.account = null;
appdata.writeData();
App.rootNavigatorKey.currentState!.pushAndRemoveUntil( App.rootNavigatorKey.currentState!.pushAndRemoveUntil(
AppPageRoute( AppPageRoute(
builder: (context) => const MainPage()), builder: (context) => const MainPage()),
@@ -131,16 +134,16 @@ class _SettingsPageState extends State<SettingsPage> {
return; return;
} }
context.to(() => _SetSingleFieldPage( context.to(() => _SetSingleFieldPage(
"Download Path".tl, "Download Path".tl,
"downloadPath", "downloadPath",
check: (text) { check: (text) {
if(!Directory(text).havePermission()) { if (!Directory(text).havePermission()) {
return "No permission".tl; return "No permission".tl;
} else { } else {
return null; return null;
} }
}, },
)); ));
}), }),
), ),
buildItem( buildItem(
@@ -179,26 +182,43 @@ class _SettingsPageState extends State<SettingsPage> {
child: Column( child: Column(
children: [ children: [
buildItem(title: "Version", subtitle: App.version), 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( buildItem(
title: "Github", title: "Github",
action: IconButton( action: IconButton(
icon: const Icon(MdIcons.open_in_new, size: 18,), icon: const Icon(
MdIcons.open_in_new,
size: 18,
),
onPressed: () => onPressed: () =>
launchUrlString("https://github.com/wgh136/pixes"), launchUrlString("https://github.com/wgh136/pixes"),
)), )),
buildItem( buildItem(
title: "Telegram", title: "Telegram",
action: IconButton( action: IconButton(
icon: const Icon(MdIcons.open_in_new, size: 18,), icon: const Icon(
onPressed: () => MdIcons.open_in_new,
launchUrlString("https://t.me/pica_group"), size: 18,
),
onPressed: () => launchUrlString("https://t.me/pica_group"),
)), )),
buildItem( buildItem(
title: "Logs", title: "Logs",
action: IconButton( action: IconButton(
icon: const Icon(MdIcons.open_in_new, size: 18,), icon: const Icon(
onPressed: () => context.to(() => const LogsPage()) MdIcons.open_in_new,
)), size: 18,
),
onPressed: () => context.to(() => const LogsPage()))),
], ],
), ),
); );
@@ -208,17 +228,72 @@ class _SettingsPageState extends State<SettingsPage> {
return SliverToBoxAdapter( return SliverToBoxAdapter(
child: Column( child: Column(
children: [ children: [
buildItem(
title: "Initial Page".tl,
action: Button(
child: Text("Edit".tl).fixWidth(64),
onPressed: () {
context.to(() => const _SetInitialPageWidget());
},
)),
buildItem( buildItem(
title: "Proxy".tl, title: "Proxy".tl,
action: Button( action: Button(
child: Text("Edit".tl).fixWidth(64), child: Text("Edit".tl).fixWidth(64),
onPressed: () { onPressed: () {
context.to(() => _SetSingleFieldPage( context.to(() => _SetSingleFieldPage(
"Http ${"Proxy".tl}", "Http ${"Proxy".tl}",
"proxy", "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( buildItem(
title: "Theme".tl, title: "Theme".tl,
action: DropDownButton( action: DropDownButton(
title: Text(appdata.settings["theme"] ?? "System".tl), title: Text(appdata.settings["theme"] ?? "System".tl),
items: [ items: [
MenuFlyoutItem(text: Text("System".tl), onPressed: () { MenuFlyoutItem(
setState(() { text: Text("System".tl),
appdata.settings["theme"] = "System"; onPressed: () {
}); setState(() {
appdata.writeData(); appdata.settings["theme"] = "System";
StateController.findOrNull(tag: "MyApp")?.update(); });
}), appdata.writeData();
MenuFlyoutItem(text: Text("light".tl), onPressed: () { StateController.findOrNull(tag: "MyApp")?.update();
setState(() { }),
appdata.settings["theme"] = "Light"; MenuFlyoutItem(
}); text: Text("light".tl),
appdata.writeData(); onPressed: () {
StateController.findOrNull(tag: "MyApp")?.update(); setState(() {
}), appdata.settings["theme"] = "Light";
MenuFlyoutItem(text: Text("dark".tl), onPressed: () { });
setState(() { appdata.writeData();
appdata.settings["theme"] = "Dark"; StateController.findOrNull(tag: "MyApp")?.update();
}); }),
appdata.writeData(); MenuFlyoutItem(
StateController.findOrNull(tag: "MyApp")?.update(); text: Text("dark".tl),
}), onPressed: () {
])), setState(() {
appdata.settings["theme"] = "Dark";
});
appdata.writeData();
StateController.findOrNull(tag: "MyApp")?.update();
}),
])),
buildItem( buildItem(
title: "Language".tl, title: "Language".tl,
action: DropDownButton( action: DropDownButton(
title: Text(appdata.settings["language"] ?? "System"), title: Text(appdata.settings["language"] ?? "System"),
items: [ items: [
MenuFlyoutItem(text: const Text("System"), onPressed: () { MenuFlyoutItem(
setState(() { text: const Text("System"),
appdata.settings["language"] = "System"; onPressed: () {
}); setState(() {
appdata.writeData(); appdata.settings["language"] = "System";
StateController.findOrNull(tag: "MyApp")?.update(); });
}), appdata.writeData();
MenuFlyoutItem(text: const Text("English"), onPressed: () { StateController.findOrNull(tag: "MyApp")?.update();
setState(() { }),
appdata.settings["language"] = "English"; MenuFlyoutItem(
}); text: const Text("English"),
appdata.writeData(); onPressed: () {
StateController.findOrNull(tag: "MyApp")?.update(); setState(() {
}), appdata.settings["language"] = "English";
MenuFlyoutItem(text: const Text("简体中文"), onPressed: () { });
setState(() { appdata.writeData();
appdata.settings["language"] = "简体中文"; StateController.findOrNull(tag: "MyApp")?.update();
}); }),
appdata.writeData(); MenuFlyoutItem(
StateController.findOrNull(tag: "MyApp")?.update(); text: const Text("简体中文"),
}), onPressed: () {
MenuFlyoutItem(text: const Text("繁體中文"), onPressed: () { setState(() {
setState(() { appdata.settings["language"] = "简体中文";
appdata.settings["language"] = "繁體中文"; });
}); appdata.writeData();
appdata.writeData(); StateController.findOrNull(tag: "MyApp")?.update();
StateController.findOrNull(tag: "MyApp")?.update(); }),
}), MenuFlyoutItem(
text: const Text("繁體中文"),
onPressed: () {
setState(() {
appdata.settings["language"] = "繁體中文";
});
appdata.writeData();
StateController.findOrNull(tag: "MyApp")?.update();
}),
])), ])),
], ],
), ),
@@ -416,3 +505,233 @@ ${"Some keywords will be replaced by the following rule:".tl}
${"Multiple path separators will be automatically replaced with a single".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",
"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();
});
},
),
),
);
},
),
);
}
}

View File

@@ -13,6 +13,7 @@ import 'package:pixes/foundation/app.dart';
import 'package:pixes/foundation/image_provider.dart'; import 'package:pixes/foundation/image_provider.dart';
import 'package:pixes/network/network.dart'; import 'package:pixes/network/network.dart';
import 'package:pixes/pages/following_users_page.dart'; import 'package:pixes/pages/following_users_page.dart';
import 'package:pixes/utils/block.dart';
import 'package:pixes/utils/translation.dart'; import 'package:pixes/utils/translation.dart';
import 'package:url_launcher/url_launcher_string.dart'; import 'package:url_launcher/url_launcher_string.dart';
@@ -20,17 +21,34 @@ import '../components/illust_widget.dart';
import 'illust_page.dart'; import 'illust_page.dart';
class UserInfoPage extends StatefulWidget { class UserInfoPage extends StatefulWidget {
const UserInfoPage(this.id, {this.followCallback, super.key}); const UserInfoPage(this.id, {super.key});
final String id; final String id;
final void Function(bool)? followCallback; static Map<String, UpdateFollowCallback> followCallbacks = {};
@override @override
State<UserInfoPage> createState() => _UserInfoPageState(); State<UserInfoPage> createState() => _UserInfoPageState();
} }
class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> { 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; int page = 0;
@override @override
@@ -45,7 +63,7 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
_RelatedUsers(widget.id), _RelatedUsers(widget.id),
buildInformation(), buildInformation(),
buildArtworkHeader(), buildArtworkHeader(),
if (page == 2) if (page == 4)
_UserNovels(widget.id) _UserNovels(widget.id)
else else
_UserArtworks( _UserArtworks(
@@ -93,7 +111,9 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
} }
} else { } else {
data!.isFollowed = !data!.isFollowed; 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(() { setState(() {
isFollowing = false; isFollowing = false;
@@ -208,8 +228,10 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
SegmentedButton<int>( SegmentedButton<int>(
options: [ options: [
SegmentedButtonOption(0, "Artworks".tl), SegmentedButtonOption(0, "Artworks".tl),
SegmentedButtonOption(1, "Bookmarks".tl), SegmentedButtonOption(1, "Illustrations".tl),
SegmentedButtonOption(2, "Novels".tl), SegmentedButtonOption(2, "Mangas".tl),
SegmentedButtonOption(3, "Bookmarks".tl),
SegmentedButtonOption(4, "Novels".tl),
], ],
value: page, value: page,
onPressed: (value) { onPressed: (value) {
@@ -219,15 +241,24 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
}, },
), ),
const Spacer(), const Spacer(),
if (page != 2) if (page != 4)
BatchDownloadButton( BatchDownloadButton(
request: () { request: () {
if (page == 0) { switch (page) {
return Network().getUserIllusts(data!.id.toString()); case 0:
} else { return Network()
return Network() .getUserIllusts(data!.id.toString(), null);
.getUserBookmarks(data!.id.toString()); 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";
}, },
), ),
], ],
@@ -249,14 +280,14 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 2), margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 2),
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
child: ListTile( child: ListTile(
leading: icon == null title: Row(
? null children: [
: Icon( Icon(icon, size: 20),
icon, const SizedBox(width: 8),
size: 20, Text(title)
), ],
title: Text(title), ),
subtitle: SelectableText(content), subtitle: SelectableText(content).paddingLeft(icon == null ? 0 : 28),
trailing: trailing, trailing: trailing,
), ),
); );
@@ -360,7 +391,8 @@ class _UserArtworksState extends MultiPageLoadingState<_UserArtworks, Illust> {
} }
@override @override
Widget buildContent(BuildContext context, final List<Illust> data) { Widget buildContent(BuildContext context, List<Illust> data) {
checkIllusts(data);
return SliverMasonryGrid( return SliverMasonryGrid(
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent( gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 240, maxCrossAxisExtent: 240,
@@ -388,8 +420,9 @@ class _UserArtworksState extends MultiPageLoadingState<_UserArtworks, Illust> {
return Res.error("No more data"); return Res.error("No more data");
} }
var res = nextUrl == null var res = nextUrl == null
? (widget.type == 0 ? (widget.type != 3
? await Network().getUserIllusts(widget.uid) ? await Network().getUserIllusts(
widget.uid, [null, "illust", "manga"][widget.type])
: await Network().getUserBookmarks(widget.uid)) : await Network().getUserBookmarks(widget.uid))
: await Network().getIllustsWithNextUrl(nextUrl!); : await Network().getIllustsWithNextUrl(nextUrl!);
if (!res.error) { if (!res.error) {
@@ -401,7 +434,7 @@ class _UserArtworksState extends MultiPageLoadingState<_UserArtworks, Illust> {
} }
class _UserNovels extends StatefulWidget { class _UserNovels extends StatefulWidget {
const _UserNovels(this.uid, {super.key}); const _UserNovels(this.uid);
final String uid; final String uid;
@@ -513,7 +546,7 @@ class _RelatedUsersState
return UserPreviewWidget(data[index]).fixWidth(342); return UserPreviewWidget(data[index]).fixWidth(342);
}, },
)); ));
if (MediaQuery.of(context).size.width > 500) { if (App.isDesktop) {
content = ScrollbarTheme.merge( content = ScrollbarTheme.merge(
data: const ScrollbarThemeData( data: const ScrollbarThemeData(
thickness: 6, thickness: 6,
@@ -521,10 +554,25 @@ class _RelatedUsersState
mainAxisMargin: 4, mainAxisMargin: 4,
hoveringPadding: EdgeInsets.zero, hoveringPadding: EdgeInsets.zero,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
hoveringMainAxisMargin: 4), 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); child: content);
} }
return content; return MediaQuery.removePadding(
context: context, removeBottom: true, child: content);
} }
@override @override

View File

@@ -1,11 +1,15 @@
import 'dart:io'; import 'dart:io';
import 'package:app_links/app_links.dart'; import 'package:app_links/app_links.dart';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:pixes/foundation/app.dart'; import 'package:pixes/foundation/app.dart';
import 'package:pixes/foundation/log.dart'; import 'package:pixes/foundation/log.dart';
import 'package:pixes/pages/illust_page.dart'; import 'package:pixes/pages/illust_page.dart';
import 'package:pixes/pages/novel_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/pages/user_info_page.dart';
import 'package:pixes/utils/ext.dart';
import 'package:pixes/utils/translation.dart';
import 'package:win32_registry/win32_registry.dart'; import 'package:win32_registry/win32_registry.dart';
Future<void> _register(String scheme) async { Future<void> _register(String scheme) async {
@@ -29,13 +33,46 @@ Future<void> _register(String scheme) async {
regKey.createKey(protocolCmdRegKey).createValue(protocolCmdRegValue); 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 Function(Uri uri)? onLink;
bool _firstLink = true;
void handleLinks() async { void handleLinks() async {
if (App.isWindows) { 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()); Log.info("App Link", uri.toString());
if (onLink?.call(uri) == true) { if (onLink?.call(uri) == true) {
return; return;
@@ -70,6 +107,33 @@ bool handleLink(Uri uri) {
} }
} }
return false; 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; return false;
} }

23
lib/utils/block.dart Normal file
View 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;
}

View File

@@ -12,6 +12,14 @@ extension FSExt on FileSystemEntity {
} }
} }
Future<void> deleteIgnoreError() async {
try {
await delete();
} catch (e) {
// ignore
}
}
int get size { int get size {
if (this is File) { if (this is File) {
return (this as File).lengthSync(); return (this as File).lengthSync();

21
lib/utils/loop.dart Normal file
View 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
View 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
View 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;
}
}

View File

@@ -6,26 +6,34 @@
#include "generated_plugin_registrant.h" #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 <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 <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
#include <system_theme/system_theme_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h> #include <url_launcher_linux/url_launcher_plugin.h>
#include <window_manager/window_manager_plugin.h> #include <window_manager/window_manager_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) { 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 = g_autoptr(FlPluginRegistrar) gtk_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin");
gtk_plugin_register_with_registrar(gtk_registrar); gtk_plugin_register_with_registrar(gtk_registrar);
g_autoptr(FlPluginRegistrar) screen_retriever_registrar = g_autoptr(FlPluginRegistrar) screen_retriever_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverLinuxPlugin");
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar); screen_retriever_linux_plugin_register_with_registrar(screen_retriever_linux_registrar);
g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar = g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin");
sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar); 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 = g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);

View File

@@ -3,10 +3,12 @@
# #
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
dynamic_color
file_selector_linux
flutter_acrylic
gtk gtk
screen_retriever screen_retriever_linux
sqlite3_flutter_libs sqlite3_flutter_libs
system_theme
url_launcher_linux url_launcher_linux
window_manager window_manager
) )

View File

@@ -55,7 +55,7 @@ static void my_application_activate(GApplication* application) {
} }
gtk_window_set_default_size(window, 1280, 720); 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(); g_autoptr(FlDartProject) project = fl_dart_project_new();
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);

View File

@@ -6,19 +6,29 @@ import FlutterMacOS
import Foundation import Foundation
import app_links import app_links
import device_info_plus
import dynamic_color
import file_selector_macos
import flutter_acrylic
import path_provider_foundation import path_provider_foundation
import screen_retriever import screen_retriever_macos
import share_plus
import sqlite3_flutter_libs import sqlite3_flutter_libs
import system_theme
import url_launcher_macos import url_launcher_macos
import webview_flutter_wkwebview
import window_manager import window_manager
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin")) 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")) 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")) Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin"))
SystemThemePlugin.register(with: registry.registrar(forPlugin: "SystemThemePlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
FLTWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "FLTWebViewFlutterPlugin"))
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
} }

46
macos/Podfile Normal file
View 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

View File

@@ -461,7 +461,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14; MACOSX_DEPLOYMENT_TARGET = 10.14.6;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx; SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule; SWIFT_COMPILATION_MODE = wholemodule;
@@ -543,7 +543,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14; MACOSX_DEPLOYMENT_TARGET = 10.14.6;
MTL_ENABLE_DEBUG_INFO = YES; MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx; SDKROOT = macosx;
@@ -593,7 +593,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14; MACOSX_DEPLOYMENT_TARGET = 10.14.6;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx; SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule; SWIFT_COMPILATION_MODE = wholemodule;

View File

@@ -3,10 +3,14 @@
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>com.apple.security.app-sandbox</key> <key>com.apple.security.app-sandbox</key>
<true/> <false/>
<key>com.apple.security.cs.allow-jit</key> <key>com.apple.security.cs.allow-jit</key>
<true/> <true/>
<key>com.apple.security.network.server</key> <key>com.apple.security.network.server</key>
<true/> <true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
</dict> </dict>
</plist> </plist>

View File

@@ -5,18 +5,42 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: app_links name: app_links
sha256: "1c2b9e9c56d80d17610bcbd111b37187875c5d0ded8654caa1bda14ea753d001" sha256: "433df2e61b10519407475d7f69e470789d23d593f28224c38ba1068597be7950"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.0.1" version: "6.3.3"
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: archive:
dependency: "direct main" dependency: "direct main"
description: description:
name: archive name: archive
sha256: ecf4273855368121b1caed0d10d4513c7241dfc813f7d3c8933b36622ae9b265 sha256: "08064924cbf0ab88280a0c3f60db9dd24fec693927e725ecb176f16c629d1cb8"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.5.1" version: "4.0.1"
async: async:
dependency: transitive dependency: transitive
description: description:
@@ -53,34 +77,66 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.18.0" version: "1.19.0"
cross_file: cross_file:
dependency: transitive dependency: transitive
description: description:
name: cross_file name: cross_file
sha256: "55d7b444feb71301ef6b8838dbc1ae02e63dd48c8773f3810ff53bb1e2945b32" sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.3.4+1" version: "0.3.4+2"
crypto: crypto:
dependency: "direct main" dependency: "direct main"
description: description:
name: crypto name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.3" version: "3.0.6"
device_info_plus:
dependency: "direct main"
description:
name: device_info_plus
sha256: "4fa68e53e26ab17b70ca39f072c285562cfc1589df5bb1e9295db90f6645f431"
url: "https://pub.dev"
source: hosted
version: "11.2.0"
device_info_plus_platform_interface:
dependency: transitive
description:
name: device_info_plus_platform_interface
sha256: "0b04e02b30791224b31969eb1b50d723498f402971bff3630bca2ba839bd1ed2"
url: "https://pub.dev"
source: hosted
version: "7.0.2"
dio: dio:
dependency: "direct main" dependency: "direct main"
description: description:
name: dio name: dio
sha256: "11e40df547d418cc0c4900a9318b26304e665da6fa4755399a9ff9efd09034b5" sha256: "5598aa796bbf4699afd5c67c0f5f6e2ed542afc956884b9cd58c306966efc260"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "5.4.3+1" version: "5.7.0"
dio_web_adapter:
dependency: transitive
description:
name: dio_web_adapter
sha256: "33259a9276d6cea88774a0000cfae0d861003497755969c92faa223108620dc8"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
dynamic_color:
dependency: "direct main"
description:
name: dynamic_color
sha256: eae98052fa6e2826bdac3dd2e921c6ce2903be15c6b7f8b6d8a5d49b5086298d
url: "https://pub.dev"
source: hosted
version: "1.7.0"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
@@ -157,10 +213,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: file_selector_web name: file_selector_web
sha256: "619e431b224711a3869e30dbd7d516f5f5a4f04b265013a50912f39e1abc88c8" sha256: c4c0ea4224d97a60a7067eca0c8fd419e708ff830e0c83b11a48faf566cec3e7
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.9.4+1" version: "0.9.4+2"
file_selector_windows: file_selector_windows:
dependency: transitive dependency: transitive
description: description:
@@ -181,23 +237,31 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: fluent_ui name: fluent_ui
sha256: a8c76cb501303d108cb9bd33e516da7cfd078031ff427d68eab6069bf4492a2c sha256: "069dc196e093864ba7252a3ed5cc4e28039f04fc9cb687f35aeaa2e2b265dd7e"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.8.7" version: "4.10.0"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" 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: flutter_file_dialog:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_file_dialog name: flutter_file_dialog
sha256: "5a1507833473b38839056d63c5125750a6d12e904f78131324fa4632504de513" sha256: "9344b8f07be6a1b6f9854b723fb0cf84a8094ba94761af1d213589d3cb087488"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.1" version: "3.0.2"
flutter_lints: flutter_lints:
dependency: "direct dev" dependency: "direct dev"
description: description:
@@ -224,6 +288,15 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_to_arch:
dependency: "direct dev"
description:
path: "."
ref: "15bfead"
resolved-ref: "15bfead0380fda79b0256b37c73b886b0882f1bf"
url: "https://github.com/wgh136/flutter_to_arch"
source: git
version: "1.0.0"
flutter_web_plugins: flutter_web_plugins:
dependency: transitive dependency: transitive
description: flutter description: flutter
@@ -241,10 +314,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: http name: http
sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938" sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.2.1" version: "1.2.2"
http_parser: http_parser:
dependency: transitive dependency: transitive
description: description:
@@ -253,6 +326,15 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.0.2" version: "4.0.2"
image_gallery_saver:
dependency: "direct main"
description:
path: "."
ref: master
resolved-ref: "38a38c45d3ed229cbc1d827eb2b5aaad1a4519cd"
url: "https://github.com/wgh136/image_gallery_saver"
source: git
version: "2.0.0"
intl: intl:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -261,22 +343,38 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.19.0" version: "0.19.0"
io:
dependency: transitive
description:
name: io
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
json_annotation:
dependency: transitive
description:
name: json_annotation
sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1"
url: "https://pub.dev"
source: hosted
version: "4.9.0"
leak_tracker: leak_tracker:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker name: leak_tracker
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "10.0.4" version: "10.0.7"
leak_tracker_flutter_testing: leak_tracker_flutter_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_flutter_testing name: leak_tracker_flutter_testing
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.3" version: "3.0.8"
leak_tracker_testing: leak_tracker_testing:
dependency: transitive dependency: transitive
description: description:
@@ -305,10 +403,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.8.0" version: "0.11.1"
math_expressions: math_expressions:
dependency: transitive dependency: transitive
description: description:
@@ -321,10 +419,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.12.0" version: "1.15.0"
mime: mime:
dependency: transitive dependency: transitive
description: description:
@@ -345,18 +443,18 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: path_provider name: path_provider
sha256: c9e7d3a4cd1410877472158bee69963a4579f78b68c65a2b7d40d1a7a88bb161 sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.3" version: "2.1.5"
path_provider_android: path_provider_android:
dependency: transitive dependency: transitive
description: description:
name: path_provider_android name: path_provider_android
sha256: a248d8146ee5983446bf03ed5ea8f6533129a12b11f12057ad1b4a67a2b3b41d sha256: "4adf4fd5423ec60a29506c76581bc05854c55e3a0b72d35bb28d661c9686edf2"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.2.4" version: "2.2.15"
path_provider_foundation: path_provider_foundation:
dependency: transitive dependency: transitive
description: description:
@@ -414,6 +512,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.8" version: "2.1.8"
posix:
dependency: transitive
description:
name: posix
sha256: a0117dc2167805aa9125b82eee515cc891819bac2f538c83646d355b16f58b9a
url: "https://pub.dev"
source: hosted
version: "6.0.1"
recase: recase:
dependency: transitive dependency: transitive
description: description:
@@ -426,10 +532,42 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: screen_retriever name: screen_retriever
sha256: "6ee02c8a1158e6dae7ca430da79436e3b1c9563c8cf02f524af997c201ac2b90" sha256: "570dbc8e4f70bac451e0efc9c9bb19fa2d6799a11e6ef04f946d7886d2e23d0c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted 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: scroll_pos:
dependency: transitive dependency: transitive
description: description:
@@ -442,23 +580,23 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: share_plus name: share_plus
sha256: ef3489a969683c4f3d0239010cc8b7a2a46543a8d139e111c06c558875083544 sha256: "6327c3f233729374d0abaafd61f6846115b2a481b4feddd8534211dc10659400"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "9.0.0" version: "10.1.3"
share_plus_platform_interface: share_plus_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: share_plus_platform_interface name: share_plus_platform_interface
sha256: "0f9e4418835d1b2c3ae78fdb918251959106cefdbc4dd43526e182f80e82f6d4" sha256: cc012a23fc2d479854e6c80150696c4a5f5bb62cb89af4de1c505cf78d0a5d0b
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.0.0" version: "5.0.2"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.99" version: "0.0.0"
source_span: source_span:
dependency: transitive dependency: transitive
description: description:
@@ -479,10 +617,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: sqlite3 name: sqlite3
sha256: b384f598b813b347c5a7e5ffad82cbaff1bec3d1561af267041e66f6f0899295 sha256: cb7f4e9dc1b52b1fa350f7b3d41c662e75fc3d399555fa4e5efcf267e9a4fbb5
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.4.3" version: "2.5.0"
sqlite3_flutter_libs: sqlite3_flutter_libs:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -495,10 +633,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.11.1" version: "1.12.0"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
@@ -511,26 +649,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.2.0" version: "1.3.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"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
@@ -543,10 +665,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.0" version: "0.7.3"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@@ -559,10 +681,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: url_launcher name: url_launcher
sha256: "6ce1e04375be4eed30548f10a315826fd933c1e493206eab82eed01f438c8d2e" sha256: "9d06212b1362abc2f0f0d78e6f09f726608c74e3b9462e8368bb03314aa8d603"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.2.6" version: "6.3.1"
url_launcher_android: url_launcher_android:
dependency: transitive dependency: transitive
description: description:
@@ -607,18 +729,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_web name: url_launcher_web
sha256: "8d9e750d8c9338601e709cd0885f95825086bd8b642547f26bda435aade95d8a" sha256: "772638d3b34c779ede05ba3d38af34657a05ac55b06279ea6edd409e323dca8e"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.3.1" version: "2.3.3"
url_launcher_windows: url_launcher_windows:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_windows name: url_launcher_windows
sha256: ecf9725510600aa2bb6d7ddabe16357691b6d2805f66216a97d1b881e21beff7 sha256: "44cf3aabcedde30f2dba119a9dea3b0f2672fbe6fa96e85536251d678216b3c4"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.1" version: "3.1.3"
uuid: uuid:
dependency: transitive dependency: transitive
description: description:
@@ -639,34 +761,34 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: vm_service name: vm_service
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "14.2.1" version: "14.3.0"
web: web:
dependency: transitive dependency: transitive
description: description:
name: web name: web
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.5.1" version: "1.1.0"
webview_flutter: webview_flutter:
dependency: "direct main" dependency: "direct main"
description: description:
name: webview_flutter name: webview_flutter
sha256: "25e1b6e839e8cbfbd708abc6f85ed09d1727e24e08e08c6b8590d7c65c9a8932" sha256: "889a0a678e7c793c308c68739996227c9661590605e70b1f6cf6b9a6634f7aec"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.7.0" version: "4.10.0"
webview_flutter_android: webview_flutter_android:
dependency: transitive dependency: transitive
description: description:
name: webview_flutter_android name: webview_flutter_android
sha256: dad3313c9ead95517bb1cae5e1c9d20ba83729d5a59e5e83c0a2d66203f27f91 sha256: "3d535126f7244871542b2f0b0fcf94629c9a14883250461f9abe1a6644c1c379"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.16.1" version: "4.2.0"
webview_flutter_platform_interface: webview_flutter_platform_interface:
dependency: transitive dependency: transitive
description: description:
@@ -679,18 +801,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: webview_flutter_wkwebview name: webview_flutter_wkwebview
sha256: "7affdf9d680c015b11587181171d3cad8093e449db1f7d9f0f08f4f33d24f9a0" sha256: b7e92f129482460951d96ef9a46b49db34bd2e1621685de26e9eaafd9674e7eb
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.13.1" version: "3.16.3"
win32: win32:
dependency: transitive dependency: transitive
description: description:
name: win32 name: win32
sha256: "0eaf06e3446824099858367950a813472af675116bf63f008a4c2a75ae13e9cb" sha256: "68d1e89a91ed61ad9c370f9f8b6effed9ae5e0ede22a270bdfa6daf79fc2290a"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "5.5.0" version: "5.5.4"
win32_registry: win32_registry:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -703,10 +825,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: window_manager name: window_manager
sha256: b3c895bdf936c77b83c5254bec2e6b3f066710c1f89c38b20b8acc382b525494 sha256: "732896e1416297c63c9e3fb95aea72d0355f61390263982a47fd519169dc5059"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.3.8" version: "0.4.3"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:
@@ -715,6 +837,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.4" version: "1.0.4"
yaml:
dependency: transitive
description:
name: yaml
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
sdks: sdks:
dart: ">=3.3.4 <4.0.0" dart: ">=3.5.0 <4.0.0"
flutter: ">=3.19.0" flutter: ">=3.27.0"

View File

@@ -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 # 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 # 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. # of the product and file versions while build-number is used as the build suffix.
version: 1.0.4+104 version: 1.1.0+110
environment: environment:
sdk: '>=3.3.4 <4.0.0' sdk: '>=3.3.4 <4.0.0'
flutter: 3.27.0
# Dependencies specify other packages that your package needs in order to work. # Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions # To automatically upgrade your package dependencies to the latest versions
@@ -34,28 +35,34 @@ dependencies:
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
window_manager: ^0.3.8 window_manager: ^0.4.3
fluent_ui: ^4.8.7 fluent_ui: ^4.10.0
dynamic_color: ^1.7.0 dynamic_color: ^1.7.0
dio: ^5.4.3 dio: ^5.7.0
crypto: crypto: ^3.0.6
intl: intl:
path_provider: path_provider: ^2.1.5
url_launcher: ^6.1.8 url_launcher: ^6.3.1
app_links: ^6.0.1 app_links: ^6.3.3
win32_registry: ^1.1.3 win32_registry: ^1.1.0
flutter_staggered_grid_view: ^0.7.0 flutter_staggered_grid_view: ^0.7.0
sqlite3: ^2.4.3 sqlite3: ^2.5.0
sqlite3_flutter_libs: any sqlite3_flutter_libs: any
photo_view: photo_view:
git: git:
url: https://github.com/wgh136/photo_view url: https://github.com/wgh136/photo_view
ref: main ref: main
share_plus: ^9.0.0 share_plus: ^10.1.3
file_selector: ^1.0.1 file_selector: ^1.0.1
flutter_file_dialog: 3.0.1 flutter_file_dialog: ^3.0.2
archive: ^3.5.1 archive: ^4.0.1
webview_flutter: ^4.7.0 webview_flutter: ^4.10.0
flutter_acrylic: 1.0.0+2
device_info_plus: ^11.2.0
image_gallery_saver:
git:
url: https://github.com/wgh136/image_gallery_saver
ref: master
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
@@ -66,10 +73,23 @@ dev_dependencies:
# package. See that file for information about deactivating specific lint # package. See that file for information about deactivating specific lint
# rules and activating additional ones. # rules and activating additional ones.
flutter_lints: ^3.0.0 flutter_lints: ^3.0.0
flutter_to_arch:
git:
url: https://github.com/wgh136/flutter_to_arch
ref: 15bfead
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec # 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. # The following section is specific to Flutter packages.
flutter: flutter:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 702 KiB

After

Width:  |  Height:  |  Size: 520 KiB

BIN
screenshots/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

BIN
screenshots/3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 KiB

BIN
screenshots/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 KiB

64
windows/build.iss Normal file
View 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_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
View 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)

View File

@@ -7,21 +7,30 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <app_links/app_links_plugin_c_api.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 <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
#include <system_theme/system_theme_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h> #include <url_launcher_windows/url_launcher_windows.h>
#include <window_manager/window_manager_plugin.h> #include <window_manager/window_manager_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) { void RegisterPlugins(flutter::PluginRegistry* registry) {
AppLinksPluginCApiRegisterWithRegistrar( AppLinksPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("AppLinksPluginCApi")); registry->GetRegistrarForPlugin("AppLinksPluginCApi"));
ScreenRetrieverPluginRegisterWithRegistrar( DynamicColorPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("ScreenRetrieverPlugin")); registry->GetRegistrarForPlugin("DynamicColorPluginCApi"));
FileSelectorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSelectorWindows"));
FlutterAcrylicPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterAcrylicPlugin"));
ScreenRetrieverWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("ScreenRetrieverWindowsPluginCApi"));
SharePlusWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
Sqlite3FlutterLibsPluginRegisterWithRegistrar( Sqlite3FlutterLibsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin")); registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin"));
SystemThemePluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SystemThemePlugin"));
UrlLauncherWindowsRegisterWithRegistrar( UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows")); registry->GetRegistrarForPlugin("UrlLauncherWindows"));
WindowManagerPluginRegisterWithRegistrar( WindowManagerPluginRegisterWithRegistrar(

View File

@@ -4,9 +4,12 @@
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
app_links app_links
screen_retriever dynamic_color
file_selector_windows
flutter_acrylic
screen_retriever_windows
share_plus
sqlite3_flutter_libs sqlite3_flutter_libs
system_theme
url_launcher_windows url_launcher_windows
window_manager window_manager
) )

BIN
windows/runner/RCa14464 Normal file

Binary file not shown.

BIN
windows/runner/Runner.aps Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 121 KiB