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

85 lines
3.1 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) {
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(
2021-01-14 20:45:10 +02:00
child: BlocProvider(
2021-03-15 17:39:44 +02:00
create: (context) =>
2021-06-21 00:08:52 +03:00
UserFormCubit(usersCubit: context.read<JobsCubit>()),
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,
2021-06-21 00:08:52 +03:00
mainAxisSize: MainAxisSize.min,
2021-01-14 20:45:10 +02:00
children: [
2021-03-18 02:55:38 +02:00
BrandHeader(
title: 'users.new_user'.tr(),
),
2021-01-14 20:45:10 +02:00
SizedBox(width: 14),
Padding(
2021-05-26 00:53:54 +03:00
padding: paddingH15V0,
2021-01-14 20:45:10 +02:00
child: Column(
2021-06-21 00:08:52 +03:00
mainAxisSize: MainAxisSize.min,
2021-01-14 20:45:10 +02:00
children: [
2021-06-21 00:08:52 +03:00
IntrinsicHeight(
child: CubitFormTextField(
formFieldCubit: context.read<UserFormCubit>().login,
decoration: InputDecoration(
labelText: 'users.login'.tr(),
suffixText: '@$domainName',
),
2021-01-14 20:45:10 +02:00
),
),
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,
2021-03-18 02:55:38 +02:00
labelText: 'basis.password'.tr(),
2021-01-14 20:45:10 +02:00
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-05-26 00:53:54 +03:00
text: 'basis.create'.tr(),
2021-01-14 20:45:10 +02:00
),
SizedBox(height: 40),
2021-03-18 02:55:38 +02:00
Text('users.new_user_info_note'.tr()),
2021-01-14 20:45:10 +02:00
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
),
);
}
}