Sender Invitation
This commit is contained in:
89
frontend/pweb/lib/pages/invitations/widgets/form/fields.dart
Normal file
89
frontend/pweb/lib/pages/invitations/widgets/form/fields.dart
Normal file
@@ -0,0 +1,89 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pshared/models/permissions/descriptions/role.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class InvitationFormFields extends StatelessWidget {
|
||||
final List<RoleDescription> roles;
|
||||
final TextEditingController emailController;
|
||||
final TextEditingController nameController;
|
||||
final TextEditingController messageController;
|
||||
final String? selectedRoleRef;
|
||||
final ValueChanged<String?> onRoleChanged;
|
||||
|
||||
const InvitationFormFields({
|
||||
super.key,
|
||||
required this.roles,
|
||||
required this.emailController,
|
||||
required this.nameController,
|
||||
required this.messageController,
|
||||
required this.selectedRoleRef,
|
||||
required this.onRoleChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context)!;
|
||||
return Column(
|
||||
children: [
|
||||
Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 12,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 320,
|
||||
child: TextFormField(
|
||||
controller: emailController,
|
||||
decoration: InputDecoration(
|
||||
labelText: loc.invitationEmailLabel,
|
||||
prefixIcon: const Icon(Icons.alternate_email_outlined),
|
||||
),
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
validator: (value) => (value == null || value.trim().isEmpty)
|
||||
? loc.errorEmailMissing
|
||||
: null,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 280,
|
||||
child: TextFormField(
|
||||
controller: nameController,
|
||||
decoration: InputDecoration(
|
||||
labelText: loc.invitationNameLabel,
|
||||
prefixIcon: const Icon(Icons.person_outline),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 260,
|
||||
child: DropdownButtonFormField<String>(
|
||||
initialValue: selectedRoleRef ?? (roles.isNotEmpty ? roles.first.storable.id : null),
|
||||
items: roles.map((role) => DropdownMenuItem(
|
||||
value: role.storable.id,
|
||||
child: Text(role.describable.name),
|
||||
)).toList(),
|
||||
onChanged: roles.isEmpty ? null : onRoleChanged,
|
||||
decoration: InputDecoration(
|
||||
labelText: loc.invitationRoleLabel,
|
||||
prefixIcon: const Icon(Icons.security_outlined),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextFormField(
|
||||
controller: messageController,
|
||||
minLines: 2,
|
||||
maxLines: 3,
|
||||
decoration: InputDecoration(
|
||||
labelText: loc.invitationMessageLabel,
|
||||
prefixIcon: const Icon(Icons.chat_bubble_outline),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user