From 782bbebce9ee8a1cea4d9ba8a64e6f3302ef1cbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20Ku=CC=88ng?= Date: Thu, 28 Sep 2023 11:38:19 +0200 Subject: [PATCH 01/14] database init --- lib/database/database.dart | 182 +++++++++++++++++++++++++++++++++---- lib/model/promemoria.dart | 1 - lib/navigation.dart | 5 +- lib/pages/test.dart | 45 +++++++++ pubspec.yaml | 3 + 5 files changed, 215 insertions(+), 21 deletions(-) create mode 100644 lib/pages/test.dart diff --git a/lib/database/database.dart b/lib/database/database.dart index 10474b8..8d9aea3 100644 --- a/lib/database/database.dart +++ b/lib/database/database.dart @@ -1,37 +1,181 @@ +import 'package:path/path.dart'; +import 'package:sqflite/sqflite.dart'; +// Models import 'package:progetto_m335_flutter/model/note.dart'; +import 'package:progetto_m335_flutter/model/promemoria.dart'; -class Database{ - static final Database _instance = Database._init(); +class NoteDatabase { + static final NoteDatabase instance = NoteDatabase._init(); static Database? _database; - Database._init(); + // Zero args constructor needed to extend this class + NoteDatabase(); + + NoteDatabase._init(); Future get database async { if (_database != null) return _database!; - _database = await _initDB('database.db'); + _database = await _initDB('note.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'; + Future _initDB(String filePath) async { + // On Android, it is typically data/data//databases. + // On iOS and MacOS, it is the Documents directory. + final databasePath = await getDatabasesPath(); + // Directory databasePath = await getApplicationDocumentsDirectory(); + + final path = join(databasePath, filePath); + return await openDatabase(path, version: 1, onCreate: _createDB); + } + + Future _createDB(Database database, int version) async { + //check if the database is created + if (database.query(noteTable) != null) { + print("Database already created"); + + }else{ + print("demo data inserting"); + await database.execute('''CREATE TABLE promemoria ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + title TEXT NOT NULL, + creationDate TEXT NOT NULL, + lastModificationDate TEXT, + expirationDate TEXT, + description TEXT, + priority TEXT, + color TEXT +); + '''); + + await database.execute('''CREATE TABLE note ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + title TEXT NOT NULL, + creationDate TEXT NOT NULL, + lastModificationDate TEXT, + description TEXT +); + '''); + + print("database created"); + } + + + await fillDemoData(database, version); + } + + Future fillDemoData(Database database, int version) async { + + print("boh speriamo funzioni"); + // Add some fake accounts + + + // Add fake categories + await database.execute(''' + INSERT INTO note ( + title, + creationDate, + lastModificationDate, + description + ) VALUES ( + 'Nota 2', + '2023-09-28', + '2023-09-28', + 'Questo è un esempio di nota 2.' + ) +'''); await database.execute(''' - CREATE TABLE $Note ( - ${Note.id} $integerPrimaryKeyAutoincrement, - - ) - '''); + INSERT INTO note ( + title, + creationDate, + lastModificationDate, + description + ) VALUES ( + 'Nota 2', + '2023-09-28', + '2023-09-28', + 'Questo è un esempio di nota 2.' + ) +'''); + + // Add currencies + await database.execute(''' + INSERT INTO promemoria ( + title, + creationDate, + lastModificationDate, + expirationDate, + description, + priority, + color + ) VALUES ( + 'Promemoria 1', + '2023-09-27', + '2023-09-27', + '2023-10-05', + 'Questo è un esempio di promemoria 1.', + 'Alta', + 'Rosso' + ) +'''); + + // Add fake budgets + await database.execute(''' + INSERT INTO promemoria ( + title, + creationDate, + lastModificationDate, + expirationDate, + description, + priority, + color + ) VALUES ( + 'Promemoria 2', + '2023-09-28', + '2023-09-28', + '2023-10-10', + 'Questo è un esempio di promemoria 2.', + 'Media', + 'Verde' + ) +'''); + print("Demo data inserted"); } - execute(String s) { - + Future clearDatabase() async { + try { + await _database?.transaction((txn) async { + var batch = txn.batch(); + batch.delete(noteTable); + batch.delete(promemoriaTable); + await batch.commit(); + }); + } catch (error) { + throw Exception('DbBase.cleanDatabase: $error'); + } } -} \ No newline at end of file + + Future> selectAllPromemoria() async { + final db = await database; + + final List> maps = await db.query(promemoriaTable); + + return maps; + } + + Future close() async { + final database = await instance.database; + database.close(); + } + + // WARNING: FOR DEV/TEST PURPOSES ONLY!! + Future deleteDatabase() async { + final databasePath = await getDatabasesPath(); + final path = join(databasePath, 'note.db'); + databaseFactory.deleteDatabase(path); + } +} diff --git a/lib/model/promemoria.dart b/lib/model/promemoria.dart index 32f4ebc..1d33319 100644 --- a/lib/model/promemoria.dart +++ b/lib/model/promemoria.dart @@ -18,6 +18,5 @@ class Promemoria extends BaseEntity{ static Color color = Color.none; - } diff --git a/lib/navigation.dart b/lib/navigation.dart index 180a383..e06a378 100644 --- a/lib/navigation.dart +++ b/lib/navigation.dart @@ -5,6 +5,7 @@ import 'pages/testUI.dart'; import 'pages/TodayView.dart'; import 'pages/InboxView.dart'; import 'pages/NotesView.dart'; +import 'pages/test.dart'; class Navigation extends StatefulWidget { const Navigation({super.key}); @@ -15,11 +16,12 @@ class Navigation extends StatefulWidget { class _NavigationState extends State { - int _selectedIndex = 0; + int _selectedIndex = 3; static const List _widgetOptions = [ TodayView(), InboxView(), NotesView(), + Test() ]; void _onItemTapped(int index) { @@ -41,6 +43,7 @@ class _NavigationState extends State { icon: Icon(Icons.calendar_today), label: "today"), BottomNavigationBarItem(icon: Icon(Icons.inbox), label: "Inbox"), BottomNavigationBarItem(icon: Icon(Icons.note), label: "Notes"), + BottomNavigationBarItem(icon: Icon(Icons.settings), label: "Settings") ], currentIndex: _selectedIndex, onTap: _onItemTapped, diff --git a/lib/pages/test.dart b/lib/pages/test.dart new file mode 100644 index 0000000..7cda250 --- /dev/null +++ b/lib/pages/test.dart @@ -0,0 +1,45 @@ +import 'package:flutter/material.dart'; +import 'package:progetto_m335_flutter/database/database.dart'; +import 'package:progetto_m335_flutter/model/note.dart'; + +import '../database/database.dart'; + +class Test extends StatefulWidget { + const Test({super.key}); + + @override + State createState() => _TestState(); +} + +class _TestState extends State { + NoteDatabase noteDatabase = NoteDatabase.instance; + + Future _pressed() async { + print("Inserting demo data"); + final db = await noteDatabase.database; + + + } + + Future _printdata() async { + final db = await noteDatabase.database; + + print("Printing data"); + print(await db.query(noteTable)); + print("Data printed"); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Column( + children: [ + FloatingActionButton(onPressed: _pressed), + FloatingActionButton(onPressed: _printdata) + ], + ) + ) + ); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 84d5e35..f735786 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -36,6 +36,9 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 firebase_core: ^2.16.0 + sqflite: ^2.3.0 + path: ^1.8.3 + sqflite_common_ffi: ^2.3.0+2 dev_dependencies: flutter_test: From 52d7defb75fb1bd8482e05b6728e3c353b9b526a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20Ku=CC=88ng?= Date: Thu, 28 Sep 2023 11:47:01 +0200 Subject: [PATCH 02/14] entity upgrade --- lib/model/note.dart | 1 + lib/model/promemoria.dart | 10 +++------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/model/note.dart b/lib/model/note.dart index df6bed2..d542561 100644 --- a/lib/model/note.dart +++ b/lib/model/note.dart @@ -7,5 +7,6 @@ class Note extends BaseEntity { static String title = BaseEntity.getTitle; static String creationDate = BaseEntity.getCreationDate; static String lastModificationDate = BaseEntity.getLastEditDate; + static String arrayPromemoria = ''; static String description = ''; } diff --git a/lib/model/promemoria.dart b/lib/model/promemoria.dart index 1d33319..5326c1d 100644 --- a/lib/model/promemoria.dart +++ b/lib/model/promemoria.dart @@ -1,22 +1,18 @@ -import 'dart:ui'; - import 'base_entity.dart'; import 'identifiers/enum/color.dart'; import 'identifiers/enum/priority.dart'; const String promemoriaTable = 'promemoria'; -class Promemoria extends BaseEntity{ +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 arrayPromemoria = ''; static String description = ''; - static Priority priority = Priority.none; + static Color color = Color.none; - - } - From 64b4f64f8c358dc8921e4afa503da12ed4930652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20Ku=CC=88ng?= Date: Thu, 28 Sep 2023 13:38:09 +0200 Subject: [PATCH 03/14] work in progress database --- lib/database/database.dart | 145 ++++++++++++++++++++++++++++++------- lib/main.dart | 1 + lib/myApp.dart | 1 + 3 files changed, 121 insertions(+), 26 deletions(-) diff --git a/lib/database/database.dart b/lib/database/database.dart index 8d9aea3..098ea74 100644 --- a/lib/database/database.dart +++ b/lib/database/database.dart @@ -22,62 +22,55 @@ class NoteDatabase { } Future _initDB(String filePath) async { - // On Android, it is typically data/data//databases. - // On iOS and MacOS, it is the Documents directory. final databasePath = await getDatabasesPath(); - // Directory databasePath = await getApplicationDocumentsDirectory(); final path = join(databasePath, filePath); return await openDatabase(path, version: 1, onCreate: _createDB); } Future _createDB(Database database, int version) async { - //check if the database is created - if (database.query(noteTable) != null) { + if (await isDatabaseExists()) { print("Database already created"); + deleteDatabase(); + print("Database deleted"); + } - }else{ - print("demo data inserting"); - await database.execute('''CREATE TABLE promemoria ( + await database.execute('''CREATE TABLE promemoria ( id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT NOT NULL, creationDate TEXT NOT NULL, lastModificationDate TEXT, expirationDate TEXT, + arrayPromemoria TEXT, description TEXT, priority TEXT, color TEXT ); '''); - await database.execute('''CREATE TABLE note ( + await database.execute('''CREATE TABLE note ( id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT NOT NULL, creationDate TEXT NOT NULL, lastModificationDate TEXT, + arrayPromemoria TEXT, description TEXT ); '''); - print("database created"); - } - - + print("database created"); await fillDemoData(database, version); } + Future fillDemoData(Database database, int version) async { - - print("boh speriamo funzioni"); - // Add some fake accounts - - // Add fake categories await database.execute(''' INSERT INTO note ( title, creationDate, lastModificationDate, + arrayPromemoria, description ) VALUES ( 'Nota 2', @@ -93,6 +86,7 @@ class NoteDatabase { title, creationDate, lastModificationDate, + arrayPromemoria, description ) VALUES ( 'Nota 2', @@ -109,6 +103,7 @@ class NoteDatabase { creationDate, lastModificationDate, expirationDate, + arrayPromemoria, description, priority, color @@ -130,6 +125,7 @@ class NoteDatabase { creationDate, lastModificationDate, expirationDate, + arrayPromemoria, description, priority, color @@ -159,6 +155,50 @@ class NoteDatabase { } } + Future close() async { + final database = await instance.database; + database.close(); + } + + + Future deleteDatabase() async { + final databasePath = await getDatabasesPath(); + final path = join(databasePath, 'note.db'); + databaseFactory.deleteDatabase(path); + } + + Future isDatabaseExists() async { + final databasePath = await getDatabasesPath(); + final path = join(databasePath, 'note.db'); + // Apre il database in modalità sola lettura. + Database database = await openDatabase(path, readOnly: true); + + // Restituisce true se il database è stato aperto correttamente, altrimenti false. + return database.isOpen; + } + + + Future createNote(Database database, Note note) async { + await database.execute(''' + INSERT INTO note ( + title, + creationDate, + lastModificationDate, + arrayPromemoria, + description, + + ) VALUES ( + '$note.title}', + '$note.creationDate', + '$note.lastModificationDate', + '$note.arrayPromemoria.toString()', + '$note.description', + ) + '''); + + print('note $note.title inserted'); + } + Future> selectAllPromemoria() async { final db = await database; @@ -167,15 +207,68 @@ class NoteDatabase { return maps; } - Future close() async { - final database = await instance.database; - database.close(); + + Future> selectAllNotes() async { + final db = await database; + + final List> maps = await db.query(noteTable); + + return maps; } - // WARNING: FOR DEV/TEST PURPOSES ONLY!! - Future deleteDatabase() async { - final databasePath = await getDatabasesPath(); - final path = join(databasePath, 'note.db'); - databaseFactory.deleteDatabase(path); + + Future createPromemoria(Database database, + Promemoria promemoria) async { + await database.execute(''' + INSERT INTO promemoria ( + title, + creationDate, + lastModificationDate, + expirationDate, + arrayPromemoria, + description, + priority, + color + ) VALUES ( + '$promemoria.title', + '$promemoria.creationDate', + '$promemoria.lastModificationDate', + '$promemoria.expirationDate', + '$promemoria.arrayPromemoria.toString()', + '$promemoria.description', + '$promemoria.priority', + '$promemoria.color' + ) + '''); + + print('promemoria $promemoria.title inserted'); } + + + Future> readPromemoria(int id) async { + final db = await database; + + final results = await db.query('SELECT * FROM note where id=$id'); + return results.first; + } + + + Future> readNote(int id) async { + final db = await database; + + final results= await db.query('SELECT * FROM promemoria where id=$id'); + + return results.first; + } + +// Future updatePromemoria(Promemoria promemoria) async { + // final db = await database; + + //await db.update('promemoria', promemoria, where: 'id = ?', + // Pass the Dog's id as a whereArg to prevent SQL injection. +// whereArgs: [dog.id],) +//} + + } + diff --git a/lib/main.dart b/lib/main.dart index cbaaa02..9fac54f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -3,4 +3,5 @@ import 'myApp.dart'; void main() { runApp(MyApp()); + print("App started"); } diff --git a/lib/myApp.dart b/lib/myApp.dart index 2f9d223..fd337d4 100644 --- a/lib/myApp.dart +++ b/lib/myApp.dart @@ -4,6 +4,7 @@ import 'navigation.dart'; class MyApp extends StatelessWidget { const MyApp({ Key? key }) : super(key: key); + @override Widget build(BuildContext context) { return MaterialApp( From a58721a6f4bd8abf626f3790743429da3d2f21b9 Mon Sep 17 00:00:00 2001 From: grata Date: Thu, 28 Sep 2023 13:57:21 +0200 Subject: [PATCH 04/14] crud --- lib/database/database.dart | 103 ++++++++++++++++--------------------- lib/model/note.dart | 59 +++++++++++++++++++++ lib/model/promemoria.dart | 81 ++++++++++++++++++++++++++++- 3 files changed, 183 insertions(+), 60 deletions(-) diff --git a/lib/database/database.dart b/lib/database/database.dart index 098ea74..84d67ed 100644 --- a/lib/database/database.dart +++ b/lib/database/database.dart @@ -62,8 +62,24 @@ class NoteDatabase { await fillDemoData(database, version); } - Future fillDemoData(Database database, int version) async { + + var nota = Note(); + nota.setTitle("Nota 1"); + nota.setCreationDate("2023-09-56"); + nota.setLastModificationDate("2023-09-56"); + nota.setArrayPromemoria("1,2,3,4,5"); + nota.setDescription("Questo è un esempio di nota 1."); + + await createNote(database, nota); + + print(await readNote(1)); + + nota.setDescription("ciao"); + await updateNote (nota); + + print(await readNote (1)); + // Add fake categories await database.execute(''' INSERT INTO note ( @@ -80,7 +96,6 @@ class NoteDatabase { ) '''); - await database.execute(''' INSERT INTO note ( title, @@ -160,7 +175,6 @@ class NoteDatabase { database.close(); } - Future deleteDatabase() async { final databasePath = await getDatabasesPath(); final path = join(databasePath, 'note.db'); @@ -177,28 +191,6 @@ class NoteDatabase { return database.isOpen; } - - Future createNote(Database database, Note note) async { - await database.execute(''' - INSERT INTO note ( - title, - creationDate, - lastModificationDate, - arrayPromemoria, - description, - - ) VALUES ( - '$note.title}', - '$note.creationDate', - '$note.lastModificationDate', - '$note.arrayPromemoria.toString()', - '$note.description', - ) - '''); - - print('note $note.title inserted'); - } - Future> selectAllPromemoria() async { final db = await database; @@ -207,7 +199,6 @@ class NoteDatabase { return maps; } - Future> selectAllNotes() async { final db = await database; @@ -216,35 +207,27 @@ class NoteDatabase { return maps; } + Future createNote(Database database, Note note) async { + await database.insert( + 'note', + note.toMap(), + conflictAlgorithm: ConflictAlgorithm.replace, + ); - Future createPromemoria(Database database, - Promemoria promemoria) async { - await database.execute(''' - INSERT INTO promemoria ( - title, - creationDate, - lastModificationDate, - expirationDate, - arrayPromemoria, - description, - priority, - color - ) VALUES ( - '$promemoria.title', - '$promemoria.creationDate', - '$promemoria.lastModificationDate', - '$promemoria.expirationDate', - '$promemoria.arrayPromemoria.toString()', - '$promemoria.description', - '$promemoria.priority', - '$promemoria.color' - ) - '''); + print('note $note.title inserted'); + } + + Future createPromemoria( + Database database, Promemoria promemoria) async { + await database.insert( + 'promemoria', + promemoria.toMap(), + conflictAlgorithm: ConflictAlgorithm.replace, + ); print('promemoria $promemoria.title inserted'); } - Future> readPromemoria(int id) async { final db = await database; @@ -252,23 +235,25 @@ class NoteDatabase { return results.first; } - Future> readNote(int id) async { final db = await database; - final results= await db.query('SELECT * FROM promemoria where id=$id'); + final results = await db.query('SELECT * FROM promemoria where id=$id'); return results.first; } -// Future updatePromemoria(Promemoria promemoria) async { - // final db = await database; + Future updatePromemoria(Promemoria promemoria) async { + final db = await database; - //await db.update('promemoria', promemoria, where: 'id = ?', - // Pass the Dog's id as a whereArg to prevent SQL injection. -// whereArgs: [dog.id],) -//} + await db.update('promemoria', promemoria.toMap(), + where: 'id = ?', whereArgs: [promemoria.getId()]); + } + Future updateNote(Note note) async { + final db = await database; + await db.update('note', note.toMap(), + where: 'id = ?', whereArgs: [note.getId()]); + } } - diff --git a/lib/model/note.dart b/lib/model/note.dart index d542561..7172796 100644 --- a/lib/model/note.dart +++ b/lib/model/note.dart @@ -9,4 +9,63 @@ class Note extends BaseEntity { static String lastModificationDate = BaseEntity.getLastEditDate; static String arrayPromemoria = ''; static String description = ''; + + Map toMap() { + return { + 'id': id, + 'title': title, + 'creationDate': creationDate, + 'lastModificationDate': lastModificationDate, + 'arrayPromemoria': arrayPromemoria, + 'description': description + }; + } + + String getId() { + return id; + } + + void setId(String id) { + id = id; + } + + String getTitle() { + return title; + } + + void setTitle(String title) { + title = title; + } + + String getCreationDate() { + return creationDate; + } + + void setCreationDate(String creationDate) { + creationDate = creationDate; + } + + String getLastModificationDate() { + return lastModificationDate; + } + + void setLastModificationDate(String lastModificationDate) { + lastModificationDate = lastModificationDate; + } + + String getArrayPromemoria() { + return arrayPromemoria; + } + + void setArrayPromemoria(String arrayPromemoria) { + arrayPromemoria = arrayPromemoria; + } + + String getDescription() { + return description; + } + + void setDescription(String description) { + description = description; + } } diff --git a/lib/model/promemoria.dart b/lib/model/promemoria.dart index 5326c1d..d57a9fc 100644 --- a/lib/model/promemoria.dart +++ b/lib/model/promemoria.dart @@ -13,6 +13,85 @@ class Promemoria extends BaseEntity { static String arrayPromemoria = ''; static String description = ''; static Priority priority = Priority.none; - static Color color = Color.none; + + Map toMap() { + return { + 'id': id, + 'title': title, + 'creationDate': creationDate, + 'lastModificationDate': lastModificationDate, + 'expirationDate': expirationDate, + 'arrayPromemoria': arrayPromemoria, + 'description': description, + 'priority': priority, + 'color': color, + }; + } + + String getId(){ + return id; + } + + void setId(String id) { + id = id; + } + + String getTitle() { + return title; + } + + void setTitle(String title) { + title = title; + } + + String getCreationDate() { + return creationDate; + } + + void setCreationDate(String creationDate) { + creationDate = creationDate; + } + + String getLastModificationDate() { + return lastModificationDate; + } + + void setLastModificationDate(String lastModificationDate) { + lastModificationDate = lastModificationDate; + } + + String getExpirationDate() { + return expirationDate; + } + + void setExpirationDate(String expirationDate) { + expirationDate = expirationDate; + } + + String getArrayPromemoria() { + return arrayPromemoria; + } + + void setArrayPromemoria(String arrayPromemoria) { + arrayPromemoria = arrayPromemoria; + } + + String getDescription() { + return description; + } + + void setDescription(String description) { + description = description; + } + + Priority getPriority() { + return priority; + } + + void setPriority(Priority priority) { + priority = priority; + } + + } From 7aa8c8dcbce934556f249fc2ec4601a376fe0b64 Mon Sep 17 00:00:00 2001 From: grata Date: Fri, 29 Sep 2023 09:40:35 +0200 Subject: [PATCH 05/14] Added Firebase --- android/app/build.gradle | 6 +- lib/database/FireDb.dart | 167 ++++++++++++++++++++++++++++++++++++++ lib/main.dart | 5 +- lib/model/note.dart | 55 ++++++++----- lib/model/promemoria.dart | 100 ++++++++++++++++------- pubspec.yaml | 1 + 6 files changed, 285 insertions(+), 49 deletions(-) create mode 100644 lib/database/FireDb.dart diff --git a/android/app/build.gradle b/android/app/build.gradle index ea07413..de67e0c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -2,6 +2,7 @@ plugins { id "com.android.application" id "kotlin-android" id "dev.flutter.flutter-gradle-plugin" + id 'com.google.gms.google-services' } def localProperties = new Properties() @@ -64,4 +65,7 @@ flutter { source '../..' } -dependencies {} +dependencies { + implementation platform('com.google.firebase:firebase-bom:32.3.1') + implementation 'com.google.firebase:firebase-analytics-ktx' +} diff --git a/lib/database/FireDb.dart b/lib/database/FireDb.dart new file mode 100644 index 0000000..a0775a8 --- /dev/null +++ b/lib/database/FireDb.dart @@ -0,0 +1,167 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:flutter/material.dart'; +import 'package:progetto_m335_flutter/model/promemoria.dart'; +import 'package:progetto_m335_flutter/model/note.dart'; + +class FireDb { + + Future createPromemoria(Promemoria promemoria) async { + final docPromemoria = + FirebaseFirestore.instance.collection('promemoria').doc(); + + final json = { + 'id': docPromemoria.id, + 'title': promemoria.getTitle(), + 'creationDate': promemoria.getCreationDate(), + 'lastModificationDate': promemoria.getLastModificationDate(), + 'expirationDate': promemoria.getExpirationDate(), + 'arrayPromemoria': promemoria.getArrayPromemoria(), + 'description': promemoria.getDescription(), + 'priority': promemoria.getPriority(), + 'color': promemoria.getColor(), + }; + + await docPromemoria.set(json); + } + + Future createAllPromemoria(List promemorias) async { + for (var promemoria in promemorias) { + await createPromemoria(promemoria); + } + } + + Future createNote(Note note) async { + final docNote = FirebaseFirestore.instance.collection('note').doc(); + + final json = { + 'id': docNote.id, + 'title': note.getTitle(), + 'creationDate': note.getCreationDate(), + 'lastModificationDate': note.getLastModificationDate(), + 'arrayPromemoria': note.getArrayPromemoria(), + 'description': note.getDescription(), + }; + + await docNote.set(json); + } + + Future createAllNotes(List notes) async { + for (var note in notes) { + await createNote(note); + } + } + + Future> readAllPromemoria() async { + var promemorias = + await FirebaseFirestore.instance.collection('promemoria').get(); + + List promemoriaList = []; + + for (var promemoria in promemorias.docs) { + promemoriaList.add(Promemoria.fromJson(promemoria.data())); + } + + return promemoriaList; + } + + Future> readAllNotes() async { + var notes = await FirebaseFirestore.instance.collection('note').get(); + + List noteList = []; + + for (var note in notes.docs) { + noteList.add(Note.fromJson(note.data())); + } + + return noteList; + } + + Future readNoteById(String id) async { + var docNote = await FirebaseFirestore.instance.collection('note').doc(id); + final snapshot = await docNote.get(); + + if (snapshot.exists) { + return Note.fromJson(snapshot.data()!); + } else { + return null; + } + } + + Future readPromemoriaById(String id) async { + final docPromemoria = + await FirebaseFirestore.instance.collection('promemoria').doc(id); + final snapshot = await docPromemoria.get(); + + if (snapshot.exists) { + return Promemoria.fromJson(snapshot.data()!); + } else { + return null; + } + } + + /* + + Future updateNote(Note note) async { + final docNote = FirebaseFirestore.instance.collection('note').doc(note.getId()); + + final json = { + 'id': note.getId(), + 'title': note.getTitle(), + 'creationDate': note.getCreationDate(), + 'lastModificationDate': note.getLastModificationDate(), + 'arrayPromemoria': note.getArrayPromemoria(), + 'description': note.getDescription(), + }; + + await docNote.update(json); + } + + Future updatePromemoria(Promemoria promemoria) async { + final docPromemoria = FirebaseFirestore.instance.collection('promemoria').doc(promemoria.getId()); + + final json = { + 'id': docPromemoria.id, + 'title': promemoria.getTitle(), + 'creationDate': promemoria.getCreationDate(), + 'lastModificationDate': promemoria.getLastModificationDate(), + 'expirationDate': promemoria.getExpirationDate(), + 'arrayPromemoria': promemoria.getArrayPromemoria(), + 'description': promemoria.getDescription(), + 'priority': promemoria.getPriority(), + 'color': promemoria.getColor(), + }; + + await docPromemoria.update(json); + } + + */ + + Future deleteNoteById(String id) async { + final docNote = FirebaseFirestore.instance.collection('note').doc(id); + + await docNote.delete(); + } + + Future deletePromemoriaById(String id) async { + final docPromemoria = FirebaseFirestore.instance.collection('promemoria').doc(id); + + await docPromemoria.delete(); + } + + Future deleteAllNotes() async { + var notes = await FirebaseFirestore.instance.collection('note').get(); + + for (var note in notes.docs) { + await deleteNoteById(note.id); + } + } + + Future deleteAllPromemoria() async { + var promemorias = await FirebaseFirestore.instance.collection('promemoria').get(); + + for (var promemoria in promemorias.docs) { + await deletePromemoriaById(promemoria.id); + } + } + +} diff --git a/lib/main.dart b/lib/main.dart index 9fac54f..f743340 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,10 @@ +import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'myApp.dart'; -void main() { +Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + await Firebase.initializeApp(); runApp(MyApp()); print("App started"); } diff --git a/lib/model/note.dart b/lib/model/note.dart index 7172796..f6c8b12 100644 --- a/lib/model/note.dart +++ b/lib/model/note.dart @@ -2,13 +2,13 @@ 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 = BaseEntity.getLastEditDate; - static String arrayPromemoria = ''; - static String description = ''; +class Note{ + String id; + String title; + String creationDate; + String lastModificationDate; + String arrayPromemoria; + String description; Map toMap() { return { @@ -21,51 +21,68 @@ class Note extends BaseEntity { }; } + Note( + this.id, + this.title, + this.creationDate, + this.lastModificationDate, + this.arrayPromemoria, + this.description, + ); + String getId() { return id; } - void setId(String id) { - id = id; + void setId(String id1) { + id = id1; } String getTitle() { return title; } - void setTitle(String title) { - title = title; + void setTitle(String title1) { + title = title1; } String getCreationDate() { return creationDate; } - void setCreationDate(String creationDate) { - creationDate = creationDate; + void setCreationDate(String creationDate1) { + creationDate = creationDate1; } String getLastModificationDate() { return lastModificationDate; } - void setLastModificationDate(String lastModificationDate) { - lastModificationDate = lastModificationDate; + void setLastModificationDate(String lastModificationDate1) { + lastModificationDate = lastModificationDate1; } String getArrayPromemoria() { return arrayPromemoria; } - void setArrayPromemoria(String arrayPromemoria) { - arrayPromemoria = arrayPromemoria; + void setArrayPromemoria(String arrayPromemoria1) { + arrayPromemoria = arrayPromemoria1; } String getDescription() { return description; } - void setDescription(String description) { - description = description; + void setDescription(String description1) { + description = description1; } + + static Note fromJson(Map data) => Note( + data['id'], + data['title'], + data['creationDate'], + data['lastModificationDate'], + data['arrayPromemoria'], + data['description']); } diff --git a/lib/model/promemoria.dart b/lib/model/promemoria.dart index d57a9fc..40a5f2f 100644 --- a/lib/model/promemoria.dart +++ b/lib/model/promemoria.dart @@ -4,16 +4,37 @@ import 'identifiers/enum/priority.dart'; 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 arrayPromemoria = ''; - static String description = ''; - static Priority priority = Priority.none; - static Color color = Color.none; +class Promemoria { + String id = ''; + String title; + String creationDate; + String lastModificationDate; + String expirationDate; + String arrayPromemoria; + String description; + String priority; + String color; + + Promemoria( + this.id, + this.title, + this.creationDate, + this.lastModificationDate, + this.expirationDate, + this.arrayPromemoria, + this.description, + this.priority, + this.color); + + Promemoria.newConstructor( + this.title, + this.creationDate, + this.lastModificationDate, + this.expirationDate, + this.arrayPromemoria, + this.description, + this.priority, + this.color); Map toMap() { return { @@ -29,69 +50,92 @@ class Promemoria extends BaseEntity { }; } - String getId(){ + String getId() { return id; } - void setId(String id) { - id = id; + void setId(String id1) { + id = id1; } String getTitle() { return title; } - void setTitle(String title) { - title = title; + void setTitle(String title1) { + title = title1; } String getCreationDate() { return creationDate; } - void setCreationDate(String creationDate) { - creationDate = creationDate; + void setCreationDate(String creationDate1) { + creationDate = creationDate1; } String getLastModificationDate() { return lastModificationDate; } - void setLastModificationDate(String lastModificationDate) { - lastModificationDate = lastModificationDate; + void setLastModificationDate(String lastModificationDate1) { + lastModificationDate = lastModificationDate1; } String getExpirationDate() { return expirationDate; } - void setExpirationDate(String expirationDate) { - expirationDate = expirationDate; + void setExpirationDate(String expirationDate1) { + expirationDate = expirationDate1; } String getArrayPromemoria() { return arrayPromemoria; } - void setArrayPromemoria(String arrayPromemoria) { - arrayPromemoria = arrayPromemoria; + void setArrayPromemoria(String arrayPromemoria1) { + arrayPromemoria = arrayPromemoria1; } String getDescription() { return description; } - void setDescription(String description) { - description = description; + void setDescription(String description1) { + description = description1; } - Priority getPriority() { + String getPriority() { return priority; } - void setPriority(Priority priority) { - priority = priority; + void setPriority(Priority priority1) { + priority = priority1.toString(); } + String getColor() { + return color; + } + void setColor(Color color1) { + color = color1.toString(); + } + + static Promemoria fromJson(Map data) { + Promemoria promemoria = Promemoria( + data['id'], + data['title'], + data['creationDate'], + data['lastModificationDate'], + data['expirationDate'], + data['arrayPromemoria'], + data['description'], + data['priority'], + data['color']); + + print(promemoria.getId().toString()); + + return promemoria; + } } diff --git a/pubspec.yaml b/pubspec.yaml index f735786..4c778b5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,6 +39,7 @@ dependencies: sqflite: ^2.3.0 path: ^1.8.3 sqflite_common_ffi: ^2.3.0+2 + cloud_firestore: ^4.9.2 dev_dependencies: flutter_test: From 039fde6dbe367b1b666208ed0d63a9ec503763bd Mon Sep 17 00:00:00 2001 From: grata Date: Fri, 29 Sep 2023 11:24:08 +0200 Subject: [PATCH 06/14] file strani --- ios/Podfile.lock | 803 ++++++++++++++++++ ios/Runner.xcodeproj/project.pbxproj | 112 +++ .../contents.xcworkspacedata | 3 + 3 files changed, 918 insertions(+) create mode 100644 ios/Podfile.lock diff --git a/ios/Podfile.lock b/ios/Podfile.lock new file mode 100644 index 0000000..28003a7 --- /dev/null +++ b/ios/Podfile.lock @@ -0,0 +1,803 @@ +PODS: + - abseil/algorithm (1.20220623.0): + - abseil/algorithm/algorithm (= 1.20220623.0) + - abseil/algorithm/container (= 1.20220623.0) + - abseil/algorithm/algorithm (1.20220623.0): + - abseil/base/config + - abseil/algorithm/container (1.20220623.0): + - abseil/algorithm/algorithm + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/base (1.20220623.0): + - abseil/base/atomic_hook (= 1.20220623.0) + - abseil/base/base (= 1.20220623.0) + - abseil/base/base_internal (= 1.20220623.0) + - abseil/base/config (= 1.20220623.0) + - abseil/base/core_headers (= 1.20220623.0) + - abseil/base/dynamic_annotations (= 1.20220623.0) + - abseil/base/endian (= 1.20220623.0) + - abseil/base/errno_saver (= 1.20220623.0) + - abseil/base/fast_type_id (= 1.20220623.0) + - abseil/base/log_severity (= 1.20220623.0) + - abseil/base/malloc_internal (= 1.20220623.0) + - abseil/base/prefetch (= 1.20220623.0) + - abseil/base/pretty_function (= 1.20220623.0) + - abseil/base/raw_logging_internal (= 1.20220623.0) + - abseil/base/spinlock_wait (= 1.20220623.0) + - abseil/base/strerror (= 1.20220623.0) + - abseil/base/throw_delegate (= 1.20220623.0) + - abseil/base/atomic_hook (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/base (1.20220623.0): + - abseil/base/atomic_hook + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/base/dynamic_annotations + - abseil/base/log_severity + - abseil/base/raw_logging_internal + - abseil/base/spinlock_wait + - abseil/meta/type_traits + - abseil/base/base_internal (1.20220623.0): + - abseil/base/config + - abseil/meta/type_traits + - abseil/base/config (1.20220623.0) + - abseil/base/core_headers (1.20220623.0): + - abseil/base/config + - abseil/base/dynamic_annotations (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/endian (1.20220623.0): + - abseil/base/base + - abseil/base/config + - abseil/base/core_headers + - abseil/base/errno_saver (1.20220623.0): + - abseil/base/config + - abseil/base/fast_type_id (1.20220623.0): + - abseil/base/config + - abseil/base/log_severity (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/malloc_internal (1.20220623.0): + - abseil/base/base + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/base/dynamic_annotations + - abseil/base/raw_logging_internal + - abseil/base/prefetch (1.20220623.0): + - abseil/base/config + - abseil/base/pretty_function (1.20220623.0) + - abseil/base/raw_logging_internal (1.20220623.0): + - abseil/base/atomic_hook + - abseil/base/config + - abseil/base/core_headers + - abseil/base/errno_saver + - abseil/base/log_severity + - abseil/base/spinlock_wait (1.20220623.0): + - abseil/base/base_internal + - abseil/base/core_headers + - abseil/base/errno_saver + - abseil/base/strerror (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/errno_saver + - abseil/base/throw_delegate (1.20220623.0): + - abseil/base/config + - abseil/base/raw_logging_internal + - abseil/cleanup/cleanup (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/cleanup/cleanup_internal + - abseil/cleanup/cleanup_internal (1.20220623.0): + - abseil/base/base_internal + - abseil/base/core_headers + - abseil/utility/utility + - abseil/container/common (1.20220623.0): + - abseil/meta/type_traits + - abseil/types/optional + - abseil/container/compressed_tuple (1.20220623.0): + - abseil/utility/utility + - abseil/container/container_memory (1.20220623.0): + - abseil/base/config + - abseil/memory/memory + - abseil/meta/type_traits + - abseil/utility/utility + - abseil/container/fixed_array (1.20220623.0): + - abseil/algorithm/algorithm + - abseil/base/config + - abseil/base/core_headers + - abseil/base/dynamic_annotations + - abseil/base/throw_delegate + - abseil/container/compressed_tuple + - abseil/memory/memory + - abseil/container/flat_hash_map (1.20220623.0): + - abseil/algorithm/container + - abseil/base/core_headers + - abseil/container/container_memory + - abseil/container/hash_function_defaults + - abseil/container/raw_hash_map + - abseil/memory/memory + - abseil/container/flat_hash_set (1.20220623.0): + - abseil/algorithm/container + - abseil/base/core_headers + - abseil/container/container_memory + - abseil/container/hash_function_defaults + - abseil/container/raw_hash_set + - abseil/memory/memory + - abseil/container/hash_function_defaults (1.20220623.0): + - abseil/base/config + - abseil/hash/hash + - abseil/strings/cord + - abseil/strings/strings + - abseil/container/hash_policy_traits (1.20220623.0): + - abseil/meta/type_traits + - abseil/container/hashtable_debug_hooks (1.20220623.0): + - abseil/base/config + - abseil/container/hashtablez_sampler (1.20220623.0): + - abseil/base/base + - abseil/base/config + - abseil/base/core_headers + - abseil/debugging/stacktrace + - abseil/memory/memory + - abseil/profiling/exponential_biased + - abseil/profiling/sample_recorder + - abseil/synchronization/synchronization + - abseil/utility/utility + - abseil/container/inlined_vector (1.20220623.0): + - abseil/algorithm/algorithm + - abseil/base/core_headers + - abseil/base/throw_delegate + - abseil/container/inlined_vector_internal + - abseil/memory/memory + - abseil/container/inlined_vector_internal (1.20220623.0): + - abseil/base/core_headers + - abseil/container/compressed_tuple + - abseil/memory/memory + - abseil/meta/type_traits + - abseil/types/span + - abseil/container/layout (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/strings/strings + - abseil/types/span + - abseil/utility/utility + - abseil/container/raw_hash_map (1.20220623.0): + - abseil/base/throw_delegate + - abseil/container/container_memory + - abseil/container/raw_hash_set + - abseil/container/raw_hash_set (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/endian + - abseil/base/prefetch + - abseil/container/common + - abseil/container/compressed_tuple + - abseil/container/container_memory + - abseil/container/hash_policy_traits + - abseil/container/hashtable_debug_hooks + - abseil/container/hashtablez_sampler + - abseil/memory/memory + - abseil/meta/type_traits + - abseil/numeric/bits + - abseil/utility/utility + - abseil/debugging/debugging_internal (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/dynamic_annotations + - abseil/base/errno_saver + - abseil/base/raw_logging_internal + - abseil/debugging/demangle_internal (1.20220623.0): + - abseil/base/base + - abseil/base/config + - abseil/base/core_headers + - abseil/debugging/stacktrace (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/debugging/debugging_internal + - abseil/debugging/symbolize (1.20220623.0): + - abseil/base/base + - abseil/base/config + - abseil/base/core_headers + - abseil/base/dynamic_annotations + - abseil/base/malloc_internal + - abseil/base/raw_logging_internal + - abseil/debugging/debugging_internal + - abseil/debugging/demangle_internal + - abseil/strings/strings + - abseil/functional/any_invocable (1.20220623.0): + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/utility/utility + - abseil/functional/bind_front (1.20220623.0): + - abseil/base/base_internal + - abseil/container/compressed_tuple + - abseil/meta/type_traits + - abseil/utility/utility + - abseil/functional/function_ref (1.20220623.0): + - abseil/base/base_internal + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/hash/city (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/endian + - abseil/hash/hash (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/endian + - abseil/container/fixed_array + - abseil/functional/function_ref + - abseil/hash/city + - abseil/hash/low_level_hash + - abseil/meta/type_traits + - abseil/numeric/int128 + - abseil/strings/strings + - abseil/types/optional + - abseil/types/variant + - abseil/utility/utility + - abseil/hash/low_level_hash (1.20220623.0): + - abseil/base/config + - abseil/base/endian + - abseil/numeric/bits + - abseil/numeric/int128 + - abseil/memory (1.20220623.0): + - abseil/memory/memory (= 1.20220623.0) + - abseil/memory/memory (1.20220623.0): + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/meta (1.20220623.0): + - abseil/meta/type_traits (= 1.20220623.0) + - abseil/meta/type_traits (1.20220623.0): + - abseil/base/config + - abseil/numeric/bits (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/numeric/int128 (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/numeric/bits + - abseil/numeric/representation (1.20220623.0): + - abseil/base/config + - abseil/profiling/exponential_biased (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/profiling/sample_recorder (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/synchronization/synchronization + - abseil/time/time + - abseil/random/distributions (1.20220623.0): + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/numeric/bits + - abseil/random/internal/distribution_caller + - abseil/random/internal/fast_uniform_bits + - abseil/random/internal/fastmath + - abseil/random/internal/generate_real + - abseil/random/internal/iostream_state_saver + - abseil/random/internal/traits + - abseil/random/internal/uniform_helper + - abseil/random/internal/wide_multiply + - abseil/strings/strings + - abseil/random/internal/distribution_caller (1.20220623.0): + - abseil/base/config + - abseil/base/fast_type_id + - abseil/utility/utility + - abseil/random/internal/fast_uniform_bits (1.20220623.0): + - abseil/base/config + - abseil/meta/type_traits + - abseil/random/internal/traits + - abseil/random/internal/fastmath (1.20220623.0): + - abseil/numeric/bits + - abseil/random/internal/generate_real (1.20220623.0): + - abseil/meta/type_traits + - abseil/numeric/bits + - abseil/random/internal/fastmath + - abseil/random/internal/traits + - abseil/random/internal/iostream_state_saver (1.20220623.0): + - abseil/meta/type_traits + - abseil/numeric/int128 + - abseil/random/internal/nonsecure_base (1.20220623.0): + - abseil/base/core_headers + - abseil/container/inlined_vector + - abseil/meta/type_traits + - abseil/random/internal/pool_urbg + - abseil/random/internal/salted_seed_seq + - abseil/random/internal/seed_material + - abseil/types/span + - abseil/random/internal/pcg_engine (1.20220623.0): + - abseil/base/config + - abseil/meta/type_traits + - abseil/numeric/bits + - abseil/numeric/int128 + - abseil/random/internal/fastmath + - abseil/random/internal/iostream_state_saver + - abseil/random/internal/platform (1.20220623.0): + - abseil/base/config + - abseil/random/internal/pool_urbg (1.20220623.0): + - abseil/base/base + - abseil/base/config + - abseil/base/core_headers + - abseil/base/endian + - abseil/base/raw_logging_internal + - abseil/random/internal/randen + - abseil/random/internal/seed_material + - abseil/random/internal/traits + - abseil/random/seed_gen_exception + - abseil/types/span + - abseil/random/internal/randen (1.20220623.0): + - abseil/base/raw_logging_internal + - abseil/random/internal/platform + - abseil/random/internal/randen_hwaes + - abseil/random/internal/randen_slow + - abseil/random/internal/randen_engine (1.20220623.0): + - abseil/base/endian + - abseil/meta/type_traits + - abseil/random/internal/iostream_state_saver + - abseil/random/internal/randen + - abseil/random/internal/randen_hwaes (1.20220623.0): + - abseil/base/config + - abseil/random/internal/platform + - abseil/random/internal/randen_hwaes_impl + - abseil/random/internal/randen_hwaes_impl (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/numeric/int128 + - abseil/random/internal/platform + - abseil/random/internal/randen_slow (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/endian + - abseil/numeric/int128 + - abseil/random/internal/platform + - abseil/random/internal/salted_seed_seq (1.20220623.0): + - abseil/container/inlined_vector + - abseil/meta/type_traits + - abseil/random/internal/seed_material + - abseil/types/optional + - abseil/types/span + - abseil/random/internal/seed_material (1.20220623.0): + - abseil/base/core_headers + - abseil/base/dynamic_annotations + - abseil/base/raw_logging_internal + - abseil/random/internal/fast_uniform_bits + - abseil/strings/strings + - abseil/types/optional + - abseil/types/span + - abseil/random/internal/traits (1.20220623.0): + - abseil/base/config + - abseil/numeric/bits + - abseil/numeric/int128 + - abseil/random/internal/uniform_helper (1.20220623.0): + - abseil/base/config + - abseil/meta/type_traits + - abseil/numeric/int128 + - abseil/random/internal/traits + - abseil/random/internal/wide_multiply (1.20220623.0): + - abseil/base/config + - abseil/numeric/bits + - abseil/numeric/int128 + - abseil/random/internal/traits + - abseil/random/random (1.20220623.0): + - abseil/random/distributions + - abseil/random/internal/nonsecure_base + - abseil/random/internal/pcg_engine + - abseil/random/internal/pool_urbg + - abseil/random/internal/randen_engine + - abseil/random/seed_sequences + - abseil/random/seed_gen_exception (1.20220623.0): + - abseil/base/config + - abseil/random/seed_sequences (1.20220623.0): + - abseil/base/config + - abseil/random/internal/pool_urbg + - abseil/random/internal/salted_seed_seq + - abseil/random/internal/seed_material + - abseil/random/seed_gen_exception + - abseil/types/span + - abseil/status/status (1.20220623.0): + - abseil/base/atomic_hook + - abseil/base/core_headers + - abseil/base/raw_logging_internal + - abseil/base/strerror + - abseil/container/inlined_vector + - abseil/debugging/stacktrace + - abseil/debugging/symbolize + - abseil/functional/function_ref + - abseil/strings/cord + - abseil/strings/str_format + - abseil/strings/strings + - abseil/types/optional + - abseil/status/statusor (1.20220623.0): + - abseil/base/base + - abseil/base/core_headers + - abseil/base/raw_logging_internal + - abseil/meta/type_traits + - abseil/status/status + - abseil/strings/strings + - abseil/types/variant + - abseil/utility/utility + - abseil/strings/cord (1.20220623.0): + - abseil/base/base + - abseil/base/config + - abseil/base/core_headers + - abseil/base/endian + - abseil/base/raw_logging_internal + - abseil/container/fixed_array + - abseil/container/inlined_vector + - abseil/functional/function_ref + - abseil/meta/type_traits + - abseil/numeric/bits + - abseil/strings/cord_internal + - abseil/strings/cordz_functions + - abseil/strings/cordz_info + - abseil/strings/cordz_statistics + - abseil/strings/cordz_update_scope + - abseil/strings/cordz_update_tracker + - abseil/strings/internal + - abseil/strings/str_format + - abseil/strings/strings + - abseil/types/optional + - abseil/types/span + - abseil/strings/cord_internal (1.20220623.0): + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/base/endian + - abseil/base/raw_logging_internal + - abseil/base/throw_delegate + - abseil/container/compressed_tuple + - abseil/container/inlined_vector + - abseil/container/layout + - abseil/functional/function_ref + - abseil/meta/type_traits + - abseil/strings/strings + - abseil/types/span + - abseil/strings/cordz_functions (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/raw_logging_internal + - abseil/profiling/exponential_biased + - abseil/strings/cordz_handle (1.20220623.0): + - abseil/base/base + - abseil/base/config + - abseil/base/raw_logging_internal + - abseil/synchronization/synchronization + - abseil/strings/cordz_info (1.20220623.0): + - abseil/base/base + - abseil/base/config + - abseil/base/core_headers + - abseil/base/raw_logging_internal + - abseil/container/inlined_vector + - abseil/debugging/stacktrace + - abseil/strings/cord_internal + - abseil/strings/cordz_functions + - abseil/strings/cordz_handle + - abseil/strings/cordz_statistics + - abseil/strings/cordz_update_tracker + - abseil/synchronization/synchronization + - abseil/types/span + - abseil/strings/cordz_statistics (1.20220623.0): + - abseil/base/config + - abseil/strings/cordz_update_tracker + - abseil/strings/cordz_update_scope (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/strings/cord_internal + - abseil/strings/cordz_info + - abseil/strings/cordz_update_tracker + - abseil/strings/cordz_update_tracker (1.20220623.0): + - abseil/base/config + - abseil/strings/internal (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/endian + - abseil/base/raw_logging_internal + - abseil/meta/type_traits + - abseil/strings/str_format (1.20220623.0): + - abseil/strings/str_format_internal + - abseil/strings/str_format_internal (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/functional/function_ref + - abseil/meta/type_traits + - abseil/numeric/bits + - abseil/numeric/int128 + - abseil/numeric/representation + - abseil/strings/strings + - abseil/types/optional + - abseil/types/span + - abseil/utility/utility + - abseil/strings/strings (1.20220623.0): + - abseil/base/base + - abseil/base/config + - abseil/base/core_headers + - abseil/base/endian + - abseil/base/raw_logging_internal + - abseil/base/throw_delegate + - abseil/memory/memory + - abseil/meta/type_traits + - abseil/numeric/bits + - abseil/numeric/int128 + - abseil/strings/internal + - abseil/synchronization/graphcycles_internal (1.20220623.0): + - abseil/base/base + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/base/malloc_internal + - abseil/base/raw_logging_internal + - abseil/synchronization/kernel_timeout_internal (1.20220623.0): + - abseil/base/core_headers + - abseil/base/raw_logging_internal + - abseil/time/time + - abseil/synchronization/synchronization (1.20220623.0): + - abseil/base/atomic_hook + - abseil/base/base + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/base/dynamic_annotations + - abseil/base/malloc_internal + - abseil/base/raw_logging_internal + - abseil/debugging/stacktrace + - abseil/debugging/symbolize + - abseil/synchronization/graphcycles_internal + - abseil/synchronization/kernel_timeout_internal + - abseil/time/time + - abseil/time (1.20220623.0): + - abseil/time/internal (= 1.20220623.0) + - abseil/time/time (= 1.20220623.0) + - abseil/time/internal (1.20220623.0): + - abseil/time/internal/cctz (= 1.20220623.0) + - abseil/time/internal/cctz (1.20220623.0): + - abseil/time/internal/cctz/civil_time (= 1.20220623.0) + - abseil/time/internal/cctz/time_zone (= 1.20220623.0) + - abseil/time/internal/cctz/civil_time (1.20220623.0): + - abseil/base/config + - abseil/time/internal/cctz/time_zone (1.20220623.0): + - abseil/base/config + - abseil/time/internal/cctz/civil_time + - abseil/time/time (1.20220623.0): + - abseil/base/base + - abseil/base/core_headers + - abseil/base/raw_logging_internal + - abseil/numeric/int128 + - abseil/strings/strings + - abseil/time/internal/cctz/civil_time + - abseil/time/internal/cctz/time_zone + - abseil/types (1.20220623.0): + - abseil/types/any (= 1.20220623.0) + - abseil/types/bad_any_cast (= 1.20220623.0) + - abseil/types/bad_any_cast_impl (= 1.20220623.0) + - abseil/types/bad_optional_access (= 1.20220623.0) + - abseil/types/bad_variant_access (= 1.20220623.0) + - abseil/types/compare (= 1.20220623.0) + - abseil/types/optional (= 1.20220623.0) + - abseil/types/span (= 1.20220623.0) + - abseil/types/variant (= 1.20220623.0) + - abseil/types/any (1.20220623.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/fast_type_id + - abseil/meta/type_traits + - abseil/types/bad_any_cast + - abseil/utility/utility + - abseil/types/bad_any_cast (1.20220623.0): + - abseil/base/config + - abseil/types/bad_any_cast_impl + - abseil/types/bad_any_cast_impl (1.20220623.0): + - abseil/base/config + - abseil/base/raw_logging_internal + - abseil/types/bad_optional_access (1.20220623.0): + - abseil/base/config + - abseil/base/raw_logging_internal + - abseil/types/bad_variant_access (1.20220623.0): + - abseil/base/config + - abseil/base/raw_logging_internal + - abseil/types/compare (1.20220623.0): + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/types/optional (1.20220623.0): + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/memory/memory + - abseil/meta/type_traits + - abseil/types/bad_optional_access + - abseil/utility/utility + - abseil/types/span (1.20220623.0): + - abseil/algorithm/algorithm + - abseil/base/core_headers + - abseil/base/throw_delegate + - abseil/meta/type_traits + - abseil/types/variant (1.20220623.0): + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/types/bad_variant_access + - abseil/utility/utility + - abseil/utility/utility (1.20220623.0): + - abseil/base/base_internal + - abseil/base/config + - abseil/meta/type_traits + - BoringSSL-GRPC (0.0.24): + - BoringSSL-GRPC/Implementation (= 0.0.24) + - BoringSSL-GRPC/Interface (= 0.0.24) + - BoringSSL-GRPC/Implementation (0.0.24): + - BoringSSL-GRPC/Interface (= 0.0.24) + - BoringSSL-GRPC/Interface (0.0.24) + - cloud_firestore (4.9.2): + - Firebase/Firestore (= 10.15.0) + - firebase_core + - Flutter + - nanopb (< 2.30910.0, >= 2.30908.0) + - Firebase/CoreOnly (10.15.0): + - FirebaseCore (= 10.15.0) + - Firebase/Firestore (10.15.0): + - Firebase/CoreOnly + - FirebaseFirestore (~> 10.15.0) + - firebase_core (2.16.0): + - Firebase/CoreOnly (= 10.15.0) + - Flutter + - FirebaseCore (10.15.0): + - FirebaseCoreInternal (~> 10.0) + - GoogleUtilities/Environment (~> 7.8) + - GoogleUtilities/Logger (~> 7.8) + - FirebaseCoreInternal (10.15.0): + - "GoogleUtilities/NSData+zlib (~> 7.8)" + - FirebaseFirestore (10.15.0): + - abseil/algorithm (~> 1.20220623.0) + - abseil/base (~> 1.20220623.0) + - abseil/container/flat_hash_map (~> 1.20220623.0) + - abseil/memory (~> 1.20220623.0) + - abseil/meta (~> 1.20220623.0) + - abseil/strings/strings (~> 1.20220623.0) + - abseil/time (~> 1.20220623.0) + - abseil/types (~> 1.20220623.0) + - FirebaseCore (~> 10.0) + - "gRPC-C++ (~> 1.50.1)" + - leveldb-library (~> 1.22) + - nanopb (< 2.30910.0, >= 2.30908.0) + - Flutter (1.0.0) + - FMDB (2.7.5): + - FMDB/standard (= 2.7.5) + - FMDB/standard (2.7.5) + - GoogleUtilities/Environment (7.11.5): + - PromisesObjC (< 3.0, >= 1.2) + - GoogleUtilities/Logger (7.11.5): + - GoogleUtilities/Environment + - "GoogleUtilities/NSData+zlib (7.11.5)" + - "gRPC-C++ (1.50.1)": + - "gRPC-C++/Implementation (= 1.50.1)" + - "gRPC-C++/Interface (= 1.50.1)" + - "gRPC-C++/Implementation (1.50.1)": + - abseil/base/base (= 1.20220623.0) + - abseil/base/core_headers (= 1.20220623.0) + - abseil/cleanup/cleanup (= 1.20220623.0) + - abseil/container/flat_hash_map (= 1.20220623.0) + - abseil/container/flat_hash_set (= 1.20220623.0) + - abseil/container/inlined_vector (= 1.20220623.0) + - abseil/functional/any_invocable (= 1.20220623.0) + - abseil/functional/bind_front (= 1.20220623.0) + - abseil/functional/function_ref (= 1.20220623.0) + - abseil/hash/hash (= 1.20220623.0) + - abseil/memory/memory (= 1.20220623.0) + - abseil/meta/type_traits (= 1.20220623.0) + - abseil/random/random (= 1.20220623.0) + - abseil/status/status (= 1.20220623.0) + - abseil/status/statusor (= 1.20220623.0) + - abseil/strings/cord (= 1.20220623.0) + - abseil/strings/str_format (= 1.20220623.0) + - abseil/strings/strings (= 1.20220623.0) + - abseil/synchronization/synchronization (= 1.20220623.0) + - abseil/time/time (= 1.20220623.0) + - abseil/types/optional (= 1.20220623.0) + - abseil/types/span (= 1.20220623.0) + - abseil/types/variant (= 1.20220623.0) + - abseil/utility/utility (= 1.20220623.0) + - "gRPC-C++/Interface (= 1.50.1)" + - gRPC-Core (= 1.50.1) + - "gRPC-C++/Interface (1.50.1)" + - gRPC-Core (1.50.1): + - gRPC-Core/Implementation (= 1.50.1) + - gRPC-Core/Interface (= 1.50.1) + - gRPC-Core/Implementation (1.50.1): + - abseil/base/base (= 1.20220623.0) + - abseil/base/core_headers (= 1.20220623.0) + - abseil/container/flat_hash_map (= 1.20220623.0) + - abseil/container/flat_hash_set (= 1.20220623.0) + - abseil/container/inlined_vector (= 1.20220623.0) + - abseil/functional/any_invocable (= 1.20220623.0) + - abseil/functional/bind_front (= 1.20220623.0) + - abseil/functional/function_ref (= 1.20220623.0) + - abseil/hash/hash (= 1.20220623.0) + - abseil/memory/memory (= 1.20220623.0) + - abseil/meta/type_traits (= 1.20220623.0) + - abseil/random/random (= 1.20220623.0) + - abseil/status/status (= 1.20220623.0) + - abseil/status/statusor (= 1.20220623.0) + - abseil/strings/cord (= 1.20220623.0) + - abseil/strings/str_format (= 1.20220623.0) + - abseil/strings/strings (= 1.20220623.0) + - abseil/synchronization/synchronization (= 1.20220623.0) + - abseil/time/time (= 1.20220623.0) + - abseil/types/optional (= 1.20220623.0) + - abseil/types/span (= 1.20220623.0) + - abseil/types/variant (= 1.20220623.0) + - abseil/utility/utility (= 1.20220623.0) + - BoringSSL-GRPC (= 0.0.24) + - gRPC-Core/Interface (= 1.50.1) + - gRPC-Core/Interface (1.50.1) + - leveldb-library (1.22.2) + - nanopb (2.30909.0): + - nanopb/decode (= 2.30909.0) + - nanopb/encode (= 2.30909.0) + - nanopb/decode (2.30909.0) + - nanopb/encode (2.30909.0) + - PromisesObjC (2.3.1) + - sqflite (0.0.3): + - Flutter + - FMDB (>= 2.7.5) + +DEPENDENCIES: + - cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`) + - firebase_core (from `.symlinks/plugins/firebase_core/ios`) + - Flutter (from `Flutter`) + - sqflite (from `.symlinks/plugins/sqflite/ios`) + +SPEC REPOS: + trunk: + - abseil + - BoringSSL-GRPC + - Firebase + - FirebaseCore + - FirebaseCoreInternal + - FirebaseFirestore + - FMDB + - GoogleUtilities + - "gRPC-C++" + - gRPC-Core + - leveldb-library + - nanopb + - PromisesObjC + +EXTERNAL SOURCES: + cloud_firestore: + :path: ".symlinks/plugins/cloud_firestore/ios" + firebase_core: + :path: ".symlinks/plugins/firebase_core/ios" + Flutter: + :path: Flutter + sqflite: + :path: ".symlinks/plugins/sqflite/ios" + +SPEC CHECKSUMS: + abseil: 926fb7a82dc6d2b8e1f2ed7f3a718bce691d1e46 + BoringSSL-GRPC: 3175b25143e648463a56daeaaa499c6cb86dad33 + cloud_firestore: ac000d8c5a79d57dc69238ea06bb422880fb825e + Firebase: 66043bd4579e5b73811f96829c694c7af8d67435 + firebase_core: 77172d0a9d8d19d07606e24406e4c2fc14d3265b + FirebaseCore: 2cec518b43635f96afe7ac3a9c513e47558abd2e + FirebaseCoreInternal: 2f4bee5ed00301b5e56da0849268797a2dd31fb4 + FirebaseFirestore: b4c0eaaf24efda5732ec21d9e6c788d083118ca6 + Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 + FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a + GoogleUtilities: 13e2c67ede716b8741c7989e26893d151b2b2084 + "gRPC-C++": 0968bace703459fd3e5dcb0b2bed4c573dbff046 + gRPC-Core: 17108291d84332196d3c8466b48f016fc17d816d + leveldb-library: f03246171cce0484482ec291f88b6d563699ee06 + nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431 + PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4 + sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a + +PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189 + +COCOAPODS: 1.13.0 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 8c12c01..50779d4 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -7,7 +7,9 @@ objects = { /* Begin PBXBuildFile section */ + 14598A476CDD143A9163A8D0 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A22145BC7083143C8550C1DF /* Pods_Runner.framework */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 2D769578FD696D1EDCE6D84F /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3537C17B34EEAED6124A6923 /* Pods_RunnerTests.framework */; }; 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 59B838D7BCD1FCB0EF703652 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 543BBA514F0FE7A2C874CB88 /* GoogleService-Info.plist */; }; @@ -43,13 +45,18 @@ /* Begin PBXFileReference section */ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 27CEB3A1A0CD7E4F0CD2D1EE /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 3537C17B34EEAED6124A6923 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 4522E91C2F197AEAF11E6C08 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; 543BBA514F0FE7A2C874CB88 /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 7D249F16ED68C041D85B3071 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; + 9686E1D9CB7869EA9A44F131 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -57,13 +64,25 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A22145BC7083143C8550C1DF /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C58B8C366954D0DE8AA14A33 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + C99E9AAEFDCBB3C6B2126798 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 18D8EA36989EDBC7D3B01AE5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 2D769578FD696D1EDCE6D84F /* Pods_RunnerTests.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 97C146EB1CF9000F007C117D /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 14598A476CDD143A9163A8D0 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -78,6 +97,20 @@ path = RunnerTests; sourceTree = ""; }; + 4746143E2707AFFC395924AD /* Pods */ = { + isa = PBXGroup; + children = ( + 27CEB3A1A0CD7E4F0CD2D1EE /* Pods-Runner.debug.xcconfig */, + 9686E1D9CB7869EA9A44F131 /* Pods-Runner.release.xcconfig */, + C58B8C366954D0DE8AA14A33 /* Pods-Runner.profile.xcconfig */, + 7D249F16ED68C041D85B3071 /* Pods-RunnerTests.debug.xcconfig */, + C99E9AAEFDCBB3C6B2126798 /* Pods-RunnerTests.release.xcconfig */, + 4522E91C2F197AEAF11E6C08 /* Pods-RunnerTests.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -97,6 +130,8 @@ 97C146EF1CF9000F007C117D /* Products */, 331C8082294A63A400263BE5 /* RunnerTests */, 543BBA514F0FE7A2C874CB88 /* GoogleService-Info.plist */, + 4746143E2707AFFC395924AD /* Pods */, + BEF8BC261C065D847E7C23E0 /* Frameworks */, ); sourceTree = ""; }; @@ -124,6 +159,15 @@ path = Runner; sourceTree = ""; }; + BEF8BC261C065D847E7C23E0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + A22145BC7083143C8550C1DF /* Pods_Runner.framework */, + 3537C17B34EEAED6124A6923 /* Pods_RunnerTests.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -131,8 +175,10 @@ isa = PBXNativeTarget; buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; buildPhases = ( + 8A5F9DF6FA4CCC4C75BDDE8A /* [CP] Check Pods Manifest.lock */, 331C807D294A63A400263BE5 /* Sources */, 331C807F294A63A400263BE5 /* Resources */, + 18D8EA36989EDBC7D3B01AE5 /* Frameworks */, ); buildRules = ( ); @@ -148,12 +194,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + A2E3A3F6E09A36780D84C246 /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + 4557F1C65EFFB341DAC93FDF /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -242,6 +290,45 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; + 4557F1C65EFFB341DAC93FDF /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 8A5F9DF6FA4CCC4C75BDDE8A /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; @@ -257,6 +344,28 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; + A2E3A3F6E09A36780D84C246 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -380,6 +489,7 @@ }; 331C8088294A63A400263BE5 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 7D249F16ED68C041D85B3071 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; @@ -397,6 +507,7 @@ }; 331C8089294A63A400263BE5 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = C99E9AAEFDCBB3C6B2126798 /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; @@ -412,6 +523,7 @@ }; 331C808A294A63A400263BE5 /* Profile */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 4522E91C2F197AEAF11E6C08 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; diff --git a/ios/Runner.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcworkspace/contents.xcworkspacedata index 1d526a1..21a3cc1 100644 --- a/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ + + From b75903e3cbe3374f50c7ca65f07f7f9d3f7a4e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20Ku=CC=88ng?= Date: Fri, 29 Sep 2023 11:38:06 +0200 Subject: [PATCH 07/14] work in progress database --- lib/database/controller.dart | 81 +++++++++++++++++++++++ lib/database/database.dart | 120 ++--------------------------------- lib/model/base_entity.dart | 19 ------ lib/model/note.dart | 16 +++-- lib/model/promemoria.dart | 5 +- lib/pages/test.dart | 13 ++++ 6 files changed, 112 insertions(+), 142 deletions(-) create mode 100644 lib/database/controller.dart delete mode 100644 lib/model/base_entity.dart diff --git a/lib/database/controller.dart b/lib/database/controller.dart new file mode 100644 index 0000000..7e01b19 --- /dev/null +++ b/lib/database/controller.dart @@ -0,0 +1,81 @@ +import '../model/note.dart'; +import '../model/promemoria.dart'; +import 'database.dart'; + +class Controller { + NoteDatabase database = NoteDatabase.instance; + + Future> getAllNote() async { + final db = await database.database; + var notes = await db.query(noteTable); + List noteList = notes.map((e) => Note.fromJson(e)).toList(); + return noteList; + } + + Future> getAllPromemoria() async { + final db = await database.database; + var promemorias = await db.query(promemoriaTable); + List promemoriaList = + promemorias.map((e) => Promemoria.fromJson(e)).toList(); + return promemoriaList; + } + + Future getNoteById(int id) async { + final db = await database.database; + var note = await db.query(noteTable, where: 'id = ?', whereArgs: [id]); + return Note.fromJson(note.first); + } + + Future getPromemoriaById(int id) async { + final db = await database.database; + var promemoria = + await db.query(promemoriaTable, where: 'id = ?', whereArgs: [id]); + return Promemoria.fromJson(promemoria.first); + } + + //add note + void addNote(Note note) async { + final db = await database.database; + await db.execute(''' + INSERT INTO note ( + title, + creationDate, + lastModificationDate, + arrayPromemoria, + description + ) VALUES ( + '${note.title}', + '${note.creationDate}', + '${note.lastModificationDate}', + '${note.arrayPromemoria}', + '${note.description}' + ) +'''); + } + + //add Promemoria + void addPromemoria(Promemoria promemoria) async { + final db = await database.database; + await db.execute(''' + INSERT INTO promemoria ( + title, + creationDate, + lastModificationDate, + expirationDate, + arrayPromemoria, + description, + priority, + color + ) VALUES ( + '${promemoria.title}', + '${promemoria.creationDate}', + '${promemoria.lastModificationDate}', + '${promemoria.expirationDate}', + '${promemoria.arrayPromemoria}', + '${promemoria.description}', + '${promemoria.priority}', + '${promemoria.color}' + ) + '''); + } +} diff --git a/lib/database/database.dart b/lib/database/database.dart index 84d67ed..8597e3a 100644 --- a/lib/database/database.dart +++ b/lib/database/database.dart @@ -1,17 +1,12 @@ import 'package:path/path.dart'; import 'package:sqflite/sqflite.dart'; -// Models -import 'package:progetto_m335_flutter/model/note.dart'; import 'package:progetto_m335_flutter/model/promemoria.dart'; class NoteDatabase { static final NoteDatabase instance = NoteDatabase._init(); static Database? _database; - // Zero args constructor needed to extend this class - NoteDatabase(); - NoteDatabase._init(); Future get database async { @@ -29,11 +24,6 @@ class NoteDatabase { } Future _createDB(Database database, int version) async { - if (await isDatabaseExists()) { - print("Database already created"); - deleteDatabase(); - print("Database deleted"); - } await database.execute('''CREATE TABLE promemoria ( id INTEGER PRIMARY KEY AUTOINCREMENT, @@ -64,22 +54,6 @@ class NoteDatabase { Future fillDemoData(Database database, int version) async { - var nota = Note(); - nota.setTitle("Nota 1"); - nota.setCreationDate("2023-09-56"); - nota.setLastModificationDate("2023-09-56"); - nota.setArrayPromemoria("1,2,3,4,5"); - nota.setDescription("Questo è un esempio di nota 1."); - - await createNote(database, nota); - - print(await readNote(1)); - - nota.setDescription("ciao"); - await updateNote (nota); - - print(await readNote (1)); - // Add fake categories await database.execute(''' INSERT INTO note ( @@ -92,6 +66,7 @@ class NoteDatabase { 'Nota 2', '2023-09-28', '2023-09-28', + '1,1', 'Questo è un esempio di nota 2.' ) '''); @@ -107,11 +82,11 @@ class NoteDatabase { 'Nota 2', '2023-09-28', '2023-09-28', + '1,1', 'Questo è un esempio di nota 2.' ) '''); - // Add currencies await database.execute(''' INSERT INTO promemoria ( title, @@ -127,6 +102,7 @@ class NoteDatabase { '2023-09-27', '2023-09-27', '2023-10-05', + '2,1', 'Questo è un esempio di promemoria 1.', 'Alta', 'Rosso' @@ -149,6 +125,7 @@ class NoteDatabase { '2023-09-28', '2023-09-28', '2023-10-10', + '1,1', 'Questo è un esempio di promemoria 2.', 'Media', 'Verde' @@ -157,40 +134,6 @@ class NoteDatabase { print("Demo data inserted"); } - Future clearDatabase() async { - try { - await _database?.transaction((txn) async { - var batch = txn.batch(); - batch.delete(noteTable); - batch.delete(promemoriaTable); - await batch.commit(); - }); - } catch (error) { - throw Exception('DbBase.cleanDatabase: $error'); - } - } - - Future close() async { - final database = await instance.database; - database.close(); - } - - Future deleteDatabase() async { - final databasePath = await getDatabasesPath(); - final path = join(databasePath, 'note.db'); - databaseFactory.deleteDatabase(path); - } - - Future isDatabaseExists() async { - final databasePath = await getDatabasesPath(); - final path = join(databasePath, 'note.db'); - // Apre il database in modalità sola lettura. - Database database = await openDatabase(path, readOnly: true); - - // Restituisce true se il database è stato aperto correttamente, altrimenti false. - return database.isOpen; - } - Future> selectAllPromemoria() async { final db = await database; @@ -199,61 +142,6 @@ class NoteDatabase { return maps; } - Future> selectAllNotes() async { - final db = await database; - final List> maps = await db.query(noteTable); - return maps; - } - - Future createNote(Database database, Note note) async { - await database.insert( - 'note', - note.toMap(), - conflictAlgorithm: ConflictAlgorithm.replace, - ); - - print('note $note.title inserted'); - } - - Future createPromemoria( - Database database, Promemoria promemoria) async { - await database.insert( - 'promemoria', - promemoria.toMap(), - conflictAlgorithm: ConflictAlgorithm.replace, - ); - - print('promemoria $promemoria.title inserted'); - } - - Future> readPromemoria(int id) async { - final db = await database; - - final results = await db.query('SELECT * FROM note where id=$id'); - return results.first; - } - - Future> readNote(int id) async { - final db = await database; - - final results = await db.query('SELECT * FROM promemoria where id=$id'); - - return results.first; - } - - Future updatePromemoria(Promemoria promemoria) async { - final db = await database; - - await db.update('promemoria', promemoria.toMap(), - where: 'id = ?', whereArgs: [promemoria.getId()]); - } - - Future updateNote(Note note) async { - final db = await database; - - await db.update('note', note.toMap(), - where: 'id = ?', whereArgs: [note.getId()]); - } } diff --git a/lib/model/base_entity.dart b/lib/model/base_entity.dart deleted file mode 100644 index 1a0b7b5..0000000 --- a/lib/model/base_entity.dart +++ /dev/null @@ -1,19 +0,0 @@ -abstract class BaseEntity{ - static String id = 'id'; - static String title = 'Title'; - static String creationDate = 'CreationDate'; - static String lastEditDate = 'LastEditDate'; - - static String get getId{ - return id; - } - static String get getTitle{ - return title; - } - static String get getCreationDate{ - return creationDate; - } - static String get getLastEditDate{ - return lastEditDate; - } -} \ No newline at end of file diff --git a/lib/model/note.dart b/lib/model/note.dart index f6c8b12..4949b2c 100644 --- a/lib/model/note.dart +++ b/lib/model/note.dart @@ -1,13 +1,13 @@ -import 'base_entity.dart'; + const String noteTable = 'note'; class Note{ - String id; + String id=''; String title; String creationDate; String lastModificationDate; - String arrayPromemoria; + String? arrayPromemoria; String description; Map toMap() { @@ -30,6 +30,14 @@ class Note{ this.description, ); + Note.newConstructor( + this.title, + this.creationDate, + this.lastModificationDate, + this.arrayPromemoria, + this.description, + ); + String getId() { return id; } @@ -62,7 +70,7 @@ class Note{ lastModificationDate = lastModificationDate1; } - String getArrayPromemoria() { + String? getArrayPromemoria() { return arrayPromemoria; } diff --git a/lib/model/promemoria.dart b/lib/model/promemoria.dart index 40a5f2f..2b2dd24 100644 --- a/lib/model/promemoria.dart +++ b/lib/model/promemoria.dart @@ -1,4 +1,3 @@ -import 'base_entity.dart'; import 'identifiers/enum/color.dart'; import 'identifiers/enum/priority.dart'; @@ -10,7 +9,7 @@ class Promemoria { String creationDate; String lastModificationDate; String expirationDate; - String arrayPromemoria; + String? arrayPromemoria; String description; String priority; String color; @@ -90,7 +89,7 @@ class Promemoria { expirationDate = expirationDate1; } - String getArrayPromemoria() { + String? getArrayPromemoria() { return arrayPromemoria; } diff --git a/lib/pages/test.dart b/lib/pages/test.dart index 7cda250..552a6e4 100644 --- a/lib/pages/test.dart +++ b/lib/pages/test.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:progetto_m335_flutter/database/controller.dart'; import 'package:progetto_m335_flutter/database/database.dart'; import 'package:progetto_m335_flutter/model/note.dart'; @@ -13,6 +14,7 @@ class Test extends StatefulWidget { class _TestState extends State { NoteDatabase noteDatabase = NoteDatabase.instance; + Controller controller = Controller(); Future _pressed() async { print("Inserting demo data"); @@ -22,9 +24,20 @@ class _TestState extends State { } Future _printdata() async { + + + var nota = Note.newConstructor( + "nota 5", + "2023-09-56", + "2023-09-56", + "1,2,3,4,5", + "Questo è un esempio di nota 1."); + + final db = await noteDatabase.database; print("Printing data"); + print((await controller.getAllNote()).first); print(await db.query(noteTable)); print("Data printed"); } From 34a73c62f7f14e808363bb1be95a27e2945e69f3 Mon Sep 17 00:00:00 2001 From: grata Date: Fri, 29 Sep 2023 11:49:21 +0200 Subject: [PATCH 08/14] database work in progress --- lib/model/note.dart | 2 +- lib/model/promemoria.dart | 2 +- lib/pages/test.dart | 24 ++- pubspec.lock | 314 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 338 insertions(+), 4 deletions(-) create mode 100644 pubspec.lock diff --git a/lib/model/note.dart b/lib/model/note.dart index 4949b2c..73baf0e 100644 --- a/lib/model/note.dart +++ b/lib/model/note.dart @@ -87,7 +87,7 @@ class Note{ } static Note fromJson(Map data) => Note( - data['id'], + data['id'].toString(), data['title'], data['creationDate'], data['lastModificationDate'], diff --git a/lib/model/promemoria.dart b/lib/model/promemoria.dart index 2b2dd24..d85cf76 100644 --- a/lib/model/promemoria.dart +++ b/lib/model/promemoria.dart @@ -123,7 +123,7 @@ class Promemoria { static Promemoria fromJson(Map data) { Promemoria promemoria = Promemoria( - data['id'], + data['id'].toString(), data['title'], data['creationDate'], data['lastModificationDate'], diff --git a/lib/pages/test.dart b/lib/pages/test.dart index 552a6e4..6758bc8 100644 --- a/lib/pages/test.dart +++ b/lib/pages/test.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:progetto_m335_flutter/database/controller.dart'; import 'package:progetto_m335_flutter/database/database.dart'; import 'package:progetto_m335_flutter/model/note.dart'; +import 'package:progetto_m335_flutter/model/promemoria.dart'; import '../database/database.dart'; @@ -29,17 +30,36 @@ class _TestState extends State { var nota = Note.newConstructor( "nota 5", "2023-09-56", - "2023-09-56", + "2028-03-1", "1,2,3,4,5", - "Questo è un esempio di nota 1."); + "Questo è un esempio di nota gesu benedetto 1."); + var promemoria = Promemoria.newConstructor( + "promemoria 5", + "2023-09-56", + "2028-03-1", + "2028-03-1", + "1,2,3,4,5", + "Questo è un esempio di promemoria gesu benedetto 1.", + "alta", + "rosso"); + + controller.addNote(nota); + controller.addPromemoria(promemoria); final db = await noteDatabase.database; print("Printing data"); + print((await controller.getAllPromemoria()).first); print((await controller.getAllNote()).first); + print("promemoria"); + print(await db.query(promemoriaTable)); + print("note"); print(await db.query(noteTable)); print("Data printed"); + + + } @override diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..3855ca5 --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,314 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _flutterfire_internals: + dependency: transitive + description: + name: _flutterfire_internals + sha256: "2d8e8e123ca3675625917f535fcc0d3a50092eef44334168f9b18adc050d4c6e" + url: "https://pub.dev" + source: hosted + version: "1.3.6" + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + characters: + dependency: transitive + description: + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" + source: hosted + version: "1.3.0" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + cloud_firestore: + dependency: "direct main" + description: + name: cloud_firestore + sha256: "50e1ffa143fc5c49db1800392f8d9524fd015f9d26a9e4fc01b5ddb1e603e01b" + url: "https://pub.dev" + source: hosted + version: "4.9.2" + cloud_firestore_platform_interface: + dependency: transitive + description: + name: cloud_firestore_platform_interface + sha256: "150e603a40d52b3199e46b1e38d9f8ef8c2dee9e1fb2122d58d456c50015bf7c" + url: "https://pub.dev" + source: hosted + version: "5.16.1" + cloud_firestore_web: + dependency: transitive + description: + name: cloud_firestore_web + sha256: f033aef13b13f94b0f361898df39307d8710859c8912626cfb08e439e350bd66 + url: "https://pub.dev" + source: hosted + version: "3.7.1" + collection: + dependency: transitive + description: + name: collection + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + url: "https://pub.dev" + source: hosted + version: "1.17.2" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d + url: "https://pub.dev" + source: hosted + version: "1.0.6" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + firebase_core: + dependency: "direct main" + description: + name: firebase_core + sha256: "675c209c94a1817649137cbd113fc4c9ae85e48d03dd578629abbec6d8a4d93d" + url: "https://pub.dev" + source: hosted + version: "2.16.0" + firebase_core_platform_interface: + dependency: transitive + description: + name: firebase_core_platform_interface + sha256: b63e3be6c96ef5c33bdec1aab23c91eb00696f6452f0519401d640938c94cba2 + url: "https://pub.dev" + source: hosted + version: "4.8.0" + firebase_core_web: + dependency: transitive + description: + name: firebase_core_web + sha256: e8c408923cd3a25bd342c576a114f2126769cd1a57106a4edeaa67ea4a84e962 + url: "https://pub.dev" + source: hosted + version: "2.8.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + url: "https://pub.dev" + source: hosted + version: "2.0.3" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + lints: + dependency: transitive + description: + name: lints + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + matcher: + dependency: transitive + description: + name: matcher + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" + source: hosted + version: "0.12.16" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" + source: hosted + version: "0.5.0" + meta: + dependency: transitive + description: + name: meta + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + path: + dependency: "direct main" + description: + name: path + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" + source: hosted + version: "1.8.3" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d + url: "https://pub.dev" + source: hosted + version: "2.1.6" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + sqflite: + dependency: "direct main" + description: + name: sqflite + sha256: "591f1602816e9c31377d5f008c2d9ef7b8aca8941c3f89cc5fd9d84da0c38a9a" + url: "https://pub.dev" + source: hosted + version: "2.3.0" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + sha256: "1b92f368f44b0dee2425bb861cfa17b6f6cf3961f762ff6f941d20b33355660a" + url: "https://pub.dev" + source: hosted + version: "2.5.0" + sqflite_common_ffi: + dependency: "direct main" + description: + name: sqflite_common_ffi + sha256: "0d5cc1be2eb18400ac6701c31211d44164393aa75886093002ecdd947be04f93" + url: "https://pub.dev" + source: hosted + version: "2.3.0+2" + sqlite3: + dependency: transitive + description: + name: sqlite3 + sha256: db65233e6b99e99b2548932f55a987961bc06d82a31a0665451fa0b4fff4c3fb + url: "https://pub.dev" + source: hosted + version: "2.1.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" + source: hosted + version: "1.11.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: "5fcbd27688af6082f5abd611af56ee575342c30e87541d0245f7ff99faa02c60" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + url: "https://pub.dev" + source: hosted + version: "0.6.0" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + web: + dependency: transitive + description: + name: web + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + url: "https://pub.dev" + source: hosted + version: "0.1.4-beta" +sdks: + dart: ">=3.1.2 <4.0.0" + flutter: ">=3.3.0" From 67dd09b2dd77a59e7eb92c756317a31269bb2958 Mon Sep 17 00:00:00 2001 From: Tito Arrigo Date: Fri, 29 Sep 2023 11:49:31 +0200 Subject: [PATCH 09/14] new ui model integration --- lib/Components/Reminder.dart | 5 ++--- lib/model/promemoria.dart | 34 +++++++++++++++++++++++++--------- lib/pages/EditReminder.dart | 29 +++++++++++++++++++++-------- lib/pages/TodayView.dart | 9 ++++----- 4 files changed, 52 insertions(+), 25 deletions(-) diff --git a/lib/Components/Reminder.dart b/lib/Components/Reminder.dart index 25fcefd..e9d82d6 100644 --- a/lib/Components/Reminder.dart +++ b/lib/Components/Reminder.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; -import '../Components/EditReminderButton.dart'; import '../model/promemoria.dart'; import '../pages/EditReminder.dart'; @@ -30,12 +29,12 @@ class _ReminderState extends State { value: _value, onChanged: _onChanged, ), - title: Text(widget.promemoria?.description ?? 'Nessun titolo'), + title: Text(widget.promemoria?.getTitle() ?? 'Nessun titolo'), subtitle: Text(DateTime.now().toString()), onTap: () { Navigator.push( context, - MaterialPageRoute(builder: (context) => EditReminder()), + MaterialPageRoute(builder: (context) => EditReminder(widget.promemoria)), ); }, ); diff --git a/lib/model/promemoria.dart b/lib/model/promemoria.dart index 40a5f2f..64a31e0 100644 --- a/lib/model/promemoria.dart +++ b/lib/model/promemoria.dart @@ -6,14 +6,14 @@ const String promemoriaTable = 'promemoria'; class Promemoria { String id = ''; - String title; - String creationDate; - String lastModificationDate; - String expirationDate; - String arrayPromemoria; - String description; - String priority; - String color; + String title = ''; + String creationDate = ''; + String lastModificationDate = ''; + String expirationDate = ''; + String arrayPromemoria = ''; + String description = ''; + String priority = ''; + String color = ''; Promemoria( this.id, @@ -34,7 +34,23 @@ class Promemoria { this.arrayPromemoria, this.description, this.priority, - this.color); + this.color + ); + + Promemoria.today( + this.title, + this.creationDate, + this.lastModificationDate, + this.expirationDate, + this.description, + ); + + Promemoria.inbox( + this.title, + this.creationDate, + this.lastModificationDate, + this.description, + ); Map toMap() { return { diff --git a/lib/pages/EditReminder.dart b/lib/pages/EditReminder.dart index 334012a..2f982ca 100644 --- a/lib/pages/EditReminder.dart +++ b/lib/pages/EditReminder.dart @@ -1,20 +1,26 @@ import 'package:flutter/material.dart'; +import 'package:progetto_m335_flutter/model/promemoria.dart'; class EditReminder extends StatefulWidget { - const EditReminder({super.key}); + final Promemoria? promemoria; + const EditReminder(this.promemoria, {super.key}); @override State createState() => _EditReminderState(); } class _EditReminderState extends State { - String _title = "ciaciao"; - String _description = "description"; + final String _title = "ciaciao"; + String _description = ""; DateTime? _date; //Arraylist of promemoria - - bool _hasDate = true; + @override + void initState() { + // TODO: implement initState + _description = widget.promemoria?.description ?? ""; + super.initState(); + } @override Widget build(BuildContext context) { @@ -27,16 +33,23 @@ class _EditReminderState extends State { padding: EdgeInsets.all(16.0), child: Column( children: [ - TextField( - controller: TextEditingController(text: _title), + TextFormField( + initialValue: widget.promemoria?.title ?? "", decoration: const InputDecoration( border: OutlineInputBorder(), labelText: 'Title', ), + onChanged: (text) { + setState(() { + widget.promemoria?.setTitle(text); + }); + }, ), const SizedBox(height: 10), - TextField( + TextFormField( + initialValue: widget.promemoria?.description ?? "", onChanged: (text) { + print(text); setState(() { _description = text; }); diff --git a/lib/pages/TodayView.dart b/lib/pages/TodayView.dart index 3180a07..1c2c39c 100644 --- a/lib/pages/TodayView.dart +++ b/lib/pages/TodayView.dart @@ -17,9 +17,8 @@ class _TodayViewState extends State { var _selectedDate = DateTime.now(); List listaPromemoria = [ - new Promemoria("Primo promemoria"), - new Promemoria("Secondo promemoria"), - new Promemoria("Terzo promemoria"), + Promemoria.today("Primo promemoria", DateTime.now().toString(), DateTime.now().toString(), DateTime.now().toString(), "Descrizione primo promemoria"), + Promemoria.today("Secondo promemoria", DateTime.now().toString(), DateTime.now().toString(), DateTime.now().toString(), "Descrizione secondo promemoria"), ]; @@ -45,10 +44,10 @@ class _TodayViewState extends State { ListView.builder( scrollDirection: Axis.vertical, shrinkWrap: true, - itemCount: listaPromemoria.length, + itemCount: listaPromemoria?.length, itemBuilder: (BuildContext context, int index){ return Reminder( - listaPromemoria[index] + listaPromemoria?[index] ); }, ), From 8049165f448886921e8893f80f0afbbb1d9ca6e2 Mon Sep 17 00:00:00 2001 From: grata Date: Fri, 29 Sep 2023 13:39:03 +0200 Subject: [PATCH 10/14] collegato lightsql e firebase --- lib/database/controller.dart | 41 +++++++++++ lib/database/database.dart | 127 ++++++----------------------------- lib/main.dart | 8 +++ lib/pages/test.dart | 4 +- 4 files changed, 74 insertions(+), 106 deletions(-) diff --git a/lib/database/controller.dart b/lib/database/controller.dart index 7e01b19..c0f4d64 100644 --- a/lib/database/controller.dart +++ b/lib/database/controller.dart @@ -1,9 +1,14 @@ +import 'package:progetto_m335_flutter/database/FireDb.dart'; + import '../model/note.dart'; import '../model/promemoria.dart'; import 'database.dart'; +import 'package:sqflite/sqflite.dart'; class Controller { NoteDatabase database = NoteDatabase.instance; + FireDb fireDb = FireDb(); + Future> getAllNote() async { final db = await database.database; @@ -78,4 +83,40 @@ class Controller { ) '''); } + + void deleteAll() async { + final db = await database.database; + await db.execute(''' + DELETE FROM promemoria + '''); + + await db.execute(''' + DELETE FROM note + '''); + } + + + void getDataFromFirebase(Database database, int version) async { + this.deleteAll(); + + var promemorias = await fireDb.readAllPromemoria(); + var notes = await fireDb.readAllNotes(); + + for (var promemoria in promemorias) { + this.addPromemoria(promemoria); + } + + for (var note in notes) { + this.addNote(note); + } + } + + void syncData() async { + var promemorias = await this.getAllPromemoria(); + var notes = await this.getAllNote(); + + await fireDb.createAllPromemoria(promemorias); + await fireDb.createAllNotes(notes); + } + } diff --git a/lib/database/database.dart b/lib/database/database.dart index 8597e3a..fc4a6c2 100644 --- a/lib/database/database.dart +++ b/lib/database/database.dart @@ -1,11 +1,14 @@ import 'package:path/path.dart'; import 'package:sqflite/sqflite.dart'; - +import 'FireDb.dart'; import 'package:progetto_m335_flutter/model/promemoria.dart'; +import 'controller.dart'; class NoteDatabase { static final NoteDatabase instance = NoteDatabase._init(); static Database? _database; + FireDb fireDb = FireDb(); + Controller controller = Controller(); NoteDatabase._init(); @@ -24,114 +27,31 @@ class NoteDatabase { } Future _createDB(Database database, int version) async { - await database.execute('''CREATE TABLE promemoria ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - title TEXT NOT NULL, - creationDate TEXT NOT NULL, - lastModificationDate TEXT, - expirationDate TEXT, - arrayPromemoria TEXT, - description TEXT, - priority TEXT, - color TEXT -); + id INTEGER PRIMARY KEY AUTOINCREMENT, + title TEXT NOT NULL, + creationDate TEXT NOT NULL, + lastModificationDate TEXT, + expirationDate TEXT, + arrayPromemoria TEXT, + description TEXT, + priority TEXT, + color TEXT + ); '''); await database.execute('''CREATE TABLE note ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - title TEXT NOT NULL, - creationDate TEXT NOT NULL, - lastModificationDate TEXT, - arrayPromemoria TEXT, - description TEXT -); + id INTEGER PRIMARY KEY AUTOINCREMENT, + title TEXT NOT NULL, + creationDate TEXT NOT NULL, + lastModificationDate TEXT, + arrayPromemoria TEXT, + description TEXT + ); '''); print("database created"); - await fillDemoData(database, version); - } - - Future fillDemoData(Database database, int version) async { - - // Add fake categories - await database.execute(''' - INSERT INTO note ( - title, - creationDate, - lastModificationDate, - arrayPromemoria, - description - ) VALUES ( - 'Nota 2', - '2023-09-28', - '2023-09-28', - '1,1', - 'Questo è un esempio di nota 2.' - ) -'''); - - await database.execute(''' - INSERT INTO note ( - title, - creationDate, - lastModificationDate, - arrayPromemoria, - description - ) VALUES ( - 'Nota 2', - '2023-09-28', - '2023-09-28', - '1,1', - 'Questo è un esempio di nota 2.' - ) -'''); - - await database.execute(''' - INSERT INTO promemoria ( - title, - creationDate, - lastModificationDate, - expirationDate, - arrayPromemoria, - description, - priority, - color - ) VALUES ( - 'Promemoria 1', - '2023-09-27', - '2023-09-27', - '2023-10-05', - '2,1', - 'Questo è un esempio di promemoria 1.', - 'Alta', - 'Rosso' - ) -'''); - - // Add fake budgets - await database.execute(''' - INSERT INTO promemoria ( - title, - creationDate, - lastModificationDate, - expirationDate, - arrayPromemoria, - description, - priority, - color - ) VALUES ( - 'Promemoria 2', - '2023-09-28', - '2023-09-28', - '2023-10-10', - '1,1', - 'Questo è un esempio di promemoria 2.', - 'Media', - 'Verde' - ) -'''); - print("Demo data inserted"); + controller.getDataFromFirebase(database, version); } Future> selectAllPromemoria() async { @@ -141,7 +61,4 @@ class NoteDatabase { return maps; } - - - } diff --git a/lib/main.dart b/lib/main.dart index f743340..54c870f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,10 +1,18 @@ import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; +import 'package:progetto_m335_flutter/database/controller.dart'; import 'myApp.dart'; +import 'dart:async'; + +Timer? timer; Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); runApp(MyApp()); print("App started"); + Controller controller = Controller(); + timer = Timer.periodic(Duration(seconds: 60), (Timer t) => ( + controller.syncData() + )); } diff --git a/lib/pages/test.dart b/lib/pages/test.dart index 6758bc8..5411aaf 100644 --- a/lib/pages/test.dart +++ b/lib/pages/test.dart @@ -58,7 +58,9 @@ class _TestState extends State { print(await db.query(noteTable)); print("Data printed"); - + print("savedata from database to firebase"); + controller.syncData(); + print("data saved"); } From 5b02be9ae759d7dcd7272f5a30b56cbee011a79f Mon Sep 17 00:00:00 2001 From: grata Date: Fri, 29 Sep 2023 14:26:09 +0200 Subject: [PATCH 11/14] removed controller --- lib/database/controller.dart | 122 ----------------------------------- lib/database/database.dart | 110 ++++++++++++++++++++++++++++++- lib/main.dart | 7 -- lib/pages/test.dart | 12 ++-- 4 files changed, 112 insertions(+), 139 deletions(-) delete mode 100644 lib/database/controller.dart diff --git a/lib/database/controller.dart b/lib/database/controller.dart deleted file mode 100644 index c0f4d64..0000000 --- a/lib/database/controller.dart +++ /dev/null @@ -1,122 +0,0 @@ -import 'package:progetto_m335_flutter/database/FireDb.dart'; - -import '../model/note.dart'; -import '../model/promemoria.dart'; -import 'database.dart'; -import 'package:sqflite/sqflite.dart'; - -class Controller { - NoteDatabase database = NoteDatabase.instance; - FireDb fireDb = FireDb(); - - - Future> getAllNote() async { - final db = await database.database; - var notes = await db.query(noteTable); - List noteList = notes.map((e) => Note.fromJson(e)).toList(); - return noteList; - } - - Future> getAllPromemoria() async { - final db = await database.database; - var promemorias = await db.query(promemoriaTable); - List promemoriaList = - promemorias.map((e) => Promemoria.fromJson(e)).toList(); - return promemoriaList; - } - - Future getNoteById(int id) async { - final db = await database.database; - var note = await db.query(noteTable, where: 'id = ?', whereArgs: [id]); - return Note.fromJson(note.first); - } - - Future getPromemoriaById(int id) async { - final db = await database.database; - var promemoria = - await db.query(promemoriaTable, where: 'id = ?', whereArgs: [id]); - return Promemoria.fromJson(promemoria.first); - } - - //add note - void addNote(Note note) async { - final db = await database.database; - await db.execute(''' - INSERT INTO note ( - title, - creationDate, - lastModificationDate, - arrayPromemoria, - description - ) VALUES ( - '${note.title}', - '${note.creationDate}', - '${note.lastModificationDate}', - '${note.arrayPromemoria}', - '${note.description}' - ) -'''); - } - - //add Promemoria - void addPromemoria(Promemoria promemoria) async { - final db = await database.database; - await db.execute(''' - INSERT INTO promemoria ( - title, - creationDate, - lastModificationDate, - expirationDate, - arrayPromemoria, - description, - priority, - color - ) VALUES ( - '${promemoria.title}', - '${promemoria.creationDate}', - '${promemoria.lastModificationDate}', - '${promemoria.expirationDate}', - '${promemoria.arrayPromemoria}', - '${promemoria.description}', - '${promemoria.priority}', - '${promemoria.color}' - ) - '''); - } - - void deleteAll() async { - final db = await database.database; - await db.execute(''' - DELETE FROM promemoria - '''); - - await db.execute(''' - DELETE FROM note - '''); - } - - - void getDataFromFirebase(Database database, int version) async { - this.deleteAll(); - - var promemorias = await fireDb.readAllPromemoria(); - var notes = await fireDb.readAllNotes(); - - for (var promemoria in promemorias) { - this.addPromemoria(promemoria); - } - - for (var note in notes) { - this.addNote(note); - } - } - - void syncData() async { - var promemorias = await this.getAllPromemoria(); - var notes = await this.getAllNote(); - - await fireDb.createAllPromemoria(promemorias); - await fireDb.createAllNotes(notes); - } - -} diff --git a/lib/database/database.dart b/lib/database/database.dart index fc4a6c2..83b0d61 100644 --- a/lib/database/database.dart +++ b/lib/database/database.dart @@ -1,14 +1,13 @@ import 'package:path/path.dart'; import 'package:sqflite/sqflite.dart'; +import '../model/note.dart'; import 'FireDb.dart'; import 'package:progetto_m335_flutter/model/promemoria.dart'; -import 'controller.dart'; class NoteDatabase { static final NoteDatabase instance = NoteDatabase._init(); static Database? _database; FireDb fireDb = FireDb(); - Controller controller = Controller(); NoteDatabase._init(); @@ -51,7 +50,7 @@ class NoteDatabase { '''); print("database created"); - controller.getDataFromFirebase(database, version); + getDataFromFirebase(database, version); } Future> selectAllPromemoria() async { @@ -61,4 +60,109 @@ class NoteDatabase { return maps; } + + Future> getAllNote() async { + var notes = await _database?.query(noteTable); + List noteList = notes!.map((e) => Note.fromJson(e)).toList(); + return noteList; + } + + Future> getAllPromemoria() async { + var promemorias = await _database?.query(promemoriaTable); + List promemoriaList = + promemorias!.map((e) => Promemoria.fromJson(e)).toList(); + return promemoriaList; + } + + Future getNoteById(int id) async { + var note = await _database?.query(noteTable, where: 'id = ?', whereArgs: [id]); + return Note.fromJson(note!.first); + } + + Future getPromemoriaById(int id) async { + var promemoria = + await _database?.query(promemoriaTable, where: 'id = ?', whereArgs: [id]); + return Promemoria.fromJson(promemoria!.first); + } + + //add note + void addNote(Note note) async { + await _database?.execute(''' + INSERT INTO note ( + title, + creationDate, + lastModificationDate, + arrayPromemoria, + description + ) VALUES ( + '${note.title}', + '${note.creationDate}', + '${note.lastModificationDate}', + '${note.arrayPromemoria}', + '${note.description}' + ) +'''); + } + + //add Promemoria + void addPromemoria(Promemoria promemoria) async { + await _database?.execute(''' + INSERT INTO promemoria ( + title, + creationDate, + lastModificationDate, + expirationDate, + arrayPromemoria, + description, + priority, + color + ) VALUES ( + '${promemoria.title}', + '${promemoria.creationDate}', + '${promemoria.lastModificationDate}', + '${promemoria.expirationDate}', + '${promemoria.arrayPromemoria}', + '${promemoria.description}', + '${promemoria.priority}', + '${promemoria.color}' + ) + '''); + } + + void deleteAll() async { + await _database?.execute(''' + DELETE FROM promemoria + '''); + + await _database?.execute(''' + DELETE FROM note + '''); + } + + + void getDataFromFirebase(Database database, int version) async { + this.deleteAll(); + + var promemorias = await fireDb.readAllPromemoria(); + var notes = await fireDb.readAllNotes(); + + for (var promemoria in promemorias) { + this.addPromemoria(promemoria); + } + + for (var note in notes) { + this.addNote(note); + } + } + + void syncData() async { + var promemorias = await getAllPromemoria(); + var notes = await getAllNote(); + + await fireDb.deleteAllPromemoria(); + await fireDb.deleteAllNotes(); + + await fireDb.createAllPromemoria(promemorias); + await fireDb.createAllNotes(notes); + } } diff --git a/lib/main.dart b/lib/main.dart index 54c870f..c254390 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,18 +1,11 @@ import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; -import 'package:progetto_m335_flutter/database/controller.dart'; import 'myApp.dart'; -import 'dart:async'; -Timer? timer; Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); runApp(MyApp()); print("App started"); - Controller controller = Controller(); - timer = Timer.periodic(Duration(seconds: 60), (Timer t) => ( - controller.syncData() - )); } diff --git a/lib/pages/test.dart b/lib/pages/test.dart index 5411aaf..6126e1f 100644 --- a/lib/pages/test.dart +++ b/lib/pages/test.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:progetto_m335_flutter/database/controller.dart'; import 'package:progetto_m335_flutter/database/database.dart'; import 'package:progetto_m335_flutter/model/note.dart'; import 'package:progetto_m335_flutter/model/promemoria.dart'; @@ -15,7 +14,6 @@ class Test extends StatefulWidget { class _TestState extends State { NoteDatabase noteDatabase = NoteDatabase.instance; - Controller controller = Controller(); Future _pressed() async { print("Inserting demo data"); @@ -44,14 +42,14 @@ class _TestState extends State { "alta", "rosso"); - controller.addNote(nota); - controller.addPromemoria(promemoria); + noteDatabase.addNote(nota); + noteDatabase.addPromemoria(promemoria); final db = await noteDatabase.database; print("Printing data"); - print((await controller.getAllPromemoria()).first); - print((await controller.getAllNote()).first); + print((await noteDatabase.getAllPromemoria()).first); + print((await noteDatabase.getAllNote()).first); print("promemoria"); print(await db.query(promemoriaTable)); print("note"); @@ -59,7 +57,7 @@ class _TestState extends State { print("Data printed"); print("savedata from database to firebase"); - controller.syncData(); + noteDatabase.syncData(); print("data saved"); } From 0628fcbbdba4ceb2373526b4ce5696dd03a301e4 Mon Sep 17 00:00:00 2001 From: Tito Arrigo Date: Fri, 29 Sep 2023 14:44:12 +0200 Subject: [PATCH 12/14] bo non lo so --- android/app/google-services.json | 29 +++++++++++++ ios/Runner/GoogleService-Info.plist | 57 +++++++++++--------------- lib/Components/EditReminderButton.dart | 17 -------- lib/Components/QuickReminder.dart | 31 +++++++++++--- lib/Components/Reminder.dart | 2 +- lib/model/promemoria.dart | 17 ++++---- lib/pages/TodayView.dart | 54 ++++++++++++++++-------- 7 files changed, 124 insertions(+), 83 deletions(-) create mode 100644 android/app/google-services.json delete mode 100644 lib/Components/EditReminderButton.dart diff --git a/android/app/google-services.json b/android/app/google-services.json new file mode 100644 index 0000000..0c8bebd --- /dev/null +++ b/android/app/google-services.json @@ -0,0 +1,29 @@ +{ + "project_info": { + "project_number": "1079915493414", + "project_id": "progetto-m335-a4126", + "storage_bucket": "progetto-m335-a4126.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:1079915493414:android:1af31a3970a27c5c5d8ee7", + "android_client_info": { + "package_name": "ch.ameti.progetto_m335_flutter" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyDANiNzXOXgtVKheZnTw7TCw40AFyIznGg" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/ios/Runner/GoogleService-Info.plist b/ios/Runner/GoogleService-Info.plist index 0632985..209e6e5 100644 --- a/ios/Runner/GoogleService-Info.plist +++ b/ios/Runner/GoogleService-Info.plist @@ -2,36 +2,29 @@ - AD_UNIT_ID_FOR_BANNER_TEST - ca-app-pub-3940256099942544/2934735716 - AD_UNIT_ID_FOR_INTERSTITIAL_TEST - ca-app-pub-3940256099942544/4411468910 - CLIENT_ID - test-do-not-use.apps.googleusercontent.com - REVERSED_CLIENT_ID - com.googleusercontent.apps.test-do-not-use - API_KEY - 000000000000000000000000000000000000000 - GCM_SENDER_ID - 999999999999 - PLIST_VERSION - 1 - BUNDLE_ID - com.google.example.BannerExample - IS_ADS_ENABLED - - IS_ANALYTICS_ENABLED - - IS_APPINVITE_ENABLED - - IS_GCM_ENABLED - - IS_SIGNIN_ENABLED - - GOOGLE_APP_ID - 1:999999999999:ios:0000000000000000 - DATABASE_URL - https://test-do-not-use.firebaseio.com + API_KEY + AIzaSyB7BuSBQ9CHuM5C9HalgpOkGf8ZKr70H8M + GCM_SENDER_ID + 1079915493414 + PLIST_VERSION + 1 + BUNDLE_ID + io.flutter.flutter.app + PROJECT_ID + progetto-m335-a4126 + STORAGE_BUCKET + progetto-m335-a4126.appspot.com + IS_ADS_ENABLED + + IS_ANALYTICS_ENABLED + + IS_APPINVITE_ENABLED + + IS_GCM_ENABLED + + IS_SIGNIN_ENABLED + + GOOGLE_APP_ID + 1:1079915493414:ios:3f77c278459dca655d8ee7 - - + \ No newline at end of file diff --git a/lib/Components/EditReminderButton.dart b/lib/Components/EditReminderButton.dart deleted file mode 100644 index cb38d88..0000000 --- a/lib/Components/EditReminderButton.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:flutter/material.dart'; -import '../pages/EditReminder.dart'; - -class EditReminderButton extends StatelessWidget{ - @override - Widget build(BuildContext context) { - return FilledButton( - onPressed: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => EditReminder()), - ); - }, - child: Icon(Icons.list), - ); - } -} diff --git a/lib/Components/QuickReminder.dart b/lib/Components/QuickReminder.dart index 93e71b1..5d4152f 100644 --- a/lib/Components/QuickReminder.dart +++ b/lib/Components/QuickReminder.dart @@ -1,4 +1,7 @@ import 'package:flutter/material.dart'; +import '../database/controller.dart'; +import '../model/promemoria.dart'; +import '../navigation.dart'; class QuickReminder extends StatefulWidget { const QuickReminder({super.key}); @@ -8,18 +11,34 @@ class QuickReminder extends StatefulWidget { } class _QuickReminderState extends State { + Controller controller = Controller(); + @override Widget build(BuildContext context) { - return const ListTile( - leading: Checkbox( + return ListTile( + leading: const Checkbox( value: false, onChanged: null, ), title: TextField( - decoration: InputDecoration( - labelText: 'New Reminder', - ), - ), + decoration: const InputDecoration( + labelText: 'New Reminder', + ), + onSubmitted: (String value) { + controller.addPromemoria(Promemoria.today( + value, + DateTime.now().toString(), + DateTime.now().toString(), + DateTime.now().toString(), + "description")); + Navigator.pushReplacement( + context, + PageRouteBuilder(pageBuilder: (context, animation1, animation2) { + return Navigation(); + }, + transitionDuration: const Duration(seconds: 0)), + ); + }), ); } } diff --git a/lib/Components/Reminder.dart b/lib/Components/Reminder.dart index e9d82d6..51e684c 100644 --- a/lib/Components/Reminder.dart +++ b/lib/Components/Reminder.dart @@ -30,7 +30,7 @@ class _ReminderState extends State { onChanged: _onChanged, ), title: Text(widget.promemoria?.getTitle() ?? 'Nessun titolo'), - subtitle: Text(DateTime.now().toString()), + subtitle: Text(widget.promemoria!.getExpirationDate().toString()), onTap: () { Navigator.push( context, diff --git a/lib/model/promemoria.dart b/lib/model/promemoria.dart index 10ba5ce..75f5261 100644 --- a/lib/model/promemoria.dart +++ b/lib/model/promemoria.dart @@ -1,4 +1,3 @@ -import 'base_entity.dart'; import 'identifiers/enum/color.dart'; import 'identifiers/enum/priority.dart'; @@ -6,14 +5,14 @@ const String promemoriaTable = 'promemoria'; class Promemoria { String id = ''; - String title; - String creationDate; - String lastModificationDate; - String expirationDate; - String? arrayPromemoria; - String description; - String priority; - String color; + String title = ''; + String creationDate = ''; + String lastModificationDate = ''; + String expirationDate = ''; + String? arrayPromemoria = ''; + String description = ''; + String priority = ''; + String color = ''; Promemoria( this.id, diff --git a/lib/pages/TodayView.dart b/lib/pages/TodayView.dart index 1c2c39c..f3f2750 100644 --- a/lib/pages/TodayView.dart +++ b/lib/pages/TodayView.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import '../Components/Reminder.dart'; import '../Components/QuickReminder.dart'; import '../model/promemoria.dart'; +import '../database/controller.dart'; class TodayView extends StatefulWidget { const TodayView({super.key}); @@ -14,14 +15,30 @@ class TodayView extends StatefulWidget { class _TodayViewState extends State { + Controller controller = Controller(); + var _selectedDate = DateTime.now(); - List listaPromemoria = [ + List listaPromemoria = []; + + /*[ Promemoria.today("Primo promemoria", DateTime.now().toString(), DateTime.now().toString(), DateTime.now().toString(), "Descrizione primo promemoria"), Promemoria.today("Secondo promemoria", DateTime.now().toString(), DateTime.now().toString(), DateTime.now().toString(), "Descrizione secondo promemoria"), - ]; + ];*/ + getAllPromemoria() async { + List temp = await controller.getAllPromemoria(); + setState(() { + listaPromemoria = temp; + }); + } + @override + void initState() { + // TODO: implement initState + getAllPromemoria(); + super.initState(); + } @override Widget build(BuildContext context) { @@ -29,30 +46,31 @@ class _TodayViewState extends State { appBar: AppBar( title: FilledButton( onPressed: () async { - DateTime? newDate = await showDatePicker(context: context, initialDate: DateTime.now(), firstDate: DateTime(1), lastDate: DateTime(9999)); + DateTime? newDate = await showDatePicker(context: context, + initialDate: DateTime.now(), + firstDate: DateTime(1), + lastDate: DateTime(9999)); if (newDate != null) { setState(() { _selectedDate = newDate; }); } }, - child: Text(_selectedDate.day.toString() + "/" + _selectedDate.month.toString() + "/" + _selectedDate.year.toString()) + child: Text("${_selectedDate.day}/${_selectedDate.month}/${_selectedDate.year}") ), ), - body: ListView( - children: [ - ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemCount: listaPromemoria?.length, - itemBuilder: (BuildContext context, int index){ - return Reminder( - listaPromemoria?[index] - ); - }, - ), - QuickReminder(), - ], + body: + ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: (listaPromemoria!.length + 1), + itemBuilder: (BuildContext context, int index) { + if (index == listaPromemoria.length) { + return QuickReminder(); + } else { + return Reminder(listaPromemoria[index]); + } + }, ), ); } From de4769cbb85e83aa9187c3e6c3501e1aa02ebb10 Mon Sep 17 00:00:00 2001 From: grata Date: Fri, 29 Sep 2023 15:05:22 +0200 Subject: [PATCH 13/14] removed controller on dev --- lib/Components/QuickReminder.dart | 6 +++--- lib/database/database.dart | 20 ++++++++++++++++++-- lib/pages/TodayView.dart | 8 ++++---- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/lib/Components/QuickReminder.dart b/lib/Components/QuickReminder.dart index 5d4152f..7d0d48c 100644 --- a/lib/Components/QuickReminder.dart +++ b/lib/Components/QuickReminder.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import '../database/controller.dart'; +import 'package:progetto_m335_flutter/database/database.dart'; import '../model/promemoria.dart'; import '../navigation.dart'; @@ -11,7 +11,7 @@ class QuickReminder extends StatefulWidget { } class _QuickReminderState extends State { - Controller controller = Controller(); + NoteDatabase db = NoteDatabase.instance; @override Widget build(BuildContext context) { @@ -25,7 +25,7 @@ class _QuickReminderState extends State { labelText: 'New Reminder', ), onSubmitted: (String value) { - controller.addPromemoria(Promemoria.today( + db.addPromemoria(Promemoria.today( value, DateTime.now().toString(), DateTime.now().toString(), diff --git a/lib/database/database.dart b/lib/database/database.dart index 83b0d61..b754064 100644 --- a/lib/database/database.dart +++ b/lib/database/database.dart @@ -63,14 +63,26 @@ class NoteDatabase { Future> getAllNote() async { var notes = await _database?.query(noteTable); - List noteList = notes!.map((e) => Note.fromJson(e)).toList(); + + if(notes == null) { + return []; + } + + List noteList = notes.map((e) => Note.fromJson(e)).toList(); return noteList; } Future> getAllPromemoria() async { var promemorias = await _database?.query(promemoriaTable); + + if(promemorias == null) { + return []; + } + List promemoriaList = - promemorias!.map((e) => Promemoria.fromJson(e)).toList(); + promemorias.map((e) => Promemoria.fromJson(e)).toList(); + + return promemoriaList; } @@ -102,6 +114,8 @@ class NoteDatabase { '${note.description}' ) '''); + + syncData(); } //add Promemoria @@ -127,6 +141,8 @@ class NoteDatabase { '${promemoria.color}' ) '''); + + syncData(); } void deleteAll() async { diff --git a/lib/pages/TodayView.dart b/lib/pages/TodayView.dart index f3f2750..67f5df5 100644 --- a/lib/pages/TodayView.dart +++ b/lib/pages/TodayView.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; +import 'package:progetto_m335_flutter/database/database.dart'; //import components import '../Components/Reminder.dart'; import '../Components/QuickReminder.dart'; import '../model/promemoria.dart'; -import '../database/controller.dart'; class TodayView extends StatefulWidget { const TodayView({super.key}); @@ -15,19 +15,19 @@ class TodayView extends StatefulWidget { class _TodayViewState extends State { - Controller controller = Controller(); - var _selectedDate = DateTime.now(); List listaPromemoria = []; + NoteDatabase db = NoteDatabase.instance; + /*[ Promemoria.today("Primo promemoria", DateTime.now().toString(), DateTime.now().toString(), DateTime.now().toString(), "Descrizione primo promemoria"), Promemoria.today("Secondo promemoria", DateTime.now().toString(), DateTime.now().toString(), DateTime.now().toString(), "Descrizione secondo promemoria"), ];*/ getAllPromemoria() async { - List temp = await controller.getAllPromemoria(); + List temp = await db.getAllPromemoria() as List; setState(() { listaPromemoria = temp; }); From e07fd0d19105e3a367c43c9800e521a9158c07ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20Ku=CC=88ng?= Date: Fri, 29 Sep 2023 15:12:55 +0200 Subject: [PATCH 14/14] fix init database --- lib/Components/QuickReminder.dart | 7 ++++--- lib/pages/TodayView.dart | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Components/QuickReminder.dart b/lib/Components/QuickReminder.dart index 7d0d48c..371e7f9 100644 --- a/lib/Components/QuickReminder.dart +++ b/lib/Components/QuickReminder.dart @@ -11,7 +11,7 @@ class QuickReminder extends StatefulWidget { } class _QuickReminderState extends State { - NoteDatabase db = NoteDatabase.instance; + NoteDatabase noteDatabase = NoteDatabase.instance; @override Widget build(BuildContext context) { @@ -24,8 +24,9 @@ class _QuickReminderState extends State { decoration: const InputDecoration( labelText: 'New Reminder', ), - onSubmitted: (String value) { - db.addPromemoria(Promemoria.today( + onSubmitted: (String value) async{ + final db = await noteDatabase.database; + noteDatabase.addPromemoria(Promemoria.today( value, DateTime.now().toString(), DateTime.now().toString(), diff --git a/lib/pages/TodayView.dart b/lib/pages/TodayView.dart index 67f5df5..8e85012 100644 --- a/lib/pages/TodayView.dart +++ b/lib/pages/TodayView.dart @@ -19,7 +19,7 @@ class _TodayViewState extends State { List listaPromemoria = []; - NoteDatabase db = NoteDatabase.instance; + NoteDatabase noteDatabase = NoteDatabase.instance; /*[ Promemoria.today("Primo promemoria", DateTime.now().toString(), DateTime.now().toString(), DateTime.now().toString(), "Descrizione primo promemoria"), @@ -27,7 +27,8 @@ class _TodayViewState extends State { ];*/ getAllPromemoria() async { - List temp = await db.getAllPromemoria() as List; + final db = await noteDatabase.database; + List temp = await noteDatabase.getAllPromemoria() as List; setState(() { listaPromemoria = temp; });