90 lines
2.8 KiB
Dart
90 lines
2.8 KiB
Dart
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),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|