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}",
|
||||
"tagsWeight": "",
|
||||
"useTranslatedNameForDownload": false,
|
||||
"maxDownloadParallels": 3
|
||||
"maxParallels": 3
|
||||
};
|
||||
|
||||
bool lock = false;
|
||||
@@ -54,7 +54,9 @@ class _Appdata {
|
||||
if (settingsFile.existsSync()) {
|
||||
var json = jsonDecode(await settingsFile.readAsString());
|
||||
for (var key in json.keys) {
|
||||
settings[key] = json[key];
|
||||
if(json[key] != null) {
|
||||
settings[key] = json[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (settings["downloadPath"] == null) {
|
||||
|
@@ -148,6 +148,10 @@ class CachedImageProvider extends BaseImageProvider<CachedImageProvider> {
|
||||
|
||||
@override
|
||||
Future<Uint8List> load(StreamController<ImageChunkEvent> chunkEvents) async{
|
||||
chunkEvents.add(const ImageChunkEvent(
|
||||
cumulativeBytesLoaded: 0,
|
||||
expectedTotalBytes: 1,
|
||||
));
|
||||
var cached = await CacheManager().findCache(key);
|
||||
if(cached != null) {
|
||||
chunkEvents.add(const ImageChunkEvent(
|
||||
|
@@ -118,13 +118,25 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
||||
return File(res);
|
||||
}
|
||||
|
||||
String getExtensionName() {
|
||||
var fileName = widget.url.split('/').last;
|
||||
if(fileName.contains('.')){
|
||||
return '.${fileName.split('.').last}';
|
||||
}
|
||||
return '.jpg';
|
||||
}
|
||||
|
||||
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);
|
||||
var fileName = file.path.split('/').last;
|
||||
if(!fileName.contains('.')){
|
||||
fileName += getExtensionName();
|
||||
}
|
||||
saveFile(file, fileName);
|
||||
}
|
||||
}),
|
||||
MenuFlyoutItem(text: Text("Share".tl), onPressed: () async{
|
||||
@@ -133,12 +145,12 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
||||
var fileName = file.path.split('/').last;
|
||||
String ext;
|
||||
if(!fileName.contains('.')){
|
||||
ext = 'jpg';
|
||||
fileName += '.jpg';
|
||||
ext = getExtensionName();
|
||||
fileName += getExtensionName();
|
||||
} else {
|
||||
ext = file.path.split('.').last;
|
||||
}
|
||||
var mediaType = switch(ext){
|
||||
var mediaType = switch(ext.replaceFirst('.', "")){
|
||||
'jpg' => 'image/jpeg',
|
||||
'jpeg' => 'image/jpeg',
|
||||
'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) {
|
||||
var fileName = file.path.split('/').last;
|
||||
final FileSaveLocation? result =
|
||||
await getSaveLocation(suggestedName: fileName);
|
||||
await getSaveLocation(suggestedName: name ?? fileName);
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
@@ -62,10 +62,10 @@ void saveFile(File file) async{
|
||||
final Uint8List fileData = await file.readAsBytes();
|
||||
String mimeType = 'image/${fileName.split('.').last}';
|
||||
final XFile textFile = XFile.fromData(
|
||||
fileData, mimeType: mimeType, name: fileName);
|
||||
fileData, mimeType: mimeType, name: name ?? fileName);
|
||||
await textFile.saveTo(result.path);
|
||||
} else {
|
||||
final params = SaveFileDialogParams(sourceFilePath: file.path);
|
||||
final params = SaveFileDialogParams(sourceFilePath: file.path, fileName: name);
|
||||
await FlutterFileDialog.saveFile(params: params);
|
||||
}
|
||||
}
|
@@ -107,7 +107,7 @@ flutter:
|
||||
# see https://flutter.dev/custom-fonts/#from-packages
|
||||
|
||||
# font used for building windows application
|
||||
fonts:
|
||||
- family: font
|
||||
fonts:
|
||||
- asset: assets/SourceHanSansSC-Regular.otf
|
||||
#fonts:
|
||||
# - family: font
|
||||
# fonts:
|
||||
# - asset: assets/SourceHanSansSC-Regular.otf
|
Reference in New Issue
Block a user