selfprivacy.org.app/lib/ui/pages/users/user_details.dart

194 lines
7.3 KiB
Dart
Raw Normal View History

2021-01-06 17:35:57 +00:00
part of 'users.dart';
class _UserDetails extends StatelessWidget {
const _UserDetails({
2021-07-29 05:24:42 +00:00
required this.user,
2021-10-11 21:10:04 +00:00
required this.isRootUser,
2022-06-09 21:13:06 +00:00
});
2021-01-06 17:35:57 +00:00
2021-07-29 05:24:42 +00:00
final User user;
2021-10-11 21:10:04 +00:00
final bool isRootUser;
2021-01-06 17:35:57 +00:00
@override
Widget build(final BuildContext context) {
final ServerInstallationState config =
context.watch<ServerInstallationCubit>().state;
2021-03-18 00:55:38 +00:00
final String domainName = UiHelpers.getDomainName(config);
2021-03-18 00:55:38 +00:00
2021-06-20 21:08:52 +00:00
return BrandBottomSheet(
isExpended: true,
2021-01-06 17:35:57 +00:00
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
2021-06-20 21:08:52 +00:00
mainAxisSize: MainAxisSize.min,
2021-01-06 17:35:57 +00:00
children: [
Container(
height: 200,
decoration: BoxDecoration(
2021-07-29 05:24:42 +00:00
color: user.color,
2022-05-24 18:55:39 +00:00
borderRadius: const BorderRadius.vertical(
2021-01-06 17:35:57 +00:00
top: Radius.circular(20),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
2021-10-11 21:10:04 +00:00
if (!isRootUser)
Align(
alignment: Alignment.centerRight,
child: Padding(
2022-05-24 18:55:39 +00:00
padding: const EdgeInsets.symmetric(
2021-10-11 21:10:04 +00:00
vertical: 4,
horizontal: 2,
2021-01-06 17:35:57 +00:00
),
2021-10-11 21:10:04 +00:00
child: PopupMenuButton<PopupMenuItemType>(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
onSelected: (final PopupMenuItemType result) {
2021-10-11 21:10:04 +00:00
switch (result) {
case PopupMenuItemType.delete:
showDialog(
context: context,
builder: (final BuildContext context) =>
AlertDialog(
title: Text('basis.confirmation'.tr()),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text(
'users.delete_confirm_question'.tr(),
),
],
2021-01-06 17:35:57 +00:00
),
),
actions: <Widget>[
TextButton(
child: Text('basis.cancel'.tr()),
onPressed: () {
Navigator.of(context).pop();
},
),
TextButton(
child: Text(
'basis.delete'.tr(),
style: const TextStyle(
color: BrandColors.red1,
2021-01-06 17:35:57 +00:00
),
),
onPressed: () {
context
.read<JobsCubit>()
.addJob(DeleteUserJob(user: user));
Navigator.of(context)
..pop()
..pop();
},
),
],
),
2021-10-11 21:10:04 +00:00
);
break;
}
},
2022-05-24 18:55:39 +00:00
icon: const Icon(Icons.more_vert),
itemBuilder: (final BuildContext context) => [
2021-10-11 21:10:04 +00:00
PopupMenuItem<PopupMenuItemType>(
value: PopupMenuItemType.delete,
child: Container(
2022-05-24 18:55:39 +00:00
padding: const EdgeInsets.only(left: 5),
2021-10-11 21:10:04 +00:00
child: Text(
'basis.delete'.tr(),
2022-05-24 18:55:39 +00:00
style: const TextStyle(color: BrandColors.red1),
2021-10-11 21:10:04 +00:00
),
2021-01-06 17:35:57 +00:00
),
),
2021-10-11 21:10:04 +00:00
],
),
2021-01-06 17:35:57 +00:00
),
),
2022-05-24 18:55:39 +00:00
const Spacer(),
2021-01-06 17:35:57 +00:00
Padding(
padding: const EdgeInsets.symmetric(
vertical: 20,
horizontal: 15,
),
child: AutoSizeText(
user.login,
style: headline1Style,
softWrap: true,
minFontSize: 9,
maxLines: 3,
overflow: TextOverflow.ellipsis,
),
),
2021-01-06 17:35:57 +00:00
],
),
),
2022-05-24 18:55:39 +00:00
const SizedBox(height: 20),
2021-01-06 17:35:57 +00:00
Padding(
2021-05-25 21:53:54 +00:00
padding: paddingH15V0.copyWith(bottom: 20),
2021-01-06 17:35:57 +00:00
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
2021-03-18 00:55:38 +00:00
BrandText.small('users.account'.tr()),
2021-01-06 17:35:57 +00:00
Container(
height: 40,
alignment: Alignment.centerLeft,
2021-07-29 05:24:42 +00:00
child: BrandText.h4('${user.login}@$domainName'),
2021-01-06 17:35:57 +00:00
),
if (user.password != null)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
2022-05-24 18:55:39 +00:00
const SizedBox(height: 14),
BrandText.small('basis.password'.tr()),
Container(
height: 40,
alignment: Alignment.centerLeft,
child: BrandText.h4(user.password),
),
],
),
2022-05-24 18:55:39 +00:00
const SizedBox(height: 24),
const BrandDivider(),
const SizedBox(height: 20),
ListTile(
onTap: () {
Navigator.of(context)
.push(materialRoute(SshKeysPage(user: user)));
},
title: Text('ssh.title'.tr()),
subtitle: user.sshKeys.isNotEmpty
? Text(
'ssh.subtitle_with_keys'
.tr(args: [user.sshKeys.length.toString()]),
)
: Text('ssh.subtitle_without_keys'.tr()),
trailing: const Icon(BrandIcons.key),
),
2022-05-24 18:55:39 +00:00
const SizedBox(height: 20),
2022-03-23 14:07:52 +00:00
ListTile(
onTap: () {
Share.share(
'login: ${user.login}, password: ${user.password}',
);
2022-03-23 14:07:52 +00:00
},
title: Text(
'users.send_registration_data'.tr(),
),
2022-05-24 18:55:39 +00:00
trailing: const Icon(BrandIcons.share),
2022-03-23 14:07:52 +00:00
),
2021-01-06 17:35:57 +00:00
],
),
)
],
),
);
}
}
enum PopupMenuItemType {
2021-03-26 13:38:39 +00:00
// reset,
2021-01-06 17:35:57 +00:00
delete,
}