mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-28 05:17:24 +00:00
Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
86c6f13282 | ||
![]() |
b69d2a0950 | ||
![]() |
c897891b2a | ||
![]() |
3c73439588 | ||
![]() |
2d16502154 | ||
![]() |
294498d8a7 | ||
![]() |
20dfbf5125 | ||
![]() |
63aa4ee8b0 | ||
![]() |
c8d4b3db88 | ||
![]() |
b1e7adb1c5 | ||
![]() |
0143a67fa0 | ||
![]() |
eee1141970 | ||
![]() |
50a69f77b6 | ||
![]() |
790ed54d5b | ||
![]() |
21fe14f88b | ||
![]() |
a03ad12837 | ||
![]() |
426257716f | ||
![]() |
67e01ea69f | ||
![]() |
6cf9ce9c96 | ||
![]() |
593899af8c | ||
![]() |
908c26d764 |
13
.github/workflows/linux.yml
vendored
13
.github/workflows/linux.yml
vendored
@@ -11,13 +11,24 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
channel: 'stable'
|
channel: 'stable'
|
||||||
architecture: x64
|
architecture: x64
|
||||||
|
flutter-version-file: pubspec.yaml
|
||||||
- run: |
|
- run: |
|
||||||
sudo apt-get update -y
|
sudo apt-get update -y
|
||||||
sudo apt-get install -y ninja-build libgtk-3-dev
|
sudo apt-get install -y ninja-build libgtk-3-dev
|
||||||
dart pub global activate flutter_to_debian
|
dart pub global activate flutter_to_debian
|
||||||
- run: python3 debian/build.py
|
- run: python3 debian/build.py
|
||||||
- uses: actions/upload-artifact@v3
|
- 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:
|
with:
|
||||||
name: deb_build
|
name: deb_build
|
||||||
path: build/linux/x64/release/debian
|
path: build/linux/x64/release/debian
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: arch_build
|
||||||
|
path: build/linux/arch/
|
||||||
|
|
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -11,6 +11,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
channel: 'stable'
|
channel: 'stable'
|
||||||
architecture: x64
|
architecture: x64
|
||||||
|
flutter-version-file: pubspec.yaml
|
||||||
- run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app
|
- run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app
|
||||||
- run: flutter pub get
|
- run: flutter pub get
|
||||||
- run: flutter build ios --release --no-codesign
|
- run: flutter build ios --release --no-codesign
|
||||||
@@ -27,6 +28,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
channel: 'stable'
|
channel: 'stable'
|
||||||
architecture: x64
|
architecture: x64
|
||||||
|
flutter-version-file: pubspec.yaml
|
||||||
- run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app
|
- run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app
|
||||||
- run: flutter pub get
|
- run: flutter pub get
|
||||||
- run: flutter build macos --release
|
- run: flutter build macos --release
|
||||||
|
41
README.md
41
README.md
@@ -1,15 +1,48 @@
|
|||||||
# pixes
|
# pixes
|
||||||
|
|
||||||
[](https://flutter.dev/)
|
[](https://flutter.dev/)
|
||||||
[](https://github.com/wgh136/pixes/blob/master/LICENSE)
|
[](https://github.com/wgh136/pixes/blob/master/LICENSE)
|
||||||
[](https://github.com/wgh136/PicaComic/pixes)
|
[](https://github.com/wgh136/pixes)
|
||||||
[](https://github.com/wgh136/pixes/stargazers)
|
[](https://github.com/wgh136/pixes/stargazers)
|
||||||
[](https://t.me/pica_group)
|
|
||||||
|
|
||||||
非官方 Pixiv app, 支持 Windows, Android, iOS, macOS
|
非官方 Pixiv app, 支持 Windows, Android, iOS, macOS, linux
|
||||||
|
|
||||||
主要功能均已实现
|
主要功能均已实现
|
||||||
|
|
||||||
|
## 下载
|
||||||
|
|
||||||
|
在 [Release](https://github.com/wgh136/pixes/releases) 页面下载
|
||||||
|
|
||||||
|
## 从源代码构建
|
||||||
|
|
||||||
|
### 准备工作
|
||||||
|
|
||||||
|
安装Stable版的Flutter
|
||||||
|
|
||||||
|
### 构建Android
|
||||||
|
|
||||||
|
将你的证书文件(`key.jks`, `key.properties`)放在`android`目录下
|
||||||
|
|
||||||
|
执行`flutter build apk`构建apk
|
||||||
|
|
||||||
|
### 构建iOS
|
||||||
|
|
||||||
|
执行`flutter build ios`构建iOS程序
|
||||||
|
|
||||||
|
### 构建Windows
|
||||||
|
|
||||||
|
执行`python windows/build_windows.py`构建Windows程序
|
||||||
|
|
||||||
|
### 构建macOS
|
||||||
|
|
||||||
|
执行`flutter build macos`构建macOS程序
|
||||||
|
|
||||||
|
### 构建Linux
|
||||||
|
|
||||||
|
执行`python3 debian/build.py`构建deb包
|
||||||
|
|
||||||
|
如果你使用其他发行版, 请注意`.desktop`文件中需要注册 URI Scheme `pixiv`
|
||||||
|
|
||||||
## 屏幕截图
|
## 屏幕截图
|
||||||
|
|
||||||
<img src="screenshots/1.png" style="width: 400px">
|
<img src="screenshots/1.png" style="width: 400px">
|
||||||
|
@@ -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"
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
"History": "历史",
|
"History": "历史",
|
||||||
"Ranking": "排行",
|
"Ranking": "排行",
|
||||||
"Settings": "设置",
|
"Settings": "设置",
|
||||||
"Artworks": "插画",
|
"Artworks": "作品",
|
||||||
"Mangas": "漫画",
|
"Mangas": "漫画",
|
||||||
"Users": "用户",
|
"Users": "用户",
|
||||||
"Search artwork": "搜索作品",
|
"Search artwork": "搜索作品",
|
||||||
@@ -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" : "返回",
|
||||||
@@ -173,7 +172,17 @@
|
|||||||
"Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application": "使用外部浏览器: 可以使用Google登录. 但是, 一些浏览器可能与应用程序不兼容",
|
"Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application": "使用外部浏览器: 可以使用Google登录. 但是, 一些浏览器可能与应用程序不兼容",
|
||||||
"External browser": "外部浏览器",
|
"External browser": "外部浏览器",
|
||||||
"Show comments": "显示评论",
|
"Show comments": "显示评论",
|
||||||
"Show original image": "显示原图"
|
"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": "作品的边框将被加深"
|
||||||
},
|
},
|
||||||
"zh_TW": {
|
"zh_TW": {
|
||||||
"Search": "搜索",
|
"Search": "搜索",
|
||||||
@@ -288,7 +297,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" : "返回",
|
||||||
@@ -349,6 +357,16 @@
|
|||||||
"Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application": "使用外部瀏覽器: 可以使用Google登錄. 但是, 一些瀏覽器可能與應用程序不兼容",
|
"Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application": "使用外部瀏覽器: 可以使用Google登錄. 但是, 一些瀏覽器可能與應用程序不兼容",
|
||||||
"External browser": "外部瀏覽器",
|
"External browser": "外部瀏覽器",
|
||||||
"Show comments": "顯示評論",
|
"Show comments": "顯示評論",
|
||||||
"Show original image": "顯示原圖"
|
"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": "作品的邊框將被加深"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -36,6 +36,8 @@ class _Appdata {
|
|||||||
LogicalKeyboardKey.keyG.keyId,
|
LogicalKeyboardKey.keyG.keyId,
|
||||||
],
|
],
|
||||||
"showOriginalImage": false,
|
"showOriginalImage": false,
|
||||||
|
"checkUpdate": true,
|
||||||
|
"emphasizeArtworksFromFollowingArtists": true,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool lock = false;
|
bool lock = false;
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
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/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';
|
||||||
@@ -61,33 +63,53 @@ class _IllustWidgetState extends State<IllustWidget> {
|
|||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
|
child: Container(
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8.0, vertical: 8.0),
|
||||||
child: Container(
|
child: Container(
|
||||||
width: width,
|
width: double.infinity,
|
||||||
height: height,
|
height: double.infinity,
|
||||||
padding:
|
padding: EdgeInsets.zero,
|
||||||
const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
|
decoration: BoxDecoration(
|
||||||
child: Card(
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
margin: EdgeInsets.zero,
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: widget.onTap ??
|
|
||||||
() {
|
|
||||||
context.to(() => IllustPage(widget.illust));
|
|
||||||
},
|
|
||||||
onSecondaryTapUp: showMenu,
|
|
||||||
child: ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(4.0),
|
borderRadius: BorderRadius.circular(4.0),
|
||||||
child: AnimatedImage(
|
color: FluentTheme.of(context).cardColor,
|
||||||
image: CachedImageProvider(
|
border: () {
|
||||||
widget.illust.images.first.medium),
|
var emphasis = widget.illust.author.isFollowed &&
|
||||||
fit: BoxFit.cover,
|
appdata.settings[
|
||||||
width: width - 16.0,
|
'emphasizeArtworksFromFollowingArtists'];
|
||||||
height: height - 16.0,
|
var color = emphasis
|
||||||
|
? ColorScheme.of(context).primary
|
||||||
|
: ColorScheme.of(context)
|
||||||
|
.outlineVariant
|
||||||
|
.withOpacity(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,
|
||||||
@@ -211,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(),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -243,6 +265,12 @@ class _IllustWidgetState extends State<IllustWidget> {
|
|||||||
context.showToast(message: "Added");
|
context.showToast(message: "Added");
|
||||||
DownloadManager().addDownloadingTask(widget.illust);
|
DownloadManager().addDownloadingTask(widget.illust);
|
||||||
}),
|
}),
|
||||||
|
MenuFlyoutItem(
|
||||||
|
text: Text("Related Artworks".tl),
|
||||||
|
onPressed: () {
|
||||||
|
context.to(
|
||||||
|
() => RelatedIllustsPage(widget.illust.id.toString()));
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -320,150 +348,149 @@ class IllustHistoryWidget extends StatelessWidget {
|
|||||||
final width = constrains.maxWidth;
|
final width = constrains.maxWidth;
|
||||||
final height = illust.height * width / illust.width;
|
final height = illust.height * width / illust.width;
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
child: Container(
|
child: Container(
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
|
const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
|
||||||
child: Card(
|
child: Card(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
margin: EdgeInsets.zero,
|
margin: EdgeInsets.zero,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.to(() => IllustPageWithId(illust.id.toString()));
|
context.to(() => IllustPageWithId(illust.id.toString()));
|
||||||
},
|
},
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(4.0),
|
borderRadius: BorderRadius.circular(4.0),
|
||||||
child: AnimatedImage(
|
child: AnimatedImage(
|
||||||
image: CachedImageProvider(
|
image: CachedImageProvider(illust.imgPath),
|
||||||
illust.imgPath),
|
fit: BoxFit.cover,
|
||||||
fit: BoxFit.cover,
|
width: width - 16.0,
|
||||||
width: width - 16.0,
|
height: height - 16.0,
|
||||||
height: height - 16.0,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)),
|
),
|
||||||
if (illust.imageCount > 1)
|
)),
|
||||||
Positioned(
|
if (illust.imageCount > 1)
|
||||||
top: 12,
|
Positioned(
|
||||||
left: 12,
|
top: 12,
|
||||||
child: Container(
|
left: 12,
|
||||||
width: 28,
|
child: Container(
|
||||||
height: 20,
|
width: 28,
|
||||||
decoration: BoxDecoration(
|
height: 20,
|
||||||
color: FluentTheme.of(context)
|
decoration: BoxDecoration(
|
||||||
.micaBackgroundColor
|
color: FluentTheme.of(context)
|
||||||
.withOpacity(0.72),
|
.micaBackgroundColor
|
||||||
borderRadius: BorderRadius.circular(4),
|
.withOpacity(0.72),
|
||||||
border: Border.all(
|
borderRadius: BorderRadius.circular(4),
|
||||||
color: ColorScheme.of(context).outlineVariant,
|
border: Border.all(
|
||||||
width: 0.6),
|
color: ColorScheme.of(context).outlineVariant,
|
||||||
|
width: 0.6),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
"${illust.imageCount}P",
|
||||||
|
style: const TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
child: Center(
|
)),
|
||||||
child: Text(
|
),
|
||||||
"${illust.imageCount}P",
|
if (illust.isAi)
|
||||||
style: const TextStyle(fontSize: 12),
|
Positioned(
|
||||||
),
|
bottom: 12,
|
||||||
)),
|
left: 12,
|
||||||
),
|
child: Container(
|
||||||
if (illust.isAi)
|
width: 28,
|
||||||
Positioned(
|
height: 20,
|
||||||
bottom: 12,
|
decoration: BoxDecoration(
|
||||||
left: 12,
|
color: ColorScheme.of(context)
|
||||||
child: Container(
|
.errorContainer
|
||||||
width: 28,
|
.withOpacity(0.8),
|
||||||
height: 20,
|
borderRadius: BorderRadius.circular(4),
|
||||||
decoration: BoxDecoration(
|
border: Border.all(
|
||||||
color: ColorScheme.of(context)
|
color: ColorScheme.of(context).outlineVariant,
|
||||||
.errorContainer
|
width: 0.6),
|
||||||
.withOpacity(0.8),
|
),
|
||||||
borderRadius: BorderRadius.circular(4),
|
child: const Center(
|
||||||
border: Border.all(
|
child: Text(
|
||||||
color: ColorScheme.of(context).outlineVariant,
|
"AI",
|
||||||
width: 0.6),
|
style: TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
child: const Center(
|
)),
|
||||||
child: Text(
|
),
|
||||||
"AI",
|
if (illust.isGif)
|
||||||
style: TextStyle(fontSize: 12),
|
Positioned(
|
||||||
),
|
bottom: 12,
|
||||||
)),
|
left: 12,
|
||||||
),
|
child: Container(
|
||||||
if (illust.isGif)
|
width: 28,
|
||||||
Positioned(
|
height: 20,
|
||||||
bottom: 12,
|
decoration: BoxDecoration(
|
||||||
left: 12,
|
color: ColorScheme.of(context)
|
||||||
child: Container(
|
.primaryContainer
|
||||||
width: 28,
|
.withOpacity(0.8),
|
||||||
height: 20,
|
borderRadius: BorderRadius.circular(4),
|
||||||
decoration: BoxDecoration(
|
border: Border.all(
|
||||||
color: ColorScheme.of(context)
|
color: ColorScheme.of(context).outlineVariant,
|
||||||
.primaryContainer
|
width: 0.6),
|
||||||
.withOpacity(0.8),
|
),
|
||||||
borderRadius: BorderRadius.circular(4),
|
child: const Center(
|
||||||
border: Border.all(
|
child: Text(
|
||||||
color: ColorScheme.of(context).outlineVariant,
|
"GIF",
|
||||||
width: 0.6),
|
style: TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
child: const Center(
|
)),
|
||||||
child: Text(
|
),
|
||||||
"GIF",
|
if (illust.isR18)
|
||||||
style: TextStyle(fontSize: 12),
|
Positioned(
|
||||||
),
|
bottom: 12,
|
||||||
)),
|
right: 12,
|
||||||
),
|
child: Container(
|
||||||
if (illust.isR18)
|
width: 28,
|
||||||
Positioned(
|
height: 20,
|
||||||
bottom: 12,
|
decoration: BoxDecoration(
|
||||||
right: 12,
|
color: ColorScheme.of(context).errorContainer,
|
||||||
child: Container(
|
borderRadius: BorderRadius.circular(4),
|
||||||
width: 28,
|
border: Border.all(
|
||||||
height: 20,
|
color: ColorScheme.of(context).outlineVariant,
|
||||||
decoration: BoxDecoration(
|
width: 0.6),
|
||||||
color: ColorScheme.of(context).errorContainer,
|
),
|
||||||
borderRadius: BorderRadius.circular(4),
|
child: const Center(
|
||||||
border: Border.all(
|
child: Text(
|
||||||
color: ColorScheme.of(context).outlineVariant,
|
"R18",
|
||||||
width: 0.6),
|
style: TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
child: const Center(
|
)),
|
||||||
child: Text(
|
),
|
||||||
"R18",
|
if (illust.isR18G)
|
||||||
style: TextStyle(fontSize: 12),
|
Positioned(
|
||||||
),
|
bottom: 12,
|
||||||
)),
|
right: 12,
|
||||||
),
|
child: Container(
|
||||||
if (illust.isR18G)
|
width: 28,
|
||||||
Positioned(
|
height: 20,
|
||||||
bottom: 12,
|
decoration: BoxDecoration(
|
||||||
right: 12,
|
color: ColorScheme.of(context).errorContainer,
|
||||||
child: Container(
|
borderRadius: BorderRadius.circular(4),
|
||||||
width: 28,
|
border: Border.all(
|
||||||
height: 20,
|
color: ColorScheme.of(context).outlineVariant,
|
||||||
decoration: BoxDecoration(
|
width: 0.6),
|
||||||
color: ColorScheme.of(context).errorContainer,
|
),
|
||||||
borderRadius: BorderRadius.circular(4),
|
child: const Center(
|
||||||
border: Border.all(
|
child: Text(
|
||||||
color: ColorScheme.of(context).outlineVariant,
|
"R18G",
|
||||||
width: 0.6),
|
style: TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
child: const Center(
|
)),
|
||||||
child: Text(
|
),
|
||||||
"R18G",
|
],
|
||||||
style: TextStyle(fontSize: 12),
|
),
|
||||||
),
|
);
|
||||||
)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -40,7 +40,7 @@ class KeyEventListenerState extends State<KeyEventListener> {
|
|||||||
focusNode: focusNode,
|
focusNode: focusNode,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
onKeyEvent: (node, event) {
|
onKeyEvent: (node, event) {
|
||||||
if (event is! KeyUpEvent) return KeyEventResult.handled;
|
if (event is! KeyUpEvent) return KeyEventResult.ignored;
|
||||||
if (event.logicalKey == LogicalKeyboardKey.escape) {
|
if (event.logicalKey == LogicalKeyboardKey.escape) {
|
||||||
if (App.rootNavigatorKey.currentState?.canPop() ?? false) {
|
if (App.rootNavigatorKey.currentState?.canPop() ?? false) {
|
||||||
App.rootNavigatorKey.currentState?.pop();
|
App.rootNavigatorKey.currentState?.pop();
|
||||||
@@ -52,7 +52,7 @@ class KeyEventListenerState extends State<KeyEventListener> {
|
|||||||
for (var handler in _handlers) {
|
for (var handler in _handlers) {
|
||||||
handler(event.logicalKey);
|
handler(event.logicalKey);
|
||||||
}
|
}
|
||||||
return KeyEventResult.handled;
|
return KeyEventResult.ignored;
|
||||||
},
|
},
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
);
|
);
|
||||||
|
@@ -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) {
|
||||||
|
@@ -12,7 +12,7 @@ export "state_controller.dart";
|
|||||||
export "navigation.dart";
|
export "navigation.dart";
|
||||||
|
|
||||||
class _App {
|
class _App {
|
||||||
final version = "1.0.7";
|
final version = "1.0.9";
|
||||||
|
|
||||||
bool get isAndroid => Platform.isAndroid;
|
bool get isAndroid => Platform.isAndroid;
|
||||||
bool get isIOS => Platform.isIOS;
|
bool get isIOS => Platform.isIOS;
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import "dart:async";
|
||||||
import "dart:ui";
|
import "dart:ui";
|
||||||
|
|
||||||
import "package:dynamic_color/dynamic_color.dart";
|
import "package:dynamic_color/dynamic_color.dart";
|
||||||
@@ -18,45 +19,51 @@ 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/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: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();
|
||||||
HistoryManager().init();
|
await appdata.readData();
|
||||||
handleLinks();
|
await Translation.init();
|
||||||
if (App.isDesktop) {
|
HistoryManager().init();
|
||||||
await flutter_acrylic.Window.initialize();
|
handleLinks();
|
||||||
if (App.isWindows) {
|
if (App.isDesktop) {
|
||||||
await flutter_acrylic.Window.hideWindowControls();
|
await flutter_acrylic.Window.initialize();
|
||||||
}
|
if (App.isWindows) {
|
||||||
await WindowManager.instance.ensureInitialized();
|
await flutter_acrylic.Window.hideWindowControls();
|
||||||
windowManager.waitUntilReadyToShow().then((_) async {
|
|
||||||
await windowManager.setTitleBarStyle(
|
|
||||||
TitleBarStyle.hidden,
|
|
||||||
windowButtonVisibility: false,
|
|
||||||
);
|
|
||||||
if(App.isLinux) {
|
|
||||||
// https://github.com/leanflutter/window_manager/issues/460
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
await windowManager.setMinimumSize(const Size(500, 600));
|
await WindowManager.instance.ensureInitialized();
|
||||||
var placement = await WindowPlacement.loadFromFile();
|
windowManager.waitUntilReadyToShow().then((_) async {
|
||||||
await placement.applyToWindow();
|
await windowManager.setTitleBarStyle(
|
||||||
await windowManager.show();
|
TitleBarStyle.hidden,
|
||||||
Loop.register(WindowPlacement.loop);
|
windowButtonVisibility: false,
|
||||||
});
|
);
|
||||||
}
|
if (App.isLinux) {
|
||||||
Loop.start();
|
// https://github.com/leanflutter/window_manager/issues/460
|
||||||
Log.info("APP", "Application started");
|
return;
|
||||||
runApp(const MyApp());
|
}
|
||||||
|
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 {
|
||||||
@@ -151,7 +158,7 @@ class MyApp extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: widget,
|
child: widget,
|
||||||
);
|
);
|
||||||
} else if (App.windowsVersion == 10) {
|
} /* else if (App.windowsVersion == 10) {
|
||||||
flutter_acrylic.Window.setEffect(
|
flutter_acrylic.Window.setEffect(
|
||||||
effect: flutter_acrylic.WindowEffect.acrylic,
|
effect: flutter_acrylic.WindowEffect.acrylic,
|
||||||
dark: FluentTheme.of(context).brightness ==
|
dark: FluentTheme.of(context).brightness ==
|
||||||
@@ -164,7 +171,7 @@ class MyApp extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: widget,
|
child: widget,
|
||||||
);
|
);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return KeyEventListener(child: widget);
|
return KeyEventListener(child: widget);
|
||||||
|
@@ -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,
|
||||||
|
@@ -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
|
||||||
|
@@ -387,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(),
|
||||||
@@ -574,7 +574,7 @@ class Network {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Res<bool>> sendHistory(List<int> ids) async{
|
Future<Res<bool>> sendHistory(List<int> ids) async {
|
||||||
var res = await apiPost("/v2/user/browsing-history/illust/add",
|
var res = await apiPost("/v2/user/browsing-history/illust/add",
|
||||||
data: {"illust_ids": ids});
|
data: {"illust_ids": ids});
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
|
75
lib/network/translator.dart
Normal file
75
lib/network/translator.dart
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
import 'package:pixes/network/app_dio.dart';
|
||||||
|
|
||||||
|
abstract class Translator {
|
||||||
|
static Translator? _instance;
|
||||||
|
|
||||||
|
static Translator get instance {
|
||||||
|
if (_instance == null) {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
return _instance!;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void init() {
|
||||||
|
_instance = GoogleTranslator();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Translates the given [text] to the given [to] language.
|
||||||
|
Future<String> translate(String text, String to);
|
||||||
|
}
|
||||||
|
|
||||||
|
class GoogleTranslator implements Translator {
|
||||||
|
final Dio _dio = AppDio();
|
||||||
|
|
||||||
|
String get url => 'https://translate.google.com/translate_a/single';
|
||||||
|
|
||||||
|
Map<String, dynamic> buildBody(String text, String to) {
|
||||||
|
return {
|
||||||
|
'q': text,
|
||||||
|
'client': 'at',
|
||||||
|
'sl': 'auto',
|
||||||
|
'tl': to,
|
||||||
|
'dt': 't',
|
||||||
|
'ie': 'UTF-8',
|
||||||
|
'oe': 'UTF-8',
|
||||||
|
'dj': '1',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> translatePart(String part, String to) async {
|
||||||
|
final response = await _dio.post(
|
||||||
|
url,
|
||||||
|
data: buildBody(part, to),
|
||||||
|
options: Options(
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
var buffer = StringBuffer();
|
||||||
|
for(var e in response.data['sentences']) {
|
||||||
|
buffer.write(e['trans']);
|
||||||
|
}
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<String> translate(String text, String to) async {
|
||||||
|
final lines = text.split('\n');
|
||||||
|
var buffer = StringBuffer();
|
||||||
|
var result = '';
|
||||||
|
for(int i=0; i<lines.length; i++) {
|
||||||
|
final line = lines[i];
|
||||||
|
if (buffer.length + line.length > 5000) {
|
||||||
|
result += await translatePart(buffer.toString(), to);
|
||||||
|
buffer.clear();
|
||||||
|
}
|
||||||
|
buffer.write(line);
|
||||||
|
buffer.write('\n');
|
||||||
|
}
|
||||||
|
if (buffer.isNotEmpty) {
|
||||||
|
result += await translatePart(buffer.toString(), to);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@@ -4,7 +4,6 @@ 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/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/keyboard.dart';
|
||||||
@@ -20,6 +19,7 @@ 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/block.dart';
|
||||||
@@ -1140,7 +1140,7 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
|||||||
).fixWidth(96),
|
).fixWidth(96),
|
||||||
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,
|
||||||
@@ -1357,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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -92,7 +92,7 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
void showMenu() {
|
void showMenu() {
|
||||||
menuController.showFlyout(
|
menuController.showFlyout(
|
||||||
barrierColor: Colors.transparent,
|
barrierColor: Colors.transparent,
|
||||||
position: Offset(context.size!.width, 0),
|
position: App.isMobile ? Offset(context.size!.width, 0) : null,
|
||||||
builder: (context) => MenuFlyout(
|
builder: (context) => MenuFlyout(
|
||||||
items: [
|
items: [
|
||||||
MenuFlyoutItem(
|
MenuFlyoutItem(
|
||||||
@@ -100,7 +100,7 @@ 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();
|
||||||
}
|
}
|
||||||
@@ -113,11 +113,14 @@ 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();
|
||||||
}
|
}
|
||||||
await ImageGallerySaver.saveFile(file.path,
|
await ImageGallerySaver.saveImage(
|
||||||
|
await file.readAsBytes(),
|
||||||
|
quality: 100,
|
||||||
name: fileName);
|
name: fileName);
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
showToast(context, message: "Saved".tl);
|
showToast(context, message: "Saved".tl);
|
||||||
@@ -130,7 +133,7 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
@@ -185,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),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@@ -87,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),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
@@ -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";
|
||||||
@@ -64,13 +65,17 @@ 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());
|
||||||
@@ -80,10 +85,22 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +168,7 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
),
|
),
|
||||||
PaneItemSeparator(),
|
PaneItemSeparator(),
|
||||||
PaneItemHeader(
|
PaneItemHeader(
|
||||||
header: Text('${"Artwork".tl}/${"Manga".tl}')
|
header: Text('${"Illustrations".tl}/${"Manga".tl}')
|
||||||
.paddingBottom(4)
|
.paddingBottom(4)
|
||||||
.paddingLeft(8)),
|
.paddingLeft(8)),
|
||||||
PaneItem(
|
PaneItem(
|
||||||
@@ -209,10 +226,7 @@ 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(
|
||||||
@@ -220,7 +234,7 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
onGenerateRoute: (settings) => AppPageRoute(
|
onGenerateRoute: (settings) => AppPageRoute(
|
||||||
builder: (context) => const RecommendationPage()),
|
builder: (context) => const RecommendationPage()),
|
||||||
),
|
),
|
||||||
))),
|
)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +311,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);
|
||||||
|
},
|
||||||
|
)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -315,6 +348,24 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
: null,
|
: null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final popValue = ValueNotifier(false);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ValueListenable<bool> get canPopNotifier => popValue;
|
||||||
|
|
||||||
|
@override
|
||||||
|
PopInvokedCallback? get onPopInvoked => onPop;
|
||||||
|
|
||||||
|
void onPop(bool value) {
|
||||||
|
if (App.rootNavigatorKey.currentState?.canPop() ?? false) {
|
||||||
|
App.rootNavigatorKey.currentState?.pop();
|
||||||
|
} else if (App.mainNavigatorKey?.currentState?.canPop() ?? false) {
|
||||||
|
App.mainNavigatorKey?.currentState?.pop();
|
||||||
|
} else {
|
||||||
|
SystemNavigator.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _BackButton extends StatefulWidget {
|
class _BackButton extends StatefulWidget {
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
|
@@ -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,15 +29,36 @@ 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".tl, () {
|
action = TitleBarAction(MdIcons.tune, "Settings".tl, () {
|
||||||
if (!isShowingSettings) {
|
if (!isShowingSettings) {
|
||||||
_NovelReadingSettings.show(context, () {
|
_NovelReadingSettings.show(
|
||||||
setState(() {});
|
context,
|
||||||
}).then((value) {
|
() {
|
||||||
isShowingSettings = false;
|
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();
|
||||||
@@ -92,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:')) {
|
||||||
@@ -132,14 +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 Future show(BuildContext context, void Function() callback) {
|
final TranslationController controller;
|
||||||
return 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
|
||||||
@@ -256,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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,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),
|
||||||
],
|
],
|
||||||
|
69
lib/pages/related_page.dart
Normal file
69
lib/pages/related_page.dart
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import 'package:fluent_ui/fluent_ui.dart';
|
||||||
|
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||||
|
import 'package:pixes/components/illust_widget.dart';
|
||||||
|
import 'package:pixes/components/loading.dart';
|
||||||
|
import 'package:pixes/components/title_bar.dart';
|
||||||
|
import 'package:pixes/foundation/app.dart';
|
||||||
|
import 'package:pixes/network/network.dart';
|
||||||
|
import 'package:pixes/utils/translation.dart';
|
||||||
|
|
||||||
|
class RelatedIllustsPage extends StatefulWidget {
|
||||||
|
const RelatedIllustsPage(this.id, {super.key});
|
||||||
|
|
||||||
|
final String id;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RelatedIllustsPage> createState() => _RelatedIllustsPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RelatedIllustsPageState
|
||||||
|
extends MultiPageLoadingState<RelatedIllustsPage, Illust> {
|
||||||
|
@override
|
||||||
|
Widget? buildFrame(BuildContext context, Widget child) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
TitleBar(title: "Related artworks".tl),
|
||||||
|
Expanded(
|
||||||
|
child: child,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||||
|
return LayoutBuilder(builder: (context, constrains) {
|
||||||
|
return MasonryGridView.builder(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8) +
|
||||||
|
EdgeInsets.only(bottom: context.padding.bottom),
|
||||||
|
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
||||||
|
maxCrossAxisExtent: 240,
|
||||||
|
),
|
||||||
|
itemCount: data.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index == data.length - 1) {
|
||||||
|
nextPage();
|
||||||
|
}
|
||||||
|
return IllustWidget(data[index]);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
String? nextUrl;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Res<List<Illust>>> loadData(page) async {
|
||||||
|
if (nextUrl == "end") {
|
||||||
|
return Res.error("No more data");
|
||||||
|
}
|
||||||
|
var res = nextUrl == null
|
||||||
|
? await Network().relatedIllusts(widget.id)
|
||||||
|
: await Network().getIllustsWithNextUrl(nextUrl!);
|
||||||
|
if (!res.error) {
|
||||||
|
nextUrl = res.subData;
|
||||||
|
nextUrl ??= "end";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
@@ -100,6 +100,7 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextBox(
|
child: TextBox(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
placeholder:
|
placeholder:
|
||||||
'${searchTypes[searchType].tl} / ${"Open link".tl}',
|
'${searchTypes[searchType].tl} / ${"Open link".tl}',
|
||||||
onChanged: (s) => text = s,
|
onChanged: (s) => text = s,
|
||||||
|
@@ -182,6 +182,16 @@ 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(
|
||||||
@@ -263,6 +273,19 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||||||
});
|
});
|
||||||
appdata.writeData();
|
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();
|
||||||
|
})),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@@ -63,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(
|
||||||
@@ -228,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) {
|
||||||
@@ -239,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";
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -269,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,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -409,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) {
|
||||||
@@ -422,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;
|
||||||
|
|
||||||
@@ -534,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,
|
||||||
@@ -542,7 +554,21 @@ 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 MediaQuery.removePadding(
|
return MediaQuery.removePadding(
|
||||||
|
@@ -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();
|
||||||
|
69
lib/utils/update.dart
Normal file
69
lib/utils/update.dart
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import 'package:fluent_ui/fluent_ui.dart';
|
||||||
|
import 'package:pixes/appdata.dart';
|
||||||
|
import 'package:pixes/foundation/app.dart';
|
||||||
|
import 'package:pixes/network/app_dio.dart';
|
||||||
|
import 'package:pixes/utils/translation.dart';
|
||||||
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
|
||||||
|
Future<String> getLatestVersion() async {
|
||||||
|
var dio = AppDio();
|
||||||
|
var res = await dio
|
||||||
|
.get("https://raw.githubusercontent.com/wgh136/pixes/refs/heads/master/pubspec.yaml");
|
||||||
|
var lines = (res.data as String).split("\n");
|
||||||
|
for (var line in lines) {
|
||||||
|
if (line.startsWith("version:")) {
|
||||||
|
return line.split(":")[1].split('+')[0].trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw "Failed to get latest version";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Compare two versions.
|
||||||
|
/// Return `true` if `a` is greater than `b`.
|
||||||
|
bool compareVersion(String a, String b) {
|
||||||
|
var aList = a.split(".").map(int.parse).toList();
|
||||||
|
var bList = b.split(".").map(int.parse).toList();
|
||||||
|
for (var i = 0; i < aList.length; i++) {
|
||||||
|
if (aList[i] > bList[i]) {
|
||||||
|
return true;
|
||||||
|
} else if (aList[i] < bList[i]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> checkUpdate() async {
|
||||||
|
if (appdata.account == null) return;
|
||||||
|
try {
|
||||||
|
var latestVersion = await getLatestVersion();
|
||||||
|
if (compareVersion(latestVersion, App.version)) {
|
||||||
|
showDialog(
|
||||||
|
context: App.rootNavigatorKey.currentContext!,
|
||||||
|
builder: (context) => ContentDialog(
|
||||||
|
title: Text("New version available".tl),
|
||||||
|
content: Text(
|
||||||
|
"A new version of Pixes is available. Do you want to update now?"
|
||||||
|
.tl,
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
Button(
|
||||||
|
child: Text("Cancel".tl),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
FilledButton(
|
||||||
|
child: Text("Update".tl),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
launchUrlString(
|
||||||
|
"https://github.com/wgh136/pixes/releases/latest");
|
||||||
|
})
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
27
pubspec.lock
27
pubspec.lock
@@ -256,6 +256,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: HEAD
|
||||||
|
resolved-ref: b7378b7bda0b71cbc7d103f5afa24bce19be145c
|
||||||
|
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
|
||||||
@@ -302,6 +311,14 @@ 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"
|
||||||
leak_tracker:
|
leak_tracker:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -740,6 +757,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.3.4 <4.0.0"
|
||||||
flutter: ">=3.19.0"
|
flutter: ">=3.22.3"
|
||||||
|
16
pubspec.yaml
16
pubspec.yaml
@@ -16,10 +16,11 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# 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.7+107
|
version: 1.0.9+109
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.3.4 <4.0.0'
|
sdk: '>=3.3.4 <4.0.0'
|
||||||
|
flutter: 3.22.3
|
||||||
|
|
||||||
# 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
|
||||||
@@ -72,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:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user