Skip to content

Commit

Permalink
Redesign: Restaurant Page (#1443)
Browse files Browse the repository at this point in the history
  • Loading branch information
thePeras authored Feb 6, 2025
2 parents 213f317 + 380b135 commit 5dfc0de
Show file tree
Hide file tree
Showing 26 changed files with 770 additions and 332 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class RestaurantFetcher {
}
return Restaurant(
establishment.id,
establishment.type.namePt,
establishment.type.nameEn,
establishment.namePt,
establishment.nameEn,
period,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ class RestaurantDatabase extends AppDatabase<List<Restaurant>> {
CREATE TABLE RESTAURANTS(
id INTEGER PRIMARY KEY,
ref TEXT,
namePt TEXT
namePt TEXT)
typePt TEXT,
typeEn TEXT,
namePt TEXT,
nameEn TEXT)
''',
'''
CREATE TABLE MEALS(
Expand Down Expand Up @@ -47,6 +49,8 @@ class RestaurantDatabase extends AppDatabase<List<Restaurant>> {

return Restaurant(
restaurantId,
map['typePt'] as String,
map['typeEn'] as String,
map['namePt'] as String,
map['nameEn'] as String,
map['period'] as String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class PreferencesController {
static final List<String> _defaultFilteredExamTypes = Exam.displayedTypes;
static const String _semesterValue = 'semester_value';
static const String _schoolYearValue = 'school_year_value';
static const String _selectedDishType = 'selected_dish_type';
static const String _isFavoriteRestaurantsFilterOn =
'is_favorite_restaurant_filter_on';

static final _statsToggleStreamController =
StreamController<bool>.broadcast();
Expand Down Expand Up @@ -285,4 +288,26 @@ class PreferencesController {
static String? getSchoolYearValue() {
return prefs.getString(_schoolYearValue);
}

static Future<void> setSelectedDishType(int? value) async {
await prefs.setInt(_selectedDishType, value ?? 1);
if (value == null) {
await prefs.remove(_selectedDishType);
}
}

static int? getSelectedDishType() {
return prefs.getInt(_selectedDishType);
}

static Future<void> setIsFavoriteRestaurantsFilterOn(bool? value) async {
await prefs.setBool(_isFavoriteRestaurantsFilterOn, value ?? false);
if (value == null) {
await prefs.remove(_selectedDishType);
}
}

static bool? getIsFavoriteRestaurantsFilterOn() {
return prefs.getBool(_isFavoriteRestaurantsFilterOn);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ List<Restaurant> getRestaurantsFromHtml(Response response) {
}
}
return Restaurant(
null,
null,
null,
restaurantTuple.$2,
restaurantTuple.$2,
Expand Down
33 changes: 27 additions & 6 deletions packages/uni_app/lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,24 @@ typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'en';

static m0(time) => "last refresh at ${time}";
static m0(type) => "${Intl.select(type, {
'all_dishes': 'All dishes',
'meat_dishes': 'Meat dishes',
'fish_dishes': 'Fish dishes',
'vegetarian_dishes': 'Vegetarian dishes',
'soups': 'Soups',
'salads': 'Salads',
'diet_dishes': 'Diet dishes',
'dishes_of_the_day': 'Dishes of the Day',
'other': 'Other',
})}";

static m1(time) => "last refresh at ${time}";

static m1(time) =>
static m2(time) =>
"${Intl.plural(time, zero: 'Refreshed ${time} minutes ago', one: 'Refreshed ${time} minute ago', other: 'Refreshed ${time} minutes ago')}";

static m2(title) => "${Intl.select(title, {
static m3(title) => "${Intl.select(title, {
'horario': 'Schedule',
'exames': 'Exams',
'area': 'Personal Area',
Expand All @@ -40,6 +52,12 @@ class MessageLookup extends MessageLookupByLibrary {
'other': 'Other',
})}";

static m4(period) => "${Intl.select(period, {
'lunch': 'Lunch',
'dinner': 'Dinner',
'other': 'Other',
})}";

