-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
120 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/uni_app/lib/view/home/widgets2/calendar_home_card.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
packages/uni_app/lib/view/home/widgets2/restaurants_carousel.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters