mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-28 05:17:24 +00:00
Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
49da2b772b | ||
![]() |
4dc1ec8784 | ||
![]() |
1fad3694cf | ||
![]() |
39eb5c836e | ||
![]() |
9603706fc6 | ||
![]() |
343e993627 | ||
![]() |
246f96bdbf | ||
![]() |
61c6ed0e1b | ||
![]() |
fd63b02b60 | ||
![]() |
9275024050 | ||
![]() |
5e53c57755 | ||
![]() |
6a95fb37ed | ||
![]() |
20829e1ad5 | ||
![]() |
cb356dbf71 | ||
![]() |
9ad6207bd5 | ||
![]() |
676e7508c7 | ||
![]() |
1652a93772 | ||
![]() |
e6d015a2bc | ||
![]() |
35dd9dee5f | ||
![]() |
b34a8342d2 | ||
![]() |
0ed17edd3e | ||
![]() |
187e5f9a09 | ||
![]() |
9505b78ae4 | ||
![]() |
1d49f1c387 | ||
![]() |
7641cc8f5c | ||
![]() |
de26cba0fa | ||
![]() |
471b319891 | ||
![]() |
1a224114fc |
15
.vscode/settings.json
vendored
Normal file
15
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"cSpell.words": [
|
||||||
|
"appdata",
|
||||||
|
"Bungo",
|
||||||
|
"gjzr",
|
||||||
|
"microtask",
|
||||||
|
"mypixiv",
|
||||||
|
"pawoo",
|
||||||
|
"Rorigod",
|
||||||
|
"sleepinglife",
|
||||||
|
"Ugoira",
|
||||||
|
"vocaloidhm",
|
||||||
|
"vsync"
|
||||||
|
]
|
||||||
|
}
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2024 nyne
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
@@ -33,6 +33,15 @@
|
|||||||
<!-- Accepts URIs that begin with "example://gizmos” -->
|
<!-- Accepts URIs that begin with "example://gizmos” -->
|
||||||
<data android:scheme="pixiv"/>
|
<data android:scheme="pixiv"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data android:scheme="https" android:host="www.pixiv.net" android:pathPrefix="/users"/>
|
||||||
|
<data android:scheme="https" android:host="www.pixiv.net" android:pathPrefix="/novel"/>
|
||||||
|
<data android:scheme="https" android:host="www.pixiv.net" android:pathPrefix="/tags"/>
|
||||||
|
<data android:scheme="https" android:host="www.pixiv.net" android:pathPrefix="/artworks"/>
|
||||||
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<!-- Don't delete the meta-data below.
|
<!-- Don't delete the meta-data below.
|
||||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||||
|
@@ -3,14 +3,14 @@
|
|||||||
"Search": "搜索",
|
"Search": "搜索",
|
||||||
"Downloading": "下载中",
|
"Downloading": "下载中",
|
||||||
"Downloaded": "已下载",
|
"Downloaded": "已下载",
|
||||||
"Artwork": "作品",
|
"Artwork": "插画",
|
||||||
"Explore": "探索",
|
"Explore": "探索",
|
||||||
"Bookmarks": "收藏",
|
"Bookmarks": "收藏",
|
||||||
"Following": "关注",
|
"Following": "关注",
|
||||||
"History": "历史",
|
"History": "历史",
|
||||||
"Ranking": "排行",
|
"Ranking": "排行",
|
||||||
"Settings": "设置",
|
"Settings": "设置",
|
||||||
"Artworks": "作品",
|
"Artworks": "插画",
|
||||||
"Mangas": "漫画",
|
"Mangas": "漫画",
|
||||||
"Users": "用户",
|
"Users": "用户",
|
||||||
"Search artwork": "搜索作品",
|
"Search artwork": "搜索作品",
|
||||||
@@ -64,9 +64,9 @@
|
|||||||
"Weekly Manga": "每周漫画",
|
"Weekly Manga": "每周漫画",
|
||||||
"Monthly Manga": "每月漫画",
|
"Monthly Manga": "每月漫画",
|
||||||
"R18": "R18",
|
"R18": "R18",
|
||||||
"Account": "账户",
|
"Account": "账号",
|
||||||
"Logout": "登出",
|
"Logout": "登出",
|
||||||
"Account Settings": "账户设置",
|
"Account Settings": "账号设置",
|
||||||
"Edit": "编辑",
|
"Edit": "编辑",
|
||||||
"Download": "下载",
|
"Download": "下载",
|
||||||
"Manage": "管理",
|
"Manage": "管理",
|
||||||
@@ -138,7 +138,31 @@
|
|||||||
"Line Height": "行高",
|
"Line Height": "行高",
|
||||||
"Paragraph Spacing": "段间距",
|
"Paragraph Spacing": "段间距",
|
||||||
"light": "浅色",
|
"light": "浅色",
|
||||||
"dark": "深色"
|
"dark": "深色",
|
||||||
|
"block": "屏蔽",
|
||||||
|
"Block": "屏蔽",
|
||||||
|
"Block(Account)": "屏蔽(账号)",
|
||||||
|
"Block(Local)": "屏蔽(本地)",
|
||||||
|
"Add": "添加",
|
||||||
|
"Submit": "提交",
|
||||||
|
"Local": "本地",
|
||||||
|
"Both": "同时",
|
||||||
|
"This artwork is blocked": "此作品已被屏蔽",
|
||||||
|
"Delete Invalid Items": "删除无效项目",
|
||||||
|
"Private Favorite": "私人收藏",
|
||||||
|
"Shortcuts": "快捷键",
|
||||||
|
"Page down": "向下翻页",
|
||||||
|
"Page up": "向上翻页",
|
||||||
|
"Next work": "下一作品",
|
||||||
|
"Previous work": "上一作品",
|
||||||
|
"Add to favorites": "添加收藏",
|
||||||
|
"Follow the artist": "关注画师",
|
||||||
|
"Manga": "漫画",
|
||||||
|
"Actions": "操作",
|
||||||
|
"Current quantity": "当前数量",
|
||||||
|
"Display the original image on the details page": "在详情页显示原图",
|
||||||
|
"Open link": "打开链接",
|
||||||
|
"Read": "阅读"
|
||||||
},
|
},
|
||||||
"zh_TW": {
|
"zh_TW": {
|
||||||
"Search": "搜索",
|
"Search": "搜索",
|
||||||
@@ -279,6 +303,30 @@
|
|||||||
"Line Height": "行高",
|
"Line Height": "行高",
|
||||||
"Paragraph Spacing": "段間距",
|
"Paragraph Spacing": "段間距",
|
||||||
"light": "淺色",
|
"light": "淺色",
|
||||||
"dark": "深色"
|
"dark": "深色",
|
||||||
|
"block": "屏蔽",
|
||||||
|
"Block": "屏蔽",
|
||||||
|
"Block(Account)": "屏蔽(賬戶)",
|
||||||
|
"Block(Local)": "屏蔽(本地)",
|
||||||
|
"Add": "添加",
|
||||||
|
"Submit": "提交",
|
||||||
|
"Local": "本地",
|
||||||
|
"Both": "同時",
|
||||||
|
"This artwork is blocked": "此作品已被屏蔽",
|
||||||
|
"Delete Invalid Items": "刪除無效項目",
|
||||||
|
"Private Favorite": "私人收藏",
|
||||||
|
"Shortcuts": "快捷鍵",
|
||||||
|
"Page down": "向下翻頁",
|
||||||
|
"Page up": "向上翻頁",
|
||||||
|
"Next work": "下一作品",
|
||||||
|
"Previous work": "上一作品",
|
||||||
|
"Add to favorites": "添加收藏",
|
||||||
|
"Follow the artist": "關注畫師",
|
||||||
|
"Manga": "漫畫",
|
||||||
|
"Actions": "操作",
|
||||||
|
"Current quantity": "當前數量",
|
||||||
|
"Display the original image on the details page": "在詳情頁顯示原圖",
|
||||||
|
"Open link": "打開鏈接",
|
||||||
|
"Read": "閱讀"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -23,6 +23,17 @@ class _Appdata {
|
|||||||
"readingFontSize": 16.0,
|
"readingFontSize": 16.0,
|
||||||
"readingLineHeight": 1.5,
|
"readingLineHeight": 1.5,
|
||||||
"readingParagraphSpacing": 8.0,
|
"readingParagraphSpacing": 8.0,
|
||||||
|
"blockTags": [],
|
||||||
|
"shortcuts": <int>[
|
||||||
|
LogicalKeyboardKey.arrowDown.keyId,
|
||||||
|
LogicalKeyboardKey.arrowUp.keyId,
|
||||||
|
LogicalKeyboardKey.arrowRight.keyId,
|
||||||
|
LogicalKeyboardKey.arrowLeft.keyId,
|
||||||
|
LogicalKeyboardKey.enter.keyId,
|
||||||
|
LogicalKeyboardKey.keyD.keyId,
|
||||||
|
LogicalKeyboardKey.keyF.keyId,
|
||||||
|
],
|
||||||
|
"showOriginalImage": false,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool lock = false;
|
bool lock = false;
|
||||||
|
@@ -15,7 +15,10 @@ class BatchDownloadButton extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Button(
|
return Button(
|
||||||
child: const Icon(MdIcons.download, size: 20,),
|
child: const Icon(
|
||||||
|
MdIcons.download,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -40,6 +43,8 @@ class _DownloadDialog extends StatefulWidget {
|
|||||||
class _DownloadDialogState extends State<_DownloadDialog> {
|
class _DownloadDialogState extends State<_DownloadDialog> {
|
||||||
int maxCount = 30;
|
int maxCount = 30;
|
||||||
|
|
||||||
|
int currentCount = 0;
|
||||||
|
|
||||||
bool loading = false;
|
bool loading = false;
|
||||||
|
|
||||||
bool cancel = false;
|
bool cancel = false;
|
||||||
@@ -53,15 +58,18 @@ class _DownloadDialogState extends State<_DownloadDialog> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text('${"Maximum number of downloads".tl}:'),
|
if (!loading) Text('${"Maximum number of downloads".tl}:'),
|
||||||
const SizedBox(height: 16,),
|
if (loading) Text("${"Current quantity".tl}: $currentCount"),
|
||||||
|
const SizedBox(
|
||||||
|
height: 16,
|
||||||
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 42,
|
height: 42,
|
||||||
width: 196,
|
width: 196,
|
||||||
child: NumberBox(
|
child: NumberBox(
|
||||||
value: maxCount,
|
value: maxCount,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
if(!loading) {
|
if (!loading) {
|
||||||
setState(() => maxCount = value ?? maxCount);
|
setState(() => maxCount = value ?? maxCount);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -71,35 +79,39 @@ class _DownloadDialogState extends State<_DownloadDialog> {
|
|||||||
largeChange: 30,
|
largeChange: 30,
|
||||||
clearButton: false,
|
clearButton: false,
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
).paddingVertical(8),
|
).paddingVertical(8),
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
Button(child: Text("Cancel".tl), onPressed: () {
|
Button(
|
||||||
cancel = true;
|
child: Text("Cancel".tl),
|
||||||
context.pop();
|
onPressed: () {
|
||||||
}),
|
cancel = true;
|
||||||
if(!loading)
|
context.pop();
|
||||||
|
}),
|
||||||
|
if (!loading)
|
||||||
FilledButton(onPressed: load, child: Text("Continue".tl))
|
FilledButton(onPressed: load, child: Text("Continue".tl))
|
||||||
else
|
else
|
||||||
FilledButton(onPressed: (){}, child: const SizedBox(
|
FilledButton(
|
||||||
height: 20,
|
onPressed: () {},
|
||||||
width: 64,
|
child: const SizedBox(
|
||||||
child: Center(
|
height: 20,
|
||||||
child: SizedBox.square(
|
width: 64,
|
||||||
dimension: 18,
|
child: Center(
|
||||||
child: ProgressRing(
|
child: SizedBox.square(
|
||||||
strokeWidth: 1.6,
|
dimension: 18,
|
||||||
|
child: ProgressRing(
|
||||||
|
strokeWidth: 1.6,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
))
|
||||||
),
|
|
||||||
))
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void load() async{
|
void load() async {
|
||||||
setState(() {
|
setState(() {
|
||||||
loading = true;
|
loading = true;
|
||||||
});
|
});
|
||||||
@@ -109,17 +121,17 @@ class _DownloadDialogState extends State<_DownloadDialog> {
|
|||||||
List<Illust> all = [];
|
List<Illust> all = [];
|
||||||
String? nextUrl;
|
String? nextUrl;
|
||||||
int retryCount = 0;
|
int retryCount = 0;
|
||||||
while(nextUrl != "end" && all.length < maxCount) {
|
while (nextUrl != "end" && all.length < maxCount) {
|
||||||
if(nextUrl != null) {
|
if (nextUrl != null) {
|
||||||
request = Network().getIllustsWithNextUrl(nextUrl);
|
request = Network().getIllustsWithNextUrl(nextUrl);
|
||||||
}
|
}
|
||||||
var res = await request;
|
var res = await request;
|
||||||
if(cancel || !mounted) {
|
if (cancel || !mounted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(res.error) {
|
if (res.error) {
|
||||||
retryCount++;
|
retryCount++;
|
||||||
if(retryCount > 3) {
|
if (retryCount > 3) {
|
||||||
setState(() {
|
setState(() {
|
||||||
loading = false;
|
loading = false;
|
||||||
});
|
});
|
||||||
@@ -130,15 +142,17 @@ class _DownloadDialogState extends State<_DownloadDialog> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
all.addAll(res.data);
|
all.addAll(res.data);
|
||||||
|
setState(() {
|
||||||
|
currentCount = all.length;
|
||||||
|
});
|
||||||
nextUrl = res.subData ?? "end";
|
nextUrl = res.subData ?? "end";
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(var illust in all) {
|
for (var illust in all) {
|
||||||
if(i > maxCount) return;
|
if (i > maxCount) break;
|
||||||
DownloadManager().addDownloadingTask(illust);
|
DownloadManager().addDownloadingTask(illust);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
context.pop();
|
context.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -92,6 +92,17 @@ class SliverGridDelegateWithFixedHeight extends SliverGridDelegate {
|
|||||||
int calcCrossItemsCount(double width) {
|
int calcCrossItemsCount(double width) {
|
||||||
int count = 20;
|
int count = 20;
|
||||||
var itemWidth = width / 20;
|
var itemWidth = width / 20;
|
||||||
|
|
||||||
|
if(minCrossAxisExtent == 0) {
|
||||||
|
count = 1;
|
||||||
|
itemWidth = width;
|
||||||
|
while(itemWidth > maxCrossAxisExtent) {
|
||||||
|
count++;
|
||||||
|
itemWidth = width / count;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
while (
|
while (
|
||||||
!(itemWidth > minCrossAxisExtent && itemWidth < maxCrossAxisExtent)) {
|
!(itemWidth > minCrossAxisExtent && itemWidth < maxCrossAxisExtent)) {
|
||||||
count--;
|
count--;
|
||||||
|
@@ -9,6 +9,8 @@ import '../network/network.dart';
|
|||||||
import '../pages/illust_page.dart';
|
import '../pages/illust_page.dart';
|
||||||
import 'md.dart';
|
import 'md.dart';
|
||||||
|
|
||||||
|
typedef UpdateFavoriteFunc = void Function(bool v);
|
||||||
|
|
||||||
class IllustWidget extends StatefulWidget {
|
class IllustWidget extends StatefulWidget {
|
||||||
const IllustWidget(this.illust, {this.onTap, super.key});
|
const IllustWidget(this.illust, {this.onTap, super.key});
|
||||||
|
|
||||||
@@ -16,6 +18,8 @@ class IllustWidget extends StatefulWidget {
|
|||||||
|
|
||||||
final void Function()? onTap;
|
final void Function()? onTap;
|
||||||
|
|
||||||
|
static Map<String, UpdateFavoriteFunc> favoriteCallbacks = {};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<IllustWidget> createState() => _IllustWidgetState();
|
State<IllustWidget> createState() => _IllustWidgetState();
|
||||||
}
|
}
|
||||||
@@ -26,6 +30,22 @@ class _IllustWidgetState extends State<IllustWidget> {
|
|||||||
final contextController = FlyoutController();
|
final contextController = FlyoutController();
|
||||||
final contextAttachKey = GlobalKey();
|
final contextAttachKey = GlobalKey();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
IllustWidget.favoriteCallbacks[widget.illust.id.toString()] = (v) {
|
||||||
|
setState(() {
|
||||||
|
widget.illust.isBookmarked = v;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
IllustWidget.favoriteCallbacks.remove(widget.illust.id.toString());
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return LayoutBuilder(builder: (context, constrains) {
|
return LayoutBuilder(builder: (context, constrains) {
|
||||||
@@ -39,52 +59,58 @@ class _IllustWidgetState extends State<IllustWidget> {
|
|||||||
height: height,
|
height: height,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Positioned.fill(child: Container(
|
Positioned.fill(
|
||||||
|
child: Container(
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
|
padding:
|
||||||
|
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: widget.onTap ?? (){
|
onTap: widget.onTap ??
|
||||||
context.to(() => IllustPage(widget.illust, favoriteCallback: (v) {
|
() {
|
||||||
setState(() {
|
context.to(() => IllustPage(widget.illust));
|
||||||
widget.illust.isBookmarked = v;
|
},
|
||||||
});
|
|
||||||
},));
|
|
||||||
},
|
|
||||||
onSecondaryTapUp: showMenu,
|
onSecondaryTapUp: showMenu,
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(4.0),
|
borderRadius: BorderRadius.circular(4.0),
|
||||||
child: AnimatedImage(
|
child: AnimatedImage(
|
||||||
image: CachedImageProvider(widget.illust.images.first.medium),
|
image: CachedImageProvider(
|
||||||
|
widget.illust.images.first.medium),
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
width: width-16.0,
|
width: width - 16.0,
|
||||||
height: height-16.0,
|
height: height - 16.0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
if(widget.illust.images.length > 1)
|
if (widget.illust.images.length > 1)
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 12,
|
top: 12,
|
||||||
left: 12,
|
left: 12,
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 28,
|
width: 28,
|
||||||
height: 20,
|
height: 20,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: FluentTheme.of(context).cardColor,
|
color: FluentTheme.of(context)
|
||||||
borderRadius: BorderRadius.circular(4),
|
.micaBackgroundColor
|
||||||
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6),
|
.withOpacity(0.72),
|
||||||
),
|
borderRadius: BorderRadius.circular(4),
|
||||||
child: Center(
|
border: Border.all(
|
||||||
child: Text("${widget.illust.images.length}P",
|
color: ColorScheme.of(context).outlineVariant,
|
||||||
style: const TextStyle(fontSize: 12),),
|
width: 0.6),
|
||||||
)),
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
"${widget.illust.images.length}P",
|
||||||
|
style: const TextStyle(fontSize: 12),
|
||||||
|
),
|
||||||
|
)),
|
||||||
),
|
),
|
||||||
if(widget.illust.isAi)
|
if (widget.illust.isAi)
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 12,
|
bottom: 12,
|
||||||
left: 12,
|
left: 12,
|
||||||
@@ -92,16 +118,22 @@ class _IllustWidgetState extends State<IllustWidget> {
|
|||||||
width: 28,
|
width: 28,
|
||||||
height: 20,
|
height: 20,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: ColorScheme.of(context).errorContainer.withOpacity(0.8),
|
color: ColorScheme.of(context)
|
||||||
|
.errorContainer
|
||||||
|
.withOpacity(0.8),
|
||||||
borderRadius: BorderRadius.circular(4),
|
borderRadius: BorderRadius.circular(4),
|
||||||
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6),
|
border: Border.all(
|
||||||
|
color: ColorScheme.of(context).outlineVariant,
|
||||||
|
width: 0.6),
|
||||||
),
|
),
|
||||||
child: const Center(
|
child: const Center(
|
||||||
child: Text("AI",
|
child: Text(
|
||||||
style: TextStyle(fontSize: 12),),
|
"AI",
|
||||||
|
style: TextStyle(fontSize: 12),
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
if(widget.illust.isUgoira)
|
if (widget.illust.isUgoira)
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 12,
|
bottom: 12,
|
||||||
left: 12,
|
left: 12,
|
||||||
@@ -109,16 +141,22 @@ class _IllustWidgetState extends State<IllustWidget> {
|
|||||||
width: 28,
|
width: 28,
|
||||||
height: 20,
|
height: 20,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: ColorScheme.of(context).primaryContainer.withOpacity(0.8),
|
color: ColorScheme.of(context)
|
||||||
|
.primaryContainer
|
||||||
|
.withOpacity(0.8),
|
||||||
borderRadius: BorderRadius.circular(4),
|
borderRadius: BorderRadius.circular(4),
|
||||||
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6),
|
border: Border.all(
|
||||||
|
color: ColorScheme.of(context).outlineVariant,
|
||||||
|
width: 0.6),
|
||||||
),
|
),
|
||||||
child: const Center(
|
child: const Center(
|
||||||
child: Text("GIF",
|
child: Text(
|
||||||
style: TextStyle(fontSize: 12),),
|
"GIF",
|
||||||
|
style: TextStyle(fontSize: 12),
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
if(widget.illust.isR18)
|
if (widget.illust.isR18)
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 12,
|
bottom: 12,
|
||||||
right: 12,
|
right: 12,
|
||||||
@@ -128,14 +166,18 @@ class _IllustWidgetState extends State<IllustWidget> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: ColorScheme.of(context).errorContainer,
|
color: ColorScheme.of(context).errorContainer,
|
||||||
borderRadius: BorderRadius.circular(4),
|
borderRadius: BorderRadius.circular(4),
|
||||||
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6),
|
border: Border.all(
|
||||||
|
color: ColorScheme.of(context).outlineVariant,
|
||||||
|
width: 0.6),
|
||||||
),
|
),
|
||||||
child: const Center(
|
child: const Center(
|
||||||
child: Text("R18",
|
child: Text(
|
||||||
style: TextStyle(fontSize: 12),),
|
"R18",
|
||||||
|
style: TextStyle(fontSize: 12),
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
if(widget.illust.isR18G)
|
if (widget.illust.isR18G)
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 12,
|
bottom: 12,
|
||||||
right: 12,
|
right: 12,
|
||||||
@@ -145,11 +187,15 @@ class _IllustWidgetState extends State<IllustWidget> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: ColorScheme.of(context).errorContainer,
|
color: ColorScheme.of(context).errorContainer,
|
||||||
borderRadius: BorderRadius.circular(4),
|
borderRadius: BorderRadius.circular(4),
|
||||||
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6),
|
border: Border.all(
|
||||||
|
color: ColorScheme.of(context).outlineVariant,
|
||||||
|
width: 0.6),
|
||||||
),
|
),
|
||||||
child: const Center(
|
child: const Center(
|
||||||
child: Text("R18G",
|
child: Text(
|
||||||
style: TextStyle(fontSize: 12),),
|
"R18G",
|
||||||
|
style: TextStyle(fontSize: 12),
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
@@ -180,35 +226,38 @@ class _IllustWidgetState extends State<IllustWidget> {
|
|||||||
builder: (context) {
|
builder: (context) {
|
||||||
return MenuFlyout(
|
return MenuFlyout(
|
||||||
items: [
|
items: [
|
||||||
MenuFlyoutItem(text: Text("View".tl), onPressed: (){
|
MenuFlyoutItem(
|
||||||
context.to(() => IllustPage(widget.illust, favoriteCallback: (v) {
|
text: Text("View".tl),
|
||||||
setState(() {
|
onPressed: () {
|
||||||
widget.illust.isBookmarked = v;
|
context.to(() => IllustPage(widget.illust));
|
||||||
});
|
}),
|
||||||
},));
|
MenuFlyoutItem(
|
||||||
}),
|
text: Text("Private Favorite".tl),
|
||||||
MenuFlyoutItem(text: Text("Private Favorite".tl), onPressed: (){
|
onPressed: () {
|
||||||
favorite("private");
|
favorite("private");
|
||||||
}),
|
}),
|
||||||
MenuFlyoutItem(text: Text("Download".tl), onPressed: (){
|
MenuFlyoutItem(
|
||||||
context.showToast(message: "Added");
|
text: Text("Download".tl),
|
||||||
DownloadManager().addDownloadingTask(widget.illust);
|
onPressed: () {
|
||||||
}),
|
context.showToast(message: "Added");
|
||||||
|
DownloadManager().addDownloadingTask(widget.illust);
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void favorite([String type = "public"]) async{
|
void favorite([String type = "public"]) async {
|
||||||
if(isBookmarking) return;
|
if (isBookmarking) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
isBookmarking = true;
|
isBookmarking = true;
|
||||||
});
|
});
|
||||||
var method = widget.illust.isBookmarked ? "delete" : "add";
|
var method = widget.illust.isBookmarked ? "delete" : "add";
|
||||||
var res = await Network().addBookmark(widget.illust.id.toString(), method, type);
|
var res =
|
||||||
if(res.error) {
|
await Network().addBookmark(widget.illust.id.toString(), method, type);
|
||||||
if(mounted) {
|
if (res.error) {
|
||||||
|
if (mounted) {
|
||||||
context.showToast(message: "Network Error");
|
context.showToast(message: "Network Error");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -221,16 +270,18 @@ class _IllustWidgetState extends State<IllustWidget> {
|
|||||||
|
|
||||||
Widget buildButton() {
|
Widget buildButton() {
|
||||||
Widget child;
|
Widget child;
|
||||||
if(isBookmarking) {
|
if (isBookmarking) {
|
||||||
child = const SizedBox(
|
child = const SizedBox(
|
||||||
width: 14,
|
width: 14,
|
||||||
height: 14,
|
height: 14,
|
||||||
child: ProgressRing(strokeWidth: 1.6,),
|
child: ProgressRing(
|
||||||
|
strokeWidth: 1.6,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else if(widget.illust.isBookmarked) {
|
} else if (widget.illust.isBookmarked) {
|
||||||
child = Icon(
|
child = Icon(
|
||||||
MdIcons.favorite,
|
MdIcons.favorite,
|
||||||
color: ColorScheme.of(context).error,
|
color: Colors.red,
|
||||||
size: 22,
|
size: 22,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
61
lib/components/keyboard.dart
Normal file
61
lib/components/keyboard.dart
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:pixes/foundation/app.dart';
|
||||||
|
|
||||||
|
typedef KeyEventHandler = void Function(LogicalKeyboardKey key);
|
||||||
|
|
||||||
|
class KeyEventListener extends StatefulWidget {
|
||||||
|
const KeyEventListener({required this.child, super.key});
|
||||||
|
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
static KeyEventListenerState? of(BuildContext context) {
|
||||||
|
return context.findAncestorStateOfType<KeyEventListenerState>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<KeyEventListener> createState() => KeyEventListenerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class KeyEventListenerState extends State<KeyEventListener> {
|
||||||
|
final focusNode = FocusNode();
|
||||||
|
|
||||||
|
final List<KeyEventHandler> _handlers = [];
|
||||||
|
|
||||||
|
void addHandler(KeyEventHandler handler) {
|
||||||
|
_handlers.add(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeHandler(KeyEventHandler handler) {
|
||||||
|
_handlers.remove(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeAll() {
|
||||||
|
_handlers.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Focus(
|
||||||
|
focusNode: focusNode,
|
||||||
|
autofocus: true,
|
||||||
|
onKeyEvent: (node, event) {
|
||||||
|
if (event is! KeyUpEvent) return KeyEventResult.ignored;
|
||||||
|
if (event.logicalKey == LogicalKeyboardKey.escape) {
|
||||||
|
if (App.rootNavigatorKey.currentState?.canPop() ?? false) {
|
||||||
|
App.rootNavigatorKey.currentState?.pop();
|
||||||
|
}
|
||||||
|
if (App.mainNavigatorKey?.currentState?.canPop() ?? false) {
|
||||||
|
App.mainNavigatorKey?.currentState?.pop();
|
||||||
|
}
|
||||||
|
return KeyEventResult.handled;
|
||||||
|
}
|
||||||
|
for (var handler in _handlers) {
|
||||||
|
handler(event.logicalKey);
|
||||||
|
}
|
||||||
|
return KeyEventResult.handled;
|
||||||
|
},
|
||||||
|
child: widget.child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -108,7 +108,7 @@ abstract class MultiPageLoadingState<T extends StatefulWidget, S extends Object>
|
|||||||
|
|
||||||
Widget? buildFrame(BuildContext context, Widget child) => null;
|
Widget? buildFrame(BuildContext context, Widget child) => null;
|
||||||
|
|
||||||
Widget buildContent(BuildContext context, final List<S> data);
|
Widget buildContent(BuildContext context, List<S> data);
|
||||||
|
|
||||||
bool get isLoading => _isLoading || _isFirstLoading;
|
bool get isLoading => _isLoading || _isFirstLoading;
|
||||||
|
|
||||||
|
@@ -328,11 +328,15 @@ class SideBarRoute<T> extends PopupRoute<T> {
|
|||||||
bottom: 0,
|
bottom: 0,
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: FluentTheme.of(context).micaBackgroundColor.withOpacity(0.98),
|
color: FluentTheme.of(context)
|
||||||
borderRadius: const BorderRadius.only(topLeft: Radius.circular(4), bottomLeft: Radius.circular(4))
|
.micaBackgroundColor
|
||||||
),
|
.withOpacity(0.98),
|
||||||
constraints: BoxConstraints(maxWidth: min(_kSideBarWidth,
|
borderRadius: const BorderRadius.only(
|
||||||
MediaQuery.of(context).size.width)),
|
topLeft: Radius.circular(4),
|
||||||
|
bottomLeft: Radius.circular(4))),
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxWidth:
|
||||||
|
min(_kSideBarWidth, MediaQuery.of(context).size.width)),
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
|
@@ -4,22 +4,43 @@ import 'package:fluent_ui/fluent_ui.dart';
|
|||||||
import 'package:pixes/components/animated_image.dart';
|
import 'package:pixes/components/animated_image.dart';
|
||||||
import 'package:pixes/foundation/app.dart';
|
import 'package:pixes/foundation/app.dart';
|
||||||
import 'package:pixes/foundation/image_provider.dart';
|
import 'package:pixes/foundation/image_provider.dart';
|
||||||
|
import 'package:pixes/pages/illust_page.dart';
|
||||||
import 'package:pixes/pages/user_info_page.dart';
|
import 'package:pixes/pages/user_info_page.dart';
|
||||||
import 'package:pixes/utils/translation.dart';
|
import 'package:pixes/utils/translation.dart';
|
||||||
|
|
||||||
import '../network/network.dart';
|
import '../network/network.dart';
|
||||||
import 'md.dart';
|
import 'md.dart';
|
||||||
|
|
||||||
|
typedef UpdateFollowCallback = void Function(bool isFollowed);
|
||||||
|
|
||||||
class UserPreviewWidget extends StatefulWidget {
|
class UserPreviewWidget extends StatefulWidget {
|
||||||
const UserPreviewWidget(this.user, {super.key});
|
const UserPreviewWidget(this.user, {super.key});
|
||||||
|
|
||||||
final UserPreview user;
|
final UserPreview user;
|
||||||
|
|
||||||
|
static Map<String, UpdateFollowCallback> followCallbacks = {};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<UserPreviewWidget> createState() => _UserPreviewWidgetState();
|
State<UserPreviewWidget> createState() => _UserPreviewWidgetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _UserPreviewWidgetState extends State<UserPreviewWidget> {
|
class _UserPreviewWidgetState extends State<UserPreviewWidget> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
UserPreviewWidget.followCallbacks[widget.user.id.toString()] = (v) {
|
||||||
|
setState(() {
|
||||||
|
widget.user.isFollowed = v;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
UserPreviewWidget.followCallbacks.remove(widget.user.id.toString());
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
bool isFollowing = false;
|
bool isFollowing = false;
|
||||||
|
|
||||||
void follow() async {
|
void follow() async {
|
||||||
@@ -39,6 +60,9 @@ class _UserPreviewWidgetState extends State<UserPreviewWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
isFollowing = false;
|
isFollowing = false;
|
||||||
});
|
});
|
||||||
|
UserInfoPage.followCallbacks[widget.user.id.toString()]
|
||||||
|
?.call(widget.user.isFollowed);
|
||||||
|
IllustPage.updateFollow(widget.user.id.toString(), widget.user.isFollowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
import 'package:fluent_ui/fluent_ui.dart';
|
import 'package:fluent_ui/fluent_ui.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
|
||||||
@@ -11,11 +12,13 @@ export "state_controller.dart";
|
|||||||
export "navigation.dart";
|
export "navigation.dart";
|
||||||
|
|
||||||
class _App {
|
class _App {
|
||||||
final version = "1.0.4";
|
final version = "1.0.6";
|
||||||
|
|
||||||
bool get isAndroid => Platform.isAndroid;
|
bool get isAndroid => Platform.isAndroid;
|
||||||
bool get isIOS => Platform.isIOS;
|
bool get isIOS => Platform.isIOS;
|
||||||
bool get isWindows => Platform.isWindows;
|
bool get isWindows => Platform.isWindows;
|
||||||
|
int? _windowsVersion;
|
||||||
|
int get windowsVersion => _windowsVersion!;
|
||||||
bool get isLinux => Platform.isLinux;
|
bool get isLinux => Platform.isLinux;
|
||||||
bool get isMacOS => Platform.isMacOS;
|
bool get isMacOS => Platform.isMacOS;
|
||||||
bool get isDesktop =>
|
bool get isDesktop =>
|
||||||
@@ -23,8 +26,8 @@ class _App {
|
|||||||
bool get isMobile => Platform.isAndroid || Platform.isIOS;
|
bool get isMobile => Platform.isAndroid || Platform.isIOS;
|
||||||
|
|
||||||
Locale get locale {
|
Locale get locale {
|
||||||
if(appdata.settings["language"] != "System"){
|
if (appdata.settings["language"] != "System") {
|
||||||
return switch(appdata.settings["language"]){
|
return switch (appdata.settings["language"]) {
|
||||||
"English" => const Locale("en"),
|
"English" => const Locale("en"),
|
||||||
"简体中文" => const Locale("zh", "CN"),
|
"简体中文" => const Locale("zh", "CN"),
|
||||||
"繁體中文" => const Locale("zh", "TW"),
|
"繁體中文" => const Locale("zh", "TW"),
|
||||||
@@ -32,7 +35,8 @@ class _App {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
Locale deviceLocale = PlatformDispatcher.instance.locale;
|
Locale deviceLocale = PlatformDispatcher.instance.locale;
|
||||||
if (deviceLocale.languageCode == "zh" && deviceLocale.scriptCode == "Hant") {
|
if (deviceLocale.languageCode == "zh" &&
|
||||||
|
deviceLocale.scriptCode == "Hant") {
|
||||||
deviceLocale = const Locale("zh", "TW");
|
deviceLocale = const Locale("zh", "TW");
|
||||||
}
|
}
|
||||||
return deviceLocale;
|
return deviceLocale;
|
||||||
@@ -41,9 +45,24 @@ class _App {
|
|||||||
late String dataPath;
|
late String dataPath;
|
||||||
late String cachePath;
|
late String cachePath;
|
||||||
|
|
||||||
init() async{
|
init() async {
|
||||||
cachePath = (await getApplicationCacheDirectory()).path;
|
cachePath = (await getApplicationCacheDirectory()).path;
|
||||||
dataPath = (await getApplicationSupportDirectory()).path;
|
dataPath = (await getApplicationSupportDirectory()).path;
|
||||||
|
if (App.isWindows) {
|
||||||
|
final deviceInfoPlugin = DeviceInfoPlugin();
|
||||||
|
final deviceInfo = await deviceInfoPlugin.windowsInfo;
|
||||||
|
if (deviceInfo.majorVersion <= 6) {
|
||||||
|
if (deviceInfo.minorVersion < 2) {
|
||||||
|
_windowsVersion = 7;
|
||||||
|
} else {
|
||||||
|
_windowsVersion = 8;
|
||||||
|
}
|
||||||
|
} else if (deviceInfo.buildNumber < 22000) {
|
||||||
|
_windowsVersion = 10;
|
||||||
|
} else {
|
||||||
|
_windowsVersion = 11;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final rootNavigatorKey = GlobalKey<NavigatorState>();
|
final rootNavigatorKey = GlobalKey<NavigatorState>();
|
||||||
|
@@ -2,9 +2,12 @@ import "dart:ui";
|
|||||||
|
|
||||||
import "package:dynamic_color/dynamic_color.dart";
|
import "package:dynamic_color/dynamic_color.dart";
|
||||||
import "package:fluent_ui/fluent_ui.dart";
|
import "package:fluent_ui/fluent_ui.dart";
|
||||||
|
import "package:flutter/foundation.dart";
|
||||||
import "package:flutter/material.dart" as md;
|
import "package:flutter/material.dart" as md;
|
||||||
import "package:flutter/services.dart";
|
import "package:flutter/services.dart";
|
||||||
|
import "package:flutter_acrylic/flutter_acrylic.dart" as flutter_acrylic;
|
||||||
import "package:pixes/appdata.dart";
|
import "package:pixes/appdata.dart";
|
||||||
|
import "package:pixes/components/keyboard.dart";
|
||||||
import "package:pixes/components/md.dart";
|
import "package:pixes/components/md.dart";
|
||||||
import "package:pixes/components/message.dart";
|
import "package:pixes/components/message.dart";
|
||||||
import "package:pixes/foundation/app.dart";
|
import "package:pixes/foundation/app.dart";
|
||||||
@@ -12,7 +15,9 @@ import "package:pixes/foundation/log.dart";
|
|||||||
import "package:pixes/network/app_dio.dart";
|
import "package:pixes/network/app_dio.dart";
|
||||||
import "package:pixes/pages/main_page.dart";
|
import "package:pixes/pages/main_page.dart";
|
||||||
import "package:pixes/utils/app_links.dart";
|
import "package:pixes/utils/app_links.dart";
|
||||||
|
import "package:pixes/utils/loop.dart";
|
||||||
import "package:pixes/utils/translation.dart";
|
import "package:pixes/utils/translation.dart";
|
||||||
|
import "package:pixes/utils/window.dart";
|
||||||
import "package:window_manager/window_manager.dart";
|
import "package:window_manager/window_manager.dart";
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
@@ -26,6 +31,10 @@ void main() async {
|
|||||||
await Translation.init();
|
await Translation.init();
|
||||||
handleLinks();
|
handleLinks();
|
||||||
if (App.isDesktop) {
|
if (App.isDesktop) {
|
||||||
|
await flutter_acrylic.Window.initialize();
|
||||||
|
if (App.isWindows) {
|
||||||
|
await flutter_acrylic.Window.hideWindowControls();
|
||||||
|
}
|
||||||
await WindowManager.instance.ensureInitialized();
|
await WindowManager.instance.ensureInitialized();
|
||||||
windowManager.waitUntilReadyToShow().then((_) async {
|
windowManager.waitUntilReadyToShow().then((_) async {
|
||||||
await windowManager.setTitleBarStyle(
|
await windowManager.setTitleBarStyle(
|
||||||
@@ -33,10 +42,13 @@ void main() async {
|
|||||||
windowButtonVisibility: false,
|
windowButtonVisibility: false,
|
||||||
);
|
);
|
||||||
await windowManager.setMinimumSize(const Size(500, 600));
|
await windowManager.setMinimumSize(const Size(500, 600));
|
||||||
|
var placement = await WindowPlacement.loadFromFile();
|
||||||
|
await placement.applyToWindow();
|
||||||
await windowManager.show();
|
await windowManager.show();
|
||||||
await windowManager.setSkipTaskbar(false);
|
Loop.register(WindowPlacement.loop);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loop.start();
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,6 +58,7 @@ class MyApp extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||||
|
var windowsFont = kDebugMode ? "微软雅黑" : "font";
|
||||||
return StateBuilder<SimpleController>(
|
return StateBuilder<SimpleController>(
|
||||||
init: SimpleController(),
|
init: SimpleController(),
|
||||||
tag: "MyApp",
|
tag: "MyApp",
|
||||||
@@ -78,7 +91,7 @@ class MyApp extends StatelessWidget {
|
|||||||
title: 'pixes',
|
title: 'pixes',
|
||||||
theme: FluentThemeData(
|
theme: FluentThemeData(
|
||||||
brightness: brightness,
|
brightness: brightness,
|
||||||
fontFamily: App.isWindows ? 'font' : null,
|
fontFamily: App.isWindows ? windowsFont : null,
|
||||||
accentColor: AccentColor.swatch({
|
accentColor: AccentColor.swatch({
|
||||||
'darkest': darken(colorScheme.primary, 30),
|
'darkest': darken(colorScheme.primary, 30),
|
||||||
'darker': darken(colorScheme.primary, 20),
|
'darker': darken(colorScheme.primary, 20),
|
||||||
@@ -87,7 +100,11 @@ class MyApp extends StatelessWidget {
|
|||||||
'light': lighten(colorScheme.primary, 10),
|
'light': lighten(colorScheme.primary, 10),
|
||||||
'lighter': lighten(colorScheme.primary, 20),
|
'lighter': lighten(colorScheme.primary, 20),
|
||||||
'lightest': lighten(colorScheme.primary, 30)
|
'lightest': lighten(colorScheme.primary, 30)
|
||||||
})),
|
}),
|
||||||
|
focusTheme: const FocusThemeData(
|
||||||
|
primaryBorder: BorderSide.none,
|
||||||
|
secondaryBorder: BorderSide.none,
|
||||||
|
)),
|
||||||
home: const MainPage(),
|
home: const MainPage(),
|
||||||
builder: (context, child) {
|
builder: (context, child) {
|
||||||
ErrorWidget.builder = (details) {
|
ErrorWidget.builder = (details) {
|
||||||
@@ -104,7 +121,7 @@ class MyApp extends StatelessWidget {
|
|||||||
throw "widget is null";
|
throw "widget is null";
|
||||||
}
|
}
|
||||||
|
|
||||||
return MdTheme(
|
Widget widget = MdTheme(
|
||||||
data: MdThemeData.from(
|
data: MdThemeData.from(
|
||||||
colorScheme: colorScheme, useMaterial3: true),
|
colorScheme: colorScheme, useMaterial3: true),
|
||||||
child: DefaultTextStyle.merge(
|
child: DefaultTextStyle.merge(
|
||||||
@@ -114,6 +131,36 @@ class MyApp extends StatelessWidget {
|
|||||||
child: OverlayWidget(child),
|
child: OverlayWidget(child),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (App.isWindows) {
|
||||||
|
if (App.windowsVersion == 11) {
|
||||||
|
flutter_acrylic.Window.setEffect(
|
||||||
|
effect: flutter_acrylic.WindowEffect.mica,
|
||||||
|
dark: FluentTheme.of(context).brightness ==
|
||||||
|
Brightness.dark);
|
||||||
|
widget = NavigationPaneTheme(
|
||||||
|
data: const NavigationPaneThemeData(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
),
|
||||||
|
child: widget,
|
||||||
|
);
|
||||||
|
} else if (App.windowsVersion == 10) {
|
||||||
|
flutter_acrylic.Window.setEffect(
|
||||||
|
effect: flutter_acrylic.WindowEffect.acrylic,
|
||||||
|
dark: FluentTheme.of(context).brightness ==
|
||||||
|
Brightness.dark);
|
||||||
|
widget = NavigationPaneTheme(
|
||||||
|
data: NavigationPaneThemeData(
|
||||||
|
backgroundColor: FluentTheme.of(context)
|
||||||
|
.micaBackgroundColor
|
||||||
|
.withOpacity(0.72),
|
||||||
|
),
|
||||||
|
child: widget,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return KeyEventListener(child: widget);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@@ -368,6 +368,26 @@ class DownloadManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> checkAndClearInvalidItems() async{
|
||||||
|
var illusts = listAll();
|
||||||
|
var shouldDelete = <DownloadedIllust>[];
|
||||||
|
for(var item in illusts) {
|
||||||
|
var paths = getImagePaths(item.illustId);
|
||||||
|
var validPaths = <String>[];
|
||||||
|
for(var path in paths) {
|
||||||
|
if(await File(path).exists()) {
|
||||||
|
validPaths.add(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(validPaths.isEmpty) {
|
||||||
|
shouldDelete.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(var item in shouldDelete) {
|
||||||
|
delete(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void resume() {
|
void resume() {
|
||||||
_paused = false;
|
_paused = false;
|
||||||
}
|
}
|
||||||
|
@@ -181,6 +181,7 @@ class Illust {
|
|||||||
bool isBookmarked;
|
bool isBookmarked;
|
||||||
final bool isAi;
|
final bool isAi;
|
||||||
final bool isUgoira;
|
final bool isUgoira;
|
||||||
|
final bool isBlocked;
|
||||||
|
|
||||||
bool get isR18 => tags.contains(const Tag("R-18", null));
|
bool get isR18 => tags.contains(const Tag("R-18", null));
|
||||||
|
|
||||||
@@ -227,7 +228,8 @@ class Illust {
|
|||||||
totalBookmarks = json['total_bookmarks'],
|
totalBookmarks = json['total_bookmarks'],
|
||||||
isBookmarked = json['is_bookmarked'],
|
isBookmarked = json['is_bookmarked'],
|
||||||
isAi = json['illust_ai_type'] == 2,
|
isAi = json['illust_ai_type'] == 2,
|
||||||
isUgoira = json['type'] == "ugoira";
|
isUgoira = json['type'] == "ugoira",
|
||||||
|
isBlocked = json['is_muted'] ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TrendingTag {
|
class TrendingTag {
|
||||||
@@ -525,3 +527,25 @@ class Novel {
|
|||||||
commentsCount = json["total_comments"],
|
commentsCount = json["total_comments"],
|
||||||
isAi = json["novel_ai_type"] == 2;
|
isAi = json["novel_ai_type"] == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MuteList {
|
||||||
|
List<Tag> tags;
|
||||||
|
|
||||||
|
List<Author> authors;
|
||||||
|
|
||||||
|
int limit;
|
||||||
|
|
||||||
|
MuteList(this.tags, this.authors, this.limit);
|
||||||
|
|
||||||
|
static MuteList? fromJson(Map<String, dynamic> data) {
|
||||||
|
return MuteList(
|
||||||
|
(data['muted_tags'] as List)
|
||||||
|
.map((e) => Tag(e['tag'], e['tag_translation']))
|
||||||
|
.toList(),
|
||||||
|
(data['muted_users'] as List)
|
||||||
|
.map((e) => Author(e['user_id'], e['user_name'], e['user_account'],
|
||||||
|
e['user_profile_image_urls']['medium'], false))
|
||||||
|
.toList(),
|
||||||
|
data['mute_limit_count']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -191,6 +191,21 @@ class Network {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String? encodeFormData(Map<String, dynamic>? data) {
|
||||||
|
if (data == null) return null;
|
||||||
|
StringBuffer buffer = StringBuffer();
|
||||||
|
data.forEach((key, value) {
|
||||||
|
if (value is List) {
|
||||||
|
for (var element in value) {
|
||||||
|
buffer.write("$key[]=$element&");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
buffer.write("$key=$value&");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
Future<Res<Map<String, dynamic>>> apiPost(String path,
|
Future<Res<Map<String, dynamic>>> apiPost(String path,
|
||||||
{Map<String, dynamic>? query, Map<String, dynamic>? data}) async {
|
{Map<String, dynamic>? query, Map<String, dynamic>? data}) async {
|
||||||
try {
|
try {
|
||||||
@@ -199,7 +214,7 @@ class Network {
|
|||||||
}
|
}
|
||||||
final res = await dio.post<Map<String, dynamic>>(path,
|
final res = await dio.post<Map<String, dynamic>>(path,
|
||||||
queryParameters: query,
|
queryParameters: query,
|
||||||
data: data,
|
data: encodeFormData(data),
|
||||||
options: Options(
|
options: Options(
|
||||||
headers: headers,
|
headers: headers,
|
||||||
validateStatus: (status) => true,
|
validateStatus: (status) => true,
|
||||||
@@ -497,21 +512,24 @@ class Network {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Tag>> getMutedTags() async {
|
Future<Res<MuteList>> getMuteList() async {
|
||||||
var res = await apiGet("/v1/mute/list");
|
var res = await apiGet("/v1/mute/list");
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
return res.data["mute_tags"]
|
return Res(MuteList.fromJson(res.data));
|
||||||
.map<Tag>((e) => Tag(e["tag"]["name"], e["tag"]["translated_name"]))
|
|
||||||
.toList();
|
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return Res.error(res.errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Res<bool>> muteTags(
|
Future<Res<bool>> editMute(List<String> addTags, List<String> addUsers,
|
||||||
List<String> muteTags, List<String> unmuteTags) async {
|
List<String> deleteTags, List<String> deleteUsers) async {
|
||||||
var res = await apiPost("/v1/mute/edit",
|
var res = await apiPost("/v1/mute/edit",
|
||||||
data: {"add_tags": muteTags, "delete_tags": unmuteTags});
|
data: {
|
||||||
|
"add_tags": addTags,
|
||||||
|
"add_user_ids": addUsers,
|
||||||
|
"delete_tags": deleteTags,
|
||||||
|
"delete_user_ids": deleteUsers
|
||||||
|
}..removeWhere((key, value) => value.isEmpty));
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
return const Res(true);
|
return const Res(true);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -7,8 +7,6 @@ import 'package:photo_view/photo_view_gallery.dart';
|
|||||||
import 'package:pixes/components/animated_image.dart';
|
import 'package:pixes/components/animated_image.dart';
|
||||||
import 'package:pixes/components/grid.dart';
|
import 'package:pixes/components/grid.dart';
|
||||||
import 'package:pixes/components/md.dart';
|
import 'package:pixes/components/md.dart';
|
||||||
import 'package:pixes/components/message.dart';
|
|
||||||
import 'package:pixes/components/page_route.dart';
|
|
||||||
import 'package:pixes/components/title_bar.dart';
|
import 'package:pixes/components/title_bar.dart';
|
||||||
import 'package:pixes/foundation/app.dart';
|
import 'package:pixes/foundation/app.dart';
|
||||||
import 'package:pixes/network/download.dart';
|
import 'package:pixes/network/download.dart';
|
||||||
@@ -33,7 +31,8 @@ class _DownloadedPageState extends State<DownloadedPage> {
|
|||||||
|
|
||||||
void loadData() {
|
void loadData() {
|
||||||
illusts = DownloadManager().listAll();
|
illusts = DownloadManager().listAll();
|
||||||
flyoutControllers = List.generate(illusts.length, (index) => FlyoutController());
|
flyoutControllers =
|
||||||
|
List.generate(illusts.length, (index) => FlyoutController());
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -46,7 +45,18 @@ class _DownloadedPageState extends State<DownloadedPage> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
TitleBar(title: "Downloaded".tl),
|
TitleBar(
|
||||||
|
title: "Downloaded".tl,
|
||||||
|
action: Button(
|
||||||
|
child: Text("Delete Invalid Items".tl),
|
||||||
|
onPressed: () async {
|
||||||
|
await DownloadManager().checkAndClearInvalidItems();
|
||||||
|
setState(() {
|
||||||
|
loadData();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: buildBody(),
|
child: buildBody(),
|
||||||
),
|
),
|
||||||
@@ -56,135 +66,134 @@ class _DownloadedPageState extends State<DownloadedPage> {
|
|||||||
|
|
||||||
Widget buildBody() {
|
Widget buildBody() {
|
||||||
return GridViewWithFixedItemHeight(
|
return GridViewWithFixedItemHeight(
|
||||||
itemCount: illusts.length,
|
itemCount: illusts.length,
|
||||||
itemHeight: 152,
|
itemHeight: 152,
|
||||||
maxCrossAxisExtent: 742,
|
maxCrossAxisExtent: 742,
|
||||||
builder: (context, index) {
|
builder: (context, index) {
|
||||||
var image = DownloadManager().getImage(illusts[index].illustId, 0);
|
var image = DownloadManager().getImage(illusts[index].illustId, 0);
|
||||||
return Card(
|
return Card(
|
||||||
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
|
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||||
child: Row(
|
child: GestureDetector(
|
||||||
children: [
|
behavior: HitTestBehavior.opaque,
|
||||||
Container(
|
onTap: () {
|
||||||
width: 96,
|
App.rootNavigatorKey.currentContext?.to(() =>
|
||||||
height: double.infinity,
|
_DownloadedIllustViewPage(DownloadManager()
|
||||||
decoration: BoxDecoration(
|
.getImagePaths(illusts[index].illustId)));
|
||||||
borderRadius: BorderRadius.circular(4),
|
},
|
||||||
color: ColorScheme.of(context).secondaryContainer
|
child: Row(
|
||||||
),
|
children: [
|
||||||
clipBehavior: Clip.antiAlias,
|
Container(
|
||||||
child: image == null ? null : AnimatedImage(
|
width: 96,
|
||||||
image: FileImage(image),
|
height: double.infinity,
|
||||||
fit: BoxFit.cover,
|
decoration: BoxDecoration(
|
||||||
width: 96,
|
borderRadius: BorderRadius.circular(4),
|
||||||
height: double.infinity,
|
color: ColorScheme.of(context).secondaryContainer),
|
||||||
filterQuality: FilterQuality.medium,
|
clipBehavior: Clip.antiAlias,
|
||||||
),
|
child: image == null
|
||||||
),
|
? null
|
||||||
const SizedBox(width: 16),
|
: AnimatedImage(
|
||||||
Expanded(
|
image: FileImage(image),
|
||||||
child: Column(
|
fit: BoxFit.cover,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
width: 96,
|
||||||
children: [
|
height: double.infinity,
|
||||||
Text(
|
filterQuality: FilterQuality.medium,
|
||||||
illusts[index].title,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(
|
|
||||||
illusts[index].author,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"${illusts[index].imageCount}P",
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
const Spacer(),
|
|
||||||
Button(
|
|
||||||
child: Text("View".tl).fixWidth(42),
|
|
||||||
onPressed: () {
|
|
||||||
var images = DownloadManager().getImagePaths(
|
|
||||||
illusts[index].illustId);
|
|
||||||
if(images.isEmpty) {
|
|
||||||
showToast(context, message: "No images found".tl);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
App.rootNavigatorKey.currentState?.push(
|
|
||||||
AppPageRoute(builder: (context) {
|
|
||||||
return _DownloadedIllustViewPage(images);
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(width: 6),
|
|
||||||
Button(
|
|
||||||
child: Text("Info".tl).fixWidth(42),
|
|
||||||
onPressed: () {
|
|
||||||
context.to(() => IllustPageWithId(
|
|
||||||
illusts[index].illustId.toString()));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(width: 6),
|
|
||||||
FlyoutTarget(
|
|
||||||
controller: flyoutControllers[index],
|
|
||||||
child: Button(
|
|
||||||
child: Text("Delete".tl).fixWidth(42),
|
|
||||||
onPressed: () {
|
|
||||||
flyoutControllers[index].showFlyout(
|
|
||||||
navigatorKey: App.rootNavigatorKey.currentState,
|
|
||||||
builder: (context) {
|
|
||||||
return FlyoutContent(
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Are you sure you want to delete?'.tl,
|
|
||||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12.0),
|
|
||||||
Button(
|
|
||||||
onPressed: () {
|
|
||||||
Flyout.of(context).close();
|
|
||||||
DownloadManager().delete(illusts[index]);
|
|
||||||
setState(() {
|
|
||||||
illusts.removeAt(index);
|
|
||||||
flyoutControllers.removeAt(index);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: Text('Yes'.tl),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
illusts[index].title,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
illusts[index].author,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"${illusts[index].imageCount}P",
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
const Spacer(),
|
||||||
|
Button(
|
||||||
|
child: Text("Info".tl).fixWidth(42),
|
||||||
|
onPressed: () {
|
||||||
|
context.to(() => IllustPageWithId(
|
||||||
|
illusts[index].illustId.toString()));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
FlyoutTarget(
|
||||||
|
controller: flyoutControllers[index],
|
||||||
|
child: Button(
|
||||||
|
child: Text("Delete".tl).fixWidth(42),
|
||||||
|
onPressed: () {
|
||||||
|
flyoutControllers[index].showFlyout(
|
||||||
|
navigatorKey:
|
||||||
|
App.rootNavigatorKey.currentState,
|
||||||
|
builder: (context) {
|
||||||
|
return FlyoutContent(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Are you sure you want to delete?'
|
||||||
|
.tl,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight:
|
||||||
|
FontWeight.bold),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12.0),
|
||||||
|
Button(
|
||||||
|
onPressed: () {
|
||||||
|
Flyout.of(context).close();
|
||||||
|
DownloadManager()
|
||||||
|
.delete(illusts[index]);
|
||||||
|
setState(() {
|
||||||
|
illusts.removeAt(index);
|
||||||
|
flyoutControllers
|
||||||
|
.removeAt(index);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Text('Yes'.tl),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
);
|
||||||
);
|
}).paddingHorizontal(8);
|
||||||
}
|
|
||||||
).paddingHorizontal(8);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,10 +203,12 @@ class _DownloadedIllustViewPage extends StatefulWidget {
|
|||||||
final List<String> imagePaths;
|
final List<String> imagePaths;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<_DownloadedIllustViewPage> createState() => _DownloadedIllustViewPageState();
|
State<_DownloadedIllustViewPage> createState() =>
|
||||||
|
_DownloadedIllustViewPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> with WindowListener{
|
class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage>
|
||||||
|
with WindowListener {
|
||||||
int windowButtonKey = 0;
|
int windowButtonKey = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -234,38 +245,47 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
|||||||
|
|
||||||
Future<File?> getFile() async {
|
Future<File?> getFile() async {
|
||||||
var file = File(widget.imagePaths[currentPage]);
|
var file = File(widget.imagePaths[currentPage]);
|
||||||
if(file.existsSync()) {
|
if (file.existsSync()) {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void showMenu() {
|
void showMenu() {
|
||||||
menuController.showFlyout(builder: (context) => MenuFlyout(
|
menuController.showFlyout(
|
||||||
items: [
|
builder: (context) => MenuFlyout(
|
||||||
MenuFlyoutItem(text: Text("Save to".tl), onPressed: () async{
|
items: [
|
||||||
var file = await getFile();
|
MenuFlyoutItem(
|
||||||
if(file != null){
|
text: Text("Save to".tl),
|
||||||
saveFile(file);
|
onPressed: () async {
|
||||||
}
|
var file = await getFile();
|
||||||
}),
|
if (file != null) {
|
||||||
MenuFlyoutItem(text: Text("Share".tl), onPressed: () async{
|
saveFile(file);
|
||||||
var file = await getFile();
|
}
|
||||||
if(file != null){
|
}),
|
||||||
var ext = file.path.split('.').last;
|
MenuFlyoutItem(
|
||||||
var mediaType = switch(ext){
|
text: Text("Share".tl),
|
||||||
'jpg' => 'image/jpeg',
|
onPressed: () async {
|
||||||
'jpeg' => 'image/jpeg',
|
var file = await getFile();
|
||||||
'png' => 'image/png',
|
if (file != null) {
|
||||||
'gif' => 'image/gif',
|
var ext = file.path.split('.').last;
|
||||||
'webp' => 'image/webp',
|
var mediaType = switch (ext) {
|
||||||
_ => 'application/octet-stream'
|
'jpg' => 'image/jpeg',
|
||||||
};
|
'jpeg' => 'image/jpeg',
|
||||||
Share.shareXFiles([XFile(file.path, mimeType: mediaType, name: file.path.split('/').last)]);
|
'png' => 'image/png',
|
||||||
}
|
'gif' => 'image/gif',
|
||||||
}),
|
'webp' => 'image/webp',
|
||||||
],
|
_ => 'application/octet-stream'
|
||||||
));
|
};
|
||||||
|
Share.shareXFiles([
|
||||||
|
XFile(file.path,
|
||||||
|
mimeType: mediaType,
|
||||||
|
name: file.path.split('/').last)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -275,12 +295,13 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
|||||||
color: FluentTheme.of(context).micaBackgroundColor,
|
color: FluentTheme.of(context).micaBackgroundColor,
|
||||||
child: Listener(
|
child: Listener(
|
||||||
onPointerSignal: (event) {
|
onPointerSignal: (event) {
|
||||||
if(event is PointerScrollEvent &&
|
if (event is PointerScrollEvent &&
|
||||||
!HardwareKeyboard.instance.isControlPressed) {
|
!HardwareKeyboard.instance.isControlPressed) {
|
||||||
if(event.scrollDelta.dy > 0
|
if (event.scrollDelta.dy > 0 &&
|
||||||
&& controller.page!.toInt() < widget.imagePaths.length - 1) {
|
controller.page!.toInt() < widget.imagePaths.length - 1) {
|
||||||
controller.jumpToPage(controller.page!.toInt() + 1);
|
controller.jumpToPage(controller.page!.toInt() + 1);
|
||||||
} else if(event.scrollDelta.dy < 0 && controller.page!.toInt() > 0){
|
} else if (event.scrollDelta.dy < 0 &&
|
||||||
|
controller.page!.toInt() > 0) {
|
||||||
controller.jumpToPage(controller.page!.toInt() - 1);
|
controller.jumpToPage(controller.page!.toInt() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -290,11 +311,11 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
|||||||
var height = constrains.maxHeight;
|
var height = constrains.maxHeight;
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
Positioned.fill(child: PhotoViewGallery.builder(
|
Positioned.fill(
|
||||||
|
child: PhotoViewGallery.builder(
|
||||||
pageController: controller,
|
pageController: controller,
|
||||||
backgroundDecoration: const BoxDecoration(
|
backgroundDecoration:
|
||||||
color: Colors.transparent
|
const BoxDecoration(color: Colors.transparent),
|
||||||
),
|
|
||||||
itemCount: widget.imagePaths.length,
|
itemCount: widget.imagePaths.length,
|
||||||
builder: (context, index) {
|
builder: (context, index) {
|
||||||
return PhotoViewGalleryPageOptions(
|
return PhotoViewGalleryPageOptions(
|
||||||
@@ -315,17 +336,22 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
|||||||
height: 36,
|
height: 36,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(width: 6,),
|
const SizedBox(
|
||||||
|
width: 6,
|
||||||
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(FluentIcons.back).paddingAll(2),
|
icon: const Icon(FluentIcons.back).paddingAll(2),
|
||||||
onPressed: () => context.pop()
|
onPressed: () => context.pop()),
|
||||||
),
|
|
||||||
const Expanded(
|
const Expanded(
|
||||||
child: DragToMoveArea(child: SizedBox.expand(),),
|
child: DragToMoveArea(
|
||||||
|
child: SizedBox.expand(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
buildActions(),
|
buildActions(),
|
||||||
if(App.isDesktop)
|
if (App.isDesktop)
|
||||||
WindowButtons(key: ValueKey(windowButtonKey),),
|
WindowButtons(
|
||||||
|
key: ValueKey(windowButtonKey),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -334,7 +360,10 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
|||||||
left: 0,
|
left: 0,
|
||||||
top: height / 2 - 9,
|
top: height / 2 - 9,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: const Icon(FluentIcons.chevron_left, size: 18,),
|
icon: const Icon(
|
||||||
|
FluentIcons.chevron_left,
|
||||||
|
size: 18,
|
||||||
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
controller.previousPage(
|
controller.previousPage(
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
@@ -377,26 +406,25 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
|||||||
controller: menuController,
|
controller: menuController,
|
||||||
child: width > 600
|
child: width > 600
|
||||||
? Button(
|
? Button(
|
||||||
onPressed: showMenu,
|
onPressed: showMenu,
|
||||||
child: const Row(
|
child: const Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
MdIcons.menu,
|
MdIcons.menu,
|
||||||
size: 18,
|
size: 18,
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 8,
|
width: 8,
|
||||||
),
|
),
|
||||||
Text('Actions'),
|
Text('Actions'),
|
||||||
],
|
],
|
||||||
))
|
))
|
||||||
: IconButton(
|
: IconButton(
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
MdIcons.more_horiz,
|
MdIcons.more_horiz,
|
||||||
size: 20,
|
size: 20,
|
||||||
),
|
),
|
||||||
onPressed: showMenu),
|
onPressed: showMenu),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@ import 'package:fluent_ui/fluent_ui.dart';
|
|||||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||||
import 'package:pixes/components/title_bar.dart';
|
import 'package:pixes/components/title_bar.dart';
|
||||||
import 'package:pixes/foundation/app.dart';
|
import 'package:pixes/foundation/app.dart';
|
||||||
|
import 'package:pixes/utils/block.dart';
|
||||||
import 'package:pixes/utils/translation.dart';
|
import 'package:pixes/utils/translation.dart';
|
||||||
|
|
||||||
import '../components/batch_download.dart';
|
import '../components/batch_download.dart';
|
||||||
@@ -27,7 +28,10 @@ class _FollowingArtworksPageState extends State<FollowingArtworksPage> {
|
|||||||
children: [
|
children: [
|
||||||
buildTab(),
|
buildTab(),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _OneFollowingPage(restrict, key: Key(restrict),),
|
child: _OneFollowingPage(
|
||||||
|
restrict,
|
||||||
|
key: Key(restrict),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -38,8 +42,11 @@ class _FollowingArtworksPageState extends State<FollowingArtworksPage> {
|
|||||||
title: "Following".tl,
|
title: "Following".tl,
|
||||||
action: Row(
|
action: Row(
|
||||||
children: [
|
children: [
|
||||||
BatchDownloadButton(request: () => Network().getFollowingArtworks(restrict)),
|
BatchDownloadButton(
|
||||||
const SizedBox(width: 8,),
|
request: () => Network().getFollowingArtworks(restrict)),
|
||||||
|
const SizedBox(
|
||||||
|
width: 8,
|
||||||
|
),
|
||||||
SegmentedButton(
|
SegmentedButton(
|
||||||
options: [
|
options: [
|
||||||
SegmentedButtonOption("all", "All".tl),
|
SegmentedButtonOption("all", "All".tl),
|
||||||
@@ -47,7 +54,7 @@ class _FollowingArtworksPageState extends State<FollowingArtworksPage> {
|
|||||||
SegmentedButtonOption("private", "Private".tl),
|
SegmentedButtonOption("private", "Private".tl),
|
||||||
],
|
],
|
||||||
onPressed: (key) {
|
onPressed: (key) {
|
||||||
if(key != restrict) {
|
if (key != restrict) {
|
||||||
setState(() {
|
setState(() {
|
||||||
restrict = key;
|
restrict = key;
|
||||||
});
|
});
|
||||||
@@ -70,27 +77,26 @@ class _OneFollowingPage extends StatefulWidget {
|
|||||||
State<_OneFollowingPage> createState() => _OneFollowingPageState();
|
State<_OneFollowingPage> createState() => _OneFollowingPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _OneFollowingPageState extends MultiPageLoadingState<_OneFollowingPage, Illust> {
|
class _OneFollowingPageState
|
||||||
|
extends MultiPageLoadingState<_OneFollowingPage, Illust> {
|
||||||
@override
|
@override
|
||||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
Widget buildContent(BuildContext context, List<Illust> data) {
|
||||||
return LayoutBuilder(builder: (context, constrains){
|
checkIllusts(data);
|
||||||
|
return LayoutBuilder(builder: (context, constrains) {
|
||||||
return MasonryGridView.builder(
|
return MasonryGridView.builder(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8)
|
padding: const EdgeInsets.symmetric(horizontal: 8) +
|
||||||
+ EdgeInsets.only(bottom: context.padding.bottom),
|
EdgeInsets.only(bottom: context.padding.bottom),
|
||||||
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
||||||
maxCrossAxisExtent: 240,
|
maxCrossAxisExtent: 240,
|
||||||
),
|
),
|
||||||
itemCount: data.length,
|
itemCount: data.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if(index == data.length - 1){
|
if (index == data.length - 1) {
|
||||||
nextPage();
|
nextPage();
|
||||||
}
|
}
|
||||||
return IllustWidget(data[index], onTap: () {
|
return IllustWidget(data[index], onTap: () {
|
||||||
context.to(() => IllustGalleryPage(
|
context.to(() => IllustGalleryPage(
|
||||||
illusts: data,
|
illusts: data, initialPage: index, nextUrl: nextUrl));
|
||||||
initialPage: index,
|
|
||||||
nextUrl: nextUrl
|
|
||||||
));
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -100,16 +106,15 @@ class _OneFollowingPageState extends MultiPageLoadingState<_OneFollowingPage, Il
|
|||||||
String? nextUrl;
|
String? nextUrl;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Res<List<Illust>>> loadData(page) async{
|
Future<Res<List<Illust>>> loadData(page) async {
|
||||||
if(nextUrl == "end") {
|
if (nextUrl == "end") {
|
||||||
return Res.error("No more data");
|
return Res.error("No more data");
|
||||||
}
|
}
|
||||||
var res = await Network().getFollowingArtworks(widget.restrict, nextUrl);
|
var res = await Network().getFollowingArtworks(widget.restrict, nextUrl);
|
||||||
if(!res.error) {
|
if (!res.error) {
|
||||||
nextUrl = res.subData;
|
nextUrl = res.subData;
|
||||||
nextUrl ??= "end";
|
nextUrl ??= "end";
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,10 +5,14 @@ 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:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||||
|
import 'package:pixes/appdata.dart';
|
||||||
import 'package:pixes/components/animated_image.dart';
|
import 'package:pixes/components/animated_image.dart';
|
||||||
|
import 'package:pixes/components/keyboard.dart';
|
||||||
import 'package:pixes/components/loading.dart';
|
import 'package:pixes/components/loading.dart';
|
||||||
import 'package:pixes/components/message.dart';
|
import 'package:pixes/components/message.dart';
|
||||||
|
import 'package:pixes/components/page_route.dart';
|
||||||
import 'package:pixes/components/title_bar.dart';
|
import 'package:pixes/components/title_bar.dart';
|
||||||
|
import 'package:pixes/components/user_preview.dart';
|
||||||
import 'package:pixes/foundation/app.dart';
|
import 'package:pixes/foundation/app.dart';
|
||||||
import 'package:pixes/foundation/image_provider.dart';
|
import 'package:pixes/foundation/image_provider.dart';
|
||||||
import 'package:pixes/network/download.dart';
|
import 'package:pixes/network/download.dart';
|
||||||
@@ -17,6 +21,7 @@ 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/search_page.dart';
|
import 'package:pixes/pages/search_page.dart';
|
||||||
import 'package:pixes/pages/user_info_page.dart';
|
import 'package:pixes/pages/user_info_page.dart';
|
||||||
|
import 'package:pixes/utils/block.dart';
|
||||||
import 'package:pixes/utils/translation.dart';
|
import 'package:pixes/utils/translation.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
|
||||||
@@ -125,25 +130,59 @@ class _IllustGalleryPageState extends State<IllustGalleryPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class IllustPage extends StatefulWidget {
|
class IllustPage extends StatefulWidget {
|
||||||
const IllustPage(this.illust,
|
const IllustPage(this.illust, {this.nextPage, this.previousPage, super.key});
|
||||||
{this.favoriteCallback, this.nextPage, this.previousPage, super.key});
|
|
||||||
|
|
||||||
final Illust illust;
|
final Illust illust;
|
||||||
|
|
||||||
final void Function(bool)? favoriteCallback;
|
|
||||||
|
|
||||||
final void Function()? nextPage;
|
final void Function()? nextPage;
|
||||||
|
|
||||||
final void Function()? previousPage;
|
final void Function()? previousPage;
|
||||||
|
|
||||||
|
static Map<String, UpdateFollowCallback> followCallbacks = {};
|
||||||
|
|
||||||
|
static void updateFollow(String uid, bool isFollowed) {
|
||||||
|
followCallbacks.forEach((key, value) {
|
||||||
|
if (key.startsWith("$uid#")) {
|
||||||
|
value(isFollowed);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<IllustPage> createState() => _IllustPageState();
|
State<IllustPage> createState() => _IllustPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _IllustPageState extends State<IllustPage> {
|
class _IllustPageState extends State<IllustPage> {
|
||||||
|
String get id => "${widget.illust.author.id}#${widget.illust.id}";
|
||||||
|
|
||||||
|
final _bottomBarController = _BottomBarController();
|
||||||
|
|
||||||
|
KeyEventListenerState? keyboardListener;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
keyboardListener = KeyEventListener.of(context);
|
||||||
|
keyboardListener?.removeAll();
|
||||||
|
keyboardListener?.addHandler(handleKey);
|
||||||
|
IllustPage.followCallbacks[id] = (v) {
|
||||||
|
setState(() {
|
||||||
|
widget.illust.author.isFollowed = v;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
keyboardListener?.removeHandler(handleKey);
|
||||||
|
IllustPage.followCallbacks.remove(id);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return buildKeyboardListener(ColoredBox(
|
var isBlocked = checkIllusts([widget.illust]).isEmpty;
|
||||||
|
return ColoredBox(
|
||||||
color: FluentTheme.of(context).micaBackgroundColor,
|
color: FluentTheme.of(context).micaBackgroundColor,
|
||||||
child: SizedBox.expand(
|
child: SizedBox.expand(
|
||||||
child: ColoredBox(
|
child: ColoredBox(
|
||||||
@@ -151,54 +190,82 @@ class _IllustPageState extends State<IllustPage> {
|
|||||||
child: LayoutBuilder(builder: (context, constrains) {
|
child: LayoutBuilder(builder: (context, constrains) {
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
Positioned(
|
if (!isBlocked)
|
||||||
bottom: 0,
|
Positioned(
|
||||||
left: 0,
|
bottom: 0,
|
||||||
right: 0,
|
left: 0,
|
||||||
top: 0,
|
right: 0,
|
||||||
child: buildBody(constrains.maxWidth, constrains.maxHeight),
|
top: 0,
|
||||||
),
|
child: buildBody(constrains.maxWidth, constrains.maxHeight),
|
||||||
_BottomBar(
|
),
|
||||||
widget.illust,
|
if (!isBlocked)
|
||||||
constrains.maxHeight,
|
_BottomBar(
|
||||||
constrains.maxWidth,
|
widget.illust,
|
||||||
favoriteCallback: widget.favoriteCallback,
|
constrains.maxHeight,
|
||||||
),
|
constrains.maxWidth,
|
||||||
|
updateCallback: () => setState(() {}),
|
||||||
|
controller: _bottomBarController,
|
||||||
|
),
|
||||||
|
if (isBlocked)
|
||||||
|
const Positioned.fill(
|
||||||
|
child: Center(
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
"This artwork is blocked",
|
||||||
|
)),
|
||||||
|
))
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final scrollController = ScrollController();
|
final scrollController = ScrollController();
|
||||||
|
|
||||||
Widget buildKeyboardListener(Widget child) {
|
void handleKey(LogicalKeyboardKey key) {
|
||||||
return KeyboardListener(
|
const kShortcutScrollOffset = 200;
|
||||||
focusNode: FocusNode(),
|
|
||||||
autofocus: true,
|
var shortcuts = appdata.settings["shortcuts"] as List;
|
||||||
onKeyEvent: (event) {
|
|
||||||
if (event is! KeyUpEvent) return;
|
switch (shortcuts.indexOf(key.keyId)) {
|
||||||
const kShortcutScrollOffset = 200;
|
case 0:
|
||||||
if (event.logicalKey == LogicalKeyboardKey.arrowDown) {
|
if (scrollController.position.pixels >=
|
||||||
|
scrollController.position.maxScrollExtent) {
|
||||||
|
_bottomBarController.openOrClose();
|
||||||
|
} else {
|
||||||
scrollController.animateTo(
|
scrollController.animateTo(
|
||||||
scrollController.offset + kShortcutScrollOffset,
|
scrollController.offset + kShortcutScrollOffset,
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
curve: Curves.easeOut);
|
curve: Curves.easeOut,
|
||||||
} else if (event.logicalKey == LogicalKeyboardKey.arrowUp) {
|
);
|
||||||
scrollController.animateTo(
|
|
||||||
scrollController.offset - kShortcutScrollOffset,
|
|
||||||
duration: const Duration(milliseconds: 200),
|
|
||||||
curve: Curves.easeOut);
|
|
||||||
} else if (event.logicalKey == LogicalKeyboardKey.arrowRight) {
|
|
||||||
widget.nextPage?.call();
|
|
||||||
} else if (event.logicalKey == LogicalKeyboardKey.arrowLeft) {
|
|
||||||
widget.previousPage?.call();
|
|
||||||
}
|
}
|
||||||
},
|
break;
|
||||||
child: child,
|
case 1:
|
||||||
);
|
if (_bottomBarController.isOpen()) {
|
||||||
|
_bottomBarController.openOrClose();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
scrollController.animateTo(
|
||||||
|
scrollController.offset - kShortcutScrollOffset,
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
curve: Curves.easeOut,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
widget.nextPage?.call();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
widget.previousPage?.call();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
_bottomBarController.favorite();
|
||||||
|
case 5:
|
||||||
|
_bottomBarController.download();
|
||||||
|
case 6:
|
||||||
|
_bottomBarController.follow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildBody(double width, double height) {
|
Widget buildBody(double width, double height) {
|
||||||
@@ -251,6 +318,10 @@ class _IllustPageState extends State<IllustPage> {
|
|||||||
}
|
}
|
||||||
Widget image;
|
Widget image;
|
||||||
|
|
||||||
|
var imageUrl = appdata.settings["showOriginalImage"]
|
||||||
|
? widget.illust.images[index].original
|
||||||
|
: widget.illust.images[index].large;
|
||||||
|
|
||||||
if (!widget.illust.isUgoira) {
|
if (!widget.illust.isUgoira) {
|
||||||
image = SizedBox(
|
image = SizedBox(
|
||||||
width: imageWidth,
|
width: imageWidth,
|
||||||
@@ -260,8 +331,7 @@ class _IllustPageState extends State<IllustPage> {
|
|||||||
child: Image(
|
child: Image(
|
||||||
key: ValueKey(index),
|
key: ValueKey(index),
|
||||||
image: downloadFile == null
|
image: downloadFile == null
|
||||||
? CachedImageProvider(widget.illust.images[index].large)
|
? CachedImageProvider(imageUrl) as ImageProvider
|
||||||
as ImageProvider
|
|
||||||
: FileImage(downloadFile) as ImageProvider,
|
: FileImage(downloadFile) as ImageProvider,
|
||||||
width: imageWidth,
|
width: imageWidth,
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
@@ -304,11 +374,33 @@ class _IllustPageState extends State<IllustPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _BottomBarController {
|
||||||
|
VoidCallback? _openOrClose;
|
||||||
|
|
||||||
|
VoidCallback get openOrClose => _openOrClose!;
|
||||||
|
|
||||||
|
bool Function()? _isOpen;
|
||||||
|
|
||||||
|
bool isOpen() => _isOpen!();
|
||||||
|
|
||||||
|
VoidCallback? _favorite;
|
||||||
|
|
||||||
|
VoidCallback get favorite => _favorite!;
|
||||||
|
|
||||||
|
VoidCallback? _download;
|
||||||
|
|
||||||
|
VoidCallback get download => _download!;
|
||||||
|
|
||||||
|
VoidCallback? _follow;
|
||||||
|
|
||||||
|
VoidCallback get follow => _follow!;
|
||||||
|
}
|
||||||
|
|
||||||
class _BottomBar extends StatefulWidget {
|
class _BottomBar extends StatefulWidget {
|
||||||
const _BottomBar(this.illust, this.height, this.width,
|
const _BottomBar(this.illust, this.height, this.width,
|
||||||
{this.favoriteCallback});
|
{this.updateCallback, this.controller});
|
||||||
|
|
||||||
final void Function(bool)? favoriteCallback;
|
final void Function()? updateCallback;
|
||||||
|
|
||||||
final Illust illust;
|
final Illust illust;
|
||||||
|
|
||||||
@@ -316,6 +408,8 @@ class _BottomBar extends StatefulWidget {
|
|||||||
|
|
||||||
final double width;
|
final double width;
|
||||||
|
|
||||||
|
final _BottomBarController? controller;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<_BottomBar> createState() => _BottomBarState();
|
State<_BottomBar> createState() => _BottomBarState();
|
||||||
}
|
}
|
||||||
@@ -352,9 +446,32 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
|||||||
..onCancel = _handlePointerCancel;
|
..onCancel = _handlePointerCancel;
|
||||||
animationController = AnimationController(
|
animationController = AnimationController(
|
||||||
vsync: this, duration: const Duration(milliseconds: 180), value: 1);
|
vsync: this, duration: const Duration(milliseconds: 180), value: 1);
|
||||||
|
if (widget.controller != null) {
|
||||||
|
widget.controller!._openOrClose = () {
|
||||||
|
if (animationController.value == 0) {
|
||||||
|
animationController.animateTo(1);
|
||||||
|
} else if (animationController.value == 1) {
|
||||||
|
animationController.animateTo(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
widget.controller!._isOpen = () => animationController.value == 0;
|
||||||
|
widget.controller!._favorite = favorite;
|
||||||
|
widget.controller!._download = () {
|
||||||
|
DownloadManager().addDownloadingTask(widget.illust);
|
||||||
|
setState(() {});
|
||||||
|
};
|
||||||
|
widget.controller!._follow = follow;
|
||||||
|
}
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
animationController.dispose();
|
||||||
|
_recognizer.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
void _handlePointerDown(DragStartDetails details) {}
|
void _handlePointerDown(DragStartDetails details) {}
|
||||||
void _handlePointerMove(DragUpdateDetails details) {
|
void _handlePointerMove(DragUpdateDetails details) {
|
||||||
var offset = details.primaryDelta ?? 0;
|
var offset = details.primaryDelta ?? 0;
|
||||||
@@ -378,8 +495,9 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _handlePointerCancel() {
|
void _handlePointerCancel() {
|
||||||
if (animationController.value == 1 || animationController.value == 0)
|
if (animationController.value == 1 || animationController.value == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (animationController.value >= 0.5) {
|
if (animationController.value >= 0.5) {
|
||||||
animationController.forward();
|
animationController.forward();
|
||||||
} else {
|
} else {
|
||||||
@@ -501,27 +619,31 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
|||||||
|
|
||||||
bool isFollowing = false;
|
bool isFollowing = false;
|
||||||
|
|
||||||
Widget buildAuthor() {
|
void follow() async {
|
||||||
void follow() async {
|
if (isFollowing) return;
|
||||||
if (isFollowing) return;
|
setState(() {
|
||||||
setState(() {
|
isFollowing = true;
|
||||||
isFollowing = true;
|
});
|
||||||
});
|
var method = widget.illust.author.isFollowed ? "delete" : "add";
|
||||||
var method = widget.illust.author.isFollowed ? "delete" : "add";
|
var res =
|
||||||
var res =
|
await Network().follow(widget.illust.author.id.toString(), method);
|
||||||
await Network().follow(widget.illust.author.id.toString(), method);
|
if (res.error) {
|
||||||
if (res.error) {
|
if (mounted) {
|
||||||
if (mounted) {
|
context.showToast(message: "Network Error");
|
||||||
context.showToast(message: "Network Error");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
widget.illust.author.isFollowed = !widget.illust.author.isFollowed;
|
|
||||||
}
|
}
|
||||||
setState(() {
|
} else {
|
||||||
isFollowing = false;
|
widget.illust.author.isFollowed = !widget.illust.author.isFollowed;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
setState(() {
|
||||||
|
isFollowing = false;
|
||||||
|
});
|
||||||
|
UserInfoPage.followCallbacks[widget.illust.author.id.toString()]
|
||||||
|
?.call(widget.illust.author.isFollowed);
|
||||||
|
UserPreviewWidget.followCallbacks[widget.illust.author.id.toString()]
|
||||||
|
?.call(widget.illust.author.isFollowed);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildAuthor() {
|
||||||
final bool showUserName = MediaQuery.of(context).size.width > 640;
|
final bool showUserName = MediaQuery.of(context).size.width > 640;
|
||||||
|
|
||||||
return Card(
|
return Card(
|
||||||
@@ -543,9 +665,6 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
|||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () => context.to(() => UserInfoPage(
|
onTap: () => context.to(() => UserInfoPage(
|
||||||
widget.illust.author.id.toString(),
|
widget.illust.author.id.toString(),
|
||||||
followCallback: (b) => setState(() {
|
|
||||||
widget.illust.author.isFollowed = b;
|
|
||||||
}),
|
|
||||||
)),
|
)),
|
||||||
child: AnimatedImage(
|
child: AnimatedImage(
|
||||||
image: CachedImageProvider(widget.illust.author.avatar),
|
image: CachedImageProvider(widget.illust.author.avatar),
|
||||||
@@ -615,7 +734,8 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
widget.illust.isBookmarked = !widget.illust.isBookmarked;
|
widget.illust.isBookmarked = !widget.illust.isBookmarked;
|
||||||
widget.favoriteCallback?.call(widget.illust.isBookmarked);
|
IllustWidget.favoriteCallbacks[widget.illust.id.toString()]
|
||||||
|
?.call(widget.illust.isBookmarked);
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
isBookmarking = false;
|
isBookmarking = false;
|
||||||
@@ -876,7 +996,9 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget buildMoreActions() {
|
Widget buildMoreActions() {
|
||||||
return Row(
|
return Wrap(
|
||||||
|
runSpacing: 4,
|
||||||
|
spacing: 8,
|
||||||
children: [
|
children: [
|
||||||
Button(
|
Button(
|
||||||
onPressed: () => favorite("private"),
|
onPressed: () => favorite("private"),
|
||||||
@@ -913,10 +1035,7 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
).fixWidth(96),
|
||||||
const SizedBox(
|
|
||||||
width: 6,
|
|
||||||
),
|
|
||||||
Button(
|
Button(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Share.share(
|
Share.share(
|
||||||
@@ -937,10 +1056,7 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
).fixWidth(96),
|
||||||
const SizedBox(
|
|
||||||
width: 6,
|
|
||||||
),
|
|
||||||
Button(
|
Button(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
var text = "https://pixiv.net/artworks/${widget.illust.id}";
|
var text = "https://pixiv.net/artworks/${widget.illust.id}";
|
||||||
@@ -959,10 +1075,7 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
).fixWidth(96),
|
||||||
const SizedBox(
|
|
||||||
width: 6,
|
|
||||||
),
|
|
||||||
Button(
|
Button(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.to(() => _RelatedIllustsPage(widget.illust.id.toString()));
|
context.to(() => _RelatedIllustsPage(widget.illust.id.toString()));
|
||||||
@@ -979,12 +1092,189 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
).fixWidth(96),
|
||||||
|
Button(
|
||||||
|
onPressed: () async {
|
||||||
|
await Navigator.of(context)
|
||||||
|
.push(SideBarRoute(_BlockingPage(widget.illust)));
|
||||||
|
if (mounted) {
|
||||||
|
widget.updateCallback?.call();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: SizedBox(
|
||||||
|
height: 28,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(MdIcons.block, size: 18),
|
||||||
|
const SizedBox(
|
||||||
|
width: 8,
|
||||||
|
),
|
||||||
|
Text("Block".tl)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).fixWidth(96),
|
||||||
],
|
],
|
||||||
).paddingHorizontal(2).paddingBottom(4);
|
).paddingHorizontal(2).paddingBottom(4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _BlockingPage extends StatefulWidget {
|
||||||
|
const _BlockingPage(this.illust);
|
||||||
|
|
||||||
|
final Illust illust;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_BlockingPage> createState() => __BlockingPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class __BlockingPageState extends State<_BlockingPage> {
|
||||||
|
List<int> blockedTags = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
TitleBar(title: "Block".tl),
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
padding: EdgeInsets.only(bottom: context.padding.bottom),
|
||||||
|
itemCount: widget.illust.tags.length + 2,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index == widget.illust.tags.length + 1) {
|
||||||
|
return buildSubmit();
|
||||||
|
}
|
||||||
|
|
||||||
|
var text = index == 0
|
||||||
|
? widget.illust.author.name
|
||||||
|
: widget.illust.tags[index - 1].name;
|
||||||
|
|
||||||
|
var subTitle = index == 0
|
||||||
|
? "author"
|
||||||
|
: widget.illust.tags[index - 1].translatedName ?? "";
|
||||||
|
|
||||||
|
return Card(
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||||
|
borderColor: blockedTags.contains(index)
|
||||||
|
? ColorScheme.of(context).outlineVariant
|
||||||
|
: ColorScheme.of(context).outlineVariant.withOpacity(0.2),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(text),
|
||||||
|
subtitle: Text(subTitle),
|
||||||
|
trailing: Button(
|
||||||
|
onPressed: () {
|
||||||
|
if (blockedTags.contains(index)) {
|
||||||
|
blockedTags.remove(index);
|
||||||
|
} else {
|
||||||
|
blockedTags.add(index);
|
||||||
|
}
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: blockedTags.contains(index)
|
||||||
|
? Text("Cancel".tl)
|
||||||
|
: Text("Block".tl))
|
||||||
|
.fixWidth(72),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
var flyout = FlyoutController();
|
||||||
|
|
||||||
|
bool isSubmitting = false;
|
||||||
|
|
||||||
|
Widget buildSubmit() {
|
||||||
|
return FlyoutTarget(
|
||||||
|
controller: flyout,
|
||||||
|
child: FilledButton(
|
||||||
|
onPressed: () async {
|
||||||
|
if (this.blockedTags.isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isSubmitting) return;
|
||||||
|
var blockedTags = <String>[];
|
||||||
|
var blockedUsers = <String>[];
|
||||||
|
for (var i in this.blockedTags) {
|
||||||
|
if (i == 0) {
|
||||||
|
blockedUsers.add(widget.illust.author.id.toString());
|
||||||
|
} else {
|
||||||
|
blockedTags.add(widget.illust.tags[i - 1].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool addToAccount = false;
|
||||||
|
bool addToLocal = false;
|
||||||
|
if (appdata.account!.user.isPremium) {
|
||||||
|
await flyout.showFlyout(
|
||||||
|
navigatorKey: App.rootNavigatorKey.currentState,
|
||||||
|
builder: (context) {
|
||||||
|
return MenuFlyout(
|
||||||
|
items: [
|
||||||
|
MenuFlyoutItem(
|
||||||
|
text: Text("Local".tl),
|
||||||
|
onPressed: () {
|
||||||
|
addToLocal = true;
|
||||||
|
}),
|
||||||
|
MenuFlyoutItem(
|
||||||
|
text: Text("Account".tl),
|
||||||
|
onPressed: () {
|
||||||
|
addToAccount = true;
|
||||||
|
}),
|
||||||
|
MenuFlyoutItem(
|
||||||
|
text: Text("Both".tl),
|
||||||
|
onPressed: () {
|
||||||
|
addToLocal = true;
|
||||||
|
addToAccount = true;
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addToLocal = true;
|
||||||
|
}
|
||||||
|
if (addToAccount) {
|
||||||
|
setState(() {
|
||||||
|
isSubmitting = true;
|
||||||
|
});
|
||||||
|
var res =
|
||||||
|
await Network().editMute(blockedTags, blockedUsers, [], []);
|
||||||
|
setState(() {
|
||||||
|
isSubmitting = false;
|
||||||
|
});
|
||||||
|
if (res.error) {
|
||||||
|
if (mounted) {
|
||||||
|
context.showToast(message: "Network Error");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (addToLocal) {
|
||||||
|
for (var tag in blockedTags) {
|
||||||
|
appdata.settings['blockTags'].add(tag);
|
||||||
|
}
|
||||||
|
for (var user in blockedUsers) {
|
||||||
|
appdata.settings['blockTags'].add('user:$user');
|
||||||
|
}
|
||||||
|
appdata.writeSettings();
|
||||||
|
}
|
||||||
|
if (mounted) {
|
||||||
|
context.pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: isSubmitting
|
||||||
|
? const ProgressRing(
|
||||||
|
strokeWidth: 1.6,
|
||||||
|
).fixWidth(18).fixHeight(18).toAlign(Alignment.center)
|
||||||
|
: Text("Submit".tl),
|
||||||
|
).fixWidth(96).fixHeight(32),
|
||||||
|
).toAlign(Alignment.center).paddingTop(16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class IllustPageWithId extends StatefulWidget {
|
class IllustPageWithId extends StatefulWidget {
|
||||||
const IllustPageWithId(this.id, {super.key});
|
const IllustPageWithId(this.id, {super.key});
|
||||||
|
|
||||||
|
@@ -201,35 +201,37 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Positioned(
|
if (currentPage != 0)
|
||||||
left: 0,
|
Positioned(
|
||||||
top: height / 2 - 9,
|
left: 0,
|
||||||
child: IconButton(
|
top: height / 2 - 9,
|
||||||
icon: const Icon(
|
child: IconButton(
|
||||||
FluentIcons.chevron_left,
|
icon: const Icon(
|
||||||
size: 18,
|
FluentIcons.chevron_left,
|
||||||
),
|
size: 18,
|
||||||
onPressed: () {
|
),
|
||||||
controller.previousPage(
|
onPressed: () {
|
||||||
duration: const Duration(milliseconds: 300),
|
controller.previousPage(
|
||||||
curve: Curves.easeInOut,
|
duration: const Duration(milliseconds: 300),
|
||||||
);
|
curve: Curves.easeInOut,
|
||||||
},
|
);
|
||||||
).paddingAll(8),
|
},
|
||||||
),
|
).paddingAll(8),
|
||||||
Positioned(
|
),
|
||||||
right: 0,
|
if (currentPage != widget.urls.length - 1)
|
||||||
top: height / 2 - 9,
|
Positioned(
|
||||||
child: IconButton(
|
right: 0,
|
||||||
icon: const Icon(FluentIcons.chevron_right, size: 18),
|
top: height / 2 - 9,
|
||||||
onPressed: () {
|
child: IconButton(
|
||||||
controller.nextPage(
|
icon: const Icon(FluentIcons.chevron_right, size: 18),
|
||||||
duration: const Duration(milliseconds: 300),
|
onPressed: () {
|
||||||
curve: Curves.easeInOut,
|
controller.nextPage(
|
||||||
);
|
duration: const Duration(milliseconds: 300),
|
||||||
},
|
curve: Curves.easeInOut,
|
||||||
).paddingAll(8),
|
);
|
||||||
),
|
},
|
||||||
|
).paddingAll(8),
|
||||||
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
left: 12,
|
left: 12,
|
||||||
bottom: 8,
|
bottom: 8,
|
||||||
@@ -252,16 +254,16 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
child: width > 600
|
child: width > 600
|
||||||
? Button(
|
? Button(
|
||||||
onPressed: showMenu,
|
onPressed: showMenu,
|
||||||
child: const Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
const Icon(
|
||||||
MdIcons.menu,
|
MdIcons.menu,
|
||||||
size: 18,
|
size: 18,
|
||||||
),
|
),
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
width: 8,
|
width: 8,
|
||||||
),
|
),
|
||||||
Text('Actions'),
|
Text('Actions'.tl),
|
||||||
],
|
],
|
||||||
))
|
))
|
||||||
: IconButton(
|
: IconButton(
|
||||||
|
@@ -20,6 +20,7 @@ import "package:pixes/pages/login_page.dart";
|
|||||||
import "package:pixes/pages/search_page.dart";
|
import "package:pixes/pages/search_page.dart";
|
||||||
import "package:pixes/pages/settings_page.dart";
|
import "package:pixes/pages/settings_page.dart";
|
||||||
import "package:pixes/pages/user_info_page.dart";
|
import "package:pixes/pages/user_info_page.dart";
|
||||||
|
import "package:pixes/utils/loop.dart";
|
||||||
import "package:pixes/utils/mouse_listener.dart";
|
import "package:pixes/utils/mouse_listener.dart";
|
||||||
import "package:pixes/utils/translation.dart";
|
import "package:pixes/utils/translation.dart";
|
||||||
import "package:window_manager/window_manager.dart";
|
import "package:window_manager/window_manager.dart";
|
||||||
@@ -150,7 +151,9 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
),
|
),
|
||||||
PaneItemSeparator(),
|
PaneItemSeparator(),
|
||||||
PaneItemHeader(
|
PaneItemHeader(
|
||||||
header: Text("Artwork".tl).paddingBottom(4).paddingLeft(8)),
|
header: Text('${"Artwork".tl}/${"Manga".tl}')
|
||||||
|
.paddingBottom(4)
|
||||||
|
.paddingLeft(8)),
|
||||||
PaneItem(
|
PaneItem(
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
MdIcons.explore_outlined,
|
MdIcons.explore_outlined,
|
||||||
@@ -268,11 +271,17 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
if (!App.isDesktop) const Spacer(),
|
if (!App.isDesktop) const Spacer(),
|
||||||
if (App.isDesktop)
|
if (App.isDesktop)
|
||||||
const Expanded(
|
const Expanded(
|
||||||
child: DragToMoveArea(
|
child: SizedBox(
|
||||||
|
height: double.infinity,
|
||||||
|
child: DragToMoveArea(
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
child: Text(
|
child: Text(
|
||||||
"Pixes",
|
"Pixes",
|
||||||
style: TextStyle(fontSize: 13),
|
style: TextStyle(fontSize: 13),
|
||||||
)),
|
),
|
||||||
|
)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
for (var action in controller.actions)
|
for (var action in controller.actions)
|
||||||
Button(
|
Button(
|
||||||
@@ -327,28 +336,22 @@ class _BackButtonState extends State<_BackButton> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
enabled = navigatorKey.currentState?.canPop() == true;
|
enabled = navigatorKey.currentState?.canPop() == true;
|
||||||
loop();
|
Loop.register(loop);
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
timer = Timer.periodic(const Duration(milliseconds: 100), (timer) {
|
bool enabled = navigatorKey.currentState?.canPop() == true;
|
||||||
if (!mounted) {
|
if (enabled != this.enabled) {
|
||||||
timer.cancel();
|
setState(() {
|
||||||
} else {
|
this.enabled = enabled;
|
||||||
bool enabled = navigatorKey.currentState?.canPop() == true;
|
});
|
||||||
if (enabled != this.enabled) {
|
}
|
||||||
setState(() {
|
|
||||||
this.enabled = enabled;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
timer?.cancel();
|
Loop.remove(loop);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,15 +29,16 @@ class _NovelReadingPageState extends LoadingState<NovelReadingPage, String> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
action = TitleBarAction(MdIcons.tune, "Settings", () {
|
action = TitleBarAction(MdIcons.tune, "Settings".tl, () {
|
||||||
if (!isShowingSettings) {
|
if (!isShowingSettings) {
|
||||||
_NovelReadingSettings.show(context, () {
|
_NovelReadingSettings.show(context, () {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
}).then((value) {
|
||||||
|
isShowingSettings = false;
|
||||||
});
|
});
|
||||||
isShowingSettings = true;
|
isShowingSettings = true;
|
||||||
} else {
|
} else {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
isShowingSettings = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Future.delayed(const Duration(milliseconds: 200), () {
|
Future.delayed(const Duration(milliseconds: 200), () {
|
||||||
@@ -136,8 +137,9 @@ class _NovelReadingSettings extends StatefulWidget {
|
|||||||
|
|
||||||
final void Function() callback;
|
final void Function() callback;
|
||||||
|
|
||||||
static void show(BuildContext context, void Function() callback) {
|
static Future show(BuildContext context, void Function() callback) {
|
||||||
Navigator.of(context).push(SideBarRoute(_NovelReadingSettings(callback)));
|
return Navigator.of(context)
|
||||||
|
.push(SideBarRoute(_NovelReadingSettings(callback)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import 'package:fluent_ui/fluent_ui.dart';
|
import 'package:fluent_ui/fluent_ui.dart';
|
||||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||||
import 'package:pixes/foundation/app.dart';
|
import 'package:pixes/foundation/app.dart';
|
||||||
|
import 'package:pixes/utils/block.dart';
|
||||||
import 'package:pixes/utils/translation.dart';
|
import 'package:pixes/utils/translation.dart';
|
||||||
|
|
||||||
import '../components/batch_download.dart';
|
import '../components/batch_download.dart';
|
||||||
@@ -86,6 +87,7 @@ class _OneRankingPage extends StatefulWidget {
|
|||||||
class _OneRankingPageState extends MultiPageLoadingState<_OneRankingPage, Illust> {
|
class _OneRankingPageState extends MultiPageLoadingState<_OneRankingPage, Illust> {
|
||||||
@override
|
@override
|
||||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||||
|
checkIllusts(data);
|
||||||
return LayoutBuilder(builder: (context, constrains){
|
return LayoutBuilder(builder: (context, constrains){
|
||||||
return MasonryGridView.builder(
|
return MasonryGridView.builder(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8)
|
padding: const EdgeInsets.symmetric(horizontal: 8)
|
||||||
|
@@ -6,6 +6,7 @@ import 'package:pixes/components/title_bar.dart';
|
|||||||
import 'package:pixes/foundation/app.dart';
|
import 'package:pixes/foundation/app.dart';
|
||||||
import 'package:pixes/network/network.dart';
|
import 'package:pixes/network/network.dart';
|
||||||
import 'package:pixes/pages/illust_page.dart';
|
import 'package:pixes/pages/illust_page.dart';
|
||||||
|
import 'package:pixes/utils/block.dart';
|
||||||
import 'package:pixes/utils/translation.dart';
|
import 'package:pixes/utils/translation.dart';
|
||||||
|
|
||||||
import '../components/grid.dart';
|
import '../components/grid.dart';
|
||||||
@@ -75,6 +76,7 @@ class _RecommendationArtworksPageState
|
|||||||
extends MultiPageLoadingState<_RecommendationArtworksPage, Illust> {
|
extends MultiPageLoadingState<_RecommendationArtworksPage, Illust> {
|
||||||
@override
|
@override
|
||||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||||
|
checkIllusts(data);
|
||||||
return LayoutBuilder(builder: (context, constrains) {
|
return LayoutBuilder(builder: (context, constrains) {
|
||||||
return MasonryGridView.builder(
|
return MasonryGridView.builder(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8) +
|
padding: const EdgeInsets.symmetric(horizontal: 8) +
|
||||||
|
@@ -2,7 +2,6 @@ import 'package:fluent_ui/fluent_ui.dart';
|
|||||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||||
import 'package:pixes/appdata.dart';
|
import 'package:pixes/appdata.dart';
|
||||||
import 'package:pixes/components/loading.dart';
|
import 'package:pixes/components/loading.dart';
|
||||||
import 'package:pixes/components/message.dart';
|
|
||||||
import 'package:pixes/components/novel.dart';
|
import 'package:pixes/components/novel.dart';
|
||||||
import 'package:pixes/components/page_route.dart';
|
import 'package:pixes/components/page_route.dart';
|
||||||
import 'package:pixes/components/user_preview.dart';
|
import 'package:pixes/components/user_preview.dart';
|
||||||
@@ -11,6 +10,9 @@ import 'package:pixes/network/network.dart';
|
|||||||
import 'package:pixes/pages/illust_page.dart';
|
import 'package:pixes/pages/illust_page.dart';
|
||||||
import 'package:pixes/pages/novel_page.dart';
|
import 'package:pixes/pages/novel_page.dart';
|
||||||
import 'package:pixes/pages/user_info_page.dart';
|
import 'package:pixes/pages/user_info_page.dart';
|
||||||
|
import 'package:pixes/utils/app_links.dart';
|
||||||
|
import 'package:pixes/utils/block.dart';
|
||||||
|
import 'package:pixes/utils/ext.dart';
|
||||||
import 'package:pixes/utils/translation.dart';
|
import 'package:pixes/utils/translation.dart';
|
||||||
|
|
||||||
import '../components/animated_image.dart';
|
import '../components/animated_image.dart';
|
||||||
@@ -41,6 +43,12 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
];
|
];
|
||||||
|
|
||||||
void search() {
|
void search() {
|
||||||
|
if (text.isURL && handleLink(Uri.parse(text))) {
|
||||||
|
return;
|
||||||
|
} else if ("https://$text".isURL &&
|
||||||
|
handleLink(Uri.parse("https://$text"))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
switch (searchType) {
|
switch (searchType) {
|
||||||
case 0:
|
case 0:
|
||||||
context.to(() => SearchResultPage(text));
|
context.to(() => SearchResultPage(text));
|
||||||
@@ -92,7 +100,8 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextBox(
|
child: TextBox(
|
||||||
placeholder: searchTypes[searchType].tl,
|
placeholder:
|
||||||
|
'${searchTypes[searchType].tl} / ${"Open link".tl}',
|
||||||
onChanged: (s) => text = s,
|
onChanged: (s) => text = s,
|
||||||
onSubmitted: (s) => search(),
|
onSubmitted: (s) => search(),
|
||||||
foregroundDecoration: BoxDecoration(
|
foregroundDecoration: BoxDecoration(
|
||||||
@@ -127,10 +136,9 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
optionController.showFlyout(
|
optionController.showFlyout(
|
||||||
navigatorKey: App.rootNavigatorKey.currentState,
|
placementMode: FlyoutPlacementMode.bottomCenter,
|
||||||
placementMode: FlyoutPlacementMode.bottomCenter,
|
builder: buildSearchOption,
|
||||||
builder: buildSearchOption,
|
barrierColor: Colors.transparent);
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -456,6 +464,7 @@ class _SearchResultPageState
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||||
|
checkIllusts(data);
|
||||||
return CustomScrollView(
|
return CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
buildSearchBar(),
|
buildSearchBar(),
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:fluent_ui/fluent_ui.dart';
|
import 'package:fluent_ui/fluent_ui.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:pixes/appdata.dart';
|
import 'package:pixes/appdata.dart';
|
||||||
|
import 'package:pixes/components/keyboard.dart';
|
||||||
import 'package:pixes/components/md.dart';
|
import 'package:pixes/components/md.dart';
|
||||||
import 'package:pixes/components/message.dart';
|
import 'package:pixes/components/message.dart';
|
||||||
import 'package:pixes/components/page_route.dart';
|
import 'package:pixes/components/page_route.dart';
|
||||||
@@ -131,16 +133,16 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
context.to(() => _SetSingleFieldPage(
|
context.to(() => _SetSingleFieldPage(
|
||||||
"Download Path".tl,
|
"Download Path".tl,
|
||||||
"downloadPath",
|
"downloadPath",
|
||||||
check: (text) {
|
check: (text) {
|
||||||
if(!Directory(text).havePermission()) {
|
if (!Directory(text).havePermission()) {
|
||||||
return "No permission".tl;
|
return "No permission".tl;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
buildItem(
|
buildItem(
|
||||||
@@ -182,23 +184,30 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||||||
buildItem(
|
buildItem(
|
||||||
title: "Github",
|
title: "Github",
|
||||||
action: IconButton(
|
action: IconButton(
|
||||||
icon: const Icon(MdIcons.open_in_new, size: 18,),
|
icon: const Icon(
|
||||||
|
MdIcons.open_in_new,
|
||||||
|
size: 18,
|
||||||
|
),
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
launchUrlString("https://github.com/wgh136/pixes"),
|
launchUrlString("https://github.com/wgh136/pixes"),
|
||||||
)),
|
)),
|
||||||
buildItem(
|
buildItem(
|
||||||
title: "Telegram",
|
title: "Telegram",
|
||||||
action: IconButton(
|
action: IconButton(
|
||||||
icon: const Icon(MdIcons.open_in_new, size: 18,),
|
icon: const Icon(
|
||||||
onPressed: () =>
|
MdIcons.open_in_new,
|
||||||
launchUrlString("https://t.me/pica_group"),
|
size: 18,
|
||||||
|
),
|
||||||
|
onPressed: () => launchUrlString("https://t.me/pica_group"),
|
||||||
)),
|
)),
|
||||||
buildItem(
|
buildItem(
|
||||||
title: "Logs",
|
title: "Logs",
|
||||||
action: IconButton(
|
action: IconButton(
|
||||||
icon: const Icon(MdIcons.open_in_new, size: 18,),
|
icon: const Icon(
|
||||||
onPressed: () => context.to(() => const LogsPage())
|
MdIcons.open_in_new,
|
||||||
)),
|
size: 18,
|
||||||
|
),
|
||||||
|
onPressed: () => context.to(() => const LogsPage()))),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -214,11 +223,45 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||||||
child: Text("Edit".tl).fixWidth(64),
|
child: Text("Edit".tl).fixWidth(64),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.to(() => _SetSingleFieldPage(
|
context.to(() => _SetSingleFieldPage(
|
||||||
"Http ${"Proxy".tl}",
|
"Http ${"Proxy".tl}",
|
||||||
"proxy",
|
"proxy",
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
|
buildItem(
|
||||||
|
title: "Block(Account)".tl,
|
||||||
|
action: Button(
|
||||||
|
child: Text("Edit".tl).fixWidth(64),
|
||||||
|
onPressed: () {
|
||||||
|
launchUrlString("https://www.pixiv.net/setting_mute.php");
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
buildItem(
|
||||||
|
title: "Block(Local)".tl,
|
||||||
|
action: Button(
|
||||||
|
child: Text("Edit".tl).fixWidth(64),
|
||||||
|
onPressed: () {
|
||||||
|
context.to(() => const _BlockTagsPage());
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
buildItem(
|
||||||
|
title: "Shortcuts".tl,
|
||||||
|
action: Button(
|
||||||
|
child: Text("Edit".tl).fixWidth(64),
|
||||||
|
onPressed: () {
|
||||||
|
context.to(() => const ShortcutsSettings());
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
buildItem(
|
||||||
|
title: "Display the original image on the details page".tl,
|
||||||
|
action: ToggleSwitch(
|
||||||
|
checked: appdata.settings['showOriginalImage'],
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
appdata.settings['showOriginalImage'] = value;
|
||||||
|
});
|
||||||
|
appdata.writeData();
|
||||||
|
})),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -231,63 +274,77 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||||||
buildItem(
|
buildItem(
|
||||||
title: "Theme".tl,
|
title: "Theme".tl,
|
||||||
action: DropDownButton(
|
action: DropDownButton(
|
||||||
title: Text(appdata.settings["theme"] ?? "System".tl),
|
title: Text(appdata.settings["theme"] ?? "System".tl),
|
||||||
items: [
|
items: [
|
||||||
MenuFlyoutItem(text: Text("System".tl), onPressed: () {
|
MenuFlyoutItem(
|
||||||
setState(() {
|
text: Text("System".tl),
|
||||||
appdata.settings["theme"] = "System";
|
onPressed: () {
|
||||||
});
|
setState(() {
|
||||||
appdata.writeData();
|
appdata.settings["theme"] = "System";
|
||||||
StateController.findOrNull(tag: "MyApp")?.update();
|
});
|
||||||
}),
|
appdata.writeData();
|
||||||
MenuFlyoutItem(text: Text("light".tl), onPressed: () {
|
StateController.findOrNull(tag: "MyApp")?.update();
|
||||||
setState(() {
|
}),
|
||||||
appdata.settings["theme"] = "Light";
|
MenuFlyoutItem(
|
||||||
});
|
text: Text("light".tl),
|
||||||
appdata.writeData();
|
onPressed: () {
|
||||||
StateController.findOrNull(tag: "MyApp")?.update();
|
setState(() {
|
||||||
}),
|
appdata.settings["theme"] = "Light";
|
||||||
MenuFlyoutItem(text: Text("dark".tl), onPressed: () {
|
});
|
||||||
setState(() {
|
appdata.writeData();
|
||||||
appdata.settings["theme"] = "Dark";
|
StateController.findOrNull(tag: "MyApp")?.update();
|
||||||
});
|
}),
|
||||||
appdata.writeData();
|
MenuFlyoutItem(
|
||||||
StateController.findOrNull(tag: "MyApp")?.update();
|
text: Text("dark".tl),
|
||||||
}),
|
onPressed: () {
|
||||||
])),
|
setState(() {
|
||||||
|
appdata.settings["theme"] = "Dark";
|
||||||
|
});
|
||||||
|
appdata.writeData();
|
||||||
|
StateController.findOrNull(tag: "MyApp")?.update();
|
||||||
|
}),
|
||||||
|
])),
|
||||||
buildItem(
|
buildItem(
|
||||||
title: "Language".tl,
|
title: "Language".tl,
|
||||||
action: DropDownButton(
|
action: DropDownButton(
|
||||||
title: Text(appdata.settings["language"] ?? "System"),
|
title: Text(appdata.settings["language"] ?? "System"),
|
||||||
items: [
|
items: [
|
||||||
MenuFlyoutItem(text: const Text("System"), onPressed: () {
|
MenuFlyoutItem(
|
||||||
setState(() {
|
text: const Text("System"),
|
||||||
appdata.settings["language"] = "System";
|
onPressed: () {
|
||||||
});
|
setState(() {
|
||||||
appdata.writeData();
|
appdata.settings["language"] = "System";
|
||||||
StateController.findOrNull(tag: "MyApp")?.update();
|
});
|
||||||
}),
|
appdata.writeData();
|
||||||
MenuFlyoutItem(text: const Text("English"), onPressed: () {
|
StateController.findOrNull(tag: "MyApp")?.update();
|
||||||
setState(() {
|
}),
|
||||||
appdata.settings["language"] = "English";
|
MenuFlyoutItem(
|
||||||
});
|
text: const Text("English"),
|
||||||
appdata.writeData();
|
onPressed: () {
|
||||||
StateController.findOrNull(tag: "MyApp")?.update();
|
setState(() {
|
||||||
}),
|
appdata.settings["language"] = "English";
|
||||||
MenuFlyoutItem(text: const Text("简体中文"), onPressed: () {
|
});
|
||||||
setState(() {
|
appdata.writeData();
|
||||||
appdata.settings["language"] = "简体中文";
|
StateController.findOrNull(tag: "MyApp")?.update();
|
||||||
});
|
}),
|
||||||
appdata.writeData();
|
MenuFlyoutItem(
|
||||||
StateController.findOrNull(tag: "MyApp")?.update();
|
text: const Text("简体中文"),
|
||||||
}),
|
onPressed: () {
|
||||||
MenuFlyoutItem(text: const Text("繁體中文"), onPressed: () {
|
setState(() {
|
||||||
setState(() {
|
appdata.settings["language"] = "简体中文";
|
||||||
appdata.settings["language"] = "繁體中文";
|
});
|
||||||
});
|
appdata.writeData();
|
||||||
appdata.writeData();
|
StateController.findOrNull(tag: "MyApp")?.update();
|
||||||
StateController.findOrNull(tag: "MyApp")?.update();
|
}),
|
||||||
}),
|
MenuFlyoutItem(
|
||||||
|
text: const Text("繁體中文"),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
appdata.settings["language"] = "繁體中文";
|
||||||
|
});
|
||||||
|
appdata.writeData();
|
||||||
|
StateController.findOrNull(tag: "MyApp")?.update();
|
||||||
|
}),
|
||||||
])),
|
])),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -416,3 +473,166 @@ ${"Some keywords will be replaced by the following rule:".tl}
|
|||||||
${"Multiple path separators will be automatically replaced with a single".tl}
|
${"Multiple path separators will be automatically replaced with a single".tl}
|
||||||
""";
|
""";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _BlockTagsPage extends StatefulWidget {
|
||||||
|
const _BlockTagsPage();
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_BlockTagsPage> createState() => __BlockTagsPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class __BlockTagsPageState extends State<_BlockTagsPage> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
TitleBar(
|
||||||
|
title: "Block".tl,
|
||||||
|
action: FilledButton(
|
||||||
|
child: Text("Add".tl),
|
||||||
|
onPressed: () {
|
||||||
|
var controller = TextEditingController();
|
||||||
|
|
||||||
|
void finish(BuildContext context) {
|
||||||
|
var text = controller.text;
|
||||||
|
if (text.isNotEmpty &&
|
||||||
|
!(appdata.settings["blockTags"] as List).contains(text)) {
|
||||||
|
setState(() {
|
||||||
|
appdata.settings["blockTags"].add(text);
|
||||||
|
});
|
||||||
|
appdata.writeSettings();
|
||||||
|
}
|
||||||
|
context.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: true,
|
||||||
|
builder: (context) {
|
||||||
|
return ContentDialog(
|
||||||
|
title: Text("Add".tl),
|
||||||
|
content: SizedBox(
|
||||||
|
width: 300,
|
||||||
|
height: 32,
|
||||||
|
child: TextBox(
|
||||||
|
controller: controller,
|
||||||
|
onSubmitted: (v) => finish(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
FilledButton(
|
||||||
|
child: Text("Submit".tl),
|
||||||
|
onPressed: () {
|
||||||
|
finish(context);
|
||||||
|
})
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: appdata.settings["blockTags"].length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return Card(
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(appdata.settings["blockTags"][index]),
|
||||||
|
trailing: Button(
|
||||||
|
child: Text("Delete".tl),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
(appdata.settings["blockTags"] as List).removeAt(index);
|
||||||
|
});
|
||||||
|
appdata.writeSettings();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ShortcutsSettings extends StatefulWidget {
|
||||||
|
const ShortcutsSettings({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ShortcutsSettings> createState() => _ShortcutsSettingsState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ShortcutsSettingsState extends State<ShortcutsSettings> {
|
||||||
|
int listening = -1;
|
||||||
|
|
||||||
|
KeyEventListenerState? listener;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
listener = KeyEventListener.of(context);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
listener?.removeAll();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
final settings = <String>[
|
||||||
|
"Page down",
|
||||||
|
"Page up",
|
||||||
|
"Next work",
|
||||||
|
"Previous work",
|
||||||
|
"Add to favorites",
|
||||||
|
"Download",
|
||||||
|
"Follow the artist",
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SingleChildScrollView(
|
||||||
|
child: Column(children: [
|
||||||
|
TitleBar(title: "Shortcuts".tl),
|
||||||
|
...settings.map((e) => buildItem(e, settings.indexOf(e)))
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildItem(String text, int index) {
|
||||||
|
var keyText = listening == index
|
||||||
|
? "Waiting..."
|
||||||
|
: LogicalKeyboardKey(appdata.settings['shortcuts'][index]).keyLabel;
|
||||||
|
return Card(
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 12),
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(text.tl),
|
||||||
|
trailing: Button(
|
||||||
|
child: Text(keyText),
|
||||||
|
onPressed: () {
|
||||||
|
if (listening != -1) {
|
||||||
|
listener?.removeAll();
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
listening = index;
|
||||||
|
});
|
||||||
|
listener?.addHandler((key) {
|
||||||
|
if (key == LogicalKeyboardKey.escape) return;
|
||||||
|
setState(() {
|
||||||
|
appdata.settings['shortcuts'][index] = key.keyId;
|
||||||
|
listening = -1;
|
||||||
|
appdata.writeData();
|
||||||
|
});
|
||||||
|
Future.microtask(() => listener?.removeAll());
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -13,6 +13,7 @@ import 'package:pixes/foundation/app.dart';
|
|||||||
import 'package:pixes/foundation/image_provider.dart';
|
import 'package:pixes/foundation/image_provider.dart';
|
||||||
import 'package:pixes/network/network.dart';
|
import 'package:pixes/network/network.dart';
|
||||||
import 'package:pixes/pages/following_users_page.dart';
|
import 'package:pixes/pages/following_users_page.dart';
|
||||||
|
import 'package:pixes/utils/block.dart';
|
||||||
import 'package:pixes/utils/translation.dart';
|
import 'package:pixes/utils/translation.dart';
|
||||||
import 'package:url_launcher/url_launcher_string.dart';
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
|
||||||
@@ -20,17 +21,34 @@ import '../components/illust_widget.dart';
|
|||||||
import 'illust_page.dart';
|
import 'illust_page.dart';
|
||||||
|
|
||||||
class UserInfoPage extends StatefulWidget {
|
class UserInfoPage extends StatefulWidget {
|
||||||
const UserInfoPage(this.id, {this.followCallback, super.key});
|
const UserInfoPage(this.id, {super.key});
|
||||||
|
|
||||||
final String id;
|
final String id;
|
||||||
|
|
||||||
final void Function(bool)? followCallback;
|
static Map<String, UpdateFollowCallback> followCallbacks = {};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<UserInfoPage> createState() => _UserInfoPageState();
|
State<UserInfoPage> createState() => _UserInfoPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
UserInfoPage.followCallbacks[widget.id] = (v) {
|
||||||
|
if (data == null) return;
|
||||||
|
setState(() {
|
||||||
|
data!.isFollowed = v;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
UserInfoPage.followCallbacks.remove(widget.id);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
int page = 0;
|
int page = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -93,7 +111,9 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data!.isFollowed = !data!.isFollowed;
|
data!.isFollowed = !data!.isFollowed;
|
||||||
widget.followCallback?.call(data!.isFollowed);
|
UserPreviewWidget.followCallbacks[data!.id.toString()]
|
||||||
|
?.call(data!.isFollowed);
|
||||||
|
IllustPage.updateFollow(data!.id.toString(), data!.isFollowed);
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
isFollowing = false;
|
isFollowing = false;
|
||||||
@@ -360,7 +380,8 @@ class _UserArtworksState extends MultiPageLoadingState<_UserArtworks, Illust> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
Widget buildContent(BuildContext context, List<Illust> data) {
|
||||||
|
checkIllusts(data);
|
||||||
return SliverMasonryGrid(
|
return SliverMasonryGrid(
|
||||||
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
||||||
maxCrossAxisExtent: 240,
|
maxCrossAxisExtent: 240,
|
||||||
@@ -524,7 +545,8 @@ class _RelatedUsersState
|
|||||||
hoveringMainAxisMargin: 4),
|
hoveringMainAxisMargin: 4),
|
||||||
child: content);
|
child: content);
|
||||||
}
|
}
|
||||||
return content;
|
return MediaQuery.removePadding(
|
||||||
|
context: context, removeBottom: true, child: content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@@ -5,7 +5,9 @@ import 'package:pixes/foundation/app.dart';
|
|||||||
import 'package:pixes/foundation/log.dart';
|
import 'package:pixes/foundation/log.dart';
|
||||||
import 'package:pixes/pages/illust_page.dart';
|
import 'package:pixes/pages/illust_page.dart';
|
||||||
import 'package:pixes/pages/novel_page.dart';
|
import 'package:pixes/pages/novel_page.dart';
|
||||||
|
import 'package:pixes/pages/search_page.dart';
|
||||||
import 'package:pixes/pages/user_info_page.dart';
|
import 'package:pixes/pages/user_info_page.dart';
|
||||||
|
import 'package:pixes/utils/ext.dart';
|
||||||
import 'package:win32_registry/win32_registry.dart';
|
import 'package:win32_registry/win32_registry.dart';
|
||||||
|
|
||||||
Future<void> _register(String scheme) async {
|
Future<void> _register(String scheme) async {
|
||||||
@@ -31,11 +33,17 @@ Future<void> _register(String scheme) async {
|
|||||||
|
|
||||||
bool Function(Uri uri)? onLink;
|
bool Function(Uri uri)? onLink;
|
||||||
|
|
||||||
|
bool _firstLink = true;
|
||||||
|
|
||||||
void handleLinks() async {
|
void handleLinks() async {
|
||||||
if (App.isWindows) {
|
if (App.isWindows) {
|
||||||
await _register("pixiv");
|
await _register("pixiv");
|
||||||
}
|
}
|
||||||
AppLinks().uriLinkStream.listen((uri) {
|
AppLinks().uriLinkStream.listen((uri) async {
|
||||||
|
if (_firstLink) {
|
||||||
|
await Future.delayed(const Duration(milliseconds: 200));
|
||||||
|
}
|
||||||
|
_firstLink = false;
|
||||||
Log.info("App Link", uri.toString());
|
Log.info("App Link", uri.toString());
|
||||||
if (onLink?.call(uri) == true) {
|
if (onLink?.call(uri) == true) {
|
||||||
return;
|
return;
|
||||||
@@ -70,6 +78,33 @@ bool handleLink(Uri uri) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
} else if (uri.scheme == "https") {
|
||||||
|
var path = uri.toString().split("/").sublist(3);
|
||||||
|
switch (path[0]) {
|
||||||
|
case "users":
|
||||||
|
if (path.length >= 2) {
|
||||||
|
App.mainNavigatorKey?.currentContext?.to(() => UserInfoPage(path[1]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case "novel":
|
||||||
|
if (path.length == 2) {
|
||||||
|
App.mainNavigatorKey?.currentContext
|
||||||
|
?.to(() => NovelPageWithId(path[1].nums));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case "artworks":
|
||||||
|
if (path.length == 2) {
|
||||||
|
App.mainNavigatorKey?.currentContext
|
||||||
|
?.to(() => IllustPageWithId(path[1]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case "tags":
|
||||||
|
if (path.length == 2) {
|
||||||
|
App.mainNavigatorKey?.currentContext
|
||||||
|
?.to(() => SearchResultPage(path[1]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
23
lib/utils/block.dart
Normal file
23
lib/utils/block.dart
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import 'package:pixes/appdata.dart';
|
||||||
|
import 'package:pixes/network/models.dart';
|
||||||
|
|
||||||
|
List<Illust> checkIllusts(List<Illust> illusts) {
|
||||||
|
illusts.removeWhere((illust) {
|
||||||
|
if (illust.isBlocked) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (appdata.settings["blockTags"] == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (appdata.settings["blockTags"].contains("user:${illust.author.name}")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (var tag in illust.tags) {
|
||||||
|
if ((appdata.settings["blockTags"] as List).contains(tag.name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
return illusts;
|
||||||
|
}
|
21
lib/utils/loop.dart
Normal file
21
lib/utils/loop.dart
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
class Loop {
|
||||||
|
static final List<void Function()> _callbacks = [];
|
||||||
|
|
||||||
|
static void start() {
|
||||||
|
Timer.periodic(const Duration(milliseconds: 100), (timer) {
|
||||||
|
for(var func in _callbacks) {
|
||||||
|
func.call();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static void register(void Function() func) {
|
||||||
|
_callbacks.add(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void remove(void Function() func) {
|
||||||
|
_callbacks.remove(func);
|
||||||
|
}
|
||||||
|
}
|
75
lib/utils/window.dart
Normal file
75
lib/utils/window.dart
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:ui';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:pixes/foundation/app.dart';
|
||||||
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
|
class WindowPlacement {
|
||||||
|
final Rect rect;
|
||||||
|
|
||||||
|
final bool isMaximized;
|
||||||
|
|
||||||
|
const WindowPlacement(this.rect, this.isMaximized);
|
||||||
|
|
||||||
|
Future<void> applyToWindow() async {
|
||||||
|
await windowManager.setBounds(rect);
|
||||||
|
|
||||||
|
if(!validate(rect)){
|
||||||
|
await windowManager.center();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isMaximized) {
|
||||||
|
await windowManager.maximize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> writeToFile() async {
|
||||||
|
var file = File("${App.dataPath}/window_placement");
|
||||||
|
await file.writeAsString(jsonEncode({
|
||||||
|
'width': rect.width,
|
||||||
|
'height': rect.height,
|
||||||
|
'x': rect.topLeft.dx,
|
||||||
|
'y': rect.topLeft.dy,
|
||||||
|
'isMaximized': isMaximized
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<WindowPlacement> loadFromFile() async {
|
||||||
|
var file = File("${App.dataPath}/window_placement");
|
||||||
|
if (!file.existsSync()) {
|
||||||
|
return defaultPlacement;
|
||||||
|
}
|
||||||
|
var json = jsonDecode(await file.readAsString());
|
||||||
|
var rect =
|
||||||
|
Rect.fromLTWH(json['x'], json['y'], json['width'], json['height']);
|
||||||
|
return WindowPlacement(rect, json['isMaximized']);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<WindowPlacement> get current async {
|
||||||
|
var rect = await windowManager.getBounds();
|
||||||
|
var isMaximized = await windowManager.isMaximized();
|
||||||
|
return WindowPlacement(rect, isMaximized);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const defaultPlacement =
|
||||||
|
WindowPlacement(Rect.fromLTWH(10, 10, 900, 600), false);
|
||||||
|
|
||||||
|
static WindowPlacement cache = defaultPlacement;
|
||||||
|
|
||||||
|
static void loop() async {
|
||||||
|
var placement = await WindowPlacement.current;
|
||||||
|
if(!validate(placement.rect)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (placement.rect != cache.rect ||
|
||||||
|
placement.isMaximized != cache.isMaximized) {
|
||||||
|
cache = placement;
|
||||||
|
await placement.writeToFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool validate(Rect rect){
|
||||||
|
return rect.topLeft.dx >= 0 && rect.topLeft.dy >= 0;
|
||||||
|
}
|
||||||
|
}
|
46
macos/Podfile
Normal file
46
macos/Podfile
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
platform :osx, '10.14.6'
|
||||||
|
|
||||||
|
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
||||||
|
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
||||||
|
|
||||||
|
project 'Runner', {
|
||||||
|
'Debug' => :debug,
|
||||||
|
'Profile' => :release,
|
||||||
|
'Release' => :release,
|
||||||
|
}
|
||||||
|
|
||||||
|
def flutter_root
|
||||||
|
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
|
||||||
|
unless File.exist?(generated_xcode_build_settings_path)
|
||||||
|
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
|
||||||
|
end
|
||||||
|
|
||||||
|
File.foreach(generated_xcode_build_settings_path) do |line|
|
||||||
|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
|
||||||
|
return matches[1].strip if matches
|
||||||
|
end
|
||||||
|
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
|
||||||
|
end
|
||||||
|
|
||||||
|
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
|
||||||
|
|
||||||
|
flutter_macos_podfile_setup
|
||||||
|
|
||||||
|
target 'Runner' do
|
||||||
|
use_frameworks!
|
||||||
|
use_modular_headers!
|
||||||
|
|
||||||
|
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
|
||||||
|
# target 'RunnerTests' do
|
||||||
|
# inherit! :search_paths
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
|
||||||
|
post_install do |installer|
|
||||||
|
installer.pods_project.targets.each do |target|
|
||||||
|
flutter_additional_macos_build_settings(target)
|
||||||
|
target.build_configurations.each do |config|
|
||||||
|
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.14.6'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@@ -461,7 +461,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
MACOSX_DEPLOYMENT_TARGET = 10.14.6;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SWIFT_COMPILATION_MODE = wholemodule;
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
@@ -543,7 +543,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
MACOSX_DEPLOYMENT_TARGET = 10.14.6;
|
||||||
MTL_ENABLE_DEBUG_INFO = YES;
|
MTL_ENABLE_DEBUG_INFO = YES;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
@@ -593,7 +593,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
MACOSX_DEPLOYMENT_TARGET = 10.14.6;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SWIFT_COMPILATION_MODE = wholemodule;
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
|
56
pubspec.lock
56
pubspec.lock
@@ -73,6 +73,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.3"
|
version: "3.0.3"
|
||||||
|
device_info_plus:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: device_info_plus
|
||||||
|
sha256: eead12d1a1ed83d8283ab4c2f3fca23ac4082f29f25f29dff0f758f57d06ec91
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "10.1.0"
|
||||||
|
device_info_plus_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: device_info_plus_platform_interface
|
||||||
|
sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "7.0.0"
|
||||||
dio:
|
dio:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -81,6 +97,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.4.3+1"
|
version: "5.4.3+1"
|
||||||
|
dynamic_color:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: dynamic_color
|
||||||
|
sha256: eae98052fa6e2826bdac3dd2e921c6ce2903be15c6b7f8b6d8a5d49b5086298d
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.7.0"
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -190,6 +214,14 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_acrylic:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_acrylic
|
||||||
|
sha256: a9a1fdf91ff1fb47858fd82507f57e255a132a5d355056694fdb9fd303633b18
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.3"
|
||||||
flutter_file_dialog:
|
flutter_file_dialog:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -293,6 +325,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.0"
|
version: "3.0.0"
|
||||||
|
macos_window_utils:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: macos_window_utils
|
||||||
|
sha256: "230be594d26f6dee92c5a1544f4242d25138a5bfb9f185b27f14de3949ef0be8"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.5.0"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -515,22 +555,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.2.0"
|
||||||
system_theme:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: system_theme
|
|
||||||
sha256: "1f208db140a3d1e1eac2034b54920d95699c1534df576ced44b3312c5de3975f"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.3.1"
|
|
||||||
system_theme_web:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: system_theme_web
|
|
||||||
sha256: "7566f5a928f6d28d7a60c97bea8a851d1c6bc9b86a4df2366230a97458489219"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.0.2"
|
|
||||||
term_glyph:
|
term_glyph:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@@ -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.4+104
|
version: 1.0.6+106
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.3.4 <4.0.0'
|
sdk: '>=3.3.4 <4.0.0'
|
||||||
@@ -56,6 +56,8 @@ dependencies:
|
|||||||
flutter_file_dialog: 3.0.1
|
flutter_file_dialog: 3.0.1
|
||||||
archive: ^3.5.1
|
archive: ^3.5.1
|
||||||
webview_flutter: ^4.7.0
|
webview_flutter: ^4.7.0
|
||||||
|
flutter_acrylic: 1.0.0+2
|
||||||
|
device_info_plus: ^10.1.0
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
64
windows/build.iss
Normal file
64
windows/build.iss
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
; Script generated by the Inno Setup Script Wizard.
|
||||||
|
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||||
|
|
||||||
|
#define MyAppName "pixes"
|
||||||
|
#define MyAppVersion "1.0.5"
|
||||||
|
#define MyAppPublisher "Nyne"
|
||||||
|
#define MyAppURL "https://github.com/wgh136/pixes"
|
||||||
|
#define MyAppExeName "pixes.exe"
|
||||||
|
#define RootPath "C:\Users\wgh19\IdeaProjects\pixes"
|
||||||
|
|
||||||
|
[Setup]
|
||||||
|
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
|
||||||
|
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
|
||||||
|
AppId={{88521115-48B7-4AF3-BF49-2BC6AF90B8D3}
|
||||||
|
AppName={#MyAppName}
|
||||||
|
AppVersion={#MyAppVersion}
|
||||||
|
;AppVerName={#MyAppName} {#MyAppVersion}
|
||||||
|
AppPublisher={#MyAppPublisher}
|
||||||
|
AppPublisherURL={#MyAppURL}
|
||||||
|
AppSupportURL={#MyAppURL}
|
||||||
|
AppUpdatesURL={#MyAppURL}
|
||||||
|
DefaultDirName={autopf}\{#MyAppName}
|
||||||
|
DisableProgramGroupPage=yes
|
||||||
|
; Uncomment the following line to run in non administrative install mode (install for current user only.)
|
||||||
|
;PrivilegesRequired=lowest
|
||||||
|
PrivilegesRequiredOverridesAllowed=dialog
|
||||||
|
OutputDir=C:\Users\wgh19\IdeaProjects\pixes\build\windows
|
||||||
|
OutputBaseFilename=pixes-windows-installer
|
||||||
|
SetupIconFile={#RootPath}\windows\runner\resources\app_icon.ico
|
||||||
|
Compression=lzma
|
||||||
|
SolidCompression=yes
|
||||||
|
WizardStyle=modern
|
||||||
|
ArchitecturesInstallIn64BitMode=x64 arm64
|
||||||
|
ArchitecturesAllowed=x64 arm64
|
||||||
|
|
||||||
|
[Languages]
|
||||||
|
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||||
|
Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
|
||||||
|
|
||||||
|
[Tasks]
|
||||||
|
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
||||||
|
|
||||||
|
[Files]
|
||||||
|
Source: "{#RootPath}\build\windows\x64\runner\Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "{#RootPath}\build\windows\x64\runner\Release\app_links_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "{#RootPath}\build\windows\x64\runner\Release\dynamic_color_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "{#RootPath}\build\windows\x64\runner\Release\file_selector_windows_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "{#RootPath}\build\windows\x64\runner\Release\flutter_windows.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "{#RootPath}\build\windows\x64\runner\Release\screen_retriever_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "{#RootPath}\build\windows\x64\runner\Release\share_plus_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "{#RootPath}\build\windows\x64\runner\Release\sqlite3.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "{#RootPath}\build\windows\x64\runner\Release\sqlite3_flutter_libs_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "{#RootPath}\build\windows\x64\runner\Release\url_launcher_windows_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "{#RootPath}\build\windows\x64\runner\Release\window_manager_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "{#RootPath}\build\windows\x64\runner\Release\flutter_acrylic_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "{#RootPath}\build\windows\x64\runner\Release\data\*"; DestDir: "{app}\data"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||||
|
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
||||||
|
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
||||||
|
|
||||||
|
[Run]
|
||||||
|
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall
|
@@ -1,6 +1,8 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
|
||||||
fontUse = '''
|
fontUse = '''
|
||||||
fonts:
|
fonts:
|
||||||
- family: font
|
- family: font
|
||||||
@@ -26,4 +28,19 @@ if os.path.exists("build/app-windows.zip"):
|
|||||||
subprocess.run(["tar", "-a", "-c", "-f", "build/windows/x64/app-windows.zip", "-C", "build/windows/x64/runner/Release", "."]
|
subprocess.run(["tar", "-a", "-c", "-f", "build/windows/x64/app-windows.zip", "-C", "build/windows/x64/runner/Release", "."]
|
||||||
, shell=True)
|
, shell=True)
|
||||||
|
|
||||||
subprocess.run(["iscc", "build/windows/build.iss"], shell=True)
|
version = str.split(str.split(content, 'version: ')[1], '+')[0]
|
||||||
|
issContent = ""
|
||||||
|
file = open('windows/build.iss', 'r')
|
||||||
|
issContent = file.read()
|
||||||
|
newContent = issContent
|
||||||
|
newContent = newContent.replace("{{version}}", version)
|
||||||
|
newContent = newContent.replace("{{root_path}}", os.getcwd())
|
||||||
|
file.close()
|
||||||
|
file = open('windows/build.iss', 'w')
|
||||||
|
file.write(newContent)
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
subprocess.run(["iscc", "windows/build.iss"], shell=True)
|
||||||
|
|
||||||
|
with open('windows/build.iss', 'w') as file:
|
||||||
|
file.write(issContent)
|
BIN
windows/runner/RCa14464
Normal file
BIN
windows/runner/RCa14464
Normal file
Binary file not shown.
BIN
windows/runner/Runner.aps
Normal file
BIN
windows/runner/Runner.aps
Normal file
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 121 KiB |
Reference in New Issue
Block a user