From 42ae2d1c4c43b5fbc5b3fe93e86b92e4fdd946bc Mon Sep 17 00:00:00 2001 From: Tito Arrigo Date: Fri, 29 Sep 2023 08:28:08 +0200 Subject: [PATCH] grafica quasi finita --- lib/Components/QuickReminder.dart | 25 ++++++ lib/Components/Reminder.dart | 8 +- lib/model/promemoria.dart | 6 +- lib/myApp.dart | 3 + lib/navigation.dart | 3 +- lib/pages/EditReminder.dart | 140 +++++++++++++++++++++++------- lib/pages/InboxView.dart | 15 +++- lib/pages/TodayView.dart | 32 +++++-- 8 files changed, 186 insertions(+), 46 deletions(-) create mode 100644 lib/Components/QuickReminder.dart diff --git a/lib/Components/QuickReminder.dart b/lib/Components/QuickReminder.dart new file mode 100644 index 0000000..93e71b1 --- /dev/null +++ b/lib/Components/QuickReminder.dart @@ -0,0 +1,25 @@ +import 'package:flutter/material.dart'; + +class QuickReminder extends StatefulWidget { + const QuickReminder({super.key}); + + @override + State createState() => _QuickReminderState(); +} + +class _QuickReminderState extends State { + @override + Widget build(BuildContext context) { + return const ListTile( + leading: Checkbox( + value: false, + onChanged: null, + ), + title: TextField( + decoration: InputDecoration( + labelText: 'New Reminder', + ), + ), + ); + } +} diff --git a/lib/Components/Reminder.dart b/lib/Components/Reminder.dart index c9da672..ac59dd5 100644 --- a/lib/Components/Reminder.dart +++ b/lib/Components/Reminder.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import '../Components/EditReminderButton.dart'; +import '../pages/EditReminder.dart'; class Reminder extends StatefulWidget { const Reminder({super.key}); @@ -27,7 +28,12 @@ class _ReminderState extends State { ), title: Text("Reminder"), subtitle: Text(DateTime.now().toString()), - trailing: EditReminderButton(), + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => EditReminder()), + ); + }, ); } } diff --git a/lib/model/promemoria.dart b/lib/model/promemoria.dart index 5326c1d..7061abf 100644 --- a/lib/model/promemoria.dart +++ b/lib/model/promemoria.dart @@ -5,14 +5,12 @@ 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; + + } diff --git a/lib/myApp.dart b/lib/myApp.dart index 9cc3f55..49d3545 100644 --- a/lib/myApp.dart +++ b/lib/myApp.dart @@ -10,6 +10,9 @@ class MyApp extends StatelessWidget { title: 'My App', theme: ThemeData( useMaterial3: true, + colorSchemeSeed: Colors.blue, + + ), home: Navigation() ); diff --git a/lib/navigation.dart b/lib/navigation.dart index b1f2cca..b2ab4c6 100644 --- a/lib/navigation.dart +++ b/lib/navigation.dart @@ -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'; -import 'pages/test.dart'; + class Navigation extends StatefulWidget { const Navigation({super.key}); diff --git a/lib/pages/EditReminder.dart b/lib/pages/EditReminder.dart index cc08858..334012a 100644 --- a/lib/pages/EditReminder.dart +++ b/lib/pages/EditReminder.dart @@ -10,7 +10,12 @@ class EditReminder extends StatefulWidget { class _EditReminderState extends State { String _title = "ciaciao"; String _description = "description"; - DateTime _date = DateTime.now(); + DateTime? _date; + + //Arraylist of promemoria + + bool _hasDate = true; + @override Widget build(BuildContext context) { return Scaffold( @@ -18,37 +23,112 @@ class _EditReminderState extends State { title: Text("Edit Reminder"), ), body: SafeArea( - child: Padding( - padding: EdgeInsets.all(16.0), - child: Column( - children: [ - TextField( - controller: TextEditingController(text: _title), - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Title', - ), + child: Padding( + padding: EdgeInsets.all(16.0), + child: Column( + children: [ + TextField( + controller: TextEditingController(text: _title), + decoration: const InputDecoration( + border: OutlineInputBorder(), + labelText: 'Title', ), - const SizedBox(height: 10), - Expanded(child: TextField( - onChanged: (text) { - setState(() { - _description = text; - }); - }, - controller: TextEditingController(text: _description), - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Description', + ), + 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"), + ], + )), ), - maxLines: 6, - keyboardType: TextInputType.multiline, - ),), - const SizedBox(height: 10), - ], - ), - ) - ), + const SizedBox(width: 10), + Expanded( + child: FilledButton( + onPressed: () { + Navigator.pop(context); + }, + child: const Text("Save"), + ), + ), + ], + ) + ], + ), + )), ); } } diff --git a/lib/pages/InboxView.dart b/lib/pages/InboxView.dart index 4d40bd7..62b429d 100644 --- a/lib/pages/InboxView.dart +++ b/lib/pages/InboxView.dart @@ -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 { @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 [ + Reminder(), + Reminder(), + ], ) ); } diff --git a/lib/pages/TodayView.dart b/lib/pages/TodayView.dart index fe3db07..ef53685 100644 --- a/lib/pages/TodayView.dart +++ b/lib/pages/TodayView.dart @@ -2,7 +2,8 @@ import 'package:flutter/material.dart'; //import components import '../Components/Reminder.dart'; -import '../Components/EditReminderButton.dart'; +import '../Components/QuickReminder.dart'; +import '../model/promemoria.dart'; class TodayView extends StatefulWidget { const TodayView({super.key}); @@ -12,13 +13,32 @@ class TodayView extends StatefulWidget { } class _TodayViewState extends State { + + var _selectedDate = DateTime.now(); + @override Widget build(BuildContext context) { - return ListView( - children: [ - Reminder(), - Reminder(), - ] + 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 [ + Reminder(), + Reminder(), + QuickReminder() + ], + ), ); } }