From b6ffc8a36c641b0ab15eda499655264ecd272850 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Mon, 17 Apr 2023 15:54:51 +0200 Subject: [PATCH] neon,app: Add branding config --- .../{neon/neon => app}/assets/logo_neon.svg | 0 .../app/integration_test/screenshot_test.dart | 4 ++- packages/app/lib/branding.dart | 12 ++++++++ packages/app/lib/main.dart | 4 ++- packages/app/pubspec.lock | 2 +- packages/app/pubspec.yaml | 3 ++ packages/neon/neon/assets/LEGALESE.txt | 2 -- packages/neon/neon/lib/l10n/en.arb | 1 - .../neon/neon/lib/l10n/localizations.dart | 6 ---- .../neon/neon/lib/l10n/localizations_en.dart | 3 -- packages/neon/neon/lib/neon.dart | 8 ++++-- packages/neon/neon/lib/src/pages/login.dart | 9 +++++- .../neon/neon/lib/src/pages/settings.dart | 10 ++++--- .../neon/neon/lib/src/utils/branding.dart | 15 ++++++++++ .../neon/neon/lib/src/widgets/neon_logo.dart | 28 ------------------- 15 files changed, 57 insertions(+), 50 deletions(-) rename packages/{neon/neon => app}/assets/logo_neon.svg (100%) create mode 100644 packages/app/lib/branding.dart delete mode 100644 packages/neon/neon/assets/LEGALESE.txt create mode 100644 packages/neon/neon/lib/src/utils/branding.dart delete mode 100644 packages/neon/neon/lib/src/widgets/neon_logo.dart diff --git a/packages/neon/neon/assets/logo_neon.svg b/packages/app/assets/logo_neon.svg similarity index 100% rename from packages/neon/neon/assets/logo_neon.svg rename to packages/app/assets/logo_neon.svg diff --git a/packages/app/integration_test/screenshot_test.dart b/packages/app/integration_test/screenshot_test.dart index d7345ff5..ae18b993 100644 --- a/packages/app/integration_test/screenshot_test.dart +++ b/packages/app/integration_test/screenshot_test.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:app/apps.dart'; +import 'package:app/branding.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -92,8 +93,9 @@ Future runTestApp( final Account? account, }) async { await runNeon( - getAppImplementations: getAppImplementations, binding: binding, + getAppImplementations: getAppImplementations, + branding: getNeonBranding(), sharedPreferencesOverride: MemorySharedPreferences(), account: account, firstLaunchDisabled: true, diff --git a/packages/app/lib/branding.dart b/packages/app/lib/branding.dart new file mode 100644 index 00000000..fdf2c26a --- /dev/null +++ b/packages/app/lib/branding.dart @@ -0,0 +1,12 @@ +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:neon/neon.dart'; + +Branding getNeonBranding() => Branding( + name: 'Nextcloud Neon', + legalese: 'Copyright © 2023, provokateurin\nUnder GPLv3 license', + buildLogo: (final context, final size) => SvgPicture.asset( + 'assets/logo_neon.svg', + width: size.width, + height: size.height, + ), + ); diff --git a/packages/app/lib/main.dart b/packages/app/lib/main.dart index 3ae8a99c..6d3a21d3 100644 --- a/packages/app/lib/main.dart +++ b/packages/app/lib/main.dart @@ -1,10 +1,12 @@ import 'package:app/apps.dart'; +import 'package:app/branding.dart'; import 'package:flutter/material.dart'; import 'package:neon/neon.dart'; Future main() async { await runNeon( - getAppImplementations: getAppImplementations, binding: WidgetsFlutterBinding.ensureInitialized(), + getAppImplementations: getAppImplementations, + branding: getNeonBranding(), ); } diff --git a/packages/app/pubspec.lock b/packages/app/pubspec.lock index eef820a1..e8b0e269 100644 --- a/packages/app/pubspec.lock +++ b/packages/app/pubspec.lock @@ -256,7 +256,7 @@ packages: source: hosted version: "2.0.9" flutter_svg: - dependency: transitive + dependency: "direct main" description: name: flutter_svg sha256: "6ff9fa12892ae074092de2fa6a9938fb21dbabfdaa2ff57dc697ff912fc8d4b2" diff --git a/packages/app/pubspec.yaml b/packages/app/pubspec.yaml index 7c1340ef..dd6c33fd 100644 --- a/packages/app/pubspec.yaml +++ b/packages/app/pubspec.yaml @@ -10,6 +10,7 @@ dependencies: flutter: sdk: flutter flutter_native_splash: ^2.2.0+1 + flutter_svg: ^1.1.6 neon: path: ../neon/neon neon_files: @@ -35,3 +36,5 @@ dev_dependencies: flutter: uses-material-design: true + assets: + - assets/ diff --git a/packages/neon/neon/assets/LEGALESE.txt b/packages/neon/neon/assets/LEGALESE.txt deleted file mode 100644 index d29b0b5e..00000000 --- a/packages/neon/neon/assets/LEGALESE.txt +++ /dev/null @@ -1,2 +0,0 @@ -Copyright © 2022, provokateurin -Under GPLv3 license diff --git a/packages/neon/neon/lib/l10n/en.arb b/packages/neon/neon/lib/l10n/en.arb index 2d86b024..ac4613e4 100644 --- a/packages/neon/neon/lib/l10n/en.arb +++ b/packages/neon/neon/lib/l10n/en.arb @@ -1,6 +1,5 @@ { "@@locale": "en", - "appName": "Nextcloud Neon", "appImplementationName": "{app, select, core{Server} files{Files} news{News} notes{Notes} notifications{Notifications} other{}}", "@appImplementationName": { "placeholders": { diff --git a/packages/neon/neon/lib/l10n/localizations.dart b/packages/neon/neon/lib/l10n/localizations.dart index da1c6240..687138a2 100644 --- a/packages/neon/neon/lib/l10n/localizations.dart +++ b/packages/neon/neon/lib/l10n/localizations.dart @@ -89,12 +89,6 @@ abstract class AppLocalizations { /// A list of this localizations delegate's supported locales. static const List supportedLocales = [Locale('en')]; - /// No description provided for @appName. - /// - /// In en, this message translates to: - /// **'Nextcloud Neon'** - String get appName; - /// No description provided for @appImplementationName. /// /// In en, this message translates to: diff --git a/packages/neon/neon/lib/l10n/localizations_en.dart b/packages/neon/neon/lib/l10n/localizations_en.dart index d69ae1e7..7d88dcc1 100644 --- a/packages/neon/neon/lib/l10n/localizations_en.dart +++ b/packages/neon/neon/lib/l10n/localizations_en.dart @@ -6,9 +6,6 @@ import 'localizations.dart'; class AppLocalizationsEn extends AppLocalizations { AppLocalizationsEn([String locale = 'en']) : super(locale); - @override - String get appName => 'Nextcloud Neon'; - @override String appImplementationName(String app) { String _temp0 = intl.Intl.selectLogic( diff --git a/packages/neon/neon/lib/neon.dart b/packages/neon/neon/lib/neon.dart index becfc733..26ecc766 100644 --- a/packages/neon/neon/lib/neon.dart +++ b/packages/neon/neon/lib/neon.dart @@ -70,6 +70,7 @@ part 'src/platform/platform.dart'; part 'src/utils/account_options.dart'; part 'src/utils/app_implementation.dart'; part 'src/utils/bloc.dart'; +part 'src/utils/branding.dart'; part 'src/utils/confirmation_dialog.dart'; part 'src/utils/global.dart'; part 'src/utils/global_options.dart'; @@ -101,16 +102,16 @@ part 'src/widgets/exception.dart'; part 'src/widgets/image_wrapper.dart'; part 'src/widgets/linear_progress_indicator.dart'; part 'src/widgets/list_view.dart'; -part 'src/widgets/neon_logo.dart'; part 'src/widgets/nextcloud_logo.dart'; part 'src/widgets/relative_time.dart'; part 'src/widgets/result_builder.dart'; part 'src/widgets/text_settings_tile.dart'; Future runNeon({ + required final WidgetsBinding binding, required final List Function(SharedPreferences, RequestManager, NeonPlatform) getAppImplementations, - required final WidgetsBinding binding, + required final Branding branding, final SharedPreferences? sharedPreferencesOverride, final Account? account, final bool firstLaunchDisabled = false, @@ -195,6 +196,9 @@ Future runNeon({ Provider( create: (final _) => packageInfo, ), + Provider( + create: (final _) => branding, + ), ], child: NeonApp( accountsBloc: accountsBloc, diff --git a/packages/neon/neon/lib/src/pages/login.dart b/packages/neon/neon/lib/src/pages/login.dart index 248f0eb9..48a5ca66 100644 --- a/packages/neon/neon/lib/src/pages/login.dart +++ b/packages/neon/neon/lib/src/pages/login.dart @@ -172,7 +172,14 @@ class _LoginPageState extends State { height: MediaQuery.of(context).size.height / 2, child: Column( children: [ - const NeonLogo(), + Provider.of(context, listen: false).buildLogo( + context, + const Size(100, 100), + ), + Text( + Provider.of(context, listen: false).name, + style: Theme.of(context).textTheme.titleLarge, + ), const SizedBox( height: 30, ), diff --git a/packages/neon/neon/lib/src/pages/settings.dart b/packages/neon/neon/lib/src/pages/settings.dart index 6c9e58f8..09562527 100644 --- a/packages/neon/neon/lib/src/pages/settings.dart +++ b/packages/neon/neon/lib/src/pages/settings.dart @@ -218,13 +218,15 @@ class _SettingsPageState extends State { ), title: Text(AppLocalizations.of(context).licenses), onTap: () async { + final branding = Provider.of(context, listen: false); showLicensePage( context: context, - applicationName: AppLocalizations.of(context).appName, - applicationIcon: const NeonLogo( - withoutText: true, + applicationName: branding.name, + applicationIcon: branding.buildLogo( + context, + const Size(100, 100), ), - applicationLegalese: await rootBundle.loadString('assets/LEGALESE.txt'), + applicationLegalese: branding.legalese, applicationVersion: Provider.of(context, listen: false).version, ); }, diff --git a/packages/neon/neon/lib/src/utils/branding.dart b/packages/neon/neon/lib/src/utils/branding.dart new file mode 100644 index 00000000..38d3edfe --- /dev/null +++ b/packages/neon/neon/lib/src/utils/branding.dart @@ -0,0 +1,15 @@ +part of '../../neon.dart'; + +class Branding { + Branding({ + required this.name, + required this.buildLogo, + this.legalese, + }); + + final String name; + + final Widget Function(BuildContext, Size) buildLogo; + + final String? legalese; +} diff --git a/packages/neon/neon/lib/src/widgets/neon_logo.dart b/packages/neon/neon/lib/src/widgets/neon_logo.dart deleted file mode 100644 index a2bb5e30..00000000 --- a/packages/neon/neon/lib/src/widgets/neon_logo.dart +++ /dev/null @@ -1,28 +0,0 @@ -part of '../../neon.dart'; - -class NeonLogo extends StatelessWidget { - const NeonLogo({ - this.withoutText = false, - super.key, - }); - - final bool withoutText; - - @override - Widget build(final BuildContext context) => Column( - children: [ - SvgPicture.asset( - 'assets/logo_neon.svg', - package: 'neon', - width: 100, - height: 100, - ), - if (!withoutText) ...[ - Text( - AppLocalizations.of(context).appName, - style: Theme.of(context).textTheme.titleLarge, - ), - ], - ], - ); -}