From 58e013a709ae0dc93ffc7a56e171c1ca1f1f8cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20Ku=CC=88ng?= Date: Wed, 27 Sep 2023 13:43:04 +0200 Subject: [PATCH 01/19] database --- lib/database/database.dart | 36 ++++++++++++++++++++++++++++++++++++ lib/database/promemoria.dart | 9 ++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 lib/database/database.dart diff --git a/lib/database/database.dart b/lib/database/database.dart new file mode 100644 index 0000000..4a68ed8 --- /dev/null +++ b/lib/database/database.dart @@ -0,0 +1,36 @@ + +import 'package:progetto_m335_flutter/model/note.dart'; + +class Database{ + static final Database _instance = Database._init(); + static Database? _database; + + Database._init(); + + Future get database async { + if (_database != null) return _database!; + _database = await _initDB('database.db'); + return _database!; + } + + Future _createDB(Database database) async{ + const integerPrimaryKeyAutoincrement = 'INTEGER PRIMARY KEY AUTOINCREMENT'; + const textNotNull = 'TEXT NOT NULL'; + const integerNotNull = 'INTEGER NOT NULL'; + const integer = 'INTEGER'; + const real = 'REAL'; + const text = 'TEXT'; + + + await database.execute(''' + CREATE TABLE $Note ( + ${Note.id} $integerPrimaryKeyAutoincrement, + + ) + '''); + } + + execute(String s) { + + } +} \ No newline at end of file diff --git a/lib/database/promemoria.dart b/lib/database/promemoria.dart index baa8ddd..66c8d27 100644 --- a/lib/database/promemoria.dart +++ b/lib/database/promemoria.dart @@ -1,11 +1,18 @@ +import 'dart:ui'; + import 'base_entity.dart'; import 'identifiers/enum/priority.dart'; +import 'identifiers/enum/color.dart'; class Note extends BaseEntity{ static String id = BaseEntity.getId; static String title = BaseEntity.getTitle; static String creationDate = BaseEntity.getCreationDate; + static String expirationDate = 'expirationDate'; - Priority priority = Priority.low; + static String description = 'description'; + Priority priority = Priority.none; + Color color = Color.none; + } From ecf7011302f391b9facd0d8e7c46d7f23c19d294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20Ku=CC=88ng?= Date: Wed, 27 Sep 2023 13:50:56 +0200 Subject: [PATCH 02/19] new directory --- lib/database/database.dart | 1 + lib/{database => model}/base_entity.dart | 0 lib/{database => model}/identifiers/enum/color.dart | 0 lib/{database => model}/identifiers/enum/priority.dart | 0 lib/{database => model}/identifiers/tag.dart | 0 lib/{database => model}/note.dart | 0 lib/{database => model}/promemoria.dart | 2 +- test/widget_test.dart | 2 +- 8 files changed, 3 insertions(+), 2 deletions(-) rename lib/{database => model}/base_entity.dart (100%) rename lib/{database => model}/identifiers/enum/color.dart (100%) rename lib/{database => model}/identifiers/enum/priority.dart (100%) rename lib/{database => model}/identifiers/tag.dart (100%) rename lib/{database => model}/note.dart (100%) rename lib/{database => model}/promemoria.dart (100%) diff --git a/lib/database/database.dart b/lib/database/database.dart index 4a68ed8..10474b8 100644 --- a/lib/database/database.dart +++ b/lib/database/database.dart @@ -10,6 +10,7 @@ class Database{ Future get database async { if (_database != null) return _database!; _database = await _initDB('database.db'); + return _database!; } diff --git a/lib/database/base_entity.dart b/lib/model/base_entity.dart similarity index 100% rename from lib/database/base_entity.dart rename to lib/model/base_entity.dart diff --git a/lib/database/identifiers/enum/color.dart b/lib/model/identifiers/enum/color.dart similarity index 100% rename from lib/database/identifiers/enum/color.dart rename to lib/model/identifiers/enum/color.dart diff --git a/lib/database/identifiers/enum/priority.dart b/lib/model/identifiers/enum/priority.dart similarity index 100% rename from lib/database/identifiers/enum/priority.dart rename to lib/model/identifiers/enum/priority.dart diff --git a/lib/database/identifiers/tag.dart b/lib/model/identifiers/tag.dart similarity index 100% rename from lib/database/identifiers/tag.dart rename to lib/model/identifiers/tag.dart diff --git a/lib/database/note.dart b/lib/model/note.dart similarity index 100% rename from lib/database/note.dart rename to lib/model/note.dart diff --git a/lib/database/promemoria.dart b/lib/model/promemoria.dart similarity index 100% rename from lib/database/promemoria.dart rename to lib/model/promemoria.dart index 66c8d27..4838317 100644 --- a/lib/database/promemoria.dart +++ b/lib/model/promemoria.dart @@ -1,8 +1,8 @@ import 'dart:ui'; import 'base_entity.dart'; -import 'identifiers/enum/priority.dart'; import 'identifiers/enum/color.dart'; +import 'identifiers/enum/priority.dart'; class Note extends BaseEntity{ static String id = BaseEntity.getId; diff --git a/test/widget_test.dart b/test/widget_test.dart index 5e5d15e..bb5dffa 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:progetto_m335_flutter/main.dart'; +import 'package:progetto_m335_flutter/myApp.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { From c35684c8f15bf1c43182e22fbdf9cb2d7bbaca12 Mon Sep 17 00:00:00 2001 From: Tito Arrigo Date: Wed, 27 Sep 2023 14:02:53 +0200 Subject: [PATCH 03/19] inizzializazione pagine --- lib/navigation.dart | 11 +++++++---- lib/pages/InboxView.dart | 19 +++++++++++++++++++ lib/pages/NoteDetailView.dart | 19 +++++++++++++++++++ lib/pages/NotesView.dart | 19 +++++++++++++++++++ lib/pages/TodayView.dart | 19 +++++++++++++++++++ lib/{ => pages}/testUI.dart | 0 6 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 lib/pages/InboxView.dart create mode 100644 lib/pages/NoteDetailView.dart create mode 100644 lib/pages/NotesView.dart create mode 100644 lib/pages/TodayView.dart rename lib/{ => pages}/testUI.dart (100%) diff --git a/lib/navigation.dart b/lib/navigation.dart index ac724e9..180a383 100644 --- a/lib/navigation.dart +++ b/lib/navigation.dart @@ -1,7 +1,10 @@ import 'dart:ffi'; import 'package:flutter/material.dart'; -import 'testUI.dart'; +import 'pages/testUI.dart'; +import 'pages/TodayView.dart'; +import 'pages/InboxView.dart'; +import 'pages/NotesView.dart'; class Navigation extends StatefulWidget { const Navigation({super.key}); @@ -14,9 +17,9 @@ class _NavigationState extends State { int _selectedIndex = 0; static const List _widgetOptions = [ - TestUI(), - Text("Inbox"), - Text("Notes"), + TodayView(), + InboxView(), + NotesView(), ]; void _onItemTapped(int index) { diff --git a/lib/pages/InboxView.dart b/lib/pages/InboxView.dart new file mode 100644 index 0000000..4d40bd7 --- /dev/null +++ b/lib/pages/InboxView.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +class InboxView extends StatefulWidget { + const InboxView({super.key}); + + @override + State createState() => _InboxViewState(); +} + +class _InboxViewState extends State { + @override + Widget build(BuildContext context) { + return const Scaffold( + body: Center( + child: Icon(Icons.inbox), + ) + ); + } +} diff --git a/lib/pages/NoteDetailView.dart b/lib/pages/NoteDetailView.dart new file mode 100644 index 0000000..a9802da --- /dev/null +++ b/lib/pages/NoteDetailView.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +class NoteDetailView extends StatefulWidget { + const NoteDetailView({super.key}); + + @override + State createState() => _NoteDetailViewState(); +} + +class _NoteDetailViewState extends State { + @override + Widget build(BuildContext context) { + return const Scaffold( + body: Center( + child: Text('NoteDetailView'), + ) + ); + } +} diff --git a/lib/pages/NotesView.dart b/lib/pages/NotesView.dart new file mode 100644 index 0000000..b0d7c4b --- /dev/null +++ b/lib/pages/NotesView.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +class NotesView extends StatefulWidget { + const NotesView({super.key}); + + @override + State createState() => _NotesViewState(); +} + +class _NotesViewState extends State { + @override + Widget build(BuildContext context) { + return const Scaffold( + body: Center( + child: Icon(Icons.note), + ) + ); + } +} diff --git a/lib/pages/TodayView.dart b/lib/pages/TodayView.dart new file mode 100644 index 0000000..cad5346 --- /dev/null +++ b/lib/pages/TodayView.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +class TodayView extends StatefulWidget { + const TodayView({super.key}); + + @override + State createState() => _TodayViewState(); +} + +class _TodayViewState extends State { + @override + Widget build(BuildContext context) { + return const Scaffold( + body: Center( + child: Icon(Icons.calendar_today) + ) + ); + } +} diff --git a/lib/testUI.dart b/lib/pages/testUI.dart similarity index 100% rename from lib/testUI.dart rename to lib/pages/testUI.dart From 9f26bc8595be3cacf5e8f415c2e993ba40214c4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20Ku=CC=88ng?= Date: Wed, 27 Sep 2023 15:17:16 +0200 Subject: [PATCH 04/19] note entity --- lib/model/note.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/model/note.dart b/lib/model/note.dart index ece0167..9d13582 100644 --- a/lib/model/note.dart +++ b/lib/model/note.dart @@ -1,8 +1,9 @@ import 'base_entity.dart'; -class Note extends BaseEntity{ +class Note extends BaseEntity { static String id = BaseEntity.getId; - static String Title = BaseEntity.getTitle; - static String CreationDate = BaseEntity.getCreationDate; - -} \ No newline at end of file + static String title = BaseEntity.getTitle; + static String creationDate = BaseEntity.getCreationDate; + static String lastModificationDate = "LastModificationDate"; + static String description = ""; +} From 05386ac20f434af1bc142bc8edfd8449905bea22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20Ku=CC=88ng?= Date: Thu, 28 Sep 2023 08:47:50 +0200 Subject: [PATCH 05/19] entity --- lib/model/note.dart | 6 ++++-- lib/model/promemoria.dart | 15 ++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/model/note.dart b/lib/model/note.dart index 9d13582..df6bed2 100644 --- a/lib/model/note.dart +++ b/lib/model/note.dart @@ -1,9 +1,11 @@ import 'base_entity.dart'; +const String noteTable = 'note'; + class Note extends BaseEntity { static String id = BaseEntity.getId; static String title = BaseEntity.getTitle; static String creationDate = BaseEntity.getCreationDate; - static String lastModificationDate = "LastModificationDate"; - static String description = ""; + static String lastModificationDate = BaseEntity.getLastEditDate; + static String description = ''; } diff --git a/lib/model/promemoria.dart b/lib/model/promemoria.dart index 4838317..32f4ebc 100644 --- a/lib/model/promemoria.dart +++ b/lib/model/promemoria.dart @@ -4,15 +4,20 @@ import 'base_entity.dart'; import 'identifiers/enum/color.dart'; import 'identifiers/enum/priority.dart'; -class Note extends BaseEntity{ +const String promemoriaTable = 'promemoria'; + +class Promemoria extends BaseEntity{ static String id = BaseEntity.getId; static String title = BaseEntity.getTitle; static String creationDate = BaseEntity.getCreationDate; + static String lastModificationDate = BaseEntity.getLastEditDate; + static String expirationDate = ''; + static String description = ''; + + static Priority priority = Priority.none; + static Color color = Color.none; + - static String expirationDate = 'expirationDate'; - static String description = 'description'; - Priority priority = Priority.none; - Color color = Color.none; } From 2f851bc630b0740bf08a8f3e2c17ff8a32546e85 Mon Sep 17 00:00:00 2001 From: lama137 <99168742+lama137@users.noreply.github.com> Date: Thu, 28 Sep 2023 09:02:52 +0200 Subject: [PATCH 06/19] IDK --- lib/database/database.dart | 6 ------ lib/main.dart | 4 ++-- lib/model/note.dart | 3 +++ lib/navigation.dart | 2 -- lib/pages/InboxView.dart | 14 ++++++++++---- lib/pages/NotesView.dart | 4 +++- test/widget_test.dart | 3 +-- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/lib/database/database.dart b/lib/database/database.dart index 10474b8..2f81885 100644 --- a/lib/database/database.dart +++ b/lib/database/database.dart @@ -7,12 +7,6 @@ class Database{ Database._init(); - Future get database async { - if (_database != null) return _database!; - _database = await _initDB('database.db'); - - return _database!; - } Future _createDB(Database database) async{ const integerPrimaryKeyAutoincrement = 'INTEGER PRIMARY KEY AUTOINCREMENT'; diff --git a/lib/main.dart b/lib/main.dart index cbaaa02..06709ad 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'myApp.dart'; +import '../myApp.dart'; void main() { runApp(MyApp()); -} +} \ No newline at end of file diff --git a/lib/model/note.dart b/lib/model/note.dart index df6bed2..ae3d498 100644 --- a/lib/model/note.dart +++ b/lib/model/note.dart @@ -8,4 +8,7 @@ class Note extends BaseEntity { static String creationDate = BaseEntity.getCreationDate; static String lastModificationDate = BaseEntity.getLastEditDate; static String description = ''; + Map toMap() { + return {'id': id, 'title': title, 'desc': description,'CreationDate': creationDate, 'lastM': lastModificationDate }; + } } diff --git a/lib/navigation.dart b/lib/navigation.dart index 180a383..80bbc5f 100644 --- a/lib/navigation.dart +++ b/lib/navigation.dart @@ -1,5 +1,3 @@ -import 'dart:ffi'; - import 'package:flutter/material.dart'; import 'pages/testUI.dart'; import 'pages/TodayView.dart'; diff --git a/lib/pages/InboxView.dart b/lib/pages/InboxView.dart index 4d40bd7..e553fbc 100644 --- a/lib/pages/InboxView.dart +++ b/lib/pages/InboxView.dart @@ -10,10 +10,16 @@ class InboxView extends StatefulWidget { class _InboxViewState extends State { @override Widget build(BuildContext context) { - return const Scaffold( - body: Center( - child: Icon(Icons.inbox), - ) + return Scaffold( + appBar: AppBar( + title: const Text('Inbox'), + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + }, + child: Icon(Icons.add), + ), + ); } } diff --git a/lib/pages/NotesView.dart b/lib/pages/NotesView.dart index b0d7c4b..70ccb07 100644 --- a/lib/pages/NotesView.dart +++ b/lib/pages/NotesView.dart @@ -13,7 +13,9 @@ class _NotesViewState extends State { return const Scaffold( body: Center( child: Icon(Icons.note), - ) + ), + ); + } } diff --git a/test/widget_test.dart b/test/widget_test.dart index bb5dffa..1c66089 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -8,12 +8,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:progetto_m335_flutter/myApp.dart'; +import 'package:progetto_m335_flutter/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); From bf7981671ded9b0d192350030cde8b0c6ea03e2f Mon Sep 17 00:00:00 2001 From: Giulia Date: Thu, 28 Sep 2023 09:07:00 +0200 Subject: [PATCH 07/19] add note button --- lib/database/database.dart | 1 - lib/pages/NotesView.dart | 24 +++++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/database/database.dart b/lib/database/database.dart index 2f81885..78b2ed5 100644 --- a/lib/database/database.dart +++ b/lib/database/database.dart @@ -1,4 +1,3 @@ - import 'package:progetto_m335_flutter/model/note.dart'; class Database{ diff --git a/lib/pages/NotesView.dart b/lib/pages/NotesView.dart index 70ccb07..6ae0886 100644 --- a/lib/pages/NotesView.dart +++ b/lib/pages/NotesView.dart @@ -1,7 +1,8 @@ import 'package:flutter/material.dart'; +import 'NoteDetailView.dart'; class NotesView extends StatefulWidget { - const NotesView({super.key}); + const NotesView({Key? key}) : super(key: key); @override State createState() => _NotesViewState(); @@ -10,12 +11,21 @@ class NotesView extends StatefulWidget { class _NotesViewState extends State { @override Widget build(BuildContext context) { - return const Scaffold( - body: Center( - child: Icon(Icons.note), - ), - + return Scaffold( + appBar: AppBar( + title: Text('Note'), + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => const NoteDetailView(), + ), + ); + }, + child: Icon(Icons.add), + ), ); - } } + From 65ed67b8f6bb330d7bb6f086818aca0df0b05589 Mon Sep 17 00:00:00 2001 From: Giulia Date: Thu, 28 Sep 2023 10:40:01 +0200 Subject: [PATCH 08/19] fixed navigation and added create new note page --- lib/navigation.dart | 3 --- lib/pages/CreateNewNote.dart | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 lib/pages/CreateNewNote.dart diff --git a/lib/navigation.dart b/lib/navigation.dart index 80bbc5f..147b894 100644 --- a/lib/navigation.dart +++ b/lib/navigation.dart @@ -29,9 +29,6 @@ class _NavigationState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: Text("BottomNavBar"), - ), body: Center(child: _widgetOptions.elementAt(_selectedIndex)), bottomNavigationBar: BottomNavigationBar( items: const [ diff --git a/lib/pages/CreateNewNote.dart b/lib/pages/CreateNewNote.dart new file mode 100644 index 0000000..7d2ca8d --- /dev/null +++ b/lib/pages/CreateNewNote.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +class CreateNewNote extends StatefulWidget { + const CreateNewNote({super.key}); + + @override + State createState() => _CreateNewNoteState(); +} + +class _CreateNewNoteState extends State { + @override + Widget build(BuildContext context) { + return const Scaffold( + body: Center( + child: Text('CreateNewNote'), + ) + ); + } +} \ No newline at end of file From 06a3712d0a28af88a7666c754c0153a761274b35 Mon Sep 17 00:00:00 2001 From: lama137 <99168742+lama137@users.noreply.github.com> Date: Thu, 28 Sep 2023 11:03:54 +0200 Subject: [PATCH 09/19] Aggiornamento note e pulsanti. --- lib/database/database.dart | 5 ++- lib/pages/NotesView.dart | 86 +++++++++++++++++++++++++++++++++++++- 2 files changed, 88 insertions(+), 3 deletions(-) diff --git a/lib/database/database.dart b/lib/database/database.dart index 78b2ed5..71b71b4 100644 --- a/lib/database/database.dart +++ b/lib/database/database.dart @@ -1,4 +1,6 @@ +import 'package:path/path.dart'; import 'package:progetto_m335_flutter/model/note.dart'; +import 'package:sqflite/sqflite.dart'; class Database{ static final Database _instance = Database._init(); @@ -22,9 +24,10 @@ class Database{ ) '''); + } execute(String s) { } -} \ No newline at end of file +} diff --git a/lib/pages/NotesView.dart b/lib/pages/NotesView.dart index 6ae0886..391e535 100644 --- a/lib/pages/NotesView.dart +++ b/lib/pages/NotesView.dart @@ -1,6 +1,22 @@ +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); @@ -9,23 +25,89 @@ class NotesView extends StatefulWidget { } 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, ), floatingActionButton: FloatingActionButton( onPressed: () { Navigator.of(context).push( MaterialPageRoute( - builder: (context) => const NoteDetailView(), + builder: (context) => const CreateNewNote(), ), ); }, child: Icon(Icons.add), + backgroundColor: Colors.blue, + ), + body: Container( + color: Colors.blue[50], + child: ListView.builder( + itemCount: notes.length, + 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}'), + ], + ), + onTap: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => const NoteDetailView(), + ), + ); + }, + ), + ); + }, + ), ), ); } } - From 0fb537d24e4462a8e22dc71c48f1eedfbbbed503 Mon Sep 17 00:00:00 2001 From: lama137 <99168742+lama137@users.noreply.github.com> Date: Thu, 28 Sep 2023 11:04:46 +0200 Subject: [PATCH 10/19] Aggiornamento note e pulsanti. --- lib/database/database.dart | 1 - lib/pages/NotesView.dart | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/database/database.dart b/lib/database/database.dart index 71b71b4..0dc22cc 100644 --- a/lib/database/database.dart +++ b/lib/database/database.dart @@ -8,7 +8,6 @@ class Database{ Database._init(); - Future _createDB(Database database) async{ const integerPrimaryKeyAutoincrement = 'INTEGER PRIMARY KEY AUTOINCREMENT'; const textNotNull = 'TEXT NOT NULL'; diff --git a/lib/pages/NotesView.dart b/lib/pages/NotesView.dart index 391e535..f106c83 100644 --- a/lib/pages/NotesView.dart +++ b/lib/pages/NotesView.dart @@ -72,6 +72,7 @@ class _NotesViewState extends State { ), ); }, + child: Icon(Icons.add), backgroundColor: Colors.blue, ), From b81cfc70fb3e4272f5a740f15a375a58b79397ce Mon Sep 17 00:00:00 2001 From: Giulia Date: Thu, 28 Sep 2023 13:21:02 +0200 Subject: [PATCH 11/19] fix --- lib/pages/InboxView.dart | 36 +++++++++++++++++++- lib/pages/Note.dart | 31 +++++++++++++++++ lib/pages/NotesView.dart | 73 +++++----------------------------------- 3 files changed, 75 insertions(+), 65 deletions(-) create mode 100644 lib/pages/Note.dart diff --git a/lib/pages/InboxView.dart b/lib/pages/InboxView.dart index e553fbc..f95cfcf 100644 --- a/lib/pages/InboxView.dart +++ b/lib/pages/InboxView.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'CreateNewNote.dart'; +import 'NoteDetailView.dart'; class InboxView extends StatefulWidget { const InboxView({super.key}); @@ -8,6 +10,14 @@ class InboxView extends StatefulWidget { } class _InboxViewState extends State { + List _values = [false, false, false, false, false]; + + void _onChanged(int index, bool? newValue){ + setState(() { + _values[index] = newValue ?? false; + }); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -19,7 +29,31 @@ class _InboxViewState extends State { }, child: Icon(Icons.add), ), - + body: Container( + child: ListView.builder( + itemCount: 5, + itemBuilder: (context, index) { + return Card( + color: Colors.white, + child: ListTile( + leading: Checkbox( + value: _values[index], + onChanged: (newValue) => _onChanged(index, newValue), + ), + 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( + builder: (context) => const NoteDetailView(), + ), + ); + }, + ), + ); + }, + ), + ), ); } } diff --git a/lib/pages/Note.dart b/lib/pages/Note.dart new file mode 100644 index 0000000..cc0a29f --- /dev/null +++ b/lib/pages/Note.dart @@ -0,0 +1,31 @@ +import 'package:flutter/material.dart'; +import 'NoteDetailView.dart'; + +class Note extends StatefulWidget { + const Note({super.key}); + + @override + State createState() => _NotesViewState(); +} + +class _NotesViewState extends State { + + @override + Widget build(BuildContext context) { + return Card( + color: Colors.white, + + child: ListTile( + 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( + builder: (context) => const NoteDetailView(), + ), + ); + }, + ), + ); + } +} \ No newline at end of file diff --git a/lib/pages/NotesView.dart b/lib/pages/NotesView.dart index f106c83..b6a5f2c 100644 --- a/lib/pages/NotesView.dart +++ b/lib/pages/NotesView.dart @@ -1,21 +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); @@ -25,44 +11,13 @@ class NotesView extends StatefulWidget { } 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, + 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( From 0d53d1421f21988ad8e409e2f406f7c32a866ea0 Mon Sep 17 00:00:00 2001 From: lama137 <99168742+lama137@users.noreply.github.com> Date: Thu, 28 Sep 2023 13:22:47 +0200 Subject: [PATCH 12/19] Aggiornamento note e pulsanti. --- lib/pages/NotesView.dart | 73 +++++++++++++++++++++++++++++++++++----- pubspec.yaml | 3 +- 2 files changed, 66 insertions(+), 10 deletions(-) diff --git a/lib/pages/NotesView.dart b/lib/pages/NotesView.dart index b6a5f2c..f106c83 100644 --- a/lib/pages/NotesView.dart +++ b/lib/pages/NotesView.dart @@ -1,7 +1,21 @@ +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); @@ -11,13 +25,44 @@ class NotesView extends StatefulWidget { } 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', style: TextStyle(color: Colors.white),), - backgroundColor: Colors.lightBlue.shade900, + title: Text('Note'), + backgroundColor: Colors.blue, ), floatingActionButton: FloatingActionButton( onPressed: () { @@ -27,21 +72,31 @@ class _NotesViewState extends State { ), ); }, + child: Icon(Icons.add), - backgroundColor: Colors.lightBlue.shade900, + backgroundColor: Colors.blue, ), - - body: Container( + color: Colors.blue[50], child: ListView.builder( - itemCount: 5, + itemCount: notes.length, itemBuilder: (context, index) { + final note = notes[index]; return Card( color: Colors.white, - + elevation: 2.0, + margin: EdgeInsets.all(8.0), child: ListTile( - title: Text("ciao", style: TextStyle(color: Colors.lightBlue.shade900, fontWeight: FontWeight.bold),), - subtitle: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [Text('Descrizione della nota:'),],), + 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}'), + ], + ), onTap: () { Navigator.of(context).push( MaterialPageRoute( diff --git a/pubspec.yaml b/pubspec.yaml index 84d5e35..5ee74ca 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -30,7 +30,8 @@ environment: dependencies: flutter: sdk: flutter - + sqflite: + path: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. From abc0926f49f0ce1dfbc9dee7be9b89d8bb197cb5 Mon Sep 17 00:00:00 2001 From: Giulia Date: Thu, 28 Sep 2023 13:55:49 +0200 Subject: [PATCH 13/19] create note --- lib/pages/CreateNewNote.dart | 48 +++++++++++++++++++++++++++++++----- lib/pages/NotesView.dart | 2 +- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/lib/pages/CreateNewNote.dart b/lib/pages/CreateNewNote.dart index 7d2ca8d..f0a8b8f 100644 --- a/lib/pages/CreateNewNote.dart +++ b/lib/pages/CreateNewNote.dart @@ -1,19 +1,55 @@ import 'package:flutter/material.dart'; +import 'package:progetto_m335_flutter/pages/NotesView.dart'; class CreateNewNote extends StatefulWidget { - const CreateNewNote({super.key}); + const CreateNewNote({Key? key}) : super(key: key); @override State createState() => _CreateNewNoteState(); } class _CreateNewNoteState extends State { + TextEditingController _titleController = TextEditingController(); + TextEditingController _textController = TextEditingController(); + + @override + void dispose() { + _titleController.dispose(); + _textController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { - return const Scaffold( - body: Center( - child: Text('CreateNewNote'), - ) + return Scaffold( + appBar: AppBar( + title: Text('Create New Note'), + ), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Title:', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),), + TextField(controller: _titleController, decoration: InputDecoration(hintText: 'Enter a title',),), + SizedBox(height: 16), // Spacing between title and text + Text('Text:', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),), + TextField(controller: _textController, maxLines: null, decoration: InputDecoration(hintText: 'Enter text', border: InputBorder.none,), + ), + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + String title = _titleController.text; + String text = _textController.text; + _titleController.clear(); + _textController.clear(); + + }, + child: Icon(Icons.save, color: Colors.white,), + backgroundColor: Colors.lightBlue.shade900, + ), ); } -} \ No newline at end of file +} diff --git a/lib/pages/NotesView.dart b/lib/pages/NotesView.dart index b6a5f2c..ddaf7a0 100644 --- a/lib/pages/NotesView.dart +++ b/lib/pages/NotesView.dart @@ -27,7 +27,7 @@ class _NotesViewState extends State { ), ); }, - child: Icon(Icons.add), + child: Icon(Icons.add, color: Colors.white,), backgroundColor: Colors.lightBlue.shade900, ), From 4121239e366ebecb39ac8b339b1e09c9dc275535 Mon Sep 17 00:00:00 2001 From: Giulia Date: Thu, 28 Sep 2023 13:56:54 +0200 Subject: [PATCH 14/19] create note --- lib/pages/CreateNewNote.dart | 1 + lib/pages/NotesView.dart | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/pages/CreateNewNote.dart b/lib/pages/CreateNewNote.dart index f0a8b8f..8e23b15 100644 --- a/lib/pages/CreateNewNote.dart +++ b/lib/pages/CreateNewNote.dart @@ -19,6 +19,7 @@ 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 ddaf7a0..bd919eb 100644 --- a/lib/pages/NotesView.dart +++ b/lib/pages/NotesView.dart @@ -10,6 +10,7 @@ class NotesView extends StatefulWidget { State createState() => _NotesViewState(); } + class _NotesViewState extends State { @override From c0c090085f775ed4bbd31d409722aafd92d786c0 Mon Sep 17 00:00:00 2001 From: Giulia Date: Thu, 28 Sep 2023 13:57:51 +0200 Subject: [PATCH 15/19] create note --- lib/pages/CreateNewNote.dart | 1 - lib/pages/NotesView.dart | 1 - 2 files changed, 2 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 bd919eb..86595ab 100644 --- a/lib/pages/NotesView.dart +++ b/lib/pages/NotesView.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'CreateNewNote.dart'; import 'NoteDetailView.dart'; - class NotesView extends StatefulWidget { const NotesView({Key? key}) : super(key: key); From b284a3d6d6a545d9254f120e58247dee8b88babe Mon Sep 17 00:00:00 2001 From: lama137 <99168742+lama137@users.noreply.github.com> Date: Thu, 28 Sep 2023 14:26:17 +0200 Subject: [PATCH 16/19] TITOOOOOOOOOOOOO --- lib/pages/TodayView.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pages/TodayView.dart b/lib/pages/TodayView.dart index fe3db07..1844bfc 100644 --- a/lib/pages/TodayView.dart +++ b/lib/pages/TodayView.dart @@ -14,6 +14,7 @@ class TodayView extends StatefulWidget { class _TodayViewState extends State { @override Widget build(BuildContext context) { + return ListView( children: [ Reminder(), From 6d9eb5f4dbe1adb48416d9d36ed0696aaf3a2746 Mon Sep 17 00:00:00 2001 From: Giulia Date: Thu, 28 Sep 2023 14:45:00 +0200 Subject: [PATCH 17/19] fixed style --- lib/navigation.dart | 2 -- lib/pages/InboxView.dart | 11 ++++++++--- lib/pages/NotesView.dart | 6 +++--- lib/pages/TodayView.dart | 20 ++++++++++++++------ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/lib/navigation.dart b/lib/navigation.dart index 6496828..d36e44d 100644 --- a/lib/navigation.dart +++ b/lib/navigation.dart @@ -1,5 +1,3 @@ -import 'dart:ffi'; - import 'package:flutter/material.dart'; import 'pages/testUI.dart'; import 'pages/TodayView.dart'; diff --git a/lib/pages/InboxView.dart b/lib/pages/InboxView.dart index f95cfcf..98c083e 100644 --- a/lib/pages/InboxView.dart +++ b/lib/pages/InboxView.dart @@ -22,12 +22,17 @@ class _InboxViewState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: const Text('Inbox'), + title: Text( + 'Inbox', + style: TextStyle(color: Colors.white), + ), + backgroundColor: Colors.cyan.shade700, ), floatingActionButton: FloatingActionButton( onPressed: () { }, - child: Icon(Icons.add), + child: Icon(Icons.add, color: Colors.white), + backgroundColor: Colors.cyan.shade700, ), body: Container( child: ListView.builder( @@ -40,7 +45,7 @@ class _InboxViewState extends State { value: _values[index], onChanged: (newValue) => _onChanged(index, newValue), ), - title: Text("ciao", style: TextStyle(color: Colors.lightBlue.shade900, fontWeight: FontWeight.bold)), + title: Text("ciao", style: TextStyle(color: Colors.cyan.shade700, fontWeight: FontWeight.bold)), subtitle: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [Text('Descrizione della nota:')]), onTap: () { Navigator.of(context).push( diff --git a/lib/pages/NotesView.dart b/lib/pages/NotesView.dart index 86595ab..053b5eb 100644 --- a/lib/pages/NotesView.dart +++ b/lib/pages/NotesView.dart @@ -17,7 +17,7 @@ class _NotesViewState extends State { return Scaffold( appBar: AppBar( title: Text('Note', style: TextStyle(color: Colors.white),), - backgroundColor: Colors.lightBlue.shade900, + backgroundColor: Colors.cyan.shade700, ), floatingActionButton: FloatingActionButton( onPressed: () { @@ -28,7 +28,7 @@ class _NotesViewState extends State { ); }, child: Icon(Icons.add, color: Colors.white,), - backgroundColor: Colors.lightBlue.shade900, + backgroundColor: Colors.cyan.shade700, ), @@ -40,7 +40,7 @@ class _NotesViewState extends State { color: Colors.white, child: ListTile( - title: Text("ciao", style: TextStyle(color: Colors.lightBlue.shade900, fontWeight: FontWeight.bold),), + title: Text("ciao", style: TextStyle(color: Colors.cyan.shade700, fontWeight: FontWeight.bold),), subtitle: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [Text('Descrizione della nota:'),],), onTap: () { Navigator.of(context).push( diff --git a/lib/pages/TodayView.dart b/lib/pages/TodayView.dart index 1844bfc..e522032 100644 --- a/lib/pages/TodayView.dart +++ b/lib/pages/TodayView.dart @@ -14,12 +14,20 @@ class TodayView extends StatefulWidget { class _TodayViewState extends State { @override Widget build(BuildContext context) { - - return ListView( - children: [ - Reminder(), - Reminder(), - ] + return Scaffold( + appBar: AppBar( + title: Text( + 'Today', + style: TextStyle(color: Colors.white), + ), + backgroundColor: Colors.cyan.shade700, + ), + body: Container( + child: ListView(children: [ + Reminder(), + Reminder(), + ]), + ), ); } } From bf3a9c552db04a88b2f14d1331a65060ceb1815b Mon Sep 17 00:00:00 2001 From: Giulia Date: Fri, 29 Sep 2023 09:09:26 +0200 Subject: [PATCH 18/19] fix --- lib/{pages => Components}/Note.dart | 8 ++------ lib/navigation.dart | 2 -- lib/pages/NotesView.dart | 32 ++++++++--------------------- 3 files changed, 10 insertions(+), 32 deletions(-) rename lib/{pages => Components}/Note.dart (86%) diff --git a/lib/pages/Note.dart b/lib/Components/Note.dart similarity index 86% rename from lib/pages/Note.dart rename to lib/Components/Note.dart index cc0a29f..c0d31c8 100644 --- a/lib/pages/Note.dart +++ b/lib/Components/Note.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'NoteDetailView.dart'; +import '../pages/NoteDetailView.dart'; class Note extends StatefulWidget { const Note({super.key}); @@ -12,10 +12,7 @@ class _NotesViewState extends State { @override Widget build(BuildContext context) { - return Card( - color: Colors.white, - - child: ListTile( + return ListTile( title: Text("ciao", style: TextStyle(color: Colors.lightBlue.shade900, fontWeight: FontWeight.bold),), subtitle: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [Text('Descrizione della nota:'),],), onTap: () { @@ -25,7 +22,6 @@ class _NotesViewState extends State { ), ); }, - ), ); } } \ No newline at end of file diff --git a/lib/navigation.dart b/lib/navigation.dart index 5ab31e1..0d67440 100644 --- a/lib/navigation.dart +++ b/lib/navigation.dart @@ -1,5 +1,3 @@ -import 'dart:ffi'; - import 'package:flutter/material.dart'; import 'pages/testUI.dart'; import 'pages/TodayView.dart'; diff --git a/lib/pages/NotesView.dart b/lib/pages/NotesView.dart index 053b5eb..dbea091 100644 --- a/lib/pages/NotesView.dart +++ b/lib/pages/NotesView.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import '../Components/Note.dart'; import 'CreateNewNote.dart'; import 'NoteDetailView.dart'; @@ -16,8 +17,7 @@ class _NotesViewState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Note', style: TextStyle(color: Colors.white),), - backgroundColor: Colors.cyan.shade700, + title: Text('Note'), ), floatingActionButton: FloatingActionButton( onPressed: () { @@ -32,28 +32,12 @@ class _NotesViewState extends State { ), - body: Container( - child: ListView.builder( - itemCount: 5, - itemBuilder: (context, index) { - return Card( - color: Colors.white, - - child: ListTile( - title: Text("ciao", style: TextStyle(color: Colors.cyan.shade700, fontWeight: FontWeight.bold),), - subtitle: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [Text('Descrizione della nota:'),],), - onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const NoteDetailView(), - ), - ); - }, - ), - ); - }, - ), - ), + body:ListView( + children: const [ + Note(), + Note(), + ], + ) ); } } From ccb56ffa9c74505a3b7768731a334f1cf68871a7 Mon Sep 17 00:00:00 2001 From: Giulia Date: Fri, 29 Sep 2023 09:52:26 +0200 Subject: [PATCH 19/19] fix notes --- lib/Components/Note.dart | 4 +- lib/pages/CreateNewNote.dart | 68 +++++++++++++++++++++-------- lib/pages/NoteDetailView.dart | 80 ++++++++++++++++++++++++++++++++--- lib/pages/NotesView.dart | 3 +- 4 files changed, 129 insertions(+), 26 deletions(-) diff --git a/lib/Components/Note.dart b/lib/Components/Note.dart index c0d31c8..b2e00d9 100644 --- a/lib/Components/Note.dart +++ b/lib/Components/Note.dart @@ -13,8 +13,8 @@ class _NotesViewState extends State { @override Widget build(BuildContext context) { return ListTile( - title: Text("ciao", style: TextStyle(color: Colors.lightBlue.shade900, fontWeight: FontWeight.bold),), - subtitle: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [Text('Descrizione della nota:'),],), + title: Text("Titolo"), + subtitle: Text('Testo'), onTap: () { Navigator.of(context).push( MaterialPageRoute( diff --git a/lib/pages/CreateNewNote.dart b/lib/pages/CreateNewNote.dart index f0a8b8f..2f8f941 100644 --- a/lib/pages/CreateNewNote.dart +++ b/lib/pages/CreateNewNote.dart @@ -30,26 +30,60 @@ class _CreateNewNoteState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text('Title:', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),), - TextField(controller: _titleController, decoration: InputDecoration(hintText: 'Enter a title',),), - SizedBox(height: 16), // Spacing between title and text - Text('Text:', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),), - TextField(controller: _textController, maxLines: null, decoration: InputDecoration(hintText: 'Enter text', border: InputBorder.none,), + TextField( + controller: _titleController, + decoration: InputDecoration( + hintText: 'Enter a title', + ), ), - ], + SizedBox(height: 16), + TextField( + controller: _textController, + maxLines: null, + decoration: InputDecoration( + hintText: 'Enter text', + border: InputBorder.none, + ), + ), + const SizedBox(height: 10), + const Spacer(), + Row( + children: [ + Expanded( + child: ElevatedButton( + onPressed: () { + print("Delete button pressed"); + }, + style: ElevatedButton.styleFrom( + primary: Colors.red, + ), + child: const Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(Icons.delete), + Text("Delete"), + ], + ), + ), + ), + const SizedBox(width: 10), + Expanded( + child: ElevatedButton( + onPressed: () { + String title = _titleController.text; + String text = _textController.text; + _titleController.clear(); + _textController.clear(); + Navigator.pop(context); + }, + child: const Text("Save"), + ), + ), + ], + ), + ], // ), ), - floatingActionButton: FloatingActionButton( - onPressed: () { - String title = _titleController.text; - String text = _textController.text; - _titleController.clear(); - _textController.clear(); - - }, - child: Icon(Icons.save, color: Colors.white,), - backgroundColor: Colors.lightBlue.shade900, - ), ); } } diff --git a/lib/pages/NoteDetailView.dart b/lib/pages/NoteDetailView.dart index a9802da..7f3b04d 100644 --- a/lib/pages/NoteDetailView.dart +++ b/lib/pages/NoteDetailView.dart @@ -1,19 +1,89 @@ import 'package:flutter/material.dart'; +import 'package:progetto_m335_flutter/pages/NotesView.dart'; class NoteDetailView extends StatefulWidget { - const NoteDetailView({super.key}); + const NoteDetailView({Key? key}) : super(key: key); @override State createState() => _NoteDetailViewState(); } class _NoteDetailViewState extends State { + TextEditingController _titleController = TextEditingController(); + TextEditingController _textController = TextEditingController(); + + @override + void dispose() { + _titleController.dispose(); + _textController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { - return const Scaffold( - body: Center( - child: Text('NoteDetailView'), - ) + return Scaffold( + appBar: AppBar( + title: Text('Edit note'), + ), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + controller: _titleController, + decoration: InputDecoration( + hintText: 'Enter a title', + ), + ), + SizedBox(height: 16), + TextField( + controller: _textController, + maxLines: null, + decoration: InputDecoration( + hintText: 'Enter text', + border: InputBorder.none, + ), + ), + const SizedBox(height: 10), + const Spacer(), + Row( + children: [ + Expanded( + child: ElevatedButton( + onPressed: () { + print("Delete button pressed"); + }, + style: ElevatedButton.styleFrom( + primary: Colors.red, + ), + child: const Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(Icons.delete), + Text("Delete"), + ], + ), + ), + ), + const SizedBox(width: 10), + Expanded( + child: ElevatedButton( + onPressed: () { + String title = _titleController.text; + String text = _textController.text; + _titleController.clear(); + _textController.clear(); + Navigator.pop(context); + }, + child: const Text("Save"), + ), + ), + ], + ), + ], // + ), + ), ); } } diff --git a/lib/pages/NotesView.dart b/lib/pages/NotesView.dart index dbea091..4ad2961 100644 --- a/lib/pages/NotesView.dart +++ b/lib/pages/NotesView.dart @@ -27,8 +27,7 @@ class _NotesViewState extends State { ), ); }, - child: Icon(Icons.add, color: Colors.white,), - backgroundColor: Colors.cyan.shade700, + child: Icon(Icons.add), ),