mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 12:57:24 +00:00
fix ui
This commit is contained in:
@@ -18,7 +18,7 @@ class _Appdata {
|
|||||||
"downloadSubPath": r"/${id}-p${index}.${ext}",
|
"downloadSubPath": r"/${id}-p${index}.${ext}",
|
||||||
"tagsWeight": "",
|
"tagsWeight": "",
|
||||||
"useTranslatedNameForDownload": false,
|
"useTranslatedNameForDownload": false,
|
||||||
"maxDownloadParallels": 3
|
"maxParallels": 3
|
||||||
};
|
};
|
||||||
|
|
||||||
bool lock = false;
|
bool lock = false;
|
||||||
@@ -54,7 +54,9 @@ class _Appdata {
|
|||||||
if (settingsFile.existsSync()) {
|
if (settingsFile.existsSync()) {
|
||||||
var json = jsonDecode(await settingsFile.readAsString());
|
var json = jsonDecode(await settingsFile.readAsString());
|
||||||
for (var key in json.keys) {
|
for (var key in json.keys) {
|
||||||
settings[key] = json[key];
|
if(json[key] != null) {
|
||||||
|
settings[key] = json[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (settings["downloadPath"] == null) {
|
if (settings["downloadPath"] == null) {
|
||||||
|
@@ -148,6 +148,10 @@ class CachedImageProvider extends BaseImageProvider<CachedImageProvider> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Uint8List> load(StreamController<ImageChunkEvent> chunkEvents) async{
|
Future<Uint8List> load(StreamController<ImageChunkEvent> chunkEvents) async{
|
||||||
|
chunkEvents.add(const ImageChunkEvent(
|
||||||
|
cumulativeBytesLoaded: 0,
|
||||||
|
expectedTotalBytes: 1,
|
||||||
|
));
|
||||||
var cached = await CacheManager().findCache(key);
|
var cached = await CacheManager().findCache(key);
|
||||||
if(cached != null) {
|
if(cached != null) {
|
||||||
chunkEvents.add(const ImageChunkEvent(
|
chunkEvents.add(const ImageChunkEvent(
|
||||||
|
@@ -118,13 +118,25 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
return File(res);
|
return File(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getExtensionName() {
|
||||||
|
var fileName = widget.url.split('/').last;
|
||||||
|
if(fileName.contains('.')){
|
||||||
|
return '.${fileName.split('.').last}';
|
||||||
|
}
|
||||||
|
return '.jpg';
|
||||||
|
}
|
||||||
|
|
||||||
void showMenu() {
|
void showMenu() {
|
||||||
menuController.showFlyout(builder: (context) => MenuFlyout(
|
menuController.showFlyout(builder: (context) => MenuFlyout(
|
||||||
items: [
|
items: [
|
||||||
MenuFlyoutItem(text: Text("Save to".tl), onPressed: () async{
|
MenuFlyoutItem(text: Text("Save to".tl), onPressed: () async{
|
||||||
var file = await getFile();
|
var file = await getFile();
|
||||||
if(file != null){
|
if(file != null){
|
||||||
saveFile(file);
|
var fileName = file.path.split('/').last;
|
||||||
|
if(!fileName.contains('.')){
|
||||||
|
fileName += getExtensionName();
|
||||||
|
}
|
||||||
|
saveFile(file, fileName);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
MenuFlyoutItem(text: Text("Share".tl), onPressed: () async{
|
MenuFlyoutItem(text: Text("Share".tl), onPressed: () async{
|
||||||
@@ -133,12 +145,12 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
var fileName = file.path.split('/').last;
|
var fileName = file.path.split('/').last;
|
||||||
String ext;
|
String ext;
|
||||||
if(!fileName.contains('.')){
|
if(!fileName.contains('.')){
|
||||||
ext = 'jpg';
|
ext = getExtensionName();
|
||||||
fileName += '.jpg';
|
fileName += getExtensionName();
|
||||||
} else {
|
} else {
|
||||||
ext = file.path.split('.').last;
|
ext = file.path.split('.').last;
|
||||||
}
|
}
|
||||||
var mediaType = switch(ext){
|
var mediaType = switch(ext.replaceFirst('.', "")){
|
||||||
'jpg' => 'image/jpeg',
|
'jpg' => 'image/jpeg',
|
||||||
'jpeg' => 'image/jpeg',
|
'jpeg' => 'image/jpeg',
|
||||||
'png' => 'image/png',
|
'png' => 'image/png',
|
||||||
|
@@ -50,11 +50,11 @@ String bytesToText(int bytes) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveFile(File file) async{
|
void saveFile(File file, [String? name]) async{
|
||||||
if(App.isDesktop) {
|
if(App.isDesktop) {
|
||||||
var fileName = file.path.split('/').last;
|
var fileName = file.path.split('/').last;
|
||||||
final FileSaveLocation? result =
|
final FileSaveLocation? result =
|
||||||
await getSaveLocation(suggestedName: fileName);
|
await getSaveLocation(suggestedName: name ?? fileName);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -62,10 +62,10 @@ void saveFile(File file) async{
|
|||||||
final Uint8List fileData = await file.readAsBytes();
|
final Uint8List fileData = await file.readAsBytes();
|
||||||
String mimeType = 'image/${fileName.split('.').last}';
|
String mimeType = 'image/${fileName.split('.').last}';
|
||||||
final XFile textFile = XFile.fromData(
|
final XFile textFile = XFile.fromData(
|
||||||
fileData, mimeType: mimeType, name: fileName);
|
fileData, mimeType: mimeType, name: name ?? fileName);
|
||||||
await textFile.saveTo(result.path);
|
await textFile.saveTo(result.path);
|
||||||
} else {
|
} else {
|
||||||
final params = SaveFileDialogParams(sourceFilePath: file.path);
|
final params = SaveFileDialogParams(sourceFilePath: file.path, fileName: name);
|
||||||
await FlutterFileDialog.saveFile(params: params);
|
await FlutterFileDialog.saveFile(params: params);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -107,7 +107,7 @@ flutter:
|
|||||||
# see https://flutter.dev/custom-fonts/#from-packages
|
# see https://flutter.dev/custom-fonts/#from-packages
|
||||||
|
|
||||||
# font used for building windows application
|
# font used for building windows application
|
||||||
fonts:
|
#fonts:
|
||||||
- family: font
|
# - family: font
|
||||||
fonts:
|
# fonts:
|
||||||
- asset: assets/SourceHanSansSC-Regular.otf
|
# - asset: assets/SourceHanSansSC-Regular.otf
|
Reference in New Issue
Block a user