Skip to content

Commit

Permalink
adding calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
DGoiana committed Jan 20, 2025
1 parent 776b2dd commit f28c551
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 9 deletions.
10 changes: 6 additions & 4 deletions packages/uni_app/lib/view/home/home2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import 'package:flutter/material.dart';
import 'package:uni/view/common_widgets/pages_layouts/general/widgets/bottom_navigation_bar.dart';
import 'package:uni/view/common_widgets/pages_layouts/general/widgets/profile_button.dart';
import 'package:uni/view/home/widgets/uni_icon.dart';
import 'package:uni/view/home/widgets2/exam_card.dart';
import 'package:uni/view/home/widgets2/generic_homecard.dart';
import 'package:uni/view/home/widgets2/calendar_home_card.dart';
import 'package:uni/view/home/widgets2/exam_home_card.dart';
import 'package:uni/view/home/widgets2/generic_home_card.dart';
import 'package:uni/view/home/widgets2/library_home_card.dart';
import 'package:uni/view/home/widgets2/schedule_homecard.dart';
import 'package:uni/view/home/widgets2/schedule_home_card.dart';
import 'package:uni_ui/cards/schedule_card.dart';

class HomePageView2 extends StatefulWidget {
Expand All @@ -18,8 +19,9 @@ class HomePageView2 extends StatefulWidget {
class HomePageView2State extends State<HomePageView2> {
List<GenericHomecard> favoriteCards = [
const ExamHomeCard(title: 'Exams'),
const ScheduleHomecard(title: 'Schedule'),
const ScheduleHomeCard(title: 'Schedule'),
const LibraryHomeCard(title: 'Library Occupation'),
const CalendarHomeCard(title: 'Calendar'),
];

@override
Expand Down
53 changes: 53 additions & 0 deletions packages/uni_app/lib/view/home/widgets2/calendar_home_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';
import 'package:uni/model/entities/calendar_event.dart';
import 'package:uni/model/providers/lazy/calendar_provider.dart';
import 'package:uni/view/home/widgets2/generic_home_card.dart';
import 'package:uni/view/lazy_consumer.dart';
import 'package:uni_ui/calendar/calendar.dart';
import 'package:uni_ui/calendar/calendar_item.dart';

class CalendarHomeCard extends GenericHomecard {
const CalendarHomeCard({super.key, required super.title});

@override
void onClick(BuildContext context) {}

@override
Widget buildCardContent(BuildContext context) {
return LazyConsumer<CalendarProvider, List<CalendarEvent>>(
builder: (context, events) {
return Calendar(
items: buildCalendarItems(events),
);
},
hasContent: (events) => events.isNotEmpty,
onNullContent: const Center(
child: Text(
'Nenhum evento encontrado',
style: TextStyle(fontSize: 18),
),
),
);
}

List<CalendarItem> buildCalendarItems(List<CalendarEvent> events) {
final items = events
.map((event) => CalendarItem(
eventName: event.name,
))
.toList();

return items; // TODO: wait for calendar events date regex
}
}


/*
const CalendarItem({
super.key,
required this.eventName,
this.eventPeriod,
this.endYear,
this.onTap,
});
*/
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:uni/controller/local_storage/preferences_controller.dart';
import 'package:uni/model/entities/exam.dart';
import 'package:uni/model/providers/lazy/exam_provider.dart';
import 'package:uni/view/home/widgets2/generic_homecard.dart';
import 'package:uni/view/home/widgets2/generic_home_card.dart';
import 'package:uni/view/lazy_consumer.dart';
import 'package:uni_ui/cards/exam_card.dart';
import 'package:uni_ui/cards/timeline_card.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:uni/generated/l10n.dart';
import 'package:uni/model/entities/library_occupation.dart';
import 'package:uni/model/providers/lazy/library_occupation_provider.dart';
import 'package:uni/view/home/widgets2/generic_homecard.dart';
import 'package:uni/view/home/widgets2/generic_home_card.dart';
import 'package:uni/view/lazy_consumer.dart';
import 'package:uni_ui/cards/library_occupation_card.dart';

Expand Down
56 changes: 56 additions & 0 deletions packages/uni_app/lib/view/home/widgets2/restaurants_carousel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:uni/controller/local_storage/preferences_controller.dart';
import 'package:uni/generated/l10n.dart';
import 'package:uni/model/entities/restaurant.dart';
import 'package:uni/model/providers/lazy/restaurant_provider.dart';
import 'package:uni/utils/navigation_items.dart';
import 'package:uni/view/home/widgets2/generic_home_card.dart';
import 'package:uni/view/lazy_consumer.dart';
import 'package:uni_ui/cards/restaurant_card.dart';

class RestaurantsCarousel extends GenericHomecard {
const RestaurantsCarousel({
super.key,
required super.title,
});

@override
void onClick(BuildContext context) => {};

@override
Widget buildCardContent(BuildContext context) {
return LazyConsumer<RestaurantProvider, List<Restaurant>>(
builder: (context, restaurants) {
final favoriteRestaurants = restaurants
.where(
(restaurant) => PreferencesController.getFavoriteRestaurants()
.contains(restaurant.namePt + restaurant.period),
)
.toList();
return Container(); // TODO: finish this once restaurants page is complete
},
hasContent: (restaurants) =>
PreferencesController.getFavoriteRestaurants().isNotEmpty,
onNullContent: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 10, bottom: 10),
child: Center(
child: Text(
S.of(context).no_favorite_restaurants,
style: Theme.of(context).textTheme.titleMedium,
),
),
),
OutlinedButton(
onPressed: () => Navigator.pushNamed(
context,
'/${NavigationItem.navRestaurants.route}',
),
child: Text(S.of(context).add),
),
],
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import 'package:intl/intl.dart';
import 'package:uni/model/entities/lecture.dart';
import 'package:uni/model/providers/lazy/lecture_provider.dart';
import 'package:uni/model/utils/time/week.dart';
import 'package:uni/view/home/widgets2/generic_homecard.dart';
import 'package:uni/view/home/widgets2/generic_home_card.dart';
import 'package:uni/view/lazy_consumer.dart';
import 'package:uni_ui/cards/schedule_card.dart';
import 'package:uni_ui/cards/timeline_card.dart';

class ScheduleHomecard extends GenericHomecard {
const ScheduleHomecard({
class ScheduleHomeCard extends GenericHomecard {
const ScheduleHomeCard({
super.key,
required super.title,
});
Expand Down

0 comments on commit f28c551

Please sign in to comment.