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

177 lines
6.7 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-03-15 15:39:44 +00:00
Key? key,
2021-07-29 05:24:42 +00:00
required this.user,
2021-10-11 21:10:04 +00:00
required this.isRootUser,
2021-01-06 17:35:57 +00:00
}) : super(key: key);
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(BuildContext context) {
2021-03-18 00:55:38 +00:00
var config = context.watch<AppConfigCubit>().state;
2021-03-26 13:38:39 +00:00
var 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,
2021-01-06 17:35:57 +00:00
borderRadius: BorderRadius.vertical(
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(
padding: EdgeInsets.symmetric(
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: (PopupMenuItemType result) {
switch (result) {
case PopupMenuItemType.delete:
showDialog(
context: context,
builder: (context) {
return 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
),
2021-10-11 21:10:04 +00:00
actions: <Widget>[
TextButton(
child: Text('basis.cancel'.tr()),
onPressed: () {
Navigator.of(context)..pop();
},
),
TextButton(
child: Text(
'basis.delete'.tr(),
style: TextStyle(
color: BrandColors.red1,
),
2021-01-06 17:35:57 +00:00
),
2021-10-11 21:10:04 +00:00
onPressed: () {
context
.read<UsersCubit>()
.remove(user);
Navigator.of(context)
..pop()
..pop();
},
2021-01-06 17:35:57 +00:00
),
2021-10-11 21:10:04 +00:00
],
);
},
);
break;
}
},
icon: Icon(Icons.more_vert),
itemBuilder: (BuildContext context) => [
// PopupMenuItem<PopupMenuItemType>(
// value: PopupMenuItemType.reset,
// child: Container(
// padding: EdgeInsets.only(left: 5),
// child: Text('users.reset_password'.tr()),
// ),
// ),
PopupMenuItem<PopupMenuItemType>(
value: PopupMenuItemType.delete,
child: Container(
padding: EdgeInsets.only(left: 5),
child: Text(
'basis.delete'.tr(),
style: TextStyle(color: BrandColors.red1),
),
2021-01-06 17:35:57 +00:00
),
),
2021-10-11 21:10:04 +00:00
],
),
2021-01-06 17:35:57 +00:00
),
),
Spacer(),
Padding(
padding: EdgeInsets.symmetric(
vertical: 20,
horizontal: 15,
),
2021-09-29 18:28:47 +00:00
child: AutoSizeText(
2021-07-29 05:24:42 +00:00
user.login,
2021-09-29 18:28:47 +00:00
style: headline1Style,
2021-01-06 17:35:57 +00:00
softWrap: true,
2021-09-29 18:28:47 +00:00
minFontSize: 9,
maxLines: 3,
2021-01-06 17:35:57 +00:00
overflow: TextOverflow.ellipsis,
)),
],
),
),
SizedBox(height: 20),
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
),
SizedBox(height: 14),
2021-03-18 00:55:38 +00:00
BrandText.small('basis.password'.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.password),
2021-01-06 17:35:57 +00:00
),
SizedBox(height: 24),
BrandDivider(),
SizedBox(height: 20),
2021-03-26 13:38:39 +00:00
BrandButton.emptyWithIconText(
2021-03-18 00:55:38 +00:00
title: 'users.send_regisration_data'.tr(),
2021-01-06 17:35:57 +00:00
icon: Icon(BrandIcons.share),
2021-07-29 05:24:42 +00:00
onPressed: () {
Share.share(
'login: ${user.login}, password: ${user.password}');
},
2021-01-06 17:35:57 +00:00
),
SizedBox(height: 20),
],
),
)
],
),
);
}
}
enum PopupMenuItemType {
2021-03-26 13:38:39 +00:00
// reset,
2021-01-06 17:35:57 +00:00
delete,
}