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

170 lines
6.2 KiB
Dart
Raw Normal View History

2021-01-06 19:35:57 +02:00
part of 'users.dart';
class _UserDetails extends StatelessWidget {
const _UserDetails({
2021-03-15 17:39:44 +02:00
Key? key,
2021-07-29 08:24:42 +03:00
required this.user,
2021-01-06 19:35:57 +02:00
}) : super(key: key);
2021-07-29 08:24:42 +03:00
final User user;
2021-01-06 19:35:57 +02:00
@override
Widget build(BuildContext context) {
2021-03-18 02:55:38 +02:00
var config = context.watch<AppConfigCubit>().state;
2021-03-26 15:38:39 +02:00
var domainName = UiHelpers.getDomainName(config);
2021-03-18 02:55:38 +02:00
2021-06-21 00:08:52 +03:00
return BrandBottomSheet(
isExpended: true,
2021-01-06 19:35:57 +02:00
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
2021-06-21 00:08:52 +03:00
mainAxisSize: MainAxisSize.min,
2021-01-06 19:35:57 +02:00
children: [
Container(
height: 200,
decoration: BoxDecoration(
2021-07-29 08:24:42 +03:00
color: user.color,
2021-01-06 19:35:57 +02:00
borderRadius: BorderRadius.vertical(
top: Radius.circular(20),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Align(
alignment: Alignment.centerRight,
child: Padding(
padding: EdgeInsets.symmetric(
vertical: 4,
horizontal: 2,
),
child: PopupMenuButton<PopupMenuItemType>(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
onSelected: (PopupMenuItemType result) {
switch (result) {
2021-03-26 15:38:39 +02:00
// case PopupMenuItemType.reset:
// break;
2021-01-06 19:35:57 +02:00
case PopupMenuItemType.delete:
showDialog(
2021-03-14 20:44:35 +02:00
context: context,
builder: (context) {
return AlertDialog(
2021-03-18 02:55:38 +02:00
title: Text('basis.confirmation'.tr()),
2021-01-06 19:35:57 +02:00
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
2021-03-18 02:55:38 +02:00
Text('users.delete_confirm_question'
.tr()),
2021-01-06 19:35:57 +02:00
],
),
),
actions: <Widget>[
TextButton(
2021-03-18 02:55:38 +02:00
child: Text('basis.cancel'.tr()),
2021-01-06 19:35:57 +02:00
onPressed: () {
Navigator.of(context)..pop();
},
),
TextButton(
child: Text(
2021-03-18 02:55:38 +02:00
'basis.delete'.tr(),
2021-01-06 19:35:57 +02:00
style: TextStyle(
color: BrandColors.red1,
),
),
onPressed: () {
2021-01-14 20:45:10 +02:00
context.read<UsersCubit>().remove(user);
2021-01-06 19:35:57 +02:00
Navigator.of(context)..pop()..pop();
},
),
],
2021-03-14 20:44:35 +02:00
);
},
);
2021-01-06 19:35:57 +02:00
break;
}
},
icon: Icon(Icons.more_vert),
itemBuilder: (BuildContext context) => [
2021-03-26 15:38:39 +02:00
// PopupMenuItem<PopupMenuItemType>(
// value: PopupMenuItemType.reset,
// child: Container(
// padding: EdgeInsets.only(left: 5),
// child: Text('users.reset_password'.tr()),
// ),
// ),
2021-01-06 19:35:57 +02:00
PopupMenuItem<PopupMenuItemType>(
value: PopupMenuItemType.delete,
child: Container(
padding: EdgeInsets.only(left: 5),
child: Text(
2021-03-18 02:55:38 +02:00
'basis.delete'.tr(),
2021-01-06 19:35:57 +02:00
style: TextStyle(color: BrandColors.red1),
),
),
),
],
),
),
),
Spacer(),
Padding(
padding: EdgeInsets.symmetric(
vertical: 20,
horizontal: 15,
),
child: BrandText.h1(
2021-07-29 08:24:42 +03:00
user.login,
2021-01-06 19:35:57 +02:00
softWrap: true,
overflow: TextOverflow.ellipsis,
)),
],
),
),
SizedBox(height: 20),
Padding(
2021-05-26 00:53:54 +03:00
padding: paddingH15V0.copyWith(bottom: 20),
2021-01-06 19:35:57 +02:00
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
2021-03-18 02:55:38 +02:00
BrandText.small('users.account'.tr()),
2021-01-06 19:35:57 +02:00
Container(
height: 40,
alignment: Alignment.centerLeft,
2021-07-29 08:24:42 +03:00
child: BrandText.h4('${user.login}@$domainName'),
2021-01-06 19:35:57 +02:00
),
SizedBox(height: 14),
2021-03-18 02:55:38 +02:00
BrandText.small('basis.password'.tr()),
2021-01-06 19:35:57 +02:00
Container(
height: 40,
alignment: Alignment.centerLeft,
2021-07-29 08:24:42 +03:00
child: BrandText.h4(user.password),
2021-01-06 19:35:57 +02:00
),
SizedBox(height: 24),
BrandDivider(),
SizedBox(height: 20),
2021-03-26 15:38:39 +02:00
BrandButton.emptyWithIconText(
2021-03-18 02:55:38 +02:00
title: 'users.send_regisration_data'.tr(),
2021-01-06 19:35:57 +02:00
icon: Icon(BrandIcons.share),
2021-07-29 08:24:42 +03:00
onPressed: () {
Share.share(
'login: ${user.login}, password: ${user.password}');
},
2021-01-06 19:35:57 +02:00
),
SizedBox(height: 20),
],
),
)
],
),
);
}
}
enum PopupMenuItemType {
2021-03-26 15:38:39 +02:00
// reset,
2021-01-06 19:35:57 +02:00
delete,
}