Skip to content

Commit

Permalink
Offer food form (zachran-jidlo#39)
Browse files Browse the repository at this point in the history
* Init firebase functions

* Introduce custom claims to set user as donor or recipient

* Customize the application from the recipient's perspective

* Add recipient object to donor and vice versa

* Fix bug with multiple home screens on stack after logout and then login.

* Minor changes and refactoring

* Introduce abstract class from donor and recipient classes inherit.

* Delete forgotten debug print

* Introduce notifications

* Send the notification only if the delivery is for today

* Change app icon to ZO logo

* Change app name

* Rename donors collection

* Rename recipients collection

* Rename deliveries collection

* Rename offeredFood collection

* Save dates in timestamp representation

* Delete forgotten dead code

* Delete forgotten dead code

* Refactoring - rename donor to canteen and recipient to charity

* Rework offer_food_form according the figma

* Refactoring - rename packaging to boxType

* Refactoring - fix typo in password_text_field file name

* Refactoring - rename enums to snake case

* Adjust donated food detail screen according to the figma

* Remove button to create a new offer from the thank you screen

* Remove currently unnecessary menu sections

* Introduce possibility to change a password

---------

Co-authored-by: Jakub Timko <[email protected]>
  • Loading branch information
Timmynek and Jakub Timko authored Sep 5, 2023
1 parent 73b794c commit a250332
Show file tree
Hide file tree
Showing 29 changed files with 1,048 additions and 353 deletions.
23 changes: 23 additions & 0 deletions lib/enums/box_type.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:flutter/cupertino.dart';
import 'package:zachranobed/extensions/build_context_extensions.dart';

enum BoxType {
reusableBox,
ikeaBox,
disposablePackaging,
}

abstract class BoxTypeHelper {
static String toValue(BoxType boxType, BuildContext context) {
switch (boxType) {
case BoxType.reusableBox:
return context.l10n!.boxTypeReKrabicka;
case BoxType.ikeaBox:
return context.l10n!.boxTypeIkeaBox;
case BoxType.disposablePackaging:
return context.l10n!.packagingDisposable;
default:
return '';
}
}
}
20 changes: 20 additions & 0 deletions lib/enums/food_category.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
import 'package:zachranobed/extensions/build_context_extensions.dart';

enum FoodCategory {
warm,
cooled,
}

abstract class FoodCategoryHelper {
static String toValue(FoodCategory foodCategory, BuildContext context) {
switch (foodCategory) {
case FoodCategory.warm:
return context.l10n!.foodCategoryWarm;
case FoodCategory.cooled:
return context.l10n!.foodCategoryCooled;
default:
return '';
}
}
}
23 changes: 0 additions & 23 deletions lib/enums/packaging.dart

This file was deleted.

28 changes: 22 additions & 6 deletions lib/l10n/app_cs.arb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
"signIn": "Přihlásit se",
"signOut": "Odhlásit se",
"forgottenPassword": "Zapomenuté heslo",
"wrongCredentialsError": "Špatné přihlašovací údaje!",
"wrongCredentialsError": "Špatné přihlašovací údaje.",
"requiredFieldError": "Vyplňte prosím toto pole",
"invalidNumberError": "Zadejte prosím validní číslo",
"invalidAllergensFormatError": "Zadejte prosím alergeny ve správném formátu",
"requiredDropdownError": "Vyberte prosím nějakou možnost",
"packagingRekrabicka": "REkrabička",
"packagingIkeaBox": "IKEA krabička",
"boxTypeReKrabicka": "ReKrabička",
"boxTypeIkeaBox": "IKEA krabička",
"packagingDisposable": "jednorázový obal",
"foodCategoryWarm": "Teplý pokrm",
"foodCategoryCooled": "Zchlazený pokrm",
"newOffer": "Nová nabídka",
"overview": "Přehled",
"donations": "Darované",
Expand All @@ -35,12 +37,15 @@
"foodName": "Název pokrmu",
"allergens": "Alergeny",
"allergensSupportingText": "Zapisujete jako čísla oddělená čárkami.",
"foodCategory": "Druh pokrmu",
"numberOfServings": "Počet porcí",
"packaging": "Balení",
"boxType": "Typ krabičky",
"consumeBy": "Spotřebujte do",
"addAnotherFood": "Přidat další",
"dish": "Pokrm",
"summaryInfo": "Souhrnné informace",
"formCantBeEdited": "Formulář po odeslání již není možné upravovat.",
"donatedOn": "Darováno dne",
"atTime": "v",
"consent": "Kliknutím na tlačítko “Darovat pokrmy” potvrzuji, že pokrmy jsou darované po zavírací době podniku a splňují všechny požadavky stanovené správnou hygienickou praxí. Přehled podmínek je uvedený v příručce ",
"manualName": "Jak darovat hotové pokrmy.",
"confirmation": "Pokrm jste úspěšně darovali \u2764. Děkujeme, že pomáháte.",
Expand All @@ -59,10 +64,21 @@
"recipient": "Příjemce",
"saveLunch": "Zachraň oběd",
"feedback": "Zpětná vazba",
"settings": "Nastavení",
"changePassword": "Změnit heslo",
"about": "Více o projektu",
"sponsors": "Sponzoři",
"more": "Další",
"rate": "Ohodnotit aplikaci",
"privacyProtection": "Ochrana soukromí",
"termsOfUse": "Podmínky používání"
"termsOfUse": "Podmínky používání",
"currentPassword": "Současné heslo",
"invalidCurrentPasswordError": "Současné heslo není validní.",
"newPassword": "Nové heslo",
"passwordLengthError": "Heslo musí být alespoň 6 znaků dlouhé.",
"repeatNewPassword": "Zopakujte nové heslo",
"passwordsDontMatchError": "Hesla se neshodují.",
"savePassword": "Uložit heslo",
"newPasswordSuccessfullySaved": "Heslo bylo úspěšně změněno. Prosím přihlašte se novým heslem.",
"somethingWentWrongError": "Něco se nepovedlo."
}
21 changes: 0 additions & 21 deletions lib/models/food_info.dart

