Skip to content

Commit

Permalink
Merge pull request #70 from univerx/dev
Browse files Browse the repository at this point in the history
v1.0.1
  • Loading branch information
31b4 authored Sep 2, 2024
2 parents 076ac66 + a1cf2f0 commit 4f67eaa
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 58 deletions.
12 changes: 6 additions & 6 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = "";
Expand Down Expand Up @@ -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;
Expand All @@ -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)";
Expand All @@ -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;
Expand All @@ -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)";
Expand Down
24 changes: 24 additions & 0 deletions lib/database/appdata.dart
Original file line number Diff line number Diff line change
@@ -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();
28 changes: 11 additions & 17 deletions lib/features/calendar/calendarPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -41,11 +43,10 @@ class _CalendarPageState extends State<Calendar> {

// 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!));
}

Expand Down Expand Up @@ -75,24 +76,16 @@ class _CalendarPageState extends State<Calendar> {
...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!);
});
}


List<Class> _changeDateForInitialBUG(List<Class> events) {
CurrentTime time = CurrentTime();
List<Class> 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);
Expand All @@ -117,8 +110,9 @@ class _CalendarPageState extends State<Calendar> {
}

void _goToToday() {
CurrentTime time = CurrentTime();
setState(() {
_focusedDay = DateTime.now();
_focusedDay = time.get_time() ;
_selectedDay = _focusedDay;
});
_selectedEvents.value = _getEventsForDay(_selectedDay!);
Expand Down Expand Up @@ -155,7 +149,7 @@ class _CalendarPageState extends State<Calendar> {
_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);
});
}
Expand All @@ -175,7 +169,7 @@ class _CalendarPageState extends State<Calendar> {
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())),
);
},
),
Expand Down
12 changes: 7 additions & 5 deletions lib/features/calendar/widgets/hourlyView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import 'package:univerx/services/neptun_ICS_fetching.dart';
class HourlyView extends StatelessWidget {
final List<Class> 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(
Expand Down Expand Up @@ -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(
Expand All @@ -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) {
Expand Down Expand Up @@ -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,
),
),
Expand Down
4 changes: 2 additions & 2 deletions lib/features/common/widgets/default_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
),
Expand Down
4 changes: 3 additions & 1 deletion lib/features/common/widgets/profile_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 8 additions & 7 deletions lib/features/home/homePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -130,8 +132,9 @@ class _HomeState extends State<Home> with RouteAware {
}

Map<String, List<Widget>> _groupEventsByDate(List<Exam> exams, List<Assignment> assignments) {
CurrentTime time = CurrentTime();
final Map<String, List<Widget>> groupedEvents = {};
final now = DateTime.now();
final now = time.get_time();
//print exams

for (final exam in exams) {
Expand Down Expand Up @@ -235,14 +238,14 @@ class _HomeState extends State<Home> 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) {
Expand Down Expand Up @@ -287,7 +290,7 @@ class _HomeState extends State<Home> with RouteAware {
child: CustomScrollView(
slivers: <Widget>[
DefaultAppBar(
title: "UniX-PTE-TTK",
title: welcomeGenerator(),
showBackButton: false,
),
SliverList(
Expand All @@ -305,7 +308,7 @@ class _HomeState extends State<Home> 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,
),
Expand Down Expand Up @@ -347,7 +350,6 @@ class _HomeState extends State<Home> with RouteAware {
return CustomBottomNavigationBar(
button1: () async {
// Handle navigation to Home
print('Navigating to Home');
},
button2: () {
addAssignmentOrExam(context);
Expand All @@ -356,7 +358,6 @@ class _HomeState extends State<Home> with RouteAware {
button3: () {
// Open drawer menu
Scaffold.of(context).openEndDrawer();
print('Navigating to Menu');
},
);
},
Expand Down
24 changes: 17 additions & 7 deletions lib/features/home/widgets/calendarWidget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
);
Expand All @@ -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),
Expand All @@ -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,
),
Expand All @@ -164,6 +164,7 @@ class CalendarWidget extends StatelessWidget {
),
],
),
SizedBox(height: 8),
FutureBuilder<String?>(
future: timeLeftForEvent,
builder: (context, snapshot) {
Expand All @@ -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,
Expand Down Expand Up @@ -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>(Color.fromARGB(255, 255, 255, 255)),
borderRadius: BorderRadius.circular(20),
value: percentagePassed,
),
); // Return an empty container if there's no current event
}
},
),
Expand Down
6 changes: 4 additions & 2 deletions lib/features/neptun_login/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -169,7 +171,7 @@ class _LoginPageState extends State<LoginPage> {
right: 0,
child: Center(
child: Text(
'v1.0.0',
version_number,
style: TextStyle(
color: Colors.grey,
fontSize: 12.0,
Expand Down
Loading

0 comments on commit 4f67eaa

Please sign in to comment.