refinements
This commit is contained in:
@@ -248,89 +248,121 @@ class _NoteFormScreenState extends State<NoteFormScreen> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// --- HEADER DEL POST-IT (Tavolozza + Azioni) ---
|
||||
Row(
|
||||
children: [
|
||||
// Tavolozza Colori
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 40,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: _noteColors.length,
|
||||
itemBuilder: (context, index) {
|
||||
final colorHex = _noteColors[index];
|
||||
final isSelected = _selectedColor == colorHex;
|
||||
final c = Color(
|
||||
int.parse(
|
||||
'FF${colorHex.replaceAll('#', '')}',
|
||||
radix: 16,
|
||||
),
|
||||
);
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
// 1. Capiamo quanto spazio reale ha la finestra in questo momento
|
||||
final isNarrow = constraints.maxWidth < 500;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() => _selectedColor = colorHex);
|
||||
_triggerAutoSave();
|
||||
},
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(right: 12),
|
||||
width: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: c,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: isSelected
|
||||
? Colors.black54
|
||||
: Colors.black12,
|
||||
width: isSelected ? 3 : 1,
|
||||
),
|
||||
// 2. Adattiamo la dimensione dei cerchi
|
||||
final double circleSize = isNarrow ? 32.0 : 40.0;
|
||||
|
||||
// -- PREPARIAMO IL BLOCCO COLORI --
|
||||
final colorPalette = SizedBox(
|
||||
height: circleSize,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: _noteColors.length,
|
||||
itemBuilder: (context, index) {
|
||||
final colorHex = _noteColors[index];
|
||||
final isSelected = _selectedColor == colorHex;
|
||||
final c = Color(
|
||||
int.parse(
|
||||
'FF${colorHex.replaceAll('#', '')}',
|
||||
radix: 16,
|
||||
),
|
||||
);
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() => _selectedColor = colorHex);
|
||||
_triggerAutoSave();
|
||||
},
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(right: 12),
|
||||
width: circleSize,
|
||||
decoration: BoxDecoration(
|
||||
color: c,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: isSelected
|
||||
? Colors.black54
|
||||
: Colors.black12,
|
||||
width: isSelected ? 3 : 1,
|
||||
),
|
||||
child: isSelected
|
||||
? const Icon(
|
||||
Icons.check,
|
||||
color: Colors.black54,
|
||||
size: 20,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
child: isSelected
|
||||
? Icon(
|
||||
Icons.check,
|
||||
color: Colors.black54,
|
||||
size: isNarrow ? 16 : 20,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
// -- PREPARIAMO IL BLOCCO AZIONI --
|
||||
final actionButtons = Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.delete_outline,
|
||||
color: Colors.black87,
|
||||
),
|
||||
tooltip: 'Elimina',
|
||||
onPressed: _deleteNote,
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
_isPinned
|
||||
? Icons.push_pin
|
||||
: Icons.push_pin_outlined,
|
||||
color: Colors.black87,
|
||||
),
|
||||
tooltip: _isPinned
|
||||
? 'Rimuovi in alto'
|
||||
: 'Fissa in alto',
|
||||
onPressed: () {
|
||||
setState(() => _isPinned = !_isPinned);
|
||||
_triggerAutoSave();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.ios_share,
|
||||
color: Colors.black87,
|
||||
),
|
||||
tooltip: 'Esporta',
|
||||
onPressed: _exportNote,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
// Azioni spostate dentro la nota!
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.delete_outline,
|
||||
color: Colors.black87,
|
||||
),
|
||||
tooltip: 'Elimina',
|
||||
onPressed: _deleteNote,
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
_isPinned ? Icons.push_pin : Icons.push_pin_outlined,
|
||||
color: Colors.black87,
|
||||
),
|
||||
tooltip: _isPinned
|
||||
? 'Rimuovi in alto'
|
||||
: 'Fissa in alto',
|
||||
onPressed: () {
|
||||
setState(() => _isPinned = !_isPinned);
|
||||
_triggerAutoSave();
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.ios_share,
|
||||
color: Colors.black87,
|
||||
),
|
||||
tooltip: 'Esporta',
|
||||
onPressed: _exportNote,
|
||||
),
|
||||
],
|
||||
// 3. DECIDIAMO IL LAYOUT FINALE IN BASE ALLO SPAZIO REALE
|
||||
if (isNarrow) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
actionButtons,
|
||||
|
||||
const SizedBox(height: 8),
|
||||
colorPalette,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// Layout "Largo" (Finestra intera)
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(child: colorPalette),
|
||||
const SizedBox(width: 16),
|
||||
actionButtons,
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user