From efed032cbad484a98f4741ff0de3b47d5e62a3a1 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Thu, 7 Sep 2023 17:16:50 +0200 Subject: [PATCH 1/2] refactor(tool): Unify asset generation scripts Signed-off-by: jld3103 --- tool/generate-app.sh | 40 --------------------- tool/generate-assets.sh | 80 +++++++++++++++++++++++++++++++++++++++++ tool/generate-neon.sh | 55 ---------------------------- 3 files changed, 80 insertions(+), 95 deletions(-) delete mode 100755 tool/generate-app.sh delete mode 100755 tool/generate-neon.sh diff --git a/tool/generate-app.sh b/tool/generate-app.sh deleted file mode 100755 index afa487d450c..00000000000 --- a/tool/generate-app.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -set -euxo pipefail -cd "$(dirname "$0")/.." - -function export_mipmap_icon() { - source="$1" - name="$2" - size="$3" - dpi="$4" - inkscape "$source" -o "android/app/src/main/res/mipmap-${dpi}dpi/$name.png" -w "$size" -h "$size" -} - -function export_mipmap_icon_all() { - source="$1" - name="$2" - export_mipmap_icon "$source" "$name" 72 h & - export_mipmap_icon "$source" "$name" 48 m & - export_mipmap_icon "$source" "$name" 96 xh & - export_mipmap_icon "$source" "$name" 144 xxh & - export_mipmap_icon "$source" "$name" 192 xxxh & - wait -} - -( - cd packages/app - - # Splash screens - inkscape assets/logo.svg -o img/splash_icon.png -w 768 -h 768 # 768px at xxxhdpi is 192dp - convert -size 1152x1152 xc:none img/splash_icon.png -gravity center -composite img/splash_icon_android_12.png # 1152px at xxxhdpi is 288dp - exiftool -overwrite_original -all= img/splash_icon_android_12.png # To remove timestamps - - # Android launcher icons - export_mipmap_icon_all "assets/logo.svg" "ic_launcher" & - for id in files news notes notifications; do - export_mipmap_icon_all "../neon/neon_$id/assets/app.svg" "app_$id" & - done - wait - - fvm dart run flutter_native_splash:create -) diff --git a/tool/generate-assets.sh b/tool/generate-assets.sh index f82d3ae7368..6a8ebd2883f 100755 --- a/tool/generate-assets.sh +++ b/tool/generate-assets.sh @@ -4,5 +4,85 @@ cd "$(dirname "$0")/.." color="#f37736" +rm -rf /tmp/nextcloud-neon +mkdir -p /tmp/nextcloud-neon + +function copy_app_svg() { + id="$1" + path="$2" + target="packages/neon/neon_$id/assets/app.svg" + if [ -f "$path/img/app.svg" ]; then + cp "$path/img/app.svg" "$target" + elif [ -f "$path/img/$id.svg" ]; then + cp "$path/img/$id.svg" "$target" + else + echo "Can not find icon for $id in $path" + exit 1 + fi + sed -i "s/fill=\"#[^\"]*\"/fill=\"$color\"/g" "$target" +} + +function export_mipmap_icon() { + source="$1" + name="$2" + size="$3" + dpi="$4" + inkscape "$source" -o "android/app/src/main/res/mipmap-${dpi}dpi/$name.png" -w "$size" -h "$size" +} + +function export_mipmap_icon_all() { + source="$1" + name="$2" + export_mipmap_icon "$source" "$name" 72 h & + export_mipmap_icon "$source" "$name" 48 m & + export_mipmap_icon "$source" "$name" 96 xh & + export_mipmap_icon "$source" "$name" 144 xxh & + export_mipmap_icon "$source" "$name" 192 xxxh & + wait +} + wget https://raw.githubusercontent.com/Templarian/MaterialDesign/master/svg/cable-data.svg -O assets/logo.svg sed -i "s/ Date: Thu, 7 Sep 2023 17:28:22 +0200 Subject: [PATCH 2/2] refactor(tool,neon,app): Precompile all SVGs Signed-off-by: jld3103 --- packages/app/assets/logo.svg | 1 - packages/app/assets/logo.svg.vec | Bin 0 -> 644 bytes packages/app/lib/branding.dart | 12 +-- packages/app/pubspec.lock | 4 +- packages/app/pubspec.yaml | 2 +- packages/neon/neon/assets/logo_nextcloud.svg | 77 ------------------ .../neon/neon/assets/logo_nextcloud.svg.vec | Bin 0 -> 3687 bytes .../lib/src/models/app_implementation.dart | 16 ++-- .../neon/lib/src/widgets/nextcloud_logo.dart | 10 ++- packages/neon/neon_files/assets/app.svg | 1 - packages/neon/neon_files/assets/app.svg.vec | Bin 0 -> 208 bytes packages/neon/neon_files/pubspec.yaml | 1 + packages/neon/neon_news/assets/app.svg | 4 - packages/neon/neon_news/assets/app.svg.vec | Bin 0 -> 628 bytes packages/neon/neon_news/pubspec.yaml | 1 + packages/neon/neon_notes/assets/app.svg | 1 - packages/neon/neon_notes/assets/app.svg.vec | Bin 0 -> 180 bytes packages/neon/neon_notes/pubspec.yaml | 1 + .../neon/neon_notifications/assets/app.svg | 1 - .../neon_notifications/assets/app.svg.vec | Bin 0 -> 296 bytes packages/neon/neon_notifications/pubspec.yaml | 1 + tool/generate-assets.sh | 23 +++++- tool/generate-neon.sh | 63 ++++++++++++++ 23 files changed, 111 insertions(+), 108 deletions(-) delete mode 120000 packages/app/assets/logo.svg create mode 100644 packages/app/assets/logo.svg.vec delete mode 100644 packages/neon/neon/assets/logo_nextcloud.svg create mode 100644 packages/neon/neon/assets/logo_nextcloud.svg.vec delete mode 100644 packages/neon/neon_files/assets/app.svg create mode 100644 packages/neon/neon_files/assets/app.svg.vec delete mode 100644 packages/neon/neon_news/assets/app.svg create mode 100644 packages/neon/neon_news/assets/app.svg.vec delete mode 100644 packages/neon/neon_notes/assets/app.svg create mode 100644 packages/neon/neon_notes/assets/app.svg.vec delete mode 100644 packages/neon/neon_notifications/assets/app.svg create mode 100644 packages/neon/neon_notifications/assets/app.svg.vec create mode 100755 tool/generate-neon.sh diff --git a/packages/app/assets/logo.svg b/packages/app/assets/logo.svg deleted file mode 120000 index 4228c63504d..00000000000 --- a/packages/app/assets/logo.svg +++ /dev/null @@ -1 +0,0 @@ -../../../assets/logo.svg \ No newline at end of file diff --git a/packages/app/assets/logo.svg.vec b/packages/app/assets/logo.svg.vec new file mode 100644 index 0000000000000000000000000000000000000000..081aa56640df9cc579d5409c2750b92495ea5962 GIT binary patch literal 644 zcmZWnF-SsD6ul}aNkfENkwHrah43V3kltNNYDuA{KUl-xqNJg+rG}3o#V2Xd$_SL8 z#X<@k!?w`I1h-G4Zc#J@cJKRqmp(ksd*|Qx&N=tJjp<`>g#ezB$LQ?tXU_xB>x}@w z3=MF*+-?_tG_mnN1N4K3C(AqFqF_mYq%`YK@_X`1p%5RE`Jmy$R%s6}3K@L)I>c`L zL?OVr;x#jmLTq7Wu}F@R3N>>LnNQS)X}yVo$^`AxP}koj&tulBEN_Reh3tiSUH7WGnAM&K2-Cjyyjh=9Jb+|9$y%xCl6213^(<-qNTYK^|GB1&MrRe9 zjS6|$SIAkI*UTJc$tx5hqcU>VkmjSgMZNeXA8!f)9whVZx!D*ZFIno@xI!ljXJy~) zg>%|oG}1jK4ZA0HKQ1w7?2wlmh3tiSA?{UOH(n)wD|AkkvMngy$--KR+HL=Q?kQ*G z%uY`Z0#oFFfV_JZI``{u3E3(|FzV09gTNSC>Bs&$q%BjH9A#f7&1<^b2zk5fuZ_++ LhR5i!&|CWh?V{%D literal 0 HcmV?d00001 diff --git a/packages/app/lib/branding.dart b/packages/app/lib/branding.dart index 13382f2fad3..0a13a7cd633 100644 --- a/packages/app/lib/branding.dart +++ b/packages/app/lib/branding.dart @@ -1,19 +1,21 @@ import 'dart:ui'; -import 'package:flutter_svg/flutter_svg.dart'; import 'package:neon/theme.dart'; +import 'package:vector_graphics/vector_graphics.dart'; -final neonTheme = NeonTheme( +const neonTheme = NeonTheme( branding: branding, colorScheme: colorScheme, ); -final branding = Branding( +const branding = Branding( name: 'Nextcloud Neon', - logo: SvgPicture.asset( - 'assets/logo.svg', + logo: VectorGraphic( width: 100, height: 100, + loader: AssetBytesLoader( + 'assets/logo.svg.vec', + ), ), legalese: 'Copyright © 2023, provokateurin\nUnder GPLv3 license', ); diff --git a/packages/app/pubspec.lock b/packages/app/pubspec.lock index 9a9d68c7391..bb604b6c491 100644 --- a/packages/app/pubspec.lock +++ b/packages/app/pubspec.lock @@ -367,7 +367,7 @@ packages: source: hosted version: "2.0.16" flutter_svg: - dependency: "direct main" + dependency: transitive description: name: flutter_svg sha256: "8c5d68a82add3ca76d792f058b186a0599414f279f00ece4830b9b231b570338" @@ -1232,7 +1232,7 @@ packages: source: hosted version: "3.0.7" vector_graphics: - dependency: transitive + dependency: "direct main" description: name: vector_graphics sha256: "670f6e07aca990b4a2bcdc08a784193c4ccdd1932620244c3a86bb72a0eac67f" diff --git a/packages/app/pubspec.yaml b/packages/app/pubspec.yaml index 6de39d11f1f..14bfa9d13c7 100644 --- a/packages/app/pubspec.yaml +++ b/packages/app/pubspec.yaml @@ -9,7 +9,6 @@ environment: dependencies: flutter: sdk: flutter - flutter_svg: ^2.0.7 neon: git: url: https://github.com/nextcloud/neon @@ -30,6 +29,7 @@ dependencies: git: url: https://github.com/nextcloud/neon path: packages/neon/neon_notifications + vector_graphics: ^1.1.7 dev_dependencies: flutter_material_design_icons: ^1.1.7296 diff --git a/packages/neon/neon/assets/logo_nextcloud.svg b/packages/neon/neon/assets/logo_nextcloud.svg deleted file mode 100644 index 7910fc000c4..00000000000 --- a/packages/neon/neon/assets/logo_nextcloud.svg +++ /dev/null @@ -1,77 +0,0 @@ - - - -image/svg+xml \ No newline at end of file diff --git a/packages/neon/neon/assets/logo_nextcloud.svg.vec b/packages/neon/neon/assets/logo_nextcloud.svg.vec new file mode 100644 index 0000000000000000000000000000000000000000..af812c8245d7a1c2d98864f8cfcae4e08f127845 GIT binary patch literal 3687 zcmY+`3tY_U8VB&HNcMHfphNi3;$QMn{XaaD%*vpZ9q$^Zx%cp`XSotX#v5 zt-ct4_9Xh0#VA^A6pEIX-U@}Hzxc1P{?p5bqrd#tiInP!?NBJ}C5L6RSw)x|cDIg` zmb`Pq-Qv4af3XEg+x9ZZpSq$-P}O!uKH=9 ze3JT;R4-<$H)(NtzEy^P_f}H|3MmpQL(`HHRgt?|AKwMB`2Eq?BlU zT9ajeNZY|F(msQh)&ARvyY^QllExudR1F8UFQ4Ye>mWVfFX6as$0TkiDW9bN)ZSXu zwbZBmip#wx#X3A^AC$Gi0jGBoN&Uz+<$XZy&UUW6zvR%g!yLbNO_8Xbq0)(>t-XJN+eykNX`I2Lo$6ZZ_f}Xba`-G- zS&M&G<`c<(b0iKV1>*JlHEX^?m#p|t>Ow!<%$GQqFPcv?_x@8%1;mT45ay15)iMTM z6+axBi~aulw6&P?PxpS5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Ya7xfm3^?mQ2hJ{D{adeguOY{9vFx!Y% z$Nh13juG}J{oym$h__;2j(sBI$fzLP%9Pn zt_g+9LttB%iT8VF;!ap5`oElt^*7Ve!7vG<#rnG53&2uM5_Ucaz(REr!j(=bprIagG#;MeOXT^KAW! zQf?=8BA*;8`u}IUh($eLr&7!o*~k-O-}Q(VQa(xjNg7vjIKkumu<|%tSkx1*#eL;a?8tU$=Y)LmyxF+S z348kPL#MUv*-_^^piJBkd&;_Uo~0k%7wsw%@QophJ>-#tc3a7V;bj^eZzFzPIWEyqi0od{Z+;PV(EKJhZ-G!f2kCo0~B|+ z70>H}n_TyScNM#F$rZNlTsZ=V>QR$b4$3D#zM6zF*;lxprT*}K^o6~prJoh^f0!00 A)Bpeg literal 0 HcmV?d00001 diff --git a/packages/neon/neon/lib/src/models/app_implementation.dart b/packages/neon/neon/lib/src/models/app_implementation.dart index 5051d0e6d85..7b0c628d58b 100644 --- a/packages/neon/neon/lib/src/models/app_implementation.dart +++ b/packages/neon/neon/lib/src/models/app_implementation.dart @@ -1,6 +1,5 @@ import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; import 'package:go_router/go_router.dart'; import 'package:meta/meta.dart'; import 'package:neon/l10n/localizations.dart'; @@ -12,6 +11,7 @@ import 'package:neon/src/settings/models/storage.dart'; import 'package:neon/src/widgets/drawer_destination.dart'; import 'package:provider/provider.dart'; import 'package:rxdart/rxdart.dart'; +import 'package:vector_graphics/vector_graphics.dart'; @immutable abstract class AppImplementation { @@ -95,13 +95,15 @@ abstract class AppImplementation final Color? color, }) => Builder( - builder: (final context) => SizedBox.fromSize( - size: size, - child: SvgPicture.asset( - 'assets/app.svg', - package: 'neon_$id', - colorFilter: ColorFilter.mode(color ?? Theme.of(context).colorScheme.primary, BlendMode.srcIn), + builder: (final context) => VectorGraphic( + width: size.width, + height: size.height, + colorFilter: ColorFilter.mode(color ?? Theme.of(context).colorScheme.primary, BlendMode.srcIn), + loader: AssetBytesLoader( + 'assets/app.svg.vec', + packageName: 'neon_$id', ), + semanticsLabel: AppLocalizations.of(context).nextcloudLogo, ), ); diff --git a/packages/neon/neon/lib/src/widgets/nextcloud_logo.dart b/packages/neon/neon/lib/src/widgets/nextcloud_logo.dart index bd11a90fb8f..c6324ca397d 100644 --- a/packages/neon/neon/lib/src/widgets/nextcloud_logo.dart +++ b/packages/neon/neon/lib/src/widgets/nextcloud_logo.dart @@ -1,6 +1,6 @@ import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/flutter_svg.dart'; import 'package:neon/l10n/localizations.dart'; +import 'package:vector_graphics/vector_graphics.dart'; class NextcloudLogo extends StatelessWidget { const NextcloudLogo({ @@ -8,11 +8,13 @@ class NextcloudLogo extends StatelessWidget { }); @override - Widget build(final BuildContext context) => SvgPicture.asset( - 'assets/logo_nextcloud.svg', - package: 'neon', + Widget build(final BuildContext context) => VectorGraphic( width: 100, height: 100, + loader: const AssetBytesLoader( + 'assets/logo_nextcloud.svg.vec', + packageName: 'neon', + ), semanticsLabel: AppLocalizations.of(context).nextcloudLogo, ); } diff --git a/packages/neon/neon_files/assets/app.svg b/packages/neon/neon_files/assets/app.svg deleted file mode 100644 index 7f84d1de9df..00000000000 --- a/packages/neon/neon_files/assets/app.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/neon/neon_files/assets/app.svg.vec b/packages/neon/neon_files/assets/app.svg.vec new file mode 100644 index 0000000000000000000000000000000000000000..51f4d00dd885b98968e705e3c47707d32d7e5790 GIT binary patch literal 208 zcmYe&?OyRW iVESRz9fz}LK - - - diff --git a/packages/neon/neon_news/assets/app.svg.vec b/packages/neon/neon_news/assets/app.svg.vec new file mode 100644 index 0000000000000000000000000000000000000000..b63e37c1516f150544208775011602d187c07329 GIT binary patch literal 628 zcmaKqtxf|`5QR_aW6+QW0|>$@^j^XPAW@`2p&A^>$|jf+%t|DpqF5A5Lkk-u-q%sq1#FJ+#u!ARoi+S97!~OHStx zBj^9?ye2*S+SS`@=-#bo4Q>*wraw-pP3U0uL9}gRM%F2OkhPv;*GOaYsQlPJa7sn+ z!g=z28M=w}_~DDyBvsR;Q(7f-P{IcbC%IY29DI$*LI(Mtesga(`~%xo#yY?h9BNqwe}9~ gozl!^@r`Cy_#iW9wvTn_n1c_pk2)25Hrf8IKeLXB-~a#s literal 0 HcmV?d00001 diff --git a/packages/neon/neon_news/pubspec.yaml b/packages/neon/neon_news/pubspec.yaml index 288afaf7385..330cb2b9755 100644 --- a/packages/neon/neon_news/pubspec.yaml +++ b/packages/neon/neon_news/pubspec.yaml @@ -31,6 +31,7 @@ dev_dependencies: git: url: https://github.com/nextcloud/neon path: packages/neon_lints + vector_graphics_compiler: ^1.1.7 flutter: uses-material-design: true diff --git a/packages/neon/neon_notes/assets/app.svg b/packages/neon/neon_notes/assets/app.svg deleted file mode 100644 index a7a15434bb6..00000000000 --- a/packages/neon/neon_notes/assets/app.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/neon/neon_notes/assets/app.svg.vec b/packages/neon/neon_notes/assets/app.svg.vec new file mode 100644 index 0000000000000000000000000000000000000000..d9dd7244e73697daf37778b11c5dd580f8d4d30a GIT binary patch literal 180 zcmYe&?O \ No newline at end of file diff --git a/packages/neon/neon_notifications/assets/app.svg.vec b/packages/neon/neon_notifications/assets/app.svg.vec new file mode 100644 index 0000000000000000000000000000000000000000..5bf968343113ba903cab8bdd7f9387a1fbed415a GIT binary patch literal 296 zcmYe&?O