From f51c4c195895c7c319a12bd1905539a198164508 Mon Sep 17 00:00:00 2001 From: simonmaggini Date: Fri, 29 Sep 2023 09:50:48 +0200 Subject: [PATCH] listViw builder --- lib/Components/Reminder.dart | 8 ++++++-- lib/model/promemoria.dart | 5 ++++- lib/pages/InboxView.dart | 4 ++-- lib/pages/TodayView.dart | 26 +++++++++++++++++++++----- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/lib/Components/Reminder.dart b/lib/Components/Reminder.dart index ac59dd5..25fcefd 100644 --- a/lib/Components/Reminder.dart +++ b/lib/Components/Reminder.dart @@ -1,10 +1,12 @@ import 'package:flutter/material.dart'; import '../Components/EditReminderButton.dart'; +import '../model/promemoria.dart'; import '../pages/EditReminder.dart'; class Reminder extends StatefulWidget { - const Reminder({super.key}); + final Promemoria? promemoria; + const Reminder(this.promemoria, {super.key}); @override State createState() => _ReminderState(); @@ -19,6 +21,8 @@ class _ReminderState extends State { }); } + + @override Widget build(BuildContext context) { return ListTile( @@ -26,7 +30,7 @@ class _ReminderState extends State { value: _value, onChanged: _onChanged, ), - title: Text("Reminder"), + title: Text(widget.promemoria?.description ?? 'Nessun titolo'), subtitle: Text(DateTime.now().toString()), onTap: () { Navigator.push( diff --git a/lib/model/promemoria.dart b/lib/model/promemoria.dart index 7061abf..c49590e 100644 --- a/lib/model/promemoria.dart +++ b/lib/model/promemoria.dart @@ -7,10 +7,13 @@ const String promemoriaTable = 'promemoria'; class Promemoria extends BaseEntity { static String expirationDate = ''; static String arrayPromemoria = ''; - static String description = ''; + String description = ''; static Priority priority = Priority.none; static Color color = Color.none; + Promemoria(String description){ + this.description = description; + } } diff --git a/lib/pages/InboxView.dart b/lib/pages/InboxView.dart index 62b429d..7f3e210 100644 --- a/lib/pages/InboxView.dart +++ b/lib/pages/InboxView.dart @@ -19,8 +19,8 @@ class _InboxViewState extends State { ), body: ListView( children: const [ - Reminder(), - Reminder(), + /* Reminder(), + Reminder(),*/ ], ) ); diff --git a/lib/pages/TodayView.dart b/lib/pages/TodayView.dart index ef53685..3180a07 100644 --- a/lib/pages/TodayView.dart +++ b/lib/pages/TodayView.dart @@ -16,6 +16,14 @@ class _TodayViewState extends State { var _selectedDate = DateTime.now(); + List listaPromemoria = [ + new Promemoria("Primo promemoria"), + new Promemoria("Secondo promemoria"), + new Promemoria("Terzo promemoria"), + ]; + + + @override Widget build(BuildContext context) { return Scaffold( @@ -33,11 +41,19 @@ class _TodayViewState extends State { ), ), body: ListView( - children: const [ - Reminder(), - Reminder(), - QuickReminder() - ], + children: [ + ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: listaPromemoria.length, + itemBuilder: (BuildContext context, int index){ + return Reminder( + listaPromemoria[index] + ); + }, + ), + QuickReminder(), + ], ), ); }