From 542bb4265cf0d1da6774e1da10864acbe8092389 Mon Sep 17 00:00:00 2001 From: Giulia Date: Thu, 28 Sep 2023 13:57:51 +0200 Subject: [PATCH] create note --- lib/pages/CreateNewNote.dart | 1 - lib/pages/NotesView.dart | 77 ++++++------------------------------ 2 files changed, 11 insertions(+), 67 deletions(-) diff --git a/lib/pages/CreateNewNote.dart b/lib/pages/CreateNewNote.dart index 8e23b15..f0a8b8f 100644 --- a/lib/pages/CreateNewNote.dart +++ b/lib/pages/CreateNewNote.dart @@ -19,7 +19,6 @@ class _CreateNewNoteState extends State { super.dispose(); } - @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/pages/NotesView.dart b/lib/pages/NotesView.dart index f106c83..86595ab 100644 --- a/lib/pages/NotesView.dart +++ b/lib/pages/NotesView.dart @@ -1,22 +1,7 @@ -import 'dart:math'; import 'package:flutter/material.dart'; import 'CreateNewNote.dart'; import 'NoteDetailView.dart'; -class Note { - late String title; - late Map content; - late DateTime startDate; - late DateTime modifyDate; - - Note({ - required this.title, - required this.content, - required this.startDate, - required this.modifyDate, - }); -} - class NotesView extends StatefulWidget { const NotesView({Key? key}) : super(key: key); @@ -24,45 +9,15 @@ class NotesView extends StatefulWidget { State createState() => _NotesViewState(); } + class _NotesViewState extends State { - DateTime randomDate(DateTime start, DateTime end) { - final random = Random(); - final dayDifference = end.difference(start).inDays; - final randomDays = random.nextInt(dayDifference + 1); - return start.add(Duration(days: randomDays)); - } - - List generateRandomNotes(int count) { - final List titles = ["Nota 1", "Nota 2", "Nota 3", "Nota 4"]; - - final DateTime now = DateTime.now(); - - return List.generate(count, (index) { - final title = titles[index % titles.length]; - final content = { - 'Desc': 'Descrizione', - }; - final startDate = randomDate(DateTime(2023, 1, 1), now); - final modifyDate = randomDate(startDate, now); - - return Note( - title: title, - content: content, - startDate: startDate, - modifyDate: modifyDate, - ); - }); - } @override Widget build(BuildContext context) { - final List notes = generateRandomNotes(10); - - return Scaffold( appBar: AppBar( - title: Text('Note'), - backgroundColor: Colors.blue, + title: Text('Note', style: TextStyle(color: Colors.white),), + backgroundColor: Colors.lightBlue.shade900, ), floatingActionButton: FloatingActionButton( onPressed: () { @@ -72,31 +27,21 @@ class _NotesViewState extends State { ), ); }, - - child: Icon(Icons.add), - backgroundColor: Colors.blue, + child: Icon(Icons.add, color: Colors.white,), + backgroundColor: Colors.lightBlue.shade900, ), + + body: Container( - color: Colors.blue[50], child: ListView.builder( - itemCount: notes.length, + itemCount: 5, itemBuilder: (context, index) { - final note = notes[index]; return Card( color: Colors.white, - elevation: 2.0, - margin: EdgeInsets.all(8.0), + child: ListTile( - title: Text( - note.title, - style: TextStyle(color: Colors.blue, fontWeight: FontWeight.bold), - ), - subtitle: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('Descrizione della nota: ${notes.first.content}'), - ], - ), + title: Text("ciao", style: TextStyle(color: Colors.lightBlue.shade900, fontWeight: FontWeight.bold),), + subtitle: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [Text('Descrizione della nota:'),],), onTap: () { Navigator.of(context).push( MaterialPageRoute(