From adfd198be7a3f0a0acd141ce56a5ed9ebfbf454f Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Wed, 12 Jul 2023 20:07:14 +0200 Subject: [PATCH] neon: better utilize theme --- packages/neon/neon/lib/src/pages/login.dart | 1 - .../lib/src/settings/widgets/settings_list.dart | 1 - packages/neon/neon/lib/src/theme/colors.dart | 13 +++++++++++++ packages/neon/neon/lib/src/theme/theme.dart | 5 +++++ packages/neon/neon/lib/src/widgets/list_view.dart | 1 - packages/neon/neon/lib/src/widgets/user_avatar.dart | 10 ++-------- packages/neon/neon_files/lib/pages/details.dart | 1 - 7 files changed, 20 insertions(+), 12 deletions(-) diff --git a/packages/neon/neon/lib/src/pages/login.dart b/packages/neon/neon/lib/src/pages/login.dart index f3f6da58..48e95e7d 100644 --- a/packages/neon/neon/lib/src/pages/login.dart +++ b/packages/neon/neon/lib/src/pages/login.dart @@ -61,7 +61,6 @@ class _LoginPageState extends State { child: ConstrainedBox( constraints: NeonDialogTheme.of(context).constraints, child: Scrollbar( - interactive: true, child: SingleChildScrollView( padding: const EdgeInsets.symmetric(vertical: 40, horizontal: 20), primary: true, diff --git a/packages/neon/neon/lib/src/settings/widgets/settings_list.dart b/packages/neon/neon/lib/src/settings/widgets/settings_list.dart index dd0c6c7f..cc69d2ff 100644 --- a/packages/neon/neon/lib/src/settings/widgets/settings_list.dart +++ b/packages/neon/neon/lib/src/settings/widgets/settings_list.dart @@ -14,7 +14,6 @@ class SettingsList extends StatelessWidget { @override Widget build(final BuildContext context) => Scrollbar( - interactive: true, child: ListView( primary: true, padding: const EdgeInsets.all(20), diff --git a/packages/neon/neon/lib/src/theme/colors.dart b/packages/neon/neon/lib/src/theme/colors.dart index 97f7e5ff..40ec0da2 100644 --- a/packages/neon/neon/lib/src/theme/colors.dart +++ b/packages/neon/neon/lib/src/theme/colors.dart @@ -1,5 +1,8 @@ import 'package:flutter/material.dart'; +import 'package:meta/meta.dart'; +import 'package:nextcloud/nextcloud.dart'; + /// [Color] constants which represent Nextcloud's /// [color palette](https://docs.nextcloud.com/server/latest/developer_manual/design/foundations.html#color). abstract final class NcColors { @@ -14,3 +17,13 @@ abstract final class NcColors { /// This color is only used at the users discretion. static const Color oledBackground = Colors.black; } + +@internal +extension UserStatusTypeColors on UserStatusType { + Color? get color => switch (this) { + UserStatusType.online => const Color(0xFF49B382), + UserStatusType.away => const Color(0xFFF4A331), + UserStatusType.dnd => const Color(0xFFED484C), + _ => null, + }; +} diff --git a/packages/neon/neon/lib/src/theme/theme.dart b/packages/neon/neon/lib/src/theme/theme.dart index 01440700..2f9aa685 100644 --- a/packages/neon/neon/lib/src/theme/theme.dart +++ b/packages/neon/neon/lib/src/theme/theme.dart @@ -47,6 +47,7 @@ class AppTheme { cardColor: colorScheme.background, // For LicensePage snackBarTheme: _snackBarTheme, dividerTheme: _dividerTheme, + scrollbarTheme: _scrollbarTheme, extensions: [ neonTheme, ...?appThemes, @@ -65,4 +66,8 @@ class AppTheme { thickness: 1.5, space: 30, ); + + static const _scrollbarTheme = ScrollbarThemeData( + interactive: true, + ); } diff --git a/packages/neon/neon/lib/src/widgets/list_view.dart b/packages/neon/neon/lib/src/widgets/list_view.dart index 65adec54..62025757 100644 --- a/packages/neon/neon/lib/src/widgets/list_view.dart +++ b/packages/neon/neon/lib/src/widgets/list_view.dart @@ -41,7 +41,6 @@ class NeonListView extends StatelessWidget { ), Expanded( child: Scrollbar( - interactive: true, child: ListView( primary: true, key: scrollKey != null ? PageStorageKey(scrollKey!) : null, diff --git a/packages/neon/neon/lib/src/widgets/user_avatar.dart b/packages/neon/neon/lib/src/widgets/user_avatar.dart index 55285bb9..69964f19 100644 --- a/packages/neon/neon/lib/src/widgets/user_avatar.dart +++ b/packages/neon/neon/lib/src/widgets/user_avatar.dart @@ -8,6 +8,7 @@ import 'package:neon/src/bloc/result.dart'; import 'package:neon/src/bloc/result_builder.dart'; import 'package:neon/src/blocs/accounts.dart'; import 'package:neon/src/models/account.dart'; +import 'package:neon/src/theme/colors.dart'; import 'package:neon/src/widgets/cached_image.dart'; import 'package:nextcloud/nextcloud.dart'; import 'package:provider/provider.dart'; @@ -119,7 +120,7 @@ class _UserAvatarState extends State { } else if (result.hasData) { decoration = BoxDecoration( shape: BoxShape.circle, - color: _userStatusToColor(result.data!.status), + color: result.data!.status.color, ); } @@ -136,11 +137,4 @@ class _UserAvatarState extends State { ), ); } - - Color? _userStatusToColor(final UserStatusType userStatusType) => switch (userStatusType) { - UserStatusType.online => const Color(0xFF49B382), - UserStatusType.away => const Color(0xFFF4A331), - UserStatusType.dnd => const Color(0xFFED484C), - _ => null, - }; } diff --git a/packages/neon/neon_files/lib/pages/details.dart b/packages/neon/neon_files/lib/pages/details.dart index eeb44e80..f51f87b6 100644 --- a/packages/neon/neon_files/lib/pages/details.dart +++ b/packages/neon/neon_files/lib/pages/details.dart @@ -17,7 +17,6 @@ class FilesDetailsPage extends StatelessWidget { title: Text(details.name), ), body: Scrollbar( - interactive: true, child: ListView( primary: true, children: [