10 Commits

Author SHA1 Message Date
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
20 changed files with 538 additions and 289 deletions

View File

@@ -2,14 +2,48 @@
[![flutter](https://img.shields.io/badge/flutter-3.22.1-blue)](https://flutter.dev/) [![flutter](https://img.shields.io/badge/flutter-3.22.1-blue)](https://flutter.dev/)
[![License](https://img.shields.io/github/license/wgh136/pixes)](https://github.com/wgh136/pixes/blob/master/LICENSE) [![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/PicaComic/pixes) [![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) [![stars](https://img.shields.io/github/stars/wgh136/pixes)](https://github.com/wgh136/pixes/stargazers)
[![Telegram Discussion](https://img.shields.io/static/v1?label=Discussion&message=Telegram&color=blue&logo=telegram)](https://t.me/pica_group) [![Telegram Discussion](https://img.shields.io/static/v1?label=Discussion&message=Telegram&color=blue&logo=telegram)](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">

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"

View File

@@ -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": "作品的邊框將被加深"
} }
} }

View File

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

View File

@@ -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';
@@ -66,8 +68,22 @@ class _IllustWidgetState extends State<IllustWidget> {
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: Container(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.0),
border: () {
var emphasis = widget.illust.author.isFollowed &&
appdata.settings[
'emphasizeArtworksFromFollowingArtists'];
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, margin: EdgeInsets.zero,
child: GestureDetector( child: GestureDetector(
onTap: widget.onTap ?? onTap: widget.onTap ??
@@ -75,6 +91,7 @@ class _IllustWidgetState extends State<IllustWidget> {
context.to(() => IllustPage(widget.illust)); context.to(() => IllustPage(widget.illust));
}, },
onSecondaryTapUp: showMenu, onSecondaryTapUp: showMenu,
onLongPress: showMenu,
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(4.0), borderRadius: BorderRadius.circular(4.0),
child: AnimatedImage( child: AnimatedImage(
@@ -211,13 +228,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 +260,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 +343,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), ),
), );
)),
),
],
),
);
}); });
} }
} }

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

@@ -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.8";
bool get isAndroid => Platform.isAndroid; bool get isAndroid => Platform.isAndroid;
bool get isIOS => Platform.isIOS; bool get isIOS => Platform.isIOS;

View File

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

View File

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

View File

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

View File

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

View File

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

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";
@@ -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()),
), ),
))), )),
); );
} }
@@ -315,6 +329,25 @@ 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) {
print("ok");
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 {

View File

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

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

@@ -33,6 +33,8 @@ class _SearchPageState extends State<SearchPage> {
int searchType = 0; int searchType = 0;
final focusNode = FocusNode();
static const searchTypes = [ static const searchTypes = [
"Search artwork", "Search artwork",
"Search novel", "Search novel",
@@ -100,6 +102,9 @@ class _SearchPageState extends State<SearchPage> {
children: [ children: [
Expanded( Expanded(
child: TextBox( child: TextBox(
focusNode: focusNode,
autofocus: false,
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,

View File

@@ -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();
})),
], ],
), ),
); );

View File

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

63
lib/utils/update.dart Normal file
View File

@@ -0,0 +1,63 @@
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://api.github.com/repos/wgh136/pixes/releases/latest");
return (res.data["tag_name"] as String).replaceFirst("v", "");
}
/// 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
}
}

View File

@@ -16,7 +16,7 @@ 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.8+108
environment: environment:
sdk: '>=3.3.4 <4.0.0' sdk: '>=3.3.4 <4.0.0'