From adf8338be8715fa1144a8aaffa8d8cf5dc366659 Mon Sep 17 00:00:00 2001 From: Inex Code Date: Tue, 12 Nov 2024 16:38:44 +0300 Subject: [PATCH] refactor(ui): Users screen cleanup --- .../molecules/list_items/user_list_item.dart | 8 ++- .../organisms/modals/new_ssh_key_modal.dart | 1 + .../modals/reset_password_modal.dart | 1 + lib/ui/pages/users/users.dart | 67 ++++++++++--------- 4 files changed, 45 insertions(+), 32 deletions(-) diff --git a/lib/ui/molecules/list_items/user_list_item.dart b/lib/ui/molecules/list_items/user_list_item.dart index be7e6abd..e4cf474d 100644 --- a/lib/ui/molecules/list_items/user_list_item.dart +++ b/lib/ui/molecules/list_items/user_list_item.dart @@ -12,6 +12,8 @@ class UserListItem extends StatelessWidget { final User user; final bool isPrimaryUser; + + // TODO: Show user's display name and avatar when supported by backend @override Widget build(final BuildContext context) => ListTile( onTap: () { @@ -24,8 +26,10 @@ class UserListItem extends StatelessWidget { ), ), trailing: isPrimaryUser - ? Icon(Icons.admin_panel_settings_outlined, - color: Theme.of(context).colorScheme.primary) + ? Icon( + Icons.admin_panel_settings_outlined, + color: Theme.of(context).colorScheme.primary, + ) : null, title: Text( user.login, diff --git a/lib/ui/organisms/modals/new_ssh_key_modal.dart b/lib/ui/organisms/modals/new_ssh_key_modal.dart index efdfb2ab..bb9a8278 100644 --- a/lib/ui/organisms/modals/new_ssh_key_modal.dart +++ b/lib/ui/organisms/modals/new_ssh_key_modal.dart @@ -63,6 +63,7 @@ class NewSshKeyModal extends StatelessWidget { formFieldCubit: context.read().key, decoration: InputDecoration( labelText: 'ssh.input_label'.tr(), + filled: true, ), ), ), diff --git a/lib/ui/organisms/modals/reset_password_modal.dart b/lib/ui/organisms/modals/reset_password_modal.dart index 2970c1be..60227b12 100644 --- a/lib/ui/organisms/modals/reset_password_modal.dart +++ b/lib/ui/organisms/modals/reset_password_modal.dart @@ -54,6 +54,7 @@ class ResetPasswordModal extends StatelessWidget { decoration: InputDecoration( alignLabelWithHint: false, labelText: 'basis.password'.tr(), + filled: true, suffixIcon: Padding( padding: const EdgeInsets.only(right: 8), child: IconButton( diff --git a/lib/ui/pages/users/users.dart b/lib/ui/pages/users/users.dart index 234d085b..132c1808 100644 --- a/lib/ui/pages/users/users.dart +++ b/lib/ui/pages/users/users.dart @@ -25,9 +25,6 @@ class UsersPage extends StatelessWidget { is ServerInstallationFinished; Widget child; - final OutdatedServerCheckerState outdatedServerCheckerState = - context.watch().state; - if (!isReady) { child = EmptyPagePlaceholder( showReadyCard: true, @@ -38,6 +35,9 @@ class UsersPage extends StatelessWidget { } else { child = BlocBuilder( builder: (final BuildContext context, final UsersState state) { + final OutdatedServerCheckerState outdatedServerCheckerState = + context.watch().state; + final users = state.orderedUsers; if (users.isEmpty) { if (state is UsersRefreshing) { @@ -45,33 +45,7 @@ class UsersPage extends StatelessWidget { child: CircularProgressIndicator.adaptive(), ); } - return RefreshIndicator( - onRefresh: () async { - await context.read().refresh(); - }, - child: Container( - padding: const EdgeInsets.symmetric(horizontal: 15), - child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - EmptyPagePlaceholder( - title: 'users.could_not_fetch_users'.tr(), - description: 'users.could_not_fetch_description'.tr(), - iconData: BrandIcons.users, - ), - const SizedBox(height: 18), - BrandOutlinedButton( - onPressed: () { - context.read().refresh(); - }, - title: 'users.refresh_users'.tr(), - ), - ], - ), - ), - ), - ); + return const _UsersNotLoaded(); } return RefreshIndicator( onRefresh: () async { @@ -140,3 +114,36 @@ class UsersPage extends StatelessWidget { ); } } + +class _UsersNotLoaded extends StatelessWidget { + const _UsersNotLoaded(); + + @override + Widget build(final BuildContext context) => RefreshIndicator( + onRefresh: () async { + await context.read().refresh(); + }, + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + EmptyPagePlaceholder( + title: 'users.could_not_fetch_users'.tr(), + description: 'users.could_not_fetch_description'.tr(), + iconData: BrandIcons.users, + ), + const SizedBox(height: 16), + BrandOutlinedButton( + onPressed: () { + context.read().refresh(); + }, + title: 'users.refresh_users'.tr(), + ), + ], + ), + ), + ), + ); +}