mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-24 20:32:28 +00:00
use copywith and final class for bookableSpaceConfig
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BookableSpaceConfig {
|
||||
String configUuid;
|
||||
List<String> bookableDays;
|
||||
TimeOfDay? bookingStartTime;
|
||||
TimeOfDay? bookingEndTime;
|
||||
int cost;
|
||||
bool availability;
|
||||
final String configUuid;
|
||||
final List<String> bookableDays;
|
||||
final TimeOfDay? bookingStartTime;
|
||||
final TimeOfDay? bookingEndTime;
|
||||
final int cost;
|
||||
final bool availability;
|
||||
BookableSpaceConfig({
|
||||
required this.configUuid,
|
||||
required this.availability,
|
||||
|
@ -66,7 +66,8 @@ class BookingPeriodWidget extends StatelessWidget {
|
||||
throw Exception();
|
||||
} else {
|
||||
setupBookableSpacesBloc.selectedBookableSpaces.forEach(
|
||||
(e) => e.spaceConfig!.bookingStartTime = timePicked,
|
||||
(e) =>
|
||||
e.spaceConfig!.copyWith(bookingStartTime: timePicked),
|
||||
);
|
||||
}
|
||||
},
|
||||
@ -99,7 +100,8 @@ class BookingPeriodWidget extends StatelessWidget {
|
||||
throw Exception();
|
||||
} else {
|
||||
setupBookableSpacesBloc.selectedBookableSpaces.forEach(
|
||||
(e) => e.spaceConfig!.bookingEndTime = timePicked,
|
||||
(e) =>
|
||||
e.spaceConfig!.copyWith(bookingEndTime: timePicked),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@ -81,7 +81,7 @@ class _PointsPartWidgetState extends State<PointsPartWidget> {
|
||||
.read<SetupBookableSpacesBloc>()
|
||||
.selectedBookableSpaces
|
||||
.forEach(
|
||||
(e) => e.spaceConfig!.cost = -1,
|
||||
(e) => e.spaceConfig!.copyWith(cost: -1),
|
||||
);
|
||||
context
|
||||
.read<SetupBookableSpacesBloc>()
|
||||
@ -95,7 +95,7 @@ class _PointsPartWidgetState extends State<PointsPartWidget> {
|
||||
.read<SetupBookableSpacesBloc>()
|
||||
.selectedBookableSpaces
|
||||
.forEach(
|
||||
(e) => e.spaceConfig!.cost = 0,
|
||||
(e) => e.spaceConfig!.copyWith(cost: 0),
|
||||
);
|
||||
context
|
||||
.read<SetupBookableSpacesBloc>()
|
||||
@ -118,10 +118,10 @@ class _PointsPartWidgetState extends State<PointsPartWidget> {
|
||||
.read<SetupBookableSpacesBloc>()
|
||||
.selectedBookableSpaces
|
||||
.forEach(
|
||||
(e) => e.spaceConfig!.cost = int.parse(
|
||||
widget.pointsController.text.isEmpty
|
||||
(e) => e.spaceConfig!.copyWith(
|
||||
cost: int.parse(widget.pointsController.text.isEmpty
|
||||
? '0'
|
||||
: widget.pointsController.text,
|
||||
: widget.pointsController.text),
|
||||
),
|
||||
);
|
||||
context
|
||||
|
@ -60,7 +60,7 @@ class _WeekDaysCheckboxRowState extends State<WeekDaysCheckboxRow> {
|
||||
for (var space in context
|
||||
.read<SetupBookableSpacesBloc>()
|
||||
.selectedBookableSpaces) {
|
||||
space.spaceConfig!.bookableDays = selectedDays;
|
||||
space.spaceConfig!.copyWith(bookableDays: selectedDays);
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user