Skip to content

Commit

Permalink
Added more information to EditBookingWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
styrix560 committed Jun 3, 2024
1 parent fa51822 commit 03adf67
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/types/booking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Booking {
);

int getPrice({required BookingTime bookingTime}) =>
priceType.calculatePrice(bookingTime) * seats.length;
priceType.calculatePricePerSeat(bookingTime) * seats.length;

List<Seat> getSeatsSorted() => IterableExtension(seats).sorted(
(a, b) {
Expand Down
2 changes: 1 addition & 1 deletion lib/types/price_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ enum PriceType {
}

extension PriceTypeExte on PriceType {
int calculatePrice(BookingTime bookingTime) {
int calculatePricePerSeat(BookingTime bookingTime) {
if (this == PriceType.free) return 0;
switch (bookingTime) {
case BookingTime.afternoon:
Expand Down
28 changes: 22 additions & 6 deletions lib/widgets/edit_booking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,27 @@ class EditBookingWidget extends HookWidget {
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"Sitze bestellt: ${numberOfSeat.value}",
style: const TextStyle(
fontSize: 18,
),
Column(
children: [
Text(
"Sitze bestellt: ${numberOfSeat.value}",
style: const TextStyle(
fontSize: 18,
),
),
Text(
"Gesamtpreis: ${numberOfSeat.value * priceType.value.calculatePricePerSeat(GlobalData.currentBookingTime.value)}€",
style: const TextStyle(
fontSize: 18,
),
),
Text(
"Zu bezahlen: ${numberOfSeat.value * priceType.value.calculatePricePerSeat(GlobalData.currentBookingTime.value) - activeBooking!.pricePaid}€",
style: const TextStyle(
fontSize: 18,
),
),
],
),
const VerticalDivider(
width: 32,
Expand All @@ -135,7 +151,7 @@ class EditBookingWidget extends HookWidget {
),
space(width: 16),
Text(
"${priceType.value.calculatePrice(
"${priceType.value.calculatePricePerSeat(
bookingTime.value,
)}€ pro Sitz",
style: const TextStyle(
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/price_paid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PaidPriceWidget extends HookWidget {
.activeBooking
.value!
.priceType
.calculatePrice(GlobalData.currentBookingTime.value);
.calculatePricePerSeat(GlobalData.currentBookingTime.value);

@override
Widget build(BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/seat_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SeatCellWidget extends HookWidget {
Color getColorForBooking(
Booking booking, Color colorIfPaid, Color colorIfNotPaid) {
final pricePerSeat = booking.priceType
.calculatePrice(GlobalData.currentBookingTime.value);
.calculatePricePerSeat(GlobalData.currentBookingTime.value);
final amountOfPaidSeats =
pricePerSeat == 0 ? 1000 : booking.pricePaid ~/ pricePerSeat;

Expand Down

0 comments on commit 03adf67

Please sign in to comment.