mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 21:07:24 +00:00
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6d4a6fad08 | ||
![]() |
6edf93beb5 | ||
![]() |
b6c4b6da5a | ||
![]() |
a8ebebfedd | ||
![]() |
8c57dd30fb | ||
![]() |
6e7e029a0d | ||
![]() |
872a2e13cf | ||
![]() |
2f72437fc1 | ||
![]() |
efd5683529 | ||
![]() |
ae0be5a97d | ||
![]() |
1698928212 | ||
![]() |
945d386d17 | ||
![]() |
2f0b1b9554 | ||
![]() |
d8df3660e0 | ||
![]() |
9b42234ac7 | ||
![]() |
2e6237bfd9 | ||
![]() |
77b298a6b9 | ||
![]() |
4ada655bbd |
@@ -106,7 +106,22 @@
|
|||||||
"Popular(Female)": "热门(女性向)",
|
"Popular(Female)": "热门(女性向)",
|
||||||
"Start Time": "开始时间",
|
"Start Time": "开始时间",
|
||||||
"End Time": "结束时间",
|
"End Time": "结束时间",
|
||||||
"Max parallels": "最大并行数"
|
"Max parallels": "最大并行数",
|
||||||
|
"Replace with 'AI' if the work was generated by AI, otherwise replace with blank": "替换为'AI'如果作品是由AI生成的, 否则替换为空白",
|
||||||
|
"Replace with * if the work have tag *, otherwise replace with blank.": "替换为*如果作品包含标签*, 否则替换为空白",
|
||||||
|
"Multiple path separators will be automatically replaced with a single": "多个路径分隔符将被自动替换为单个",
|
||||||
|
"Login": "登录",
|
||||||
|
"You need to complete the login operation in the browser window that will open.": "您需要在打开的浏览器窗口中完成登录操作",
|
||||||
|
"I have read and agree to the Terms of Use": "我已阅读并同意使用条款",
|
||||||
|
"Waiting..." : "等待中...",
|
||||||
|
"Waiting for authentication. Please finished in the browser." : "等待验证. 请在浏览器中完成.",
|
||||||
|
"Back" : "返回",
|
||||||
|
"Logging in" : "登录中",
|
||||||
|
"Browse": "浏览",
|
||||||
|
"Proxy": "代理",
|
||||||
|
"Appearance": "外观",
|
||||||
|
"Language": "语言",
|
||||||
|
"Theme": "主题"
|
||||||
},
|
},
|
||||||
"zh_TW": {
|
"zh_TW": {
|
||||||
"Search": "搜索",
|
"Search": "搜索",
|
||||||
@@ -215,6 +230,21 @@
|
|||||||
"Popular(Female)": "熱門(女性)",
|
"Popular(Female)": "熱門(女性)",
|
||||||
"Start Time": "開始時間",
|
"Start Time": "開始時間",
|
||||||
"End Time": "結束時間",
|
"End Time": "結束時間",
|
||||||
"Max parallels": "最大並行數"
|
"Max parallels": "最大並行數",
|
||||||
|
"Replace with 'AI' if the work was generated by AI, otherwise replace with blank": "替換為'AI'如果作品是由AI生成的, 否則替換為空白",
|
||||||
|
"Replace with * if the work have tag *, otherwise replace with blank.": "替換為*如果作品包含標籤*, 否則替換為空白",
|
||||||
|
"Multiple path separators will be automatically replaced with a single": "多個路徑分隔符號將自動替換為單一",
|
||||||
|
"Login": "登錄",
|
||||||
|
"You need to complete the login operation in the browser window that will open.": "您需要在打開的瀏覽器窗口中完成登錄操作",
|
||||||
|
"I have read and agree to the Terms of Use": "我已閱讀並同意使用條款",
|
||||||
|
"Waiting..." : "等待中...",
|
||||||
|
"Waiting for authentication. Please finished in the browser." : "等待驗證. 請在瀏覽器中完成.",
|
||||||
|
"Back" : "返回",
|
||||||
|
"Logging in" : "登錄中",
|
||||||
|
"Browse": "瀏覽",
|
||||||
|
"Proxy": "代理",
|
||||||
|
"Appearance": "外觀",
|
||||||
|
"Language": "語言",
|
||||||
|
"Theme": "主題"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -16,9 +16,10 @@ class _Appdata {
|
|||||||
Map<String, dynamic> settings = {
|
Map<String, dynamic> settings = {
|
||||||
"downloadPath": null,
|
"downloadPath": null,
|
||||||
"downloadSubPath": r"/${id}-p${index}.${ext}",
|
"downloadSubPath": r"/${id}-p${index}.${ext}",
|
||||||
"tagsWeight": "風景 ロリ 巨乳 女の子",
|
"maxParallels": 3,
|
||||||
"useTranslatedNameForDownload": true,
|
"proxy": "",
|
||||||
"maxParallels": 3
|
"darkMode": "System",
|
||||||
|
"language": "System",
|
||||||
};
|
};
|
||||||
|
|
||||||
bool lock = false;
|
bool lock = false;
|
||||||
|
@@ -65,6 +65,91 @@ class _IllustWidgetState extends State<IllustWidget> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
|
if(widget.illust.images.length > 1)
|
||||||
|
Positioned(
|
||||||
|
top: 12,
|
||||||
|
left: 12,
|
||||||
|
child: Container(
|
||||||
|
width: 28,
|
||||||
|
height: 20,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: FluentTheme.of(context).cardColor,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Text("${widget.illust.images.length}P",
|
||||||
|
style: const TextStyle(fontSize: 12),),
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
if(widget.illust.isAi)
|
||||||
|
Positioned(
|
||||||
|
bottom: 12,
|
||||||
|
left: 12,
|
||||||
|
child: Container(
|
||||||
|
width: 28,
|
||||||
|
height: 20,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: ColorScheme.of(context).errorContainer.withOpacity(0.8),
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6),
|
||||||
|
),
|
||||||
|
child: const Center(
|
||||||
|
child: Text("AI",
|
||||||
|
style: TextStyle(fontSize: 12),),
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
if(widget.illust.isUgoira)
|
||||||
|
Positioned(
|
||||||
|
bottom: 12,
|
||||||
|
left: 12,
|
||||||
|
child: Container(
|
||||||
|
width: 28,
|
||||||
|
height: 20,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: ColorScheme.of(context).primaryContainer.withOpacity(0.8),
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6),
|
||||||
|
),
|
||||||
|
child: const Center(
|
||||||
|
child: Text("GIF",
|
||||||
|
style: TextStyle(fontSize: 12),),
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
if(widget.illust.isR18)
|
||||||
|
Positioned(
|
||||||
|
bottom: 12,
|
||||||
|
right: 12,
|
||||||
|
child: Container(
|
||||||
|
width: 28,
|
||||||
|
height: 20,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: ColorScheme.of(context).errorContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6),
|
||||||
|
),
|
||||||
|
child: const Center(
|
||||||
|
child: Text("R18",
|
||||||
|
style: TextStyle(fontSize: 12),),
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
if(widget.illust.isR18G)
|
||||||
|
Positioned(
|
||||||
|
bottom: 12,
|
||||||
|
right: 12,
|
||||||
|
child: Container(
|
||||||
|
width: 28,
|
||||||
|
height: 20,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: ColorScheme.of(context).errorContainer,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6),
|
||||||
|
),
|
||||||
|
child: const Center(
|
||||||
|
child: Text("R18G",
|
||||||
|
style: TextStyle(fontSize: 12),),
|
||||||
|
)),
|
||||||
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 16,
|
top: 16,
|
||||||
right: 16,
|
right: 16,
|
||||||
|
@@ -30,7 +30,7 @@ class ToastOverlay extends StatelessWidget {
|
|||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.bottomCenter,
|
alignment: Alignment.bottomCenter,
|
||||||
child: PhysicalModel(
|
child: PhysicalModel(
|
||||||
color: FluentTheme.of(context).cardColor.withOpacity(1),
|
color: ColorScheme.of(context).surface.withOpacity(1),
|
||||||
borderRadius: BorderRadius.circular(4),
|
borderRadius: BorderRadius.circular(4),
|
||||||
elevation: 1,
|
elevation: 1,
|
||||||
child: Container(
|
child: Container(
|
||||||
|
265
lib/components/ugoira.dart
Normal file
265
lib/components/ugoira.dart
Normal file
@@ -0,0 +1,265 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:archive/archive_io.dart';
|
||||||
|
|
||||||
|
import 'package:crypto/crypto.dart';
|
||||||
|
import 'package:fluent_ui/fluent_ui.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:pixes/components/md.dart';
|
||||||
|
import 'package:pixes/network/network.dart';
|
||||||
|
|
||||||
|
import '../foundation/cache_manager.dart';
|
||||||
|
import '../network/app_dio.dart';
|
||||||
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
|
class UgoiraWidget extends StatefulWidget {
|
||||||
|
const UgoiraWidget({super.key, required this.id, required this.previewImage,
|
||||||
|
required this.width, required this.height});
|
||||||
|
|
||||||
|
final String id;
|
||||||
|
|
||||||
|
final ImageProvider previewImage;
|
||||||
|
|
||||||
|
final double width;
|
||||||
|
|
||||||
|
final double height;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<UgoiraWidget> createState() => _UgoiraWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _UgoiraWidgetState extends State<UgoiraWidget> {
|
||||||
|
_UgoiraMetadata? _metadata;
|
||||||
|
|
||||||
|
bool _loading = false;
|
||||||
|
|
||||||
|
bool _finished = false;
|
||||||
|
|
||||||
|
bool _error = false;
|
||||||
|
|
||||||
|
int expectedBytes = 1;
|
||||||
|
|
||||||
|
int receivedBytes = 0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SizedBox(
|
||||||
|
width: widget.width,
|
||||||
|
height: widget.height,
|
||||||
|
child: !_finished
|
||||||
|
? buildPreview()
|
||||||
|
: _UgoiraAnimation(metadata: _metadata!, key: Key(widget.id),),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildPreview() {
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
Positioned.fill(
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
child: Image(
|
||||||
|
image: widget.previewImage,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if(_error)
|
||||||
|
const Positioned.fill(
|
||||||
|
child: Center(
|
||||||
|
child: Icon(
|
||||||
|
MdIcons.error_outline,
|
||||||
|
size: 36,
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
if(!_loading)
|
||||||
|
Positioned.fill(
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: load,
|
||||||
|
child: const Center(
|
||||||
|
child: Icon(
|
||||||
|
MdIcons.play_circle_outline,
|
||||||
|
size: 36,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Center(
|
||||||
|
child: ProgressRing(value: (receivedBytes / expectedBytes) * 100,),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void load() async {
|
||||||
|
setState(() {
|
||||||
|
_loading = true;
|
||||||
|
});
|
||||||
|
var res0 = await Network().apiGet('/v1/ugoira/metadata?illust_id=${widget.id}');
|
||||||
|
if(res0.error) {
|
||||||
|
setState(() {
|
||||||
|
_error = true;
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var json = res0.data;
|
||||||
|
_metadata = _UgoiraMetadata(
|
||||||
|
url: json["ugoira_metadata"]["zip_urls"]["medium"],
|
||||||
|
frames: (json["ugoira_metadata"]["frames"] as List).map<_UgoiraFrame>((e) => _UgoiraFrame(
|
||||||
|
delay: e["delay"],
|
||||||
|
fileName: e["file"],
|
||||||
|
)).toList(),
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
var key = "ugoira_${widget.id}";
|
||||||
|
var cached = await CacheManager().findCache(key);
|
||||||
|
if(cached != null) {
|
||||||
|
await extract(cached);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var dio = AppDio();
|
||||||
|
final time = DateFormat("yyyy-MM-dd'T'HH:mm:ss'+00:00'").format(DateTime.now());
|
||||||
|
final hash = md5.convert(utf8.encode(time + Network.hashSalt)).toString();
|
||||||
|
var res = await dio.get<ResponseBody>(
|
||||||
|
_metadata!.url,
|
||||||
|
options: Options(
|
||||||
|
responseType: ResponseType.stream,
|
||||||
|
validateStatus: (status) => status != null && status < 500,
|
||||||
|
headers: {
|
||||||
|
"referer": "https://app-api.pixiv.net/",
|
||||||
|
"user-agent": "PixivAndroidApp/5.0.234 (Android 14; Pixes)",
|
||||||
|
"x-client-time": time,
|
||||||
|
"x-client-hash": hash,
|
||||||
|
"accept-enconding": "gzip",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if(res.statusCode != 200) {
|
||||||
|
throw "Failed to load image: ${res.statusCode}";
|
||||||
|
}
|
||||||
|
expectedBytes = int.parse(res.headers.value("content-length") ?? "1");
|
||||||
|
var cachingFile = await CacheManager().openWrite(key);
|
||||||
|
await for (var chunk in res.data!.stream) {
|
||||||
|
await cachingFile.writeBytes(chunk);
|
||||||
|
setState(() {
|
||||||
|
receivedBytes += chunk.length;
|
||||||
|
if(receivedBytes > expectedBytes) {
|
||||||
|
expectedBytes = receivedBytes + 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await cachingFile.close();
|
||||||
|
await extract(cachingFile.file.path);
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
setState(() {
|
||||||
|
_error = true;
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> extract(String filePath) async{
|
||||||
|
var zip = ZipDecoder().decodeBytes(await File(filePath).readAsBytes());
|
||||||
|
for(var file in zip) {
|
||||||
|
if(file.isFile) {
|
||||||
|
var frame = _metadata!.frames.firstWhere((element) => element.fileName == file.name);
|
||||||
|
frame.data = await decodeImageFromList(file.content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zip.clear();
|
||||||
|
setState(() {
|
||||||
|
_loading = false;
|
||||||
|
_finished = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class _UgoiraAnimation extends StatefulWidget {
|
||||||
|
const _UgoiraAnimation({super.key, required this.metadata});
|
||||||
|
|
||||||
|
final _UgoiraMetadata metadata;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_UgoiraAnimation> createState() => _UgoiraAnimationState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _UgoiraAnimationState extends State<_UgoiraAnimation> with SingleTickerProviderStateMixin {
|
||||||
|
late AnimationController _controller;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
final totalDuration = widget.metadata.frames.fold<int>(
|
||||||
|
0, (previousValue, element) => previousValue + element.delay);
|
||||||
|
_controller = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: Duration(milliseconds: totalDuration),
|
||||||
|
value: 0,
|
||||||
|
lowerBound: 0,
|
||||||
|
upperBound: widget.metadata.frames.length.toDouble(),
|
||||||
|
);
|
||||||
|
_controller.repeat();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AnimatedBuilder(
|
||||||
|
animation: _controller,
|
||||||
|
builder: (context, child) {
|
||||||
|
final frame = widget.metadata.frames[_controller.value.toInt()];
|
||||||
|
return CustomPaint(
|
||||||
|
painter: _ImagePainter(frame.data!),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _UgoiraMetadata {
|
||||||
|
final String url;
|
||||||
|
final List<_UgoiraFrame> frames;
|
||||||
|
|
||||||
|
_UgoiraMetadata({required this.url, required this.frames});
|
||||||
|
}
|
||||||
|
|
||||||
|
class _UgoiraFrame {
|
||||||
|
final int delay;
|
||||||
|
final String fileName;
|
||||||
|
ui.Image? data;
|
||||||
|
|
||||||
|
_UgoiraFrame({required this.delay, required this.fileName});
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ImagePainter extends CustomPainter {
|
||||||
|
final ui.Image data;
|
||||||
|
|
||||||
|
_ImagePainter(this.data);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void paint(Canvas canvas, Size size) {
|
||||||
|
// 覆盖整个画布
|
||||||
|
Rect rect = Offset.zero & size;
|
||||||
|
canvas.drawImageRect(
|
||||||
|
data,
|
||||||
|
Rect.fromLTRB(0, 0, data.width.toDouble(), data.height.toDouble()),
|
||||||
|
rect,
|
||||||
|
Paint()..filterQuality = FilterQuality.medium
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldRepaint(covariant CustomPainter oldDelegate) {
|
||||||
|
return data != (oldDelegate as _ImagePainter).data;
|
||||||
|
}
|
||||||
|
}
|
@@ -4,12 +4,14 @@ import 'dart:ui';
|
|||||||
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';
|
||||||
|
|
||||||
|
import '../appdata.dart';
|
||||||
|
|
||||||
export "widget_utils.dart";
|
export "widget_utils.dart";
|
||||||
export "state_controller.dart";
|
export "state_controller.dart";
|
||||||
export "navigation.dart";
|
export "navigation.dart";
|
||||||
|
|
||||||
class _App {
|
class _App {
|
||||||
final version = "1.0.0";
|
final version = "1.0.2";
|
||||||
|
|
||||||
bool get isAndroid => Platform.isAndroid;
|
bool get isAndroid => Platform.isAndroid;
|
||||||
bool get isIOS => Platform.isIOS;
|
bool get isIOS => Platform.isIOS;
|
||||||
@@ -21,6 +23,14 @@ 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"){
|
||||||
|
return switch(appdata.settings["language"]){
|
||||||
|
"English" => const Locale("en"),
|
||||||
|
"简体中文" => const Locale("zh"),
|
||||||
|
"繁體中文" => const Locale("zh", "Hant"),
|
||||||
|
_ => const Locale("en"),
|
||||||
|
};
|
||||||
|
}
|
||||||
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");
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
import "dart:ui";
|
||||||
|
|
||||||
import "package:fluent_ui/fluent_ui.dart";
|
import "package:fluent_ui/fluent_ui.dart";
|
||||||
import "package:flutter/services.dart";
|
import "package:flutter/services.dart";
|
||||||
import "package:pixes/appdata.dart";
|
import "package:pixes/appdata.dart";
|
||||||
@@ -47,32 +49,31 @@ class MyApp extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
return StateBuilder<SimpleController>(
|
||||||
value: const SystemUiOverlayStyle(
|
init: SimpleController(),
|
||||||
systemNavigationBarColor: Colors.transparent,
|
tag: "MyApp",
|
||||||
statusBarColor: Colors.transparent),
|
builder: (controller) {
|
||||||
child: StateBuilder<SimpleController>(
|
Brightness brightness = PlatformDispatcher.instance.platformBrightness;
|
||||||
init: SimpleController(),
|
|
||||||
tag: "MyApp",
|
if(appdata.settings["theme"] == "Dark") {
|
||||||
builder: (controller) {
|
brightness = Brightness.dark;
|
||||||
return FluentApp(
|
} else if(appdata.settings["theme"] == "Light") {
|
||||||
|
brightness = Brightness.light;
|
||||||
|
}
|
||||||
|
|
||||||
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||||
|
value: SystemUiOverlayStyle(
|
||||||
|
systemNavigationBarColor: Colors.transparent,
|
||||||
|
statusBarColor: Colors.transparent,
|
||||||
|
statusBarIconBrightness: brightness.opposite,
|
||||||
|
systemNavigationBarIconBrightness: brightness.opposite,
|
||||||
|
),
|
||||||
|
child: FluentApp(
|
||||||
navigatorKey: App.rootNavigatorKey,
|
navigatorKey: App.rootNavigatorKey,
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
title: 'pixes',
|
title: 'pixes',
|
||||||
theme: FluentThemeData(
|
theme: FluentThemeData(
|
||||||
brightness: Brightness.light,
|
brightness: brightness,
|
||||||
fontFamily: App.isWindows ? 'font' : null,
|
|
||||||
accentColor: AccentColor.swatch({
|
|
||||||
'darkest': SystemTheme.accentColor.darkest,
|
|
||||||
'darker': SystemTheme.accentColor.darker,
|
|
||||||
'dark': SystemTheme.accentColor.dark,
|
|
||||||
'normal': SystemTheme.accentColor.accent,
|
|
||||||
'light': SystemTheme.accentColor.light,
|
|
||||||
'lighter': SystemTheme.accentColor.lighter,
|
|
||||||
'lightest': SystemTheme.accentColor.lightest,
|
|
||||||
})),
|
|
||||||
darkTheme: FluentThemeData(
|
|
||||||
brightness: Brightness.dark,
|
|
||||||
fontFamily: App.isWindows ? 'font' : null,
|
fontFamily: App.isWindows ? 'font' : null,
|
||||||
accentColor: AccentColor.swatch({
|
accentColor: AccentColor.swatch({
|
||||||
'darkest': SystemTheme.accentColor.darkest,
|
'darkest': SystemTheme.accentColor.darkest,
|
||||||
@@ -99,8 +100,8 @@ class MyApp extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return OverlayWidget(child);
|
return OverlayWidget(child);
|
||||||
});
|
}),
|
||||||
}),
|
);
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@ import 'dart:io';
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:dio/io.dart';
|
import 'package:dio/io.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:pixes/appdata.dart';
|
||||||
import 'package:pixes/foundation/app.dart';
|
import 'package:pixes/foundation/app.dart';
|
||||||
import 'package:pixes/foundation/log.dart';
|
import 'package:pixes/foundation/log.dart';
|
||||||
import 'package:pixes/utils/ext.dart';
|
import 'package:pixes/utils/ext.dart';
|
||||||
@@ -132,7 +133,9 @@ class _ProxyHttpOverrides extends HttpOverrides {
|
|||||||
String proxy = "DIRECT";
|
String proxy = "DIRECT";
|
||||||
|
|
||||||
String findProxy(Uri uri) {
|
String findProxy(Uri uri) {
|
||||||
if(!App.isLinux) {
|
var haveUserProxy = appdata.settings["proxy"] != null
|
||||||
|
&& appdata.settings["proxy"].toString().isNotEmpty;
|
||||||
|
if(!App.isLinux && !haveUserProxy){
|
||||||
var channel = const MethodChannel("pixes/proxy");
|
var channel = const MethodChannel("pixes/proxy");
|
||||||
channel.invokeMethod("getProxy").then((value) {
|
channel.invokeMethod("getProxy").then((value) {
|
||||||
if(value.toString().toLowerCase() == "no proxy"){
|
if(value.toString().toLowerCase() == "no proxy"){
|
||||||
@@ -150,6 +153,10 @@ class _ProxyHttpOverrides extends HttpOverrides {
|
|||||||
proxy = "PROXY $value";
|
proxy = "PROXY $value";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
if(haveUserProxy){
|
||||||
|
proxy = "PROXY ${appdata.settings["proxy"]}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
@@ -127,30 +127,35 @@ class DownloadingTask {
|
|||||||
static String _generateFilePath(Illust illust, int index, String ext) {
|
static String _generateFilePath(Illust illust, int index, String ext) {
|
||||||
final String downloadPath = appdata.settings["downloadPath"];
|
final String downloadPath = appdata.settings["downloadPath"];
|
||||||
String subPathPatten = appdata.settings["downloadSubPath"];
|
String subPathPatten = appdata.settings["downloadSubPath"];
|
||||||
final tagsWeight = (appdata.settings["tagsWeight"] as String).split(' ');
|
|
||||||
final originalTags = List<Tag>.from(illust.tags);
|
|
||||||
print(originalTags);
|
|
||||||
originalTags.sort((a, b){
|
|
||||||
var aWeight = tagsWeight.indexOf(a.name);
|
|
||||||
if(aWeight == -1) aWeight = tagsWeight.length;
|
|
||||||
var bWeight = tagsWeight.indexOf(b.name);
|
|
||||||
if(bWeight == -1) bWeight = tagsWeight.length;
|
|
||||||
return aWeight - bWeight;
|
|
||||||
});
|
|
||||||
print(originalTags);
|
|
||||||
final tags = appdata.settings["useTranslatedNameForDownload"] == false
|
|
||||||
? originalTags.map((e) => e.name).toList()
|
|
||||||
: originalTags.map((e) => e.translatedName ?? e.name).toList();
|
|
||||||
|
|
||||||
subPathPatten = subPathPatten.replaceAll(r"${id}", illust.id.toString());
|
subPathPatten = subPathPatten.replaceAll(r"${id}", illust.id.toString());
|
||||||
subPathPatten = subPathPatten.replaceAll(r"${title}", illust.title);
|
subPathPatten = subPathPatten.replaceAll(r"${title}", illust.title);
|
||||||
subPathPatten = subPathPatten.replaceAll(r"${author}", illust.author.name);
|
subPathPatten = subPathPatten.replaceAll(r"${author}", illust.author.name);
|
||||||
subPathPatten = subPathPatten.replaceAll(r"${index}", index.toString());
|
subPathPatten = subPathPatten.replaceAll(r"${index}", index.toString());
|
||||||
subPathPatten = subPathPatten.replaceAll(r"${ext}", ext);
|
subPathPatten = subPathPatten.replaceAll(r"${ext}", ext);
|
||||||
for(int i=0; i<tags.length; i++) {
|
subPathPatten = subPathPatten.replaceAll(r"${AI}", illust.isAi ? "AI" : "");
|
||||||
subPathPatten = subPathPatten.replaceAll("\${tag$i}", tags[i]);
|
List<String> extractTags(String input) {
|
||||||
|
final regex = RegExp(r'\$\{tag\((.*?)\)\}');
|
||||||
|
final matches = regex.allMatches(input);
|
||||||
|
return matches.map((match) => match.group(1)!).toList();
|
||||||
}
|
}
|
||||||
return "$downloadPath$subPathPatten";
|
var tags = extractTags(subPathPatten);
|
||||||
|
for(var tag in tags) {
|
||||||
|
if (illust.tags.where((e) => e.name == tag || e.translatedName == tag).isNotEmpty) {
|
||||||
|
subPathPatten = subPathPatten.replaceAll("\${tag($tag)}", tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _cleanFilePath("$downloadPath$subPathPatten");
|
||||||
|
}
|
||||||
|
|
||||||
|
static String _cleanFilePath(String filePath) {
|
||||||
|
const invalidChars = ['*', '?', '"', '<', '>', '|'];
|
||||||
|
|
||||||
|
String cleanedPath =
|
||||||
|
filePath.replaceAll(RegExp('[${invalidChars.join(' ')}]'), '');
|
||||||
|
|
||||||
|
cleanedPath = cleanedPath.replaceAll(RegExp(r'[/\\]+'), '/');
|
||||||
|
|
||||||
|
return cleanedPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void retry() {
|
void retry() {
|
||||||
@@ -269,7 +274,7 @@ class DownloadManager {
|
|||||||
_currentBytes += bytes;
|
_currentBytes += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get maxConcurrentTasks => appdata.settings["maxDownloadParallels"];
|
int get maxConcurrentTasks => appdata.settings["maxParallels"];
|
||||||
|
|
||||||
void run() {
|
void run() {
|
||||||
_loop ??= Timer.periodic(const Duration(seconds: 1), (timer) {
|
_loop ??= Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||||
|
@@ -142,6 +142,17 @@ class Tag {
|
|||||||
String toString() {
|
String toString() {
|
||||||
return "$name${translatedName == null ? "" : "($translatedName)"}";
|
return "$name${translatedName == null ? "" : "($translatedName)"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
if (other is Tag) {
|
||||||
|
return name == other.name;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => name.hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
class IllustImage {
|
class IllustImage {
|
||||||
@@ -170,6 +181,11 @@ class Illust {
|
|||||||
final int totalBookmarks;
|
final int totalBookmarks;
|
||||||
bool isBookmarked;
|
bool isBookmarked;
|
||||||
final bool isAi;
|
final bool isAi;
|
||||||
|
final bool isUgoira;
|
||||||
|
|
||||||
|
bool get isR18 => tags.contains(const Tag("R-18", null));
|
||||||
|
|
||||||
|
bool get isR18G => tags.contains(const Tag("R-18G", null));
|
||||||
|
|
||||||
Illust.fromJson(Map<String, dynamic> json)
|
Illust.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
@@ -211,7 +227,8 @@ class Illust {
|
|||||||
totalView = json['total_view'],
|
totalView = json['total_view'],
|
||||||
totalBookmarks = json['total_bookmarks'],
|
totalBookmarks = json['total_bookmarks'],
|
||||||
isBookmarked = json['is_bookmarked'],
|
isBookmarked = json['is_bookmarked'],
|
||||||
isAi = json['is_ai'] != 1;
|
isAi = json['illust_ai_type'] == 2,
|
||||||
|
isUgoira = json['type'] == "ugoira";
|
||||||
}
|
}
|
||||||
|
|
||||||
class TrendingTag {
|
class TrendingTag {
|
||||||
|
@@ -223,7 +223,7 @@ class Network {
|
|||||||
Future<Res<List<Illust>>> getBookmarkedIllusts(String restrict,
|
Future<Res<List<Illust>>> getBookmarkedIllusts(String restrict,
|
||||||
[String? nextUrl]) async {
|
[String? nextUrl]) async {
|
||||||
var res = await apiGet(nextUrl ??
|
var res = await apiGet(nextUrl ??
|
||||||
"/v1/user/bookmarks/illust?user_id=49258688&restrict=$restrict");
|
"/v1/user/bookmarks/illust?user_id=${appdata.account?.user.id}&restrict=$restrict");
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
return Res(
|
return Res(
|
||||||
(res.data["illusts"] as List).map((e) => Illust.fromJson(e)).toList(),
|
(res.data["illusts"] as List).map((e) => Illust.fromJson(e)).toList(),
|
||||||
|
@@ -2,6 +2,7 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:fluent_ui/fluent_ui.dart';
|
import 'package:fluent_ui/fluent_ui.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:photo_view/photo_view_gallery.dart';
|
import 'package:photo_view/photo_view_gallery.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';
|
||||||
@@ -266,11 +267,13 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ScaffoldPage(
|
return Container(
|
||||||
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
|
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
|
||||||
content: Listener(
|
color: FluentTheme.of(context).micaBackgroundColor,
|
||||||
|
child: Listener(
|
||||||
onPointerSignal: (event) {
|
onPointerSignal: (event) {
|
||||||
if(event is PointerScrollEvent) {
|
if(event is PointerScrollEvent &&
|
||||||
|
!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);
|
||||||
@@ -286,8 +289,8 @@ class _DownloadedIllustViewPageState extends State<_DownloadedIllustViewPage> wi
|
|||||||
children: [
|
children: [
|
||||||
Positioned.fill(child: PhotoViewGallery.builder(
|
Positioned.fill(child: PhotoViewGallery.builder(
|
||||||
pageController: controller,
|
pageController: controller,
|
||||||
backgroundDecoration: BoxDecoration(
|
backgroundDecoration: const BoxDecoration(
|
||||||
color: FluentTheme.of(context).micaBackgroundColor
|
color: Colors.transparent
|
||||||
),
|
),
|
||||||
itemCount: widget.imagePaths.length,
|
itemCount: widget.imagePaths.length,
|
||||||
builder: (context, index) {
|
builder: (context, index) {
|
||||||
|
@@ -19,6 +19,7 @@ import 'package:pixes/utils/translation.dart';
|
|||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
|
||||||
import '../components/md.dart';
|
import '../components/md.dart';
|
||||||
|
import '../components/ugoira.dart';
|
||||||
|
|
||||||
|
|
||||||
const _kBottomBarHeight = 64.0;
|
const _kBottomBarHeight = 64.0;
|
||||||
@@ -75,6 +76,19 @@ class _IllustPageState extends State<IllustPage> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void openImage(int index) {
|
||||||
|
var images = <String>[];
|
||||||
|
for(var i = 0; i < widget.illust.images.length; i++) {
|
||||||
|
var downloadFile = DownloadManager().getImage(widget.illust.id, i);
|
||||||
|
if(downloadFile != null) {
|
||||||
|
images.add("file://${downloadFile.path}");
|
||||||
|
} else {
|
||||||
|
images.add(widget.illust.images[i].original);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImagePage.show(images, initialPage: index);
|
||||||
|
}
|
||||||
|
|
||||||
Widget buildImage(double width, double height, int index) {
|
Widget buildImage(double width, double height, int index) {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
return Text(
|
return Text(
|
||||||
@@ -100,44 +114,53 @@ class _IllustPageState extends State<IllustPage> {
|
|||||||
imageWidth = imageWidth / scale;
|
imageWidth = imageWidth / scale;
|
||||||
imageHeight = height;
|
imageHeight = height;
|
||||||
}
|
}
|
||||||
var image = SizedBox(
|
Widget image;
|
||||||
width: imageWidth,
|
|
||||||
height: imageHeight,
|
if(!widget.illust.isUgoira) {
|
||||||
child: GestureDetector(
|
image = SizedBox(
|
||||||
onTap: () => ImagePage.show(downloadFile == null
|
width: imageWidth,
|
||||||
? widget.illust.images[index].original
|
height: imageHeight,
|
||||||
: "file://${downloadFile.path}"),
|
child: GestureDetector(
|
||||||
child: Image(
|
onTap: () => openImage(index),
|
||||||
key: ValueKey(index),
|
child: Image(
|
||||||
image: downloadFile == null
|
key: ValueKey(index),
|
||||||
? CachedImageProvider(widget.illust.images[index].large) as ImageProvider
|
image: downloadFile == null
|
||||||
: FileImage(downloadFile) as ImageProvider,
|
? CachedImageProvider(widget.illust.images[index].large) as ImageProvider
|
||||||
width: imageWidth,
|
: FileImage(downloadFile) as ImageProvider,
|
||||||
fit: BoxFit.cover,
|
width: imageWidth,
|
||||||
height: imageHeight,
|
fit: BoxFit.cover,
|
||||||
loadingBuilder: (context, child, loadingProgress) {
|
height: imageHeight,
|
||||||
if (loadingProgress == null) return child;
|
loadingBuilder: (context, child, loadingProgress) {
|
||||||
double? value;
|
if (loadingProgress == null) return child;
|
||||||
if(loadingProgress.expectedTotalBytes != null) {
|
double? value;
|
||||||
value = (loadingProgress.cumulativeBytesLoaded /
|
if(loadingProgress.expectedTotalBytes != null) {
|
||||||
loadingProgress.expectedTotalBytes!)*100;
|
value = (loadingProgress.cumulativeBytesLoaded /
|
||||||
}
|
loadingProgress.expectedTotalBytes!)*100;
|
||||||
if(value != null && (value > 100 || value < 0)) {
|
}
|
||||||
value = null;
|
if(value != null && (value > 100 || value < 0)) {
|
||||||
}
|
value = null;
|
||||||
return Center(
|
}
|
||||||
child: SizedBox(
|
return Center(
|
||||||
width: 24,
|
child: SizedBox(
|
||||||
height: 24,
|
width: 24,
|
||||||
child: ProgressRing(
|
height: 24,
|
||||||
value: value,
|
child: ProgressRing(
|
||||||
),
|
value: value,
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
} else {
|
||||||
|
image = UgoiraWidget(
|
||||||
|
id: widget.illust.id.toString(),
|
||||||
|
previewImage: CachedImageProvider(widget.illust.images[index].large),
|
||||||
|
width: imageWidth,
|
||||||
|
height: imageHeight,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return Center(
|
return Center(
|
||||||
child: image,
|
child: image,
|
||||||
|
@@ -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:photo_view/photo_view.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:photo_view/photo_view_gallery.dart';
|
||||||
import 'package:pixes/components/md.dart';
|
import 'package:pixes/components/md.dart';
|
||||||
import 'package:pixes/components/page_route.dart';
|
import 'package:pixes/components/page_route.dart';
|
||||||
import 'package:pixes/foundation/app.dart';
|
import 'package:pixes/foundation/app.dart';
|
||||||
@@ -14,13 +16,16 @@ import 'package:share_plus/share_plus.dart';
|
|||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
class ImagePage extends StatefulWidget {
|
class ImagePage extends StatefulWidget {
|
||||||
const ImagePage(this.url, {super.key});
|
const ImagePage(this.urls, {this.initialPage = 1, super.key});
|
||||||
|
|
||||||
final String url;
|
final List<String> urls;
|
||||||
|
|
||||||
static show(String url) {
|
final int initialPage;
|
||||||
|
|
||||||
|
static show(List<String> urls, {int initialPage = 1}) {
|
||||||
App.rootNavigatorKey.currentState
|
App.rootNavigatorKey.currentState
|
||||||
?.push(AppPageRoute(builder: (context) => ImagePage(url)));
|
?.push(AppPageRoute(
|
||||||
|
builder: (context) => ImagePage(urls, initialPage: initialPage)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -56,70 +61,25 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
late var controller = PageController(initialPage: widget.initialPage);
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Container(
|
late int currentPage = widget.initialPage;
|
||||||
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
|
|
||||||
color: FluentTheme.of(context).micaBackgroundColor,
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
Positioned.fill(
|
|
||||||
child: PhotoView(
|
|
||||||
backgroundDecoration: BoxDecoration(
|
|
||||||
color: FluentTheme.of(context).micaBackgroundColor),
|
|
||||||
filterQuality: FilterQuality.medium,
|
|
||||||
imageProvider: widget.url.startsWith("file://")
|
|
||||||
? FileImage(File(widget.url.replaceFirst("file://", "")))
|
|
||||||
: CachedImageProvider(widget.url) as ImageProvider,
|
|
||||||
)),
|
|
||||||
Positioned(
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
child: SizedBox(
|
|
||||||
height: 36,
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
const SizedBox(
|
|
||||||
width: 6,
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(FluentIcons.back).paddingAll(2),
|
|
||||||
onPressed: () => context.pop()),
|
|
||||||
const Expanded(
|
|
||||||
child: DragToMoveArea(
|
|
||||||
child: SizedBox.expand(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
buildActions(),
|
|
||||||
if (App.isDesktop)
|
|
||||||
WindowButtons(
|
|
||||||
key: ValueKey(windowButtonKey),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
var menuController = FlyoutController();
|
var menuController = FlyoutController();
|
||||||
|
|
||||||
Future<File?> getFile() async{
|
Future<File?> getFile() async {
|
||||||
if (widget.url.startsWith("file://")) {
|
var image = widget.urls[currentPage];
|
||||||
return File(widget.url.replaceFirst("file://", ""));
|
if(image.startsWith("file://")){
|
||||||
|
return File(image.replaceFirst("file://", ""));
|
||||||
}
|
}
|
||||||
var res = await CacheManager().findCache(widget.url);
|
var file = await CacheManager().findCache(image);
|
||||||
if(res == null){
|
return file == null
|
||||||
return null;
|
? null
|
||||||
}
|
: File(file);
|
||||||
return File(res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String getExtensionName() {
|
String getExtensionName() {
|
||||||
var fileName = widget.url.split('/').last;
|
var fileName = widget.urls[currentPage].split('/').last;
|
||||||
if(fileName.contains('.')){
|
if(fileName.contains('.')){
|
||||||
return '.${fileName.split('.').last}';
|
return '.${fileName.split('.').last}';
|
||||||
}
|
}
|
||||||
@@ -142,20 +102,17 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
MenuFlyoutItem(text: Text("Share".tl), onPressed: () async{
|
MenuFlyoutItem(text: Text("Share".tl), onPressed: () async{
|
||||||
var file = await getFile();
|
var file = await getFile();
|
||||||
if(file != null){
|
if(file != null){
|
||||||
|
var ext = getExtensionName();
|
||||||
var fileName = file.path.split('/').last;
|
var fileName = file.path.split('/').last;
|
||||||
String ext;
|
|
||||||
if(!fileName.contains('.')){
|
if(!fileName.contains('.')){
|
||||||
ext = getExtensionName();
|
fileName += ext;
|
||||||
fileName += getExtensionName();
|
|
||||||
} else {
|
|
||||||
ext = file.path.split('.').last;
|
|
||||||
}
|
}
|
||||||
var mediaType = switch(ext.replaceFirst('.', "")){
|
var mediaType = switch(ext){
|
||||||
'jpg' => 'image/jpeg',
|
'.jpg' => 'image/jpeg',
|
||||||
'jpeg' => 'image/jpeg',
|
'.jpeg' => 'image/jpeg',
|
||||||
'png' => 'image/png',
|
'.png' => 'image/png',
|
||||||
'gif' => 'image/gif',
|
'.gif' => 'image/gif',
|
||||||
'webp' => 'image/webp',
|
'.webp' => 'image/webp',
|
||||||
_ => 'application/octet-stream'
|
_ => 'application/octet-stream'
|
||||||
};
|
};
|
||||||
Share.shareXFiles([XFile.fromData(
|
Share.shareXFiles([XFile.fromData(
|
||||||
@@ -169,6 +126,113 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
|
||||||
|
color: FluentTheme.of(context).micaBackgroundColor,
|
||||||
|
child: Listener(
|
||||||
|
onPointerSignal: (event) {
|
||||||
|
if(event is PointerScrollEvent &&
|
||||||
|
!HardwareKeyboard.instance.isControlPressed) {
|
||||||
|
if(event.scrollDelta.dy > 0
|
||||||
|
&& controller.page!.toInt() < widget.urls.length - 1) {
|
||||||
|
controller.jumpToPage(controller.page!.toInt() + 1);
|
||||||
|
} else if(event.scrollDelta.dy < 0 && controller.page!.toInt() > 0){
|
||||||
|
controller.jumpToPage(controller.page!.toInt() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constrains) {
|
||||||
|
var height = constrains.maxHeight;
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
Positioned.fill(child: PhotoViewGallery.builder(
|
||||||
|
pageController: controller,
|
||||||
|
backgroundDecoration: const BoxDecoration(
|
||||||
|
color: Colors.transparent
|
||||||
|
),
|
||||||
|
itemCount: widget.urls.length,
|
||||||
|
builder: (context, index) {
|
||||||
|
var image = widget.urls[index];
|
||||||
|
|
||||||
|
return PhotoViewGalleryPageOptions(
|
||||||
|
imageProvider: image.startsWith("file://")
|
||||||
|
? FileImage(File(image.replaceFirst("file://", "")))
|
||||||
|
: CachedImageProvider(image) as ImageProvider,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onPageChanged: (index) {
|
||||||
|
setState(() {
|
||||||
|
currentPage = index;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
Positioned(
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
child: SizedBox(
|
||||||
|
height: 36,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const SizedBox(width: 6,),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(FluentIcons.back).paddingAll(2),
|
||||||
|
onPressed: () => context.pop()
|
||||||
|
),
|
||||||
|
const Expanded(
|
||||||
|
child: DragToMoveArea(child: SizedBox.expand(),),
|
||||||
|
),
|
||||||
|
buildActions(),
|
||||||
|
if(App.isDesktop)
|
||||||
|
WindowButtons(key: ValueKey(windowButtonKey),),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
top: height / 2 - 9,
|
||||||
|
child: IconButton(
|
||||||
|
icon: const Icon(FluentIcons.chevron_left, size: 18,),
|
||||||
|
onPressed: () {
|
||||||
|
controller.previousPage(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).paddingAll(8),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
right: 0,
|
||||||
|
top: height / 2 - 9,
|
||||||
|
child: IconButton(
|
||||||
|
icon: const Icon(FluentIcons.chevron_right, size: 18),
|
||||||
|
onPressed: () {
|
||||||
|
controller.nextPage(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).paddingAll(8),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
left: 12,
|
||||||
|
bottom: 8,
|
||||||
|
child: Text(
|
||||||
|
"${currentPage + 1}/${widget.urls.length}",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget buildActions() {
|
Widget buildActions() {
|
||||||
var width = MediaQuery.of(context).size.width;
|
var width = MediaQuery.of(context).size.width;
|
||||||
return FlyoutTarget(
|
return FlyoutTarget(
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import 'package:fluent_ui/fluent_ui.dart';
|
import 'package:fluent_ui/fluent_ui.dart';
|
||||||
import 'package:pixes/foundation/app.dart';
|
import 'package:pixes/foundation/app.dart';
|
||||||
import 'package:pixes/network/network.dart';
|
import 'package:pixes/network/network.dart';
|
||||||
|
import 'package:pixes/pages/webview_page.dart';
|
||||||
import 'package:pixes/utils/app_links.dart';
|
import 'package:pixes/utils/app_links.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';
|
||||||
@@ -186,7 +187,6 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
|
|
||||||
void onContinue() async {
|
void onContinue() async {
|
||||||
var url = await Network().generateWebviewUrl();
|
var url = await Network().generateWebviewUrl();
|
||||||
launchUrlString(url);
|
|
||||||
onLink = (uri) {
|
onLink = (uri) {
|
||||||
if (uri.scheme == "pixiv") {
|
if (uri.scheme == "pixiv") {
|
||||||
onFinished(uri.queryParameters["code"]!);
|
onFinished(uri.queryParameters["code"]!);
|
||||||
@@ -198,6 +198,18 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
waitingForAuth = true;
|
waitingForAuth = true;
|
||||||
});
|
});
|
||||||
|
if(App.isMobile && mounted) {
|
||||||
|
context.to(() => WebviewPage(url, onNavigation: (req) {
|
||||||
|
if(req.url.startsWith("pixiv://")) {
|
||||||
|
App.rootNavigatorKey.currentState!.pop();
|
||||||
|
onLink?.call(Uri.parse(req.url));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},));
|
||||||
|
} else {
|
||||||
|
launchUrlString(url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onFinished(String code) async {
|
void onFinished(String code) async {
|
||||||
|
80
lib/pages/logs.dart
Normal file
80
lib/pages/logs.dart
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
import 'package:fluent_ui/fluent_ui.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:pixes/components/md.dart';
|
||||||
|
import 'package:pixes/components/title_bar.dart';
|
||||||
|
import 'package:pixes/foundation/log.dart';
|
||||||
|
|
||||||
|
class LogsPage extends StatefulWidget {
|
||||||
|
const LogsPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<LogsPage> createState() => _LogsPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LogsPageState extends State<LogsPage> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
const TitleBar(title: "Logs"),
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
reverse: true,
|
||||||
|
controller: ScrollController(),
|
||||||
|
itemCount: Log.logs.length,
|
||||||
|
itemBuilder: (context, index){
|
||||||
|
index = Log.logs.length - index - 1;
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
|
||||||
|
child: SelectionArea(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: ColorScheme.of(context).surfaceVariant,
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(5, 0, 5, 1),
|
||||||
|
child: Text(Log.logs[index].title),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 3,),
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: [
|
||||||
|
ColorScheme.of(context).error,
|
||||||
|
ColorScheme.of(context).errorContainer,
|
||||||
|
ColorScheme.of(context).primaryContainer
|
||||||
|
][Log.logs[index].level.index],
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(5, 0, 5, 1),
|
||||||
|
child: Text(
|
||||||
|
Log.logs[index].level.name,
|
||||||
|
style: TextStyle(color: Log.logs[index].level.index==0?Colors.white:Colors.black),),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Text(Log.logs[index].content),
|
||||||
|
Text(Log.logs[index].time.toString().replaceAll(RegExp(r"\.\w+"), "")),
|
||||||
|
Button(onPressed: (){
|
||||||
|
Clipboard.setData(ClipboardData(text: Log.logs[index].content));
|
||||||
|
}, child: const Text("复制")),
|
||||||
|
const Divider(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -6,6 +6,7 @@ import "package:flutter/material.dart" as md;
|
|||||||
import "package:pixes/appdata.dart";
|
import "package:pixes/appdata.dart";
|
||||||
import "package:pixes/components/md.dart";
|
import "package:pixes/components/md.dart";
|
||||||
import "package:pixes/foundation/app.dart";
|
import "package:pixes/foundation/app.dart";
|
||||||
|
import "package:pixes/foundation/image_provider.dart";
|
||||||
import "package:pixes/network/network.dart";
|
import "package:pixes/network/network.dart";
|
||||||
import "package:pixes/pages/bookmarks.dart";
|
import "package:pixes/pages/bookmarks.dart";
|
||||||
import "package:pixes/pages/downloaded_page.dart";
|
import "package:pixes/pages/downloaded_page.dart";
|
||||||
@@ -465,7 +466,7 @@ class UserPane extends PaneItem {
|
|||||||
child: Image(
|
child: Image(
|
||||||
height: 48,
|
height: 48,
|
||||||
width: 48,
|
width: 48,
|
||||||
image: NetworkImage(appdata.account!.user.profile),
|
image: CachedImageProvider(appdata.account!.user.profile),
|
||||||
fit: BoxFit.fill,
|
fit: BoxFit.fill,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@@ -12,6 +12,8 @@ import 'package:pixes/utils/io.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';
|
||||||
|
|
||||||
|
import 'logs.dart';
|
||||||
|
|
||||||
class SettingsPage extends StatefulWidget {
|
class SettingsPage extends StatefulWidget {
|
||||||
const SettingsPage({super.key});
|
const SettingsPage({super.key});
|
||||||
|
|
||||||
@@ -29,8 +31,12 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||||||
SliverTitleBar(title: "Settings".tl),
|
SliverTitleBar(title: "Settings".tl),
|
||||||
buildHeader("Account".tl),
|
buildHeader("Account".tl),
|
||||||
buildAccount(),
|
buildAccount(),
|
||||||
|
buildHeader("Browse".tl),
|
||||||
|
buildBrowse(),
|
||||||
buildHeader("Download".tl),
|
buildHeader("Download".tl),
|
||||||
buildDownload(),
|
buildDownload(),
|
||||||
|
buildHeader("Appearance".tl),
|
||||||
|
buildAppearance(),
|
||||||
buildHeader("About".tl),
|
buildHeader("About".tl),
|
||||||
buildAbout(),
|
buildAbout(),
|
||||||
SliverPadding(
|
SliverPadding(
|
||||||
@@ -121,10 +127,20 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||||||
child: Text("Manage".tl).fixWidth(64),
|
child: Text("Manage".tl).fixWidth(64),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (Platform.isIOS) {
|
if (Platform.isIOS) {
|
||||||
showToast(context, message: "Unsupport platform".tl);
|
showToast(context, message: "Unsupported platform".tl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
context.to(() => const _SetDownloadPathPage());
|
context.to(() => _SetSingleFieldPage(
|
||||||
|
"Download Path".tl,
|
||||||
|
"downloadPath",
|
||||||
|
check: (text) {
|
||||||
|
if(!Directory(text).havePermission()) {
|
||||||
|
return "No permission".tl;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
buildItem(
|
buildItem(
|
||||||
@@ -177,29 +193,131 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
launchUrlString("https://t.me/pica_group"),
|
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())
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildBrowse() {
|
||||||
|
return SliverToBoxAdapter(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
buildItem(
|
||||||
|
title: "Proxy".tl,
|
||||||
|
action: Button(
|
||||||
|
child: Text("Edit".tl).fixWidth(64),
|
||||||
|
onPressed: () {
|
||||||
|
context.to(() => _SetSingleFieldPage(
|
||||||
|
"Http ${"Proxy".tl}",
|
||||||
|
"proxy",
|
||||||
|
));
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildAppearance() {
|
||||||
|
return SliverToBoxAdapter(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
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();
|
||||||
|
}),
|
||||||
|
])),
|
||||||
|
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();
|
||||||
|
}),
|
||||||
|
])),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SetDownloadPathPage extends StatefulWidget {
|
class _SetSingleFieldPage extends StatefulWidget {
|
||||||
const _SetDownloadPathPage();
|
const _SetSingleFieldPage(this.title, this.field, {this.check});
|
||||||
|
|
||||||
|
final String title;
|
||||||
|
|
||||||
|
final String field;
|
||||||
|
|
||||||
|
final String? Function(String)? check;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<_SetDownloadPathPage> createState() => __SetDownloadPathPageState();
|
State<_SetSingleFieldPage> createState() => _SetSingleFieldPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class __SetDownloadPathPageState extends State<_SetDownloadPathPage> {
|
class _SetSingleFieldPageState extends State<_SetSingleFieldPage> {
|
||||||
final controller =
|
late final controller =
|
||||||
TextEditingController(text: appdata.settings["downloadPath"]);
|
TextEditingController(text: appdata.settings[widget.field]);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
TitleBar(title: "Download Path".tl),
|
TitleBar(title: widget.title),
|
||||||
TextBox(
|
TextBox(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
).paddingHorizontal(16),
|
).paddingHorizontal(16),
|
||||||
@@ -210,12 +328,13 @@ class __SetDownloadPathPageState extends State<_SetDownloadPathPage> {
|
|||||||
child: Text("Confirm".tl),
|
child: Text("Confirm".tl),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
var text = controller.text;
|
var text = controller.text;
|
||||||
if (Directory(text).havePermission()) {
|
var checkRes = widget.check?.call(text);
|
||||||
appdata.settings["downloadPath"] = text;
|
if (checkRes == null) {
|
||||||
|
appdata.settings[widget.field] = text;
|
||||||
appdata.writeData();
|
appdata.writeData();
|
||||||
context.pop();
|
context.pop();
|
||||||
} else {
|
} else {
|
||||||
showToast(context, message: "No Permission".tl);
|
showToast(context, message: checkRes);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
).toAlign(Alignment.centerRight).paddingRight(16),
|
).toAlign(Alignment.centerRight).paddingRight(16),
|
||||||
@@ -235,8 +354,6 @@ class _SetDownloadSubPathPage extends StatefulWidget {
|
|||||||
class __SetDownloadSubPathPageState extends State<_SetDownloadSubPathPage> {
|
class __SetDownloadSubPathPageState extends State<_SetDownloadSubPathPage> {
|
||||||
final controller =
|
final controller =
|
||||||
TextEditingController(text: appdata.settings["downloadSubPath"]);
|
TextEditingController(text: appdata.settings["downloadSubPath"]);
|
||||||
final controller2 =
|
|
||||||
TextEditingController(text: appdata.settings["tagsWeight"]);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -250,26 +367,6 @@ class __SetDownloadSubPathPageState extends State<_SetDownloadSubPathPage> {
|
|||||||
TextBox(
|
TextBox(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
).paddingHorizontal(16),
|
).paddingHorizontal(16),
|
||||||
Text("Weights of the tags".tl)
|
|
||||||
.padding(const EdgeInsets.symmetric(vertical: 8, horizontal: 16)),
|
|
||||||
TextBox(
|
|
||||||
controller: controller2,
|
|
||||||
).paddingHorizontal(16),
|
|
||||||
const SizedBox(
|
|
||||||
height: 8,
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text("Use translated tag name".tl),
|
|
||||||
trailing: ToggleSwitch(
|
|
||||||
checked: appdata.settings["useTranslatedNameForDownload"],
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
appdata.settings["useTranslatedNameForDownload"] = value;
|
|
||||||
});
|
|
||||||
appdata.writeSettings();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 8,
|
height: 8,
|
||||||
),
|
),
|
||||||
@@ -279,7 +376,6 @@ class __SetDownloadSubPathPageState extends State<_SetDownloadSubPathPage> {
|
|||||||
var text = controller.text;
|
var text = controller.text;
|
||||||
if (check(text)) {
|
if (check(text)) {
|
||||||
appdata.settings["downloadSubPath"] = text;
|
appdata.settings["downloadSubPath"] = text;
|
||||||
appdata.settings["tagsWeight"] = controller2.text;
|
|
||||||
appdata.writeData();
|
appdata.writeData();
|
||||||
context.pop();
|
context.pop();
|
||||||
} else {
|
} else {
|
||||||
@@ -313,15 +409,9 @@ ${"Some keywords will be replaced by the following rule:".tl}
|
|||||||
\${id} -> ${"Artwork ID".tl}
|
\${id} -> ${"Artwork ID".tl}
|
||||||
\${index} -> ${"Index of the image in the artwork".tl}
|
\${index} -> ${"Index of the image in the artwork".tl}
|
||||||
\${ext} -> ${"File extension".tl}
|
\${ext} -> ${"File extension".tl}
|
||||||
|
\${AI} -> ${"Replace with 'AI' if the work was generated by AI, otherwise replace with blank".tl}
|
||||||
|
\${tag{*}} -> ${"Replace with * if the work have tag *, otherwise replace with blank.".tl}
|
||||||
|
|
||||||
${"Tags: Tags will be sorted by the \"Weights of tags\" setting and replaced by the following rule:".tl}
|
${"Multiple path separators will be automatically replaced with a single".tl}
|
||||||
${"The final text will be affected by the \"Use translated tag name\" setting.".tl}
|
|
||||||
\${tag0} -> ${"The first tag of the artwork".tl}
|
|
||||||
\${tag1} -> ${"The second tag of the artwork".tl}
|
|
||||||
...
|
|
||||||
|
|
||||||
${"Weights of the tags".tl}:
|
|
||||||
${"Filled with tags. The tags should be separated by a space. The tag in front has higher weight.".tl}
|
|
||||||
${"It is required to use the original name instead of the translated name.".tl}
|
|
||||||
""";
|
""";
|
||||||
}
|
}
|
||||||
|
81
lib/pages/webview_page.dart
Normal file
81
lib/pages/webview_page.dart
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import 'package:fluent_ui/fluent_ui.dart';
|
||||||
|
import 'package:pixes/components/md.dart';
|
||||||
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
import 'package:webview_flutter/webview_flutter.dart';
|
||||||
|
|
||||||
|
import '../foundation/app.dart';
|
||||||
|
|
||||||
|
double get _appBarHeight => App.isDesktop ? 36.0 : 48.0;
|
||||||
|
|
||||||
|
class WebviewPage extends StatefulWidget {
|
||||||
|
const WebviewPage(this.url, {this.onNavigation, super.key});
|
||||||
|
|
||||||
|
final String url;
|
||||||
|
|
||||||
|
final bool Function(NavigationRequest req)? onNavigation;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<WebviewPage> createState() => _WebviewPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _WebviewPageState extends State<WebviewPage> {
|
||||||
|
WebViewController? controller;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
NavigationDecision handleNavigation(NavigationRequest req) {
|
||||||
|
if (widget.onNavigation != null) {
|
||||||
|
return widget.onNavigation!(req)
|
||||||
|
? NavigationDecision.navigate
|
||||||
|
: NavigationDecision.prevent;
|
||||||
|
}
|
||||||
|
return NavigationDecision.navigate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
controller ??= WebViewController()
|
||||||
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||||
|
..setBackgroundColor(FluentTheme.of(context).brightness == Brightness.light
|
||||||
|
? Colors.white
|
||||||
|
: Colors.black)
|
||||||
|
..setNavigationDelegate(
|
||||||
|
NavigationDelegate(
|
||||||
|
onProgress: (int progress) {
|
||||||
|
// Update loading bar.
|
||||||
|
},
|
||||||
|
onPageStarted: (String url) {},
|
||||||
|
onPageFinished: (String url) {},
|
||||||
|
onWebResourceError: (WebResourceError error) {},
|
||||||
|
onNavigationRequest: handleNavigation,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
..loadRequest(Uri.parse(widget.url));
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: _appBarHeight,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Text("Webview"),
|
||||||
|
const Spacer(),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(MdIcons.open_in_new, size: 20,),
|
||||||
|
onPressed: () {
|
||||||
|
launchUrlString(widget.url);
|
||||||
|
context.pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).paddingHorizontal(16),
|
||||||
|
).paddingTop(MediaQuery.of(context).padding.top),
|
||||||
|
Expanded(
|
||||||
|
child: WebViewWidget(controller: controller!,),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -29,6 +29,9 @@ extension FSExt on FileSystemEntity {
|
|||||||
extension DirectoryExt on Directory {
|
extension DirectoryExt on Directory {
|
||||||
bool havePermission() {
|
bool havePermission() {
|
||||||
if(!existsSync()) return false;
|
if(!existsSync()) return false;
|
||||||
|
if(App.isMacOS) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
listSync();
|
listSync();
|
||||||
return true;
|
return true;
|
||||||
|
68
pubspec.lock
68
pubspec.lock
@@ -9,6 +9,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.0.1"
|
version: "6.0.1"
|
||||||
|
archive:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: archive
|
||||||
|
sha256: ecf4273855368121b1caed0d10d4513c7241dfc813f7d3c8933b36622ae9b265
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.5.1"
|
||||||
async:
|
async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -249,34 +257,34 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: intl
|
name: intl
|
||||||
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
|
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.18.1"
|
version: "0.19.0"
|
||||||
leak_tracker:
|
leak_tracker:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker
|
name: leak_tracker
|
||||||
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
|
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "10.0.0"
|
version: "10.0.4"
|
||||||
leak_tracker_flutter_testing:
|
leak_tracker_flutter_testing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker_flutter_testing
|
name: leak_tracker_flutter_testing
|
||||||
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
|
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "3.0.3"
|
||||||
leak_tracker_testing:
|
leak_tracker_testing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker_testing
|
name: leak_tracker_testing
|
||||||
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
|
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "3.0.1"
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -313,10 +321,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
|
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.11.0"
|
version: "1.12.0"
|
||||||
mime:
|
mime:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -535,10 +543,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
|
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.1"
|
version: "0.7.0"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -631,10 +639,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vm_service
|
name: vm_service
|
||||||
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
|
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "13.0.0"
|
version: "14.2.1"
|
||||||
web:
|
web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -643,6 +651,38 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.1"
|
version: "0.5.1"
|
||||||
|
webview_flutter:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: webview_flutter
|
||||||
|
sha256: "25e1b6e839e8cbfbd708abc6f85ed09d1727e24e08e08c6b8590d7c65c9a8932"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.7.0"
|
||||||
|
webview_flutter_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: webview_flutter_android
|
||||||
|
sha256: dad3313c9ead95517bb1cae5e1c9d20ba83729d5a59e5e83c0a2d66203f27f91
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.16.1"
|
||||||
|
webview_flutter_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: webview_flutter_platform_interface
|
||||||
|
sha256: d937581d6e558908d7ae3dc1989c4f87b786891ab47bb9df7de548a151779d8d
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.10.0"
|
||||||
|
webview_flutter_wkwebview:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: webview_flutter_wkwebview
|
||||||
|
sha256: "7affdf9d680c015b11587181171d3cad8093e449db1f7d9f0f08f4f33d24f9a0"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.13.1"
|
||||||
win32:
|
win32:
|
||||||
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.0+1
|
version: 1.0.2+3
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.3.4 <4.0.0'
|
sdk: '>=3.3.4 <4.0.0'
|
||||||
@@ -54,6 +54,8 @@ dependencies:
|
|||||||
share_plus: ^9.0.0
|
share_plus: ^9.0.0
|
||||||
file_selector: ^1.0.1
|
file_selector: ^1.0.1
|
||||||
flutter_file_dialog: 3.0.1
|
flutter_file_dialog: 3.0.1
|
||||||
|
archive: ^3.5.1
|
||||||
|
webview_flutter: ^4.7.0
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
Reference in New Issue
Block a user