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

81 lines
2.9 KiB
Dart
Raw Normal View History

2021-01-06 17:35:57 +00:00
part of 'users.dart';
2021-01-14 18:45:10 +00:00
class _NewUser extends StatelessWidget {
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-01-06 17:35:57 +00:00
return BrandModalSheet(
2021-01-14 18:45:10 +00:00
child: BlocProvider(
2021-03-15 15:39:44 +00:00
create: (context) =>
2021-03-26 13:38:39 +00:00
UserFormCubit(usersCubit: context.read<UsersCubit>()),
2021-01-14 18:45:10 +00:00
child: Builder(builder: (context) {
2021-03-15 15:39:44 +00:00
var formCubitState = context.watch<UserFormCubit>().state;
2021-01-14 18:45:10 +00:00
return BlocListener<UserFormCubit, FormCubitState>(
listener: (context, state) {
if (state.isSubmitted) {
Navigator.pop(context);
}
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
2021-03-18 00:55:38 +00:00
BrandHeader(
title: 'users.new_user'.tr(),
),
2021-01-14 18:45:10 +00:00
SizedBox(width: 14),
Padding(
padding: brandPagePadding2,
child: Column(
children: [
CubitFormTextField(
2021-03-15 15:39:44 +00:00
formFieldCubit: context.read<UserFormCubit>().login,
2021-01-14 18:45:10 +00:00
decoration: InputDecoration(
2021-03-18 00:55:38 +00:00
labelText: 'users.login'.tr(),
suffixText: '@$domainName',
2021-01-14 18:45:10 +00:00
),
),
SizedBox(height: 20),
CubitFormTextField(
2021-03-15 15:39:44 +00:00
formFieldCubit: context.read<UserFormCubit>().password,
2021-01-14 18:45:10 +00:00
decoration: InputDecoration(
alignLabelWithHint: false,
2021-03-18 00:55:38 +00:00
labelText: 'basis.password'.tr(),
2021-01-14 18:45:10 +00:00
suffixIcon: Padding(
padding: const EdgeInsets.only(right: 8),
child: IconButton(
icon: Icon(
BrandIcons.refresh,
color: BrandColors.blue,
),
2021-03-15 15:39:44 +00:00
onPressed:
context.read<UserFormCubit>().genNewPassword,
2021-01-14 18:45:10 +00:00
),
2021-01-06 17:35:57 +00:00
),
),
),
2021-01-14 18:45:10 +00:00
SizedBox(height: 30),
BrandButton.rised(
2021-03-15 15:39:44 +00:00
onPressed: formCubitState.isSubmitting
2021-01-14 18:45:10 +00:00
? null
2021-03-15 15:39:44 +00:00
: () => context.read<UserFormCubit>().trySubmit(),
2021-03-18 00:55:38 +00:00
title: 'basis.create'.tr(),
2021-01-14 18:45:10 +00:00
),
SizedBox(height: 40),
2021-03-18 00:55:38 +00:00
Text('users.new_user_info_note'.tr()),
2021-01-14 18:45:10 +00:00
SizedBox(height: 30),
],
2021-01-06 17:35:57 +00:00
),
2021-01-14 18:45:10 +00:00
),
],
2021-01-06 17:35:57 +00:00
),
2021-01-14 18:45:10 +00:00
);
}),
2021-01-06 17:35:57 +00:00
),
);
}
}