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

76 lines
2.9 KiB
Dart
Raw Normal View History

2021-01-06 19:35:57 +02:00
part of 'users.dart';
2021-01-14 20:45:10 +02:00
class _NewUser extends StatelessWidget {
2021-01-06 19:35:57 +02:00
@override
Widget build(BuildContext context) {
return BrandModalSheet(
2021-01-14 20:45:10 +02:00
child: BlocProvider(
2021-03-15 17:39:44 +02:00
create: (context) =>
UserFormCubit(usersCubit: context.watch<UsersCubit>()),
2021-01-14 20:45:10 +02:00
child: Builder(builder: (context) {
2021-03-15 17:39:44 +02:00
var formCubitState = context.watch<UserFormCubit>().state;
2021-01-14 20:45:10 +02:00
return BlocListener<UserFormCubit, FormCubitState>(
listener: (context, state) {
if (state.isSubmitted) {
Navigator.pop(context);
}
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
BrandHeader(title: 'Новый пользователь'),
SizedBox(width: 14),
Padding(
padding: brandPagePadding2,
child: Column(
children: [
CubitFormTextField(
2021-03-15 17:39:44 +02:00
formFieldCubit: context.read<UserFormCubit>().login,
2021-01-14 20:45:10 +02:00
decoration: InputDecoration(
labelText: 'Логин',
suffixText: '@example',
),
),
SizedBox(height: 20),
CubitFormTextField(
2021-03-15 17:39:44 +02:00
formFieldCubit: context.read<UserFormCubit>().password,
2021-01-14 20:45:10 +02:00
decoration: InputDecoration(
alignLabelWithHint: false,
labelText: 'Пароль',
suffixIcon: Padding(
padding: const EdgeInsets.only(right: 8),
child: IconButton(
icon: Icon(
BrandIcons.refresh,
color: BrandColors.blue,
),
2021-03-15 17:39:44 +02:00
onPressed:
context.read<UserFormCubit>().genNewPassword,
2021-01-14 20:45:10 +02:00
),
2021-01-06 19:35:57 +02:00
),
),
),
2021-01-14 20:45:10 +02:00
SizedBox(height: 30),
BrandButton.rised(
2021-03-15 17:39:44 +02:00
onPressed: formCubitState.isSubmitting
2021-01-14 20:45:10 +02:00
? null
2021-03-15 17:39:44 +02:00
: () => context.read<UserFormCubit>().trySubmit(),
2021-01-14 20:45:10 +02:00
title: 'Создать',
),
SizedBox(height: 40),
Text(
'Новый пользователь автоматически получит доступ ко всем сервисам. Ещё какое-то описание.'),
SizedBox(height: 30),
],
2021-01-06 19:35:57 +02:00
),
2021-01-14 20:45:10 +02:00
),
],
2021-01-06 19:35:57 +02:00
),
2021-01-14 20:45:10 +02:00
);
}),
2021-01-06 19:35:57 +02:00
),
);
}
}