25 Commits
Joe ... Zina

Author SHA1 Message Date
Giulia
ccb56ffa9c fix notes 2023-09-29 09:52:26 +02:00
Giulia
bf3a9c552d fix 2023-09-29 09:09:26 +02:00
Giulia
c2196663ae Merge remote-tracking branch 'origin/dev' into Zina
# Conflicts:
#	lib/navigation.dart
#	lib/pages/InboxView.dart
#	lib/pages/TodayView.dart
2023-09-29 08:43:10 +02:00
Tito Arrigo
7d1bec6b0c grafica quasi finita 2023-09-29 08:28:08 +02:00
Giulia
6d9eb5f4db fixed style 2023-09-28 14:45:00 +02:00
lama137
b284a3d6d6 TITOOOOOOOOOOOOO 2023-09-28 14:26:17 +02:00
lama137
d69c7ab525 Merge remote-tracking branch 'origin/Tito' into Zina
# Conflicts:
#	lib/database/database.dart
#	lib/model/note.dart
#	lib/model/promemoria.dart
#	lib/navigation.dart
2023-09-28 14:12:20 +02:00
Giulia
c0c090085f create note 2023-09-28 13:57:51 +02:00
Giulia
850497301c Merge remote-tracking branch 'origin/Zina' into Zina
# Conflicts:
#	lib/pages/NotesView.dart
2023-09-28 13:57:19 +02:00
Giulia
4121239e36 create note 2023-09-28 13:56:54 +02:00
Giulia
abc0926f49 create note 2023-09-28 13:55:49 +02:00
lama137
0d53d1421f Aggiornamento note e pulsanti. 2023-09-28 13:22:47 +02:00
Giulia
b81cfc70fb fix 2023-09-28 13:21:02 +02:00
Tito Arrigo
c2824c99a4 merge 2023-09-28 13:04:42 +02:00
Tito Arrigo
e061871c4f grafica pagina TodayView.dart 2023-09-28 11:46:08 +02:00
lama137
0fb537d24e Aggiornamento note e pulsanti. 2023-09-28 11:04:46 +02:00
lama137
06a3712d0a Aggiornamento note e pulsanti. 2023-09-28 11:03:54 +02:00
Giulia
65ed67b8f6 fixed navigation and added create new note page 2023-09-28 10:40:01 +02:00
Tito Arrigo
29a54bbcbc grafica pagina TodayView.dart 2023-09-28 09:49:09 +02:00
Giulia
bf7981671d add note button 2023-09-28 09:07:00 +02:00
lama137
2f851bc630 IDK 2023-09-28 09:02:52 +02:00
lama137
4c4dcc2654 Merge remote-tracking branch 'origin/Joe' into Zina 2023-09-28 08:48:36 +02:00
Tito Arrigo
330d0e4c61 Merge branch 'Tito' into dev 2023-09-27 14:04:34 +02:00
Tito Arrigo
6a05861341 inizzializazione pagine 2023-09-27 14:02:53 +02:00
Tito Arrigo
4006030f5b added GoggleServie-Info.plist 2023-09-27 13:48:10 +02:00
19 changed files with 708 additions and 65 deletions

View 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
View 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(),
),
);
},
);
}
}

View 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',
),
),
);
}
}

View 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()),
);
},
);
}
}

View File

@@ -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<Database> 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<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();
// 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');
}
}
}
Future<List<Map>> selectAllPromemoria() async {
final db = await database;
final List<Map<String, dynamic>> maps = await db.query(promemoriaTable);
return maps;
}
Future close() async {
final database = await instance.database;
database.close();
}
// WARNING: FOR DEV/TEST PURPOSES ONLY!!
Future<void> deleteDatabase() async {
final databasePath = await getDatabasesPath();
final path = join(databasePath, 'note.db');
databaseFactory.deleteDatabase(path);
}
}

View File

@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'myApp.dart';
import '../myApp.dart';
void main() {
runApp(MyApp());
}
}

View File

@@ -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 = '';
}

View File

@@ -1,23 +1,16 @@
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{
static String id = BaseEntity.getId;
static String title = BaseEntity.getTitle;
static String creationDate = BaseEntity.getCreationDate;
static String lastModificationDate = BaseEntity.getLastEditDate;
class Promemoria extends BaseEntity {
static String expirationDate = '';
static String arrayPromemoria = '';
static String description = '';
static Priority priority = Priority.none;
static Color color = Color.none;
}

View File

@@ -10,7 +10,9 @@ class MyApp extends StatelessWidget {
title: 'My App',
theme: ThemeData(
useMaterial3: true,
primaryColor: Colors.red,
colorSchemeSeed: Colors.blue,
),
home: Navigation()
);

View File

@@ -1,11 +1,10 @@
import 'dart:ffi';
import 'package:flutter/material.dart';
import 'pages/testUI.dart';
import 'pages/TodayView.dart';
import 'pages/InboxView.dart';
import 'pages/NotesView.dart';
class Navigation extends StatefulWidget {
const Navigation({super.key});
@@ -31,19 +30,17 @@ class _NavigationState extends State<Navigation> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("BottomNavBar"),
),
body: Center(child: _widgetOptions.elementAt(_selectedIndex)),
body: SafeArea(child: _widgetOptions.elementAt(_selectedIndex)),
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.calendar_today), label: "today"),
BottomNavigationBarItem(icon: Icon(Icons.inbox), label: "Inbox"),
BottomNavigationBarItem(icon: Icon(Icons.note), label: "Notes"),
],
currentIndex: _selectedIndex,
onTap: _onItemTapped,
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.today), label: "today"),
BottomNavigationBarItem(icon: Icon(Icons.inbox), label: "Inbox"),
BottomNavigationBarItem(icon: Icon(Icons.note), label: "Notes"),
],
currentIndex: _selectedIndex,
onTap: _onItemTapped,
type: BottomNavigationBarType.fixed,
),
);
}

View 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
View 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"),
),
),
],
)
],
),
)),
);
}
}

View File

@@ -1,5 +1,8 @@
import 'package:flutter/material.dart';
//import components
import '../Components/Reminder.dart';
class InboxView extends StatefulWidget {
const InboxView({super.key});
@@ -10,9 +13,15 @@ class InboxView extends StatefulWidget {
class _InboxViewState extends State<InboxView> {
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: Icon(Icons.inbox),
return Scaffold(
appBar: AppBar(
title: const Text('Inbox'),
),
body: ListView(
children: const <Widget>[
Reminder(),
Reminder(),
],
)
);
}

View File

@@ -1,19 +1,89 @@
import 'package:flutter/material.dart';
import 'package:progetto_m335_flutter/pages/NotesView.dart';
class NoteDetailView extends StatefulWidget {
const NoteDetailView({super.key});
const NoteDetailView({Key? key}) : super(key: key);
@override
State<NoteDetailView> createState() => _NoteDetailViewState();
}
class _NoteDetailViewState extends State<NoteDetailView> {
TextEditingController _titleController = TextEditingController();
TextEditingController _textController = TextEditingController();
@override
void dispose() {
_titleController.dispose();
_textController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: Text('NoteDetailView'),
)
return Scaffold(
appBar: AppBar(
title: Text('Edit note'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextField(
controller: _titleController,
decoration: InputDecoration(
hintText: 'Enter a title',
),
),
SizedBox(height: 16),
TextField(
controller: _textController,
maxLines: null,
decoration: InputDecoration(
hintText: 'Enter text',
border: InputBorder.none,
),
),
const SizedBox(height: 10),
const Spacer(),
Row(
children: [
Expanded(
child: ElevatedButton(
onPressed: () {
print("Delete button pressed");
},
style: ElevatedButton.styleFrom(
primary: Colors.red,
),
child: const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.delete),
Text("Delete"),
],
),
),
),
const SizedBox(width: 10),
Expanded(
child: ElevatedButton(
onPressed: () {
String title = _titleController.text;
String text = _textController.text;
_titleController.clear();
_textController.clear();
Navigator.pop(context);
},
child: const Text("Save"),
),
),
],
),
], //
),
),
);
}
}

View File

@@ -1,19 +1,42 @@
import 'package:flutter/material.dart';
import '../Components/Note.dart';
import 'CreateNewNote.dart';
import 'NoteDetailView.dart';
class NotesView extends StatefulWidget {
const NotesView({super.key});
const NotesView({Key? key}) : super(key: key);
@override
State<NotesView> createState() => _NotesViewState();
}
class _NotesViewState extends State<NotesView> {
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: Icon(Icons.note),
)
return Scaffold(
appBar: AppBar(
title: Text('Note'),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const CreateNewNote(),
),
);
},
child: Icon(Icons.add),
),
body:ListView(
children: const <Widget>[
Note(),
Note(),
],
)
);
}
}

View File

@@ -1,5 +1,10 @@
import 'package:flutter/material.dart';
//import components
import '../Components/Reminder.dart';
import '../Components/QuickReminder.dart';
import '../model/promemoria.dart';
class TodayView extends StatefulWidget {
const TodayView({super.key});
@@ -8,12 +13,32 @@ class TodayView extends StatefulWidget {
}
class _TodayViewState extends State<TodayView> {
var _selectedDate = DateTime.now();
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: Icon(Icons.calendar_today)
)
return Scaffold(
appBar: AppBar(
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()
],
),
);
}
}

45
lib/pages/test.dart Normal file
View File

@@ -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<Test> createState() => _TestState();
}
class _TestState extends State<Test> {
NoteDatabase noteDatabase = NoteDatabase.instance;
Future<void> _pressed() async {
print("Inserting demo data");
final db = await noteDatabase.database;
}
Future<void> _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)
],
)
)
);
}
}

View File

@@ -30,12 +30,16 @@ environment:
dependencies:
flutter:
sdk: flutter
sqflite:
path:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
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:

View File

@@ -13,7 +13,6 @@ import 'package:progetto_m335_flutter/myApp.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);