diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 8316800..a183ec3 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -471,7 +471,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 11; + CURRENT_PROJECT_VERSION = 12; DEVELOPMENT_TEAM = S4AJ4WBQ76; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -480,7 +480,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 0.4.3; + MARKETING_VERSION = 1.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.31b4.univerx; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -659,7 +659,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 11; + CURRENT_PROJECT_VERSION = 12; DEVELOPMENT_TEAM = S4AJ4WBQ76; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -668,7 +668,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 0.4.3; + MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = com.31b4.univerx; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -688,7 +688,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 11; + CURRENT_PROJECT_VERSION = 12; DEVELOPMENT_TEAM = S4AJ4WBQ76; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -697,7 +697,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 0.4.3; + MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = com.31b4.univerx; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/lib/database/appdata.dart b/lib/database/appdata.dart new file mode 100644 index 0000000..e032a21 --- /dev/null +++ b/lib/database/appdata.dart @@ -0,0 +1,24 @@ +import 'package:univerx/models/class.dart'; + +const String version_number = 'v1.0.1'; + +// create class for time with setter and getter with Datetime +class CurrentTime{ + DateTime _time = DateTime.now(); + //DateTime _time = DateTime(2024,09,02,11,40); + + DateTime get_time(){ + updateTime(); + return _time; + } + + + // update time with datetime.now + void updateTime(){ + _time = DateTime.now(); + //_time = DateTime(2024,09,02,11,40); + } +} + + +//final DateTime set_time = DateTime.now(); diff --git a/lib/features/calendar/calendarPage.dart b/lib/features/calendar/calendarPage.dart index 54c13ef..d351850 100644 --- a/lib/features/calendar/calendarPage.dart +++ b/lib/features/calendar/calendarPage.dart @@ -15,6 +15,8 @@ import 'package:univerx/services/icsLinkManager.dart'; import 'package:univerx/features/common/widgets/profile_menu.dart'; import 'package:univerx/features/calendar/widgets/customCalendar.dart'; import 'package:univerx/features/calendar/widgets/hourlyView.dart'; +import 'package:univerx/database/appdata.dart'; + class Calendar extends StatefulWidget { final DateTime? focusedDay; @@ -41,11 +43,10 @@ class _CalendarPageState extends State { // Load events _loadEvents(); - - // Set _focusedDay to the provided focusedDay or default to DateTime.now() - _focusedDay = DateTime.now(); + CurrentTime time = CurrentTime(); + _focusedDay = time.get_time(); _selectedDay = _focusedDay; - initialDate = DateTime.now(); + initialDate = time.get_time(); _selectedEvents = ValueNotifier(_getEventsForDay(_selectedDay!)); } @@ -75,15 +76,6 @@ class _CalendarPageState extends State { ...exams.map((exam) => exam.convertExamToClass()), ...assignments.map((assignment) => assignment.convertAssignmentToClass()), ]; - /* - for (Class event in _allEvents) { - print(event.title); - print(event.startTime); - print(event.endTime); - print(event.location); - print("-----------------"); - } - */ setState(() { _selectedEvents.value = _getEventsForDay(_selectedDay!); }); @@ -91,8 +83,9 @@ class _CalendarPageState extends State { List _changeDateForInitialBUG(List events) { + CurrentTime time = CurrentTime(); List newEvents = []; - DateTime now = DateTime.now(); + DateTime now = time.get_time(); for (Class event in events) { DateTime newStart = DateTime(now.year, now.month, now.day, event.startTime.hour, event.startTime.minute); DateTime newEnd = DateTime(now.year, now.month, now.day, event.endTime.hour, event.endTime.minute); @@ -117,8 +110,9 @@ class _CalendarPageState extends State { } void _goToToday() { + CurrentTime time = CurrentTime(); setState(() { - _focusedDay = DateTime.now(); + _focusedDay = time.get_time() ; _selectedDay = _focusedDay; }); _selectedEvents.value = _getEventsForDay(_selectedDay!); @@ -155,7 +149,7 @@ class _CalendarPageState extends State { _selectedDay = selectedDay; _focusedDay = focusedDay; - initialDate = __selectedEvents.isNotEmpty ? __selectedEvents.first.startTime : DateTime.now(); + initialDate = __selectedEvents.isNotEmpty ? __selectedEvents.first.startTime : CurrentTime().get_time(); _selectedEvents.value = _changeDateForInitialBUG(__selectedEvents); }); } @@ -175,7 +169,7 @@ class _CalendarPageState extends State { builder: (context, value, _) { return Container( height: 1000, // Adjust the height as needed - child: HourlyView(allEvents: value, initialDate: initialDate), + child: HourlyView(allEvents: value, initialDate: initialDate, isToday: isSameDay(_selectedDay!, CurrentTime().get_time())), ); }, ), diff --git a/lib/features/calendar/widgets/hourlyView.dart b/lib/features/calendar/widgets/hourlyView.dart index 389f75f..190bd4f 100644 --- a/lib/features/calendar/widgets/hourlyView.dart +++ b/lib/features/calendar/widgets/hourlyView.dart @@ -8,13 +8,14 @@ import 'package:univerx/services/neptun_ICS_fetching.dart'; class HourlyView extends StatelessWidget { final List allEvents; final DateTime initialDate; + final bool isToday; - HourlyView({required this.allEvents, required this.initialDate}); + HourlyView({required this.allEvents, required this.initialDate, required this.isToday}); @override Widget build(BuildContext context) { EventController eventController = EventController(); - + // Map EventModel to CalendarEventData and add to controller allEvents.forEach((event) { eventController.add( @@ -54,6 +55,8 @@ class HourlyView extends StatelessWidget { event1.startTime.isBefore(end)); } + final liveTimeIndicatorColor = isToday ? const Color.fromARGB(255, 84, 111, 178) : Colors.transparent; + return ScrollConfiguration( behavior: NoScrollBehavior(), child: Container( @@ -65,7 +68,6 @@ class HourlyView extends StatelessWidget { } // Check for overlapping events - print(events); bool isOverlapping = false; for (int i = 0; i < allEvents.length; i++) { if (events[0].title != allEvents[i].title) { @@ -167,8 +169,8 @@ class HourlyView extends StatelessWidget { color: Color.fromARGB(255, 97, 97, 97), height: 0.7, ), - liveTimeIndicatorSettings: const LiveTimeIndicatorSettings( - color: Color.fromARGB(255, 84, 111, 178), + liveTimeIndicatorSettings: LiveTimeIndicatorSettings( + color: liveTimeIndicatorColor, height: 2.0, ), ), diff --git a/lib/features/common/widgets/default_app_bar.dart b/lib/features/common/widgets/default_app_bar.dart index 11e5e4a..e43c486 100644 --- a/lib/features/common/widgets/default_app_bar.dart +++ b/lib/features/common/widgets/default_app_bar.dart @@ -39,8 +39,8 @@ class DefaultAppBar extends StatelessWidget { Text( title, style: const TextStyle( - color: Colors.white, - fontSize: 16.0, + color: Color.fromARGB(255, 188, 188, 188), + fontSize: 24.0, fontFamily: "sfpro", ), ), diff --git a/lib/features/common/widgets/profile_menu.dart b/lib/features/common/widgets/profile_menu.dart index a99934c..efa124b 100644 --- a/lib/features/common/widgets/profile_menu.dart +++ b/lib/features/common/widgets/profile_menu.dart @@ -7,6 +7,8 @@ import 'package:univerx/features/neptun_login/data/logout.dart'; import 'package:univerx/database/database_helper.dart'; import 'package:univerx/models/assignment.dart'; import 'package:url_launcher/url_launcher.dart'; // Add this import for launching URLs +import 'package:univerx/database/appdata.dart'; + class DrawerMenu extends StatelessWidget { const DrawerMenu({Key? key}) : super(key: key); @@ -198,7 +200,7 @@ class DrawerMenu extends StatelessWidget { ), SizedBox(height: 10.0), const Text( - 'v1.0.0', + version_number, style: TextStyle( color: Colors.white, fontSize: 12.0, diff --git a/lib/features/home/homePage.dart b/lib/features/home/homePage.dart index 800c8b9..58e3893 100644 --- a/lib/features/home/homePage.dart +++ b/lib/features/home/homePage.dart @@ -19,6 +19,8 @@ import 'package:univerx/models/class.dart'; // ---------------------Other Packages-------------------------- import 'package:custom_refresh_indicator/custom_refresh_indicator.dart'; import 'package:vibration/vibration.dart'; +import 'package:univerx/services/titleGenerator.dart'; +import 'package:univerx/database/appdata.dart'; // ---------------------Widgets-------------------------- import 'package:univerx/features/common/widgets/default_app_bar.dart'; @@ -130,8 +132,9 @@ class _HomeState extends State with RouteAware { } Map> _groupEventsByDate(List exams, List assignments) { + CurrentTime time = CurrentTime(); final Map> groupedEvents = {}; - final now = DateTime.now(); + final now = time.get_time(); //print exams for (final exam in exams) { @@ -235,14 +238,14 @@ class _HomeState extends State with RouteAware { } final groupedEvents = _groupEventsByDate(filteredExams, filteredAssignments); - + CurrentTime time = CurrentTime(); // Sort the entries by date final sortedEntries = groupedEvents.entries.toList() ..sort((a, b) => DateFormat('yyyy MMM d').parse(a.key).compareTo(DateFormat('yyyy MMM d').parse(b.key))); // remove events from sorted entries that are in the past sortedEntries.removeWhere((entry) { final date = DateFormat('yyyy MMM d').parse(entry.key); - return date.isBefore(DateTime.now()); + return date.isBefore(time.get_time()); }); return sortedEntries.map((entry) { @@ -287,7 +290,7 @@ class _HomeState extends State with RouteAware { child: CustomScrollView( slivers: [ DefaultAppBar( - title: "UniX-PTE-TTK", + title: welcomeGenerator(), showBackButton: false, ), SliverList( @@ -305,7 +308,7 @@ class _HomeState extends State with RouteAware { const SizedBox(height: 10), // --------------------------- Horizontal menu --------------------------- HorizontalScrollableMenu( - menuItems: ["Összes", "Zh-k", "Beadandók"], + menuItems: ["Összes", "Zh-k", "Beadandók", "Vizsga időszak", "Szünetek"], onItemSelected: _onMenuItemSelected, selectedItem: _selectedMenuItem, ), @@ -347,7 +350,6 @@ class _HomeState extends State with RouteAware { return CustomBottomNavigationBar( button1: () async { // Handle navigation to Home - print('Navigating to Home'); }, button2: () { addAssignmentOrExam(context); @@ -356,7 +358,6 @@ class _HomeState extends State with RouteAware { button3: () { // Open drawer menu Scaffold.of(context).openEndDrawer(); - print('Navigating to Menu'); }, ); }, diff --git a/lib/features/home/widgets/calendarWidget.dart b/lib/features/home/widgets/calendarWidget.dart index 6d7f02b..fd344d5 100644 --- a/lib/features/home/widgets/calendarWidget.dart +++ b/lib/features/home/widgets/calendarWidget.dart @@ -115,10 +115,10 @@ class CalendarWidget extends StatelessWidget { final event = snapshot.data; if (event != null) { return Text( - '→ ${Class.getFormattedTitle(event.title)}', + '→ ${event.startTime.hour}:${event.startTime.minute == 0 ? "00" : event.startTime.minute} ${Class.getFormattedTitle(event.title)}', style: TextStyle( fontSize: 14.0, - color: Colors.white, + color: const Color.fromARGB(255, 188, 188, 188), fontFamily: "sfpro", ), ); @@ -132,7 +132,7 @@ class CalendarWidget extends StatelessWidget { ), SizedBox(width: 5), Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6), + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 3), decoration: BoxDecoration( color: const Color.fromARGB(255, 20, 18, 32), borderRadius: BorderRadius.circular(8), @@ -148,7 +148,7 @@ class CalendarWidget extends StatelessWidget { return Text( '${event.location.split(" ").first}', style: const TextStyle( - color: Color.fromARGB(255, 255, 255, 255), + color: Color.fromARGB(255, 188, 188, 188), fontWeight: FontWeight.bold, fontSize: 10, ), @@ -164,6 +164,7 @@ class CalendarWidget extends StatelessWidget { ), ], ), + SizedBox(height: 8), FutureBuilder( future: timeLeftForEvent, builder: (context, snapshot) { @@ -176,7 +177,7 @@ class CalendarWidget extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.end, children: [ Text( - "Time left: ${timeLeft}", + "${timeLeft}", style: const TextStyle( color: Colors.white, fontSize: 10, @@ -209,8 +210,17 @@ class CalendarWidget extends StatelessWidget { value: percentagePassed, ), ); - } else { - return Container(); // Return an empty container if there's no current event + } else { //ha jelenleg nincs ora, kovetkezo oraig az ido + var percentagePassed = 1.0; + return SizedBox( + height: 10, + child: LinearProgressIndicator( + backgroundColor: const Color.fromARGB(255, 20, 18, 32), + valueColor: const AlwaysStoppedAnimation(Color.fromARGB(255, 255, 255, 255)), + borderRadius: BorderRadius.circular(20), + value: percentagePassed, + ), + ); // Return an empty container if there's no current event } }, ), diff --git a/lib/features/neptun_login/login.dart b/lib/features/neptun_login/login.dart index d8169f5..82cd3d6 100644 --- a/lib/features/neptun_login/login.dart +++ b/lib/features/neptun_login/login.dart @@ -8,7 +8,9 @@ import 'package:flutter/services.dart' show rootBundle; import 'package:univerx/features/home/homePage.dart'; import 'package:univerx/services/neptun_API_fetching.dart'; import 'package:univerx/features/common/widgets/box_3d.dart'; -import 'package:univerx/services/neptun_ICS_fetching.dart'; // Import the custom decorations +import 'package:univerx/services/neptun_ICS_fetching.dart'; // Ixport the custom decorations +import 'package:univerx/database/appdata.dart'; + class LoginPage extends StatefulWidget { @override @@ -169,7 +171,7 @@ class _LoginPageState extends State { right: 0, child: Center( child: Text( - 'v1.0.0', + version_number, style: TextStyle( color: Colors.grey, fontSize: 12.0, diff --git a/lib/services/neptun_ICS_fetching.dart b/lib/services/neptun_ICS_fetching.dart index 3a99c11..14fc6bf 100644 --- a/lib/services/neptun_ICS_fetching.dart +++ b/lib/services/neptun_ICS_fetching.dart @@ -5,6 +5,8 @@ import 'package:univerx/database/database_helper.dart'; import 'package:univerx/models/class.dart'; import 'package:univerx/models/exam.dart'; import 'package:univerx/services/neptun_API_fetching.dart'; +import 'package:univerx/database/appdata.dart'; + class ParsedData { final List classes; @@ -15,7 +17,7 @@ class ParsedData { class EventService { final String url; - final now = DateTime.now(); + var now; EventService(this.url); Future fetchAndUpdateIcs() async { @@ -29,8 +31,6 @@ class EventService { //classes and exams List newClasses = newEvents.classes; List newExams = newEvents.exams; - print(newExams); - print(newClasses); // Fetch existing events from database DatabaseHelper dbHelper = DatabaseHelper.instance; @@ -91,8 +91,9 @@ class EventService { } Future getCurrentEvent() async { + CurrentTime time = CurrentTime(); + now = time.get_time(); final events = await DatabaseHelper.instance.getClasses(); - // final now = DateTime.now(); //-------------------------------REMOVE COMMENT TO ENABLE LIVE TIME----------------------------- for (final event in events) { if (event.startTime.isBefore(now) && event.endTime.isAfter(now)) { event.title = formatText(20, event.title); @@ -102,6 +103,8 @@ class EventService { } Future getUpcomingEvent() async { + CurrentTime time = CurrentTime(); + now = time.get_time(); var events = await DatabaseHelper.instance.getClasses(); for (final event in events) { if (event.startTime.isAfter(now)) { @@ -136,33 +139,51 @@ class EventService { return result; } - String formatTimeLeft(int minutes) { + String formatTimeLeft(int minutes, bool current) { final hours = minutes ~/ 60; final mins = minutes % 60; - return '${hours}h ${mins}m'; + String prefix = current ? 'Ends in: ' : 'Starts in:'; + if (hours == 0) { + return '${prefix} ${mins}m'; + } + return '${prefix} ${hours}h ${mins}m'; } Future timeLeftForCurrentEvent() async { + CurrentTime time = CurrentTime(); + now = time.get_time(); final currentEvent = await getCurrentEvent(); + final upcomingEvent = await getUpcomingEvent(); if (currentEvent != null) { - // final now = DateTime.now(); //-------------------------------REMOVE COMMENT TO ENABLE LIVE TIME----------------------------- - final timeLeft = currentEvent.endTime.difference(now).inMinutes; - return formatTimeLeft(timeLeft); + return formatTimeLeft(timeLeft, true); + } + else if(upcomingEvent != null) { + final timeLeft = upcomingEvent.startTime.difference(now).inMinutes; + return formatTimeLeft(timeLeft, false); } return null; // No event currently happening } Future percentagePassedOfCurrentEvent() async { + CurrentTime time = CurrentTime(); + now = time.get_time(); final currentEvent = await getCurrentEvent(); + final upcomingEvent = await getUpcomingEvent(); if (currentEvent != null) { - //final now = DateTime.now(); //-------------------------------REMOVE COMMENT TO ENABLE LIVE TIME----------------------------- - final duration = currentEvent.endTime.difference(currentEvent.startTime).inMinutes; final timePassed = now.difference(currentEvent.startTime).inMinutes; final percentagePassed = timePassed / duration; return percentagePassed; } + else if (upcomingEvent != null) { + // time till upcoming event start, from last class, if there is no class, from 8:00 + final timeTillNextClass = upcomingEvent.startTime.difference(now).inMinutes; + final timeTillNextClassFrom8 = upcomingEvent.startTime.difference(DateTime(now.year, now.month, now.day, 8, 0)).inMinutes; + final percentagePassed = 1 - timeTillNextClass / timeTillNextClassFrom8; + return percentagePassed; + + } return null; // No event currently happening } diff --git a/lib/services/titleGenerator.dart b/lib/services/titleGenerator.dart new file mode 100644 index 0000000..a2a9b4d --- /dev/null +++ b/lib/services/titleGenerator.dart @@ -0,0 +1,19 @@ + + +String welcomeGenerator() { + String res = ""; + DateTime now = DateTime.now(); + // if weekend + if (now.weekday == 6 || now.weekday == 7) { + res = "Kellemes hétvégét!"; + } else if (now.hour < 12) { + res = "Jó reggelt!"; + } else if (now.hour < 18) { + res = "Kellemes délutánt!"; + } else { + res = "Jó estét!"; + } + + + return res; +} \ No newline at end of file