final messages = _notInlinedMessages(_notInlinedMessages);
static _notInlinedMessages(_) => <String, Function>{
"about": MessageLookupByLibrary.simpleMessage("About us"),
Expand Down Expand Up @@ -113,6 +131,7 @@ class MessageLookup extends MessageLookupByLibrary {
"desired_email": MessageLookupByLibrary.simpleMessage(
"Email where you want to be contacted"),
"dinner": MessageLookupByLibrary.simpleMessage("Dinner"),
"dish_type": m0,
"dona_bia": MessageLookupByLibrary.simpleMessage(
"D. Beatriz\'s stationery store"),
"dona_bia_building": MessageLookupByLibrary.simpleMessage(
Expand All @@ -135,6 +154,7 @@ class MessageLookup extends MessageLookupByLibrary {
"fail_to_authenticate":
MessageLookupByLibrary.simpleMessage("Failed to authenticate"),
"failed_login": MessageLookupByLibrary.simpleMessage("Login failed"),
"favourite_filter": MessageLookupByLibrary.simpleMessage("Favourites"),
"fee_date": MessageLookupByLibrary.simpleMessage("Deadline"),
"fee_notification":
MessageLookupByLibrary.simpleMessage("Fee deadline"),
Expand Down Expand Up @@ -164,8 +184,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Invalid credentials"),
"keep_login": MessageLookupByLibrary.simpleMessage("Remember me"),
"language": MessageLookupByLibrary.simpleMessage("Language"),
"last_refresh_time": m0,
"last_timestamp": m1,
"last_refresh_time": m1,
"last_timestamp": m2,
"leave_feedback":
MessageLookupByLibrary.simpleMessage("Leave feedback"),
"lectures": MessageLookupByLibrary.simpleMessage("Lectures"),
Expand All @@ -185,7 +205,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Minimum value: 1,00 €"),
"multimedia_center":
MessageLookupByLibrary.simpleMessage("Multimedia center"),
"nav_title": m2,
"nav_title": m3,
"news": MessageLookupByLibrary.simpleMessage("News"),
"no": MessageLookupByLibrary.simpleMessage("No"),
"noExamsScheduled":
Expand Down Expand Up @@ -279,6 +299,7 @@ class MessageLookup extends MessageLookupByLibrary {
"report_error": MessageLookupByLibrary.simpleMessage("Report error"),
"restaurant_main_page": MessageLookupByLibrary.simpleMessage(
"Do you want to see your favorite restaurants in the main page?"),
"restaurant_period": m4,
"room": MessageLookupByLibrary.simpleMessage("Room"),
"school_calendar":
MessageLookupByLibrary.simpleMessage("School Calendar"),
Expand Down
33 changes: 27 additions & 6 deletions packages/uni_app/lib/generated/intl/messages_pt_PT.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,24 @@ typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'pt_PT';

static m0(time) => "última atualização às ${time}";
static m0(type) => "${Intl.select(type, {
'all_dishes': 'Todos os pratos',
'meat_dishes': 'Pratos de Carne',
'fish_dishes': 'Pratos de Peixe',
'vegetarian_dishes': 'Pratos Vegetarianos',
'soups': 'Sopas',
'salads': 'Saladas',
'diet_dishes': 'Pratos de Dieta',
'dishes_of_the_day': 'Pratos do Dia',
'other': 'Outros',
})}";

static m1(time) => "última atualização às ${time}";

static m1(time) =>
static m2(time) =>
"${Intl.plural(time, zero: 'Atualizado há ${time} minutos', one: 'Atualizado há ${time} minuto', other: 'Atualizado há ${time} minutos')}";

static m2(title) => "${Intl.select(title, {
static m3(title) => "${Intl.select(title, {
'horario': 'Horário',
'exames': 'Exames',
'area': 'Área Pessoal',
Expand All @@ -40,6 +52,12 @@ class MessageLookup extends MessageLookupByLibrary {
'other': 'Outros',
})}";

static m4(period) => "${Intl.select(period, {
'lunch': 'Almoço',
'dinner': 'Jantar',
'other': 'Other',
})}";

