From f4ddc01a237c82f5ac1ed16dfacb6f13a554c83c Mon Sep 17 00:00:00 2001 From: Theo Diamantidis Date: Sun, 22 Oct 2023 02:16:07 +0300 Subject: [PATCH] feat: properly handle root svg icons to copy to 'scalable' icon directory; remove .xpm since it's unsupported by 'dart:ui' --- .../home/data/appimage_tools_repository.dart | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/src/features/home/data/appimage_tools_repository.dart b/lib/src/features/home/data/appimage_tools_repository.dart index a1715ff..9a81ce6 100644 --- a/lib/src/features/home/data/appimage_tools_repository.dart +++ b/lib/src/features/home/data/appimage_tools_repository.dart @@ -150,7 +150,7 @@ class AppimageToolsRepository { .listSync() .firstWhere((element) => p.basenameWithoutExtension(element.path) == desktopBasename - && ['.png', '.svg', '.xpm'].contains(p.extension(element.path)) + && ['.png', '.svg'].contains(p.extension(element.path)) ); if (icon is File) { @@ -160,11 +160,19 @@ class AppimageToolsRepository { ); } - var iconData = await decodeImageFromList(icon.readAsBytesSync()); - int iconSize = iconData.height; - var iconFilename = "aip_${desktopBasename}_$checksum" + p.extension(icon.path); + String sizeName; + String iconExt = p.extension(icon.path); + if (iconExt == '.png') { + var iconData = await decodeImageFromList(icon.readAsBytesSync()); + int iconSize = iconData.height; + sizeName = "${iconSize}x${iconSize}"; + } else { + sizeName = "scalable"; + } + + var iconFilename = "aip_${desktopBasename}_${checksum}${iconExt}"; icon.moveResolvedFile( - localShareDir + "/icons/hicolor/${iconSize}x${iconSize}/apps/${iconFilename}" + localShareDir + "/icons/hicolor/${sizeName}/apps/${iconFilename}" ); } } catch (e) {