This file was deleted.

21 changes: 0 additions & 21 deletions lib/models/food_info.g.dart

This file was deleted.

50 changes: 19 additions & 31 deletions lib/models/offered_food.dart
Original file line number Diff line number Diff line change
@@ -1,44 +1,32 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:zachranobed/converters/timestamp_converter.dart';
import 'package:zachranobed/models/food_info.dart';

/*
* Command to rebuild the offered_food.g.dart file:
* flutter packages pub run build_runner build --delete-conflicting-outputs
*/
part 'offered_food.freezed.dart';
part 'offered_food.g.dart';

@JsonSerializable(explicitToJson: true)
class OfferedFood {
final String id;
@TimestampConverter()
final DateTime date;
final int dateTimestamp;
final FoodInfo foodInfo;
final String packaging;
@TimestampConverter()
final DateTime consumeBy;
final int consumeByTimestamp;
final String weekNumber;
final String donorId;
final String recipientId;

OfferedFood({
required this.id,
required this.date,
required this.dateTimestamp,
required this.foodInfo,
required this.packaging,
required this.consumeBy,
required this.consumeByTimestamp,
required this.weekNumber,
required this.donorId,
required this.recipientId,
});
@Freezed()
class OfferedFood with _$OfferedFood {
const factory OfferedFood({
String? id,
@TimestampConverter() DateTime? date,
int? dateTimestamp,
String? dishName,
String? foodCategory,
List<String>? allergens,
int? numberOfServings,
String? boxType,
@TimestampConverter() DateTime? consumeBy,
int? consumeByTimestamp,
String? weekNumber,
String? donorId,
String? recipientId,
}) = _OfferedFood;

factory OfferedFood.fromJson(Map<String, dynamic> json) =>
_$OfferedFoodFromJson(json);

Map<String, dynamic> toJson() => _$OfferedFoodToJson(this);
}
Loading

0 comments on commit a250332

Please sign in to comment.