mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 17:11:14 +00:00
refactor(ui): Users screen cleanup
This commit is contained in:
parent
a0d76a2979
commit
adf8338be8
|
@ -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,
|
||||
|
|
|
@ -63,6 +63,7 @@ class NewSshKeyModal extends StatelessWidget {
|
|||
formFieldCubit: context.read<SshFormCubit>().key,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'ssh.input_label'.tr(),
|
||||
filled: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -25,9 +25,6 @@ class UsersPage extends StatelessWidget {
|
|||
is ServerInstallationFinished;
|
||||
Widget child;
|
||||
|
||||
final OutdatedServerCheckerState outdatedServerCheckerState =
|
||||
context.watch<OutdatedServerCheckerBloc>().state;
|
||||
|
||||
if (!isReady) {
|
||||
child = EmptyPagePlaceholder(
|
||||
showReadyCard: true,
|
||||
|
@ -38,6 +35,9 @@ class UsersPage extends StatelessWidget {
|
|||
} else {
|
||||
child = BlocBuilder<UsersBloc, UsersState>(
|
||||
builder: (final BuildContext context, final UsersState state) {
|
||||
final OutdatedServerCheckerState outdatedServerCheckerState =
|
||||
context.watch<OutdatedServerCheckerBloc>().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<UsersBloc>().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<UsersBloc>().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<UsersBloc>().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<UsersBloc>().refresh();
|
||||
},
|
||||
title: 'users.refresh_users'.tr(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue