diff --git a/assets/images/gojek.png b/assets/images/gojek.png new file mode 100644 index 0000000..75548ee Binary files /dev/null and b/assets/images/gojek.png differ diff --git a/assets/images/grab.png b/assets/images/grab.png new file mode 100644 index 0000000..09ffcbd Binary files /dev/null and b/assets/images/grab.png differ diff --git a/lib/application/checkout/checkout_form/checkout_form_bloc.dart b/lib/application/checkout/checkout_form/checkout_form_bloc.dart new file mode 100644 index 0000000..bf9f0f4 --- /dev/null +++ b/lib/application/checkout/checkout_form/checkout_form_bloc.dart @@ -0,0 +1,168 @@ +import 'dart:developer'; + +import 'package:bloc/bloc.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../common/types/order_type.dart'; +import '../../../domain/delivery/delivery.dart'; +import '../../../domain/product/product.dart'; + +part 'checkout_form_event.dart'; +part 'checkout_form_state.dart'; +part 'checkout_form_bloc.freezed.dart'; + +@injectable +class CheckoutFormBloc extends Bloc { + CheckoutFormBloc() : super(CheckoutFormState.initial()) { + on(_onCheckoutFormEvent); + } + Future _onCheckoutFormEvent( + CheckoutFormEvent event, + Emitter emit, + ) { + return event.map( + addItem: (e) async { + final currentState = state; + emit(currentState.copyWith(isLoading: true)); + + List items = [...currentState.items]; + + final index = items.indexWhere( + (element) => + element.product.id == e.product.id && + element.variant?.id == e.variant?.id, + ); + + if (index != -1) { + // Jika sudah ada → tambah quantity + items[index] = items[index].copyWith( + quantity: items[index].quantity + 1, + ); + } else { + // Jika belum ada → tambahkan item baru + items.add( + ProductQuantity( + product: e.product, + quantity: 1, + variant: e.variant, + ), + ); + } + + log('🛒 Items updated: ${items.length} items total'); + + final totalQuantity = items.fold( + 0, + (sum, item) => sum + item.quantity, + ); + final totalPrice = items.fold( + 0, + (sum, item) => + sum + + (item.quantity * + (item.variant?.priceModifier.toInt() ?? + item.product.price.toInt())), + ); + + emit( + currentState.copyWith( + items: items, + totalQuantity: totalQuantity, + totalPrice: totalPrice, + isLoading: false, + ), + ); + }, + removeItem: (e) async { + final currentState = state; + emit(currentState.copyWith(isLoading: true)); + List items = [...currentState.items]; + + final index = items.indexWhere( + (element) => + element.product.id == e.product.id && + element.variant?.id == e.variant?.id, + ); + + if (index != -1) { + final currentItem = items[index]; + if (currentItem.quantity > 1) { + // Kurangi quantity + items[index] = currentItem.copyWith( + quantity: currentItem.quantity - 1, + ); + } else { + // Hapus item kalau quantity = 1 + items.removeAt(index); + } + } + + final totalQuantity = items.fold( + 0, + (sum, item) => sum + item.quantity, + ); + final totalPrice = items.fold( + 0, + (sum, item) => + sum + + (item.quantity * + (item.variant?.priceModifier.toInt() ?? + item.product.price.toInt())), + ); + + log( + '🗑️ Item removed. Total items: ${items.length}, totalQuantity: $totalQuantity, totalPrice: $totalPrice', + ); + + // Emit state baru + emit( + currentState.copyWith( + items: items, + totalQuantity: totalQuantity, + totalPrice: totalPrice, + isLoading: false, + ), + ); + }, + started: (e) async { + emit(CheckoutFormState.initial().copyWith(isLoading: true)); + try { + emit( + CheckoutFormState.initial().copyWith( + items: e.items, + tax: 0, + serviceCharge: 0, + isLoading: false, + ), + ); + } catch (e) { + // Kalau gagal, pakai default values + log('⚠️ Failed to load settings: $e'); + emit( + CheckoutFormState.initial().copyWith( + tax: 10, + serviceCharge: 5, + isLoading: false, + ), + ); + } + }, + updateItemNotes: (e) async { + final currentState = state; + + // Clone list items agar tidak mutasi langsung + final items = [...currentState.items]; + final index = items.indexWhere( + (element) => element.product.id == e.product.id, + ); + + if (index != -1) { + items[index] = items[index].copyWith(notes: e.notes); + } + + emit(currentState.copyWith(items: items, isLoading: false)); + }, + ); + } +} diff --git a/lib/application/checkout/checkout_form/checkout_form_bloc.freezed.dart b/lib/application/checkout/checkout_form/checkout_form_bloc.freezed.dart new file mode 100644 index 0000000..910d0eb --- /dev/null +++ b/lib/application/checkout/checkout_form/checkout_form_bloc.freezed.dart @@ -0,0 +1,1187 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'checkout_form_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', +); + +/// @nodoc +mixin _$CheckoutFormEvent { + @optionalTypeArgs + TResult when({ + required TResult Function(List items) started, + required TResult Function(Product product, ProductVariant? variant) addItem, + required TResult Function(Product product, ProductVariant? variant) + removeItem, + required TResult Function(Product product, String notes) updateItemNotes, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(List items)? started, + TResult? Function(Product product, ProductVariant? variant)? addItem, + TResult? Function(Product product, ProductVariant? variant)? removeItem, + TResult? Function(Product product, String notes)? updateItemNotes, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(List items)? started, + TResult Function(Product product, ProductVariant? variant)? addItem, + TResult Function(Product product, ProductVariant? variant)? removeItem, + TResult Function(Product product, String notes)? updateItemNotes, + required TResult orElse(), + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(_Started value) started, + required TResult Function(_AddItem value) addItem, + required TResult Function(_RemoveItem value) removeItem, + required TResult Function(_UpdateItemNotes value) updateItemNotes, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_Started value)? started, + TResult? Function(_AddItem value)? addItem, + TResult? Function(_RemoveItem value)? removeItem, + TResult? Function(_UpdateItemNotes value)? updateItemNotes, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_Started value)? started, + TResult Function(_AddItem value)? addItem, + TResult Function(_RemoveItem value)? removeItem, + TResult Function(_UpdateItemNotes value)? updateItemNotes, + required TResult orElse(), + }) => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CheckoutFormEventCopyWith<$Res> { + factory $CheckoutFormEventCopyWith( + CheckoutFormEvent value, + $Res Function(CheckoutFormEvent) then, + ) = _$CheckoutFormEventCopyWithImpl<$Res, CheckoutFormEvent>; +} + +/// @nodoc +class _$CheckoutFormEventCopyWithImpl<$Res, $Val extends CheckoutFormEvent> + implements $CheckoutFormEventCopyWith<$Res> { + _$CheckoutFormEventCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$StartedImplCopyWith<$Res> { + factory _$$StartedImplCopyWith( + _$StartedImpl value, + $Res Function(_$StartedImpl) then, + ) = __$$StartedImplCopyWithImpl<$Res>; + @useResult + $Res call({List items}); +} + +/// @nodoc +class __$$StartedImplCopyWithImpl<$Res> + extends _$CheckoutFormEventCopyWithImpl<$Res, _$StartedImpl> + implements _$$StartedImplCopyWith<$Res> { + __$$StartedImplCopyWithImpl( + _$StartedImpl _value, + $Res Function(_$StartedImpl) _then, + ) : super(_value, _then); + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? items = null}) { + return _then( + _$StartedImpl( + null == items + ? _value._items + : items // ignore: cast_nullable_to_non_nullable + as List, + ), + ); + } +} + +/// @nodoc + +class _$StartedImpl implements _Started { + const _$StartedImpl(final List items) : _items = items; + + final List _items; + @override + List get items { + if (_items is EqualUnmodifiableListView) return _items; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_items); + } + + @override + String toString() { + return 'CheckoutFormEvent.started(items: $items)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$StartedImpl && + const DeepCollectionEquality().equals(other._items, _items)); + } + + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(_items)); + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$StartedImplCopyWith<_$StartedImpl> get copyWith => + __$$StartedImplCopyWithImpl<_$StartedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(List items) started, + required TResult Function(Product product, ProductVariant? variant) addItem, + required TResult Function(Product product, ProductVariant? variant) + removeItem, + required TResult Function(Product product, String notes) updateItemNotes, + }) { + return started(items); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(List items)? started, + TResult? Function(Product product, ProductVariant? variant)? addItem, + TResult? Function(Product product, ProductVariant? variant)? removeItem, + TResult? Function(Product product, String notes)? updateItemNotes, + }) { + return started?.call(items); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(List items)? started, + TResult Function(Product product, ProductVariant? variant)? addItem, + TResult Function(Product product, ProductVariant? variant)? removeItem, + TResult Function(Product product, String notes)? updateItemNotes, + required TResult orElse(), + }) { + if (started != null) { + return started(items); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_Started value) started, + required TResult Function(_AddItem value) addItem, + required TResult Function(_RemoveItem value) removeItem, + required TResult Function(_UpdateItemNotes value) updateItemNotes, + }) { + return started(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_Started value)? started, + TResult? Function(_AddItem value)? addItem, + TResult? Function(_RemoveItem value)? removeItem, + TResult? Function(_UpdateItemNotes value)? updateItemNotes, + }) { + return started?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_Started value)? started, + TResult Function(_AddItem value)? addItem, + TResult Function(_RemoveItem value)? removeItem, + TResult Function(_UpdateItemNotes value)? updateItemNotes, + required TResult orElse(), + }) { + if (started != null) { + return started(this); + } + return orElse(); + } +} + +abstract class _Started implements CheckoutFormEvent { + const factory _Started(final List items) = _$StartedImpl; + + List get items; + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$StartedImplCopyWith<_$StartedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$AddItemImplCopyWith<$Res> { + factory _$$AddItemImplCopyWith( + _$AddItemImpl value, + $Res Function(_$AddItemImpl) then, + ) = __$$AddItemImplCopyWithImpl<$Res>; + @useResult + $Res call({Product product, ProductVariant? variant}); + + $ProductCopyWith<$Res> get product; + $ProductVariantCopyWith<$Res>? get variant; +} + +/// @nodoc +class __$$AddItemImplCopyWithImpl<$Res> + extends _$CheckoutFormEventCopyWithImpl<$Res, _$AddItemImpl> + implements _$$AddItemImplCopyWith<$Res> { + __$$AddItemImplCopyWithImpl( + _$AddItemImpl _value, + $Res Function(_$AddItemImpl) _then, + ) : super(_value, _then); + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? product = null, Object? variant = freezed}) { + return _then( + _$AddItemImpl( + null == product + ? _value.product + : product // ignore: cast_nullable_to_non_nullable + as Product, + freezed == variant + ? _value.variant + : variant // ignore: cast_nullable_to_non_nullable + as ProductVariant?, + ), + ); + } + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ProductCopyWith<$Res> get product { + return $ProductCopyWith<$Res>(_value.product, (value) { + return _then(_value.copyWith(product: value)); + }); + } + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ProductVariantCopyWith<$Res>? get variant { + if (_value.variant == null) { + return null; + } + + return $ProductVariantCopyWith<$Res>(_value.variant!, (value) { + return _then(_value.copyWith(variant: value)); + }); + } +} + +/// @nodoc + +class _$AddItemImpl implements _AddItem { + const _$AddItemImpl(this.product, this.variant); + + @override + final Product product; + @override + final ProductVariant? variant; + + @override + String toString() { + return 'CheckoutFormEvent.addItem(product: $product, variant: $variant)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AddItemImpl && + (identical(other.product, product) || other.product == product) && + (identical(other.variant, variant) || other.variant == variant)); + } + + @override + int get hashCode => Object.hash(runtimeType, product, variant); + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$AddItemImplCopyWith<_$AddItemImpl> get copyWith => + __$$AddItemImplCopyWithImpl<_$AddItemImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(List items) started, + required TResult Function(Product product, ProductVariant? variant) addItem, + required TResult Function(Product product, ProductVariant? variant) + removeItem, + required TResult Function(Product product, String notes) updateItemNotes, + }) { + return addItem(product, variant); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(List items)? started, + TResult? Function(Product product, ProductVariant? variant)? addItem, + TResult? Function(Product product, ProductVariant? variant)? removeItem, + TResult? Function(Product product, String notes)? updateItemNotes, + }) { + return addItem?.call(product, variant); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(List items)? started, + TResult Function(Product product, ProductVariant? variant)? addItem, + TResult Function(Product product, ProductVariant? variant)? removeItem, + TResult Function(Product product, String notes)? updateItemNotes, + required TResult orElse(), + }) { + if (addItem != null) { + return addItem(product, variant); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_Started value) started, + required TResult Function(_AddItem value) addItem, + required TResult Function(_RemoveItem value) removeItem, + required TResult Function(_UpdateItemNotes value) updateItemNotes, + }) { + return addItem(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_Started value)? started, + TResult? Function(_AddItem value)? addItem, + TResult? Function(_RemoveItem value)? removeItem, + TResult? Function(_UpdateItemNotes value)? updateItemNotes, + }) { + return addItem?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_Started value)? started, + TResult Function(_AddItem value)? addItem, + TResult Function(_RemoveItem value)? removeItem, + TResult Function(_UpdateItemNotes value)? updateItemNotes, + required TResult orElse(), + }) { + if (addItem != null) { + return addItem(this); + } + return orElse(); + } +} + +abstract class _AddItem implements CheckoutFormEvent { + const factory _AddItem(final Product product, final ProductVariant? variant) = + _$AddItemImpl; + + Product get product; + ProductVariant? get variant; + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$AddItemImplCopyWith<_$AddItemImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$RemoveItemImplCopyWith<$Res> { + factory _$$RemoveItemImplCopyWith( + _$RemoveItemImpl value, + $Res Function(_$RemoveItemImpl) then, + ) = __$$RemoveItemImplCopyWithImpl<$Res>; + @useResult + $Res call({Product product, ProductVariant? variant}); + + $ProductCopyWith<$Res> get product; + $ProductVariantCopyWith<$Res>? get variant; +} + +/// @nodoc +class __$$RemoveItemImplCopyWithImpl<$Res> + extends _$CheckoutFormEventCopyWithImpl<$Res, _$RemoveItemImpl> + implements _$$RemoveItemImplCopyWith<$Res> { + __$$RemoveItemImplCopyWithImpl( + _$RemoveItemImpl _value, + $Res Function(_$RemoveItemImpl) _then, + ) : super(_value, _then); + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? product = null, Object? variant = freezed}) { + return _then( + _$RemoveItemImpl( + null == product + ? _value.product + : product // ignore: cast_nullable_to_non_nullable + as Product, + freezed == variant + ? _value.variant + : variant // ignore: cast_nullable_to_non_nullable + as ProductVariant?, + ), + ); + } + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ProductCopyWith<$Res> get product { + return $ProductCopyWith<$Res>(_value.product, (value) { + return _then(_value.copyWith(product: value)); + }); + } + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ProductVariantCopyWith<$Res>? get variant { + if (_value.variant == null) { + return null; + } + + return $ProductVariantCopyWith<$Res>(_value.variant!, (value) { + return _then(_value.copyWith(variant: value)); + }); + } +} + +/// @nodoc + +class _$RemoveItemImpl implements _RemoveItem { + const _$RemoveItemImpl(this.product, this.variant); + + @override + final Product product; + @override + final ProductVariant? variant; + + @override + String toString() { + return 'CheckoutFormEvent.removeItem(product: $product, variant: $variant)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RemoveItemImpl && + (identical(other.product, product) || other.product == product) && + (identical(other.variant, variant) || other.variant == variant)); + } + + @override + int get hashCode => Object.hash(runtimeType, product, variant); + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$RemoveItemImplCopyWith<_$RemoveItemImpl> get copyWith => + __$$RemoveItemImplCopyWithImpl<_$RemoveItemImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(List items) started, + required TResult Function(Product product, ProductVariant? variant) addItem, + required TResult Function(Product product, ProductVariant? variant) + removeItem, + required TResult Function(Product product, String notes) updateItemNotes, + }) { + return removeItem(product, variant); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(List items)? started, + TResult? Function(Product product, ProductVariant? variant)? addItem, + TResult? Function(Product product, ProductVariant? variant)? removeItem, + TResult? Function(Product product, String notes)? updateItemNotes, + }) { + return removeItem?.call(product, variant); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(List items)? started, + TResult Function(Product product, ProductVariant? variant)? addItem, + TResult Function(Product product, ProductVariant? variant)? removeItem, + TResult Function(Product product, String notes)? updateItemNotes, + required TResult orElse(), + }) { + if (removeItem != null) { + return removeItem(product, variant); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_Started value) started, + required TResult Function(_AddItem value) addItem, + required TResult Function(_RemoveItem value) removeItem, + required TResult Function(_UpdateItemNotes value) updateItemNotes, + }) { + return removeItem(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_Started value)? started, + TResult? Function(_AddItem value)? addItem, + TResult? Function(_RemoveItem value)? removeItem, + TResult? Function(_UpdateItemNotes value)? updateItemNotes, + }) { + return removeItem?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_Started value)? started, + TResult Function(_AddItem value)? addItem, + TResult Function(_RemoveItem value)? removeItem, + TResult Function(_UpdateItemNotes value)? updateItemNotes, + required TResult orElse(), + }) { + if (removeItem != null) { + return removeItem(this); + } + return orElse(); + } +} + +abstract class _RemoveItem implements CheckoutFormEvent { + const factory _RemoveItem( + final Product product, + final ProductVariant? variant, + ) = _$RemoveItemImpl; + + Product get product; + ProductVariant? get variant; + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$RemoveItemImplCopyWith<_$RemoveItemImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$UpdateItemNotesImplCopyWith<$Res> { + factory _$$UpdateItemNotesImplCopyWith( + _$UpdateItemNotesImpl value, + $Res Function(_$UpdateItemNotesImpl) then, + ) = __$$UpdateItemNotesImplCopyWithImpl<$Res>; + @useResult + $Res call({Product product, String notes}); + + $ProductCopyWith<$Res> get product; +} + +/// @nodoc +class __$$UpdateItemNotesImplCopyWithImpl<$Res> + extends _$CheckoutFormEventCopyWithImpl<$Res, _$UpdateItemNotesImpl> + implements _$$UpdateItemNotesImplCopyWith<$Res> { + __$$UpdateItemNotesImplCopyWithImpl( + _$UpdateItemNotesImpl _value, + $Res Function(_$UpdateItemNotesImpl) _then, + ) : super(_value, _then); + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? product = null, Object? notes = null}) { + return _then( + _$UpdateItemNotesImpl( + null == product + ? _value.product + : product // ignore: cast_nullable_to_non_nullable + as Product, + null == notes + ? _value.notes + : notes // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ProductCopyWith<$Res> get product { + return $ProductCopyWith<$Res>(_value.product, (value) { + return _then(_value.copyWith(product: value)); + }); + } +} + +/// @nodoc + +class _$UpdateItemNotesImpl implements _UpdateItemNotes { + const _$UpdateItemNotesImpl(this.product, this.notes); + + @override + final Product product; + @override + final String notes; + + @override + String toString() { + return 'CheckoutFormEvent.updateItemNotes(product: $product, notes: $notes)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$UpdateItemNotesImpl && + (identical(other.product, product) || other.product == product) && + (identical(other.notes, notes) || other.notes == notes)); + } + + @override + int get hashCode => Object.hash(runtimeType, product, notes); + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$UpdateItemNotesImplCopyWith<_$UpdateItemNotesImpl> get copyWith => + __$$UpdateItemNotesImplCopyWithImpl<_$UpdateItemNotesImpl>( + this, + _$identity, + ); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(List items) started, + required TResult Function(Product product, ProductVariant? variant) addItem, + required TResult Function(Product product, ProductVariant? variant) + removeItem, + required TResult Function(Product product, String notes) updateItemNotes, + }) { + return updateItemNotes(product, notes); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(List items)? started, + TResult? Function(Product product, ProductVariant? variant)? addItem, + TResult? Function(Product product, ProductVariant? variant)? removeItem, + TResult? Function(Product product, String notes)? updateItemNotes, + }) { + return updateItemNotes?.call(product, notes); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(List items)? started, + TResult Function(Product product, ProductVariant? variant)? addItem, + TResult Function(Product product, ProductVariant? variant)? removeItem, + TResult Function(Product product, String notes)? updateItemNotes, + required TResult orElse(), + }) { + if (updateItemNotes != null) { + return updateItemNotes(product, notes); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_Started value) started, + required TResult Function(_AddItem value) addItem, + required TResult Function(_RemoveItem value) removeItem, + required TResult Function(_UpdateItemNotes value) updateItemNotes, + }) { + return updateItemNotes(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_Started value)? started, + TResult? Function(_AddItem value)? addItem, + TResult? Function(_RemoveItem value)? removeItem, + TResult? Function(_UpdateItemNotes value)? updateItemNotes, + }) { + return updateItemNotes?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_Started value)? started, + TResult Function(_AddItem value)? addItem, + TResult Function(_RemoveItem value)? removeItem, + TResult Function(_UpdateItemNotes value)? updateItemNotes, + required TResult orElse(), + }) { + if (updateItemNotes != null) { + return updateItemNotes(this); + } + return orElse(); + } +} + +abstract class _UpdateItemNotes implements CheckoutFormEvent { + const factory _UpdateItemNotes(final Product product, final String notes) = + _$UpdateItemNotesImpl; + + Product get product; + String get notes; + + /// Create a copy of CheckoutFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$UpdateItemNotesImplCopyWith<_$UpdateItemNotesImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$CheckoutFormState { + List get items => throw _privateConstructorUsedError; + int get discount => throw _privateConstructorUsedError; + int get discountAmount => throw _privateConstructorUsedError; + int get tax => throw _privateConstructorUsedError; + int get serviceCharge => throw _privateConstructorUsedError; + int get totalQuantity => throw _privateConstructorUsedError; + int get totalPrice => throw _privateConstructorUsedError; + String get draftName => throw _privateConstructorUsedError; + OrderType get orderType => throw _privateConstructorUsedError; + Delivery? get delivery => throw _privateConstructorUsedError; + bool get isLoading => throw _privateConstructorUsedError; + + /// Create a copy of CheckoutFormState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $CheckoutFormStateCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CheckoutFormStateCopyWith<$Res> { + factory $CheckoutFormStateCopyWith( + CheckoutFormState value, + $Res Function(CheckoutFormState) then, + ) = _$CheckoutFormStateCopyWithImpl<$Res, CheckoutFormState>; + @useResult + $Res call({ + List items, + int discount, + int discountAmount, + int tax, + int serviceCharge, + int totalQuantity, + int totalPrice, + String draftName, + OrderType orderType, + Delivery? delivery, + bool isLoading, + }); +} + +/// @nodoc +class _$CheckoutFormStateCopyWithImpl<$Res, $Val extends CheckoutFormState> + implements $CheckoutFormStateCopyWith<$Res> { + _$CheckoutFormStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of CheckoutFormState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? items = null, + Object? discount = null, + Object? discountAmount = null, + Object? tax = null, + Object? serviceCharge = null, + Object? totalQuantity = null, + Object? totalPrice = null, + Object? draftName = null, + Object? orderType = null, + Object? delivery = freezed, + Object? isLoading = null, + }) { + return _then( + _value.copyWith( + items: null == items + ? _value.items + : items // ignore: cast_nullable_to_non_nullable + as List, + discount: null == discount + ? _value.discount + : discount // ignore: cast_nullable_to_non_nullable + as int, + discountAmount: null == discountAmount + ? _value.discountAmount + : discountAmount // ignore: cast_nullable_to_non_nullable + as int, + tax: null == tax + ? _value.tax + : tax // ignore: cast_nullable_to_non_nullable + as int, + serviceCharge: null == serviceCharge + ? _value.serviceCharge + : serviceCharge // ignore: cast_nullable_to_non_nullable + as int, + totalQuantity: null == totalQuantity + ? _value.totalQuantity + : totalQuantity // ignore: cast_nullable_to_non_nullable + as int, + totalPrice: null == totalPrice + ? _value.totalPrice + : totalPrice // ignore: cast_nullable_to_non_nullable + as int, + draftName: null == draftName + ? _value.draftName + : draftName // ignore: cast_nullable_to_non_nullable + as String, + orderType: null == orderType + ? _value.orderType + : orderType // ignore: cast_nullable_to_non_nullable + as OrderType, + delivery: freezed == delivery + ? _value.delivery + : delivery // ignore: cast_nullable_to_non_nullable + as Delivery?, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, + ) + as $Val, + ); + } +} + +/// @nodoc +abstract class _$$CheckoutFormStateImplCopyWith<$Res> + implements $CheckoutFormStateCopyWith<$Res> { + factory _$$CheckoutFormStateImplCopyWith( + _$CheckoutFormStateImpl value, + $Res Function(_$CheckoutFormStateImpl) then, + ) = __$$CheckoutFormStateImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + List items, + int discount, + int discountAmount, + int tax, + int serviceCharge, + int totalQuantity, + int totalPrice, + String draftName, + OrderType orderType, + Delivery? delivery, + bool isLoading, + }); +} + +/// @nodoc +class __$$CheckoutFormStateImplCopyWithImpl<$Res> + extends _$CheckoutFormStateCopyWithImpl<$Res, _$CheckoutFormStateImpl> + implements _$$CheckoutFormStateImplCopyWith<$Res> { + __$$CheckoutFormStateImplCopyWithImpl( + _$CheckoutFormStateImpl _value, + $Res Function(_$CheckoutFormStateImpl) _then, + ) : super(_value, _then); + + /// Create a copy of CheckoutFormState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? items = null, + Object? discount = null, + Object? discountAmount = null, + Object? tax = null, + Object? serviceCharge = null, + Object? totalQuantity = null, + Object? totalPrice = null, + Object? draftName = null, + Object? orderType = null, + Object? delivery = freezed, + Object? isLoading = null, + }) { + return _then( + _$CheckoutFormStateImpl( + items: null == items + ? _value._items + : items // ignore: cast_nullable_to_non_nullable + as List, + discount: null == discount + ? _value.discount + : discount // ignore: cast_nullable_to_non_nullable + as int, + discountAmount: null == discountAmount + ? _value.discountAmount + : discountAmount // ignore: cast_nullable_to_non_nullable + as int, + tax: null == tax + ? _value.tax + : tax // ignore: cast_nullable_to_non_nullable + as int, + serviceCharge: null == serviceCharge + ? _value.serviceCharge + : serviceCharge // ignore: cast_nullable_to_non_nullable + as int, + totalQuantity: null == totalQuantity + ? _value.totalQuantity + : totalQuantity // ignore: cast_nullable_to_non_nullable + as int, + totalPrice: null == totalPrice + ? _value.totalPrice + : totalPrice // ignore: cast_nullable_to_non_nullable + as int, + draftName: null == draftName + ? _value.draftName + : draftName // ignore: cast_nullable_to_non_nullable + as String, + orderType: null == orderType + ? _value.orderType + : orderType // ignore: cast_nullable_to_non_nullable + as OrderType, + delivery: freezed == delivery + ? _value.delivery + : delivery // ignore: cast_nullable_to_non_nullable + as Delivery?, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, + ), + ); + } +} + +/// @nodoc + +class _$CheckoutFormStateImpl implements _CheckoutFormState { + _$CheckoutFormStateImpl({ + required final List items, + required this.discount, + required this.discountAmount, + required this.tax, + required this.serviceCharge, + required this.totalQuantity, + required this.totalPrice, + required this.draftName, + required this.orderType, + this.delivery, + this.isLoading = false, + }) : _items = items; + + final List _items; + @override + List get items { + if (_items is EqualUnmodifiableListView) return _items; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_items); + } + + @override + final int discount; + @override + final int discountAmount; + @override + final int tax; + @override + final int serviceCharge; + @override + final int totalQuantity; + @override + final int totalPrice; + @override + final String draftName; + @override + final OrderType orderType; + @override + final Delivery? delivery; + @override + @JsonKey() + final bool isLoading; + + @override + String toString() { + return 'CheckoutFormState(items: $items, discount: $discount, discountAmount: $discountAmount, tax: $tax, serviceCharge: $serviceCharge, totalQuantity: $totalQuantity, totalPrice: $totalPrice, draftName: $draftName, orderType: $orderType, delivery: $delivery, isLoading: $isLoading)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CheckoutFormStateImpl && + const DeepCollectionEquality().equals(other._items, _items) && + (identical(other.discount, discount) || + other.discount == discount) && + (identical(other.discountAmount, discountAmount) || + other.discountAmount == discountAmount) && + (identical(other.tax, tax) || other.tax == tax) && + (identical(other.serviceCharge, serviceCharge) || + other.serviceCharge == serviceCharge) && + (identical(other.totalQuantity, totalQuantity) || + other.totalQuantity == totalQuantity) && + (identical(other.totalPrice, totalPrice) || + other.totalPrice == totalPrice) && + (identical(other.draftName, draftName) || + other.draftName == draftName) && + (identical(other.orderType, orderType) || + other.orderType == orderType) && + (identical(other.delivery, delivery) || + other.delivery == delivery) && + (identical(other.isLoading, isLoading) || + other.isLoading == isLoading)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_items), + discount, + discountAmount, + tax, + serviceCharge, + totalQuantity, + totalPrice, + draftName, + orderType, + delivery, + isLoading, + ); + + /// Create a copy of CheckoutFormState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$CheckoutFormStateImplCopyWith<_$CheckoutFormStateImpl> get copyWith => + __$$CheckoutFormStateImplCopyWithImpl<_$CheckoutFormStateImpl>( + this, + _$identity, + ); +} + +abstract class _CheckoutFormState implements CheckoutFormState { + factory _CheckoutFormState({ + required final List items, + required final int discount, + required final int discountAmount, + required final int tax, + required final int serviceCharge, + required final int totalQuantity, + required final int totalPrice, + required final String draftName, + required final OrderType orderType, + final Delivery? delivery, + final bool isLoading, + }) = _$CheckoutFormStateImpl; + + @override + List get items; + @override + int get discount; + @override + int get discountAmount; + @override + int get tax; + @override + int get serviceCharge; + @override + int get totalQuantity; + @override + int get totalPrice; + @override + String get draftName; + @override + OrderType get orderType; + @override + Delivery? get delivery; + @override + bool get isLoading; + + /// Create a copy of CheckoutFormState + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CheckoutFormStateImplCopyWith<_$CheckoutFormStateImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/application/checkout/checkout_form/checkout_form_event.dart b/lib/application/checkout/checkout_form/checkout_form_event.dart new file mode 100644 index 0000000..b3c10df --- /dev/null +++ b/lib/application/checkout/checkout_form/checkout_form_event.dart @@ -0,0 +1,22 @@ +part of 'checkout_form_bloc.dart'; + +@freezed +class CheckoutFormEvent with _$CheckoutFormEvent { + const factory CheckoutFormEvent.started(List items) = + _Started; + + const factory CheckoutFormEvent.addItem( + Product product, + ProductVariant? variant, + ) = _AddItem; + + const factory CheckoutFormEvent.removeItem( + Product product, + ProductVariant? variant, + ) = _RemoveItem; + + const factory CheckoutFormEvent.updateItemNotes( + Product product, + String notes, + ) = _UpdateItemNotes; +} diff --git a/lib/application/checkout/checkout_form/checkout_form_state.dart b/lib/application/checkout/checkout_form/checkout_form_state.dart new file mode 100644 index 0000000..c750b54 --- /dev/null +++ b/lib/application/checkout/checkout_form/checkout_form_state.dart @@ -0,0 +1,30 @@ +part of 'checkout_form_bloc.dart'; + +@freezed +class CheckoutFormState with _$CheckoutFormState { + factory CheckoutFormState({ + required List items, + required int discount, + required int discountAmount, + required int tax, + required int serviceCharge, + required int totalQuantity, + required int totalPrice, + required String draftName, + required OrderType orderType, + Delivery? delivery, + @Default(false) bool isLoading, + }) = _CheckoutFormState; + + factory CheckoutFormState.initial() => CheckoutFormState( + items: [], + discount: 0, + discountAmount: 0, + tax: 0, + serviceCharge: 0, + totalQuantity: 0, + totalPrice: 0, + draftName: '', + orderType: OrderType.dineIn, + ); +} diff --git a/lib/common/types/order_type.dart b/lib/common/types/order_type.dart new file mode 100644 index 0000000..4de6b5b --- /dev/null +++ b/lib/common/types/order_type.dart @@ -0,0 +1,16 @@ +enum OrderType { + dineIn('DINE IN'), + takeAway('TAKE AWAY'), + delivery('DELIVERY'), + freeTable('FREE TABLE'); + + final String value; + const OrderType(this.value); + + static OrderType fromString(String value) { + return OrderType.values.firstWhere( + (type) => type.value == value, + orElse: () => OrderType.dineIn, + ); + } +} diff --git a/lib/domain/delivery/delivery.dart b/lib/domain/delivery/delivery.dart new file mode 100644 index 0000000..225a390 --- /dev/null +++ b/lib/domain/delivery/delivery.dart @@ -0,0 +1,14 @@ +import '../../presentation/components/assets/assets.gen.dart'; + +class Delivery { + String id; + String name; + String imageUrl; + + Delivery({required this.id, required this.name, required this.imageUrl}); +} + +List deliveries = [ + Delivery(id: 'gojek', name: 'Gojek', imageUrl: Assets.images.gojek.path), + Delivery(id: 'grab', name: 'Grab', imageUrl: Assets.images.grab.path), +]; diff --git a/lib/domain/product/entities/product_quantity_entity.dart b/lib/domain/product/entities/product_quantity_entity.dart new file mode 100644 index 0000000..e7b4548 --- /dev/null +++ b/lib/domain/product/entities/product_quantity_entity.dart @@ -0,0 +1,14 @@ +part of '../product.dart'; + +@freezed +class ProductQuantity with _$ProductQuantity { + const factory ProductQuantity({ + required Product product, + ProductVariant? variant, + required int quantity, + String? notes, + }) = _ProductQuantity; + + factory ProductQuantity.empty() => + ProductQuantity(product: Product.empty(), quantity: 0); +} diff --git a/lib/domain/product/product.dart b/lib/domain/product/product.dart index 54dfec3..fd4ebac 100644 --- a/lib/domain/product/product.dart +++ b/lib/domain/product/product.dart @@ -7,5 +7,6 @@ import '../../common/api/api_failure.dart'; part 'product.freezed.dart'; part 'entities/product_entity.dart'; +part 'entities/product_quantity_entity.dart'; part 'failures/product_failure.dart'; part 'repositories/i_product_repository.dart'; diff --git a/lib/domain/product/product.freezed.dart b/lib/domain/product/product.freezed.dart index 850a898..7f760e7 100644 --- a/lib/domain/product/product.freezed.dart +++ b/lib/domain/product/product.freezed.dart @@ -1092,6 +1092,260 @@ abstract class _ProductVariant implements ProductVariant { throw _privateConstructorUsedError; } +/// @nodoc +mixin _$ProductQuantity { + Product get product => throw _privateConstructorUsedError; + ProductVariant? get variant => throw _privateConstructorUsedError; + int get quantity => throw _privateConstructorUsedError; + String? get notes => throw _privateConstructorUsedError; + + /// Create a copy of ProductQuantity + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ProductQuantityCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ProductQuantityCopyWith<$Res> { + factory $ProductQuantityCopyWith( + ProductQuantity value, + $Res Function(ProductQuantity) then, + ) = _$ProductQuantityCopyWithImpl<$Res, ProductQuantity>; + @useResult + $Res call({ + Product product, + ProductVariant? variant, + int quantity, + String? notes, + }); + + $ProductCopyWith<$Res> get product; + $ProductVariantCopyWith<$Res>? get variant; +} + +/// @nodoc +class _$ProductQuantityCopyWithImpl<$Res, $Val extends ProductQuantity> + implements $ProductQuantityCopyWith<$Res> { + _$ProductQuantityCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of ProductQuantity + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? product = null, + Object? variant = freezed, + Object? quantity = null, + Object? notes = freezed, + }) { + return _then( + _value.copyWith( + product: null == product + ? _value.product + : product // ignore: cast_nullable_to_non_nullable + as Product, + variant: freezed == variant + ? _value.variant + : variant // ignore: cast_nullable_to_non_nullable + as ProductVariant?, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + notes: freezed == notes + ? _value.notes + : notes // ignore: cast_nullable_to_non_nullable + as String?, + ) + as $Val, + ); + } + + /// Create a copy of ProductQuantity + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ProductCopyWith<$Res> get product { + return $ProductCopyWith<$Res>(_value.product, (value) { + return _then(_value.copyWith(product: value) as $Val); + }); + } + + /// Create a copy of ProductQuantity + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ProductVariantCopyWith<$Res>? get variant { + if (_value.variant == null) { + return null; + } + + return $ProductVariantCopyWith<$Res>(_value.variant!, (value) { + return _then(_value.copyWith(variant: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$ProductQuantityImplCopyWith<$Res> + implements $ProductQuantityCopyWith<$Res> { + factory _$$ProductQuantityImplCopyWith( + _$ProductQuantityImpl value, + $Res Function(_$ProductQuantityImpl) then, + ) = __$$ProductQuantityImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + Product product, + ProductVariant? variant, + int quantity, + String? notes, + }); + + @override + $ProductCopyWith<$Res> get product; + @override + $ProductVariantCopyWith<$Res>? get variant; +} + +/// @nodoc +class __$$ProductQuantityImplCopyWithImpl<$Res> + extends _$ProductQuantityCopyWithImpl<$Res, _$ProductQuantityImpl> + implements _$$ProductQuantityImplCopyWith<$Res> { + __$$ProductQuantityImplCopyWithImpl( + _$ProductQuantityImpl _value, + $Res Function(_$ProductQuantityImpl) _then, + ) : super(_value, _then); + + /// Create a copy of ProductQuantity + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? product = null, + Object? variant = freezed, + Object? quantity = null, + Object? notes = freezed, + }) { + return _then( + _$ProductQuantityImpl( + product: null == product + ? _value.product + : product // ignore: cast_nullable_to_non_nullable + as Product, + variant: freezed == variant + ? _value.variant + : variant // ignore: cast_nullable_to_non_nullable + as ProductVariant?, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + notes: freezed == notes + ? _value.notes + : notes // ignore: cast_nullable_to_non_nullable + as String?, + ), + ); + } +} + +/// @nodoc + +class _$ProductQuantityImpl + with DiagnosticableTreeMixin + implements _ProductQuantity { + const _$ProductQuantityImpl({ + required this.product, + this.variant, + required this.quantity, + this.notes, + }); + + @override + final Product product; + @override + final ProductVariant? variant; + @override + final int quantity; + @override + final String? notes; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + return 'ProductQuantity(product: $product, variant: $variant, quantity: $quantity, notes: $notes)'; + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('type', 'ProductQuantity')) + ..add(DiagnosticsProperty('product', product)) + ..add(DiagnosticsProperty('variant', variant)) + ..add(DiagnosticsProperty('quantity', quantity)) + ..add(DiagnosticsProperty('notes', notes)); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ProductQuantityImpl && + (identical(other.product, product) || other.product == product) && + (identical(other.variant, variant) || other.variant == variant) && + (identical(other.quantity, quantity) || + other.quantity == quantity) && + (identical(other.notes, notes) || other.notes == notes)); + } + + @override + int get hashCode => + Object.hash(runtimeType, product, variant, quantity, notes); + + /// Create a copy of ProductQuantity + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ProductQuantityImplCopyWith<_$ProductQuantityImpl> get copyWith => + __$$ProductQuantityImplCopyWithImpl<_$ProductQuantityImpl>( + this, + _$identity, + ); +} + +abstract class _ProductQuantity implements ProductQuantity { + const factory _ProductQuantity({ + required final Product product, + final ProductVariant? variant, + required final int quantity, + final String? notes, + }) = _$ProductQuantityImpl; + + @override + Product get product; + @override + ProductVariant? get variant; + @override + int get quantity; + @override + String? get notes; + + /// Create a copy of ProductQuantity + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ProductQuantityImplCopyWith<_$ProductQuantityImpl> get copyWith => + throw _privateConstructorUsedError; +} + /// @nodoc mixin _$ProductFailure { @optionalTypeArgs diff --git a/lib/injection.config.dart b/lib/injection.config.dart index 21300f7..f863fdf 100644 --- a/lib/injection.config.dart +++ b/lib/injection.config.dart @@ -14,6 +14,8 @@ import 'package:apskel_pos_flutter_v2/application/auth/login_form/login_form_blo as _i46; import 'package:apskel_pos_flutter_v2/application/category/category_loader/category_loader_bloc.dart' as _i1018; +import 'package:apskel_pos_flutter_v2/application/checkout/checkout_form/checkout_form_bloc.dart' + as _i13; import 'package:apskel_pos_flutter_v2/application/outlet/outlet_loader/outlet_loader_bloc.dart' as _i76; import 'package:apskel_pos_flutter_v2/application/product/product_loader/product_loader_bloc.dart' @@ -86,6 +88,7 @@ extension GetItInjectableX on _i174.GetIt { () => sharedPreferencesDi.prefs, preResolve: true, ); + gh.factory<_i13.CheckoutFormBloc>(() => _i13.CheckoutFormBloc()); gh.singleton<_i487.DatabaseHelper>(() => databaseDi.databaseHelper); gh.lazySingleton<_i361.Dio>(() => dioDi.dio); gh.lazySingleton<_i800.AppRouter>(() => autoRouteDi.appRouter); @@ -116,12 +119,12 @@ extension GetItInjectableX on _i174.GetIt { gh.factory<_i370.AuthRemoteDataProvider>( () => _i370.AuthRemoteDataProvider(gh<_i457.ApiClient>()), ); - gh.factory<_i132.OutletRemoteDataProvider>( - () => _i132.OutletRemoteDataProvider(gh<_i457.ApiClient>()), - ); gh.factory<_i707.ProductRemoteDataProvider>( () => _i707.ProductRemoteDataProvider(gh<_i457.ApiClient>()), ); + gh.factory<_i132.OutletRemoteDataProvider>( + () => _i132.OutletRemoteDataProvider(gh<_i457.ApiClient>()), + ); gh.factory<_i776.IAuthRepository>( () => _i941.AuthRepository( gh<_i370.AuthRemoteDataProvider>(), diff --git a/lib/presentation/components/assets/assets.gen.dart b/lib/presentation/components/assets/assets.gen.dart index 343ade5..5da9a06 100644 --- a/lib/presentation/components/assets/assets.gen.dart +++ b/lib/presentation/components/assets/assets.gen.dart @@ -14,6 +14,12 @@ import 'package:flutter/widgets.dart'; class $AssetsImagesGen { const $AssetsImagesGen(); + /// File path: assets/images/gojek.png + AssetGenImage get gojek => const AssetGenImage('assets/images/gojek.png'); + + /// File path: assets/images/grab.png + AssetGenImage get grab => const AssetGenImage('assets/images/grab.png'); + /// File path: assets/images/logo.png AssetGenImage get logo => const AssetGenImage('assets/images/logo.png'); @@ -22,7 +28,7 @@ class $AssetsImagesGen { const AssetGenImage('assets/images/logo_white.png'); /// List of all assets - List get values => [logo, logoWhite]; + List get values => [gojek, grab, logo, logoWhite]; } class Assets {