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 1/5] 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 2/5] 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 3/5] 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 4/5] 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 5/5] 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; }