This commit is contained in:
2026-05-23 11:08:39 +02:00
parent 361b61a694
commit 7a11e829b3
4 changed files with 86 additions and 64 deletions

View File

@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flux/core/routes/routes.dart';
import 'package:flux/core/theme/theme.dart';
import 'package:flux/features/notes/blocs/notes_bloc.dart';
import 'package:flux/features/notes/models/note_model.dart';
import 'package:go_router/go_router.dart'; // Supponendo tu usi GoRouter per la navigazione
@@ -9,66 +11,93 @@ class DashboardNotesWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Intestazione del riquadro
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Le mie Note',
style: Theme.of(
context,
).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.bold),
),
TextButton(
onPressed: () {
// Vai alla bacheca completa
context.push('/notes');
},
child: const Text('Vedi tutte'),
),
],
return Card(
elevation: 0,
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(
color: Theme.of(context).dividerColor.withValues(alpha: 0.3),
style: BorderStyle.solid,
),
const SizedBox(height: 12),
),
child: InkWell(
onTap: () => context.pushNamed(Routes.notes),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Intestazione del riquadro
Row(
children: [
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.yellow.shade700.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
),
child: Icon(
Icons.sticky_note_2_outlined,
size: 16,
color: Colors.yellow.shade700,
),
),
const SizedBox(width: 12),
Text(
'Le mie Note',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
color: context.primaryText,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
const SizedBox(height: 12),
// Il corpo del widget collegato al Bloc
BlocBuilder<NotesBloc, NotesState>(
builder: (context, state) {
if (state.status == NotesStatus.loading && state.notes.isEmpty) {
return const Center(child: CircularProgressIndicator());
}
// Il corpo del widget collegato al Bloc
BlocBuilder<NotesBloc, NotesState>(
builder: (context, state) {
if (state.status == NotesStatus.loading &&
state.notes.isEmpty) {
return const Center(child: CircularProgressIndicator());
}
if (state.status == NotesStatus.failure) {
return const Center(
child: Text(
'Errore nel caricamento delle note.',
style: TextStyle(color: Colors.red),
),
);
}
if (state.status == NotesStatus.failure) {
return const Center(
child: Text(
'Errore nel caricamento delle note.',
style: TextStyle(color: Colors.red),
),
);
}
if (state.notes.isEmpty) {
return _buildEmptyState(context);
}
if (state.notes.isEmpty) {
return _buildEmptyState(context);
}
// Prendiamo solo le prime 4 note per non intaccare troppo spazio in Dashboard
final displayNotes = state.notes.take(4).toList();
// Prendiamo solo le prime 4 note per non intaccare troppo spazio in Dashboard
final displayNotes = state.notes.take(4).toList();
return SizedBox(
height: 140, // Altezza fissa per lo scroll orizzontale
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: displayNotes.length,
itemBuilder: (context, index) {
return _buildMiniPostIt(context, displayNotes[index]);
return SizedBox(
height: 140, // Altezza fissa per lo scroll orizzontale
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: displayNotes.length,
itemBuilder: (context, index) {
return _buildMiniPostIt(context, displayNotes[index]);
},
),
);
},
),
);
},
],
),
),
],
),
);
}