Browse Source

neon, neon_notifications: make AppImplementation.buildIcon a builder

pull/387/head
Nikolas Rimikis 1 year ago
parent
commit
6472214a57
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 2
      packages/neon/neon/lib/src/pages/home.dart
  2. 2
      packages/neon/neon/lib/src/pages/settings.dart
  3. 17
      packages/neon/neon/lib/src/utils/app_implementation.dart
  4. 1
      packages/neon/neon/lib/src/widgets/app_implementation_icon.dart
  5. 1
      packages/neon/neon_notifications/lib/pages/main.dart

2
packages/neon/neon/lib/src/pages/home.dart

@ -356,7 +356,7 @@ class _HomePageState extends State<HomePage> {
], ],
], ],
), ),
leading: appImplementation.buildIcon(context), leading: appImplementation.buildIcon(),
minLeadingWidth: 0, minLeadingWidth: 0,
onTap: () async { onTap: () async {
await _appsBloc.setActiveApp(appImplementation.id); await _appsBloc.setActiveApp(appImplementation.id);

2
packages/neon/neon/lib/src/pages/settings.dart

@ -78,7 +78,7 @@ class _SettingsPageState extends State<SettingsPage> {
for (final appImplementation in appImplementations) ...[ for (final appImplementation in appImplementations) ...[
if (appImplementation.options.options.isNotEmpty) ...[ if (appImplementation.options.options.isNotEmpty) ...[
CustomSettingsTile( CustomSettingsTile(
leading: appImplementation.buildIcon(context), leading: appImplementation.buildIcon(),
title: Text(appImplementation.name(context)), title: Text(appImplementation.name(context)),
onTap: () { onTap: () {
NextcloudAppSettingsRoute(appid: appImplementation.id).go(context); NextcloudAppSettingsRoute(appid: appImplementation.id).go(context);

17
packages/neon/neon/lib/src/utils/app_implementation.dart

@ -41,17 +41,18 @@ abstract class AppImplementation<T extends Bloc, R extends NextcloudAppSpecificO
Widget get page; Widget get page;
Widget buildIcon( Widget buildIcon({
final BuildContext context, {
final Size size = const Size.square(32), final Size size = const Size.square(32),
final Color? color, final Color? color,
}) => }) =>
SizedBox.fromSize( Builder(
size: size, builder: (final context) => SizedBox.fromSize(
child: SvgPicture.asset( size: size,
'assets/app.svg', child: SvgPicture.asset(
package: 'neon_$id', 'assets/app.svg',
colorFilter: ColorFilter.mode(color ?? Theme.of(context).colorScheme.primary, BlendMode.srcIn), package: 'neon_$id',
colorFilter: ColorFilter.mode(color ?? Theme.of(context).colorScheme.primary, BlendMode.srcIn),
),
), ),
); );

1
packages/neon/neon/lib/src/widgets/app_implementation_icon.dart

@ -24,7 +24,6 @@ class NeonAppImplementationIcon extends StatelessWidget {
Container( Container(
margin: const EdgeInsets.all(5), margin: const EdgeInsets.all(5),
child: appImplementation.buildIcon( child: appImplementation.buildIcon(
context,
size: size, size: size,
color: color, color: color,
), ),

1
packages/neon/neon_notifications/lib/pages/main.dart

@ -74,7 +74,6 @@ class _NotificationsMainPageState extends State<NotificationsMainPage> {
), ),
leading: app != null leading: app != null
? app.buildIcon( ? app.buildIcon(
context,
size: const Size.square(40), size: const Size.square(40),
) )
: SizedBox.fromSize( : SizedBox.fromSize(

Loading…
Cancel
Save