final messages = _notInlinedMessages(_notInlinedMessages);
static _notInlinedMessages(_) => <String, Function>{
"about": MessageLookupByLibrary.simpleMessage("Sobre nós"),
Expand Down Expand Up @@ -113,6 +131,7 @@ class MessageLookup extends MessageLookupByLibrary {
"desired_email": MessageLookupByLibrary.simpleMessage(
"Email em que desejas ser contactado"),
"dinner": MessageLookupByLibrary.simpleMessage("Jantar"),
"dish_type": m0,
"dona_bia":
MessageLookupByLibrary.simpleMessage("Papelaria D. Beatriz"),
"dona_bia_building": MessageLookupByLibrary.simpleMessage(
Expand All @@ -135,6 +154,7 @@ class MessageLookup extends MessageLookupByLibrary {
"fail_to_authenticate":
MessageLookupByLibrary.simpleMessage("Falha ao autenticar"),
"failed_login": MessageLookupByLibrary.simpleMessage("O login falhou"),
"favourite_filter": MessageLookupByLibrary.simpleMessage("Favoritos"),
"fee_date": MessageLookupByLibrary.simpleMessage("Data limite"),
"fee_notification":
MessageLookupByLibrary.simpleMessage("Data limite de propina"),
Expand Down Expand Up @@ -164,8 +184,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Credenciais inválidas"),
"keep_login": MessageLookupByLibrary.simpleMessage("Lembre-se de mim"),
"language": MessageLookupByLibrary.simpleMessage("Idioma"),
"last_refresh_time": m0,
"last_timestamp": m1,
"last_refresh_time": m1,
"last_timestamp": m2,
"leave_feedback": MessageLookupByLibrary.simpleMessage("Feedback"),
"lectures": MessageLookupByLibrary.simpleMessage("Aulas"),
"library_occupation":
Expand All @@ -184,7 +204,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Valor mínimo: 1,00 €"),
"multimedia_center":
MessageLookupByLibrary.simpleMessage("Centro de multimédia"),
"nav_title": m2,
"nav_title": m3,
"news": MessageLookupByLibrary.simpleMessage("Notícias"),
"no": MessageLookupByLibrary.simpleMessage("Não"),
"noExamsScheduled":
Expand Down Expand Up @@ -281,6 +301,7 @@ class MessageLookup extends MessageLookupByLibrary {
"report_error": MessageLookupByLibrary.simpleMessage("Reportar erro"),
"restaurant_main_page": MessageLookupByLibrary.simpleMessage(
"Queres ver os teus restaurantes favoritos na página principal?"),
"restaurant_period": m4,
"room": MessageLookupByLibrary.simpleMessage("Sala"),
"school_calendar":
MessageLookupByLibrary.simpleMessage("Calendário Escolar"),
Expand Down
46 changes: 46 additions & 0 deletions packages/uni_app/lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions packages/uni_app/lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -365,5 +365,11 @@
"exams": "Exams",
"@exams": {},
"courses": "Courses",
"@courses": {}
}
"@courses": {},
"dish_type": "{type, select, all_dishes{All dishes} meat_dishes{Meat dishes} fish_dishes{Fish dishes} vegetarian_dishes{Vegetarian dishes} soups{Soups} salads{Salads} diet_dishes{Diet dishes} dishes_of_the_day{Dishes of the Day} other{Other}}",
"@dish_type": {},
"favourite_filter": "Favourites",
"@favourite_filter": {},
"restaurant_period": "{period, select, lunch{Lunch} dinner{Dinner} other{Other}}",
"@restaurant_period": {}
}
8 changes: 7 additions & 1 deletion packages/uni_app/lib/l10n/intl_pt_PT.arb
Original file line number Diff line number Diff line change
Expand Up @@ -365,5 +365,11 @@
"exams": "Exames",
"@exams": {},
"courses": "Cursos",
"@courses": {}
"@courses": {},
"dish_type": "{type, select, all_dishes{Todos os pratos} meat_dishes{Pratos de Carne} fish_dishes{Pratos de Peixe} vegetarian_dishes{Pratos Vegetarianos} soups{Sopas} salads{Saladas} diet_dishes{Pratos de Dieta} dishes_of_the_day{Pratos do Dia} other{Outros}}",
"@dish_type": {},
"favourite_filter": "Favoritos",
"@favourite_filter": {},
"restaurant_period": "{period, select, lunch{Almoço} dinner{Jantar} other{Other}}",
"@restaurant_period": {}
}
2 changes: 0 additions & 2 deletions packages/uni_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import 'package:uni/view/profile/profile.dart';
import 'package:uni/view/restaurant/restaurant_page_view.dart';
import 'package:uni/view/schedule/schedule.dart';
import 'package:uni/view/splash/splash.dart';
import 'package:uni/view/theme.dart';
import 'package:uni/view/theme_notifier.dart';
import 'package:uni/view/transports/transports.dart';
import 'package:uni_ui/theme.dart';
Expand Down Expand Up @@ -241,7 +240,6 @@ class ApplicationState extends State<Application> {
title: 'uni',
navigatorKey: Application.navigatorKey,
theme: lightTheme,
darkTheme: applicationDarkTheme,
themeMode: ThemeMode.light, // themeNotifier.getTheme(),
locale: localeNotifier.getLocale().localeCode,
localizationsDelegates: const [
Expand Down
6 changes: 6 additions & 0 deletions packages/uni_app/lib/model/entities/restaurant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ part '../../generated/model/entities/restaurant.g.dart';
class Restaurant {
Restaurant(
this.id,
this.typePt,
this.typeEn,
this.namePt,
this.nameEn,
this.period,
Expand All @@ -26,6 +28,10 @@ class Restaurant {
_$RestaurantFromJson(json);
@JsonKey(name: 'id')
final int? id;
@JsonKey(name: 'typePt')
final String? typePt;
@JsonKey(name: 'typeEn')
final String? typeEn;
@JsonKey(name: 'namePt')
final String namePt;
@JsonKey(name: 'nameEn')
Expand Down
Loading

0 comments on commit 5dfc0de

Please sign in to comment.