Compare commits
25 Commits
controller
...
Zina
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccb56ffa9c | ||
|
|
bf3a9c552d | ||
|
|
c2196663ae | ||
|
|
7d1bec6b0c | ||
|
|
6d9eb5f4db | ||
|
|
b284a3d6d6 | ||
|
|
d69c7ab525 | ||
|
|
c0c090085f | ||
|
|
850497301c | ||
|
|
4121239e36 | ||
|
|
abc0926f49 | ||
|
|
0d53d1421f | ||
|
|
b81cfc70fb | ||
|
|
c2824c99a4 | ||
|
|
e061871c4f | ||
|
|
0fb537d24e | ||
|
|
06a3712d0a | ||
|
|
65ed67b8f6 | ||
|
|
29a54bbcbc | ||
|
|
bf7981671d | ||
|
|
2f851bc630 | ||
|
|
4c4dcc2654 | ||
|
|
330d0e4c61 | ||
|
|
6a05861341 | ||
|
|
4006030f5b |
17
lib/Components/EditReminderButton.dart
Normal file
17
lib/Components/EditReminderButton.dart
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
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),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
27
lib/Components/Note.dart
Normal file
27
lib/Components/Note.dart
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../pages/NoteDetailView.dart';
|
||||||
|
|
||||||
|
class Note extends StatefulWidget {
|
||||||
|
const Note({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<Note> createState() => _NotesViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _NotesViewState extends State<Note> {
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListTile(
|
||||||
|
title: Text("Titolo"),
|
||||||
|
subtitle: Text('Testo'),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).push(
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => const NoteDetailView(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
lib/Components/QuickReminder.dart
Normal file
25
lib/Components/QuickReminder.dart
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class QuickReminder extends StatefulWidget {
|
||||||
|
const QuickReminder({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<QuickReminder> createState() => _QuickReminderState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _QuickReminderState extends State<QuickReminder> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return const ListTile(
|
||||||
|
leading: Checkbox(
|
||||||
|
value: false,
|
||||||
|
onChanged: null,
|
||||||
|
),
|
||||||
|
title: TextField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'New Reminder',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
39
lib/Components/Reminder.dart
Normal file
39
lib/Components/Reminder.dart
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../Components/EditReminderButton.dart';
|
||||||
|
import '../pages/EditReminder.dart';
|
||||||
|
|
||||||
|
class Reminder extends StatefulWidget {
|
||||||
|
const Reminder({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<Reminder> createState() => _ReminderState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ReminderState extends State<Reminder> {
|
||||||
|
bool _value = false;
|
||||||
|
|
||||||
|
void _onChanged(bool? newValue) {
|
||||||
|
setState(() {
|
||||||
|
_value = newValue ?? false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListTile(
|
||||||
|
leading: Checkbox(
|
||||||
|
value: _value,
|
||||||
|
onChanged: _onChanged,
|
||||||
|
),
|
||||||
|
title: Text("Reminder"),
|
||||||
|
subtitle: Text(DateTime.now().toString()),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => EditReminder()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,26 +22,28 @@ class NoteDatabase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Database> _initDB(String filePath) async {
|
Future<Database> _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();
|
final databasePath = await getDatabasesPath();
|
||||||
|
// Directory databasePath = await getApplicationDocumentsDirectory();
|
||||||
|
|
||||||
final path = join(databasePath, filePath);
|
final path = join(databasePath, filePath);
|
||||||
return await openDatabase(path, version: 1, onCreate: _createDB);
|
return await openDatabase(path, version: 1, onCreate: _createDB);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _createDB(Database database, int version) async {
|
Future _createDB(Database database, int version) async {
|
||||||
if (await isDatabaseExists()) {
|
//check if the database is created
|
||||||
|
if (database.query(noteTable) != null) {
|
||||||
print("Database already created");
|
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,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
title TEXT NOT NULL,
|
title TEXT NOT NULL,
|
||||||
creationDate TEXT NOT NULL,
|
creationDate TEXT NOT NULL,
|
||||||
lastModificationDate TEXT,
|
lastModificationDate TEXT,
|
||||||
expirationDate TEXT,
|
expirationDate TEXT,
|
||||||
arrayPromemoria TEXT,
|
|
||||||
description TEXT,
|
description TEXT,
|
||||||
priority TEXT,
|
priority TEXT,
|
||||||
color TEXT
|
color TEXT
|
||||||
@@ -53,32 +55,22 @@ class NoteDatabase {
|
|||||||
title TEXT NOT NULL,
|
title TEXT NOT NULL,
|
||||||
creationDate TEXT NOT NULL,
|
creationDate TEXT NOT NULL,
|
||||||
lastModificationDate TEXT,
|
lastModificationDate TEXT,
|
||||||
arrayPromemoria TEXT,
|
|
||||||
description TEXT
|
description TEXT
|
||||||
);
|
);
|
||||||
''');
|
''');
|
||||||
|
|
||||||
print("database created");
|
print("database created");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
await fillDemoData(database, version);
|
await fillDemoData(database, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future fillDemoData(Database database, int version) async {
|
Future fillDemoData(Database database, int version) async {
|
||||||
|
|
||||||
var nota = Note();
|
print("boh speriamo funzioni");
|
||||||
nota.setTitle("Nota 1");
|
// Add some fake accounts
|
||||||
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
|
// Add fake categories
|
||||||
await database.execute('''
|
await database.execute('''
|
||||||
@@ -86,7 +78,6 @@ class NoteDatabase {
|
|||||||
title,
|
title,
|
||||||
creationDate,
|
creationDate,
|
||||||
lastModificationDate,
|
lastModificationDate,
|
||||||
arrayPromemoria,
|
|
||||||
description
|
description
|
||||||
) VALUES (
|
) VALUES (
|
||||||
'Nota 2',
|
'Nota 2',
|
||||||
@@ -96,12 +87,12 @@ class NoteDatabase {
|
|||||||
)
|
)
|
||||||
''');
|
''');
|
||||||
|
|
||||||
|
|
||||||
await database.execute('''
|
await database.execute('''
|
||||||
INSERT INTO note (
|
INSERT INTO note (
|
||||||
title,
|
title,
|
||||||
creationDate,
|
creationDate,
|
||||||
lastModificationDate,
|
lastModificationDate,
|
||||||
arrayPromemoria,
|
|
||||||
description
|
description
|
||||||
) VALUES (
|
) VALUES (
|
||||||
'Nota 2',
|
'Nota 2',
|
||||||
@@ -118,7 +109,6 @@ class NoteDatabase {
|
|||||||
creationDate,
|
creationDate,
|
||||||
lastModificationDate,
|
lastModificationDate,
|
||||||
expirationDate,
|
expirationDate,
|
||||||
arrayPromemoria,
|
|
||||||
description,
|
description,
|
||||||
priority,
|
priority,
|
||||||
color
|
color
|
||||||
@@ -140,7 +130,6 @@ class NoteDatabase {
|
|||||||
creationDate,
|
creationDate,
|
||||||
lastModificationDate,
|
lastModificationDate,
|
||||||
expirationDate,
|
expirationDate,
|
||||||
arrayPromemoria,
|
|
||||||
description,
|
description,
|
||||||
priority,
|
priority,
|
||||||
color
|
color
|
||||||
@@ -170,27 +159,6 @@ class NoteDatabase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future close() async {
|
|
||||||
final database = await instance.database;
|
|
||||||
database.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> deleteDatabase() async {
|
|
||||||
final databasePath = await getDatabasesPath();
|
|
||||||
final path = join(databasePath, 'note.db');
|
|
||||||
databaseFactory.deleteDatabase(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<bool> 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<List<Map>> selectAllPromemoria() async {
|
Future<List<Map>> selectAllPromemoria() async {
|
||||||
final db = await database;
|
final db = await database;
|
||||||
|
|
||||||
@@ -199,61 +167,15 @@ class NoteDatabase {
|
|||||||
return maps;
|
return maps;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Map>> selectAllNotes() async {
|
Future close() async {
|
||||||
final db = await database;
|
final database = await instance.database;
|
||||||
|
database.close();
|
||||||
final List<Map<String, dynamic>> maps = await db.query(noteTable);
|
|
||||||
|
|
||||||
return maps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> createNote(Database database, Note note) async {
|
// WARNING: FOR DEV/TEST PURPOSES ONLY!!
|
||||||
await database.insert(
|
Future<void> deleteDatabase() async {
|
||||||
'note',
|
final databasePath = await getDatabasesPath();
|
||||||
note.toMap(),
|
final path = join(databasePath, 'note.db');
|
||||||
conflictAlgorithm: ConflictAlgorithm.replace,
|
databaseFactory.deleteDatabase(path);
|
||||||
);
|
|
||||||
|
|
||||||
print('note $note.title inserted');
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> createPromemoria(
|
|
||||||
Database database, Promemoria promemoria) async {
|
|
||||||
await database.insert(
|
|
||||||
'promemoria',
|
|
||||||
promemoria.toMap(),
|
|
||||||
conflictAlgorithm: ConflictAlgorithm.replace,
|
|
||||||
);
|
|
||||||
|
|
||||||
print('promemoria $promemoria.title inserted');
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Map<String, Object?>> readPromemoria(int id) async {
|
|
||||||
final db = await database;
|
|
||||||
|
|
||||||
final results = await db.query('SELECT * FROM note where id=$id');
|
|
||||||
return results.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Map<String, Object?>> readNote(int id) async {
|
|
||||||
final db = await database;
|
|
||||||
|
|
||||||
final results = await db.query('SELECT * FROM promemoria where id=$id');
|
|
||||||
|
|
||||||
return results.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> updatePromemoria(Promemoria promemoria) async {
|
|
||||||
final db = await database;
|
|
||||||
|
|
||||||
await db.update('promemoria', promemoria.toMap(),
|
|
||||||
where: 'id = ?', whereArgs: [promemoria.getId()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> updateNote(Note note) async {
|
|
||||||
final db = await database;
|
|
||||||
|
|
||||||
await db.update('note', note.toMap(),
|
|
||||||
where: 'id = ?', whereArgs: [note.getId()]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'myApp.dart';
|
import '../myApp.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(MyApp());
|
runApp(MyApp());
|
||||||
print("App started");
|
|
||||||
}
|
}
|
||||||
@@ -9,63 +9,4 @@ class Note extends BaseEntity {
|
|||||||
static String lastModificationDate = BaseEntity.getLastEditDate;
|
static String lastModificationDate = BaseEntity.getLastEditDate;
|
||||||
static String arrayPromemoria = '';
|
static String arrayPromemoria = '';
|
||||||
static String description = '';
|
static String description = '';
|
||||||
|
|
||||||
Map<String, dynamic> 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,93 +5,12 @@ import 'identifiers/enum/priority.dart';
|
|||||||
const String promemoriaTable = 'promemoria';
|
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 expirationDate = '';
|
||||||
static String arrayPromemoria = '';
|
static String arrayPromemoria = '';
|
||||||
static String description = '';
|
static String description = '';
|
||||||
static Priority priority = Priority.none;
|
static Priority priority = Priority.none;
|
||||||
|
|
||||||
static Color color = Color.none;
|
static Color color = Color.none;
|
||||||
|
|
||||||
Map<String, dynamic> 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,15 @@ import 'navigation.dart';
|
|||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
const MyApp({ Key? key }) : super(key: key);
|
const MyApp({ Key? key }) : super(key: key);
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'My App',
|
title: 'My App',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
primaryColor: Colors.red,
|
colorSchemeSeed: Colors.blue,
|
||||||
|
|
||||||
|
|
||||||
),
|
),
|
||||||
home: Navigation()
|
home: Navigation()
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import 'dart:ffi';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'pages/testUI.dart';
|
import 'pages/testUI.dart';
|
||||||
import 'pages/TodayView.dart';
|
import 'pages/TodayView.dart';
|
||||||
import 'pages/InboxView.dart';
|
import 'pages/InboxView.dart';
|
||||||
import 'pages/NotesView.dart';
|
import 'pages/NotesView.dart';
|
||||||
import 'pages/test.dart';
|
|
||||||
|
|
||||||
class Navigation extends StatefulWidget {
|
class Navigation extends StatefulWidget {
|
||||||
const Navigation({super.key});
|
const Navigation({super.key});
|
||||||
@@ -16,12 +14,11 @@ class Navigation extends StatefulWidget {
|
|||||||
|
|
||||||
class _NavigationState extends State<Navigation> {
|
class _NavigationState extends State<Navigation> {
|
||||||
|
|
||||||
int _selectedIndex = 3;
|
int _selectedIndex = 0;
|
||||||
static const List<Widget> _widgetOptions = <Widget>[
|
static const List<Widget> _widgetOptions = <Widget>[
|
||||||
TodayView(),
|
TodayView(),
|
||||||
InboxView(),
|
InboxView(),
|
||||||
NotesView(),
|
NotesView(),
|
||||||
Test()
|
|
||||||
];
|
];
|
||||||
|
|
||||||
void _onItemTapped(int index) {
|
void _onItemTapped(int index) {
|
||||||
@@ -33,20 +30,17 @@ class _NavigationState extends State<Navigation> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
body: SafeArea(child: _widgetOptions.elementAt(_selectedIndex)),
|
||||||
title: Text("BottomNavBar"),
|
|
||||||
),
|
|
||||||
body: Center(child: _widgetOptions.elementAt(_selectedIndex)),
|
|
||||||
bottomNavigationBar: BottomNavigationBar(
|
bottomNavigationBar: BottomNavigationBar(
|
||||||
items: const <BottomNavigationBarItem>[
|
items: const <BottomNavigationBarItem>[
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: Icon(Icons.calendar_today), label: "today"),
|
icon: Icon(Icons.today), label: "today"),
|
||||||
BottomNavigationBarItem(icon: Icon(Icons.inbox), label: "Inbox"),
|
BottomNavigationBarItem(icon: Icon(Icons.inbox), label: "Inbox"),
|
||||||
BottomNavigationBarItem(icon: Icon(Icons.note), label: "Notes"),
|
BottomNavigationBarItem(icon: Icon(Icons.note), label: "Notes"),
|
||||||
BottomNavigationBarItem(icon: Icon(Icons.settings), label: "Settings")
|
|
||||||
],
|
],
|
||||||
currentIndex: _selectedIndex,
|
currentIndex: _selectedIndex,
|
||||||
onTap: _onItemTapped,
|
onTap: _onItemTapped,
|
||||||
|
type: BottomNavigationBarType.fixed,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
89
lib/pages/CreateNewNote.dart
Normal file
89
lib/pages/CreateNewNote.dart
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:progetto_m335_flutter/pages/NotesView.dart';
|
||||||
|
|
||||||
|
class CreateNewNote extends StatefulWidget {
|
||||||
|
const CreateNewNote({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CreateNewNote> createState() => _CreateNewNoteState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CreateNewNoteState extends State<CreateNewNote> {
|
||||||
|
TextEditingController _titleController = TextEditingController();
|
||||||
|
TextEditingController _textController = TextEditingController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_titleController.dispose();
|
||||||
|
_textController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text('Create New Note'),
|
||||||
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
TextField(
|
||||||
|
controller: _titleController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'Enter a title',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 16),
|
||||||
|
TextField(
|
||||||
|
controller: _textController,
|
||||||
|
maxLines: null,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'Enter text',
|
||||||
|
border: InputBorder.none,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
const Spacer(),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
print("Delete button pressed");
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
primary: Colors.red,
|
||||||
|
),
|
||||||
|
child: const Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.delete),
|
||||||
|
Text("Delete"),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
String title = _titleController.text;
|
||||||
|
String text = _textController.text;
|
||||||
|
_titleController.clear();
|
||||||
|
_textController.clear();
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: const Text("Save"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
], //
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
134
lib/pages/EditReminder.dart
Normal file
134
lib/pages/EditReminder.dart
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class EditReminder extends StatefulWidget {
|
||||||
|
const EditReminder({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<EditReminder> createState() => _EditReminderState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _EditReminderState extends State<EditReminder> {
|
||||||
|
String _title = "ciaciao";
|
||||||
|
String _description = "description";
|
||||||
|
DateTime? _date;
|
||||||
|
|
||||||
|
//Arraylist of promemoria
|
||||||
|
|
||||||
|
bool _hasDate = true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text("Edit Reminder"),
|
||||||
|
),
|
||||||
|
body: SafeArea(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
TextField(
|
||||||
|
controller: TextEditingController(text: _title),
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
labelText: 'Title',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
TextField(
|
||||||
|
onChanged: (text) {
|
||||||
|
setState(() {
|
||||||
|
_description = text;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
labelText: 'Description',
|
||||||
|
),
|
||||||
|
maxLines: 6,
|
||||||
|
keyboardType: TextInputType.multiline,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
FilledButton(
|
||||||
|
onPressed: () async {
|
||||||
|
DateTime? newDate = await showDatePicker(
|
||||||
|
context: context,
|
||||||
|
initialDate: DateTime.now(),
|
||||||
|
firstDate: DateTime(1),
|
||||||
|
lastDate: DateTime(9999));
|
||||||
|
if (newDate != null) {
|
||||||
|
setState(() {
|
||||||
|
_date = newDate;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Row(children: [
|
||||||
|
if (_date != null) Text("${_date?.day}/${_date?.month}/${_date?.year}"),
|
||||||
|
//if (_date == null) Text("Add Date"),
|
||||||
|
if (_date != null) const SizedBox(width: 10),
|
||||||
|
const Icon(Icons.calendar_month)
|
||||||
|
])),
|
||||||
|
if (_date != null) IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_date = null;
|
||||||
|
});
|
||||||
|
print("setting _date to ${_date}");
|
||||||
|
},
|
||||||
|
icon: Icon(Icons.close)),
|
||||||
|
if (_date == null) TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_date = DateTime.now();
|
||||||
|
});
|
||||||
|
print("setting _date to ${_date}");
|
||||||
|
},
|
||||||
|
child: const Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.add),
|
||||||
|
SizedBox(width: 5),
|
||||||
|
Text("Add Today")
|
||||||
|
],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
const Spacer(),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: FilledButton(
|
||||||
|
onPressed: () {
|
||||||
|
print("ciao");
|
||||||
|
},
|
||||||
|
style: ButtonStyle(
|
||||||
|
backgroundColor:
|
||||||
|
MaterialStateProperty.all(Colors.red)),
|
||||||
|
child: const Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.delete),
|
||||||
|
Text("Delete"),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: FilledButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: const Text("Save"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
//import components
|
||||||
|
import '../Components/Reminder.dart';
|
||||||
|
|
||||||
class InboxView extends StatefulWidget {
|
class InboxView extends StatefulWidget {
|
||||||
const InboxView({super.key});
|
const InboxView({super.key});
|
||||||
|
|
||||||
@@ -10,9 +13,15 @@ class InboxView extends StatefulWidget {
|
|||||||
class _InboxViewState extends State<InboxView> {
|
class _InboxViewState extends State<InboxView> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const Scaffold(
|
return Scaffold(
|
||||||
body: Center(
|
appBar: AppBar(
|
||||||
child: Icon(Icons.inbox),
|
title: const Text('Inbox'),
|
||||||
|
),
|
||||||
|
body: ListView(
|
||||||
|
children: const <Widget>[
|
||||||
|
Reminder(),
|
||||||
|
Reminder(),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,89 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:progetto_m335_flutter/pages/NotesView.dart';
|
||||||
|
|
||||||
class NoteDetailView extends StatefulWidget {
|
class NoteDetailView extends StatefulWidget {
|
||||||
const NoteDetailView({super.key});
|
const NoteDetailView({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<NoteDetailView> createState() => _NoteDetailViewState();
|
State<NoteDetailView> createState() => _NoteDetailViewState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _NoteDetailViewState extends State<NoteDetailView> {
|
class _NoteDetailViewState extends State<NoteDetailView> {
|
||||||
|
TextEditingController _titleController = TextEditingController();
|
||||||
|
TextEditingController _textController = TextEditingController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_titleController.dispose();
|
||||||
|
_textController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const Scaffold(
|
return Scaffold(
|
||||||
body: Center(
|
appBar: AppBar(
|
||||||
child: Text('NoteDetailView'),
|
title: Text('Edit note'),
|
||||||
)
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
TextField(
|
||||||
|
controller: _titleController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'Enter a title',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 16),
|
||||||
|
TextField(
|
||||||
|
controller: _textController,
|
||||||
|
maxLines: null,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'Enter text',
|
||||||
|
border: InputBorder.none,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
const Spacer(),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
print("Delete button pressed");
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
primary: Colors.red,
|
||||||
|
),
|
||||||
|
child: const Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.delete),
|
||||||
|
Text("Delete"),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
String title = _titleController.text;
|
||||||
|
String text = _textController.text;
|
||||||
|
_titleController.clear();
|
||||||
|
_textController.clear();
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: const Text("Save"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
], //
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,41 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import '../Components/Note.dart';
|
||||||
|
import 'CreateNewNote.dart';
|
||||||
|
import 'NoteDetailView.dart';
|
||||||
|
|
||||||
class NotesView extends StatefulWidget {
|
class NotesView extends StatefulWidget {
|
||||||
const NotesView({super.key});
|
const NotesView({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<NotesView> createState() => _NotesViewState();
|
State<NotesView> createState() => _NotesViewState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _NotesViewState extends State<NotesView> {
|
class _NotesViewState extends State<NotesView> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const Scaffold(
|
return Scaffold(
|
||||||
body: Center(
|
appBar: AppBar(
|
||||||
child: Icon(Icons.note),
|
title: Text('Note'),
|
||||||
|
),
|
||||||
|
floatingActionButton: FloatingActionButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).push(
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => const CreateNewNote(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Icon(Icons.add),
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
|
body:ListView(
|
||||||
|
children: const <Widget>[
|
||||||
|
Note(),
|
||||||
|
Note(),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
//import components
|
||||||
|
import '../Components/Reminder.dart';
|
||||||
|
import '../Components/QuickReminder.dart';
|
||||||
|
import '../model/promemoria.dart';
|
||||||
|
|
||||||
class TodayView extends StatefulWidget {
|
class TodayView extends StatefulWidget {
|
||||||
const TodayView({super.key});
|
const TodayView({super.key});
|
||||||
|
|
||||||
@@ -8,12 +13,32 @@ class TodayView extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _TodayViewState extends State<TodayView> {
|
class _TodayViewState extends State<TodayView> {
|
||||||
|
|
||||||
|
var _selectedDate = DateTime.now();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const Scaffold(
|
return Scaffold(
|
||||||
body: Center(
|
appBar: AppBar(
|
||||||
child: Icon(Icons.calendar_today)
|
title: FilledButton(
|
||||||
)
|
onPressed: () async {
|
||||||
|
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())
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: ListView(
|
||||||
|
children: const <Widget>[
|
||||||
|
Reminder(),
|
||||||
|
Reminder(),
|
||||||
|
QuickReminder()
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ environment:
|
|||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
sqflite:
|
||||||
|
path:
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import 'package:progetto_m335_flutter/myApp.dart';
|
|||||||
void main() {
|
void main() {
|
||||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||||
// Build our app and trigger a frame.
|
// Build our app and trigger a frame.
|
||||||
await tester.pumpWidget(const MyApp());
|
|
||||||
|
|
||||||
// Verify that our counter starts at 0.
|
// Verify that our counter starts at 0.
|
||||||
expect(find.text('0'), findsOneWidget);
|
expect(find.text('0'), findsOneWidget);
|
||||||
|
|||||||
Reference in New Issue
Block a user