6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit c2270418

AuthorMikkel Thygesen<mikkelet@gmail.com>
Date2026-02-27 12:55:07 +0100
2922: made so ready time can be selected independently

Changed files

.../presentation/app/cart_cubit.freezed.dart       | 49 ++++++++++++----------
 concierge/lib/presentation/app/cart_cubit.dart     | 11 +++--
 .../widget/delivery_method_picker.dart             |  9 ++--
 .../review_order/widget/delivery_time_picker.dart  | 14 +++----
 .../review_order/widget/review_order_app_bar.dart  |  5 +--
 5 files changed, 46 insertions(+), 42 deletions(-)

Diff

diff --git a/concierge/lib/_generated/presentation/app/cart_cubit.freezed.dart b/concierge/lib/_generated/presentation/app/cart_cubit.freezed.dart
index 94ad16eb..4f886948 100644
--- a/concierge/lib/_generated/presentation/app/cart_cubit.freezed.dart
+++ b/concierge/lib/_generated/presentation/app/cart_cubit.freezed.dart
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$CartState {
- bool get isLoading; AppError get error; Map<int, ProductInCart> get productsWithQuantity; DeliveryMethod get deliveryMethod; String get comment;
+ bool get isLoading; AppError get error; Map<int, ProductInCart> get productsWithQuantity; bool get isDelivery; String get comment; String get readyTime;
/// Create a copy of CartState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $CartStateCopyWith<CartState> get copyWith => _$CartStateCopyWithImpl<CartState>
@override
bool operator ==(Object other) {
- return identical(this, other) || (other.runtimeType == runtimeType&&other is CartState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.error, error) || other.error == error)&&const DeepCollectionEquality().equals(other.productsWithQuantity, productsWithQuantity)&&(identical(other.deliveryMethod, deliveryMethod) || other.deliveryMethod == deliveryMethod)&&(identical(other.comment, comment) || other.comment == comment));
+ return identical(this, other) || (other.runtimeType == runtimeType&&other is CartState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.error, error) || other.error == error)&&const DeepCollectionEquality().equals(other.productsWithQuantity, productsWithQuantity)&&(identical(other.isDelivery, isDelivery) || other.isDelivery == isDelivery)&&(identical(other.comment, comment) || other.comment == comment)&&(identical(other.readyTime, readyTime) || other.readyTime == readyTime));
}
@override
-int get hashCode => Object.hash(runtimeType,isLoading,error,const DeepCollectionEquality().hash(productsWithQuantity),deliveryMethod,comment);
+int get hashCode => Object.hash(runtimeType,isLoading,error,const DeepCollectionEquality().hash(productsWithQuantity),isDelivery,comment,readyTime);
@override
String toString() {
- return 'CartState(isLoading: $isLoading, error: $error, productsWithQuantity: $productsWithQuantity, deliveryMethod: $deliveryMethod, comment: $comment)';
+ return 'CartState(isLoading: $isLoading, error: $error, productsWithQuantity: $productsWithQuantity, isDelivery: $isDelivery, comment: $comment, readyTime: $readyTime)';
}
@@ -45,7 +45,7 @@ abstract mixin class $CartStateCopyWith<$Res> {
factory $CartStateCopyWith(CartState value, $Res Function(CartState) _then) = _$CartStateCopyWithImpl;
@useResult
$Res call({
- bool isLoading, AppError error, Map<int, ProductInCart> productsWithQuantity, DeliveryMethod deliveryMethod, String comment
+ bool isLoading, AppError error, Map<int, ProductInCart> productsWithQuantity, bool isDelivery, String comment, String readyTime
});
@@ -62,13 +62,14 @@ class _$CartStateCopyWithImpl<$Res>
/// Create a copy of CartState
/// with the given fields replaced by the non-null parameter values.
-@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? error = null,Object? productsWithQuantity = null,Object? deliveryMethod = null,Object? comment = null,}) {
+@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? error = null,Object? productsWithQuantity = null,Object? isDelivery = null,Object? comment = null,Object? readyTime = null,}) {
return _then(_self.copyWith(
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,error: null == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
as AppError,productsWithQuantity: null == productsWithQuantity ? _self.productsWithQuantity : productsWithQuantity // ignore: cast_nullable_to_non_nullable
-as Map<int, ProductInCart>,deliveryMethod: null == deliveryMethod ? _self.deliveryMethod : deliveryMethod // ignore: cast_nullable_to_non_nullable
-as DeliveryMethod,comment: null == comment ? _self.comment : comment // ignore: cast_nullable_to_non_nullable
+as Map<int, ProductInCart>,isDelivery: null == isDelivery ? _self.isDelivery : isDelivery // ignore: cast_nullable_to_non_nullable
+as bool,comment: null == comment ? _self.comment : comment // ignore: cast_nullable_to_non_nullable
+as String,readyTime: null == readyTime ? _self.readyTime : readyTime // ignore: cast_nullable_to_non_nullable
as String,
));
}
@@ -154,10 +155,10 @@ return $default(_that);case _:
/// }
/// ```
-@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, AppError error, Map<int, ProductInCart> productsWithQuantity, DeliveryMethod deliveryMethod, String comment)? $default,{required TResult orElse(),}) {final _that = this;
+@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, AppError error, Map<int, ProductInCart> productsWithQuantity, bool isDelivery, String comment, String readyTime)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _CartState() when $default != null:
-return $default(_that.isLoading,_that.error,_that.productsWithQuantity,_that.deliveryMethod,_that.comment);case _:
+return $default(_that.isLoading,_that.error,_that.productsWithQuantity,_that.isDelivery,_that.comment,_that.readyTime);case _:
return orElse();
}
@@ -175,10 +176,10 @@ return $default(_that.isLoading,_that.error,_that.productsWithQuantity,_that.del
/// }
/// ```
-@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, AppError error, Map<int, ProductInCart> productsWithQuantity, DeliveryMethod deliveryMethod, String comment) $default,) {final _that = this;
+@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, AppError error, Map<int, ProductInCart> productsWithQuantity, bool isDelivery, String comment, String readyTime) $default,) {final _that = this;
switch (_that) {
case _CartState():
-return $default(_that.isLoading,_that.error,_that.productsWithQuantity,_that.deliveryMethod,_that.comment);case _:
+return $default(_that.isLoading,_that.error,_that.productsWithQuantity,_that.isDelivery,_that.comment,_that.readyTime);case _:
throw StateError('Unexpected subclass');
}
@@ -195,10 +196,10 @@ return $default(_that.isLoading,_that.error,_that.productsWithQuantity,_that.del
/// }
/// ```
-@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, AppError error, Map<int, ProductInCart> productsWithQuantity, DeliveryMethod deliveryMethod, String comment)? $default,) {final _that = this;
+@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, AppError error, Map<int, ProductInCart> productsWithQuantity, bool isDelivery, String comment, String readyTime)? $default,) {final _that = this;
switch (_that) {
case _CartState() when $default != null:
-return $default(_that.isLoading,_that.error,_that.productsWithQuantity,_that.deliveryMethod,_that.comment);case _:
+return $default(_that.isLoading,_that.error,_that.productsWithQuantity,_that.isDelivery,_that.comment,_that.readyTime);case _:
return null;
}
@@ -210,7 +211,7 @@ return $default(_that.isLoading,_that.error,_that.productsWithQuantity,_that.del
class _CartState extends CartState {
- const _CartState({this.isLoading = false, this.error = AppError.none, final Map<int, ProductInCart> productsWithQuantity = const {}, this.deliveryMethod = DeliveryMethod.pickUp, this.comment = ""}): _productsWithQuantity = productsWithQuantity,super._();
+ const _CartState({this.isLoading = false, this.error = AppError.none, final Map<int, ProductInCart> productsWithQuantity = const {}, this.isDelivery = false, this.comment = "", this.readyTime = ""}): _productsWithQuantity = productsWithQuantity,super._();
@override@JsonKey() final bool isLoading;
@@ -222,8 +223,9 @@ class _CartState extends CartState {
return EqualUnmodifiableMapView(_productsWithQuantity);
}
-@override@JsonKey() final DeliveryMethod deliveryMethod;
+@override@JsonKey() final bool isDelivery;
@override@JsonKey() final String comment;
+@override@JsonKey() final String readyTime;
/// Create a copy of CartState
/// with the given fields replaced by the non-null parameter values.
@@ -235,16 +237,16 @@ _$CartStateCopyWith<_CartState> get copyWith => __$CartStateCopyWithImpl<_CartSt
@override
bool operator ==(Object other) {
- return identical(this, other) || (other.runtimeType == runtimeType&&other is _CartState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.error, error) || other.error == error)&&const DeepCollectionEquality().equals(other._productsWithQuantity, _productsWithQuantity)&&(identical(other.deliveryMethod, deliveryMethod) || other.deliveryMethod == deliveryMethod)&&(identical(other.comment, comment) || other.comment == comment));
+ return identical(this, other) || (other.runtimeType == runtimeType&&other is _CartState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.error, error) || other.error == error)&&const DeepCollectionEquality().equals(other._productsWithQuantity, _productsWithQuantity)&&(identical(other.isDelivery, isDelivery) || other.isDelivery == isDelivery)&&(identical(other.comment, comment) || other.comment == comment)&&(identical(other.readyTime, readyTime) || other.readyTime == readyTime));
}
@override
-int get hashCode => Object.hash(runtimeType,isLoading,error,const DeepCollectionEquality().hash(_productsWithQuantity),deliveryMethod,comment);
+int get hashCode => Object.hash(runtimeType,isLoading,error,const DeepCollectionEquality().hash(_productsWithQuantity),isDelivery,comment,readyTime);
@override
String toString() {
- return 'CartState(isLoading: $isLoading, error: $error, productsWithQuantity: $productsWithQuantity, deliveryMethod: $deliveryMethod, comment: $comment)';
+ return 'CartState(isLoading: $isLoading, error: $error, productsWithQuantity: $productsWithQuantity, isDelivery: $isDelivery, comment: $comment, readyTime: $readyTime)';
}
@@ -255,7 +257,7 @@ abstract mixin class _$CartStateCopyWith<$Res> implements $CartStateCopyWith<$Re
factory _$CartStateCopyWith(_CartState value, $Res Function(_CartState) _then) = __$CartStateCopyWithImpl;
@override @useResult
$Res call({
- bool isLoading, AppError error, Map<int, ProductInCart> productsWithQuantity, DeliveryMethod deliveryMethod, String comment
+ bool isLoading, AppError error, Map<int, ProductInCart> productsWithQuantity, bool isDelivery, String comment, String readyTime
});
@@ -272,13 +274,14 @@ class __$CartStateCopyWithImpl<$Res>
/// Create a copy of CartState
/// with the given fields replaced by the non-null parameter values.
-@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? error = null,Object? productsWithQuantity = null,Object? deliveryMethod = null,Object? comment = null,}) {
+@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? error = null,Object? productsWithQuantity = null,Object? isDelivery = null,Object? comment = null,Object? readyTime = null,}) {
return _then(_CartState(
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,error: null == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
as AppError,productsWithQuantity: null == productsWithQuantity ? _self._productsWithQuantity : productsWithQuantity // ignore: cast_nullable_to_non_nullable
-as Map<int, ProductInCart>,deliveryMethod: null == deliveryMethod ? _self.deliveryMethod : deliveryMethod // ignore: cast_nullable_to_non_nullable
-as DeliveryMethod,comment: null == comment ? _self.comment : comment // ignore: cast_nullable_to_non_nullable
+as Map<int, ProductInCart>,isDelivery: null == isDelivery ? _self.isDelivery : isDelivery // ignore: cast_nullable_to_non_nullable
+as bool,comment: null == comment ? _self.comment : comment // ignore: cast_nullable_to_non_nullable
+as String,readyTime: null == readyTime ? _self.readyTime : readyTime // ignore: cast_nullable_to_non_nullable
as String,
));
}
diff --git a/concierge/lib/presentation/app/cart_cubit.dart b/concierge/lib/presentation/app/cart_cubit.dart
index 1df15bc0..99ae1e62 100644
--- a/concierge/lib/presentation/app/cart_cubit.dart
+++ b/concierge/lib/presentation/app/cart_cubit.dart
@@ -37,8 +37,12 @@ class CartCubit extends BaseCubit<CartState> {
safeEmit(state.copyWith(comment: comment));
}
- void updateDelivery(DeliveryMethod deliveryMethod) {
- safeEmit(state.copyWith(deliveryMethod: deliveryMethod));
+ void updateDelivery(bool isDelivery) {
+ safeEmit(state.copyWith(isDelivery: isDelivery));
+ }
+
+ void updateReadyTime(String time) {
+ safeEmit(state.copyWith(readyTime: time));
}
int get totalItems {
@@ -71,8 +75,9 @@ abstract class CartState with _$CartState {
@Default(false) bool isLoading,
@Default(AppError.none) AppError error,
@Default({}) Map<int, ProductInCart> productsWithQuantity,
- @Default(DeliveryMethod.pickUp) DeliveryMethod deliveryMethod,
+ @Default(false) bool isDelivery,
@Default("") String comment,
+ @Default("") String readyTime,
}) = _CartState;
const CartState._();
diff --git a/concierge/lib/presentation/screens/review_order/widget/delivery_method_picker.dart b/concierge/lib/presentation/screens/review_order/widget/delivery_method_picker.dart
index dbc28aae..cddb4394 100644
--- a/concierge/lib/presentation/screens/review_order/widget/delivery_method_picker.dart
+++ b/concierge/lib/presentation/screens/review_order/widget/delivery_method_picker.dart
@@ -1,4 +1,3 @@
-import 'package:concierge/domain/models/delivery_method.dart';
import 'package:concierge/presentation/app/cart_cubit.dart';
import 'package:concierge/presentation/theme/app_colors.dart';
import 'package:flutter/material.dart';
@@ -16,9 +15,9 @@ class DeliveryMethodPicker extends StatelessWidget {
Expanded(
child: buildButton(
context,
- isSelected: cartCubit.state.deliveryMethod is Delivery,
+ isSelected: cartCubit.state.isDelivery,
onClick: () {
- cartCubit.updateDelivery(DeliveryMethod.delivery("00:00"));
+ cartCubit.updateDelivery(true);
},
text: "Levering",
),
@@ -27,9 +26,9 @@ class DeliveryMethodPicker extends StatelessWidget {
Expanded(
child: buildButton(
context,
- isSelected: cartCubit.state.deliveryMethod is PickUp,
+ isSelected: !cartCubit.state.isDelivery,
onClick: () {
- cartCubit.updateDelivery(DeliveryMethod.pickUp);
+ cartCubit.updateDelivery(false);
},
text: "Afhentning",
),
diff --git a/concierge/lib/presentation/screens/review_order/widget/delivery_time_picker.dart b/concierge/lib/presentation/screens/review_order/widget/delivery_time_picker.dart
index 131ba478..237bc8b8 100644
--- a/concierge/lib/presentation/screens/review_order/widget/delivery_time_picker.dart
+++ b/concierge/lib/presentation/screens/review_order/widget/delivery_time_picker.dart
@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Iterable<String> _deliveryTimes() sync* {
- yield "Hurtigst muligt";
+ yield "";
for (var i = 16; i < 24; i++) {
yield* ["$i:00", "$i:30"];
}
@@ -24,17 +24,15 @@ class DeliveryTimePicker extends StatelessWidget {
itemCount: times.length,
itemBuilder: (context, index) {
final time = times[index];
- final isSelected = switch (cartCubit.state.deliveryMethod) {
- Delivery delivery => delivery.time == time,
- _ => false,
- };
return TextButton(
onPressed: () {
- cartCubit.updateDelivery(DeliveryMethod.delivery(time));
+ cartCubit.updateReadyTime(time);
},
child: Text(
- time,
- style: TextStyle(color: isSelected ? Colors.black : Colors.grey),
+ time.isEmpty ? "Hurtigst muligt" : time,
+ style: TextStyle(
+ color: cartCubit.state.readyTime == time ? Colors.black : Colors.grey,
+ ),
),
);
},
diff --git a/concierge/lib/presentation/screens/review_order/widget/review_order_app_bar.dart b/concierge/lib/presentation/screens/review_order/widget/review_order_app_bar.dart
index dafc4678..007482f2 100644
--- a/concierge/lib/presentation/screens/review_order/widget/review_order_app_bar.dart
+++ b/concierge/lib/presentation/screens/review_order/widget/review_order_app_bar.dart
@@ -1,4 +1,5 @@
import 'package:concierge/presentation/app/cart_cubit.dart';
+import 'package:concierge/presentation/screens/confirm_order/confirm_order_route.dart';
import 'package:concierge/presentation/screens/provide_location/provide_location_route.dart';
import 'package:concierge/presentation/theme/app_colors.dart';
import 'package:flutter/material.dart';
@@ -22,9 +23,7 @@ class ReviewOrderAppBar extends StatelessWidget {
WidgetState.any: AppColors.sandColor,
}),
),
- onPressed: cartCubit.products.isEmpty
- ? null
- : () => ProvideLocationRoute().push(context),
+ onPressed: cartCubit.products.isEmpty ? null : () => ConfirmOrderRoute().push(context),
child: Row(
children: [
Text(