part of 'users.dart'; class NewUser extends StatelessWidget { const NewUser({super.key}); @override Widget build(final BuildContext context) { final ServerInstallationState config = context.watch().state; final String domainName = UiHelpers.getDomainName(config); return BrandBottomSheet( child: BlocProvider( create: (final BuildContext context) { final jobCubit = context.read(); final jobState = jobCubit.state; final users = []; users.addAll(context.read().state.users); if (jobState is JobsStateWithJobs) { final jobs = jobState.clientJobList; for (final job in jobs) { if (job is CreateUserJob) { users.add(job.user); } } } return UserFormCubit( jobsCubit: jobCubit, fieldFactory: FieldCubitFactory(context), ); }, child: Builder( builder: (final BuildContext context) { final FormCubitState formCubitState = context.watch().state; return BlocListener( listener: (final BuildContext context, final FormCubitState state) { if (state.isSubmitted) { Navigator.pop(context); } }, child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ BrandHeader( title: 'users.new_user'.tr(), ), const SizedBox(width: 14), Padding( padding: paddingH15V0, child: Column( mainAxisSize: MainAxisSize.min, children: [ if (formCubitState.isErrorShown) Text( 'users.username_rule'.tr(), style: TextStyle( color: Theme.of(context).colorScheme.error, ), ), const SizedBox(width: 14), IntrinsicHeight( child: CubitFormTextField( formFieldCubit: context.read().login, decoration: InputDecoration( labelText: 'users.login'.tr(), suffixText: '@$domainName', ), ), ), const SizedBox(height: 20), CubitFormTextField( formFieldCubit: context.read().password, decoration: InputDecoration( alignLabelWithHint: false, labelText: 'basis.password'.tr(), suffixIcon: Padding( padding: const EdgeInsets.only(right: 8), child: IconButton( icon: Icon( BrandIcons.refresh, color: Theme.of(context).colorScheme.secondary, ), onPressed: context .read() .genNewPassword, ), ), ), ), const SizedBox(height: 30), BrandButton.rised( onPressed: formCubitState.isSubmitting ? null : () => context.read().trySubmit(), text: 'basis.create'.tr(), ), const SizedBox(height: 40), Text('users.new_user_info_note'.tr()), const SizedBox(height: 30), ], ), ), ], ), ); }, ), ), ); } }