fixes
This commit is contained in:
@@ -134,73 +134,76 @@ class _NoteFormScreenState extends State<NoteFormScreen> {
|
||||
builder: (context) {
|
||||
return StatefulBuilder(
|
||||
builder: (context, setModalState) {
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Text(
|
||||
'Seleziona Collaboratori',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Text(
|
||||
'Seleziona Collaboratori',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: allStaff.length,
|
||||
itemBuilder: (context, index) {
|
||||
final staff = allStaff[index];
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: allStaff.length,
|
||||
itemBuilder: (context, index) {
|
||||
final staff = allStaff[index];
|
||||
|
||||
// Capiamo se questo membro dello staff è il creatore
|
||||
final isCreator = staff.id == creatorId;
|
||||
// È spuntato se è il creatore OPPURE se è nella lista dei collaboratori
|
||||
final isSelected =
|
||||
isCreator || _selectedStaffIds.contains(staff.id);
|
||||
// Capiamo se questo membro dello staff è il creatore
|
||||
final isCreator = staff.id == creatorId;
|
||||
// È spuntato se è il creatore OPPURE se è nella lista dei collaboratori
|
||||
final isSelected =
|
||||
isCreator || _selectedStaffIds.contains(staff.id);
|
||||
|
||||
return CheckboxListTile(
|
||||
title: RichText(
|
||||
text: TextSpan(
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
children: [
|
||||
TextSpan(text: staff.name),
|
||||
if (isCreator)
|
||||
const TextSpan(
|
||||
text: ' (Proprietario)',
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontStyle: FontStyle.italic,
|
||||
fontSize: 12,
|
||||
return CheckboxListTile(
|
||||
title: RichText(
|
||||
text: TextSpan(
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
children: [
|
||||
TextSpan(text: staff.name),
|
||||
if (isCreator)
|
||||
const TextSpan(
|
||||
text: ' (Proprietario)',
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontStyle: FontStyle.italic,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
value: isSelected,
|
||||
activeColor: Theme.of(context).colorScheme.primary,
|
||||
// IL TRUCCO NINJA: se è il creatore, passiamo null per disabilitare la spunta!
|
||||
onChanged: isCreator
|
||||
? null
|
||||
: (bool? value) {
|
||||
setModalState(() {
|
||||
if (value == true) {
|
||||
_selectedStaffIds.add(staff.id!);
|
||||
} else {
|
||||
_selectedStaffIds.remove(staff.id!);
|
||||
}
|
||||
});
|
||||
setState(() {});
|
||||
_triggerAutoSave();
|
||||
},
|
||||
);
|
||||
},
|
||||
value: isSelected,
|
||||
activeColor: Theme.of(context).colorScheme.primary,
|
||||
// IL TRUCCO NINJA: se è il creatore, passiamo null per disabilitare la spunta!
|
||||
onChanged: isCreator
|
||||
? null
|
||||
: (bool? value) {
|
||||
setModalState(() {
|
||||
if (value == true) {
|
||||
_selectedStaffIds.add(staff.id!);
|
||||
} else {
|
||||
_selectedStaffIds.remove(staff.id!);
|
||||
}
|
||||
});
|
||||
setState(() {});
|
||||
_triggerAutoSave();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: FilledButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Fatto'),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: FilledButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Fatto'),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -403,24 +406,27 @@ class _NoteFormScreenState extends State<NoteFormScreen> {
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// --- CONDIVISIONE ---
|
||||
SwitchListTile(
|
||||
title: const Text(
|
||||
'Condividi con tutti',
|
||||
style: TextStyle(
|
||||
color: Colors.black87,
|
||||
fontWeight: FontWeight.w500,
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: SwitchListTile(
|
||||
title: const Text(
|
||||
'Condividi con tutti',
|
||||
style: TextStyle(
|
||||
color: Colors.black87,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
value: _isSharedAll,
|
||||
activeThumbColor: Colors.black87,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onChanged: (val) {
|
||||
setState(() {
|
||||
_isSharedAll = val;
|
||||
if (val) _selectedStaffIds.clear();
|
||||
});
|
||||
_triggerAutoSave();
|
||||
},
|
||||
),
|
||||
value: _isSharedAll,
|
||||
activeThumbColor: Colors.black87,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onChanged: (val) {
|
||||
setState(() {
|
||||
_isSharedAll = val;
|
||||
if (val) _selectedStaffIds.clear();
|
||||
});
|
||||
_triggerAutoSave();
|
||||
},
|
||||
),
|
||||
|
||||
if (!_isSharedAll) ...[
|
||||
|
||||
Reference in New Issue
Block a user