mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 12:57:24 +00:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
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"
|
||||
]
|
||||
}
|
@@ -64,9 +64,9 @@
|
||||
"Weekly Manga": "每周漫画",
|
||||
"Monthly Manga": "每月漫画",
|
||||
"R18": "R18",
|
||||
"Account": "账户",
|
||||
"Account": "账号",
|
||||
"Logout": "登出",
|
||||
"Account Settings": "账户设置",
|
||||
"Account Settings": "账号设置",
|
||||
"Edit": "编辑",
|
||||
"Download": "下载",
|
||||
"Manage": "管理",
|
||||
@@ -138,7 +138,17 @@
|
||||
"Line Height": "行高",
|
||||
"Paragraph Spacing": "段间距",
|
||||
"light": "浅色",
|
||||
"dark": "深色"
|
||||
"dark": "深色",
|
||||
"block": "屏蔽",
|
||||
"Block": "屏蔽",
|
||||
"Block(Account)": "屏蔽(账号)",
|
||||
"Block(Local)": "屏蔽(本地)",
|
||||
"Add": "添加",
|
||||
"Submit": "提交",
|
||||
"Local": "本地",
|
||||
"Both": "同时",
|
||||
"This artwork is blocked": "此作品已被屏蔽",
|
||||
"Delete Invalid Items": "删除无效项目"
|
||||
},
|
||||
"zh_TW": {
|
||||
"Search": "搜索",
|
||||
@@ -279,6 +289,16 @@
|
||||
"Line Height": "行高",
|
||||
"Paragraph Spacing": "段間距",
|
||||
"light": "淺色",
|
||||
"dark": "深色"
|
||||
"dark": "深色",
|
||||
"block": "屏蔽",
|
||||
"Block": "屏蔽",
|
||||
"Block(Account)": "屏蔽(賬戶)",
|
||||
"Block(Local)": "屏蔽(本地)",
|
||||
"Add": "添加",
|
||||
"Submit": "提交",
|
||||
"Local": "本地",
|
||||
"Both": "同時",
|
||||
"This artwork is blocked": "此作品已被屏蔽",
|
||||
"Delete Invalid Items": "刪除無效項目"
|
||||
}
|
||||
}
|
@@ -23,6 +23,7 @@ class _Appdata {
|
||||
"readingFontSize": 16.0,
|
||||
"readingLineHeight": 1.5,
|
||||
"readingParagraphSpacing": 8.0,
|
||||
"blockTags": [],
|
||||
};
|
||||
|
||||
bool lock = false;
|
||||
|
@@ -92,6 +92,17 @@ class SliverGridDelegateWithFixedHeight extends SliverGridDelegate {
|
||||
int calcCrossItemsCount(double width) {
|
||||
int count = 20;
|
||||
var itemWidth = width / 20;
|
||||
|
||||
if(minCrossAxisExtent == 0) {
|
||||
count = 1;
|
||||
itemWidth = width;
|
||||
while(itemWidth > maxCrossAxisExtent) {
|
||||
count++;
|
||||
itemWidth = width / count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
while (
|
||||
!(itemWidth > minCrossAxisExtent && itemWidth < maxCrossAxisExtent)) {
|
||||
count--;
|
||||
|
@@ -9,6 +9,8 @@ import '../network/network.dart';
|
||||
import '../pages/illust_page.dart';
|
||||
import 'md.dart';
|
||||
|
||||
typedef UpdateFavoriteFunc = void Function(bool v);
|
||||
|
||||
class IllustWidget extends StatefulWidget {
|
||||
const IllustWidget(this.illust, {this.onTap, super.key});
|
||||
|
||||
@@ -16,6 +18,8 @@ class IllustWidget extends StatefulWidget {
|
||||
|
||||
final void Function()? onTap;
|
||||
|
||||
static Map<String, UpdateFavoriteFunc> favoriteCallbacks = {};
|
||||
|
||||
@override
|
||||
State<IllustWidget> createState() => _IllustWidgetState();
|
||||
}
|
||||
@@ -26,6 +30,22 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
final contextController = FlyoutController();
|
||||
final contextAttachKey = GlobalKey();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
IllustWidget.favoriteCallbacks[widget.illust.id.toString()] = (v) {
|
||||
setState(() {
|
||||
widget.illust.isBookmarked = v;
|
||||
});
|
||||
};
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
IllustWidget.favoriteCallbacks.remove(widget.illust.id.toString());
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(builder: (context, constrains) {
|
||||
@@ -48,11 +68,7 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
margin: EdgeInsets.zero,
|
||||
child: GestureDetector(
|
||||
onTap: widget.onTap ?? (){
|
||||
context.to(() => IllustPage(widget.illust, favoriteCallback: (v) {
|
||||
setState(() {
|
||||
widget.illust.isBookmarked = v;
|
||||
});
|
||||
},));
|
||||
context.to(() => IllustPage(widget.illust));
|
||||
},
|
||||
onSecondaryTapUp: showMenu,
|
||||
child: ClipRRect(
|
||||
@@ -181,11 +197,7 @@ class _IllustWidgetState extends State<IllustWidget> {
|
||||
return MenuFlyout(
|
||||
items: [
|
||||
MenuFlyoutItem(text: Text("View".tl), onPressed: (){
|
||||
context.to(() => IllustPage(widget.illust, favoriteCallback: (v) {
|
||||
setState(() {
|
||||
widget.illust.isBookmarked = v;
|
||||
});
|
||||
},));
|
||||
context.to(() => IllustPage(widget.illust));
|
||||
}),
|
||||
MenuFlyoutItem(text: Text("Private Favorite".tl), onPressed: (){
|
||||
favorite("private");
|
||||
|
@@ -108,7 +108,7 @@ abstract class MultiPageLoadingState<T extends StatefulWidget, S extends Object>
|
||||
|
||||
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;
|
||||
|
||||
|
@@ -4,22 +4,43 @@ import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:pixes/components/animated_image.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/foundation/image_provider.dart';
|
||||
import 'package:pixes/pages/illust_page.dart';
|
||||
import 'package:pixes/pages/user_info_page.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../network/network.dart';
|
||||
import 'md.dart';
|
||||
|
||||
typedef UpdateFollowCallback = void Function(bool isFollowed);
|
||||
|
||||
class UserPreviewWidget extends StatefulWidget {
|
||||
const UserPreviewWidget(this.user, {super.key});
|
||||
|
||||
final UserPreview user;
|
||||
|
||||
static Map<String, UpdateFollowCallback> followCallbacks = {};
|
||||
|
||||
@override
|
||||
State<UserPreviewWidget> createState() => _UserPreviewWidgetState();
|
||||
}
|
||||
|
||||
class _UserPreviewWidgetState extends State<UserPreviewWidget> {
|
||||
@override
|
||||
void initState() {
|
||||
UserPreviewWidget.followCallbacks[widget.user.id.toString()] = (v) {
|
||||
setState(() {
|
||||
widget.user.isFollowed = v;
|
||||
});
|
||||
};
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
UserPreviewWidget.followCallbacks.remove(widget.user.id.toString());
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
bool isFollowing = false;
|
||||
|
||||
void follow() async {
|
||||
@@ -39,6 +60,9 @@ class _UserPreviewWidgetState extends State<UserPreviewWidget> {
|
||||
setState(() {
|
||||
isFollowing = false;
|
||||
});
|
||||
UserInfoPage.followCallbacks[widget.user.id.toString()]
|
||||
?.call(widget.user.isFollowed);
|
||||
IllustPage.updateFollow(widget.user.id.toString(), widget.user.isFollowed);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@@ -11,7 +11,7 @@ export "state_controller.dart";
|
||||
export "navigation.dart";
|
||||
|
||||
class _App {
|
||||
final version = "1.0.4";
|
||||
final version = "1.0.5";
|
||||
|
||||
bool get isAndroid => Platform.isAndroid;
|
||||
bool get isIOS => Platform.isIOS;
|
||||
|
@@ -12,7 +12,9 @@ import "package:pixes/foundation/log.dart";
|
||||
import "package:pixes/network/app_dio.dart";
|
||||
import "package:pixes/pages/main_page.dart";
|
||||
import "package:pixes/utils/app_links.dart";
|
||||
import "package:pixes/utils/loop.dart";
|
||||
import "package:pixes/utils/translation.dart";
|
||||
import "package:pixes/utils/window.dart";
|
||||
import "package:window_manager/window_manager.dart";
|
||||
|
||||
void main() async {
|
||||
@@ -33,10 +35,13 @@ void main() async {
|
||||
windowButtonVisibility: false,
|
||||
);
|
||||
await windowManager.setMinimumSize(const Size(500, 600));
|
||||
var placement = await WindowPlacement.loadFromFile();
|
||||
await placement.applyToWindow();
|
||||
await windowManager.show();
|
||||
await windowManager.setSkipTaskbar(false);
|
||||
Loop.register(WindowPlacement.loop);
|
||||
});
|
||||
}
|
||||
Loop.start();
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
|
@@ -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() {
|
||||
_paused = false;
|
||||
}
|
||||
|
@@ -181,6 +181,7 @@ class Illust {
|
||||
bool isBookmarked;
|
||||
final bool isAi;
|
||||
final bool isUgoira;
|
||||
final bool isBlocked;
|
||||
|
||||
bool get isR18 => tags.contains(const Tag("R-18", null));
|
||||
|
||||
@@ -227,7 +228,8 @@ class Illust {
|
||||
totalBookmarks = json['total_bookmarks'],
|
||||
isBookmarked = json['is_bookmarked'],
|
||||
isAi = json['illust_ai_type'] == 2,
|
||||
isUgoira = json['type'] == "ugoira";
|
||||
isUgoira = json['type'] == "ugoira",
|
||||
isBlocked = json['is_muted'] ?? false;
|
||||
}
|
||||
|
||||
class TrendingTag {
|
||||
@@ -525,3 +527,25 @@ class Novel {
|
||||
commentsCount = json["total_comments"],
|
||||
isAi = json["novel_ai_type"] == 2;
|
||||
}
|
||||
|
||||
class MuteList {
|
||||
List<Tag> tags;
|
||||
|
||||
List<Author> authors;
|
||||
|
||||
int limit;
|
||||
|
||||
MuteList(this.tags, this.authors, this.limit);
|
||||
|
||||
static MuteList? fromJson(Map<String, dynamic> data) {
|
||||
return MuteList(
|
||||
(data['muted_tags'] as List)
|
||||
.map((e) => Tag(e['tag'], e['tag_translation']))
|
||||
.toList(),
|
||||
(data['muted_users'] as List)
|
||||
.map((e) => Author(e['user_id'], e['user_name'], e['user_account'],
|
||||
e['user_profile_image_urls']['medium'], false))
|
||||
.toList(),
|
||||
data['mute_limit_count']);
|
||||
}
|
||||
}
|
||||
|
@@ -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,
|
||||
{Map<String, dynamic>? query, Map<String, dynamic>? data}) async {
|
||||
try {
|
||||
@@ -199,7 +214,7 @@ class Network {
|
||||
}
|
||||
final res = await dio.post<Map<String, dynamic>>(path,
|
||||
queryParameters: query,
|
||||
data: data,
|
||||
data: encodeFormData(data),
|
||||
options: Options(
|
||||
headers: headers,
|
||||
validateStatus: (status) => true,
|
||||
@@ -497,21 +512,24 @@ class Network {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<Tag>> getMutedTags() async {
|
||||
Future<Res<MuteList>> getMuteList() async {
|
||||
var res = await apiGet("/v1/mute/list");
|
||||
if (res.success) {
|
||||
return res.data["mute_tags"]
|
||||
.map<Tag>((e) => Tag(e["tag"]["name"], e["tag"]["translated_name"]))
|
||||
.toList();
|
||||
return Res(MuteList.fromJson(res.data));
|
||||
} else {
|
||||
return [];
|
||||
return Res.error(res.errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<bool>> muteTags(
|
||||
List<String> muteTags, List<String> unmuteTags) async {
|
||||
Future<Res<bool>> editMute(List<String> addTags, List<String> addUsers,
|
||||
List<String> deleteTags, List<String> deleteUsers) async {
|
||||
var res = await apiPost("/v1/mute/edit",
|
||||
data: {"add_tags": 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) {
|
||||
return const Res(true);
|
||||
} else {
|
||||
|
@@ -7,8 +7,6 @@ import 'package:photo_view/photo_view_gallery.dart';
|
||||
import 'package:pixes/components/animated_image.dart';
|
||||
import 'package:pixes/components/grid.dart';
|
||||
import 'package:pixes/components/md.dart';
|
||||
import 'package:pixes/components/message.dart';
|
||||
import 'package:pixes/components/page_route.dart';
|
||||
import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/network/download.dart';
|
||||
@@ -33,7 +31,8 @@ class _DownloadedPageState extends State<DownloadedPage> {
|
||||
|
||||
void loadData() {
|
||||
illusts = DownloadManager().listAll();
|
||||
flyoutControllers = List.generate(illusts.length, (index) => FlyoutController());
|
||||
flyoutControllers =
|
||||
List.generate(illusts.length, (index) => FlyoutController());
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -46,7 +45,18 @@ class _DownloadedPageState extends State<DownloadedPage> {
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
TitleBar(title: "Downloaded".tl),
|
||||
TitleBar(
|
||||
title: "Downloaded".tl,
|
||||
action: Button(
|
||||
child: Text("Delete Invalid Items".tl),
|
||||
onPressed: () async {
|
||||
await DownloadManager().checkAndClearInvalidItems();
|
||||
setState(() {
|
||||
loadData();
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: buildBody(),
|
||||
),
|
||||
@@ -56,135 +66,134 @@ class _DownloadedPageState extends State<DownloadedPage> {
|
||||
|
||||
Widget buildBody() {
|
||||
return GridViewWithFixedItemHeight(
|
||||
itemCount: illusts.length,
|
||||
itemHeight: 152,
|
||||
maxCrossAxisExtent: 742,
|
||||
builder: (context, index) {
|
||||
var image = DownloadManager().getImage(illusts[index].illustId, 0);
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 96,
|
||||
height: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
color: ColorScheme.of(context).secondaryContainer
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: image == null ? null : AnimatedImage(
|
||||
image: FileImage(image),
|
||||
fit: BoxFit.cover,
|
||||
width: 96,
|
||||
height: double.infinity,
|
||||
filterQuality: FilterQuality.medium,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
illusts[index].title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
illusts[index].author,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
"${illusts[index].imageCount}P",
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Button(
|
||||
child: Text("View".tl).fixWidth(42),
|
||||
onPressed: () {
|
||||
var images = DownloadManager().getImagePaths(
|
||||
illusts[index].illustId);
|
||||
if(images.isEmpty) {
|
||||
showToast(context, message: "No images found".tl);
|
||||
return;
|
||||
}
|
||||
App.rootNavigatorKey.currentState?.push(
|
||||
AppPageRoute(builder: (context) {
|
||||
return _DownloadedIllustViewPage(images);
|
||||
}));
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Button(
|
||||
child: Text("Info".tl).fixWidth(42),
|
||||
onPressed: () {
|
||||
context.to(() => IllustPageWithId(
|
||||
illusts[index].illustId.toString()));
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
FlyoutTarget(
|
||||
controller: flyoutControllers[index],
|
||||
child: Button(
|
||||
child: Text("Delete".tl).fixWidth(42),
|
||||
onPressed: () {
|
||||
flyoutControllers[index].showFlyout(
|
||||
navigatorKey: App.rootNavigatorKey.currentState,
|
||||
builder: (context) {
|
||||
return FlyoutContent(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Are you sure you want to delete?'.tl,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 12.0),
|
||||
Button(
|
||||
onPressed: () {
|
||||
Flyout.of(context).close();
|
||||
DownloadManager().delete(illusts[index]);
|
||||
setState(() {
|
||||
illusts.removeAt(index);
|
||||
flyoutControllers.removeAt(index);
|
||||
});
|
||||
},
|
||||
child: Text('Yes'.tl),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
itemCount: illusts.length,
|
||||
itemHeight: 152,
|
||||
maxCrossAxisExtent: 742,
|
||||
builder: (context, index) {
|
||||
var image = DownloadManager().getImage(illusts[index].illustId, 0);
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
App.rootNavigatorKey.currentContext?.to(() =>
|
||||
_DownloadedIllustViewPage(DownloadManager()
|
||||
.getImagePaths(illusts[index].illustId)));
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 96,
|
||||
height: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
color: ColorScheme.of(context).secondaryContainer),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: image == null
|
||||
? null
|
||||
: AnimatedImage(
|
||||
image: FileImage(image),
|
||||
fit: BoxFit.cover,
|
||||
width: 96,
|
||||
height: double.infinity,
|
||||
filterQuality: FilterQuality.medium,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
illusts[index].title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
illusts[index].author,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
"${illusts[index].imageCount}P",
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Button(
|
||||
child: Text("Info".tl).fixWidth(42),
|
||||
onPressed: () {
|
||||
context.to(() => IllustPageWithId(
|
||||
illusts[index].illustId.toString()));
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
FlyoutTarget(
|
||||
controller: flyoutControllers[index],
|
||||
child: Button(
|
||||
child: Text("Delete".tl).fixWidth(42),
|
||||
onPressed: () {
|
||||
flyoutControllers[index].showFlyout(
|
||||
navigatorKey:
|
||||
App.rootNavigatorKey.currentState,
|
||||
builder: (context) {
|
||||
return FlyoutContent(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Are you sure you want to delete?'
|
||||
.tl,
|
||||
style: const TextStyle(
|
||||
fontWeight:
|
||||
FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 12.0),
|
||||
Button(
|
||||
onPressed: () {
|
||||
Flyout.of(context).close();
|
||||
DownloadManager()
|
||||
.delete(illusts[index]);
|
||||
setState(() {
|
||||
illusts.removeAt(index);
|
||||
flyoutControllers
|
||||
.removeAt(index);
|
||||
});
|
||||
},
|
||||
child: Text('Yes'.tl),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
).paddingHorizontal(8);
|
||||
),
|
||||
);
|
||||
}).paddingHorizontal(8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,10 +203,12 @@ class _DownloadedIllustViewPage extends StatefulWidget {
|
||||
final List<String> imagePaths;
|
||||
|
||||
@override
|
||||
State<_DownloadedIllustViewPage> createState() => _DownloadedIllustViewPageState();
|
||||
State<_DownloadedIllustViewPage> createState() =>
|
||||
_DownloadedIllustViewPageState();
|
||||
}
|
||||
|
||||
class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> with WindowListener{
|
||||
class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage>
|
||||
with WindowListener {
|
||||
int windowButtonKey = 0;
|
||||
|
||||
@override
|
||||
@@ -234,38 +245,47 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
||||
|
||||
Future<File?> getFile() async {
|
||||
var file = File(widget.imagePaths[currentPage]);
|
||||
if(file.existsSync()) {
|
||||
if (file.existsSync()) {
|
||||
return file;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void showMenu() {
|
||||
menuController.showFlyout(builder: (context) => MenuFlyout(
|
||||
items: [
|
||||
MenuFlyoutItem(text: Text("Save to".tl), onPressed: () async{
|
||||
var file = await getFile();
|
||||
if(file != null){
|
||||
saveFile(file);
|
||||
}
|
||||
}),
|
||||
MenuFlyoutItem(text: Text("Share".tl), onPressed: () async{
|
||||
var file = await getFile();
|
||||
if(file != null){
|
||||
var ext = file.path.split('.').last;
|
||||
var mediaType = switch(ext){
|
||||
'jpg' => 'image/jpeg',
|
||||
'jpeg' => 'image/jpeg',
|
||||
'png' => 'image/png',
|
||||
'gif' => 'image/gif',
|
||||
'webp' => 'image/webp',
|
||||
_ => 'application/octet-stream'
|
||||
};
|
||||
Share.shareXFiles([XFile(file.path, mimeType: mediaType, name: file.path.split('/').last)]);
|
||||
}
|
||||
}),
|
||||
],
|
||||
));
|
||||
menuController.showFlyout(
|
||||
builder: (context) => MenuFlyout(
|
||||
items: [
|
||||
MenuFlyoutItem(
|
||||
text: Text("Save to".tl),
|
||||
onPressed: () async {
|
||||
var file = await getFile();
|
||||
if (file != null) {
|
||||
saveFile(file);
|
||||
}
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: Text("Share".tl),
|
||||
onPressed: () async {
|
||||
var file = await getFile();
|
||||
if (file != null) {
|
||||
var ext = file.path.split('.').last;
|
||||
var mediaType = switch (ext) {
|
||||
'jpg' => 'image/jpeg',
|
||||
'jpeg' => 'image/jpeg',
|
||||
'png' => 'image/png',
|
||||
'gif' => 'image/gif',
|
||||
'webp' => 'image/webp',
|
||||
_ => 'application/octet-stream'
|
||||
};
|
||||
Share.shareXFiles([
|
||||
XFile(file.path,
|
||||
mimeType: mediaType,
|
||||
name: file.path.split('/').last)
|
||||
]);
|
||||
}
|
||||
}),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -275,12 +295,13 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
||||
color: FluentTheme.of(context).micaBackgroundColor,
|
||||
child: Listener(
|
||||
onPointerSignal: (event) {
|
||||
if(event is PointerScrollEvent &&
|
||||
if (event is PointerScrollEvent &&
|
||||
!HardwareKeyboard.instance.isControlPressed) {
|
||||
if(event.scrollDelta.dy > 0
|
||||
&& controller.page!.toInt() < widget.imagePaths.length - 1) {
|
||||
if (event.scrollDelta.dy > 0 &&
|
||||
controller.page!.toInt() < widget.imagePaths.length - 1) {
|
||||
controller.jumpToPage(controller.page!.toInt() + 1);
|
||||
} else if(event.scrollDelta.dy < 0 && controller.page!.toInt() > 0){
|
||||
} else if (event.scrollDelta.dy < 0 &&
|
||||
controller.page!.toInt() > 0) {
|
||||
controller.jumpToPage(controller.page!.toInt() - 1);
|
||||
}
|
||||
}
|
||||
@@ -290,11 +311,11 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
||||
var height = constrains.maxHeight;
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned.fill(child: PhotoViewGallery.builder(
|
||||
Positioned.fill(
|
||||
child: PhotoViewGallery.builder(
|
||||
pageController: controller,
|
||||
backgroundDecoration: const BoxDecoration(
|
||||
color: Colors.transparent
|
||||
),
|
||||
backgroundDecoration:
|
||||
const BoxDecoration(color: Colors.transparent),
|
||||
itemCount: widget.imagePaths.length,
|
||||
builder: (context, index) {
|
||||
return PhotoViewGalleryPageOptions(
|
||||
@@ -315,17 +336,22 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
||||
height: 36,
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(width: 6,),
|
||||
const SizedBox(
|
||||
width: 6,
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(FluentIcons.back).paddingAll(2),
|
||||
onPressed: () => context.pop()
|
||||
),
|
||||
onPressed: () => context.pop()),
|
||||
const Expanded(
|
||||
child: DragToMoveArea(child: SizedBox.expand(),),
|
||||
child: DragToMoveArea(
|
||||
child: SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
buildActions(),
|
||||
if(App.isDesktop)
|
||||
WindowButtons(key: ValueKey(windowButtonKey),),
|
||||
if (App.isDesktop)
|
||||
WindowButtons(
|
||||
key: ValueKey(windowButtonKey),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -334,7 +360,10 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
||||
left: 0,
|
||||
top: height / 2 - 9,
|
||||
child: IconButton(
|
||||
icon: const Icon(FluentIcons.chevron_left, size: 18,),
|
||||
icon: const Icon(
|
||||
FluentIcons.chevron_left,
|
||||
size: 18,
|
||||
),
|
||||
onPressed: () {
|
||||
controller.previousPage(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
@@ -377,26 +406,25 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
||||
controller: menuController,
|
||||
child: width > 600
|
||||
? Button(
|
||||
onPressed: showMenu,
|
||||
child: const Row(
|
||||
children: [
|
||||
Icon(
|
||||
MdIcons.menu,
|
||||
size: 18,
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Text('Actions'),
|
||||
],
|
||||
))
|
||||
onPressed: showMenu,
|
||||
child: const Row(
|
||||
children: [
|
||||
Icon(
|
||||
MdIcons.menu,
|
||||
size: 18,
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Text('Actions'),
|
||||
],
|
||||
))
|
||||
: IconButton(
|
||||
icon: const Icon(
|
||||
MdIcons.more_horiz,
|
||||
size: 20,
|
||||
),
|
||||
onPressed: showMenu),
|
||||
icon: const Icon(
|
||||
MdIcons.more_horiz,
|
||||
size: 20,
|
||||
),
|
||||
onPressed: showMenu),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,7 @@ import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/utils/block.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../components/batch_download.dart';
|
||||
@@ -27,7 +28,10 @@ class _FollowingArtworksPageState extends State<FollowingArtworksPage> {
|
||||
children: [
|
||||
buildTab(),
|
||||
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,
|
||||
action: Row(
|
||||
children: [
|
||||
BatchDownloadButton(request: () => Network().getFollowingArtworks(restrict)),
|
||||
const SizedBox(width: 8,),
|
||||
BatchDownloadButton(
|
||||
request: () => Network().getFollowingArtworks(restrict)),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
SegmentedButton(
|
||||
options: [
|
||||
SegmentedButtonOption("all", "All".tl),
|
||||
@@ -47,7 +54,7 @@ class _FollowingArtworksPageState extends State<FollowingArtworksPage> {
|
||||
SegmentedButtonOption("private", "Private".tl),
|
||||
],
|
||||
onPressed: (key) {
|
||||
if(key != restrict) {
|
||||
if (key != restrict) {
|
||||
setState(() {
|
||||
restrict = key;
|
||||
});
|
||||
@@ -70,27 +77,26 @@ class _OneFollowingPage extends StatefulWidget {
|
||||
State<_OneFollowingPage> createState() => _OneFollowingPageState();
|
||||
}
|
||||
|
||||
class _OneFollowingPageState extends MultiPageLoadingState<_OneFollowingPage, Illust> {
|
||||
class _OneFollowingPageState
|
||||
extends MultiPageLoadingState<_OneFollowingPage, Illust> {
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
return LayoutBuilder(builder: (context, constrains){
|
||||
Widget buildContent(BuildContext context, List<Illust> data) {
|
||||
checkIllusts(data);
|
||||
return LayoutBuilder(builder: (context, constrains) {
|
||||
return MasonryGridView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8)
|
||||
+ EdgeInsets.only(bottom: context.padding.bottom),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8) +
|
||||
EdgeInsets.only(bottom: context.padding.bottom),
|
||||
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 240,
|
||||
),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, index) {
|
||||
if(index == data.length - 1){
|
||||
if (index == data.length - 1) {
|
||||
nextPage();
|
||||
}
|
||||
return IllustWidget(data[index], onTap: () {
|
||||
context.to(() => IllustGalleryPage(
|
||||
illusts: data,
|
||||
initialPage: index,
|
||||
nextUrl: nextUrl
|
||||
));
|
||||
illusts: data, initialPage: index, nextUrl: nextUrl));
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -100,16 +106,15 @@ class _OneFollowingPageState extends MultiPageLoadingState<_OneFollowingPage, Il
|
||||
String? nextUrl;
|
||||
|
||||
@override
|
||||
Future<Res<List<Illust>>> loadData(page) async{
|
||||
if(nextUrl == "end") {
|
||||
Future<Res<List<Illust>>> loadData(page) async {
|
||||
if (nextUrl == "end") {
|
||||
return Res.error("No more data");
|
||||
}
|
||||
var res = await Network().getFollowingArtworks(widget.restrict, nextUrl);
|
||||
if(!res.error) {
|
||||
if (!res.error) {
|
||||
nextUrl = res.subData;
|
||||
nextUrl ??= "end";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -5,10 +5,13 @@ import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart' show Icons;
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
import 'package:pixes/appdata.dart';
|
||||
import 'package:pixes/components/animated_image.dart';
|
||||
import 'package:pixes/components/loading.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/user_preview.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/foundation/image_provider.dart';
|
||||
import 'package:pixes/network/download.dart';
|
||||
@@ -17,6 +20,7 @@ import 'package:pixes/pages/comments_page.dart';
|
||||
import 'package:pixes/pages/image_page.dart';
|
||||
import 'package:pixes/pages/search_page.dart';
|
||||
import 'package:pixes/pages/user_info_page.dart';
|
||||
import 'package:pixes/utils/block.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
@@ -125,24 +129,50 @@ class _IllustGalleryPageState extends State<IllustGalleryPage> {
|
||||
}
|
||||
|
||||
class IllustPage extends StatefulWidget {
|
||||
const IllustPage(this.illust,
|
||||
{this.favoriteCallback, this.nextPage, this.previousPage, super.key});
|
||||
const IllustPage(this.illust, {this.nextPage, this.previousPage, super.key});
|
||||
|
||||
final Illust illust;
|
||||
|
||||
final void Function(bool)? favoriteCallback;
|
||||
|
||||
final void Function()? nextPage;
|
||||
|
||||
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
|
||||
State<IllustPage> createState() => _IllustPageState();
|
||||
}
|
||||
|
||||
class _IllustPageState extends State<IllustPage> {
|
||||
String get id => "${widget.illust.author.id}#${widget.illust.id}";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
IllustPage.followCallbacks[id] = (v) {
|
||||
setState(() {
|
||||
widget.illust.author.isFollowed = v;
|
||||
});
|
||||
};
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
IllustPage.followCallbacks.remove(id);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var isBlocked = checkIllusts([widget.illust]).isEmpty;
|
||||
return buildKeyboardListener(ColoredBox(
|
||||
color: FluentTheme.of(context).micaBackgroundColor,
|
||||
child: SizedBox.expand(
|
||||
@@ -151,19 +181,29 @@ class _IllustPageState extends State<IllustPage> {
|
||||
child: LayoutBuilder(builder: (context, constrains) {
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
child: buildBody(constrains.maxWidth, constrains.maxHeight),
|
||||
),
|
||||
_BottomBar(
|
||||
widget.illust,
|
||||
constrains.maxHeight,
|
||||
constrains.maxWidth,
|
||||
favoriteCallback: widget.favoriteCallback,
|
||||
),
|
||||
if (!isBlocked)
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
child: buildBody(constrains.maxWidth, constrains.maxHeight),
|
||||
),
|
||||
if (!isBlocked)
|
||||
_BottomBar(
|
||||
widget.illust,
|
||||
constrains.maxHeight,
|
||||
constrains.maxWidth,
|
||||
updateCallback: () => setState(() {}),
|
||||
),
|
||||
if (isBlocked)
|
||||
const Positioned.fill(
|
||||
child: Center(
|
||||
child: Center(
|
||||
child: Text(
|
||||
"This artwork is blocked",
|
||||
)),
|
||||
))
|
||||
],
|
||||
);
|
||||
}),
|
||||
@@ -305,10 +345,9 @@ class _IllustPageState extends State<IllustPage> {
|
||||
}
|
||||
|
||||
class _BottomBar extends StatefulWidget {
|
||||
const _BottomBar(this.illust, this.height, this.width,
|
||||
{this.favoriteCallback});
|
||||
const _BottomBar(this.illust, this.height, this.width, {this.updateCallback});
|
||||
|
||||
final void Function(bool)? favoriteCallback;
|
||||
final void Function()? updateCallback;
|
||||
|
||||
final Illust illust;
|
||||
|
||||
@@ -378,8 +417,9 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
||||
}
|
||||
|
||||
void _handlePointerCancel() {
|
||||
if (animationController.value == 1 || animationController.value == 0)
|
||||
if (animationController.value == 1 || animationController.value == 0) {
|
||||
return;
|
||||
}
|
||||
if (animationController.value >= 0.5) {
|
||||
animationController.forward();
|
||||
} else {
|
||||
@@ -520,6 +560,10 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
||||
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);
|
||||
}
|
||||
|
||||
final bool showUserName = MediaQuery.of(context).size.width > 640;
|
||||
@@ -543,9 +587,6 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
||||
child: GestureDetector(
|
||||
onTap: () => context.to(() => UserInfoPage(
|
||||
widget.illust.author.id.toString(),
|
||||
followCallback: (b) => setState(() {
|
||||
widget.illust.author.isFollowed = b;
|
||||
}),
|
||||
)),
|
||||
child: AnimatedImage(
|
||||
image: CachedImageProvider(widget.illust.author.avatar),
|
||||
@@ -615,7 +656,8 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
||||
}
|
||||
} else {
|
||||
widget.illust.isBookmarked = !widget.illust.isBookmarked;
|
||||
widget.favoriteCallback?.call(widget.illust.isBookmarked);
|
||||
IllustWidget.favoriteCallbacks[widget.illust.id.toString()]
|
||||
?.call(widget.illust.isBookmarked);
|
||||
}
|
||||
setState(() {
|
||||
isBookmarking = false;
|
||||
@@ -876,7 +918,9 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
||||
}
|
||||
|
||||
Widget buildMoreActions() {
|
||||
return Row(
|
||||
return Wrap(
|
||||
runSpacing: 4,
|
||||
spacing: 8,
|
||||
children: [
|
||||
Button(
|
||||
onPressed: () => favorite("private"),
|
||||
@@ -913,10 +957,7 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 6,
|
||||
),
|
||||
).fixWidth(96),
|
||||
Button(
|
||||
onPressed: () {
|
||||
Share.share(
|
||||
@@ -937,10 +978,7 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 6,
|
||||
),
|
||||
).fixWidth(96),
|
||||
Button(
|
||||
onPressed: () {
|
||||
var text = "https://pixiv.net/artworks/${widget.illust.id}";
|
||||
@@ -959,10 +997,7 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 6,
|
||||
),
|
||||
).fixWidth(96),
|
||||
Button(
|
||||
onPressed: () {
|
||||
context.to(() => _RelatedIllustsPage(widget.illust.id.toString()));
|
||||
@@ -979,12 +1014,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);
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
const IllustPageWithId(this.id, {super.key});
|
||||
|
||||
|
@@ -20,6 +20,7 @@ import "package:pixes/pages/login_page.dart";
|
||||
import "package:pixes/pages/search_page.dart";
|
||||
import "package:pixes/pages/settings_page.dart";
|
||||
import "package:pixes/pages/user_info_page.dart";
|
||||
import "package:pixes/utils/loop.dart";
|
||||
import "package:pixes/utils/mouse_listener.dart";
|
||||
import "package:pixes/utils/translation.dart";
|
||||
import "package:window_manager/window_manager.dart";
|
||||
@@ -327,28 +328,22 @@ class _BackButtonState extends State<_BackButton> {
|
||||
@override
|
||||
void initState() {
|
||||
enabled = navigatorKey.currentState?.canPop() == true;
|
||||
loop();
|
||||
Loop.register(loop);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
timer = Timer.periodic(const Duration(milliseconds: 100), (timer) {
|
||||
if (!mounted) {
|
||||
timer.cancel();
|
||||
} else {
|
||||
bool enabled = navigatorKey.currentState?.canPop() == true;
|
||||
if (enabled != this.enabled) {
|
||||
setState(() {
|
||||
this.enabled = enabled;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
bool enabled = navigatorKey.currentState?.canPop() == true;
|
||||
if (enabled != this.enabled) {
|
||||
setState(() {
|
||||
this.enabled = enabled;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
timer?.cancel();
|
||||
Loop.remove(loop);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
@@ -33,11 +33,12 @@ class _NovelReadingPageState extends LoadingState<NovelReadingPage, String> {
|
||||
if (!isShowingSettings) {
|
||||
_NovelReadingSettings.show(context, () {
|
||||
setState(() {});
|
||||
}).then((value) {
|
||||
isShowingSettings = false;
|
||||
});
|
||||
isShowingSettings = true;
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
isShowingSettings = false;
|
||||
}
|
||||
});
|
||||
Future.delayed(const Duration(milliseconds: 200), () {
|
||||
@@ -136,8 +137,8 @@ class _NovelReadingSettings extends StatefulWidget {
|
||||
|
||||
final void Function() callback;
|
||||
|
||||
static void show(BuildContext context, void Function() callback) {
|
||||
Navigator.of(context).push(SideBarRoute(_NovelReadingSettings(callback)));
|
||||
static Future show(BuildContext context, void Function() callback) {
|
||||
return Navigator.of(context).push(SideBarRoute(_NovelReadingSettings(callback)));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/utils/block.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../components/batch_download.dart';
|
||||
@@ -86,6 +87,7 @@ class _OneRankingPage extends StatefulWidget {
|
||||
class _OneRankingPageState extends MultiPageLoadingState<_OneRankingPage, Illust> {
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
checkIllusts(data);
|
||||
return LayoutBuilder(builder: (context, constrains){
|
||||
return MasonryGridView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8)
|
||||
|
@@ -6,6 +6,7 @@ import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/pages/illust_page.dart';
|
||||
import 'package:pixes/utils/block.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../components/grid.dart';
|
||||
@@ -75,6 +76,7 @@ class _RecommendationArtworksPageState
|
||||
extends MultiPageLoadingState<_RecommendationArtworksPage, Illust> {
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
checkIllusts(data);
|
||||
return LayoutBuilder(builder: (context, constrains) {
|
||||
return MasonryGridView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8) +
|
||||
|
@@ -2,7 +2,6 @@ import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
import 'package:pixes/appdata.dart';
|
||||
import 'package:pixes/components/loading.dart';
|
||||
import 'package:pixes/components/message.dart';
|
||||
import 'package:pixes/components/novel.dart';
|
||||
import 'package:pixes/components/page_route.dart';
|
||||
import 'package:pixes/components/user_preview.dart';
|
||||
@@ -11,6 +10,7 @@ import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/pages/illust_page.dart';
|
||||
import 'package:pixes/pages/novel_page.dart';
|
||||
import 'package:pixes/pages/user_info_page.dart';
|
||||
import 'package:pixes/utils/block.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../components/animated_image.dart';
|
||||
@@ -127,7 +127,6 @@ class _SearchPageState extends State<SearchPage> {
|
||||
),
|
||||
onPressed: () {
|
||||
optionController.showFlyout(
|
||||
navigatorKey: App.rootNavigatorKey.currentState,
|
||||
placementMode: FlyoutPlacementMode.bottomCenter,
|
||||
builder: buildSearchOption,
|
||||
);
|
||||
@@ -456,6 +455,7 @@ class _SearchResultPageState
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
checkIllusts(data);
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
buildSearchBar(),
|
||||
|
@@ -131,16 +131,16 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
return;
|
||||
}
|
||||
context.to(() => _SetSingleFieldPage(
|
||||
"Download Path".tl,
|
||||
"downloadPath",
|
||||
check: (text) {
|
||||
if(!Directory(text).havePermission()) {
|
||||
return "No permission".tl;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
));
|
||||
"Download Path".tl,
|
||||
"downloadPath",
|
||||
check: (text) {
|
||||
if (!Directory(text).havePermission()) {
|
||||
return "No permission".tl;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
));
|
||||
}),
|
||||
),
|
||||
buildItem(
|
||||
@@ -182,23 +182,30 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
buildItem(
|
||||
title: "Github",
|
||||
action: IconButton(
|
||||
icon: const Icon(MdIcons.open_in_new, size: 18,),
|
||||
icon: const Icon(
|
||||
MdIcons.open_in_new,
|
||||
size: 18,
|
||||
),
|
||||
onPressed: () =>
|
||||
launchUrlString("https://github.com/wgh136/pixes"),
|
||||
)),
|
||||
buildItem(
|
||||
title: "Telegram",
|
||||
action: IconButton(
|
||||
icon: const Icon(MdIcons.open_in_new, size: 18,),
|
||||
onPressed: () =>
|
||||
launchUrlString("https://t.me/pica_group"),
|
||||
icon: const Icon(
|
||||
MdIcons.open_in_new,
|
||||
size: 18,
|
||||
),
|
||||
onPressed: () => launchUrlString("https://t.me/pica_group"),
|
||||
)),
|
||||
buildItem(
|
||||
title: "Logs",
|
||||
action: IconButton(
|
||||
icon: const Icon(MdIcons.open_in_new, size: 18,),
|
||||
onPressed: () => context.to(() => const LogsPage())
|
||||
)),
|
||||
icon: const Icon(
|
||||
MdIcons.open_in_new,
|
||||
size: 18,
|
||||
),
|
||||
onPressed: () => context.to(() => const LogsPage()))),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -214,9 +221,25 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
child: Text("Edit".tl).fixWidth(64),
|
||||
onPressed: () {
|
||||
context.to(() => _SetSingleFieldPage(
|
||||
"Http ${"Proxy".tl}",
|
||||
"proxy",
|
||||
));
|
||||
"Http ${"Proxy".tl}",
|
||||
"proxy",
|
||||
));
|
||||
},
|
||||
)),
|
||||
buildItem(
|
||||
title: "Block(Account)".tl,
|
||||
action: Button(
|
||||
child: Text("Edit".tl).fixWidth(64),
|
||||
onPressed: () {
|
||||
launchUrlString("https://www.pixiv.net/setting_mute.php");
|
||||
},
|
||||
)),
|
||||
buildItem(
|
||||
title: "Block(Local)".tl,
|
||||
action: Button(
|
||||
child: Text("Edit".tl).fixWidth(64),
|
||||
onPressed: () {
|
||||
context.to(() => const _BlockTagsPage());
|
||||
},
|
||||
)),
|
||||
],
|
||||
@@ -231,63 +254,77 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
buildItem(
|
||||
title: "Theme".tl,
|
||||
action: DropDownButton(
|
||||
title: Text(appdata.settings["theme"] ?? "System".tl),
|
||||
items: [
|
||||
MenuFlyoutItem(text: Text("System".tl), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "System";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(text: Text("light".tl), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "Light";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(text: Text("dark".tl), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "Dark";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
])),
|
||||
title: Text(appdata.settings["theme"] ?? "System".tl),
|
||||
items: [
|
||||
MenuFlyoutItem(
|
||||
text: Text("System".tl),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "System";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: Text("light".tl),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "Light";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: Text("dark".tl),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["theme"] = "Dark";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
])),
|
||||
buildItem(
|
||||
title: "Language".tl,
|
||||
action: DropDownButton(
|
||||
title: Text(appdata.settings["language"] ?? "System"),
|
||||
items: [
|
||||
MenuFlyoutItem(text: const Text("System"), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "System";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(text: const Text("English"), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "English";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(text: const Text("简体中文"), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "简体中文";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(text: const Text("繁體中文"), onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "繁體中文";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: const Text("System"),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "System";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: const Text("English"),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "English";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: const Text("简体中文"),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "简体中文";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
MenuFlyoutItem(
|
||||
text: const Text("繁體中文"),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
appdata.settings["language"] = "繁體中文";
|
||||
});
|
||||
appdata.writeData();
|
||||
StateController.findOrNull(tag: "MyApp")?.update();
|
||||
}),
|
||||
])),
|
||||
],
|
||||
),
|
||||
@@ -416,3 +453,88 @@ ${"Some keywords will be replaced by the following rule:".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();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/foundation/image_provider.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/pages/following_users_page.dart';
|
||||
import 'package:pixes/utils/block.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
@@ -20,17 +21,34 @@ import '../components/illust_widget.dart';
|
||||
import 'illust_page.dart';
|
||||
|
||||
class UserInfoPage extends StatefulWidget {
|
||||
const UserInfoPage(this.id, {this.followCallback, super.key});
|
||||
const UserInfoPage(this.id, {super.key});
|
||||
|
||||
final String id;
|
||||
|
||||
final void Function(bool)? followCallback;
|
||||
static Map<String, UpdateFollowCallback> followCallbacks = {};
|
||||
|
||||
@override
|
||||
State<UserInfoPage> createState() => _UserInfoPageState();
|
||||
}
|
||||
|
||||
class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||
@override
|
||||
void initState() {
|
||||
UserInfoPage.followCallbacks[widget.id] = (v) {
|
||||
if (data == null) return;
|
||||
setState(() {
|
||||
data!.isFollowed = v;
|
||||
});
|
||||
};
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
UserInfoPage.followCallbacks.remove(widget.id);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
int page = 0;
|
||||
|
||||
@override
|
||||
@@ -93,7 +111,9 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||
}
|
||||
} else {
|
||||
data!.isFollowed = !data!.isFollowed;
|
||||
widget.followCallback?.call(data!.isFollowed);
|
||||
UserPreviewWidget.followCallbacks[data!.id.toString()]
|
||||
?.call(data!.isFollowed);
|
||||
IllustPage.updateFollow(data!.id.toString(), data!.isFollowed);
|
||||
}
|
||||
setState(() {
|
||||
isFollowing = false;
|
||||
@@ -360,7 +380,8 @@ class _UserArtworksState extends MultiPageLoadingState<_UserArtworks, Illust> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
Widget buildContent(BuildContext context, List<Illust> data) {
|
||||
checkIllusts(data);
|
||||
return SliverMasonryGrid(
|
||||
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 240,
|
||||
|
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);
|
||||
}
|
||||
}
|
64
lib/utils/window.dart
Normal file
64
lib/utils/window.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
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 (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 (placement.rect != cache.rect ||
|
||||
placement.isMaximized != cache.isMaximized) {
|
||||
cache = placement;
|
||||
await placement.writeToFile();
|
||||
}
|
||||
}
|
||||
}
|
@@ -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
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.0.4+104
|
||||
version: 1.0.5+105
|
||||
|
||||
environment:
|
||||
sdk: '>=3.3.4 <4.0.0'
|
||||
|
63
windows/build.iss
Normal file
63
windows/build.iss
Normal file
@@ -0,0 +1,63 @@
|
||||
; 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\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 os
|
||||
|
||||
os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
fontUse = '''
|
||||
fonts:
|
||||
- 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", "."]
|
||||
, 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)
|
Reference in New Issue
Block a user