Vue mobile add event OK
This commit is contained in:
@ -8,6 +8,7 @@ class OptionSelectorWidget extends StatefulWidget {
|
||||
final ValueChanged<List<Map<String, dynamic>>> onChanged;
|
||||
final void Function(String name)? onRemove;
|
||||
final bool eventTypeRequired;
|
||||
final bool isMobile;
|
||||
|
||||
const OptionSelectorWidget({
|
||||
super.key,
|
||||
@ -16,6 +17,7 @@ class OptionSelectorWidget extends StatefulWidget {
|
||||
required this.onChanged,
|
||||
this.onRemove,
|
||||
this.eventTypeRequired = false,
|
||||
this.isMobile = false,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -79,53 +81,56 @@ class _OptionSelectorWidgetState extends State<OptionSelectorWidget> {
|
||||
Text('Options sélectionnées',
|
||||
style: Theme.of(context).textTheme.titleMedium),
|
||||
const SizedBox(height: 8),
|
||||
Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 12,
|
||||
Column(
|
||||
children: widget.selectedOptions
|
||||
.map((opt) => SizedBox(
|
||||
width: 260,
|
||||
child: Card(
|
||||
elevation: 2,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(opt['name'] ?? '',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 4),
|
||||
Text(opt['details'] ?? '',
|
||||
style: const TextStyle(fontSize: 13)),
|
||||
const SizedBox(height: 4),
|
||||
Text('Prix : ${opt['price'] ?? ''} €',
|
||||
style: const TextStyle(fontSize: 13)),
|
||||
],
|
||||
),
|
||||
.map((opt) => Card(
|
||||
elevation: widget.isMobile ? 0 : 2,
|
||||
margin: EdgeInsets.symmetric(
|
||||
vertical: widget.isMobile ? 4 : 8,
|
||||
horizontal: widget.isMobile ? 0 : 8),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(widget.isMobile ? 8 : 12)),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(widget.isMobile ? 8.0 : 12.0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(opt['name'] ?? '',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold)),
|
||||
if (opt['details'] != null &&
|
||||
opt['details'] != '')
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 2.0),
|
||||
child: Text(opt['details'],
|
||||
style: const TextStyle(fontSize: 13)),
|
||||
),
|
||||
Text('Prix : ${opt['price'] ?? ''} €',
|
||||
style: const TextStyle(fontSize: 13)),
|
||||
],
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete),
|
||||
tooltip: 'Supprimer cette option',
|
||||
onPressed: () {
|
||||
if (widget.onRemove != null) {
|
||||
widget.onRemove!(opt['name'] as String);
|
||||
} else {
|
||||
final newList =
|
||||
List<Map<String, dynamic>>.from(
|
||||
widget.selectedOptions)
|
||||
..removeWhere(
|
||||
(o) => o['name'] == opt['name']);
|
||||
widget.onChanged(newList);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete),
|
||||
tooltip: 'Supprimer cette option',
|
||||
onPressed: () {
|
||||
if (widget.onRemove != null) {
|
||||
widget.onRemove!(opt['name'] as String);
|
||||
} else {
|
||||
final newList = List<Map<String, dynamic>>.from(
|
||||
widget.selectedOptions)
|
||||
..removeWhere(
|
||||
(o) => o['name'] == opt['name']);
|
||||
widget.onChanged(newList);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
))
|
||||
|
Reference in New Issue
Block a user