mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-09 17:39:42 +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 User user;
|
||||||
final bool isPrimaryUser;
|
final bool isPrimaryUser;
|
||||||
|
|
||||||
|
// TODO: Show user's display name and avatar when supported by backend
|
||||||
@override
|
@override
|
||||||
Widget build(final BuildContext context) => ListTile(
|
Widget build(final BuildContext context) => ListTile(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
@ -24,8 +26,10 @@ class UserListItem extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
trailing: isPrimaryUser
|
trailing: isPrimaryUser
|
||||||
? Icon(Icons.admin_panel_settings_outlined,
|
? Icon(
|
||||||
color: Theme.of(context).colorScheme.primary)
|
Icons.admin_panel_settings_outlined,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
)
|
||||||
: null,
|
: null,
|
||||||
title: Text(
|
title: Text(
|
||||||
user.login,
|
user.login,
|
||||||
|
|
|
@ -63,6 +63,7 @@ class NewSshKeyModal extends StatelessWidget {
|
||||||
formFieldCubit: context.read<SshFormCubit>().key,
|
formFieldCubit: context.read<SshFormCubit>().key,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'ssh.input_label'.tr(),
|
labelText: 'ssh.input_label'.tr(),
|
||||||
|
filled: true,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -54,6 +54,7 @@ class ResetPasswordModal extends StatelessWidget {
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
alignLabelWithHint: false,
|
alignLabelWithHint: false,
|
||||||
labelText: 'basis.password'.tr(),
|
labelText: 'basis.password'.tr(),
|
||||||
|
filled: true,
|
||||||
suffixIcon: Padding(
|
suffixIcon: Padding(
|
||||||
padding: const EdgeInsets.only(right: 8),
|
padding: const EdgeInsets.only(right: 8),
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
|
|
|
@ -25,9 +25,6 @@ class UsersPage extends StatelessWidget {
|
||||||
is ServerInstallationFinished;
|
is ServerInstallationFinished;
|
||||||
Widget child;
|
Widget child;
|
||||||
|
|
||||||
final OutdatedServerCheckerState outdatedServerCheckerState =
|
|
||||||
context.watch<OutdatedServerCheckerBloc>().state;
|
|
||||||
|
|
||||||
if (!isReady) {
|
if (!isReady) {
|
||||||
child = EmptyPagePlaceholder(
|
child = EmptyPagePlaceholder(
|
||||||
showReadyCard: true,
|
showReadyCard: true,
|
||||||
|
@ -38,6 +35,9 @@ class UsersPage extends StatelessWidget {
|
||||||
} else {
|
} else {
|
||||||
child = BlocBuilder<UsersBloc, UsersState>(
|
child = BlocBuilder<UsersBloc, UsersState>(
|
||||||
builder: (final BuildContext context, final UsersState state) {
|
builder: (final BuildContext context, final UsersState state) {
|
||||||
|
final OutdatedServerCheckerState outdatedServerCheckerState =
|
||||||
|
context.watch<OutdatedServerCheckerBloc>().state;
|
||||||
|
|
||||||
final users = state.orderedUsers;
|
final users = state.orderedUsers;
|
||||||
if (users.isEmpty) {
|
if (users.isEmpty) {
|
||||||
if (state is UsersRefreshing) {
|
if (state is UsersRefreshing) {
|
||||||
|
@ -45,33 +45,7 @@ class UsersPage extends StatelessWidget {
|
||||||
child: CircularProgressIndicator.adaptive(),
|
child: CircularProgressIndicator.adaptive(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return RefreshIndicator(
|
return const _UsersNotLoaded();
|
||||||
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 RefreshIndicator(
|
return RefreshIndicator(
|
||||||
onRefresh: () async {
|
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