diff --git a/packages/app/assets/logo.svg b/packages/app/assets/logo.svg deleted file mode 120000 index 4228c635..00000000 --- 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 00000000..081aa566 Binary files /dev/null and b/packages/app/assets/logo.svg.vec differ diff --git a/packages/app/lib/branding.dart b/packages/app/lib/branding.dart index 13382f2f..0a13a7cd 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 0cf02efd..362d763d 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 8c95f97a..060afa09 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 7910fc00..00000000 --- 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 00000000..af812c82 Binary files /dev/null and b/packages/neon/neon/assets/logo_nextcloud.svg.vec differ diff --git a/packages/neon/neon/lib/src/models/app_implementation.dart b/packages/neon/neon/lib/src/models/app_implementation.dart index 5051d0e6..7b0c628d 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 bd11a90f..c6324ca3 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 7f84d1de..00000000 --- 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 00000000..51f4d00d Binary files /dev/null and b/packages/neon/neon_files/assets/app.svg.vec differ diff --git a/packages/neon/neon_files/pubspec.yaml b/packages/neon/neon_files/pubspec.yaml index c090f568..1d6d4d6c 100644 --- a/packages/neon/neon_files/pubspec.yaml +++ b/packages/neon/neon_files/pubspec.yaml @@ -39,6 +39,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_news/assets/app.svg b/packages/neon/neon_news/assets/app.svg deleted file mode 100644 index c27cae23..00000000 --- a/packages/neon/neon_news/assets/app.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - 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 00000000..b63e37c1 Binary files /dev/null and b/packages/neon/neon_news/assets/app.svg.vec differ diff --git a/packages/neon/neon_news/pubspec.yaml b/packages/neon/neon_news/pubspec.yaml index 81199c8b..2f978b18 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 a7a15434..00000000 --- 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 00000000..d9dd7244 Binary files /dev/null and b/packages/neon/neon_notes/assets/app.svg.vec differ diff --git a/packages/neon/neon_notes/pubspec.yaml b/packages/neon/neon_notes/pubspec.yaml index f70f0e12..23a04f82 100644 --- a/packages/neon/neon_notes/pubspec.yaml +++ b/packages/neon/neon_notes/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_notifications/assets/app.svg b/packages/neon/neon_notifications/assets/app.svg deleted file mode 100644 index 51507f36..00000000 --- a/packages/neon/neon_notifications/assets/app.svg +++ /dev/null @@ -1 +0,0 @@ - \ 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 00000000..5bf96834 Binary files /dev/null and b/packages/neon/neon_notifications/assets/app.svg.vec differ diff --git a/packages/neon/neon_notifications/pubspec.yaml b/packages/neon/neon_notifications/pubspec.yaml index 2d80ae74..95239eee 100644 --- a/packages/neon/neon_notifications/pubspec.yaml +++ b/packages/neon/neon_notifications/pubspec.yaml @@ -25,6 +25,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/tool/generate-app.sh b/tool/generate-app.sh deleted file mode 100755 index afa487d4..00000000 --- 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 f82d3ae7..07d72075 100755 --- a/tool/generate-assets.sh +++ b/tool/generate-assets.sh @@ -4,5 +4,100 @@ 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 +} + +function precompile_assets() { + fvm dart run vector_graphics_compiler --input-dir assets/ + find assets/ -name "*.svg" -exec rm {} \; +} + wget https://raw.githubusercontent.com/Templarian/MaterialDesign/master/svg/cable-data.svg -O assets/logo.svg sed -i "s/