From 5c8e3956d03b382a5ad45b047141238d8a5dce2a Mon Sep 17 00:00:00 2001 From: Nathan Fox <58736647+Sergentfox234@users.noreply.github.com> Date: Fri, 15 Apr 2022 18:35:49 -0400 Subject: [PATCH 01/13] Added functionality to the new tabs --- lib/Assignments.dart | 68 ++++++++++++++++++++ lib/Events.dart | 28 +++++++-- lib/Exams.dart | 68 ++++++++++++++++++++ lib/Projects.dart | 73 +++++++++++++++++++++ lib/main.dart | 147 ++++++++++++++++++++++--------------------- 5 files changed, 307 insertions(+), 77 deletions(-) create mode 100644 lib/Assignments.dart create mode 100644 lib/Exams.dart create mode 100644 lib/Projects.dart diff --git a/lib/Assignments.dart b/lib/Assignments.dart new file mode 100644 index 0000000..bf34ee4 --- /dev/null +++ b/lib/Assignments.dart @@ -0,0 +1,68 @@ +import 'package:flutter/material.dart'; +import 'Events.dart'; +import 'dart:collection'; + +class AssignmentsWidget extends StatefulWidget { + final assignmentsList = Queue(); + + AssignmentsWidget({Key? key}) : super(key: key); + + @override + State createState() => AssignmentsState(); +} + +class AssignmentsState extends State { + List assignments = ["HW 1", "HW 2"]; + List checked = [false, false]; + int count = 2; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Center(child: Text("Assignments List")), + ), + body: ListView.builder( + itemCount: count, + itemBuilder: (BuildContext context, int index) { + return Card( + child: CheckboxListTile( + dense: true, + activeColor: Colors.red[400], + controlAffinity: ListTileControlAffinity.leading, + value: checked[index], + onChanged: (value) { + setState(() { + assignments.removeAt(index); + checked.removeAt(index); + count--; + }); + }, + title: Text( + assignments[index], + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20, + color: Color.fromARGB(255, 12, 12, 12)), + ))); + }, + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + setState(() { + count++; + String returnStr = "HW " + count.toString(); + assignments.add(returnStr); + checked.add(false); + }); + }, + child: const Icon( + Icons.add, + size: 45, + color: Colors.white, + ), + backgroundColor: Colors.blueGrey, + ), + ); + } +} diff --git a/lib/Events.dart b/lib/Events.dart index fcdfc5b..95f518a 100644 --- a/lib/Events.dart +++ b/lib/Events.dart @@ -1,7 +1,9 @@ +import 'dart:ffi'; + import 'package:flutter/material.dart'; class Events { - + String type = ""; int monthFrom = 0; int monthTo = 0; int yearFrom = 0; @@ -19,8 +21,22 @@ class Events { String repeat; int weekDay = 0; -Events(this.monthFrom, this.yearFrom, this.dayFrom, this.title, this.timeF, this.timeT, this.dayTo, this.monthTo, this.yearTo, this.color, - this.fromT, this.toT, this.allDay, this.repeat, this.page, this.weekDay); - - -} \ No newline at end of file + Events( + this.monthFrom, + this.yearFrom, + this.dayFrom, + this.title, + this.timeF, + this.timeT, + this.dayTo, + this.monthTo, + this.yearTo, + this.color, + this.fromT, + this.toT, + this.allDay, + this.repeat, + this.page, + this.weekDay, + this.type); +} diff --git a/lib/Exams.dart b/lib/Exams.dart new file mode 100644 index 0000000..09fba42 --- /dev/null +++ b/lib/Exams.dart @@ -0,0 +1,68 @@ +import 'package:flutter/material.dart'; +import 'Events.dart'; +import 'dart:collection'; + +class ExamsWidget extends StatefulWidget { + final projectsList = Queue(); + + ExamsWidget({Key? key}) : super(key: key); + + @override + State createState() => ExamsState(); +} + +class ExamsState extends State { + List exams = ["Exam 1", "Exam 2"]; + int count = 2; + List checked = [false, false]; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Center(child: Text("Exams List")), + ), + body: ListView.builder( + itemCount: count, + itemBuilder: (BuildContext context, int index) { + return Card( + child: CheckboxListTile( + dense: true, + activeColor: Colors.red[400], + controlAffinity: ListTileControlAffinity.leading, + value: checked[index], + onChanged: (value) { + setState(() { + exams.removeAt(index); + checked.removeAt(index); + count--; + }); + }, + title: Text( + exams[index], + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20, + color: Color.fromARGB(255, 12, 12, 12)), + ))); + }, + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + setState(() { + count++; + String returnStr = "Exam " + count.toString(); + exams.add(returnStr); + checked.add(false); + }); + }, + child: const Icon( + Icons.add, + size: 45, + color: Colors.white, + ), + backgroundColor: Colors.blueGrey, + ), + ); + } +} diff --git a/lib/Projects.dart b/lib/Projects.dart new file mode 100644 index 0000000..e953fbc --- /dev/null +++ b/lib/Projects.dart @@ -0,0 +1,73 @@ +import 'dart:async'; +import 'dart:collection'; +import 'package:day_to_day/Inherited.dart'; +import 'package:day_to_day/Months.dart'; +import 'package:flutter/material.dart'; +import 'Events.dart'; +import 'globals.dart' as globals; +import 'package:firebase_database/firebase_database.dart'; + +class ProjectsWidget extends StatefulWidget { + ProjectsWidget({Key? key}) : super(key: key); + + @override + State createState() => ProjectsState(); +} + +class ProjectsState extends State { + List projectsList = ["P1", "P2"]; + int count = 2; + List checked = [false, false]; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Center(child: Text("Projects List")), + ), + body: ListView.builder( + itemCount: count, + itemBuilder: (BuildContext context, int index) { + return Card( + child: CheckboxListTile( + dense: true, + activeColor: Colors.red[400], + controlAffinity: ListTileControlAffinity.leading, + value: checked[index], + onChanged: (value) { + setState(() { + projectsList.removeAt(index); + checked.removeAt(index); + count--; + }); + }, + title: Text( + projectsList[index], + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20, + color: Color.fromARGB(255, 12, 12, 12)), + ))); + }, + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + setState(() { + count++; + String returnStr = "P" + count.toString(); + projectsList.add(returnStr); + checked.add(false); + print(count); + print(projectsList); + }); + }, + child: const Icon( + Icons.add, + size: 45, + color: Colors.white, + ), + backgroundColor: Colors.blueGrey, + ), + ); + } +} diff --git a/lib/main.dart b/lib/main.dart index d9b9fee..35a5124 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,8 @@ import 'package:day_to_day/Inherited.dart'; import 'package:day_to_day/Months.dart'; +import 'package:day_to_day/Projects.dart'; +import 'package:day_to_day/Assignments.dart'; +import 'package:day_to_day/Exams.dart'; import 'package:day_to_day/to_do_list_directory_widget.dart'; import 'package:flutter/material.dart'; import 'package:firebase_database/firebase_database.dart'; @@ -21,63 +24,63 @@ class DayToDay extends StatelessWidget { bool wic = true; @override Widget build(BuildContext context) => InheritedState( - child: MaterialApp( - title: "DayToDay", - theme: ThemeData( - timePickerTheme: TimePickerThemeData( - //backgroundColor: Colors.red[200], - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), - hourMinuteShape: const CircleBorder(), - ), - - brightness: Brightness.light, - scaffoldBackgroundColor: Colors.white, + child: MaterialApp( + title: "DayToDay", + theme: ThemeData( + timePickerTheme: TimePickerThemeData( + //backgroundColor: Colors.red[200], + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20)), + hourMinuteShape: const CircleBorder(), + ), + brightness: Brightness.light, + scaffoldBackgroundColor: Colors.white, - /* light theme settings */ - ), - darkTheme: ThemeData( - timePickerTheme: TimePickerThemeData( - backgroundColor: Colors.grey[900], - dayPeriodTextColor: Colors.white, - entryModeIconColor: Colors.white, - dialTextColor: Colors.white, - hourMinuteTextColor: Colors.white, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), - hourMinuteShape: const CircleBorder(), + /* light theme settings */ ), + darkTheme: ThemeData( + timePickerTheme: TimePickerThemeData( + backgroundColor: Colors.grey[900], + dayPeriodTextColor: Colors.white, + entryModeIconColor: Colors.white, + dialTextColor: Colors.white, + hourMinuteTextColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20)), + hourMinuteShape: const CircleBorder(), + ), colorScheme: ColorScheme.fromSwatch().copyWith( - primary: Colors.red[200], - secondary: Colors.redAccent[200], - brightness: Brightness.dark, + primary: Colors.red[200], + secondary: Colors.redAccent[200], + brightness: Brightness.dark, ), - brightness: Brightness.dark, - - scaffoldBackgroundColor: Colors.black, - ), - themeMode: ThemeMode.system, - /* ThemeMode.system to follow system theme, + brightness: Brightness.dark, + scaffoldBackgroundColor: Colors.black, + ), + themeMode: ThemeMode.system, + /* ThemeMode.system to follow system theme, ThemeMode.light for light theme, ThemeMode.dark for dark theme */ - //home: const MyStatefulWidget(), - home: FutureBuilder( - future: _fbApp, - builder: (context, snapshot) { - if (snapshot.hasError) { - print('You have an error! ${snapshot.error.toString()}'); - return const Text('Something went wrong!'); - } else if (snapshot.hasData) { - return const AppWidget(); - } else { - return const Center( - child: CircularProgressIndicator(), - ); - } - }, + //home: const MyStatefulWidget(), + home: FutureBuilder( + future: _fbApp, + builder: (context, snapshot) { + if (snapshot.hasError) { + print('You have an error! ${snapshot.error.toString()}'); + return const Text('Something went wrong!'); + } else if (snapshot.hasData) { + return const AppWidget(); + } else { + return const Center( + child: CircularProgressIndicator(), + ); + } + }, + ), + debugShowCheckedModeBanner: false, ), - debugShowCheckedModeBanner: false, - ), - ); + ); } class AppWidget extends StatefulWidget { @@ -91,12 +94,12 @@ class _MyStatefulWidgetState extends State with TickerProviderStateMixin { late TabController _tabController; - @override void initState() { super.initState(); - _tabController = TabController(length: 4, vsync: this); + _tabController = TabController(length: 5, vsync: this); } + @override void dispose() { _tabController.dispose(); @@ -119,8 +122,7 @@ class _MyStatefulWidgetState extends State if (darkMode) { appBarC = Colors.grey[800]; appBarT = Colors.white; - } - else { + } else { appBarC = Colors.white10; appBarT = Colors.black; } @@ -140,27 +142,32 @@ class _MyStatefulWidgetState extends State ListTile( title: const Text('Ex1'), onTap: () { - Navigator.pop(context); }, ), ListTile( title: const Text('Ex2'), onTap: () { - Navigator.pop(context); }, ), ], ), ), - floatingActionButton: FloatingActionButton( + /*floatingActionButton: FloatingActionButton( onPressed: () => onAddEventButtonPressed(), - child: const Icon(Icons.add,size: 45, color: Colors.white,), + child: const Icon( + Icons.add, + size: 45, + color: Colors.white, + ), backgroundColor: Colors.blueGrey, - ), + ),*/ appBar: AppBar( - title: Text('DayToDay', style: TextStyle(color: appBarT),), + title: Text( + 'DayToDay', + style: TextStyle(color: appBarT), + ), backgroundColor: appBarC, actions: [ IconButton( @@ -201,29 +208,30 @@ class _MyStatefulWidgetState extends State text: "To-Do", ), const Tab( - text: "Projects", + text: "Assignments", ), const Tab( - text: "Homework", + text: "Projects", ), + const Tab(text: "Exams") ], ), ), body: TabBarView( controller: _tabController, children: [ - CalendarWidget(stream: streamController.stream,), - const ToDoListDirectoryWidget(), - const Center( - child: Text("Projects"), + CalendarWidget( + stream: streamController.stream, ), - const Center( - child: Text("HW"), - ) + const ToDoListDirectoryWidget(), + AssignmentsWidget(), + ProjectsWidget(), + ExamsWidget(), ], ), ); } + void onSearchButtonPressed() {} void onAddEventButtonPressed() { Navigator.of(context).push(MaterialPageRoute(builder: (context) { @@ -232,8 +240,5 @@ class _MyStatefulWidgetState extends State //print(clicked); return const EventForm(); })); - } - - } From b846c5e8193e282a7853b6629067bfa2062611f6 Mon Sep 17 00:00:00 2001 From: Nathan Fox <58736647+Sergentfox234@users.noreply.github.com> Date: Fri, 15 Apr 2022 19:23:39 -0400 Subject: [PATCH 02/13] Fixed the add button for the calendar --- lib/Calendar.dart | 791 +++++++++++++++++++++++---------------------- lib/Inherited.dart | 200 +++++++++--- 2 files changed, 565 insertions(+), 426 deletions(-) diff --git a/lib/Calendar.dart b/lib/Calendar.dart index c3b6da6..4e785ff 100644 --- a/lib/Calendar.dart +++ b/lib/Calendar.dart @@ -3,6 +3,7 @@ import 'package:day_to_day/Inherited.dart'; import 'package:day_to_day/Months.dart'; import 'package:flutter/material.dart'; import 'Events.dart'; +import 'EventForm.dart'; import 'globals.dart' as globals; import 'package:firebase_database/firebase_database.dart'; @@ -51,303 +52,287 @@ class CalendarState extends State { var systemColor = MediaQuery.of(context).platformBrightness; bool darkMode = systemColor == Brightness.dark; - return InheritedState( - child: Column( - children: [ - Expanded( - //Builds separate page for each month of every year since 1980 - child: PageView.builder( - controller: pageController, - scrollDirection: Axis.vertical, - itemBuilder: (BuildContext context, int pages) { - int temporaryM = pages; - - if (clickedPosition == -1) { - clickedPosition = getCurrentDay(); - if (globals.events[getCurrentDay().toString() + - getCurrentMonth().toString() + - getCurrentYear().toString()] != - null) { - globals.events[getCurrentDay().toString() + - getCurrentMonth().toString() + - getCurrentYear().toString()] - ?.forEach((element) { - dayClicked.add(Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - padding: EdgeInsets.only(right: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 15, - width: 2, - ), - Padding(padding: EdgeInsets.only(right: 10)), - Text( - element.title, - style: const TextStyle( - fontWeight: FontWeight.bold, fontSize: 20), - ), - ], - )); - if (element.dayFrom == element.dayTo && - element.monthFrom == element.monthTo && - element.yearFrom == element.yearTo) { - dayClicked.add(Center( - child: Text(element.timeF + " - " + element.timeT), - )); - } else if (element.yearFrom == element.yearTo) { - dayClicked.add(Center( - child: Text( - Months().getMonthShort(element.monthFrom)! + - " " + - element.dayFrom.toString() + - ", " + - element.timeF + - " - " + - Months().getMonthShort(element.monthTo)! + - " " + - element.dayTo.toString() + - ", " + - element.timeT), - )); + return Scaffold( + body: InheritedState( + child: Column( + children: [ + Expanded( + //Builds separate page for each month of every year since 1980 + child: PageView.builder( + controller: pageController, + scrollDirection: Axis.vertical, + itemBuilder: (BuildContext context, int pages) { + int temporaryM = pages; + + if (clickedPosition == -1) { + clickedPosition = getCurrentDay(); + if (globals.events[getCurrentDay().toString() + + getCurrentMonth().toString() + + getCurrentYear().toString()] != + null) { + globals.events[getCurrentDay().toString() + + getCurrentMonth().toString() + + getCurrentYear().toString()] + ?.forEach((element) { + dayClicked.add(Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + padding: EdgeInsets.only(right: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 15, + width: 2, + ), + Padding(padding: EdgeInsets.only(right: 10)), + Text( + element.title, + style: const TextStyle( + fontWeight: FontWeight.bold, fontSize: 20), + ), + ], + )); + if (element.dayFrom == element.dayTo && + element.monthFrom == element.monthTo && + element.yearFrom == element.yearTo) { + dayClicked.add(Center( + child: + Text(element.timeF + " - " + element.timeT), + )); + } else if (element.yearFrom == element.yearTo) { + dayClicked.add(Center( + child: Text( + Months().getMonthShort(element.monthFrom)! + + " " + + element.dayFrom.toString() + + ", " + + element.timeF + + " - " + + Months().getMonthShort(element.monthTo)! + + " " + + element.dayTo.toString() + + ", " + + element.timeT), + )); + } else { + dayClicked.add(Center( + child: Text( + Months().getMonthShort(element.monthFrom)! + + " " + + element.dayFrom.toString() + + ", " + + element.yearFrom.toString() + + ", " + + element.timeF + + " - " + + Months().getMonthShort(element.monthTo)! + + " " + + element.dayTo.toString() + + ", " + + element.yearTo.toString() + + ", " + + element.timeT), + )); + } + }); } else { - dayClicked.add(Center( - child: Text( - Months().getMonthShort(element.monthFrom)! + - " " + - element.dayFrom.toString() + - ", " + - element.yearFrom.toString() + - ", " + - element.timeF + - " - " + - Months().getMonthShort(element.monthTo)! + - " " + - element.dayTo.toString() + - ", " + - element.yearTo.toString() + - ", " + - element.timeT), - )); + dayClicked.add(const Text("No events today")); } + } + + int yearsPassed = 1; + if (pages > 12) { + temporaryM = (temporaryM % 12) + 1; + } + int userMonth = temporaryM; + temporaryM = pages; + + var yearEarly = 1980; + yearsPassed = (pages / 12).floor(); + int earlyYear = yearEarly + yearsPassed; + String monthIAmIn = n.currentMonth; + if (n.now.month == userMonth && n.now.year == earlyYear) { + monthView = n; + } else { + monthView = Months.otherYears(userMonth, earlyYear); + } + int mdw = monthView.monthStart; + if (monthView.monthStart == 7) { + mdw = 0; + } + monthIAmIn = n.month[userMonth].toString(); + + String year = (yearEarly + yearsPassed).toString(); + + if (getCurrentYear().toString() == year) { + year = ""; + } + Color clickedColor = Colors.white70; + pageController.addListener(() { + clickedPosition = -2; }); - } else { - dayClicked.add(const Text("No events today")); - } - } - - int yearsPassed = 1; - if (pages > 12) { - temporaryM = (temporaryM % 12) + 1; - } - int userMonth = temporaryM; - temporaryM = pages; - - var yearEarly = 1980; - yearsPassed = (pages / 12).floor(); - int earlyYear = yearEarly + yearsPassed; - String monthIAmIn = n.currentMonth; - if (n.now.month == userMonth && n.now.year == earlyYear) { - monthView = n; - } else { - monthView = Months.otherYears(userMonth, earlyYear); - } - int mdw = monthView.monthStart; - if (monthView.monthStart == 7) { - mdw = 0; - } - monthIAmIn = n.month[userMonth].toString(); - - String year = (yearEarly + yearsPassed).toString(); - - if (getCurrentYear().toString() == year) { - year = ""; - } - Color clickedColor = Colors.white70; - pageController.addListener(() { - clickedPosition = -2; - }); - return Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( + return Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ - Center( - child: InkWell( - child: Container( - padding: - const EdgeInsets.only(bottom: 16, top: 10), - child: Align( - alignment: Alignment.center, - child: Text( - monthIAmIn + ' ' + year, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 25), + Row( + children: [ + Center( + child: InkWell( + child: Container( + padding: const EdgeInsets.only( + bottom: 16, top: 10), + child: Align( + alignment: Alignment.center, + child: Text( + monthIAmIn + ' ' + year, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 25), + ), + ), ), + onTap: () { + onYearPressed(context, pageController); + }, + borderRadius: BorderRadius.circular(200), ), ), - onTap: () { - onYearPressed(context, pageController); - }, - borderRadius: BorderRadius.circular(200), - ), + Padding( + child: InkWell( + onTap: () => onFindMyDayPressed(), + splashColor: Colors.red[400]!, + child: Container( + decoration: BoxDecoration( + color: Colors.transparent, + border: Border.all(color: Colors.red[400]!), + shape: BoxShape.circle, + ), + height: 25.0, + width: 25.0, + child: Center( + child: Text(CalendarState() + .getCurrentDay() + .toString()), + ), + ), + ), + padding: + const EdgeInsets.only(left: 120, right: 15), + ), + ], + //mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.end, ), Padding( - child: InkWell( - onTap: () => onFindMyDayPressed(), - splashColor: Colors.red[400]!, - child: Container( - decoration: BoxDecoration( - color: Colors.transparent, - border: Border.all(color: Colors.red[400]!), - shape: BoxShape.circle, - ), - height: 25.0, - width: 25.0, - child: Center( - child: Text( - CalendarState().getCurrentDay().toString()), + padding: const EdgeInsets.only(bottom: 20), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: const [ + Text( + "Sun", + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold), ), - ), + Text("Mon", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold)), + Text("Tues", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold)), + Text("Wed", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold)), + Text("Thur", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold)), + Text("Fri", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold)), + Text("Sat", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold)) + ], ), - padding: const EdgeInsets.only(left: 120, right: 15), ), - ], - //mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.end, - ), - Padding( - padding: const EdgeInsets.only(bottom: 20), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: const [ - Text( - "Sun", - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold), - ), - Text("Mon", - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold)), - Text("Tues", - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold)), - Text("Wed", - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold)), - Text("Thur", - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold)), - Text("Fri", - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold)), - Text("Sat", - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold)) - ], - ), - ), - Expanded( - flex: 2, - //Builds grid of days based on number of days in month - child: GridView.builder( - itemCount: monthView.daysInMonth + mdw, - scrollDirection: Axis.vertical, - physics: const ScrollPhysics(), - gridDelegate: - const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 7, - childAspectRatio: 1 / 1.1, - ), - itemBuilder: (BuildContext context, int index) { - index += 1; - int day; - bool skip = false; - if (mdw != 0) { - day = index - monthView.monthStart; - } else { - day = index; - skip = true; - } - Color textColor; - Widget textStyleToday = Text((day).toString()); - - if ((day) == monthView.now.day && - monthView.now.month == n.now.month && - monthView.now.year == n.now.year) { - textColor = Colors.white; - textStyleToday = CircleAvatar( - backgroundColor: Colors.red[400]!, - child: Text( - day.toString(), - style: TextStyle( - color: textColor, - fontWeight: FontWeight.bold), - ), - maxRadius: 12, - ); - } - if (clickedPosition == day) { - clickedColor = Colors.red[200]!; - } else { - clickedColor = Colors.white70; - } - - int dayLetters = index - 1; - - if (index <= monthView.monthStart && !skip) { - Color colorCard; - if (darkMode) { - colorCard = Colors.black; - } else { - colorCard = Colors.white; - } - - return Card( - color: colorCard, - elevation: 0, - ); - } else { - if (dayLetters >= 7) { - dayLetters = (dayLetters % 7); - } - var todayE = globals.events[day.toString() + - userMonth.toString() + - (yearEarly + yearsPassed).toString()]; - List dayInfo = []; - dayInfo.add(textStyleToday); - if (todayE != null) { - for (var element in todayE) { - dayInfo.add(Container( - padding: const EdgeInsets.only(top: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 2, - width: 40, - )); + Expanded( + flex: 2, + //Builds grid of days based on number of days in month + child: GridView.builder( + itemCount: monthView.daysInMonth + mdw, + scrollDirection: Axis.vertical, + physics: const ScrollPhysics(), + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 7, + childAspectRatio: 1 / 1.1, + ), + itemBuilder: (BuildContext context, int index) { + index += 1; + int day; + bool skip = false; + if (mdw != 0) { + day = index - monthView.monthStart; + } else { + day = index; + skip = true; } - } - if (globals.everyDay.isNotEmpty) { - for (var element in globals.everyDay) { - if (temporaryM >= element.page) { - if (element.yearFrom == (yearsPassed + yearEarly) && element.monthFrom == userMonth) { - if (day >= element.dayFrom) { - dayInfo.add(Container( - padding: const EdgeInsets.only(top: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 2, - width: 40, - )); - } - } - else { + Color textColor; + Widget textStyleToday = Text((day).toString()); + + if ((day) == monthView.now.day && + monthView.now.month == n.now.month && + monthView.now.year == n.now.year) { + textColor = Colors.white; + textStyleToday = CircleAvatar( + backgroundColor: Colors.red[400]!, + child: Text( + day.toString(), + style: TextStyle( + color: textColor, + fontWeight: FontWeight.bold), + ), + maxRadius: 12, + ); + } + if (clickedPosition == day) { + clickedColor = Colors.red[200]!; + } else { + clickedColor = Colors.white70; + } + + int dayLetters = index - 1; + + if (index <= monthView.monthStart && !skip) { + Color colorCard; + if (darkMode) { + colorCard = Colors.black; + } else { + colorCard = Colors.white; + } + + return Card( + color: colorCard, + elevation: 0, + ); + } else { + if (dayLetters >= 7) { + dayLetters = (dayLetters % 7); + } + var todayE = globals.events[day.toString() + + userMonth.toString() + + (yearEarly + yearsPassed).toString()]; + List dayInfo = []; + dayInfo.add(textStyleToday); + if (todayE != null) { + for (var element in todayE) { dayInfo.add(Container( padding: const EdgeInsets.only(top: 10), decoration: BoxDecoration( @@ -358,18 +343,27 @@ class CalendarState extends State { )); } } - } - } - if (globals.everyWeek.isNotEmpty) { - - for (var element in globals.everyWeek) { - if (temporaryM >= element.page) { - DateTime wee = DateTime(yearEarly + yearsPassed, userMonth, day); - if (wee.weekday == (element.weekDay)) { - if (element.yearFrom == (yearsPassed + yearEarly) && element.monthFrom == userMonth) { - if (day >= element.dayFrom) { + if (globals.everyDay.isNotEmpty) { + for (var element in globals.everyDay) { + if (temporaryM >= element.page) { + if (element.yearFrom == + (yearsPassed + yearEarly) && + element.monthFrom == userMonth) { + if (day >= element.dayFrom) { + dayInfo.add(Container( + padding: const EdgeInsets.only( + top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } else { dayInfo.add(Container( - padding: const EdgeInsets.only(top: 10), + padding: + const EdgeInsets.only(top: 10), decoration: BoxDecoration( shape: BoxShape.rectangle, color: element.color), @@ -378,102 +372,146 @@ class CalendarState extends State { )); } } - else { - dayInfo.add(Container( - padding: const EdgeInsets.only(top: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 2, - width: 40, - )); + } + } + if (globals.everyWeek.isNotEmpty) { + for (var element in globals.everyWeek) { + if (temporaryM >= element.page) { + DateTime wee = DateTime( + yearEarly + yearsPassed, + userMonth, + day); + if (wee.weekday == (element.weekDay)) { + if (element.yearFrom == + (yearsPassed + yearEarly) && + element.monthFrom == userMonth) { + if (day >= element.dayFrom) { + dayInfo.add(Container( + padding: const EdgeInsets.only( + top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } else { + dayInfo.add(Container( + padding: const EdgeInsets.only( + top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } } } } - } - } - if (globals.everyMonth.isNotEmpty) { - - for (var element in globals.everyMonth) { - if (day == element.dayFrom) { - if (temporaryM >= element.page) { + if (globals.everyMonth.isNotEmpty) { + for (var element in globals.everyMonth) { + if (day == element.dayFrom) { + if (temporaryM >= element.page) { dayInfo.add(Container( - padding: const EdgeInsets.only(top: 10), + padding: + const EdgeInsets.only(top: 10), decoration: BoxDecoration( shape: BoxShape.rectangle, color: element.color), height: 2, width: 40, )); + } + } } - } - } - } - if (globals.everyYear.isNotEmpty) { - for (var element in globals.everyYear) { - if (day == element.dayFrom && - userMonth == element.monthFrom) { - if (temporaryM >= element.page) { + if (globals.everyYear.isNotEmpty) { + for (var element in globals.everyYear) { + if (day == element.dayFrom && + userMonth == element.monthFrom) { + if (temporaryM >= element.page) { dayInfo.add(Container( - padding: const EdgeInsets.only(top: 10), + padding: + const EdgeInsets.only(top: 10), decoration: BoxDecoration( shape: BoxShape.rectangle, color: element.color), height: 2, width: 40, )); - + } + } } } - } - } - - return SizedBox( - height: 200, - child: Card( - shape: RoundedRectangleBorder( - side: BorderSide( - color: clickedColor, width: 1), - borderRadius: BorderRadius.circular(10), - ), - child: InkWell( - borderRadius: BorderRadius.circular(50), - splashColor: Colors.deepOrangeAccent, - child: Align( - alignment: Alignment.topCenter, - child: Column( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - children: dayInfo, + + return SizedBox( + height: 200, + child: Card( + shape: RoundedRectangleBorder( + side: BorderSide( + color: clickedColor, width: 1), + borderRadius: BorderRadius.circular(10), + ), + child: InkWell( + borderRadius: BorderRadius.circular(50), + splashColor: Colors.deepOrangeAccent, + child: Align( + alignment: Alignment.topCenter, + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: dayInfo, + ), + ), + onTap: () => _tapDate( + day, + yearEarly + yearsPassed, + userMonth, + temporaryM), ), ), - onTap: () => _tapDate(day, - yearEarly + yearsPassed, userMonth, temporaryM), - ), + ); + } + }), + ), + Expanded( + flex: 1, + child: ListView( + children: [ + Column( + children: dayClicked, ), - ); - } - }), - ), - Expanded( - flex: 1, - child: ListView( - children: [ - Column( - children: dayClicked, - ), - ], - )), - ], - ); - }, - ), + ], + )), + ], + ); + }, + ), + ), + ], ), - ], - ), - ); + ), + floatingActionButton: FloatingActionButton( + onPressed: () => onAddEventButtonPressed(), + child: const Icon( + Icons.add, + size: 45, + color: Colors.white, + ), + )); + } + + void onAddEventButtonPressed() { + Navigator.of(context).push(MaterialPageRoute(builder: (context) { + int? clicked = StateWidget.of(context)?.clicked; + + //print(clicked); + return const EventForm(); + })); } void _tapDate(int day, int year, int month, int page) { @@ -483,10 +521,11 @@ class CalendarState extends State { clickedPosition = day; }); List temp; - if (globals.events[day.toString() + month.toString() + year.toString()] != null) { - temp = (globals.events[day.toString() + month.toString() + year.toString()])!; - } - else { + if (globals.events[day.toString() + month.toString() + year.toString()] != + null) { + temp = (globals + .events[day.toString() + month.toString() + year.toString()])!; + } else { temp = []; } @@ -497,8 +536,7 @@ class CalendarState extends State { if (day >= element.dayFrom) { temp.add(element); } - } - else { + } else { temp.add(element); } } @@ -513,8 +551,7 @@ class CalendarState extends State { if (day >= element.dayFrom) { temp.add(element); } - } - else { + } else { temp.add(element); } } @@ -524,14 +561,12 @@ class CalendarState extends State { if (globals.everyMonth.isNotEmpty) { for (var element in globals.everyMonth) { if (day == element.dayFrom) { - if (page >= element.page) { if (element.yearFrom == year && element.monthFrom == month) { if (day >= element.dayFrom) { temp.add(element); } - } - else { + } else { temp.add(element); } } @@ -546,12 +581,10 @@ class CalendarState extends State { if (day >= element.dayFrom) { temp.add(element); } - } - else { + } else { temp.add(element); } } - } } } diff --git a/lib/Inherited.dart b/lib/Inherited.dart index 47d0b11..5351e32 100644 --- a/lib/Inherited.dart +++ b/lib/Inherited.dart @@ -8,7 +8,7 @@ class InheritedState extends StatefulWidget { const InheritedState({ Key? key, required this.child, -}) : super(key: key); + }) : super(key: key); @override _InheritedStateState createState() => _InheritedStateState(); @@ -21,68 +21,179 @@ class _InheritedStateState extends State { int yearFrom = 0; int monthFrom = 0; - void updateClicked(int position, int yearC, int monthC) { - clicked = position; yearFrom = yearC; monthFrom = monthC; } - void addEvent(int dayFrom, int yearFrom, int monthFrom, String title, String timeF, String timeT, int dayTo, int monthTo, int yearTo, Color color, - TimeOfDay toT, TimeOfDay fromT, bool allDay, String repeat, int page) { + void addEvent( + int dayFrom, + int yearFrom, + int monthFrom, + String title, + String timeF, + String timeT, + int dayTo, + int monthTo, + int yearTo, + Color color, + TimeOfDay toT, + TimeOfDay fromT, + bool allDay, + String repeat, + int page) { int weekDay = DateTime(yearFrom, monthFrom, dayFrom).weekday; if (repeat == "Everyday") { - globals.everyDay.add(Events(monthFrom, yearFrom, dayFrom, title, timeF, timeT, dayTo, monthTo, yearTo, color, - fromT, toT, allDay, repeat, page, weekDay)); - } - else if (repeat == "Every week") { - globals.everyWeek.add(Events(monthFrom, yearFrom, dayFrom, title, timeF, timeT, dayTo, monthTo, yearTo, color, - fromT, toT, allDay, repeat, page, weekDay)); - } - else if (repeat == "Every month") { - globals.everyMonth.add(Events(monthFrom, yearFrom, dayFrom, title, timeF, timeT, dayTo, monthTo, yearTo, color, - fromT, toT, allDay, repeat, page, weekDay)); - } - else if (repeat == "Every year") { - globals.everyYear.add(Events(monthFrom, yearFrom, dayFrom, title, timeF, timeT, dayTo, monthTo, yearTo, color, - fromT, toT, allDay, repeat, page, weekDay)); - } - else { - if (globals.events[dayFrom.toString() + monthFrom.toString() + yearFrom.toString()] != null) { - globals.events[dayFrom.toString() + monthFrom.toString() + yearFrom.toString()]?.add(Events(monthFrom, yearFrom, dayFrom, title, timeF, timeT, dayTo, monthTo, yearTo, color, - fromT, toT, allDay, repeat, page, weekDay)); - } - else { - List temp = [Events(monthFrom, yearFrom, dayFrom, title, timeF, timeT, dayTo, monthTo, yearTo, color, fromT, toT, allDay, repeat, page, weekDay)]; - globals.events[dayFrom.toString() + monthFrom.toString() + yearFrom.toString()] = temp; - + globals.everyDay.add(Events( + monthFrom, + yearFrom, + dayFrom, + title, + timeF, + timeT, + dayTo, + monthTo, + yearTo, + color, + fromT, + toT, + allDay, + repeat, + page, + weekDay, + 'calendar')); + } else if (repeat == "Every week") { + globals.everyWeek.add(Events( + monthFrom, + yearFrom, + dayFrom, + title, + timeF, + timeT, + dayTo, + monthTo, + yearTo, + color, + fromT, + toT, + allDay, + repeat, + page, + weekDay, + 'calendar')); + } else if (repeat == "Every month") { + globals.everyMonth.add(Events( + monthFrom, + yearFrom, + dayFrom, + title, + timeF, + timeT, + dayTo, + monthTo, + yearTo, + color, + fromT, + toT, + allDay, + repeat, + page, + weekDay, + 'calendar')); + } else if (repeat == "Every year") { + globals.everyYear.add(Events( + monthFrom, + yearFrom, + dayFrom, + title, + timeF, + timeT, + dayTo, + monthTo, + yearTo, + color, + fromT, + toT, + allDay, + repeat, + page, + weekDay, + 'calendar')); + } else { + if (globals.events[dayFrom.toString() + + monthFrom.toString() + + yearFrom.toString()] != + null) { + globals.events[ + dayFrom.toString() + monthFrom.toString() + yearFrom.toString()] + ?.add(Events( + monthFrom, + yearFrom, + dayFrom, + title, + timeF, + timeT, + dayTo, + monthTo, + yearTo, + color, + fromT, + toT, + allDay, + repeat, + page, + weekDay, + 'calendar')); + } else { + List temp = [ + Events( + monthFrom, + yearFrom, + dayFrom, + title, + timeF, + timeT, + dayTo, + monthTo, + yearTo, + color, + fromT, + toT, + allDay, + repeat, + page, + weekDay, + 'calendar') + ]; + globals.events[dayFrom.toString() + + monthFrom.toString() + + yearFrom.toString()] = temp; } } - globals.events[dayFrom.toString() + monthFrom.toString() + yearFrom.toString()]?.sort((a,b) { + globals + .events[dayFrom.toString() + monthFrom.toString() + yearFrom.toString()] + ?.sort((a, b) { if (a.fromT.hour == b.fromT.hour) { return a.fromT.minute.compareTo(b.fromT.minute); - } - else { + } else { return a.fromT.hour.compareTo(b.fromT.hour); } }); } - @override Widget build(BuildContext context) => StateWidget( - child: widget.child, - clicked: clicked, - monthFrom: monthFrom, - yearFrom: yearFrom, - eventAdded: eventAdded, - state: this, - ); + child: widget.child, + clicked: clicked, + monthFrom: monthFrom, + yearFrom: yearFrom, + eventAdded: eventAdded, + state: this, + ); } - class StateWidget extends InheritedWidget { final int clicked; final _InheritedStateState state; @@ -90,7 +201,6 @@ class StateWidget extends InheritedWidget { final int eventAdded; final int monthFrom; - const StateWidget({ Key? key, required Widget child, @@ -102,18 +212,14 @@ class StateWidget extends InheritedWidget { }) : super(key: key, child: child); static _InheritedStateState? of(BuildContext context) => - context - .dependOnInheritedWidgetOfExactType() - ?.state; + context.dependOnInheritedWidgetOfExactType()?.state; @override bool updateShouldNotify(StateWidget oldWidget) { - return oldWidget.clicked != clicked || oldWidget.monthFrom != monthFrom || oldWidget.yearFrom != yearFrom || oldWidget.eventAdded != eventAdded || oldWidget.state != state; } - } From ca81a79780407c61eae8cce85ced72fe27639bc7 Mon Sep 17 00:00:00 2001 From: joseph81301 Date: Sat, 16 Apr 2022 16:01:33 -0400 Subject: [PATCH 03/13] Updates --- pubspec.lock | 45 ++++++++++++++++++++++++++++++++++++++++----- pubspec.yaml | 2 ++ 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 1496fc3..343f54a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -57,13 +57,34 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + firebase_auth: + dependency: "direct main" + description: + name: firebase_auth + url: "https://pub.dartlang.org" + source: hosted + version: "3.3.14" + firebase_auth_platform_interface: + dependency: transitive + description: + name: firebase_auth_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "6.2.3" + firebase_auth_web: + dependency: transitive + description: + name: firebase_auth_web + url: "https://pub.dartlang.org" + source: hosted + version: "3.3.12" firebase_core: dependency: "direct main" description: name: firebase_core url: "https://pub.dartlang.org" source: hosted - version: "1.14.0" + version: "1.14.1" firebase_core_platform_interface: dependency: transitive description: @@ -77,28 +98,28 @@ packages: name: firebase_core_web url: "https://pub.dartlang.org" source: hosted - version: "1.6.1" + version: "1.6.2" firebase_database: dependency: "direct main" description: name: firebase_database url: "https://pub.dartlang.org" source: hosted - version: "9.0.9" + version: "9.0.11" firebase_database_platform_interface: dependency: transitive description: name: firebase_database_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "0.2.1+2" + version: "0.2.1+3" firebase_database_web: dependency: transitive description: name: firebase_database_web url: "https://pub.dartlang.org" source: hosted - version: "0.2.0+8" + version: "0.2.0+10" flutter: dependency: "direct main" description: flutter @@ -121,6 +142,20 @@ packages: description: flutter source: sdk version: "0.0.0" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" + intl: + dependency: transitive + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.17.0" js: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index cf055c1..d7a03d3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -35,6 +35,8 @@ dependencies: # 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_auth: ^3.3.14 + dev_dependencies: flutter_test: From 57846af01c885dabca4c6c891dcb3d829ca5d052 Mon Sep 17 00:00:00 2001 From: Nathan Fox <58736647+Sergentfox234@users.noreply.github.com> Date: Sat, 16 Apr 2022 20:15:11 -0400 Subject: [PATCH 04/13] My Application in it's whole so far --- .vscode/launch.json | 25 +++++++ lib/Assignments.dart | 35 +++++---- lib/Calendar.dart | 6 +- lib/EventForm.dart | 150 +++++++++++++++++++++++++++---------- lib/EventListStorage.dart | 153 ++++++++++++++++++++++++++++++++++++++ lib/EventsWidget.dart | 0 lib/Exams.dart | 39 +++++----- lib/Inherited.dart | 15 ++-- lib/Projects.dart | 75 +------------------ lib/ProjectsWidget.dart | 75 +++++++++++++++++++ lib/globals.dart | 3 +- lib/main.dart | 19 ++++- pubspec.lock | 93 ++++++++++++++++++++++- pubspec.yaml | 1 + 14 files changed, 532 insertions(+), 157 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 lib/EventListStorage.dart create mode 100644 lib/EventsWidget.dart create mode 100644 lib/ProjectsWidget.dart diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..c819ee2 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,25 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "DayToDay", + "request": "launch", + "type": "dart" + }, + { + "name": "DayToDay (profile mode)", + "request": "launch", + "type": "dart", + "flutterMode": "profile" + }, + { + "name": "DayToDay (release mode)", + "request": "launch", + "type": "dart", + "flutterMode": "release" + } + ] +} \ No newline at end of file diff --git a/lib/Assignments.dart b/lib/Assignments.dart index bf34ee4..291fdc8 100644 --- a/lib/Assignments.dart +++ b/lib/Assignments.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; +import 'EventForm.dart'; +import 'globals.dart' as globals; import 'Events.dart'; -import 'dart:collection'; class AssignmentsWidget extends StatefulWidget { - final assignmentsList = Queue(); - + List hw = []; AssignmentsWidget({Key? key}) : super(key: key); @override @@ -12,34 +12,39 @@ class AssignmentsWidget extends StatefulWidget { } class AssignmentsState extends State { - List assignments = ["HW 1", "HW 2"]; - List checked = [false, false]; int count = 2; @override Widget build(BuildContext context) { + widget.hw = []; + globals.events.forEach((key, value) { + for (int i = 0; i < value.length; i++) { + if (value[i].type.contains("assign")) { + widget.hw.add(value[i]); + } + } + }); return Scaffold( appBar: AppBar( title: const Center(child: Text("Assignments List")), + backgroundColor: const Color.fromARGB(255, 255, 82, 82), ), body: ListView.builder( - itemCount: count, + itemCount: widget.hw.length, itemBuilder: (BuildContext context, int index) { return Card( child: CheckboxListTile( dense: true, activeColor: Colors.red[400], controlAffinity: ListTileControlAffinity.leading, - value: checked[index], + value: false, onChanged: (value) { setState(() { - assignments.removeAt(index); - checked.removeAt(index); - count--; + widget.hw.removeAt(index); }); }, title: Text( - assignments[index], + widget.hw[index].title, style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 20, @@ -50,11 +55,11 @@ class AssignmentsState extends State { floatingActionButton: FloatingActionButton( onPressed: () { setState(() { - count++; - String returnStr = "HW " + count.toString(); - assignments.add(returnStr); - checked.add(false); + Navigator.of(context).push(MaterialPageRoute(builder: (context) { + return EventForm(); + })); }); + setState(() {}); }, child: const Icon( Icons.add, diff --git a/lib/Calendar.dart b/lib/Calendar.dart index 4e785ff..c1a33c0 100644 --- a/lib/Calendar.dart +++ b/lib/Calendar.dart @@ -8,8 +8,10 @@ import 'globals.dart' as globals; import 'package:firebase_database/firebase_database.dart'; class CalendarWidget extends StatefulWidget { - const CalendarWidget({Key? key, required this.stream}) : super(key: key); + CalendarWidget(this.eventList, {Key? key, required this.stream}) + : super(key: key); final Stream stream; + List eventList; @override State createState() => CalendarState(); @@ -510,7 +512,7 @@ class CalendarState extends State { int? clicked = StateWidget.of(context)?.clicked; //print(clicked); - return const EventForm(); + return EventForm(); })); } diff --git a/lib/EventForm.dart b/lib/EventForm.dart index af11401..2899d00 100644 --- a/lib/EventForm.dart +++ b/lib/EventForm.dart @@ -1,11 +1,13 @@ +import 'package:day_to_day/EventListStorage.dart'; import 'package:day_to_day/Inherited.dart'; +import 'Events.dart'; import 'package:day_to_day/Months.dart'; import 'package:day_to_day/main.dart'; import 'package:flutter/material.dart'; import 'globals.dart' as globals; class EventForm extends StatefulWidget { - const EventForm({Key? key}) : super(key: key); + EventForm({Key? key}) : super(key: key); @override EventFormState createState() => EventFormState(); @@ -47,11 +49,12 @@ class EventFormState extends State { String colorChosenText = "Default"; TimeOfDay fromObj = TimeOfDay.now(); TimeOfDay toObj = TimeOfDay.now(); + String type = "Calendar"; + String title = "Default Event"; @override Widget build(BuildContext context) { String to; - String title = "Default Event"; int dayF = (StateWidget.of(context)?.clicked)!; int weekDayN; int hour = n.now.hour; @@ -178,6 +181,60 @@ class EventFormState extends State { ), ), const Divider(color: Colors.grey,), + Padding(padding: const EdgeInsets.only( + top: 12, bottom: 12, left: 20, right: 20), + child: Center( + child: Column( + children: [ + const Text("Event Type: "), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ElevatedButton( + style: type.contains("calendar") ? ElevatedButton.styleFrom(side: BorderSide( + color: Colors.red[200]!, width: 1)) + : ElevatedButton.styleFrom(side: BorderSide( + color: Colors.blue[100]!, width: 1)), + onPressed: () { + setState(() { + type = "calendar"; + }); + }, + child: const Center(child: Text("Calendar"))), + ElevatedButton( + style: type.contains("assignment") ? ElevatedButton.styleFrom(side: BorderSide( + color: Colors.red[200]!, width: 1)) + : ElevatedButton.styleFrom(side: BorderSide( + color: Colors.blue[100]!, width: 1)), + onPressed: () { + setState(() { + type = "assignment"; + }); + }, + child: const Center(child: Text("Assignment"))), + ElevatedButton( + style: type.contains("project") ? ElevatedButton.styleFrom(side: BorderSide( + color: Colors.red[200]!, width: 1)) + : ElevatedButton.styleFrom(side: BorderSide( + color: Colors.blue[100]!, width: 1)), + onPressed: () { + setState(() { + type = "project"; + }); + }, + child: const Center(child: Text("Project"))), + ElevatedButton( + style: type.contains("exam") ? ElevatedButton.styleFrom(side: BorderSide( + color: Colors.red[200]!, width: 1)) + : ElevatedButton.styleFrom(side: BorderSide( + color: Colors.blue[100]!, width: 1)), + onPressed: () { + setState(() { + type = "exam"; + }); + }, + child: const Center(child: Text("Exam")))] + )]),)), InkWell( child: Row( children: [ @@ -325,14 +382,30 @@ class EventFormState extends State { ), TextButton( onPressed: () { - //print(title); + //If the event was saved, write it to the respective file + //!!!!!!TODO!!!!! if (selectedTimeTo != null) { + Events newEvent = Events(selectedTime.month, selectedTime.year, selectedTime.day, title, + finalTimeFrom, finalTimeTo, (selectedTimeTo?.day)!, (selectedTimeTo?.month)!, (selectedTimeTo?.year)!, + colorChosenBubble, fromObj, toObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, 0, + type); + StateWidget.of(context)?.addEvent(selectedTime.day, selectedTime.year, selectedTime.month, title, - finalTimeFrom, finalTimeTo, (selectedTimeTo?.day)!, (selectedTimeTo?.month)!, (selectedTimeTo?.year)!, colorChosenBubble, toObj, fromObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1); + finalTimeFrom, finalTimeTo, (selectedTimeTo?.day)!, (selectedTimeTo?.month)!, (selectedTimeTo?.year)!, + colorChosenBubble, toObj, fromObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, + type); + } else { + Events newEvent = Events(selectedTime.month, selectedTime.year, selectedTime.day, title, + finalTimeFrom, finalTimeTo, selectedTime.day, selectedTime.month, selectedTime.year, + colorChosenBubble, fromObj, toObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, 0, + type); + StateWidget.of(context)?.addEvent(selectedTime.day, selectedTime.year, selectedTime.month, title, - finalTimeFrom, finalTimeTo, selectedTime.day, selectedTime.month, selectedTime.year, colorChosenBubble, toObj, fromObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1); + finalTimeFrom, finalTimeTo, selectedTime.day, selectedTime.month, selectedTime.year, + colorChosenBubble, toObj, fromObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, + type); } streamController.add(true); Navigator.pop(context); @@ -369,41 +442,42 @@ class EventFormState extends State { Future chooseFromDay( BuildContext context, DateTime current, bool fromChoose) async { - DateTime? userChosenFrom = (await showDatePicker( - builder: (context, child) { - return Theme( - data: Theme.of(context).copyWith( - colorScheme: ColorScheme.dark( - primary: Colors.red[200]!, - onPrimary: Colors.white, - onSurface: Colors.white, - ), - textButtonTheme: TextButtonThemeData( - style: TextButton.styleFrom( - primary: Colors.red[200], - ), - ), - ), child: child!, - )}, - context: context, - initialDate: current, - firstDate: DateTime(1980, 1), - lastDate: DateTime(2222)))!; - if (fromChoose) { - if (userChosenFrom != current) { - chosenFrom = true; - setState(() { - selectedTime = userChosenFrom; + DateTime? userChosenFrom = (await showDatePicker( + builder: (context, child) { + return Theme( + data: Theme.of(context).copyWith( + colorScheme: ColorScheme.dark( + primary: Colors.red[200]!, + onPrimary: Colors.white, + onSurface: Colors.white, + ), + textButtonTheme: TextButtonThemeData( + style: TextButton.styleFrom( + primary: Colors.red[200], + ), + ), + ), child: child!, + )}, + context: context, + initialDate: current, + firstDate: DateTime(1980, 1), + lastDate: DateTime(2222)))!; - }); - } - } else { - chosenTo = true; - setState(() { - selectedTimeTo = userChosenFrom; - }); + if (fromChoose) { + if (userChosenFrom != current) { + chosenFrom = true; + setState(() { + selectedTime = userChosenFrom; - } + }); + } + } else { + chosenTo = true; + setState(() { + selectedTimeTo = userChosenFrom; + }); + + } } diff --git a/lib/EventListStorage.dart b/lib/EventListStorage.dart new file mode 100644 index 0000000..d4641b8 --- /dev/null +++ b/lib/EventListStorage.dart @@ -0,0 +1,153 @@ +import 'package:flutter/material.dart'; +import 'dart:convert'; +import 'Events.dart'; +import 'package:path_provider/path_provider.dart'; +import 'dart:io'; + +// This class is used to read and write files in the application +class EventListStorage { + var typeName = ""; + EventListStorage(this.typeName); + + Future get _localPath async { + final directory = await getApplicationDocumentsDirectory(); + + return directory.path; + } + + Future get _localFile async { + final path = await _localPath; + File file = File('$path/$typeName.txt'); + if (!await file.exists()) { + file.writeAsString(""); + } + return file; + } + + Future> readEvents() async { + final file = await _localFile; + + // Read the file + final contents = await file.readAsString(); + + List events = []; + String type = ""; + int monthFrom = 0; + int monthTo = 0; + int yearFrom = 0; + int page = 0; + int yearTo = 0; + int dayTo = 0; + int dayFrom = 0; + String title = ""; + String timeF = ""; + String timeT = ""; + Color color; + TimeOfDay fromT; + TimeOfDay toT; + bool allDay; + String repeat; + int weekDay = 0; + + if (contents.isEmpty) { + return []; + } + + var data = contents.split(":"); + for (int i = 0; i < data.length / 17; i++) { + type = data[i * 17]; + monthFrom = int.parse(data[i * 17 + 1]); + monthTo = int.parse(data[i * 17 + 2]); + yearFrom = int.parse(data[i * 17 + 3]); + page = int.parse(data[i * 17 + 4]); + yearTo = int.parse(data[i * 17 + 5]); + dayTo = int.parse(data[i * 17 + 6]); + dayFrom = int.parse(data[i * 17 + 7]); + title = data[i * 17 + 8]; + timeF = data[i * 17 + 9]; + timeT = data[i * 17 + 10]; + color = data[i * 17 + 11] as Color; + fromT = data[i * 17 + 12] as TimeOfDay; + toT = data[i * 17 + 13] as TimeOfDay; + if (data[i * 17 + 14].contains("rue")) { + allDay = true; + } else { + allDay = false; + } + repeat = data[i * 17 + 15]; + weekDay = int.parse(data[i * 17 + 16]); + + events.add(Events( + monthFrom, + yearFrom, + dayFrom, + title, + timeF, + timeT, + dayTo, + monthTo, + yearTo, + color, + fromT, + toT, + allDay, + repeat, + page, + weekDay, + type)); + } + + return events; + } + + Future writeEvents(List events) async { + //This is the file + final file = await _localFile; + + /*Every event has String type = ""; + int monthFrom = 0; + int monthTo = 0; + int yearFrom = 0; + int page = 0; + int yearTo = 0; + int dayTo = 0; + int dayFrom = 0; + String title = ""; + String timeF = ""; + String timeT = ""; + Color color; + TimeOfDay fromT; + TimeOfDay toT; + bool allDay; + String repeat; + int weekDay = 0;*/ + for (int i = 0; i < events.length; i++) { + file.writeAsString(events[i].type + ":"); + file.writeAsString(events[i].monthFrom.toString() + ":"); + file.writeAsString(events[i].monthTo.toString() + ":"); + file.writeAsString(events[i].yearFrom.toString() + ":"); + file.writeAsString(events[i].yearTo.toString() + ":"); + file.writeAsString(events[i].page.toString() + ":"); + file.writeAsString(events[i].dayFrom.toString() + ":"); + file.writeAsString(events[i].dayTo.toString() + ":"); + file.writeAsString(events[i].title + ":"); + file.writeAsString(events[i].timeF + ":"); + file.writeAsString(events[i].timeT + ":"); + file.writeAsString(events[i].color.toString() + ":"); + file.writeAsString(events[i].fromT.toString() + ":"); + file.writeAsString(events[i].toT.toString() + ":"); + file.writeAsString(events[i].allDay.toString() + ":"); + file.writeAsString(events[i].repeat + ":"); + file.writeAsString(events[i].weekDay.toString() + ":"); + } + + return file; + } + + Future writeEvent(Events event) async { + final file = await _localFile; + List oldList = await readEvents(); + oldList.add(event); + return writeEvents(oldList); + } +} diff --git a/lib/EventsWidget.dart b/lib/EventsWidget.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/Exams.dart b/lib/Exams.dart index 09fba42..5c18a1d 100644 --- a/lib/Exams.dart +++ b/lib/Exams.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; +import 'EventForm.dart'; +import 'globals.dart' as globals; import 'Events.dart'; -import 'dart:collection'; class ExamsWidget extends StatefulWidget { - final projectsList = Queue(); - + List exams = []; ExamsWidget({Key? key}) : super(key: key); @override @@ -12,34 +12,37 @@ class ExamsWidget extends StatefulWidget { } class ExamsState extends State { - List exams = ["Exam 1", "Exam 2"]; - int count = 2; - List checked = [false, false]; - @override Widget build(BuildContext context) { + widget.exams = []; + globals.events.forEach((key, value) { + for (int i = 0; i < value.length; i++) { + if (value[i].type.contains("exam")) { + widget.exams.add(value[i]); + } + } + }); return Scaffold( appBar: AppBar( title: const Center(child: Text("Exams List")), + backgroundColor: const Color.fromARGB(255, 255, 82, 82), ), body: ListView.builder( - itemCount: count, + itemCount: widget.exams.length, itemBuilder: (BuildContext context, int index) { return Card( child: CheckboxListTile( dense: true, activeColor: Colors.red[400], controlAffinity: ListTileControlAffinity.leading, - value: checked[index], + value: false, onChanged: (value) { setState(() { - exams.removeAt(index); - checked.removeAt(index); - count--; + widget.exams.removeAt(index); }); }, title: Text( - exams[index], + widget.exams[index].title, style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 20, @@ -50,10 +53,12 @@ class ExamsState extends State { floatingActionButton: FloatingActionButton( onPressed: () { setState(() { - count++; - String returnStr = "Exam " + count.toString(); - exams.add(returnStr); - checked.add(false); + setState(() { + Navigator.of(context).push(MaterialPageRoute(builder: (context) { + return EventForm(); + })); + }); + setState(() {}); }); }, child: const Icon( diff --git a/lib/Inherited.dart b/lib/Inherited.dart index 5351e32..26f888f 100644 --- a/lib/Inherited.dart +++ b/lib/Inherited.dart @@ -42,7 +42,8 @@ class _InheritedStateState extends State { TimeOfDay fromT, bool allDay, String repeat, - int page) { + int page, + String type) { int weekDay = DateTime(yearFrom, monthFrom, dayFrom).weekday; if (repeat == "Everyday") { globals.everyDay.add(Events( @@ -62,7 +63,7 @@ class _InheritedStateState extends State { repeat, page, weekDay, - 'calendar')); + type)); } else if (repeat == "Every week") { globals.everyWeek.add(Events( monthFrom, @@ -81,7 +82,7 @@ class _InheritedStateState extends State { repeat, page, weekDay, - 'calendar')); + type)); } else if (repeat == "Every month") { globals.everyMonth.add(Events( monthFrom, @@ -100,7 +101,7 @@ class _InheritedStateState extends State { repeat, page, weekDay, - 'calendar')); + type)); } else if (repeat == "Every year") { globals.everyYear.add(Events( monthFrom, @@ -119,7 +120,7 @@ class _InheritedStateState extends State { repeat, page, weekDay, - 'calendar')); + type)); } else { if (globals.events[dayFrom.toString() + monthFrom.toString() + @@ -144,7 +145,7 @@ class _InheritedStateState extends State { repeat, page, weekDay, - 'calendar')); + type)); } else { List temp = [ Events( @@ -164,7 +165,7 @@ class _InheritedStateState extends State { repeat, page, weekDay, - 'calendar') + type) ]; globals.events[dayFrom.toString() + monthFrom.toString() + diff --git a/lib/Projects.dart b/lib/Projects.dart index e953fbc..5137dc2 100644 --- a/lib/Projects.dart +++ b/lib/Projects.dart @@ -1,73 +1,4 @@ -import 'dart:async'; -import 'dart:collection'; -import 'package:day_to_day/Inherited.dart'; -import 'package:day_to_day/Months.dart'; -import 'package:flutter/material.dart'; -import 'Events.dart'; -import 'globals.dart' as globals; -import 'package:firebase_database/firebase_database.dart'; - -class ProjectsWidget extends StatefulWidget { - ProjectsWidget({Key? key}) : super(key: key); - - @override - State createState() => ProjectsState(); -} - -class ProjectsState extends State { - List projectsList = ["P1", "P2"]; - int count = 2; - List checked = [false, false]; - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Center(child: Text("Projects List")), - ), - body: ListView.builder( - itemCount: count, - itemBuilder: (BuildContext context, int index) { - return Card( - child: CheckboxListTile( - dense: true, - activeColor: Colors.red[400], - controlAffinity: ListTileControlAffinity.leading, - value: checked[index], - onChanged: (value) { - setState(() { - projectsList.removeAt(index); - checked.removeAt(index); - count--; - }); - }, - title: Text( - projectsList[index], - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20, - color: Color.fromARGB(255, 12, 12, 12)), - ))); - }, - ), - floatingActionButton: FloatingActionButton( - onPressed: () { - setState(() { - count++; - String returnStr = "P" + count.toString(); - projectsList.add(returnStr); - checked.add(false); - print(count); - print(projectsList); - }); - }, - child: const Icon( - Icons.add, - size: 45, - color: Colors.white, - ), - backgroundColor: Colors.blueGrey, - ), - ); - } +class Project { + List projects = []; + List checked = []; } diff --git a/lib/ProjectsWidget.dart b/lib/ProjectsWidget.dart new file mode 100644 index 0000000..d4d92f6 --- /dev/null +++ b/lib/ProjectsWidget.dart @@ -0,0 +1,75 @@ +import 'package:day_to_day/globals.dart'; +import 'EventListStorage.dart'; +import 'EventForm.dart'; +import 'package:flutter/material.dart'; +import 'Events.dart'; +import 'globals.dart' as globals; +//import 'package:firebase_database/firebase_database.dart'; + +class ProjectsWidget extends StatefulWidget { + List projects = []; + ProjectsWidget({Key? key}) : super(key: key); + + @override + State createState() => ProjectsState(); +} + +class ProjectsState extends State { + @override + Widget build(BuildContext context) { + projects = []; + globals.events.forEach((key, value) { + for (int i = 0; i < value.length; i++) { + if (value[i].type.contains("project")) { + projects.add(value[i]); + } + } + }); + print("\n\n\nProjects: " + projects.length.toString()); + return Scaffold( + appBar: AppBar( + title: const Center(child: Text("Projects List")), + backgroundColor: const Color.fromARGB(255, 255, 82, 82), + ), + body: ListView.builder( + itemCount: projects.length, + itemBuilder: (BuildContext context, int index) { + return Card( + child: CheckboxListTile( + dense: true, + activeColor: Colors.red[400], + controlAffinity: ListTileControlAffinity.leading, + value: false, + onChanged: (value) { + setState(() { + projects.removeAt(index); + }); + }, + title: Text( + projects[index].title, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20, + color: Color.fromARGB(255, 12, 12, 12)), + ))); + }, + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + setState(() { + Navigator.of(context).push(MaterialPageRoute(builder: (context) { + return EventForm(); + })); + }); + setState(() {}); + }, + child: const Icon( + Icons.add, + size: 45, + color: Colors.white, + ), + backgroundColor: Colors.blueGrey, + ), + ); + } +} diff --git a/lib/globals.dart b/lib/globals.dart index 0259797..5598495 100644 --- a/lib/globals.dart +++ b/lib/globals.dart @@ -1,7 +1,8 @@ import 'Events.dart'; Map> events = {}; +List projects = []; List everyDay = []; List everyMonth = []; List everyWeek = []; -List everyYear = []; \ No newline at end of file +List everyYear = []; diff --git a/lib/main.dart b/lib/main.dart index 35a5124..a3df517 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,7 @@ +import 'package:day_to_day/Events.dart'; import 'package:day_to_day/Inherited.dart'; import 'package:day_to_day/Months.dart'; -import 'package:day_to_day/Projects.dart'; +import 'package:day_to_day/ProjectsWidget.dart'; import 'package:day_to_day/Assignments.dart'; import 'package:day_to_day/Exams.dart'; import 'package:day_to_day/to_do_list_directory_widget.dart'; @@ -9,7 +10,9 @@ import 'package:firebase_database/firebase_database.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:day_to_day/Calendar.dart'; import 'package:day_to_day/EventForm.dart'; +import 'globals.dart'; import 'dart:async'; +import 'EventListStorage.dart'; StreamController streamController = StreamController.broadcast(); @@ -22,6 +25,7 @@ class DayToDay extends StatelessWidget { final Future _fbApp = Firebase.initializeApp(); DayToDay({Key? key}) : super(key: key); bool wic = true; + @override Widget build(BuildContext context) => InheritedState( child: MaterialApp( @@ -70,7 +74,7 @@ class DayToDay extends StatelessWidget { print('You have an error! ${snapshot.error.toString()}'); return const Text('Something went wrong!'); } else if (snapshot.hasData) { - return const AppWidget(); + return AppWidget(); } else { return const Center( child: CircularProgressIndicator(), @@ -84,7 +88,9 @@ class DayToDay extends StatelessWidget { } class AppWidget extends StatefulWidget { - const AppWidget({Key? key}) : super(key: key); + AppWidget({Key? key}) : super(key: key); + List eventList = []; + @override State createState() => _MyStatefulWidgetState(); } @@ -108,6 +114,10 @@ class _MyStatefulWidgetState extends State @override Widget build(BuildContext context) { + var pass = EventListStorage("Project").readEvents().then((value) { + widget.eventList = value; + }); + var systemColor = MediaQuery.of(context).platformBrightness; bool darkMode = systemColor == Brightness.dark; Color labelColorChange; @@ -221,6 +231,7 @@ class _MyStatefulWidgetState extends State controller: _tabController, children: [ CalendarWidget( + widget.eventList, stream: streamController.stream, ), const ToDoListDirectoryWidget(), @@ -238,7 +249,7 @@ class _MyStatefulWidgetState extends State int? clicked = StateWidget.of(context)?.clicked; //print(clicked); - return const EventForm(); + return EventForm(); })); } } diff --git a/pubspec.lock b/pubspec.lock index 1496fc3..6c8b319 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -57,6 +57,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.2" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.2" firebase_core: dependency: "direct main" description: @@ -163,6 +177,62 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + path_provider: + dependency: "direct main" + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.9" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.12" + path_provider_ios: + dependency: transitive + description: + name: path_provider_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.8" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.5" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" plugin_platform_interface: dependency: transitive description: @@ -170,6 +240,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.4" sky_engine: dependency: transitive description: flutter @@ -231,6 +308,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.1" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.5.1" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0+1" sdks: dart: ">=2.16.1 <3.0.0" - flutter: ">=1.20.0" + flutter: ">=2.8.0" diff --git a/pubspec.yaml b/pubspec.yaml index cf055c1..30882dc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -31,6 +31,7 @@ dependencies: sdk: flutter firebase_core: ^1.13.1 firebase_database: ^9.0.8 + path_provider: ^2.0.9 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. From d2bc72886cdfee6ec0f7cae78883f44bfb2a7e60 Mon Sep 17 00:00:00 2001 From: joseph81301 Date: Sat, 16 Apr 2022 20:58:25 -0400 Subject: [PATCH 05/13] changes --- lib/calendar.dart | 1063 +++++++++++++++++++++++---------------------- lib/events.dart | 4 +- lib/main.dart | 18 - 3 files changed, 554 insertions(+), 531 deletions(-) diff --git a/lib/calendar.dart b/lib/calendar.dart index cc72d14..cc1416a 100644 --- a/lib/calendar.dart +++ b/lib/calendar.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:day_to_day/inherited.dart'; import 'package:day_to_day/months.dart'; import 'package:flutter/material.dart'; +import 'event_form.dart'; import 'events.dart'; import 'globals.dart' as globals; import 'package:firebase_database/firebase_database.dart'; @@ -53,315 +54,335 @@ class CalendarState extends State { bool darkMode = systemColor == Brightness.dark; return InheritedState( - child: Column( - children: [ - Expanded( - //Builds separate page for each month of every year since 1980 - child: PageView.builder( - controller: pageController, - scrollDirection: Axis.vertical, - itemBuilder: (BuildContext context, int pages) { - int temporaryM = pages; + child: Scaffold( + floatingActionButton: FloatingActionButton( + onPressed: () => onAddEventButtonPressed(), + child: const Icon( + Icons.add, + size: 45, + color: Colors.white, + ), + backgroundColor: Colors.blueGrey, + ), + body: Column( + children: [ + Expanded( + //Builds separate page for each month of every year since 1980 + child: PageView.builder( + controller: pageController, + scrollDirection: Axis.vertical, + itemBuilder: (BuildContext context, int pages) { + int temporaryM = pages; - if (clickedPosition == -1) { - clickedPosition = getCurrentDay(); - if (globals.eventsList[getCurrentDay().toString() + + if (clickedPosition == -1) { + clickedPosition = getCurrentDay(); + if (globals.eventsList[getCurrentDay().toString() + + getCurrentMonth().toString() + + getCurrentYear().toString()] != + null) { + globals.eventsList[getCurrentDay().toString() + getCurrentMonth().toString() + - getCurrentYear().toString()] != - null) { - globals.eventsList[getCurrentDay().toString() + - getCurrentMonth().toString() + - getCurrentYear().toString()] - ?.forEach((element) { - dayClicked.add(Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - padding: const EdgeInsets.only(right: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 15, - width: 2, - ), - const Padding(padding: EdgeInsets.only(right: 10)), - Text( - element.title, - style: const TextStyle( - fontWeight: FontWeight.bold, fontSize: 20), - ), - ], - )); - String timeF = TimeOfDay( - hour: element.from.hour, - minute: element.from.minute) - .format(context); - String timeT = TimeOfDay( - hour: element.to.hour, minute: element.to.minute) - .format(context); - String repeatingString; - - if (element.from.day == element.to.day && - element.from.month == element.to.month && - element.from.year == element.to.year) { - dayClicked.add(Center( - child: Padding( - padding: const EdgeInsets.only(bottom: 20), - child: Text(timeF + " - " + timeT), - ), - )); - } else if (element.from.year == element.to.year) { - dayClicked.add(Center( - child: Padding( - padding: const EdgeInsets.only(bottom: 20), - child: Text( - Months().getMonthShort(element.from.month)! + - " " + - element.from.day.toString() + - ", " + - timeF + - " - " + - Months().getMonthShort(element.to.month)! + - " " + - element.to.day.toString() + - ", " + - timeT), - ), - )); - } else { - dayClicked.add(Center( - child: Padding( - padding: const EdgeInsets.only(bottom: 20), - child: Text( - Months().getMonthShort(element.from.month)! + - " " + - element.from.day.toString() + - ", " + - element.from.year.toString() + - ", " + - timeF + - " - " + - Months().getMonthShort(element.to.month)! + - " " + - element.to.day.toString() + - ", " + - element.to.year.toString() + - ", " + - timeT), - ), + getCurrentYear().toString()] + ?.forEach((element) { + dayClicked.add(Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.only(right: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 15, + width: 2, + ), + const Padding(padding: EdgeInsets.only(right: 10)), + Text( + element.title, + style: const TextStyle( + fontWeight: FontWeight.bold, fontSize: 20), + ), + ], )); - } - }); - } else { - dayClicked.add(const Text("No events today")); + String timeF = TimeOfDay( + hour: element.from.hour, + minute: element.from.minute) + .format(context); + String timeT = TimeOfDay( + hour: element.to.hour, minute: element.to.minute) + .format(context); + String repeatingString; + + if (element.from.day == element.to.day && + element.from.month == element.to.month && + element.from.year == element.to.year) { + dayClicked.add(Center( + child: Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Text(timeF + " - " + timeT), + ), + )); + } else if (element.from.year == element.to.year) { + dayClicked.add(Center( + child: Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Text( + Months().getMonthShort(element.from.month)! + + " " + + element.from.day.toString() + + ", " + + timeF + + " - " + + Months().getMonthShort(element.to.month)! + + " " + + element.to.day.toString() + + ", " + + timeT), + ), + )); + } else { + dayClicked.add(Center( + child: Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Text( + Months().getMonthShort(element.from.month)! + + " " + + element.from.day.toString() + + ", " + + element.from.year.toString() + + ", " + + timeF + + " - " + + Months().getMonthShort(element.to.month)! + + " " + + element.to.day.toString() + + ", " + + element.to.year.toString() + + ", " + + timeT), + ), + )); + } + }); + } else { + dayClicked.add(const Text("No events today")); + } } - } - int yearsPassed = 1; - if (pages > 12) { - temporaryM = (temporaryM % 12) + 1; - } - int userMonth = temporaryM; - temporaryM = pages; + int yearsPassed = 1; + if (pages > 12) { + temporaryM = (temporaryM % 12) + 1; + } + int userMonth = temporaryM; + temporaryM = pages; - var yearEarly = 1980; - yearsPassed = (pages / 12).floor(); - int earlyYear = yearEarly + yearsPassed; - String monthIAmIn = n.currentMonth; - if (n.now.month == userMonth && n.now.year == earlyYear) { - monthView = n; - } else { - monthView = Months.otherYears(userMonth, earlyYear); - } - int mdw = monthView.monthStart; - if (monthView.monthStart == 7) { - mdw = 0; - } - monthIAmIn = n.month[userMonth].toString(); + var yearEarly = 1980; + yearsPassed = (pages / 12).floor(); + int earlyYear = yearEarly + yearsPassed; + String monthIAmIn = n.currentMonth; + if (n.now.month == userMonth && n.now.year == earlyYear) { + monthView = n; + } else { + monthView = Months.otherYears(userMonth, earlyYear); + } + int mdw = monthView.monthStart; + if (monthView.monthStart == 7) { + mdw = 0; + } + monthIAmIn = n.month[userMonth].toString(); - String year = (yearEarly + yearsPassed).toString(); + String year = (yearEarly + yearsPassed).toString(); - if (getCurrentYear().toString() == year) { - year = ""; - } - Color clickedColor = Colors.white70; - pageController.addListener(() { - clickedPosition = -2; - }); - return Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - children: [ - Center( - child: InkWell( - child: Container( - padding: - const EdgeInsets.only(bottom: 16, top: 10), - child: Align( - alignment: Alignment.center, - child: Text( - monthIAmIn + ' ' + year, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 25), + if (getCurrentYear().toString() == year) { + year = ""; + } + Color clickedColor = Colors.white70; + pageController.addListener(() { + clickedPosition = -2; + }); + return Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + children: [ + Center( + child: InkWell( + child: Container( + padding: + const EdgeInsets.only(bottom: 16, top: 10), + child: Align( + alignment: Alignment.center, + child: Text( + monthIAmIn + ' ' + year, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 25), + ), ), ), + onTap: () { + onYearPressed(context, pageController); + }, + borderRadius: BorderRadius.circular(200), ), - onTap: () { - onYearPressed(context, pageController); - }, - borderRadius: BorderRadius.circular(200), ), - ), - Padding( - child: InkWell( - onTap: () => onFindMyDayPressed(), - splashColor: Colors.red[400]!, - child: Container( - decoration: BoxDecoration( - color: Colors.transparent, - border: Border.all(color: Colors.red[400]!), - shape: BoxShape.circle, - ), - height: 25.0, - width: 25.0, - child: Center( - child: Text( - CalendarState().getCurrentDay().toString()), + Padding( + child: InkWell( + onTap: () => onFindMyDayPressed(), + splashColor: Colors.red[400]!, + child: Container( + decoration: BoxDecoration( + color: Colors.transparent, + border: Border.all(color: Colors.red[400]!), + shape: BoxShape.circle, + ), + height: 25.0, + width: 25.0, + child: Center( + child: Text( + CalendarState().getCurrentDay().toString()), + ), ), ), + padding: const EdgeInsets.only(left: 120, right: 15), ), - padding: const EdgeInsets.only(left: 120, right: 15), - ), - ], - //mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.end, - ), - Padding( - padding: const EdgeInsets.only(bottom: 20), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: const [ - Text( - "Sun", - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold), - ), - Text("Mon", - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold)), - Text("Tues", - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold)), - Text("Wed", - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold)), - Text("Thur", - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold)), - Text("Fri", - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold)), - Text("Sat", - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold)) ], + //mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.end, ), - ), - Expanded( - flex: 3, - //Builds grid of days based on number of days in month - child: GridView.builder( - itemCount: monthView.daysInMonth + mdw, - scrollDirection: Axis.vertical, - physics: const ScrollPhysics(), - gridDelegate: - const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 7, - childAspectRatio: 1 / 1.1, - ), - itemBuilder: (BuildContext context, int index) { - index += 1; - int day; - bool skip = false; - if (mdw != 0) { - day = index - monthView.monthStart; - } else { - day = index; - skip = true; - } - Color textColor; - Widget textStyleToday = Text((day).toString()); - - if ((day) == monthView.now.day && - monthView.now.month == n.now.month && - monthView.now.year == n.now.year) { - textColor = Colors.white; - textStyleToday = CircleAvatar( - backgroundColor: Colors.red[400]!, - child: Text( - day.toString(), - style: TextStyle( - color: textColor, - fontWeight: FontWeight.bold), - ), - maxRadius: 12, - ); - } - if (clickedPosition == day) { - clickedColor = Colors.red[200]!; - } else { - clickedColor = Colors.white70; - } - - int dayLetters = index - 1; - - if (index <= monthView.monthStart && !skip) { - Color colorCard; - if (darkMode) { - colorCard = Colors.black; + Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: const [ + Text( + "Sun", + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold), + ), + Text("Mon", + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold)), + Text("Tues", + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold)), + Text("Wed", + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold)), + Text("Thur", + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold)), + Text("Fri", + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold)), + Text("Sat", + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold)) + ], + ), + ), + Expanded( + flex: 3, + //Builds grid of days based on number of days in month + child: GridView.builder( + itemCount: monthView.daysInMonth + mdw, + scrollDirection: Axis.vertical, + physics: const ScrollPhysics(), + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 7, + childAspectRatio: 1 / 1.1, + ), + itemBuilder: (BuildContext context, int index) { + index += 1; + int day; + bool skip = false; + if (mdw != 0) { + day = index - monthView.monthStart; } else { - colorCard = Colors.white; + day = index; + skip = true; } + Color textColor; + Widget textStyleToday = Text((day).toString()); - return Card( - color: colorCard, - elevation: 0, - ); - } else { - if (dayLetters >= 7) { - dayLetters = (dayLetters % 7); + if ((day) == monthView.now.day && + monthView.now.month == n.now.month && + monthView.now.year == n.now.year) { + textColor = Colors.white; + textStyleToday = CircleAvatar( + backgroundColor: Colors.red[400]!, + child: Text( + day.toString(), + style: TextStyle( + color: textColor, + fontWeight: FontWeight.bold), + ), + maxRadius: 12, + ); } - var todayE = globals.eventsList[day.toString() + - userMonth.toString() + - (yearEarly + yearsPassed).toString()]; - List dayInfo = []; - dayInfo.add(textStyleToday); - if (todayE != null) { - for (var element in todayE) { - dayInfo.add(Container( - padding: const EdgeInsets.only(top: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 2, - width: 40, - )); - } + if (clickedPosition == day) { + clickedColor = Colors.red[200]!; + } else { + clickedColor = Colors.white70; } - if (globals.everyDay.isNotEmpty) { - for (var element in globals.everyDay) { - if (temporaryM >= element.page) { - if (element.from.year == - (yearsPassed + yearEarly) && - element.from.month == userMonth) { - if (day >= element.from.day) { + int dayLetters = index - 1; + + if (index <= monthView.monthStart && !skip) { + Color colorCard; + if (darkMode) { + colorCard = Colors.black; + } else { + colorCard = Colors.white; + } + + return Card( + color: colorCard, + elevation: 0, + ); + } else { + if (dayLetters >= 7) { + dayLetters = (dayLetters % 7); + } + var todayE = globals.eventsList[day.toString() + + userMonth.toString() + + (yearEarly + yearsPassed).toString()]; + List dayInfo = []; + dayInfo.add(textStyleToday); + if (todayE != null) { + for (var element in todayE) { + dayInfo.add(Container( + padding: const EdgeInsets.only(top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } + + if (globals.everyDay.isNotEmpty) { + for (var element in globals.everyDay) { + if (temporaryM >= element.page) { + if (element.from.year == + (yearsPassed + yearEarly) && + element.from.month == userMonth) { + if (day >= element.from.day) { + dayInfo.add(Container( + padding: + const EdgeInsets.only(top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } else { dayInfo.add(Container( - padding: - const EdgeInsets.only(top: 10), + padding: const EdgeInsets.only(top: 10), decoration: BoxDecoration( shape: BoxShape.rectangle, color: element.color), @@ -369,62 +390,63 @@ class CalendarState extends State { width: 40, )); } - } else { - dayInfo.add(Container( - padding: const EdgeInsets.only(top: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 2, - width: 40, - )); } } } - } - if (globals.everyWeek.isNotEmpty) { - for (var element in globals.everyWeek) { - if (temporaryM >= element.page) { - DateTime weekDay = DateTime( - yearEarly + yearsPassed, - userMonth, - day); - if (element.to - .difference(element.from) - .inDays != - 0) { - for (int i = 0; - i <= - element.to - .difference(element.from) - .inDays; - i++) { - int dayCalc = element.from.day + i; - int month = element.from.month; - int yearCalc = element.from.year; + if (globals.everyWeek.isNotEmpty) { + for (var element in globals.everyWeek) { + if (temporaryM >= element.page) { + DateTime weekDay = DateTime( + yearEarly + yearsPassed, + userMonth, + day); + if (element.to + .difference(element.from) + .inDays != + 0) { + for (int i = 0; + i <= + element.to + .difference(element.from) + .inDays; + i++) { + int dayCalc = element.from.day + i; + int month = element.from.month; + int yearCalc = element.from.year; - if (dayCalc > - DateTime(element.from.year, - element.from.month + 1, 0) - .day) { - dayCalc = 1; - month += 1; - } - if (month > 12) { - if (month % 12 == 0) { - yearCalc += month~/12; + if (dayCalc > + DateTime(element.from.year, + element.from.month + 1, 0) + .day) { + dayCalc = 1; + month += 1; } - month = 1; - } - int dayOffset = - DateTime(yearCalc, month, dayCalc) - .weekday; + if (month > 12) { + if (month % 12 == 0) { + yearCalc += month~/12; + } + month = 1; + } + int dayOffset = + DateTime(yearCalc, month, dayCalc) + .weekday; - if (weekDay.weekday == dayOffset) { - if (yearCalc == - (yearsPassed + yearEarly) && - month == userMonth) { - if (day >= dayCalc) { + if (weekDay.weekday == dayOffset) { + if (yearCalc == + (yearsPassed + yearEarly) && + month == userMonth) { + if (day >= dayCalc) { + dayInfo.add(Container( + padding: const EdgeInsets.only( + top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } else { dayInfo.add(Container( padding: const EdgeInsets.only( top: 10), @@ -435,10 +457,17 @@ class CalendarState extends State { width: 40, )); } - } else { + } + } + } else if (weekDay.weekday == + (element.from.weekday)) { + if (element.from.year == + (yearsPassed + yearEarly) && + element.from.month == userMonth) { + if (day >= element.from.day) { dayInfo.add(Container( - padding: const EdgeInsets.only( - top: 10), + padding: + const EdgeInsets.only(top: 10), decoration: BoxDecoration( shape: BoxShape.rectangle, color: element.color), @@ -446,17 +475,10 @@ class CalendarState extends State { width: 40, )); } - } - } - } else if (weekDay.weekday == - (element.from.weekday)) { - if (element.from.year == - (yearsPassed + yearEarly) && - element.from.month == userMonth) { - if (day >= element.from.day) { + } else { dayInfo.add(Container( padding: - const EdgeInsets.only(top: 10), + const EdgeInsets.only(top: 10), decoration: BoxDecoration( shape: BoxShape.rectangle, color: element.color), @@ -464,52 +486,56 @@ class CalendarState extends State { width: 40, )); } - } else { - dayInfo.add(Container( - padding: - const EdgeInsets.only(top: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 2, - width: 40, - )); } } } } - } - if (globals.everyMonth.isNotEmpty) { - for (var element in globals.everyMonth) { - if (element.to - .difference(element.from) - .inDays != - 0) { - for (int i = 0; - i <= - element.to - .difference(element.from) - .inDays; - i++) { - int dayCalc = element.from.day + i; - int monthCalc = element.from.month; + if (globals.everyMonth.isNotEmpty) { + for (var element in globals.everyMonth) { + if (element.to + .difference(element.from) + .inDays != + 0) { + for (int i = 0; + i <= + element.to + .difference(element.from) + .inDays; + i++) { + int dayCalc = element.from.day + i; + int monthCalc = element.from.month; - if (dayCalc > - DateTime(element.from.year, - element.from.month + 1, 0) - .day) { - dayCalc = 1; - monthCalc += 1; - } - if (monthCalc > 12) { - monthCalc = 1; + if (dayCalc > + DateTime(element.from.year, + element.from.month + 1, 0) + .day) { + dayCalc = 1; + monthCalc += 1; + } + if (monthCalc > 12) { + monthCalc = 1; + } + if (day == dayCalc) { + if (temporaryM >= element.page) { + dayInfo.add(Container( + padding: + const EdgeInsets.only(top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } } - if (day == dayCalc) { + } else { + if (day == element.from.day) { if (temporaryM >= element.page) { dayInfo.add(Container( padding: - const EdgeInsets.only(top: 10), + const EdgeInsets.only(top: 10), decoration: BoxDecoration( shape: BoxShape.rectangle, color: element.color), @@ -519,51 +545,52 @@ class CalendarState extends State { } } } - } else { - if (day == element.from.day) { - if (temporaryM >= element.page) { - dayInfo.add(Container( - padding: - const EdgeInsets.only(top: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 2, - width: 40, - )); - } - } } } - } - if (globals.everyYear.isNotEmpty) { - for (var element in globals.everyYear) { - if (element.to - .difference(element.from) - .inDays != - 0) { - for (int i = 0; - i <= - element.to - .difference(element.from) - .inDays; - i++) { - int dayCalc = element.from.day + i; - int month = element.from.month; + if (globals.everyYear.isNotEmpty) { + for (var element in globals.everyYear) { + if (element.to + .difference(element.from) + .inDays != + 0) { + for (int i = 0; + i <= + element.to + .difference(element.from) + .inDays; + i++) { + int dayCalc = element.from.day + i; + int month = element.from.month; - if (dayCalc > - DateTime(element.from.year, - element.from.month + 1, 0) - .day) { - dayCalc = 1; - month += 1; - } - if (month > 12) { - month = 1; - } + if (dayCalc > + DateTime(element.from.year, + element.from.month + 1, 0) + .day) { + dayCalc = 1; + month += 1; + } + if (month > 12) { + month = 1; + } - if (day == dayCalc && - userMonth == month) { + if (day == dayCalc && + userMonth == month) { + if (temporaryM >= element.page) { + dayInfo.add(Container( + padding: const EdgeInsets.only(top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } + } + } + else { + if (day == element.from.day && + userMonth == element.from.month) { if (temporaryM >= element.page) { dayInfo.add(Container( padding: const EdgeInsets.only(top: 10), @@ -577,69 +604,69 @@ class CalendarState extends State { } } } - else { - if (day == element.from.day && - userMonth == element.from.month) { - if (temporaryM >= element.page) { - dayInfo.add(Container( - padding: const EdgeInsets.only(top: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 2, - width: 40, - )); - } - } - } } - } - return SizedBox( - height: 200, - child: Card( - shape: RoundedRectangleBorder( - side: BorderSide( - color: clickedColor, width: 1), - borderRadius: BorderRadius.circular(10), - ), - child: InkWell( - borderRadius: BorderRadius.circular(50), - splashColor: Colors.deepOrangeAccent, - child: Align( - alignment: Alignment.topCenter, - child: Column( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - children: dayInfo, + return SizedBox( + height: 200, + child: Card( + shape: RoundedRectangleBorder( + side: BorderSide( + color: clickedColor, width: 1), + borderRadius: BorderRadius.circular(10), + ), + child: InkWell( + borderRadius: BorderRadius.circular(50), + splashColor: Colors.deepOrangeAccent, + child: Align( + alignment: Alignment.topCenter, + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: dayInfo, + ), ), + onTap: () => _tapDate( + day, + yearEarly + yearsPassed, + userMonth, + temporaryM), ), - onTap: () => _tapDate( - day, - yearEarly + yearsPassed, - userMonth, - temporaryM), ), - ), + ); + } + }), + ), + Expanded( + flex: 1, + child: ListView.builder( + itemCount: dayClicked.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + onLongPress: () { + + + }, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + dayClicked[index], + ] + ) ); - } - }), - ), - Expanded( - flex: 1, - child: ListView( - children: [ - Column( - children: dayClicked, - ), - ], - )), - ], - ); - }, + }, + //children: [ + //Column( + //children: dayClicked, + //), + //], + )), + ], + ); + }, + ), ), - ), - ], + ], + ), ), ); } @@ -829,25 +856,29 @@ class CalendarState extends State { } } + Widget firstLine = Spacer(); + Widget secondLine = Spacer(); + if (temp.isNotEmpty) { for (var element in temp) { - dayClicked.add(Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - padding: const EdgeInsets.only(right: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, color: element.color), - height: 15, - width: 2, - ), - const Padding(padding: EdgeInsets.only(right: 10)), - Text( - element.title, - style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 20), - ), - ], - )); + firstLine = + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.only(right: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, color: element.color), + height: 15, + width: 2, + ), + const Padding(padding: EdgeInsets.only(right: 10)), + Text( + element.title, + style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + ), + ], + ); String timeF = TimeOfDay(hour: element.from.hour, minute: element.from.minute) .format(context); @@ -858,23 +889,23 @@ class CalendarState extends State { element.from.month == element.to.month && element.from.year == element.to.year) { if (element.allDay) { - dayClicked.add(const Center( + secondLine = const Center( child: Padding( padding: EdgeInsets.only(bottom: 20), child: Text("All day"), ), - )); + ); } else { - dayClicked.add(Center( + secondLine = Center( child: Padding( padding: const EdgeInsets.only(bottom: 20), child: Text(timeF + " - " + timeT), ), - )); + ); } } else if (element.from.year == element.to.year) { if (element.allDay) { - dayClicked.add(Center( + secondLine = Center( child: Padding( padding: const EdgeInsets.only(bottom: 20), child: Text(Months().getMonthShort(element.from.month)! + @@ -885,9 +916,9 @@ class CalendarState extends State { " " + element.to.month.toString()), ), - )); + ); } else { - dayClicked.add(Center( + secondLine = Center( child: Padding( padding: const EdgeInsets.only(bottom: 20), child: Text(Months().getMonthShort(element.from.month)! + @@ -902,11 +933,11 @@ class CalendarState extends State { ", " + timeT), ), - )); + ); } } else { if (element.allDay) { - dayClicked.add(Center( + secondLine = Center( child: Padding( padding: const EdgeInsets.only(bottom: 20), child: Text(Months().getMonthShort(element.from.month)! + @@ -921,9 +952,9 @@ class CalendarState extends State { ", " + element.to.year.toString()), ), - )); + ); } else { - dayClicked.add(Center( + secondLine = Center( child: Padding( padding: const EdgeInsets.only(bottom: 20), child: Text(Months().getMonthShort(element.from.month)! + @@ -942,13 +973,15 @@ class CalendarState extends State { ", " + timeT), ), - )); + ); } } + dayClicked.add(Column(children: [firstLine, secondLine],)); } } else { - dayClicked.add(const Text("No events today")); + dayClicked.add(const Center(child: Text("No events today"))); } + final access = StateWidget.of(context); access?.updateClicked(day, year, month); DatabaseReference _day = FirebaseDatabase.instance.ref().child("test"); @@ -1030,7 +1063,7 @@ class CalendarState extends State { display = (firstYearRange.toString() + "-" + (firstYearRange + 12).toString()); - print(display); + //print(display); }); }, ), @@ -1069,4 +1102,12 @@ class CalendarState extends State { ); }); } + void onAddEventButtonPressed() { + Navigator.of(context).push(MaterialPageRoute(builder: (context) { + int? clicked = StateWidget.of(context)?.clicked; + + //print(clicked); + return const EventForm(); + })); + } } diff --git a/lib/events.dart b/lib/events.dart index 64ec52c..c2e14f6 100644 --- a/lib/events.dart +++ b/lib/events.dart @@ -7,9 +7,9 @@ class Events { String title = ""; Color color; bool allDay; - String eventType; + String type; Events(this.title, this.color, - this.allDay, this.page, this.from, this.to, this.eventType); + this.allDay, this.page, this.from, this.to, this.type); } \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 93b4588..8858025 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,13 +1,11 @@ import 'package:day_to_day/inherited.dart'; import 'package:day_to_day/login_widget.dart'; -import 'package:day_to_day/months.dart'; import 'package:day_to_day/to_do_list_directory_widget.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:firebase_database/firebase_database.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:day_to_day/calendar.dart'; -import 'package:day_to_day/event_form.dart'; import 'dart:async'; StreamController streamController = StreamController.broadcast(); @@ -154,15 +152,6 @@ class _MyStatefulWidgetState extends State ], ), ), - floatingActionButton: FloatingActionButton( - onPressed: () => onAddEventButtonPressed(), - child: const Icon( - Icons.add, - size: 45, - color: Colors.white, - ), - backgroundColor: Colors.blueGrey, - ), appBar: AppBar( title: Text( 'DayToDay', @@ -242,12 +231,5 @@ class _MyStatefulWidgetState extends State } void onSearchButtonPressed() {} - void onAddEventButtonPressed() { - Navigator.of(context).push(MaterialPageRoute(builder: (context) { - int? clicked = StateWidget.of(context)?.clicked; - //print(clicked); - return const EventForm(); - })); - } } From 01fc5f9be8c447ae4f30d543dd5ac1254da78061 Mon Sep 17 00:00:00 2001 From: Nathan Fox <58736647+Sergentfox234@users.noreply.github.com> Date: Sat, 16 Apr 2022 21:19:58 -0400 Subject: [PATCH 06/13] Added the files in a way that github should like. Updated the three pages --- lib/event_form.dart | 666 ++++++++++++++++++++++++++++++++++++ lib/event_list_storage.dart | 117 +++++++ lib/projects_widget.dart | 75 ++++ 3 files changed, 858 insertions(+) create mode 100644 lib/event_form.dart create mode 100644 lib/event_list_storage.dart create mode 100644 lib/projects_widget.dart diff --git a/lib/event_form.dart b/lib/event_form.dart new file mode 100644 index 0000000..2899d00 --- /dev/null +++ b/lib/event_form.dart @@ -0,0 +1,666 @@ +import 'package:day_to_day/EventListStorage.dart'; +import 'package:day_to_day/Inherited.dart'; +import 'Events.dart'; +import 'package:day_to_day/Months.dart'; +import 'package:day_to_day/main.dart'; +import 'package:flutter/material.dart'; +import 'globals.dart' as globals; + +class EventForm extends StatefulWidget { + EventForm({Key? key}) : super(key: key); + + @override + EventFormState createState() => EventFormState(); +} +enum SingingCharacter {daily,weekly, monthly, yearly, none} + +class EventFormState extends State { + var events = {}; + bool isSwitched = false; + TextEditingController titleController = TextEditingController(); + var weekdays = { + 1: "Mon", + 2: "Tue", + 3: "Wed", + 4: "Thu", + 5: "Fri", + 6: "Sat", + 7: "Sun" + }; + SingingCharacter? repeatingChoose = SingingCharacter.none; + + String? from; + String? to; + Months n = Months(); + DateTime selectedTime = DateTime(2020); + DateTime? selectedTimeTo; + bool chosenFrom = false; + bool chosenTFrom = false; + String timeFrom = ""; + String? selectedHour; + String finalTimeFrom = ""; + bool chosenTo = false; + bool chosenTTo = false; + String timeTo= ""; + String? selectedHourTo; + String finalTimeTo = ""; + String repeatD = "Don't repeat"; + Color colorChosenBubble = Colors.red[200]!; + String colorChosenText = "Default"; + TimeOfDay fromObj = TimeOfDay.now(); + TimeOfDay toObj = TimeOfDay.now(); + String type = "Calendar"; + String title = "Default Event"; + + @override + Widget build(BuildContext context) { + String to; + int dayF = (StateWidget.of(context)?.clicked)!; + int weekDayN; + int hour = n.now.hour; + int minute = n.now.minute; + String? weekD; + bool pastSixty = false; + if (dayF == -2 && !chosenFrom) { + selectedTime = n.now; + } else if (!chosenFrom) { + selectedTime = DateTime( + (StateWidget.of(context)?.yearFrom)!, + (StateWidget.of(context)?.monthFrom)!, + (StateWidget.of(context)?.clicked)!); + } + if (minute % 10 != 0) { + if (10 - (minute % 10) <= 5) { + minute += 10 - (minute % 10) + 5; + } else { + minute += 10 - (minute % 10); + } + } + if (minute >= 60) { + hour += 1; + if (hour == 24) { + hour == 0; + } + else if (hour == 25) { + hour = 1; + } + pastSixty = true; + minute = 0; + } + if (!chosenTFrom && !isSwitched) { + String minuteStr = minute.toString(); + if (minute == 0) { + minuteStr = minuteStr.toString() + "0"; + } + + if (hour > 12) { + hour %= 12; + timeFrom = hour.toString() + ":" + minuteStr + " PM"; + } else if (hour == 12) { + timeFrom = hour.toString() + ":" + minuteStr + " PM"; + } else { + if (hour == 0) { + hour = 12; + } + timeFrom = hour.toString() + ":" + minuteStr + " AM"; + } + finalTimeFrom = timeFrom; + } + if (!chosenTTo && !isSwitched) { + hour = n.now.hour; + hour += 1; + if (pastSixty) { + hour += 1; + } + String minuteStr = minute.toString(); + if (minute == 0) { + minuteStr = minuteStr.toString() + "0"; + } + if (hour > 12) { + hour %= 12; + timeTo = hour.toString() + ":" + minuteStr + " PM"; + } else if (hour == 12) { + timeTo = hour.toString() + ":" + minuteStr + " PM"; + } else { + if (hour == 0) { + hour = 12; + } + timeTo = hour.toString() + ":" + minuteStr + " AM"; + } + finalTimeTo = timeTo; + } + + weekDayN = selectedTime.weekday; + weekD = weekdays[weekDayN]; + from = weekD! + + ", " + + n.monthShort[selectedTime.month]! + + " " + + (selectedTime.day.toString()) + + ", " + + (selectedTime.year.toString()); + if (chosenTo) { + to = weekdays[selectedTimeTo?.weekday]! + + ", " + + n.monthShort[selectedTimeTo?.month]! + + " " + + (selectedTimeTo?.day.toString())! + + ", " + + (selectedTimeTo?.year.toString())!; + } + else { + to = weekD+ + ", " + + n.monthShort[selectedTime.month]! + + " " + + (selectedTime.day.toString()) + + ", " + + (selectedTime.year.toString()); + } + + return InheritedState( + child: Scaffold( + resizeToAvoidBottomInset: false, + body: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only( + top: 50, bottom: 12, left: 15, right: 20), + child: TextFormField( + autofocus: true, + controller: titleController, + maxLength: 50, + decoration: const InputDecoration( + border: UnderlineInputBorder(), + labelText: 'Add Event Title', + ), + onChanged: (value) { + title = value; + }, + ), + ), + const Divider(color: Colors.grey,), + Padding(padding: const EdgeInsets.only( + top: 12, bottom: 12, left: 20, right: 20), + child: Center( + child: Column( + children: [ + const Text("Event Type: "), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ElevatedButton( + style: type.contains("calendar") ? ElevatedButton.styleFrom(side: BorderSide( + color: Colors.red[200]!, width: 1)) + : ElevatedButton.styleFrom(side: BorderSide( + color: Colors.blue[100]!, width: 1)), + onPressed: () { + setState(() { + type = "calendar"; + }); + }, + child: const Center(child: Text("Calendar"))), + ElevatedButton( + style: type.contains("assignment") ? ElevatedButton.styleFrom(side: BorderSide( + color: Colors.red[200]!, width: 1)) + : ElevatedButton.styleFrom(side: BorderSide( + color: Colors.blue[100]!, width: 1)), + onPressed: () { + setState(() { + type = "assignment"; + }); + }, + child: const Center(child: Text("Assignment"))), + ElevatedButton( + style: type.contains("project") ? ElevatedButton.styleFrom(side: BorderSide( + color: Colors.red[200]!, width: 1)) + : ElevatedButton.styleFrom(side: BorderSide( + color: Colors.blue[100]!, width: 1)), + onPressed: () { + setState(() { + type = "project"; + }); + }, + child: const Center(child: Text("Project"))), + ElevatedButton( + style: type.contains("exam") ? ElevatedButton.styleFrom(side: BorderSide( + color: Colors.red[200]!, width: 1)) + : ElevatedButton.styleFrom(side: BorderSide( + color: Colors.blue[100]!, width: 1)), + onPressed: () { + setState(() { + type = "exam"; + }); + }, + child: const Center(child: Text("Exam")))] + )]),)), + InkWell( + child: Row( + children: [ + const Padding(padding: EdgeInsets.only(left: 20)), + const ImageIcon( + AssetImage("assets/icons/clock.png"), + ), + const Padding( + padding: EdgeInsets.only(left: 26), + child: Text( + "All Day", + style: TextStyle(fontSize: 20), + ), + ), + const Spacer(), + Switch(value: isSwitched, onChanged: onToggled), + ], + ), + onTap: () => onToggled(true), + ), + + Row( + children: [ + Padding( + padding: const EdgeInsets.only(left: 70), + child: InkWell( + child: Text( + from!, + style: const TextStyle(fontSize: 20), + ), + onTap: () => chooseFromDay(context, selectedTime, true), + ), + ), + const Spacer(), + Padding( + padding: const EdgeInsets.only(right: 20), + child: InkWell( + child: Text( + finalTimeFrom, + style: const TextStyle(fontSize: 20), + ), + onTap: () => chooseFromTime(context, true), + ), + ), + ], + ), + + Padding( + padding: const EdgeInsets.only(top: 30, bottom: 30), + child: Row( + children: [ + Padding( + padding: const EdgeInsets.only(left: 70), + child: InkWell( + child: Text( + to, + style: const TextStyle(fontSize: 20), + ), + onTap: () => chooseFromDay(context, selectedTime, false), + ), + ), + const Spacer(), + Padding( + padding: const EdgeInsets.only(right: 20), + child: InkWell( + child: Text( + finalTimeTo, + style: const TextStyle(fontSize: 20), + ), + onTap: () => chooseFromTime(context, false), + ), + ), + ], + ), + ), + InkWell( + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Padding(padding: EdgeInsets.only(left: 20)), + const Padding( + padding: EdgeInsets.only(bottom: 17), + child: ImageIcon( + AssetImage("assets/icons/repeat.png"), + ), + ), + Padding( + padding: const EdgeInsets.only(left: 25), + child: SizedBox( + child: Text( + repeatD, + style: const TextStyle(fontSize: 20), + ), + height: 45, + ), + ), + ], + ), + onTap: () { + onRepeat(); + }, + ), + const Divider(color: Colors.grey,), + InkWell( + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Padding(padding: EdgeInsets.only(left: 20)), + Container( + decoration: BoxDecoration( + color: colorChosenBubble, + shape: BoxShape.circle, + ), + height: 45.0, + width: 25.0, + ), + Padding( + padding: EdgeInsets.only(left: 25), + child: Text( + colorChosenText, + style: TextStyle(fontSize: 20), + ), + ), + ], + ), + onTap: () { + onColor(); + }, + ), + const Spacer(), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Align( + child: TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: Text( + "Cancel", + style: TextStyle(fontSize: 25, color: Colors.red[200]), + ), + ), + alignment: Alignment.bottomCenter, + ), + TextButton( + onPressed: () { + //If the event was saved, write it to the respective file + //!!!!!!TODO!!!!! + if (selectedTimeTo != null) { + Events newEvent = Events(selectedTime.month, selectedTime.year, selectedTime.day, title, + finalTimeFrom, finalTimeTo, (selectedTimeTo?.day)!, (selectedTimeTo?.month)!, (selectedTimeTo?.year)!, + colorChosenBubble, fromObj, toObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, 0, + type); + + StateWidget.of(context)?.addEvent(selectedTime.day, selectedTime.year, selectedTime.month, title, + finalTimeFrom, finalTimeTo, (selectedTimeTo?.day)!, (selectedTimeTo?.month)!, (selectedTimeTo?.year)!, + colorChosenBubble, toObj, fromObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, + type); + + } + else { + Events newEvent = Events(selectedTime.month, selectedTime.year, selectedTime.day, title, + finalTimeFrom, finalTimeTo, selectedTime.day, selectedTime.month, selectedTime.year, + colorChosenBubble, fromObj, toObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, 0, + type); + + StateWidget.of(context)?.addEvent(selectedTime.day, selectedTime.year, selectedTime.month, title, + finalTimeFrom, finalTimeTo, selectedTime.day, selectedTime.month, selectedTime.year, + colorChosenBubble, toObj, fromObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, + type); + } + streamController.add(true); + Navigator.pop(context); + + }, + child: Text( + "Save", + style: TextStyle(fontSize: 25, color: Colors.red[200]), + ), + ), + ], + ) + ], + ), + ), + ); + } + + void onToggled(bool state) { + if (isSwitched == false) { + setState(() { + isSwitched = true; + finalTimeFrom = ""; + finalTimeTo = ""; + }); + } else if (isSwitched == true) { + setState(() { + finalTimeFrom = timeFrom; + finalTimeTo = timeTo; + isSwitched = false; + }); + } + } + + Future chooseFromDay( + BuildContext context, DateTime current, bool fromChoose) async { + DateTime? userChosenFrom = (await showDatePicker( + builder: (context, child) { + return Theme( + data: Theme.of(context).copyWith( + colorScheme: ColorScheme.dark( + primary: Colors.red[200]!, + onPrimary: Colors.white, + onSurface: Colors.white, + ), + textButtonTheme: TextButtonThemeData( + style: TextButton.styleFrom( + primary: Colors.red[200], + ), + ), + ), child: child!, + )}, + context: context, + initialDate: current, + firstDate: DateTime(1980, 1), + lastDate: DateTime(2222)))!; + + if (fromChoose) { + if (userChosenFrom != current) { + chosenFrom = true; + setState(() { + selectedTime = userChosenFrom; + + }); + } + } else { + chosenTo = true; + setState(() { + selectedTimeTo = userChosenFrom; + }); + + } + + } + + Future chooseFromTime(BuildContext context, bool fromChoose) async { + if (fromChoose) { + TimeOfDay? userChosenTimeFrom = (await showTimePicker( + context: context, + initialTime: TimeOfDay.now(), + )); + if (userChosenTimeFrom != null) { + chosenTFrom = true; + fromObj = userChosenTimeFrom; + setState(() { + timeFrom = userChosenTimeFrom.format(context); + finalTimeFrom = userChosenTimeFrom.format(context); + }); + } + } else { + TimeOfDay? userChosenTimeTo = (await showTimePicker( + context: context, + initialTime: TimeOfDay( + hour: TimeOfDay.now().hour + 1, minute: TimeOfDay.now().minute), + )); + if (userChosenTimeTo != null) { + chosenTTo = true; + toObj = userChosenTimeTo; + setState(() { + timeTo = userChosenTimeTo.format(context); + finalTimeTo = userChosenTimeTo.format(context); + }); + } + } + } + + void onRepeat() { + + showDialog(context: context, builder: (context) { + return StatefulBuilder( + builder: (context, setState) { + return Dialog( + elevation: 20, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)), + child: SizedBox( + height: 300, + child: Column( + children: [ + RadioListTile( + title: const Text("Don't Repeat"), + value: SingingCharacter.none, + groupValue: repeatingChoose, + onChanged: (SingingCharacter? value) { + Navigator.pop(context, true); + setState(() { + repeatD = "Don't Repeat"; + repeatingChoose = value; + }); + } + ), + RadioListTile( + title: const Text("Everyday"), + value: SingingCharacter.daily, + groupValue: repeatingChoose, + onChanged: (SingingCharacter? value) { + Navigator.pop(context, true); + setState(() { + repeatD = "Everyday"; + repeatingChoose = value; + }); + } + ), + RadioListTile( + title: const Text("Every week"), + value: SingingCharacter.weekly, + groupValue: repeatingChoose, + onChanged: (SingingCharacter? value) { + Navigator.pop(context, true); + setState(() { + repeatD = "Every week"; + repeatingChoose = value; + }); + } + ), + RadioListTile( + title: const Text("Every month"), + value: SingingCharacter.monthly, + groupValue: repeatingChoose, + onChanged: (SingingCharacter? value) { + Navigator.pop(context,true); + setState(() { + repeatD = "Every month"; + repeatingChoose = value; + }); + } + ), + RadioListTile( + title: const Text("Every year"), + value: SingingCharacter.yearly, + groupValue: repeatingChoose, + onChanged: (SingingCharacter? value) { + Navigator.pop(context, true); + + setState(() { + repeatD = "Every year"; + repeatingChoose = value; + }); + } + ), + + ], + ), + ) + ); + }); + + }).then((value) { + setState(() { + + }); + }); + } + + void onColor() { + showDialog(context: context, builder: (context) { + return StatefulBuilder( + builder: (context, setState) { + return Dialog( + elevation: 20, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)), + child: SizedBox( + height: 300, + child: Column( + children: [ + chooseColor(Colors.red, "Red"), + chooseColor(Colors.green, "Green"), + chooseColor(Colors.blue, "Blue"), + chooseColor(Colors.yellow, "Yellow"), + chooseColor(Colors.orange, "Orange"), + chooseColor(Colors.red[200]!, "Default"), + + ], + ), + ) + ); + }); + + }).then((value) { + setState(() { + + }); + }); + } + Widget chooseColor(Color color, String text) { + return + Padding( + padding: const EdgeInsets.only(left: 20), + child: InkWell( + onTap: () { + Navigator.pop(context, true); + setState(() { + colorChosenBubble = color; + colorChosenText = text; + }); + }, + child: Row( + children: [ + Container( + decoration: BoxDecoration( + color: color, + shape: BoxShape.circle, + ), + height: 45.0, + width: 25.0, + padding: const EdgeInsets.only(right: 50), + ), + Padding( + padding: const EdgeInsets.only(left: 20), + child: Text(text, + style: const TextStyle(fontSize: 20), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/event_list_storage.dart b/lib/event_list_storage.dart new file mode 100644 index 0000000..a7c683f --- /dev/null +++ b/lib/event_list_storage.dart @@ -0,0 +1,117 @@ +import 'package:flutter/material.dart'; +import 'dart:convert'; +import 'Events.dart'; +import 'package:path_provider/path_provider.dart'; +import 'dart:io'; + +// This class is used to read and write files in the application +class EventListStorage { + var typeName = ""; + EventListStorage(this.typeName); + + Future get _localPath async { + final directory = await getApplicationDocumentsDirectory(); + + return directory.path; + } + + Future get _localFile async { + final path = await _localPath; + File file = File('$path/$typeName.txt'); + if (!await file.exists()) { + file.writeAsString(""); + } + return file; + } + + Future> readEvents() async { + final file = await _localFile; + + // Read the file + final contents = await file.readAsString(); + + List events = []; + DateTime from = DateTime.now(); + DateTime to = DateTime.now(); + int dayT = 0; + int monthT = 0; + int yearT = 0; + int dayF = 0; + int monthF = 0; + int yearF = 0; + int page = 0; + String type = ""; + String title = ""; + Color color; + bool allDay; + + if (contents.isEmpty) { + return []; + } + + var data = contents.split(":"); + for (int i = 0; i < data.length / 11; i++) { + type = data[i * 11]; + monthF = int.parse(data[i * 11 + 1]); + monthT = int.parse(data[i * 11 + 2]); + yearF = int.parse(data[i * 11 + 3]); + page = int.parse(data[i * 11 + 4]); + yearT = int.parse(data[i * 11 + 5]); + dayT = int.parse(data[i * 11 + 6]); + dayF = int.parse(data[i * 11 + 7]); + title = data[i * 11 + 8]; + color = data[i * 11 + 9] as Color; + if (data[i * 11 + 10].contains("rue")) { + allDay = true; + } else { + allDay = false; + } + + from = DateTime(yearF, monthF, dayF, 0, 0, 0, 0, 0); + to = DateTime(yearT, monthT, dayT, 0, 0, 0, 0, 0); + + events.add(Events(from, to, title, color, allDay, page, type)); + } + + return events; + } + + Future writeEvents(List events) async { + //This is the file + final file = await _localFile; + + //Set globals.timestamp = date.now() every time you write + + /*Every event has + DateTime from; + DateTime to; + int page = 0; + String type = ""; + String title = ""; + Color color; + bool allDay;*/ + + for (int i = 0; i < events.length; i++) { + file.writeAsString(events[i].from.toIso8601String()); + file.writeAsString(events[i].to.toIso8601String()); + file.writeAsString(events[i].page.toString()); + file.writeAsString(events[i].type); + file.writeAsString(events[i].title); + file.writeAsString(events[i].color.toString()); + if (events[i].allDay) { + file.writeAsString("True"); + } else { + file.writeAsString("False"); + } + } + + return file; + } + + Future writeEvent(Events event) async { + final file = await _localFile; + List oldList = await readEvents(); + oldList.add(event); + return writeEvents(oldList); + } +} diff --git a/lib/projects_widget.dart b/lib/projects_widget.dart new file mode 100644 index 0000000..1df391e --- /dev/null +++ b/lib/projects_widget.dart @@ -0,0 +1,75 @@ +import 'package:day_to_day/globals.dart'; +import 'event_list_storage.dart'; +import 'event_form.dart'; +import 'package:flutter/material.dart'; +import 'events.dart'; +import 'globals.dart' as globals; +//import 'package:firebase_database/firebase_database.dart'; + +class ProjectsWidget extends StatefulWidget { + List projects = []; + ProjectsWidget({Key? key}) : super(key: key); + + @override + State createState() => ProjectsState(); +} + +class ProjectsState extends State { + @override + Widget build(BuildContext context) { + projects = []; + globals.eventsList.forEach((key, value) { + for (int i = 0; i < value.length; i++) { + if (value[i].type.contains("project")) { + projects.add(value[i]); + } + } + }); + print("\n\n\nProjects: " + projects.length.toString()); + return Scaffold( + appBar: AppBar( + title: const Center(child: Text("Projects List")), + backgroundColor: const Color.fromARGB(255, 255, 82, 82), + ), + body: ListView.builder( + itemCount: projects.length, + itemBuilder: (BuildContext context, int index) { + return Card( + child: CheckboxListTile( + dense: true, + activeColor: Colors.red[400], + controlAffinity: ListTileControlAffinity.leading, + value: false, + onChanged: (value) { + setState(() { + projects.removeAt(index); + }); + }, + title: Text( + projects[index].title, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20, + color: Color.fromARGB(255, 12, 12, 12)), + ))); + }, + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + setState(() { + Navigator.of(context).push(MaterialPageRoute(builder: (context) { + return EventForm(); + })); + }); + setState(() {}); + }, + child: const Icon( + Icons.add, + size: 45, + color: Colors.white, + ), + backgroundColor: Colors.blueGrey, + ), + ); + } +} From 3189d0de471172060c0e43beb0968d09a6913ae3 Mon Sep 17 00:00:00 2001 From: Nathan Fox <58736647+Sergentfox234@users.noreply.github.com> Date: Sat, 16 Apr 2022 22:04:56 -0400 Subject: [PATCH 07/13] Added assignments page --- lib/Assignments.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Assignments.dart b/lib/Assignments.dart index 291fdc8..7174204 100644 --- a/lib/Assignments.dart +++ b/lib/Assignments.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -import 'EventForm.dart'; +import 'event_form.dart'; import 'globals.dart' as globals; -import 'Events.dart'; +import 'events.dart'; class AssignmentsWidget extends StatefulWidget { List hw = []; @@ -17,7 +17,7 @@ class AssignmentsState extends State { @override Widget build(BuildContext context) { widget.hw = []; - globals.events.forEach((key, value) { + globals.eventsList.forEach((key, value) { for (int i = 0; i < value.length; i++) { if (value[i].type.contains("assign")) { widget.hw.add(value[i]); From 095f588d4806e5a18ab8aa635ba7ef020815140d Mon Sep 17 00:00:00 2001 From: Nathan Fox <58736647+Sergentfox234@users.noreply.github.com> Date: Sat, 16 Apr 2022 22:11:32 -0400 Subject: [PATCH 08/13] Added the three tabs hopefully --- lib/Exams.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Exams.dart b/lib/Exams.dart index 5c18a1d..6a6b81a 100644 --- a/lib/Exams.dart +++ b/lib/Exams.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -import 'EventForm.dart'; +import 'event_form.dart'; import 'globals.dart' as globals; -import 'Events.dart'; +import 'events.dart'; class ExamsWidget extends StatefulWidget { List exams = []; @@ -15,7 +15,7 @@ class ExamsState extends State { @override Widget build(BuildContext context) { widget.exams = []; - globals.events.forEach((key, value) { + globals.eventsList.forEach((key, value) { for (int i = 0; i < value.length; i++) { if (value[i].type.contains("exam")) { widget.exams.add(value[i]); From 0cb98d68c10bfbdf51e36c0ea8d0e606f9131e74 Mon Sep 17 00:00:00 2001 From: joseph81301 Date: Sat, 16 Apr 2022 22:39:24 -0400 Subject: [PATCH 09/13] Fixes --- lib/Calendar.dart | 809 ----------------------- lib/EventForm.dart | 666 ------------------- lib/EventListStorage.dart | 153 ----- lib/Events.dart | 42 -- lib/Inherited.dart | 226 ------- lib/ProjectsWidget.dart | 8 +- lib/calendar.dart | 1113 ++++++++++++++++++++++++++++++++ lib/event_form.dart | 71 +- lib/event_list_storage.dart | 4 +- lib/events.dart | 15 + lib/globals.dart | 4 +- lib/inherited.dart | 154 +++++ lib/main.dart | 11 +- pubspec.lock | 10 +- test/calendar_widget_test.dart | 10 +- 15 files changed, 1345 insertions(+), 1951 deletions(-) delete mode 100644 lib/Calendar.dart delete mode 100644 lib/EventForm.dart delete mode 100644 lib/EventListStorage.dart delete mode 100644 lib/Events.dart delete mode 100644 lib/Inherited.dart create mode 100644 lib/calendar.dart create mode 100644 lib/events.dart create mode 100644 lib/inherited.dart diff --git a/lib/Calendar.dart b/lib/Calendar.dart deleted file mode 100644 index c1a33c0..0000000 --- a/lib/Calendar.dart +++ /dev/null @@ -1,809 +0,0 @@ -import 'dart:async'; -import 'package:day_to_day/Inherited.dart'; -import 'package:day_to_day/Months.dart'; -import 'package:flutter/material.dart'; -import 'Events.dart'; -import 'EventForm.dart'; -import 'globals.dart' as globals; -import 'package:firebase_database/firebase_database.dart'; - -class CalendarWidget extends StatefulWidget { - CalendarWidget(this.eventList, {Key? key, required this.stream}) - : super(key: key); - final Stream stream; - List eventList; - - @override - State createState() => CalendarState(); -} - -class CalendarState extends State { - //Creating month object to get data about what day it is - Months n = Months(); - PageController pageController = PageController(); - String display = ""; - int clickedPosition = -1; - List dayClicked = []; - - @override - void initState() { - var equation = ((getCurrentYear() - 1980) * 12 + getCurrentMonth()) - 1; - pageController = PageController(initialPage: equation); - widget.stream.listen((event) { - mySetStateAdd(); - }); - super.initState(); - } - - @override - void dispose() { - pageController.dispose(); - super.dispose(); - } - - void mySetStateAdd() { - setState(() { - clickedPosition = -1; - dayClicked.clear(); - }); - } - - @override - Widget build(BuildContext context) { - Months monthView; - var systemColor = MediaQuery.of(context).platformBrightness; - bool darkMode = systemColor == Brightness.dark; - - return Scaffold( - body: InheritedState( - child: Column( - children: [ - Expanded( - //Builds separate page for each month of every year since 1980 - child: PageView.builder( - controller: pageController, - scrollDirection: Axis.vertical, - itemBuilder: (BuildContext context, int pages) { - int temporaryM = pages; - - if (clickedPosition == -1) { - clickedPosition = getCurrentDay(); - if (globals.events[getCurrentDay().toString() + - getCurrentMonth().toString() + - getCurrentYear().toString()] != - null) { - globals.events[getCurrentDay().toString() + - getCurrentMonth().toString() + - getCurrentYear().toString()] - ?.forEach((element) { - dayClicked.add(Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - padding: EdgeInsets.only(right: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 15, - width: 2, - ), - Padding(padding: EdgeInsets.only(right: 10)), - Text( - element.title, - style: const TextStyle( - fontWeight: FontWeight.bold, fontSize: 20), - ), - ], - )); - if (element.dayFrom == element.dayTo && - element.monthFrom == element.monthTo && - element.yearFrom == element.yearTo) { - dayClicked.add(Center( - child: - Text(element.timeF + " - " + element.timeT), - )); - } else if (element.yearFrom == element.yearTo) { - dayClicked.add(Center( - child: Text( - Months().getMonthShort(element.monthFrom)! + - " " + - element.dayFrom.toString() + - ", " + - element.timeF + - " - " + - Months().getMonthShort(element.monthTo)! + - " " + - element.dayTo.toString() + - ", " + - element.timeT), - )); - } else { - dayClicked.add(Center( - child: Text( - Months().getMonthShort(element.monthFrom)! + - " " + - element.dayFrom.toString() + - ", " + - element.yearFrom.toString() + - ", " + - element.timeF + - " - " + - Months().getMonthShort(element.monthTo)! + - " " + - element.dayTo.toString() + - ", " + - element.yearTo.toString() + - ", " + - element.timeT), - )); - } - }); - } else { - dayClicked.add(const Text("No events today")); - } - } - - int yearsPassed = 1; - if (pages > 12) { - temporaryM = (temporaryM % 12) + 1; - } - int userMonth = temporaryM; - temporaryM = pages; - - var yearEarly = 1980; - yearsPassed = (pages / 12).floor(); - int earlyYear = yearEarly + yearsPassed; - String monthIAmIn = n.currentMonth; - if (n.now.month == userMonth && n.now.year == earlyYear) { - monthView = n; - } else { - monthView = Months.otherYears(userMonth, earlyYear); - } - int mdw = monthView.monthStart; - if (monthView.monthStart == 7) { - mdw = 0; - } - monthIAmIn = n.month[userMonth].toString(); - - String year = (yearEarly + yearsPassed).toString(); - - if (getCurrentYear().toString() == year) { - year = ""; - } - Color clickedColor = Colors.white70; - pageController.addListener(() { - clickedPosition = -2; - }); - return Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - children: [ - Center( - child: InkWell( - child: Container( - padding: const EdgeInsets.only( - bottom: 16, top: 10), - child: Align( - alignment: Alignment.center, - child: Text( - monthIAmIn + ' ' + year, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 25), - ), - ), - ), - onTap: () { - onYearPressed(context, pageController); - }, - borderRadius: BorderRadius.circular(200), - ), - ), - Padding( - child: InkWell( - onTap: () => onFindMyDayPressed(), - splashColor: Colors.red[400]!, - child: Container( - decoration: BoxDecoration( - color: Colors.transparent, - border: Border.all(color: Colors.red[400]!), - shape: BoxShape.circle, - ), - height: 25.0, - width: 25.0, - child: Center( - child: Text(CalendarState() - .getCurrentDay() - .toString()), - ), - ), - ), - padding: - const EdgeInsets.only(left: 120, right: 15), - ), - ], - //mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.end, - ), - Padding( - padding: const EdgeInsets.only(bottom: 20), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: const [ - Text( - "Sun", - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold), - ), - Text("Mon", - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold)), - Text("Tues", - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold)), - Text("Wed", - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold)), - Text("Thur", - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold)), - Text("Fri", - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold)), - Text("Sat", - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold)) - ], - ), - ), - Expanded( - flex: 2, - //Builds grid of days based on number of days in month - child: GridView.builder( - itemCount: monthView.daysInMonth + mdw, - scrollDirection: Axis.vertical, - physics: const ScrollPhysics(), - gridDelegate: - const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 7, - childAspectRatio: 1 / 1.1, - ), - itemBuilder: (BuildContext context, int index) { - index += 1; - int day; - bool skip = false; - if (mdw != 0) { - day = index - monthView.monthStart; - } else { - day = index; - skip = true; - } - Color textColor; - Widget textStyleToday = Text((day).toString()); - - if ((day) == monthView.now.day && - monthView.now.month == n.now.month && - monthView.now.year == n.now.year) { - textColor = Colors.white; - textStyleToday = CircleAvatar( - backgroundColor: Colors.red[400]!, - child: Text( - day.toString(), - style: TextStyle( - color: textColor, - fontWeight: FontWeight.bold), - ), - maxRadius: 12, - ); - } - if (clickedPosition == day) { - clickedColor = Colors.red[200]!; - } else { - clickedColor = Colors.white70; - } - - int dayLetters = index - 1; - - if (index <= monthView.monthStart && !skip) { - Color colorCard; - if (darkMode) { - colorCard = Colors.black; - } else { - colorCard = Colors.white; - } - - return Card( - color: colorCard, - elevation: 0, - ); - } else { - if (dayLetters >= 7) { - dayLetters = (dayLetters % 7); - } - var todayE = globals.events[day.toString() + - userMonth.toString() + - (yearEarly + yearsPassed).toString()]; - List dayInfo = []; - dayInfo.add(textStyleToday); - if (todayE != null) { - for (var element in todayE) { - dayInfo.add(Container( - padding: const EdgeInsets.only(top: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 2, - width: 40, - )); - } - } - if (globals.everyDay.isNotEmpty) { - for (var element in globals.everyDay) { - if (temporaryM >= element.page) { - if (element.yearFrom == - (yearsPassed + yearEarly) && - element.monthFrom == userMonth) { - if (day >= element.dayFrom) { - dayInfo.add(Container( - padding: const EdgeInsets.only( - top: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 2, - width: 40, - )); - } - } else { - dayInfo.add(Container( - padding: - const EdgeInsets.only(top: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 2, - width: 40, - )); - } - } - } - } - if (globals.everyWeek.isNotEmpty) { - for (var element in globals.everyWeek) { - if (temporaryM >= element.page) { - DateTime wee = DateTime( - yearEarly + yearsPassed, - userMonth, - day); - if (wee.weekday == (element.weekDay)) { - if (element.yearFrom == - (yearsPassed + yearEarly) && - element.monthFrom == userMonth) { - if (day >= element.dayFrom) { - dayInfo.add(Container( - padding: const EdgeInsets.only( - top: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 2, - width: 40, - )); - } - } else { - dayInfo.add(Container( - padding: const EdgeInsets.only( - top: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 2, - width: 40, - )); - } - } - } - } - } - - if (globals.everyMonth.isNotEmpty) { - for (var element in globals.everyMonth) { - if (day == element.dayFrom) { - if (temporaryM >= element.page) { - dayInfo.add(Container( - padding: - const EdgeInsets.only(top: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 2, - width: 40, - )); - } - } - } - } - if (globals.everyYear.isNotEmpty) { - for (var element in globals.everyYear) { - if (day == element.dayFrom && - userMonth == element.monthFrom) { - if (temporaryM >= element.page) { - dayInfo.add(Container( - padding: - const EdgeInsets.only(top: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: element.color), - height: 2, - width: 40, - )); - } - } - } - } - - return SizedBox( - height: 200, - child: Card( - shape: RoundedRectangleBorder( - side: BorderSide( - color: clickedColor, width: 1), - borderRadius: BorderRadius.circular(10), - ), - child: InkWell( - borderRadius: BorderRadius.circular(50), - splashColor: Colors.deepOrangeAccent, - child: Align( - alignment: Alignment.topCenter, - child: Column( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - children: dayInfo, - ), - ), - onTap: () => _tapDate( - day, - yearEarly + yearsPassed, - userMonth, - temporaryM), - ), - ), - ); - } - }), - ), - Expanded( - flex: 1, - child: ListView( - children: [ - Column( - children: dayClicked, - ), - ], - )), - ], - ); - }, - ), - ), - ], - ), - ), - floatingActionButton: FloatingActionButton( - onPressed: () => onAddEventButtonPressed(), - child: const Icon( - Icons.add, - size: 45, - color: Colors.white, - ), - )); - } - - void onAddEventButtonPressed() { - Navigator.of(context).push(MaterialPageRoute(builder: (context) { - int? clicked = StateWidget.of(context)?.clicked; - - //print(clicked); - return EventForm(); - })); - } - - void _tapDate(int day, int year, int month, int page) { - dayClicked.clear(); - - setState(() { - clickedPosition = day; - }); - List temp; - if (globals.events[day.toString() + month.toString() + year.toString()] != - null) { - temp = (globals - .events[day.toString() + month.toString() + year.toString()])!; - } else { - temp = []; - } - - if (globals.everyDay.isNotEmpty) { - for (var element in globals.everyDay) { - if (page >= element.page) { - if (element.yearFrom == year && element.monthFrom == month) { - if (day >= element.dayFrom) { - temp.add(element); - } - } else { - temp.add(element); - } - } - } - } - if (globals.everyWeek.isNotEmpty) { - for (var element in globals.everyWeek) { - DateTime wee = DateTime(year, month, day); - if (wee.weekday == (element.weekDay)) { - if (page >= element.page) { - if (element.yearFrom == year && element.monthFrom == month) { - if (day >= element.dayFrom) { - temp.add(element); - } - } else { - temp.add(element); - } - } - } - } - } - if (globals.everyMonth.isNotEmpty) { - for (var element in globals.everyMonth) { - if (day == element.dayFrom) { - if (page >= element.page) { - if (element.yearFrom == year && element.monthFrom == month) { - if (day >= element.dayFrom) { - temp.add(element); - } - } else { - temp.add(element); - } - } - } - } - } - if (globals.everyYear.isNotEmpty) { - for (var element in globals.everyYear) { - if (day == element.dayFrom && month == element.monthFrom) { - if (page >= element.page) { - if (element.yearFrom == year && element.monthFrom == month) { - if (day >= element.dayFrom) { - temp.add(element); - } - } else { - temp.add(element); - } - } - } - } - } - if (temp.isNotEmpty) { - temp.forEach((element) { - dayClicked.add(Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - padding: const EdgeInsets.only(right: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, color: element.color), - height: 15, - width: 2, - ), - const Padding(padding: EdgeInsets.only(right: 10)), - Text( - element.title, - style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 20), - ), - ], - )); - if (element.dayFrom == element.dayTo && - element.monthFrom == element.monthTo && - element.yearFrom == element.yearTo) { - if (element.allDay) { - dayClicked.add(const Center( - child: Text("All day"), - )); - } else { - dayClicked.add(Center( - child: Text(element.timeF + " - " + element.timeT), - )); - } - } else if (element.yearFrom == element.yearTo) { - if (element.allDay) { - dayClicked.add(Center( - child: Text(Months().getMonthShort(element.monthFrom)! + - " " + - element.dayFrom.toString() + - " - " + - Months().getMonthShort(element.monthTo)! + - " " + - element.dayTo.toString()), - )); - } else { - dayClicked.add(Center( - child: Text(Months().getMonthShort(element.monthFrom)! + - " " + - element.dayFrom.toString() + - ", " + - element.timeF + - " - " + - Months().getMonthShort(element.monthTo)! + - " " + - element.dayTo.toString() + - ", " + - element.timeT), - )); - } - } else { - if (element.allDay) { - dayClicked.add(Center( - child: Text(Months().getMonthShort(element.monthFrom)! + - " " + - element.dayFrom.toString() + - ", " + - element.yearFrom.toString() + - " - " + - Months().getMonthShort(element.monthTo)! + - " " + - element.dayTo.toString() + - ", " + - element.yearTo.toString()), - )); - } else { - dayClicked.add(Center( - child: Text(Months().getMonthShort(element.monthFrom)! + - " " + - element.dayFrom.toString() + - ", " + - element.yearFrom.toString() + - ", " + - element.timeF + - " - " + - Months().getMonthShort(element.monthTo)! + - " " + - element.dayTo.toString() + - ", " + - element.yearTo.toString() + - ", " + - element.timeT), - )); - } - } - }); - } else { - dayClicked.add(const Text("No events today")); - } - final access = StateWidget.of(context); - access?.updateClicked(day, year, month); - DatabaseReference _day = FirebaseDatabase.instance.ref().child("test"); - _day.set("Day tapped: ${day}"); - print(day); - } - - void navigationPress(int month, int year, BuildContext context) { - Navigator.pop(context); - pageController.animateToPage(year * 12 + month, - duration: const Duration(seconds: 1), curve: Curves.easeIn); - } - - int getCurrentMonth() { - return n.now.month; - } - - int getCurrentDay() { - return n.now.day; - } - - int getCurrentYear() { - return n.now.year; - } - - int getClicked() { - return clickedPosition; - } - - void onYearPressed(BuildContext context, PageController pageController) { - showModalBottomSheet( - context: context, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - ), - backgroundColor: Colors.black, - builder: (BuildContext context) { - return SizedBox( - child: selectMonth(context, pageController), - height: 200, - width: 200, - ); - }, - ); - } - - void onFindMyDayPressed() { - if (pageController.hasClients) { - pageController.animateToPage( - ((getCurrentYear() - 1980) * 12 + getCurrentMonth()) - 1, - duration: const Duration(seconds: 2), - curve: Curves.easeIn); - } - } - - Widget selectMonth(BuildContext context, PageController pageController) { - int equation = getCurrentYear() - 1980; - - PageController selectionController = PageController( - initialPage: equation, - ); - return PageView.builder( - scrollDirection: Axis.horizontal, - controller: selectionController, - itemBuilder: (BuildContext context, int year) { - var displayYear = (1980 + year).toString(); - display = displayYear; - return Column( - children: [ - InkWell( - child: Text( - display, - style: const TextStyle( - fontSize: 20, fontWeight: FontWeight.bold), - ), - onTap: () { - var firstYearRange = 1980 + ((year / 12).floor() * 12); - setState(() { - display = (firstYearRange.toString() + - "-" + - (firstYearRange + 12).toString()); - print(display); - }); - }, - ), - Expanded( - child: GridView.builder( - itemCount: 12, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 6, - ), - itemBuilder: (BuildContext context, int month) { - Color monthName; - if (month + 1 == getCurrentMonth() && - year == getCurrentYear() - 1980) { - monthName = Colors.red[200]!; - } else { - monthName = Colors.grey[800]!; - } - return Container( - padding: const EdgeInsets.all(5), - child: ElevatedButton( - child: Text( - n.getMonthShort(month + 1).toString(), - style: const TextStyle(fontSize: 12), - ), - onPressed: () => navigationPress(month, year, context), - style: ElevatedButton.styleFrom( - primary: monthName, - side: const BorderSide(width: 1.0, color: Colors.red), - shape: const CircleBorder(), - ), - ), - ); - }, - )), - ], - ); - }); - } -} diff --git a/lib/EventForm.dart b/lib/EventForm.dart deleted file mode 100644 index 2899d00..0000000 --- a/lib/EventForm.dart +++ /dev/null @@ -1,666 +0,0 @@ -import 'package:day_to_day/EventListStorage.dart'; -import 'package:day_to_day/Inherited.dart'; -import 'Events.dart'; -import 'package:day_to_day/Months.dart'; -import 'package:day_to_day/main.dart'; -import 'package:flutter/material.dart'; -import 'globals.dart' as globals; - -class EventForm extends StatefulWidget { - EventForm({Key? key}) : super(key: key); - - @override - EventFormState createState() => EventFormState(); -} -enum SingingCharacter {daily,weekly, monthly, yearly, none} - -class EventFormState extends State { - var events = {}; - bool isSwitched = false; - TextEditingController titleController = TextEditingController(); - var weekdays = { - 1: "Mon", - 2: "Tue", - 3: "Wed", - 4: "Thu", - 5: "Fri", - 6: "Sat", - 7: "Sun" - }; - SingingCharacter? repeatingChoose = SingingCharacter.none; - - String? from; - String? to; - Months n = Months(); - DateTime selectedTime = DateTime(2020); - DateTime? selectedTimeTo; - bool chosenFrom = false; - bool chosenTFrom = false; - String timeFrom = ""; - String? selectedHour; - String finalTimeFrom = ""; - bool chosenTo = false; - bool chosenTTo = false; - String timeTo= ""; - String? selectedHourTo; - String finalTimeTo = ""; - String repeatD = "Don't repeat"; - Color colorChosenBubble = Colors.red[200]!; - String colorChosenText = "Default"; - TimeOfDay fromObj = TimeOfDay.now(); - TimeOfDay toObj = TimeOfDay.now(); - String type = "Calendar"; - String title = "Default Event"; - - @override - Widget build(BuildContext context) { - String to; - int dayF = (StateWidget.of(context)?.clicked)!; - int weekDayN; - int hour = n.now.hour; - int minute = n.now.minute; - String? weekD; - bool pastSixty = false; - if (dayF == -2 && !chosenFrom) { - selectedTime = n.now; - } else if (!chosenFrom) { - selectedTime = DateTime( - (StateWidget.of(context)?.yearFrom)!, - (StateWidget.of(context)?.monthFrom)!, - (StateWidget.of(context)?.clicked)!); - } - if (minute % 10 != 0) { - if (10 - (minute % 10) <= 5) { - minute += 10 - (minute % 10) + 5; - } else { - minute += 10 - (minute % 10); - } - } - if (minute >= 60) { - hour += 1; - if (hour == 24) { - hour == 0; - } - else if (hour == 25) { - hour = 1; - } - pastSixty = true; - minute = 0; - } - if (!chosenTFrom && !isSwitched) { - String minuteStr = minute.toString(); - if (minute == 0) { - minuteStr = minuteStr.toString() + "0"; - } - - if (hour > 12) { - hour %= 12; - timeFrom = hour.toString() + ":" + minuteStr + " PM"; - } else if (hour == 12) { - timeFrom = hour.toString() + ":" + minuteStr + " PM"; - } else { - if (hour == 0) { - hour = 12; - } - timeFrom = hour.toString() + ":" + minuteStr + " AM"; - } - finalTimeFrom = timeFrom; - } - if (!chosenTTo && !isSwitched) { - hour = n.now.hour; - hour += 1; - if (pastSixty) { - hour += 1; - } - String minuteStr = minute.toString(); - if (minute == 0) { - minuteStr = minuteStr.toString() + "0"; - } - if (hour > 12) { - hour %= 12; - timeTo = hour.toString() + ":" + minuteStr + " PM"; - } else if (hour == 12) { - timeTo = hour.toString() + ":" + minuteStr + " PM"; - } else { - if (hour == 0) { - hour = 12; - } - timeTo = hour.toString() + ":" + minuteStr + " AM"; - } - finalTimeTo = timeTo; - } - - weekDayN = selectedTime.weekday; - weekD = weekdays[weekDayN]; - from = weekD! + - ", " + - n.monthShort[selectedTime.month]! + - " " + - (selectedTime.day.toString()) + - ", " + - (selectedTime.year.toString()); - if (chosenTo) { - to = weekdays[selectedTimeTo?.weekday]! + - ", " + - n.monthShort[selectedTimeTo?.month]! + - " " + - (selectedTimeTo?.day.toString())! + - ", " + - (selectedTimeTo?.year.toString())!; - } - else { - to = weekD+ - ", " + - n.monthShort[selectedTime.month]! + - " " + - (selectedTime.day.toString()) + - ", " + - (selectedTime.year.toString()); - } - - return InheritedState( - child: Scaffold( - resizeToAvoidBottomInset: false, - body: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.only( - top: 50, bottom: 12, left: 15, right: 20), - child: TextFormField( - autofocus: true, - controller: titleController, - maxLength: 50, - decoration: const InputDecoration( - border: UnderlineInputBorder(), - labelText: 'Add Event Title', - ), - onChanged: (value) { - title = value; - }, - ), - ), - const Divider(color: Colors.grey,), - Padding(padding: const EdgeInsets.only( - top: 12, bottom: 12, left: 20, right: 20), - child: Center( - child: Column( - children: [ - const Text("Event Type: "), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - ElevatedButton( - style: type.contains("calendar") ? ElevatedButton.styleFrom(side: BorderSide( - color: Colors.red[200]!, width: 1)) - : ElevatedButton.styleFrom(side: BorderSide( - color: Colors.blue[100]!, width: 1)), - onPressed: () { - setState(() { - type = "calendar"; - }); - }, - child: const Center(child: Text("Calendar"))), - ElevatedButton( - style: type.contains("assignment") ? ElevatedButton.styleFrom(side: BorderSide( - color: Colors.red[200]!, width: 1)) - : ElevatedButton.styleFrom(side: BorderSide( - color: Colors.blue[100]!, width: 1)), - onPressed: () { - setState(() { - type = "assignment"; - }); - }, - child: const Center(child: Text("Assignment"))), - ElevatedButton( - style: type.contains("project") ? ElevatedButton.styleFrom(side: BorderSide( - color: Colors.red[200]!, width: 1)) - : ElevatedButton.styleFrom(side: BorderSide( - color: Colors.blue[100]!, width: 1)), - onPressed: () { - setState(() { - type = "project"; - }); - }, - child: const Center(child: Text("Project"))), - ElevatedButton( - style: type.contains("exam") ? ElevatedButton.styleFrom(side: BorderSide( - color: Colors.red[200]!, width: 1)) - : ElevatedButton.styleFrom(side: BorderSide( - color: Colors.blue[100]!, width: 1)), - onPressed: () { - setState(() { - type = "exam"; - }); - }, - child: const Center(child: Text("Exam")))] - )]),)), - InkWell( - child: Row( - children: [ - const Padding(padding: EdgeInsets.only(left: 20)), - const ImageIcon( - AssetImage("assets/icons/clock.png"), - ), - const Padding( - padding: EdgeInsets.only(left: 26), - child: Text( - "All Day", - style: TextStyle(fontSize: 20), - ), - ), - const Spacer(), - Switch(value: isSwitched, onChanged: onToggled), - ], - ), - onTap: () => onToggled(true), - ), - - Row( - children: [ - Padding( - padding: const EdgeInsets.only(left: 70), - child: InkWell( - child: Text( - from!, - style: const TextStyle(fontSize: 20), - ), - onTap: () => chooseFromDay(context, selectedTime, true), - ), - ), - const Spacer(), - Padding( - padding: const EdgeInsets.only(right: 20), - child: InkWell( - child: Text( - finalTimeFrom, - style: const TextStyle(fontSize: 20), - ), - onTap: () => chooseFromTime(context, true), - ), - ), - ], - ), - - Padding( - padding: const EdgeInsets.only(top: 30, bottom: 30), - child: Row( - children: [ - Padding( - padding: const EdgeInsets.only(left: 70), - child: InkWell( - child: Text( - to, - style: const TextStyle(fontSize: 20), - ), - onTap: () => chooseFromDay(context, selectedTime, false), - ), - ), - const Spacer(), - Padding( - padding: const EdgeInsets.only(right: 20), - child: InkWell( - child: Text( - finalTimeTo, - style: const TextStyle(fontSize: 20), - ), - onTap: () => chooseFromTime(context, false), - ), - ), - ], - ), - ), - InkWell( - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const Padding(padding: EdgeInsets.only(left: 20)), - const Padding( - padding: EdgeInsets.only(bottom: 17), - child: ImageIcon( - AssetImage("assets/icons/repeat.png"), - ), - ), - Padding( - padding: const EdgeInsets.only(left: 25), - child: SizedBox( - child: Text( - repeatD, - style: const TextStyle(fontSize: 20), - ), - height: 45, - ), - ), - ], - ), - onTap: () { - onRepeat(); - }, - ), - const Divider(color: Colors.grey,), - InkWell( - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const Padding(padding: EdgeInsets.only(left: 20)), - Container( - decoration: BoxDecoration( - color: colorChosenBubble, - shape: BoxShape.circle, - ), - height: 45.0, - width: 25.0, - ), - Padding( - padding: EdgeInsets.only(left: 25), - child: Text( - colorChosenText, - style: TextStyle(fontSize: 20), - ), - ), - ], - ), - onTap: () { - onColor(); - }, - ), - const Spacer(), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Align( - child: TextButton( - onPressed: () { - Navigator.pop(context); - }, - child: Text( - "Cancel", - style: TextStyle(fontSize: 25, color: Colors.red[200]), - ), - ), - alignment: Alignment.bottomCenter, - ), - TextButton( - onPressed: () { - //If the event was saved, write it to the respective file - //!!!!!!TODO!!!!! - if (selectedTimeTo != null) { - Events newEvent = Events(selectedTime.month, selectedTime.year, selectedTime.day, title, - finalTimeFrom, finalTimeTo, (selectedTimeTo?.day)!, (selectedTimeTo?.month)!, (selectedTimeTo?.year)!, - colorChosenBubble, fromObj, toObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, 0, - type); - - StateWidget.of(context)?.addEvent(selectedTime.day, selectedTime.year, selectedTime.month, title, - finalTimeFrom, finalTimeTo, (selectedTimeTo?.day)!, (selectedTimeTo?.month)!, (selectedTimeTo?.year)!, - colorChosenBubble, toObj, fromObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, - type); - - } - else { - Events newEvent = Events(selectedTime.month, selectedTime.year, selectedTime.day, title, - finalTimeFrom, finalTimeTo, selectedTime.day, selectedTime.month, selectedTime.year, - colorChosenBubble, fromObj, toObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, 0, - type); - - StateWidget.of(context)?.addEvent(selectedTime.day, selectedTime.year, selectedTime.month, title, - finalTimeFrom, finalTimeTo, selectedTime.day, selectedTime.month, selectedTime.year, - colorChosenBubble, toObj, fromObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, - type); - } - streamController.add(true); - Navigator.pop(context); - - }, - child: Text( - "Save", - style: TextStyle(fontSize: 25, color: Colors.red[200]), - ), - ), - ], - ) - ], - ), - ), - ); - } - - void onToggled(bool state) { - if (isSwitched == false) { - setState(() { - isSwitched = true; - finalTimeFrom = ""; - finalTimeTo = ""; - }); - } else if (isSwitched == true) { - setState(() { - finalTimeFrom = timeFrom; - finalTimeTo = timeTo; - isSwitched = false; - }); - } - } - - Future chooseFromDay( - BuildContext context, DateTime current, bool fromChoose) async { - DateTime? userChosenFrom = (await showDatePicker( - builder: (context, child) { - return Theme( - data: Theme.of(context).copyWith( - colorScheme: ColorScheme.dark( - primary: Colors.red[200]!, - onPrimary: Colors.white, - onSurface: Colors.white, - ), - textButtonTheme: TextButtonThemeData( - style: TextButton.styleFrom( - primary: Colors.red[200], - ), - ), - ), child: child!, - )}, - context: context, - initialDate: current, - firstDate: DateTime(1980, 1), - lastDate: DateTime(2222)))!; - - if (fromChoose) { - if (userChosenFrom != current) { - chosenFrom = true; - setState(() { - selectedTime = userChosenFrom; - - }); - } - } else { - chosenTo = true; - setState(() { - selectedTimeTo = userChosenFrom; - }); - - } - - } - - Future chooseFromTime(BuildContext context, bool fromChoose) async { - if (fromChoose) { - TimeOfDay? userChosenTimeFrom = (await showTimePicker( - context: context, - initialTime: TimeOfDay.now(), - )); - if (userChosenTimeFrom != null) { - chosenTFrom = true; - fromObj = userChosenTimeFrom; - setState(() { - timeFrom = userChosenTimeFrom.format(context); - finalTimeFrom = userChosenTimeFrom.format(context); - }); - } - } else { - TimeOfDay? userChosenTimeTo = (await showTimePicker( - context: context, - initialTime: TimeOfDay( - hour: TimeOfDay.now().hour + 1, minute: TimeOfDay.now().minute), - )); - if (userChosenTimeTo != null) { - chosenTTo = true; - toObj = userChosenTimeTo; - setState(() { - timeTo = userChosenTimeTo.format(context); - finalTimeTo = userChosenTimeTo.format(context); - }); - } - } - } - - void onRepeat() { - - showDialog(context: context, builder: (context) { - return StatefulBuilder( - builder: (context, setState) { - return Dialog( - elevation: 20, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)), - child: SizedBox( - height: 300, - child: Column( - children: [ - RadioListTile( - title: const Text("Don't Repeat"), - value: SingingCharacter.none, - groupValue: repeatingChoose, - onChanged: (SingingCharacter? value) { - Navigator.pop(context, true); - setState(() { - repeatD = "Don't Repeat"; - repeatingChoose = value; - }); - } - ), - RadioListTile( - title: const Text("Everyday"), - value: SingingCharacter.daily, - groupValue: repeatingChoose, - onChanged: (SingingCharacter? value) { - Navigator.pop(context, true); - setState(() { - repeatD = "Everyday"; - repeatingChoose = value; - }); - } - ), - RadioListTile( - title: const Text("Every week"), - value: SingingCharacter.weekly, - groupValue: repeatingChoose, - onChanged: (SingingCharacter? value) { - Navigator.pop(context, true); - setState(() { - repeatD = "Every week"; - repeatingChoose = value; - }); - } - ), - RadioListTile( - title: const Text("Every month"), - value: SingingCharacter.monthly, - groupValue: repeatingChoose, - onChanged: (SingingCharacter? value) { - Navigator.pop(context,true); - setState(() { - repeatD = "Every month"; - repeatingChoose = value; - }); - } - ), - RadioListTile( - title: const Text("Every year"), - value: SingingCharacter.yearly, - groupValue: repeatingChoose, - onChanged: (SingingCharacter? value) { - Navigator.pop(context, true); - - setState(() { - repeatD = "Every year"; - repeatingChoose = value; - }); - } - ), - - ], - ), - ) - ); - }); - - }).then((value) { - setState(() { - - }); - }); - } - - void onColor() { - showDialog(context: context, builder: (context) { - return StatefulBuilder( - builder: (context, setState) { - return Dialog( - elevation: 20, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)), - child: SizedBox( - height: 300, - child: Column( - children: [ - chooseColor(Colors.red, "Red"), - chooseColor(Colors.green, "Green"), - chooseColor(Colors.blue, "Blue"), - chooseColor(Colors.yellow, "Yellow"), - chooseColor(Colors.orange, "Orange"), - chooseColor(Colors.red[200]!, "Default"), - - ], - ), - ) - ); - }); - - }).then((value) { - setState(() { - - }); - }); - } - Widget chooseColor(Color color, String text) { - return - Padding( - padding: const EdgeInsets.only(left: 20), - child: InkWell( - onTap: () { - Navigator.pop(context, true); - setState(() { - colorChosenBubble = color; - colorChosenText = text; - }); - }, - child: Row( - children: [ - Container( - decoration: BoxDecoration( - color: color, - shape: BoxShape.circle, - ), - height: 45.0, - width: 25.0, - padding: const EdgeInsets.only(right: 50), - ), - Padding( - padding: const EdgeInsets.only(left: 20), - child: Text(text, - style: const TextStyle(fontSize: 20), - ), - ), - ], - ), - ), - ); - } -} diff --git a/lib/EventListStorage.dart b/lib/EventListStorage.dart deleted file mode 100644 index d4641b8..0000000 --- a/lib/EventListStorage.dart +++ /dev/null @@ -1,153 +0,0 @@ -import 'package:flutter/material.dart'; -import 'dart:convert'; -import 'Events.dart'; -import 'package:path_provider/path_provider.dart'; -import 'dart:io'; - -// This class is used to read and write files in the application -class EventListStorage { - var typeName = ""; - EventListStorage(this.typeName); - - Future get _localPath async { - final directory = await getApplicationDocumentsDirectory(); - - return directory.path; - } - - Future get _localFile async { - final path = await _localPath; - File file = File('$path/$typeName.txt'); - if (!await file.exists()) { - file.writeAsString(""); - } - return file; - } - - Future> readEvents() async { - final file = await _localFile; - - // Read the file - final contents = await file.readAsString(); - - List events = []; - String type = ""; - int monthFrom = 0; - int monthTo = 0; - int yearFrom = 0; - int page = 0; - int yearTo = 0; - int dayTo = 0; - int dayFrom = 0; - String title = ""; - String timeF = ""; - String timeT = ""; - Color color; - TimeOfDay fromT; - TimeOfDay toT; - bool allDay; - String repeat; - int weekDay = 0; - - if (contents.isEmpty) { - return []; - } - - var data = contents.split(":"); - for (int i = 0; i < data.length / 17; i++) { - type = data[i * 17]; - monthFrom = int.parse(data[i * 17 + 1]); - monthTo = int.parse(data[i * 17 + 2]); - yearFrom = int.parse(data[i * 17 + 3]); - page = int.parse(data[i * 17 + 4]); - yearTo = int.parse(data[i * 17 + 5]); - dayTo = int.parse(data[i * 17 + 6]); - dayFrom = int.parse(data[i * 17 + 7]); - title = data[i * 17 + 8]; - timeF = data[i * 17 + 9]; - timeT = data[i * 17 + 10]; - color = data[i * 17 + 11] as Color; - fromT = data[i * 17 + 12] as TimeOfDay; - toT = data[i * 17 + 13] as TimeOfDay; - if (data[i * 17 + 14].contains("rue")) { - allDay = true; - } else { - allDay = false; - } - repeat = data[i * 17 + 15]; - weekDay = int.parse(data[i * 17 + 16]); - - events.add(Events( - monthFrom, - yearFrom, - dayFrom, - title, - timeF, - timeT, - dayTo, - monthTo, - yearTo, - color, - fromT, - toT, - allDay, - repeat, - page, - weekDay, - type)); - } - - return events; - } - - Future writeEvents(List events) async { - //This is the file - final file = await _localFile; - - /*Every event has String type = ""; - int monthFrom = 0; - int monthTo = 0; - int yearFrom = 0; - int page = 0; - int yearTo = 0; - int dayTo = 0; - int dayFrom = 0; - String title = ""; - String timeF = ""; - String timeT = ""; - Color color; - TimeOfDay fromT; - TimeOfDay toT; - bool allDay; - String repeat; - int weekDay = 0;*/ - for (int i = 0; i < events.length; i++) { - file.writeAsString(events[i].type + ":"); - file.writeAsString(events[i].monthFrom.toString() + ":"); - file.writeAsString(events[i].monthTo.toString() + ":"); - file.writeAsString(events[i].yearFrom.toString() + ":"); - file.writeAsString(events[i].yearTo.toString() + ":"); - file.writeAsString(events[i].page.toString() + ":"); - file.writeAsString(events[i].dayFrom.toString() + ":"); - file.writeAsString(events[i].dayTo.toString() + ":"); - file.writeAsString(events[i].title + ":"); - file.writeAsString(events[i].timeF + ":"); - file.writeAsString(events[i].timeT + ":"); - file.writeAsString(events[i].color.toString() + ":"); - file.writeAsString(events[i].fromT.toString() + ":"); - file.writeAsString(events[i].toT.toString() + ":"); - file.writeAsString(events[i].allDay.toString() + ":"); - file.writeAsString(events[i].repeat + ":"); - file.writeAsString(events[i].weekDay.toString() + ":"); - } - - return file; - } - - Future writeEvent(Events event) async { - final file = await _localFile; - List oldList = await readEvents(); - oldList.add(event); - return writeEvents(oldList); - } -} diff --git a/lib/Events.dart b/lib/Events.dart deleted file mode 100644 index 95f518a..0000000 --- a/lib/Events.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'dart:ffi'; - -import 'package:flutter/material.dart'; - -class Events { - String type = ""; - int monthFrom = 0; - int monthTo = 0; - int yearFrom = 0; - int page = 0; - int yearTo = 0; - int dayTo = 0; - int dayFrom = 0; - String title = ""; - String timeF = ""; - String timeT = ""; - Color color; - TimeOfDay fromT; - TimeOfDay toT; - bool allDay; - String repeat; - int weekDay = 0; - - Events( - this.monthFrom, - this.yearFrom, - this.dayFrom, - this.title, - this.timeF, - this.timeT, - this.dayTo, - this.monthTo, - this.yearTo, - this.color, - this.fromT, - this.toT, - this.allDay, - this.repeat, - this.page, - this.weekDay, - this.type); -} diff --git a/lib/Inherited.dart b/lib/Inherited.dart deleted file mode 100644 index 26f888f..0000000 --- a/lib/Inherited.dart +++ /dev/null @@ -1,226 +0,0 @@ -import 'package:flutter/material.dart'; -import 'Events.dart'; -import 'globals.dart' as globals; - -class InheritedState extends StatefulWidget { - final Widget child; - - const InheritedState({ - Key? key, - required this.child, - }) : super(key: key); - - @override - _InheritedStateState createState() => _InheritedStateState(); -} - -class _InheritedStateState extends State { - int clicked = -2; - int eventAdded = 0; - - int yearFrom = 0; - int monthFrom = 0; - - void updateClicked(int position, int yearC, int monthC) { - clicked = position; - yearFrom = yearC; - monthFrom = monthC; - } - - void addEvent( - int dayFrom, - int yearFrom, - int monthFrom, - String title, - String timeF, - String timeT, - int dayTo, - int monthTo, - int yearTo, - Color color, - TimeOfDay toT, - TimeOfDay fromT, - bool allDay, - String repeat, - int page, - String type) { - int weekDay = DateTime(yearFrom, monthFrom, dayFrom).weekday; - if (repeat == "Everyday") { - globals.everyDay.add(Events( - monthFrom, - yearFrom, - dayFrom, - title, - timeF, - timeT, - dayTo, - monthTo, - yearTo, - color, - fromT, - toT, - allDay, - repeat, - page, - weekDay, - type)); - } else if (repeat == "Every week") { - globals.everyWeek.add(Events( - monthFrom, - yearFrom, - dayFrom, - title, - timeF, - timeT, - dayTo, - monthTo, - yearTo, - color, - fromT, - toT, - allDay, - repeat, - page, - weekDay, - type)); - } else if (repeat == "Every month") { - globals.everyMonth.add(Events( - monthFrom, - yearFrom, - dayFrom, - title, - timeF, - timeT, - dayTo, - monthTo, - yearTo, - color, - fromT, - toT, - allDay, - repeat, - page, - weekDay, - type)); - } else if (repeat == "Every year") { - globals.everyYear.add(Events( - monthFrom, - yearFrom, - dayFrom, - title, - timeF, - timeT, - dayTo, - monthTo, - yearTo, - color, - fromT, - toT, - allDay, - repeat, - page, - weekDay, - type)); - } else { - if (globals.events[dayFrom.toString() + - monthFrom.toString() + - yearFrom.toString()] != - null) { - globals.events[ - dayFrom.toString() + monthFrom.toString() + yearFrom.toString()] - ?.add(Events( - monthFrom, - yearFrom, - dayFrom, - title, - timeF, - timeT, - dayTo, - monthTo, - yearTo, - color, - fromT, - toT, - allDay, - repeat, - page, - weekDay, - type)); - } else { - List temp = [ - Events( - monthFrom, - yearFrom, - dayFrom, - title, - timeF, - timeT, - dayTo, - monthTo, - yearTo, - color, - fromT, - toT, - allDay, - repeat, - page, - weekDay, - type) - ]; - globals.events[dayFrom.toString() + - monthFrom.toString() + - yearFrom.toString()] = temp; - } - } - - globals - .events[dayFrom.toString() + monthFrom.toString() + yearFrom.toString()] - ?.sort((a, b) { - if (a.fromT.hour == b.fromT.hour) { - return a.fromT.minute.compareTo(b.fromT.minute); - } else { - return a.fromT.hour.compareTo(b.fromT.hour); - } - }); - } - - @override - Widget build(BuildContext context) => StateWidget( - child: widget.child, - clicked: clicked, - monthFrom: monthFrom, - yearFrom: yearFrom, - eventAdded: eventAdded, - state: this, - ); -} - -class StateWidget extends InheritedWidget { - final int clicked; - final _InheritedStateState state; - final int yearFrom; - final int eventAdded; - final int monthFrom; - - const StateWidget({ - Key? key, - required Widget child, - required this.clicked, - required this.state, - required this.monthFrom, - required this.yearFrom, - required this.eventAdded, - }) : super(key: key, child: child); - - static _InheritedStateState? of(BuildContext context) => - context.dependOnInheritedWidgetOfExactType()?.state; - - @override - bool updateShouldNotify(StateWidget oldWidget) { - return oldWidget.clicked != clicked || - oldWidget.monthFrom != monthFrom || - oldWidget.yearFrom != yearFrom || - oldWidget.eventAdded != eventAdded || - oldWidget.state != state; - } -} diff --git a/lib/ProjectsWidget.dart b/lib/ProjectsWidget.dart index d4d92f6..e45e40d 100644 --- a/lib/ProjectsWidget.dart +++ b/lib/ProjectsWidget.dart @@ -1,8 +1,8 @@ import 'package:day_to_day/globals.dart'; -import 'EventListStorage.dart'; -import 'EventForm.dart'; +import 'event_form.dart'; +import 'event_list_storage.dart'; import 'package:flutter/material.dart'; -import 'Events.dart'; +import 'events.dart'; import 'globals.dart' as globals; //import 'package:firebase_database/firebase_database.dart'; @@ -18,7 +18,7 @@ class ProjectsState extends State { @override Widget build(BuildContext context) { projects = []; - globals.events.forEach((key, value) { + globals.eventsList.forEach((key, value) { for (int i = 0; i < value.length; i++) { if (value[i].type.contains("project")) { projects.add(value[i]); diff --git a/lib/calendar.dart b/lib/calendar.dart new file mode 100644 index 0000000..99c8b35 --- /dev/null +++ b/lib/calendar.dart @@ -0,0 +1,1113 @@ +import 'dart:async'; +import 'package:day_to_day/inherited.dart'; +import 'package:day_to_day/months.dart'; +import 'package:flutter/material.dart'; +import 'event_form.dart'; +import 'events.dart'; +import 'globals.dart' as globals; +import 'package:firebase_database/firebase_database.dart'; + +class CalendarWidget extends StatefulWidget { + const CalendarWidget({Key? key, required this.stream}) : super(key: key); + final Stream stream; + + @override + State createState() => CalendarState(); +} + +class CalendarState extends State { + //Creating month object to get data about what day it is + Months n = Months(); + PageController pageController = PageController(); + String display = ""; + int clickedPosition = -1; + List dayClicked = []; + Map span = {}; + + @override + void initState() { + var equation = ((getCurrentYear() - 1980) * 12 + getCurrentMonth()) - 1; + pageController = PageController(initialPage: equation); + widget.stream.listen((event) { + mySetStateAdd(); + }); + super.initState(); + } + + @override + void dispose() { + pageController.dispose(); + super.dispose(); + } + + void mySetStateAdd() { + setState(() { + clickedPosition = -1; + dayClicked.clear(); + }); + } + + @override + Widget build(BuildContext context) { + Months monthView; + var systemColor = MediaQuery.of(context).platformBrightness; + bool darkMode = systemColor == Brightness.dark; + + return InheritedState( + child: Scaffold( + floatingActionButton: FloatingActionButton( + onPressed: () => onAddEventButtonPressed(), + child: const Icon( + Icons.add, + size: 45, + color: Colors.white, + ), + backgroundColor: Colors.blueGrey, + ), + body: Column( + children: [ + Expanded( + //Builds separate page for each month of every year since 1980 + child: PageView.builder( + controller: pageController, + scrollDirection: Axis.vertical, + itemBuilder: (BuildContext context, int pages) { + int temporaryM = pages; + + if (clickedPosition == -1) { + clickedPosition = getCurrentDay(); + if (globals.eventsList[getCurrentDay().toString() + + getCurrentMonth().toString() + + getCurrentYear().toString()] != + null) { + globals.eventsList[getCurrentDay().toString() + + getCurrentMonth().toString() + + getCurrentYear().toString()] + ?.forEach((element) { + dayClicked.add(Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.only(right: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 15, + width: 2, + ), + const Padding(padding: EdgeInsets.only(right: 10)), + Text( + element.title, + style: const TextStyle( + fontWeight: FontWeight.bold, fontSize: 20), + ), + ], + )); + String timeF = TimeOfDay( + hour: element.from.hour, + minute: element.from.minute) + .format(context); + String timeT = TimeOfDay( + hour: element.to.hour, minute: element.to.minute) + .format(context); + String repeatingString; + + if (element.from.day == element.to.day && + element.from.month == element.to.month && + element.from.year == element.to.year) { + dayClicked.add(Center( + child: Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Text(timeF + " - " + timeT), + ), + )); + } else if (element.from.year == element.to.year) { + dayClicked.add(Center( + child: Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Text( + Months().getMonthShort(element.from.month)! + + " " + + element.from.day.toString() + + ", " + + timeF + + " - " + + Months().getMonthShort(element.to.month)! + + " " + + element.to.day.toString() + + ", " + + timeT), + ), + )); + } else { + dayClicked.add(Center( + child: Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Text( + Months().getMonthShort(element.from.month)! + + " " + + element.from.day.toString() + + ", " + + element.from.year.toString() + + ", " + + timeF + + " - " + + Months().getMonthShort(element.to.month)! + + " " + + element.to.day.toString() + + ", " + + element.to.year.toString() + + ", " + + timeT), + ), + )); + } + }); + } else { + dayClicked.add(const Text("No events today")); + } + } + + int yearsPassed = 1; + if (pages > 12) { + temporaryM = (temporaryM % 12) + 1; + } + int userMonth = temporaryM; + temporaryM = pages; + + var yearEarly = 1980; + yearsPassed = (pages / 12).floor(); + int earlyYear = yearEarly + yearsPassed; + String monthIAmIn = n.currentMonth; + if (n.now.month == userMonth && n.now.year == earlyYear) { + monthView = n; + } else { + monthView = Months.otherYears(userMonth, earlyYear); + } + int mdw = monthView.monthStart; + if (monthView.monthStart == 7) { + mdw = 0; + } + monthIAmIn = n.month[userMonth].toString(); + + String year = (yearEarly + yearsPassed).toString(); + + if (getCurrentYear().toString() == year) { + year = ""; + } + Color clickedColor = Colors.white70; + pageController.addListener(() { + clickedPosition = -2; + }); + return Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + children: [ + Center( + child: InkWell( + child: Container( + padding: + const EdgeInsets.only(bottom: 16, top: 10), + child: Align( + alignment: Alignment.center, + child: Text( + monthIAmIn + ' ' + year, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 25), + ), + ), + ), + onTap: () { + onYearPressed(context, pageController); + }, + borderRadius: BorderRadius.circular(200), + ), + ), + Padding( + child: InkWell( + onTap: () => onFindMyDayPressed(), + splashColor: Colors.red[400]!, + child: Container( + decoration: BoxDecoration( + color: Colors.transparent, + border: Border.all(color: Colors.red[400]!), + shape: BoxShape.circle, + ), + height: 25.0, + width: 25.0, + child: Center( + child: Text( + CalendarState().getCurrentDay().toString()), + ), + ), + ), + padding: const EdgeInsets.only(left: 120, right: 15), + ), + ], + //mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.end, + ), + Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: const [ + Text( + "Sun", + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold), + ), + Text("Mon", + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold)), + Text("Tues", + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold)), + Text("Wed", + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold)), + Text("Thur", + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold)), + Text("Fri", + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold)), + Text("Sat", + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold)) + ], + ), + ), + Expanded( + flex: 3, + //Builds grid of days based on number of days in month + child: GridView.builder( + itemCount: monthView.daysInMonth + mdw, + scrollDirection: Axis.vertical, + physics: const ScrollPhysics(), + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 7, + childAspectRatio: 1 / 1.1, + ), + itemBuilder: (BuildContext context, int index) { + index += 1; + int day; + bool skip = false; + if (mdw != 0) { + day = index - monthView.monthStart; + } else { + day = index; + skip = true; + } + Color textColor; + Widget textStyleToday = Text((day).toString()); + + if ((day) == monthView.now.day && + monthView.now.month == n.now.month && + monthView.now.year == n.now.year) { + textColor = Colors.white; + textStyleToday = CircleAvatar( + backgroundColor: Colors.red[400]!, + child: Text( + day.toString(), + style: TextStyle( + color: textColor, + fontWeight: FontWeight.bold), + ), + maxRadius: 12, + ); + } + if (clickedPosition == day) { + clickedColor = Colors.red[200]!; + } else { + clickedColor = Colors.white70; + } + + int dayLetters = index - 1; + + if (index <= monthView.monthStart && !skip) { + Color colorCard; + if (darkMode) { + colorCard = Colors.black; + } else { + colorCard = Colors.white; + } + + return Card( + color: colorCard, + elevation: 0, + ); + } else { + if (dayLetters >= 7) { + dayLetters = (dayLetters % 7); + } + var todayE = globals.eventsList[day.toString() + + userMonth.toString() + + (yearEarly + yearsPassed).toString()]; + List dayInfo = []; + dayInfo.add(textStyleToday); + if (todayE != null) { + for (var element in todayE) { + dayInfo.add(Container( + padding: const EdgeInsets.only(top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } + + if (globals.everyDay.isNotEmpty) { + for (var element in globals.everyDay) { + if (temporaryM >= element.page) { + if (element.from.year == + (yearsPassed + yearEarly) && + element.from.month == userMonth) { + if (day >= element.from.day) { + dayInfo.add(Container( + padding: + const EdgeInsets.only(top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } else { + dayInfo.add(Container( + padding: const EdgeInsets.only(top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } + } + } + if (globals.everyWeek.isNotEmpty) { + for (var element in globals.everyWeek) { + if (temporaryM >= element.page) { + DateTime weekDay = DateTime( + yearEarly + yearsPassed, + userMonth, + day); + if (element.to + .difference(element.from) + .inDays != + 0) { + for (int i = 0; + i <= + element.to + .difference(element.from) + .inDays; + i++) { + int dayCalc = element.from.day + i; + int month = element.from.month; + int yearCalc = element.from.year; + + if (dayCalc > + DateTime(element.from.year, + element.from.month + 1, 0) + .day) { + dayCalc = 1; + month += 1; + } + if (month > 12) { + if (month % 12 == 0) { + yearCalc += month~/12; + } + month = 1; + } + int dayOffset = + DateTime(yearCalc, month, dayCalc) + .weekday; + + if (weekDay.weekday == dayOffset) { + if (yearCalc == + (yearsPassed + yearEarly) && + month == userMonth) { + if (day >= dayCalc) { + dayInfo.add(Container( + padding: const EdgeInsets.only( + top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } else { + dayInfo.add(Container( + padding: const EdgeInsets.only( + top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } + } + } else if (weekDay.weekday == + (element.from.weekday)) { + if (element.from.year == + (yearsPassed + yearEarly) && + element.from.month == userMonth) { + if (day >= element.from.day) { + dayInfo.add(Container( + padding: + const EdgeInsets.only(top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } else { + dayInfo.add(Container( + padding: + const EdgeInsets.only(top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } + } + } + } + + if (globals.everyMonth.isNotEmpty) { + for (var element in globals.everyMonth) { + if (element.to + .difference(element.from) + .inDays != + 0) { + for (int i = 0; + i <= + element.to + .difference(element.from) + .inDays; + i++) { + int dayCalc = element.from.day + i; + int monthCalc = element.from.month; + + if (dayCalc > + DateTime(element.from.year, + element.from.month + 1, 0) + .day) { + dayCalc = 1; + monthCalc += 1; + } + if (monthCalc > 12) { + monthCalc = 1; + } + if (day == dayCalc) { + if (temporaryM >= element.page) { + dayInfo.add(Container( + padding: + const EdgeInsets.only(top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } + } + } else { + if (day == element.from.day) { + if (temporaryM >= element.page) { + dayInfo.add(Container( + padding: + const EdgeInsets.only(top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } + } + } + } + if (globals.everyYear.isNotEmpty) { + for (var element in globals.everyYear) { + if (element.to + .difference(element.from) + .inDays != + 0) { + for (int i = 0; + i <= + element.to + .difference(element.from) + .inDays; + i++) { + int dayCalc = element.from.day + i; + int month = element.from.month; + + if (dayCalc > + DateTime(element.from.year, + element.from.month + 1, 0) + .day) { + dayCalc = 1; + month += 1; + } + if (month > 12) { + month = 1; + } + + if (day == dayCalc && + userMonth == month) { + if (temporaryM >= element.page) { + dayInfo.add(Container( + padding: const EdgeInsets.only(top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } + } + } + else { + if (day == element.from.day && + userMonth == element.from.month) { + if (temporaryM >= element.page) { + dayInfo.add(Container( + padding: const EdgeInsets.only(top: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: element.color), + height: 2, + width: 40, + )); + } + } + } + } + } + + return SizedBox( + height: 200, + child: Card( + shape: RoundedRectangleBorder( + side: BorderSide( + color: clickedColor, width: 1), + borderRadius: BorderRadius.circular(10), + ), + child: InkWell( + borderRadius: BorderRadius.circular(50), + splashColor: Colors.deepOrangeAccent, + child: Align( + alignment: Alignment.topCenter, + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: dayInfo, + ), + ), + onTap: () => _tapDate( + day, + yearEarly + yearsPassed, + userMonth, + temporaryM), + ), + ), + ); + } + }), + ), + Expanded( + flex: 1, + child: ListView.builder( + itemCount: dayClicked.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + onLongPress: () { + + + }, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + dayClicked[index], + ] + ) + ); + }, + //children: [ + //Column( + //children: dayClicked, + //), + //], + )), + ], + ); + }, + ), + ), + ], + ), + ), + ); + } + + void _tapDate(int day, int year, int month, int page) { + dayClicked.clear(); + + setState(() { + clickedPosition = day; + }); + List temp; + if (globals + .eventsList[day.toString() + month.toString() + year.toString()] != + null) { + temp = (globals + .eventsList[day.toString() + month.toString() + year.toString()])!; + } else { + temp = []; + } + List repeatingStrings = []; + if (globals.everyDay.isNotEmpty) { + for (var element in globals.everyDay) { + if (page >= element.page) { + if (element.from.year == year && element.from.month == month) { + if (day >= element.from.day) { + temp.add(element); + } + } else { + temp.add(element); + } + } + } + } + if (globals.everyWeek.isNotEmpty) { + for (var element in globals.everyWeek) { + DateTime weekDay = DateTime(year, month, day); + if (element.to.difference(element.from).inDays != 0) { + for (int i = 0; + i <= element.to.difference(element.from).inDays; + i++) { + int dayCalc = element.from.day + i; + int monthCalc = element.from.month; + int yearCalc = element.from.year; + + if (dayCalc > + DateTime(element.from.year, element.from.month + 1, 0).day) { + dayCalc = 1; + monthCalc += 1; + } + if (monthCalc > 12) { + if (month % 12 == 0) { + yearCalc += month~/12; + } + monthCalc = 1; + } + int dayOffset = DateTime(yearCalc, monthCalc, dayCalc).weekday; + if (weekDay.weekday == dayOffset) { + if (page >= element.page) { + if (yearCalc == year && month == monthCalc) { + if (day >= dayCalc) { + temp.add(element); + } + } else { + temp.add(element); + } + } + } + } + } else { + if (weekDay.weekday == (element.from.weekday)) { + if (page >= element.page) { + if (element.from.year == year && element.from.month == month) { + if (day >= element.from.day) { + temp.add(element); + } + } else { + temp.add(element); + } + } + } + } + } + } + if (globals.everyMonth.isNotEmpty) { + for (var element in globals.everyMonth) { + if (element.to.difference(element.from).inDays != 0) { + for (int i = 0; + i <= element.to.difference(element.from).inDays; + i++) { + int dayCalc = element.from.day + i; + int monthCalc = element.from.month; + int yearCalc = element.from.year; + + if (dayCalc > + DateTime(element.from.year, element.from.month + 1, 0).day) { + dayCalc = 1; + monthCalc += 1; + } + if (monthCalc > 12) { + if (month % 12 == 0) { + yearCalc += month~/12; + } + monthCalc = 1; + } + if (day == dayCalc) { + if (page >= element.page) { + if (yearCalc == year && monthCalc == month) { + if (day >= element.from.day) { + temp.add(element); + } + } else { + temp.add(element); + } + } + } + } + } else { + if (day == element.from.day) { + if (page >= element.page) { + if (element.from.year == year && element.from.month == month) { + if (day >= element.from.day) { + temp.add(element); + } + } else { + temp.add(element); + } + } + } + } + } + } + if (globals.everyYear.isNotEmpty) { + for (var element in globals.everyYear) { + if (element.to + .difference(element.from) + .inDays != + 0) { + for (int i = 0; + i <= + element.to + .difference(element.from) + .inDays; + i++) { + int dayCalc = element.from.day + i; + int monthCalc = element.from.month; + int yearCalc = element.from.year; + + if (dayCalc > + DateTime(element.from.year, + element.from.month + 1, 0) + .day) { + dayCalc = 1; + month += 1; + } + if (month > 12) { + if (month % 12 == 0) { + yearCalc += month~/12; + } + month = 1; + } + if (day == dayCalc && month == monthCalc) { + if (page >= element.page) { + if (yearCalc == year && monthCalc == month) { + if (day >= element.from.day) { + temp.add(element); + } + } else { + temp.add(element); + } + } + } + } + } + else { + if (day == element.from.day && month == element.from.month) { + if (page >= element.page) { + if (element.from.year == year && element.from.month == month) { + if (day >= element.from.day) { + temp.add(element); + } + } else { + temp.add(element); + } + } + } + } + + } + } + Widget firstLine = Spacer(); + Widget secondLine = Spacer(); + + if (temp.isNotEmpty) { + for (var element in temp) { + firstLine = + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.only(right: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, color: element.color), + height: 15, + width: 2, + ), + const Padding(padding: EdgeInsets.only(right: 10)), + Text( + element.title, + style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + ), + ], + ); + String timeF = + TimeOfDay(hour: element.from.hour, minute: element.from.minute) + .format(context); + String timeT = + TimeOfDay(hour: element.to.hour, minute: element.to.minute) + .format(context); + if (element.from.day == element.to.day && + element.from.month == element.to.month && + element.from.year == element.to.year) { + if (element.allDay) { + secondLine = const Center( + child: Padding( + padding: EdgeInsets.only(bottom: 20), + child: Text("All day"), + ), + ); + } else { + secondLine = Center( + child: Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Text(timeF + " - " + timeT), + ), + ); + } + } else if (element.from.year == element.to.year) { + if (element.allDay) { + secondLine = Center( + child: Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Text(Months().getMonthShort(element.from.month)! + + " " + + element.from.month.toString() + + " - " + + Months().getMonthShort(element.to.month)! + + " " + + element.to.month.toString()), + ), + ); + } else { + secondLine = Center( + child: Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Text(Months().getMonthShort(element.from.month)! + + " " + + element.from.day.toString() + + ", " + + timeF + + " - " + + Months().getMonthShort(element.to.month)! + + " " + + element.to.day.toString() + + ", " + + timeT), + ), + ); + } + } else { + if (element.allDay) { + secondLine = Center( + child: Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Text(Months().getMonthShort(element.from.month)! + + " " + + element.from.day.toString() + + ", " + + element.from.year.toString() + + " - " + + Months().getMonthShort(element.to.month)! + + " " + + element.to.day.toString() + + ", " + + element.to.year.toString()), + ), + ); + } else { + secondLine = Center( + child: Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Text(Months().getMonthShort(element.from.month)! + + " " + + element.from.day.toString() + + ", " + + element.from.year.toString() + + ", " + + timeF + + " - " + + Months().getMonthShort(element.to.month)! + + " " + + element.to.day.toString() + + ", " + + element.to.day.toString() + + ", " + + timeT), + ), + ); + } + } + dayClicked.add(Column(children: [firstLine, secondLine],)); + } + } else { + dayClicked.add(const Center(child: Text("No events today"))); + } + + final access = StateWidget.of(context); + access?.updateClicked(day, year, month); + DatabaseReference _day = FirebaseDatabase.instance.ref().child("test"); + _day.set("Day tapped: ${day}"); + print(day); + } + + void navigationPress(int month, int year, BuildContext context) { + Navigator.pop(context); + pageController.animateToPage(year * 12 + month, + duration: const Duration(seconds: 1), curve: Curves.easeIn); + } + + int getCurrentMonth() { + return n.now.month; + } + + int getCurrentDay() { + return n.now.day; + } + + int getCurrentYear() { + return n.now.year; + } + + int getClicked() { + return clickedPosition; + } + + void onYearPressed(BuildContext context, PageController pageController) { + showModalBottomSheet( + context: context, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + backgroundColor: Colors.black, + builder: (BuildContext context) { + return SizedBox( + child: selectMonth(context, pageController), + height: 200, + width: 200, + ); + }, + ); + } + + void onFindMyDayPressed() { + if (pageController.hasClients) { + pageController.animateToPage( + ((getCurrentYear() - 1980) * 12 + getCurrentMonth()) - 1, + duration: const Duration(seconds: 2), + curve: Curves.easeIn); + } + } + + Widget selectMonth(BuildContext context, PageController pageController) { + int equation = getCurrentYear() - 1980; + + PageController selectionController = PageController( + initialPage: equation, + ); + return PageView.builder( + scrollDirection: Axis.horizontal, + controller: selectionController, + itemBuilder: (BuildContext context, int year) { + var displayYear = (1980 + year).toString(); + display = displayYear; + return Column( + children: [ + InkWell( + child: Text( + display, + style: const TextStyle( + fontSize: 20, fontWeight: FontWeight.bold), + ), + onTap: () { + var firstYearRange = 1980 + ((year / 12).floor() * 12); + setState(() { + display = (firstYearRange.toString() + + "-" + + (firstYearRange + 12).toString()); + //print(display); + }); + }, + ), + Expanded( + child: GridView.builder( + itemCount: 12, + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 6, + ), + itemBuilder: (BuildContext context, int month) { + Color monthName; + if (month + 1 == getCurrentMonth() && + year == getCurrentYear() - 1980) { + monthName = Colors.red[200]!; + } else { + monthName = Colors.grey[800]!; + } + return Container( + padding: const EdgeInsets.all(5), + child: ElevatedButton( + child: Text( + n.getMonthShort(month + 1).toString(), + style: const TextStyle(fontSize: 12), + ), + onPressed: () => navigationPress(month, year, context), + style: ElevatedButton.styleFrom( + primary: monthName, + side: const BorderSide(width: 1.0, color: Colors.red), + shape: const CircleBorder(), + ), + ), + ); + }, + )), + ], + ); + }); + } + void onAddEventButtonPressed() { + Navigator.of(context).push(MaterialPageRoute(builder: (context) { + int? clicked = StateWidget.of(context)?.clicked; + + //print(clicked); + return EventForm(); + })); + } +} \ No newline at end of file diff --git a/lib/event_form.dart b/lib/event_form.dart index 2899d00..4239fcf 100644 --- a/lib/event_form.dart +++ b/lib/event_form.dart @@ -1,6 +1,6 @@ -import 'package:day_to_day/EventListStorage.dart'; -import 'package:day_to_day/Inherited.dart'; -import 'Events.dart'; +import 'package:day_to_day/event_list_storage.dart'; +import 'package:day_to_day/inherited.dart'; +import 'events.dart'; import 'package:day_to_day/Months.dart'; import 'package:day_to_day/main.dart'; import 'package:flutter/material.dart'; @@ -50,10 +50,14 @@ class EventFormState extends State { TimeOfDay fromObj = TimeOfDay.now(); TimeOfDay toObj = TimeOfDay.now(); String type = "Calendar"; - String title = "Default Event"; + int hourF = 0; + int minuteF = 0; + int minuteT = 0; + int hourT = 0; @override Widget build(BuildContext context) { + String title = "Default Event"; String to; int dayF = (StateWidget.of(context)?.clicked)!; int weekDayN; @@ -61,6 +65,7 @@ class EventFormState extends State { int minute = n.now.minute; String? weekD; bool pastSixty = false; + if (dayF == -2 && !chosenFrom) { selectedTime = n.now; } else if (!chosenFrom) { @@ -87,6 +92,7 @@ class EventFormState extends State { pastSixty = true; minute = 0; } + if (!chosenTFrom && !isSwitched) { String minuteStr = minute.toString(); if (minute == 0) { @@ -94,18 +100,23 @@ class EventFormState extends State { } if (hour > 12) { - hour %= 12; - timeFrom = hour.toString() + ":" + minuteStr + " PM"; + var hourReduced = hour %12; + //hour %= 12; + timeFrom = hourReduced.toString() + ":" + minuteStr + " PM"; } else if (hour == 12) { timeFrom = hour.toString() + ":" + minuteStr + " PM"; } else { + var hourReduced = hour; if (hour == 0) { - hour = 12; + hourReduced = 12; } - timeFrom = hour.toString() + ":" + minuteStr + " AM"; + timeFrom = hourReduced.toString() + ":" + minuteStr + " AM"; } finalTimeFrom = timeFrom; + hourF = hour; + minuteF = minute; } + var midnight = 0; if (!chosenTTo && !isSwitched) { hour = n.now.hour; hour += 1; @@ -116,18 +127,28 @@ class EventFormState extends State { if (minute == 0) { minuteStr = minuteStr.toString() + "0"; } - if (hour > 12) { - hour %= 12; - timeTo = hour.toString() + ":" + minuteStr + " PM"; + if (hour == 24) { + var hourReduced = 12; + midnight +=1; + timeTo = hourReduced.toString() + ":" + minuteStr + " AM"; + } + else if (hour > 12) { + var hourReduced = hour % 12; + //hour %= 12; + timeTo = hourReduced.toString() + ":" + minuteStr + " PM"; } else if (hour == 12) { timeTo = hour.toString() + ":" + minuteStr + " PM"; } else { + var hourReduced = hour; if (hour == 0) { - hour = 12; + hourReduced = 12; } - timeTo = hour.toString() + ":" + minuteStr + " AM"; + timeTo = hourReduced.toString() + ":" + minuteStr + " AM"; } finalTimeTo = timeTo; + print(hour); + hourT = hour; + minuteT = minute; } weekDayN = selectedTime.weekday; @@ -149,11 +170,12 @@ class EventFormState extends State { (selectedTimeTo?.year.toString())!; } else { + var dayOffset = selectedTime.day + midnight; to = weekD+ ", " + n.monthShort[selectedTime.month]! + " " + - (selectedTime.day.toString()) + + (dayOffset.toString()) + ", " + (selectedTime.year.toString()); } @@ -385,27 +407,14 @@ class EventFormState extends State { //If the event was saved, write it to the respective file //!!!!!!TODO!!!!! if (selectedTimeTo != null) { - Events newEvent = Events(selectedTime.month, selectedTime.year, selectedTime.day, title, - finalTimeFrom, finalTimeTo, (selectedTimeTo?.day)!, (selectedTimeTo?.month)!, (selectedTimeTo?.year)!, - colorChosenBubble, fromObj, toObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, 0, - type); - StateWidget.of(context)?.addEvent(selectedTime.day, selectedTime.year, selectedTime.month, title, - finalTimeFrom, finalTimeTo, (selectedTimeTo?.day)!, (selectedTimeTo?.month)!, (selectedTimeTo?.year)!, - colorChosenBubble, toObj, fromObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, - type); - + finalTimeFrom, finalTimeTo, (selectedTimeTo?.day)!, (selectedTimeTo?.month)!, (selectedTimeTo?.year)!, colorChosenBubble, toObj, fromObj, isSwitched, repeatD, + (selectedTime.year - 1980) * 12 + selectedTime.month - 1, hourF, hourT, minuteF, minuteT, type); } else { - Events newEvent = Events(selectedTime.month, selectedTime.year, selectedTime.day, title, - finalTimeFrom, finalTimeTo, selectedTime.day, selectedTime.month, selectedTime.year, - colorChosenBubble, fromObj, toObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, 0, - type); - StateWidget.of(context)?.addEvent(selectedTime.day, selectedTime.year, selectedTime.month, title, - finalTimeFrom, finalTimeTo, selectedTime.day, selectedTime.month, selectedTime.year, - colorChosenBubble, toObj, fromObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, - type); + finalTimeFrom, finalTimeTo, selectedTime.day, selectedTime.month, + selectedTime.year, colorChosenBubble, toObj, fromObj, isSwitched, repeatD, (selectedTime.year - 1980) * 12 + selectedTime.month - 1, hourF, hourT, minuteF, minuteT, type); } streamController.add(true); Navigator.pop(context); diff --git a/lib/event_list_storage.dart b/lib/event_list_storage.dart index a7c683f..3c20eea 100644 --- a/lib/event_list_storage.dart +++ b/lib/event_list_storage.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'dart:convert'; -import 'Events.dart'; +import 'events.dart'; import 'package:path_provider/path_provider.dart'; import 'dart:io'; @@ -70,7 +70,7 @@ class EventListStorage { from = DateTime(yearF, monthF, dayF, 0, 0, 0, 0, 0); to = DateTime(yearT, monthT, dayT, 0, 0, 0, 0, 0); - events.add(Events(from, to, title, color, allDay, page, type)); + events.add(Events(title, color, allDay, page, from, to, type)); } return events; diff --git a/lib/events.dart b/lib/events.dart new file mode 100644 index 0000000..ceac4e5 --- /dev/null +++ b/lib/events.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class Events { + DateTime from; + DateTime to; + int page; + String title = ""; + Color color; + bool allDay; + String type; + + Events(this.title, this.color, + this.allDay, this.page, this.from, this.to, this.type); + +} \ No newline at end of file diff --git a/lib/globals.dart b/lib/globals.dart index 5598495..b28c0ad 100644 --- a/lib/globals.dart +++ b/lib/globals.dart @@ -1,6 +1,6 @@ -import 'Events.dart'; +import 'events.dart'; -Map> events = {}; +Map> eventsList = {}; List projects = []; List everyDay = []; List everyMonth = []; diff --git a/lib/inherited.dart b/lib/inherited.dart new file mode 100644 index 0000000..912094b --- /dev/null +++ b/lib/inherited.dart @@ -0,0 +1,154 @@ +import 'package:flutter/material.dart'; +import 'events.dart'; +import 'globals.dart' as globals; + +class InheritedState extends StatefulWidget { + final Widget child; + + const InheritedState({ + Key? key, + required this.child, + }) : super(key: key); + + @override + _InheritedStateState createState() => _InheritedStateState(); +} + +class _InheritedStateState extends State { + int clicked = -2; + int eventAdded = 0; + + int yearFrom = 0; + int monthFrom = 0; + + + void updateClicked(int position, int yearC, int monthC) { + + clicked = position; + yearFrom = yearC; + monthFrom = monthC; + } + + void addEvent(int dayFrom, int yearFrom, int monthFrom, String title, String timeF, String timeT, int dayTo, int monthTo, int yearTo, Color color, + TimeOfDay toT, TimeOfDay fromT, bool allDay, String repeat, int page, int hourF, int hourT, int minuteF, int minuteT, String eventType) { + + DateTime from = DateTime(yearFrom, monthFrom, dayFrom, hourF, minuteF); + DateTime to = DateTime(yearTo, monthTo, dayTo, hourT, minuteT); + + if (repeat == "Everyday") { + globals.everyDay.add(Events(title, color, + allDay, page, from, to, eventType)); + } + else if (repeat == "Every week") { + + globals.everyWeek.add(Events(title, color, + allDay, page, from, to, eventType)); + } + else if (repeat == "Every month") { + globals.everyMonth.add(Events(title, color, + allDay, page, from, to, eventType)); + } + else if (repeat == "Every year") { + globals.everyYear.add(Events(title, color, + allDay, page, from, to, eventType)); + } + else { + if (globals.eventsList[dayFrom.toString() + monthFrom.toString() + yearFrom.toString()] != null) { + if (to.difference(from).inDays != 0) { + for (int i = 0; i <= to.difference(from).inDays; i++) { + + globals.eventsList[dayFrom.toString() + monthFrom.toString() + yearFrom.toString()]?.add(Events(title, color, + allDay, page, from, to, eventType)); + dayFrom += 1; + if (dayFrom> DateTime(from.year, from.month + 1, 0).day) { + dayFrom = 1; + monthFrom +=1; + } + } + } + else { + globals.eventsList[dayFrom.toString() + monthFrom.toString() + yearFrom.toString()]?.add(Events(title, color, + allDay, page, from, to, eventType)); + } + + } + else { + if (to.difference(from).inDays != 0) { + for (int i = 0; i <= to.difference(from).inDays; i++) { + + List temp = [Events(title, color, + allDay, page, from, to, eventType)]; + globals.eventsList[dayFrom.toString() + monthFrom.toString() + yearFrom.toString()] = temp; + dayFrom += 1; + if (dayFrom> DateTime(from.year, from.month + 1, 0).day) { + dayFrom = 1; + monthFrom +=1; + } + } + } + else { + List temp = [Events(title, color, + allDay, page, from, to, eventType)]; + globals.eventsList[dayFrom.toString() + monthFrom.toString() + yearFrom.toString()] = temp; + } + + } + } + + globals.eventsList[dayFrom.toString() + monthFrom.toString() + yearFrom.toString()]?.sort((a,b) { + if (a.from.hour == b.from.hour) { + return a.from.minute.compareTo(b.from.minute); + } + else { + return a.from.hour.compareTo(b.from.hour); + } + }); + } + + + @override + Widget build(BuildContext context) => StateWidget( + child: widget.child, + clicked: clicked, + monthFrom: monthFrom, + yearFrom: yearFrom, + eventAdded: eventAdded, + state: this, + ); +} + + +class StateWidget extends InheritedWidget { + final int clicked; + final _InheritedStateState state; + final int yearFrom; + final int eventAdded; + final int monthFrom; + + + const StateWidget({ + Key? key, + required Widget child, + required this.clicked, + required this.state, + required this.monthFrom, + required this.yearFrom, + required this.eventAdded, + }) : super(key: key, child: child); + + static _InheritedStateState? of(BuildContext context) => + context + .dependOnInheritedWidgetOfExactType() + ?.state; + + @override + bool updateShouldNotify(StateWidget oldWidget) { + + return oldWidget.clicked != clicked || + oldWidget.monthFrom != monthFrom || + oldWidget.yearFrom != yearFrom || + oldWidget.eventAdded != eventAdded || + oldWidget.state != state; + } + +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index a3df517..1aba822 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,5 @@ -import 'package:day_to_day/Events.dart'; -import 'package:day_to_day/Inherited.dart'; +import 'package:day_to_day/events.dart'; +import 'package:day_to_day/inherited.dart'; import 'package:day_to_day/Months.dart'; import 'package:day_to_day/ProjectsWidget.dart'; import 'package:day_to_day/Assignments.dart'; @@ -8,11 +8,11 @@ import 'package:day_to_day/to_do_list_directory_widget.dart'; import 'package:flutter/material.dart'; import 'package:firebase_database/firebase_database.dart'; import 'package:firebase_core/firebase_core.dart'; -import 'package:day_to_day/Calendar.dart'; -import 'package:day_to_day/EventForm.dart'; +import 'package:day_to_day/calendar.dart'; +import 'package:day_to_day/event_form.dart'; import 'globals.dart'; import 'dart:async'; -import 'EventListStorage.dart'; +import 'event_list_storage.dart'; StreamController streamController = StreamController.broadcast(); @@ -231,7 +231,6 @@ class _MyStatefulWidgetState extends State controller: _tabController, children: [ CalendarWidget( - widget.eventList, stream: streamController.stream, ), const ToDoListDirectoryWidget(), diff --git a/pubspec.lock b/pubspec.lock index 6c8b319..57bd98a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -77,7 +77,7 @@ packages: name: firebase_core url: "https://pub.dartlang.org" source: hosted - version: "1.14.0" + version: "1.14.1" firebase_core_platform_interface: dependency: transitive description: @@ -91,28 +91,28 @@ packages: name: firebase_core_web url: "https://pub.dartlang.org" source: hosted - version: "1.6.1" + version: "1.6.2" firebase_database: dependency: "direct main" description: name: firebase_database url: "https://pub.dartlang.org" source: hosted - version: "9.0.9" + version: "9.0.11" firebase_database_platform_interface: dependency: transitive description: name: firebase_database_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "0.2.1+2" + version: "0.2.1+3" firebase_database_web: dependency: transitive description: name: firebase_database_web url: "https://pub.dartlang.org" source: hosted - version: "0.2.0+8" + version: "0.2.0+10" flutter: dependency: "direct main" description: flutter diff --git a/test/calendar_widget_test.dart b/test/calendar_widget_test.dart index 333029a..da9484a 100644 --- a/test/calendar_widget_test.dart +++ b/test/calendar_widget_test.dart @@ -1,5 +1,5 @@ -import 'package:day_to_day/Calendar.dart'; +import 'package:day_to_day/calendar.dart'; import 'package:day_to_day/main.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Testing that correct month displayed at app startup', (WidgetTester tester) async { // Create the widget by telling the tester to build it. - await tester.pumpWidget(const MaterialApp(home: Material(child: CalendarWidget()))); + //await tester.pumpWidget(const MaterialApp(home: Material(child: CalendarWidget()))); final displayText = find.text("March "); @@ -15,7 +15,7 @@ void main() { }); testWidgets('Test if modal bottom sheet pops up for quick navigation', (WidgetTester tester) async { - await tester.pumpWidget(const MaterialApp(home: Material(child: CalendarWidget()))); + //await tester.pumpWidget(const MaterialApp(home: Material(child: CalendarWidget()))); await tester.tap(find.text('March ')); await tester.pumpAndSettle(); @@ -23,7 +23,7 @@ void main() { expect(find.text('2022'), findsOneWidget); }); testWidgets('Test if add event button brings up new page', (WidgetTester tester) async { - await tester.pumpWidget(const MaterialApp(home: Material(child: AppWidget()))); + //await tester.pumpWidget(const MaterialApp(home: Material(child: AppWidget()))); await tester.tap(find.byType(FloatingActionButton)); await tester.pumpAndSettle(); @@ -31,7 +31,7 @@ void main() { expect(find.text('All Day'), findsOneWidget); }); testWidgets('Test if cancel button on event add page goes back to calendar', (WidgetTester tester) async { - await tester.pumpWidget(const MaterialApp(home: Material(child: AppWidget()))); + //await tester.pumpWidget(const MaterialApp(home: Material(child: AppWidget()))); await tester.tap(find.byType(FloatingActionButton)); await tester.pumpAndSettle(); await tester.tap(find.byType(TextButton).first); From bffe8e7a480ffdd8d9a243a45804e92a2081c2d1 Mon Sep 17 00:00:00 2001 From: joseph81301 Date: Sun, 17 Apr 2022 09:11:47 -0400 Subject: [PATCH 10/13] Fixes --- lib/ProjectsWidget.dart | 75 ------------------- lib/{Assignments.dart => assignments.dart} | 14 +++- lib/calendar.dart | 3 +- lib/event_form.dart | 27 +++++-- lib/{EventsWidget.dart => events_widget.dart} | 0 lib/{Exams.dart => exams.dart} | 13 +++- lib/main.dart | 26 +++---- lib/{Months.dart => months.dart} | 0 lib/{Projects.dart => projects.dart} | 0 lib/projects_widget.dart | 16 +++- 10 files changed, 72 insertions(+), 102 deletions(-) delete mode 100644 lib/ProjectsWidget.dart rename lib/{Assignments.dart => assignments.dart} (89%) rename lib/{EventsWidget.dart => events_widget.dart} (100%) rename lib/{Exams.dart => exams.dart} (90%) rename lib/{Months.dart => months.dart} (100%) rename lib/{Projects.dart => projects.dart} (100%) diff --git a/lib/ProjectsWidget.dart b/lib/ProjectsWidget.dart deleted file mode 100644 index e45e40d..0000000 --- a/lib/ProjectsWidget.dart +++ /dev/null @@ -1,75 +0,0 @@ -import 'package:day_to_day/globals.dart'; -import 'event_form.dart'; -import 'event_list_storage.dart'; -import 'package:flutter/material.dart'; -import 'events.dart'; -import 'globals.dart' as globals; -//import 'package:firebase_database/firebase_database.dart'; - -class ProjectsWidget extends StatefulWidget { - List projects = []; - ProjectsWidget({Key? key}) : super(key: key); - - @override - State createState() => ProjectsState(); -} - -class ProjectsState extends State { - @override - Widget build(BuildContext context) { - projects = []; - globals.eventsList.forEach((key, value) { - for (int i = 0; i < value.length; i++) { - if (value[i].type.contains("project")) { - projects.add(value[i]); - } - } - }); - print("\n\n\nProjects: " + projects.length.toString()); - return Scaffold( - appBar: AppBar( - title: const Center(child: Text("Projects List")), - backgroundColor: const Color.fromARGB(255, 255, 82, 82), - ), - body: ListView.builder( - itemCount: projects.length, - itemBuilder: (BuildContext context, int index) { - return Card( - child: CheckboxListTile( - dense: true, - activeColor: Colors.red[400], - controlAffinity: ListTileControlAffinity.leading, - value: false, - onChanged: (value) { - setState(() { - projects.removeAt(index); - }); - }, - title: Text( - projects[index].title, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20, - color: Color.fromARGB(255, 12, 12, 12)), - ))); - }, - ), - floatingActionButton: FloatingActionButton( - onPressed: () { - setState(() { - Navigator.of(context).push(MaterialPageRoute(builder: (context) { - return EventForm(); - })); - }); - setState(() {}); - }, - child: const Icon( - Icons.add, - size: 45, - color: Colors.white, - ), - backgroundColor: Colors.blueGrey, - ), - ); - } -} diff --git a/lib/Assignments.dart b/lib/assignments.dart similarity index 89% rename from lib/Assignments.dart rename to lib/assignments.dart index 7174204..f602f91 100644 --- a/lib/Assignments.dart +++ b/lib/assignments.dart @@ -5,7 +5,8 @@ import 'events.dart'; class AssignmentsWidget extends StatefulWidget { List hw = []; - AssignmentsWidget({Key? key}) : super(key: key); + AssignmentsWidget({Key? key, required this.stream}) : super(key: key); + final Stream stream; @override State createState() => AssignmentsState(); @@ -14,6 +15,17 @@ class AssignmentsWidget extends StatefulWidget { class AssignmentsState extends State { int count = 2; + @override + void initState() { + + widget.stream.listen((event) { + setState(() { + + }); + }); + super.initState(); + } + @override Widget build(BuildContext context) { widget.hw = []; diff --git a/lib/calendar.dart b/lib/calendar.dart index 99c8b35..70a6442 100644 --- a/lib/calendar.dart +++ b/lib/calendar.dart @@ -903,7 +903,8 @@ class CalendarState extends State { ), ); } - } else if (element.from.year == element.to.year) { + } + else if (element.from.year == element.to.year) { if (element.allDay) { secondLine = Center( child: Padding( diff --git a/lib/event_form.dart b/lib/event_form.dart index 4239fcf..86b653d 100644 --- a/lib/event_form.dart +++ b/lib/event_form.dart @@ -1,7 +1,7 @@ import 'package:day_to_day/event_list_storage.dart'; import 'package:day_to_day/inherited.dart'; import 'events.dart'; -import 'package:day_to_day/Months.dart'; +import 'package:day_to_day/months.dart'; import 'package:day_to_day/main.dart'; import 'package:flutter/material.dart'; import 'globals.dart' as globals; @@ -92,6 +92,8 @@ class EventFormState extends State { pastSixty = true; minute = 0; } + print(hour); + print(minute); if (!chosenTFrom && !isSwitched) { String minuteStr = minute.toString(); @@ -100,10 +102,18 @@ class EventFormState extends State { } if (hour > 12) { - var hourReduced = hour %12; - //hour %= 12; - timeFrom = hourReduced.toString() + ":" + minuteStr + " PM"; - } else if (hour == 12) { + if (hour == 24) { + var hourReduced = 12; + timeFrom = hourReduced.toString() + ":" + minuteStr + " AM"; + } + else { + var hourReduced = hour %12; + //hour %= 12; + timeFrom = hourReduced.toString() + ":" + minuteStr + " PM"; + } + + } + else if (hour == 12) { timeFrom = hour.toString() + ":" + minuteStr + " PM"; } else { var hourReduced = hour; @@ -124,6 +134,7 @@ class EventFormState extends State { hour += 1; } String minuteStr = minute.toString(); + if (minute == 0) { minuteStr = minuteStr.toString() + "0"; } @@ -132,6 +143,11 @@ class EventFormState extends State { midnight +=1; timeTo = hourReduced.toString() + ":" + minuteStr + " AM"; } + if (hour == 25) { + var hourReduced = 1; + midnight +=1; + timeTo = hourReduced.toString() + ":" + minuteStr + " AM"; + } else if (hour > 12) { var hourReduced = hour % 12; //hour %= 12; @@ -146,7 +162,6 @@ class EventFormState extends State { timeTo = hourReduced.toString() + ":" + minuteStr + " AM"; } finalTimeTo = timeTo; - print(hour); hourT = hour; minuteT = minute; } diff --git a/lib/EventsWidget.dart b/lib/events_widget.dart similarity index 100% rename from lib/EventsWidget.dart rename to lib/events_widget.dart diff --git a/lib/Exams.dart b/lib/exams.dart similarity index 90% rename from lib/Exams.dart rename to lib/exams.dart index 6a6b81a..d464afb 100644 --- a/lib/Exams.dart +++ b/lib/exams.dart @@ -5,13 +5,24 @@ import 'events.dart'; class ExamsWidget extends StatefulWidget { List exams = []; - ExamsWidget({Key? key}) : super(key: key); + ExamsWidget({Key? key, required this.stream}) : super(key: key); + final Stream stream; @override State createState() => ExamsState(); } class ExamsState extends State { + @override + void initState() { + + widget.stream.listen((event) { + setState(() { + + }); + }); + super.initState(); + } @override Widget build(BuildContext context) { widget.exams = []; diff --git a/lib/main.dart b/lib/main.dart index 1aba822..551bd87 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,16 +1,12 @@ import 'package:day_to_day/events.dart'; import 'package:day_to_day/inherited.dart'; -import 'package:day_to_day/Months.dart'; -import 'package:day_to_day/ProjectsWidget.dart'; -import 'package:day_to_day/Assignments.dart'; -import 'package:day_to_day/Exams.dart'; +import 'package:day_to_day/projects_widget.dart'; +import 'package:day_to_day/assignments.dart'; +import 'package:day_to_day/exams.dart'; import 'package:day_to_day/to_do_list_directory_widget.dart'; import 'package:flutter/material.dart'; -import 'package:firebase_database/firebase_database.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:day_to_day/calendar.dart'; -import 'package:day_to_day/event_form.dart'; -import 'globals.dart'; import 'dart:async'; import 'event_list_storage.dart'; @@ -196,6 +192,7 @@ class _MyStatefulWidgetState extends State ),*/ ], bottom: TabBar( + isScrollable: true, indicatorColor: Colors.white, labelColor: Colors.white, controller: _tabController, @@ -229,26 +226,21 @@ class _MyStatefulWidgetState extends State ), body: TabBarView( controller: _tabController, + children: [ CalendarWidget( stream: streamController.stream, ), const ToDoListDirectoryWidget(), - AssignmentsWidget(), - ProjectsWidget(), - ExamsWidget(), + AssignmentsWidget(stream: streamController.stream,), + ProjectsWidget(stream: streamController.stream,), + ExamsWidget(stream: streamController.stream,), ], + ), ); } void onSearchButtonPressed() {} - void onAddEventButtonPressed() { - Navigator.of(context).push(MaterialPageRoute(builder: (context) { - int? clicked = StateWidget.of(context)?.clicked; - //print(clicked); - return EventForm(); - })); - } } diff --git a/lib/Months.dart b/lib/months.dart similarity index 100% rename from lib/Months.dart rename to lib/months.dart diff --git a/lib/Projects.dart b/lib/projects.dart similarity index 100% rename from lib/Projects.dart rename to lib/projects.dart diff --git a/lib/projects_widget.dart b/lib/projects_widget.dart index 1df391e..fe19594 100644 --- a/lib/projects_widget.dart +++ b/lib/projects_widget.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'package:day_to_day/globals.dart'; import 'event_list_storage.dart'; import 'event_form.dart'; @@ -5,16 +6,29 @@ import 'package:flutter/material.dart'; import 'events.dart'; import 'globals.dart' as globals; //import 'package:firebase_database/firebase_database.dart'; +StreamController streamController = StreamController.broadcast(); class ProjectsWidget extends StatefulWidget { List projects = []; - ProjectsWidget({Key? key}) : super(key: key); + ProjectsWidget({Key? key, required this.stream}) : super(key: key); + final Stream stream; @override State createState() => ProjectsState(); } class ProjectsState extends State { + + @override + void initState() { + + widget.stream.listen((event) { + setState(() { + + }); + }); + super.initState(); + } @override Widget build(BuildContext context) { projects = []; From 3f8ee5f576cddf07b50c759b2ced87a7eca905c4 Mon Sep 17 00:00:00 2001 From: joseph81301 Date: Sun, 17 Apr 2022 09:33:53 -0400 Subject: [PATCH 11/13] Fixes again --- android/app/build.gradle | 2 +- lib/main.dart | 3 +-- pubspec.lock | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 1253e65..9062d2c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -45,7 +45,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.day_to_day" - minSdkVersion 19 + minSdkVersion 21 targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/lib/main.dart b/lib/main.dart index fe08b47..d284028 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -69,7 +69,7 @@ class DayToDay extends StatelessWidget { stream: FirebaseAuth.instance.authStateChanges(), builder: (context, snapshot) { if (snapshot.hasData) { - return const AppWidget(); + return AppWidget(); } else if (snapshot.hasError) { return const Center( child: Text('Error'), @@ -189,7 +189,6 @@ class _MyStatefulWidgetState extends State indicatorColor: Colors.white, labelColor: Colors.white, controller: _tabController, - isScrollable: true, indicatorSize: TabBarIndicatorSize.label, tabs: [ Tab( diff --git a/pubspec.lock b/pubspec.lock index c346e48..f282d7c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -57,6 +57,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.2" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.2" firebase_auth: dependency: "direct main" description: From 45b89f220d4e2440df9786e860e821814d77c4fb Mon Sep 17 00:00:00 2001 From: joseph81301 Date: Sun, 17 Apr 2022 16:28:43 -0400 Subject: [PATCH 12/13] Fixes --- lib/calendar.dart | 361 +++++++++++++++++++++++++++----------------- lib/event_form.dart | 165 ++++++++++---------- lib/main.dart | 14 +- 3 files changed, 319 insertions(+), 221 deletions(-) diff --git a/lib/calendar.dart b/lib/calendar.dart index bfbbfda..3bc1698 100644 --- a/lib/calendar.dart +++ b/lib/calendar.dart @@ -11,6 +11,7 @@ class CalendarWidget extends StatefulWidget { const CalendarWidget({Key? key, required this.stream}) : super(key: key); final Stream stream; + @override State createState() => CalendarState(); } @@ -23,6 +24,8 @@ class CalendarState extends State { int clickedPosition = -1; List dayClicked = []; Map span = {}; + int pag = 0; + List deleteSearch = []; @override void initState() { @@ -73,18 +76,21 @@ class CalendarState extends State { scrollDirection: Axis.vertical, itemBuilder: (BuildContext context, int pages) { int temporaryM = pages; + pag = pages; if (clickedPosition == -1) { + Widget firstLine; + Widget secondLine; clickedPosition = getCurrentDay(); if (globals.eventsList[getCurrentDay().toString() + - getCurrentMonth().toString() + - getCurrentYear().toString()] != + getCurrentMonth().toString() + + getCurrentYear().toString()] != null) { globals.eventsList[getCurrentDay().toString() + - getCurrentMonth().toString() + - getCurrentYear().toString()] + getCurrentMonth().toString() + + getCurrentYear().toString()] ?.forEach((element) { - dayClicked.add(Row( + firstLine = Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( @@ -102,67 +108,70 @@ class CalendarState extends State { fontWeight: FontWeight.bold, fontSize: 20), ), ], - )); + ); String timeF = TimeOfDay( - hour: element.from.hour, - minute: element.from.minute) + hour: element.from.hour, + minute: element.from.minute) .format(context); String timeT = TimeOfDay( - hour: element.to.hour, minute: element.to.minute) + hour: element.to.hour, + minute: element.to.minute) .format(context); String repeatingString; if (element.from.day == element.to.day && element.from.month == element.to.month && element.from.year == element.to.year) { - dayClicked.add(Center( + secondLine = Center( child: Padding( padding: const EdgeInsets.only(bottom: 20), child: Text(timeF + " - " + timeT), ), - )); + ); } else if (element.from.year == element.to.year) { - dayClicked.add(Center( + secondLine = Center( child: Padding( padding: const EdgeInsets.only(bottom: 20), - child: Text( - Months().getMonthShort(element.from.month)! + - " " + - element.from.day.toString() + - ", " + - timeF + - " - " + - Months().getMonthShort(element.to.month)! + - " " + - element.to.day.toString() + - ", " + - timeT), + child: Text(Months() + .getMonthShort(element.from.month)! + + " " + + element.from.day.toString() + + ", " + + timeF + + " - " + + Months().getMonthShort(element.to.month)! + + " " + + element.to.day.toString() + + ", " + + timeT), ), - )); + ); } else { - dayClicked.add(Center( + secondLine = Center( child: Padding( padding: const EdgeInsets.only(bottom: 20), - child: Text( - Months().getMonthShort(element.from.month)! + - " " + - element.from.day.toString() + - ", " + - element.from.year.toString() + - ", " + - timeF + - " - " + - Months().getMonthShort(element.to.month)! + - " " + - element.to.day.toString() + - ", " + - element.to.year.toString() + - ", " + - timeT), + child: Text(Months() + .getMonthShort(element.from.month)! + + " " + + element.from.day.toString() + + ", " + + element.from.year.toString() + + ", " + + timeF + + " - " + + Months().getMonthShort(element.to.month)! + + " " + + element.to.day.toString() + + ", " + + element.to.year.toString() + + ", " + + timeT), ), - )); + ); } - }); + dayClicked.add(Column(children: [firstLine,secondLine],)); + } + ); } else { dayClicked.add(const Text("No events today")); } @@ -209,7 +218,7 @@ class CalendarState extends State { child: InkWell( child: Container( padding: - const EdgeInsets.only(bottom: 16, top: 10), + const EdgeInsets.only(bottom: 16, top: 10), child: Align( alignment: Alignment.center, child: Text( @@ -239,12 +248,14 @@ class CalendarState extends State { height: 25.0, width: 25.0, child: Center( - child: Text( - CalendarState().getCurrentDay().toString()), + child: Text(CalendarState() + .getCurrentDay() + .toString()), ), ), ), - padding: const EdgeInsets.only(left: 120, right: 15), + padding: + const EdgeInsets.only(left: 120, right: 15), ), ], //mainAxisSize: MainAxisSize.min, @@ -289,7 +300,7 @@ class CalendarState extends State { scrollDirection: Axis.vertical, physics: const ScrollPhysics(), gridDelegate: - const SliverGridDelegateWithFixedCrossAxisCount( + const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 7, childAspectRatio: 1 / 1.1, ), @@ -367,12 +378,12 @@ class CalendarState extends State { for (var element in globals.everyDay) { if (temporaryM >= element.page) { if (element.from.year == - (yearsPassed + yearEarly) && + (yearsPassed + yearEarly) && element.from.month == userMonth) { if (day >= element.from.day) { dayInfo.add(Container( padding: - const EdgeInsets.only(top: 10), + const EdgeInsets.only(top: 10), decoration: BoxDecoration( shape: BoxShape.rectangle, color: element.color), @@ -382,7 +393,8 @@ class CalendarState extends State { } } else { dayInfo.add(Container( - padding: const EdgeInsets.only(top: 10), + padding: + const EdgeInsets.only(top: 10), decoration: BoxDecoration( shape: BoxShape.rectangle, color: element.color), @@ -401,29 +413,29 @@ class CalendarState extends State { userMonth, day); if (element.to - .difference(element.from) - .inDays != + .difference(element.from) + .inDays != 0) { for (int i = 0; - i <= - element.to - .difference(element.from) - .inDays; - i++) { + i <= + element.to + .difference(element.from) + .inDays; + i++) { int dayCalc = element.from.day + i; int month = element.from.month; int yearCalc = element.from.year; if (dayCalc > DateTime(element.from.year, - element.from.month + 1, 0) + element.from.month + 1, 0) .day) { dayCalc = 1; month += 1; } if (month > 12) { if (month % 12 == 0) { - yearCalc += month~/12; + yearCalc += month ~/ 12; } month = 1; } @@ -433,12 +445,13 @@ class CalendarState extends State { if (weekDay.weekday == dayOffset) { if (yearCalc == - (yearsPassed + yearEarly) && + (yearsPassed + yearEarly) && month == userMonth) { if (day >= dayCalc) { dayInfo.add(Container( - padding: const EdgeInsets.only( - top: 10), + padding: + const EdgeInsets.only( + top: 10), decoration: BoxDecoration( shape: BoxShape.rectangle, color: element.color), @@ -462,12 +475,12 @@ class CalendarState extends State { } else if (weekDay.weekday == (element.from.weekday)) { if (element.from.year == - (yearsPassed + yearEarly) && + (yearsPassed + yearEarly) && element.from.month == userMonth) { if (day >= element.from.day) { dayInfo.add(Container( - padding: - const EdgeInsets.only(top: 10), + padding: const EdgeInsets.only( + top: 10), decoration: BoxDecoration( shape: BoxShape.rectangle, color: element.color), @@ -478,7 +491,7 @@ class CalendarState extends State { } else { dayInfo.add(Container( padding: - const EdgeInsets.only(top: 10), + const EdgeInsets.only(top: 10), decoration: BoxDecoration( shape: BoxShape.rectangle, color: element.color), @@ -494,21 +507,21 @@ class CalendarState extends State { if (globals.everyMonth.isNotEmpty) { for (var element in globals.everyMonth) { if (element.to - .difference(element.from) - .inDays != + .difference(element.from) + .inDays != 0) { for (int i = 0; - i <= - element.to - .difference(element.from) - .inDays; - i++) { + i <= + element.to + .difference(element.from) + .inDays; + i++) { int dayCalc = element.from.day + i; int monthCalc = element.from.month; if (dayCalc > DateTime(element.from.year, - element.from.month + 1, 0) + element.from.month + 1, 0) .day) { dayCalc = 1; monthCalc += 1; @@ -519,8 +532,8 @@ class CalendarState extends State { if (day == dayCalc) { if (temporaryM >= element.page) { dayInfo.add(Container( - padding: - const EdgeInsets.only(top: 10), + padding: const EdgeInsets.only( + top: 10), decoration: BoxDecoration( shape: BoxShape.rectangle, color: element.color), @@ -535,7 +548,7 @@ class CalendarState extends State { if (temporaryM >= element.page) { dayInfo.add(Container( padding: - const EdgeInsets.only(top: 10), + const EdgeInsets.only(top: 10), decoration: BoxDecoration( shape: BoxShape.rectangle, color: element.color), @@ -550,21 +563,21 @@ class CalendarState extends State { if (globals.everyYear.isNotEmpty) { for (var element in globals.everyYear) { if (element.to - .difference(element.from) - .inDays != + .difference(element.from) + .inDays != 0) { for (int i = 0; - i <= - element.to - .difference(element.from) - .inDays; - i++) { + i <= + element.to + .difference(element.from) + .inDays; + i++) { int dayCalc = element.from.day + i; int month = element.from.month; if (dayCalc > DateTime(element.from.year, - element.from.month + 1, 0) + element.from.month + 1, 0) .day) { dayCalc = 1; month += 1; @@ -577,7 +590,8 @@ class CalendarState extends State { userMonth == month) { if (temporaryM >= element.page) { dayInfo.add(Container( - padding: const EdgeInsets.only(top: 10), + padding: const EdgeInsets.only( + top: 10), decoration: BoxDecoration( shape: BoxShape.rectangle, color: element.color), @@ -587,13 +601,13 @@ class CalendarState extends State { } } } - } - else { + } else { if (day == element.from.day && userMonth == element.from.month) { if (temporaryM >= element.page) { dayInfo.add(Container( - padding: const EdgeInsets.only(top: 10), + padding: + const EdgeInsets.only(top: 10), decoration: BoxDecoration( shape: BoxShape.rectangle, color: element.color), @@ -621,7 +635,7 @@ class CalendarState extends State { alignment: Alignment.topCenter, child: Column( mainAxisAlignment: - MainAxisAlignment.spaceEvenly, + MainAxisAlignment.spaceEvenly, children: dayInfo, ), ), @@ -642,17 +656,102 @@ class CalendarState extends State { itemCount: dayClicked.length, itemBuilder: (BuildContext context, int index) { return InkWell( + onTap: () { + if (deleteSearch[index].type == "assignment") { + } + + }, onLongPress: () { + showDialog( + context: context, + builder: (BuildContext context) => AlertDialog( + title: const Text('Delete event?'), + content: const Text('Can\'t be undone'), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('Cancel'), + ), + TextButton( + onPressed: () { + String d = deleteSearch[index].from.day.toString(); + String m = deleteSearch[index].from.month.toString(); + String y = deleteSearch[index].from.year.toString(); + print(deleteSearch[index].title); + print(deleteSearch[index].from.day); + print("In long press"); + + if (deleteSearch[index].to.difference(deleteSearch[index].from).inDays != 0) { + //print("i am here"); + //print(deleteSearch[index].from.difference(deleteSearch[index].to).inDays); + for (int j = 0; j <= deleteSearch[index].to.difference(deleteSearch[index].from).inDays; j++) { + d = (deleteSearch[index].from.day + j).toString(); + print(d); + for (int i = 0; i < (globals.eventsList[d + m + y]?.length)!; i++) { + print(globals.eventsList[d + m + y]?.length); + if (globals.eventsList[d + m + y]?.elementAt(i).to.day == deleteSearch[index].to.day && + globals.eventsList[d + m + y]?.elementAt(i).to.month == deleteSearch[index].to.month && + globals.eventsList[d + m + y]?.elementAt(i).to.year == deleteSearch[index].to.year && + globals.eventsList[d + m + y]?.elementAt(i).to.hour == deleteSearch[index].to.hour && + globals.eventsList[d + m + y]?.elementAt(i).to.minute == deleteSearch[index].to.minute && + globals.eventsList[d + m + y]?.elementAt(i).from.day == deleteSearch[index].from.day && + globals.eventsList[d + m + y]?.elementAt(i).from.minute == deleteSearch[index].from.minute && + globals.eventsList[d + m + y]?.elementAt(i).from.year == deleteSearch[index].from.year && + globals.eventsList[d + m + y]?.elementAt(i).from.month == deleteSearch[index].from.month && + globals.eventsList[d + m + y]?.elementAt(i).from.hour == deleteSearch[index].from.hour && + globals.eventsList[d + m + y]?.elementAt(i).type == deleteSearch[index].type && + globals.eventsList[d + m + y]?.elementAt(i).allDay == deleteSearch[index].allDay && + globals.eventsList[d + m + y]?.elementAt(i).page == deleteSearch[index].page && + globals.eventsList[d + m + y]?.elementAt(i).title == deleteSearch[index].title + ) { + + globals.eventsList[d + m + y]?.removeAt(i); + print("hm"); + + } + } + } + _tapDate(deleteSearch[index].from.day, deleteSearch[index].from.year, deleteSearch[index].from.month, pag); + } + else { + for (int i = 0; i < (globals.eventsList[d + m + y]?.length)!; i++) { + if (globals.eventsList[d + m + y]?.elementAt(i).to.day == deleteSearch[index].to.day && + globals.eventsList[d + m + y]?.elementAt(i).to.month == deleteSearch[index].to.month && + globals.eventsList[d + m + y]?.elementAt(i).to.year == deleteSearch[index].to.year && + globals.eventsList[d + m + y]?.elementAt(i).to.hour == deleteSearch[index].to.hour && + globals.eventsList[d + m + y]?.elementAt(i).to.minute == deleteSearch[index].to.minute && + globals.eventsList[d + m + y]?.elementAt(i).from.day == deleteSearch[index].from.day && + globals.eventsList[d + m + y]?.elementAt(i).from.minute == deleteSearch[index].from.minute && + globals.eventsList[d + m + y]?.elementAt(i).from.year == deleteSearch[index].from.year && + globals.eventsList[d + m + y]?.elementAt(i).from.month == deleteSearch[index].from.month && + globals.eventsList[d + m + y]?.elementAt(i).from.hour == deleteSearch[index].from.hour && + globals.eventsList[d + m + y]?.elementAt(i).type == deleteSearch[index].type && + globals.eventsList[d + m + y]?.elementAt(i).allDay == deleteSearch[index].allDay && + globals.eventsList[d + m + y]?.elementAt(i).page == deleteSearch[index].page && + globals.eventsList[d + m + y]?.elementAt(i).title == deleteSearch[index].title + ) { + globals.eventsList[d + m + y]?.removeAt(i); + _tapDate(deleteSearch[index].from.day, deleteSearch[index].from.year, deleteSearch[index].from.month, pag); + + } + } + } + + Navigator.pop(context); + }, + child: const Text('Delete'), + ), + ], + )); }, child: Column( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, children: [ dayClicked[index], - ] - ) - ); + ])); }, //children: [ //Column( @@ -673,7 +772,7 @@ class CalendarState extends State { void _tapDate(int day, int year, int month, int page) { dayClicked.clear(); - + deleteSearch.clear(); setState(() { clickedPosition = day; }); @@ -718,7 +817,7 @@ class CalendarState extends State { } if (monthCalc > 12) { if (month % 12 == 0) { - yearCalc += month~/12; + yearCalc += month ~/ 12; } monthCalc = 1; } @@ -767,7 +866,7 @@ class CalendarState extends State { } if (monthCalc > 12) { if (month % 12 == 0) { - yearCalc += month~/12; + yearCalc += month ~/ 12; } monthCalc = 1; } @@ -800,30 +899,22 @@ class CalendarState extends State { } if (globals.everyYear.isNotEmpty) { for (var element in globals.everyYear) { - if (element.to - .difference(element.from) - .inDays != - 0) { + if (element.to.difference(element.from).inDays != 0) { for (int i = 0; - i <= - element.to - .difference(element.from) - .inDays; - i++) { + i <= element.to.difference(element.from).inDays; + i++) { int dayCalc = element.from.day + i; int monthCalc = element.from.month; int yearCalc = element.from.year; if (dayCalc > - DateTime(element.from.year, - element.from.month + 1, 0) - .day) { + DateTime(element.from.year, element.from.month + 1, 0).day) { dayCalc = 1; month += 1; } if (month > 12) { if (month % 12 == 0) { - yearCalc += month~/12; + yearCalc += month ~/ 12; } month = 1; } @@ -839,8 +930,7 @@ class CalendarState extends State { } } } - } - else { + } else { if (day == element.from.day && month == element.from.month) { if (page >= element.page) { if (element.from.year == year && element.from.month == month) { @@ -853,7 +943,6 @@ class CalendarState extends State { } } } - } } Widget firstLine = Spacer(); @@ -861,24 +950,23 @@ class CalendarState extends State { if (temp.isNotEmpty) { for (var element in temp) { - firstLine = - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - padding: const EdgeInsets.only(right: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, color: element.color), - height: 15, - width: 2, - ), - const Padding(padding: EdgeInsets.only(right: 10)), - Text( - element.title, - style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 20), - ), - ], - ); + firstLine = Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.only(right: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, color: element.color), + height: 15, + width: 2, + ), + const Padding(padding: EdgeInsets.only(right: 10)), + Text( + element.title, + style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + ), + ], + ); String timeF = TimeOfDay(hour: element.from.hour, minute: element.from.minute) .format(context); @@ -976,7 +1064,10 @@ class CalendarState extends State { ); } } - dayClicked.add(Column(children: [firstLine, secondLine],)); + dayClicked.add(Column( + children: [firstLine, secondLine], + )); + deleteSearch.add(element); } } else { dayClicked.add(const Center(child: Text("No events today"))); @@ -986,7 +1077,6 @@ class CalendarState extends State { access?.updateClicked(day, year, month); DatabaseReference _day = FirebaseDatabase.instance.ref().child("test"); _day.set("Day tapped: ${day}"); - print(day); } void navigationPress(int month, int year, BuildContext context) { @@ -1102,6 +1192,7 @@ class CalendarState extends State { ); }); } + void onAddEventButtonPressed() { Navigator.of(context).push(MaterialPageRoute(builder: (context) { int? clicked = StateWidget.of(context)?.clicked; diff --git a/lib/event_form.dart b/lib/event_form.dart index fc17f1c..d333386 100644 --- a/lib/event_form.dart +++ b/lib/event_form.dart @@ -48,7 +48,7 @@ class EventFormState extends State { String colorChosenText = "Default"; TimeOfDay fromObj = TimeOfDay.now(); TimeOfDay toObj = TimeOfDay.now(); - String type = "Calendar"; + String type = "calendar"; int hourF = 0; int minuteF = 0; int minuteT = 0; @@ -193,7 +193,10 @@ class EventFormState extends State { ", " + (selectedTime.year.toString()); } - + Color disable = Colors.white; + if (type != "calendar") { + disable = Colors.grey; + } return InheritedState( child: Scaffold( @@ -363,7 +366,7 @@ class EventFormState extends State { child: SizedBox( child: Text( repeatD, - style: const TextStyle(fontSize: 20), + style: TextStyle(fontSize: 20, color: disable), ), height: 45, ), @@ -371,7 +374,7 @@ class EventFormState extends State { ], ), onTap: () { - onRepeat(); + onRepeat(type); }, ), const Divider(color: Colors.grey,), @@ -562,91 +565,95 @@ class EventFormState extends State { } } - void onRepeat() { + void onRepeat(String type) { + if (type == "calendar") { showDialog(context: context, builder: (context) { return StatefulBuilder( - builder: (context, setState) { - return Dialog( - elevation: 20, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)), - child: SizedBox( - height: 300, - child: Column( - children: [ - RadioListTile( - title: const Text("Don't Repeat"), - value: SingingCharacter.none, - groupValue: repeatingChoose, - onChanged: (SingingCharacter? value) { - Navigator.pop(context, true); - setState(() { - repeatD = "Don't Repeat"; - repeatingChoose = value; - }); - } - ), - RadioListTile( - title: const Text("Everyday"), - value: SingingCharacter.daily, - groupValue: repeatingChoose, - onChanged: (SingingCharacter? value) { - Navigator.pop(context, true); - setState(() { - repeatD = "Everyday"; - repeatingChoose = value; - }); - } - ), - RadioListTile( - title: const Text("Every week"), - value: SingingCharacter.weekly, - groupValue: repeatingChoose, - onChanged: (SingingCharacter? value) { - Navigator.pop(context, true); - setState(() { - repeatD = "Every week"; - repeatingChoose = value; - }); - } - ), - RadioListTile( - title: const Text("Every month"), - value: SingingCharacter.monthly, - groupValue: repeatingChoose, - onChanged: (SingingCharacter? value) { - Navigator.pop(context,true); - setState(() { - repeatD = "Every month"; - repeatingChoose = value; - }); - } - ), - RadioListTile( - title: const Text("Every year"), - value: SingingCharacter.yearly, - groupValue: repeatingChoose, - onChanged: (SingingCharacter? value) { - Navigator.pop(context, true); - - setState(() { - repeatD = "Every year"; - repeatingChoose = value; - }); - } - ), + builder: (context, setState) { + return Dialog( + elevation: 20, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)), + child: SizedBox( + height: 300, + child: Column( + children: [ + RadioListTile( + title: const Text("Don't Repeat"), + value: SingingCharacter.none, + groupValue: repeatingChoose, + onChanged: (SingingCharacter? value) { + Navigator.pop(context, true); + setState(() { + repeatD = "Don't Repeat"; + repeatingChoose = value; + }); + } + ), + RadioListTile( + title: const Text("Everyday"), + value: SingingCharacter.daily, + groupValue: repeatingChoose, + onChanged: (SingingCharacter? value) { + Navigator.pop(context, true); + setState(() { + repeatD = "Everyday"; + repeatingChoose = value; + }); + } + ), + RadioListTile( + title: const Text("Every week"), + value: SingingCharacter.weekly, + groupValue: repeatingChoose, + onChanged: (SingingCharacter? value) { + Navigator.pop(context, true); + setState(() { + repeatD = "Every week"; + repeatingChoose = value; + }); + } + ), + RadioListTile( + title: const Text("Every month"), + value: SingingCharacter.monthly, + groupValue: repeatingChoose, + onChanged: (SingingCharacter? value) { + Navigator.pop(context,true); + setState(() { + repeatD = "Every month"; + repeatingChoose = value; + }); + } + ), + RadioListTile( + title: const Text("Every year"), + value: SingingCharacter.yearly, + groupValue: repeatingChoose, + onChanged: (SingingCharacter? value) { + Navigator.pop(context, true); + + setState(() { + repeatD = "Every year"; + repeatingChoose = value; + }); + } + ), - ], - ), - ) - ); - }); + ], + ), + ) + ); + }); }).then((value) { setState(() { }); }); + } + + } void onColor() { diff --git a/lib/main.dart b/lib/main.dart index d284028..61d23b4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -96,17 +96,17 @@ class AppWidget extends StatefulWidget { class _MyStatefulWidgetState extends State with TickerProviderStateMixin { - late TabController _tabController; + late TabController tabController; @override void initState() { super.initState(); - _tabController = TabController(length: 5, vsync: this); + tabController = TabController(length: 5, vsync: this); } @override void dispose() { - _tabController.dispose(); + tabController.dispose(); super.dispose(); } @@ -188,7 +188,7 @@ class _MyStatefulWidgetState extends State isScrollable: true, indicatorColor: Colors.white, labelColor: Colors.white, - controller: _tabController, + controller: tabController, indicatorSize: TabBarIndicatorSize.label, tabs: [ Tab( @@ -208,10 +208,10 @@ class _MyStatefulWidgetState extends State text: "To-Do", ), const Tab( - text: "Projects", + text: "Assignments", ), const Tab( - text: "Assignments", + text: "Projects", ), const Tab( text: "Exams", @@ -221,7 +221,7 @@ class _MyStatefulWidgetState extends State ), ), body: TabBarView( - controller: _tabController, + controller: tabController, children: [ CalendarWidget( From 5b000f16ef92e57c19020aa78171005f1ed72109 Mon Sep 17 00:00:00 2001 From: Nathan Fox <58736647+Sergentfox234@users.noreply.github.com> Date: Sun, 17 Apr 2022 18:25:58 -0400 Subject: [PATCH 13/13] Added the logo to the application --- assets/icons/dayToDayLogo.jpg | Bin 0 -> 5734 bytes assets/icons/dtdLogo1.png | Bin 0 -> 13198 bytes assets/icons/dtdLogo2.jpg | Bin 0 -> 12259 bytes pubspec.yaml | 20 +++++++++++++++++++- 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 assets/icons/dayToDayLogo.jpg create mode 100644 assets/icons/dtdLogo1.png create mode 100644 assets/icons/dtdLogo2.jpg diff --git a/assets/icons/dayToDayLogo.jpg b/assets/icons/dayToDayLogo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f8e110ce86f09e1da18501b88ef29425b8e5898d GIT binary patch literal 5734 zcma)Ac|26z|GzT^V@NY*#u75NF;Uh+sO&>_BckkUBD)Edv2QJm$i7zgge+NVY}rf5 zR%A=|B?>*tZ|Ldid0yXtexGyh=e*D7eP8c;&iR~s@66pB-kSj6=hZdU0T37f?5G9U zTLKWOKDJl=01yBH06>8nS^=<1c5XKIfE|Sz0nq?x2n`+V5CG7(0{~1001mqX0IS{J zdmt2`gFqm(5IR~~ItDuG!3d?JgEBI~V2m&r6P)S5;7rVi;fI--kVq5?iR9wswkZ3>%0E__9AV7O9zz_g{X+R(lb^O1L z20}{*q6brB`^@hswWWc8_Zc{KrZiw$2$lUs(ok0kj({L(C0Ha;XpHztR$e|usZ;z2 zYMcf_Pe=b-g{p{Uk%D8g%icG$y&7#;05BK~q6+_WQ4m4` z&WjP(_Xtw7CMmHX_Z9c`{wN~gyb@~%I+(cZvc|XTlj4f{d!qmob#!0^4T74NO-4C= zTFI+$swx3n1^~KJJ3nrw@5lj?pvNa~DR0&lfkf-Js?d_ru^9Te4gnj&t1eAR0yXMke)pS7`>Msdo>D1%AK59`J&P9< z_a^e7N3TnxJ zKa@DSB_Cfg}9k$0ZpPx1xqO#c%q@Ek_6J zkGXvv@oDk^H=H_l|C351kGX-5fnZH=H?KV;hl%eY)2BdBLaJy7mmz5X% zb8rukjk{R^+lho)94~uIeJ*|E5%j!Tb+MqhW=kZs0x~1nfFJVhhI{&WJ9;1DFvvwLVD^_Y%S~^ks zx2J-C*T1P^7hrP0X_pXq{xD(v8g@bN2aZeAAXjZ{2b&`HsN*EAPIFS^nV@Iu_~m## zw!WDZCiAoeZmDXzmcVngF?F^XPJc~IV^+)jG;TL-tQmX^^FY}L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`yLmAHlxw4Y=-RrIs)0oBa%WwJG|Af; zbT77c+VQ@yD2qVUIQL-NfDphW%)%th5gHxD<-?F!Ye*^7ttQFJqQ5pO*G3`-+S?ej zgcYpzfd-(HBm^QNg(bFh&{)sbcQ}-N2LQxc2IzLJ{@e951Wf=4`NnW#kX6&^{`S^%I_r10 zJKB&CkusKn@G?HwM!0eGT9{vjfk4!Y1P%a1|tnP1=g0SZ)mDc|J+O zT6?IOZ+D(K@kztGY+-WftTDqmw$>})Ofky+U}FupdwVV2=?5Bsr4zesMt1mK%E+BR z=*lF(zdbQ_vrH8Nq{B)pY}nYN zOU&h>^X_txPYggxax^M?)MLPrzH3Xe_`z@1y0oiu*ogG7f!-0dbGzQ%YrV|gKmd-m z!dvp6h*V(?D%{c1>sx*#LQdLV^nM#+iC}N<1-w>UP>vSa!CluEx{G$UwDh)Lr<77S zzPOGx5B4mO1pT5St*Rii3^}|emqcL3Ny~};|IU#W(qdP#;Q#;t07*qoM6N<$g7C3+ AivR!s literal 0 HcmV?d00001 diff --git a/assets/icons/dtdLogo2.jpg b/assets/icons/dtdLogo2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..637feb743eba9143c02305d1e8523d5072052993 GIT binary patch literal 12259 zcmd^lc|278`}Yx2mL{RdG8IaMC{f{5ZWNVUvV=@KnIs~+Q^^`lR77f$t!$GbyD8h) zWt~D8I}^s(WIzd4J0YPCQ zp|$Hog+)b0ghfQeHf-7`wn2P@h{(px8^t9grKF@pQCp-pOG50Q+YZwIhOoR43ek5>br0f0{sQD9Yve?0isATq8MTDM+U z1o=YYMqmveKmQs5{#B`wZwDct0|MfLo3?8mT`OUEQD}#Ur1rholy!>7^1n!(X{Rae zyX1L)z3}EO(lT3>ckWWzt-4?5fUe%bLq@+Do0uLyVPAf`=#0c znqv3=w>0}xvA^`{1w{Gzkj>*42S9+!|0YU}YVoBiO6B#MD6@S>g!f8sBuS6#mvT#! zSa8;9Vo-;7;%LjH8UKnV{$0Db#RbwB8 zJMM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itynTIQ`+fjm@RQPK&b4EL6 zYtCFdC`mK+4wh#mLa(!oJWnn&NoRaHYMJw>(A>i3<~P=kd=z)Op5>xjdNTByiOWJ= zd(zl54JcyyeQ|?j!hYpz0fsN;ZA~jb_fuiIxC3^$MdNCJ(Q%XatKY(J67#xz?ZdDsLYTOgJh#Vqovkgb?D%pgAR@wsYS*(Z=zoSH0# z$w`2jl2BECA=1!lfaYS)f9mA6n;?gkOL$>o4U(e&{K)jrA4v7Nfj=Zy5Bu#i*E~R4 zjvF*V$FN5cR}-!y!>cf{()doF#fq^ka%_$WIQL&&&iIW&k2Au>{`xuk&sA;RkaoG3 z<*)z#A4-M#hvaq)XV>O+6^Y@gDpI+Zhkj_+qqL+0yINmZezNYO ex$kniYW9`nuacHwH=j1&|8+OD%4-zw`~LumE{r|^ literal 0 HcmV?d00001 diff --git a/pubspec.yaml b/pubspec.yaml index 6cae892..d091755 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -38,11 +38,13 @@ dependencies: cupertino_icons: ^1.0.2 firebase_auth: ^3.3.14 - dev_dependencies: flutter_test: sdk: flutter + flutter_launcher_icons: ^0.9.2 + flutter_native_splash: ^2.1.6 + # The "flutter_lints" package below contains a set of recommended lints to # encourage good coding practices. The lint set provided by the package is # activated in the `analysis_options.yaml` file located at the root of your @@ -50,6 +52,19 @@ dev_dependencies: # rules and activating additional ones. flutter_lints: ^1.0.0 +flutter_icons: + android: "launcher_icon" + ios: true + image_path: "assets/icons/dtdLogo1.png" + +flutter_native_splash: + color: "#de6749" + image: "assets/icons/dtdLogo1.png" + android12: + image: "assets/icons/dtdLogo1.png" + android: true + ios: true + # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec @@ -68,6 +83,9 @@ flutter: - assets/icons/search-icon.png - assets/icons/clock.png - assets/icons/repeat.png + - assets/icons/dayToDayLogo.jpg + - assets/icons/dtdLogo2.jpg + - assets/icons/dtdLogo1.png # An image asset can refer to one or more resolution-specific "variants", see