Compare commits
2 Commits
30f190aab9
...
7474a8b677
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7474a8b677 | ||
|
|
7e9fbd2cf3 |
@@ -12,6 +12,7 @@
|
|||||||
import 'package:get_it/get_it.dart' as _i174;
|
import 'package:get_it/get_it.dart' as _i174;
|
||||||
import 'package:injectable/injectable.dart' as _i526;
|
import 'package:injectable/injectable.dart' as _i526;
|
||||||
|
|
||||||
|
import '../../feature/basket/presentation/blocs/basket_bloc.dart' as _i728;
|
||||||
import '../../feature/common/presentation/blocs/language_bloc/language_bloc.dart'
|
import '../../feature/common/presentation/blocs/language_bloc/language_bloc.dart'
|
||||||
as _i942;
|
as _i942;
|
||||||
import '../../feature/home/presentation/blocs/home_bloc/home_bloc.dart'
|
import '../../feature/home/presentation/blocs/home_bloc/home_bloc.dart'
|
||||||
@@ -34,6 +35,7 @@ extension GetItInjectableX on _i174.GetIt {
|
|||||||
gh.factory<_i1007.HomeBloc>(() => _i1007.HomeBloc());
|
gh.factory<_i1007.HomeBloc>(() => _i1007.HomeBloc());
|
||||||
gh.factory<_i580.MainBloc>(() => _i580.MainBloc());
|
gh.factory<_i580.MainBloc>(() => _i580.MainBloc());
|
||||||
gh.factory<_i311.SplashBloc>(() => _i311.SplashBloc());
|
gh.factory<_i311.SplashBloc>(() => _i311.SplashBloc());
|
||||||
|
gh.factory<_i728.BasketBloc>(() => _i728.BasketBloc());
|
||||||
gh.singleton<_i306.StorageService>(() => _i306.StorageService());
|
gh.singleton<_i306.StorageService>(() => _i306.StorageService());
|
||||||
gh.singleton<_i152.AppRoutes>(() => _i152.AppRoutes());
|
gh.singleton<_i152.AppRoutes>(() => _i152.AppRoutes());
|
||||||
gh.factory<_i942.LanguageBloc>(
|
gh.factory<_i942.LanguageBloc>(
|
||||||
|
|||||||
@@ -1 +1,5 @@
|
|||||||
export 'presentation/pages/basket_page/basket_page.dart';
|
export 'presentation/pages/basket_page/basket_page.dart';
|
||||||
|
export 'package:food_delivery_client/feature/basket/presentation/pages/basket_page/widgets/w_basket_empty.dart';
|
||||||
|
export 'package:food_delivery_client/feature/basket/presentation/pages/basket_page/widgets/w_basket_header.dart';
|
||||||
|
export 'presentation/blocs/basket_bloc.dart';
|
||||||
|
export 'package:food_delivery_client/feature/basket/presentation/pages/basket_page/widgets/w_basket_body.dart';
|
||||||
|
|||||||
20
lib/feature/basket/presentation/blocs/basket_bloc.dart
Normal file
20
lib/feature/basket/presentation/blocs/basket_bloc.dart
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import 'package:food_delivery_client/food_delivery_client.dart';
|
||||||
|
|
||||||
|
part 'basket_event.dart';
|
||||||
|
|
||||||
|
part 'basket_state.dart';
|
||||||
|
|
||||||
|
part 'basket_bloc.freezed.dart';
|
||||||
|
|
||||||
|
@injectable
|
||||||
|
class BasketBloc extends Bloc<BasketEvent, BasketState> {
|
||||||
|
BasketBloc() : super(const BasketState()) {
|
||||||
|
on<_Started>(_onStarted);
|
||||||
|
}
|
||||||
|
|
||||||
|
_onStarted(_Started event, Emitter<BasketState> emit) async {
|
||||||
|
emit(state.copyWith(status: RequestStatus.loading));
|
||||||
|
await Future.delayed(TimeDelayConst.duration3);
|
||||||
|
emit(state.copyWith(status: RequestStatus.loaded));
|
||||||
|
}
|
||||||
|
}
|
||||||
472
lib/feature/basket/presentation/blocs/basket_bloc.freezed.dart
Normal file
472
lib/feature/basket/presentation/blocs/basket_bloc.freezed.dart
Normal file
@@ -0,0 +1,472 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
// coverage:ignore-file
|
||||||
|
// 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 'basket_bloc.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// FreezedGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
// dart format off
|
||||||
|
T _$identity<T>(T value) => value;
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$BasketEvent {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is BasketEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => runtimeType.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'BasketEvent()';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class $BasketEventCopyWith<$Res> {
|
||||||
|
$BasketEventCopyWith(BasketEvent _, $Res Function(BasketEvent) __);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Adds pattern-matching-related methods to [BasketEvent].
|
||||||
|
extension BasketEventPatterns on BasketEvent {
|
||||||
|
/// A variant of `map` that fallback to returning `orElse`.
|
||||||
|
///
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case final Subclass value:
|
||||||
|
/// return ...;
|
||||||
|
/// case _:
|
||||||
|
/// return orElse();
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _Started value)? started,required TResult orElse(),}){
|
||||||
|
final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _Started() when started != null:
|
||||||
|
return started(_that);case _:
|
||||||
|
return orElse();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A `switch`-like method, using callbacks.
|
||||||
|
///
|
||||||
|
/// Callbacks receives the raw object, upcasted.
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case final Subclass value:
|
||||||
|
/// return ...;
|
||||||
|
/// case final Subclass2 value:
|
||||||
|
/// return ...;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _Started value) started,}){
|
||||||
|
final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _Started():
|
||||||
|
return started(_that);case _:
|
||||||
|
throw StateError('Unexpected subclass');
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A variant of `map` that fallback to returning `null`.
|
||||||
|
///
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case final Subclass value:
|
||||||
|
/// return ...;
|
||||||
|
/// case _:
|
||||||
|
/// return null;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _Started value)? started,}){
|
||||||
|
final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _Started() when started != null:
|
||||||
|
return started(_that);case _:
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A variant of `when` that fallback to an `orElse` callback.
|
||||||
|
///
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case Subclass(:final field):
|
||||||
|
/// return ...;
|
||||||
|
/// case _:
|
||||||
|
/// return orElse();
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? started,required TResult orElse(),}) {final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _Started() when started != null:
|
||||||
|
return started();case _:
|
||||||
|
return orElse();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A `switch`-like method, using callbacks.
|
||||||
|
///
|
||||||
|
/// As opposed to `map`, this offers destructuring.
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case Subclass(:final field):
|
||||||
|
/// return ...;
|
||||||
|
/// case Subclass2(:final field2):
|
||||||
|
/// return ...;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() started,}) {final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _Started():
|
||||||
|
return started();case _:
|
||||||
|
throw StateError('Unexpected subclass');
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A variant of `when` that fallback to returning `null`
|
||||||
|
///
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case Subclass(:final field):
|
||||||
|
/// return ...;
|
||||||
|
/// case _:
|
||||||
|
/// return null;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? started,}) {final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _Started() when started != null:
|
||||||
|
return started();case _:
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
|
||||||
|
class _Started implements BasketEvent {
|
||||||
|
const _Started();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Started);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => runtimeType.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'BasketEvent.started()';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$BasketState {
|
||||||
|
|
||||||
|
RequestStatus get status; List get orders;
|
||||||
|
/// Create a copy of BasketState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
$BasketStateCopyWith<BasketState> get copyWith => _$BasketStateCopyWithImpl<BasketState>(this as BasketState, _$identity);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is BasketState&&(identical(other.status, status) || other.status == status)&&const DeepCollectionEquality().equals(other.orders, orders));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType,status,const DeepCollectionEquality().hash(orders));
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'BasketState(status: $status, orders: $orders)';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract mixin class $BasketStateCopyWith<$Res> {
|
||||||
|
factory $BasketStateCopyWith(BasketState value, $Res Function(BasketState) _then) = _$BasketStateCopyWithImpl;
|
||||||
|
@useResult
|
||||||
|
$Res call({
|
||||||
|
RequestStatus status, List orders
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
/// @nodoc
|
||||||
|
class _$BasketStateCopyWithImpl<$Res>
|
||||||
|
implements $BasketStateCopyWith<$Res> {
|
||||||
|
_$BasketStateCopyWithImpl(this._self, this._then);
|
||||||
|
|
||||||
|
final BasketState _self;
|
||||||
|
final $Res Function(BasketState) _then;
|
||||||
|
|
||||||
|
/// Create a copy of BasketState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline') @override $Res call({Object? status = null,Object? orders = null,}) {
|
||||||
|
return _then(_self.copyWith(
|
||||||
|
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||||
|
as RequestStatus,orders: null == orders ? _self.orders : orders // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Adds pattern-matching-related methods to [BasketState].
|
||||||
|
extension BasketStatePatterns on BasketState {
|
||||||
|
/// A variant of `map` that fallback to returning `orElse`.
|
||||||
|
///
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case final Subclass value:
|
||||||
|
/// return ...;
|
||||||
|
/// case _:
|
||||||
|
/// return orElse();
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _BasketState value)? $default,{required TResult orElse(),}){
|
||||||
|
final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _BasketState() when $default != null:
|
||||||
|
return $default(_that);case _:
|
||||||
|
return orElse();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A `switch`-like method, using callbacks.
|
||||||
|
///
|
||||||
|
/// Callbacks receives the raw object, upcasted.
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case final Subclass value:
|
||||||
|
/// return ...;
|
||||||
|
/// case final Subclass2 value:
|
||||||
|
/// return ...;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _BasketState value) $default,){
|
||||||
|
final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _BasketState():
|
||||||
|
return $default(_that);case _:
|
||||||
|
throw StateError('Unexpected subclass');
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A variant of `map` that fallback to returning `null`.
|
||||||
|
///
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case final Subclass value:
|
||||||
|
/// return ...;
|
||||||
|
/// case _:
|
||||||
|
/// return null;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _BasketState value)? $default,){
|
||||||
|
final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _BasketState() when $default != null:
|
||||||
|
return $default(_that);case _:
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A variant of `when` that fallback to an `orElse` callback.
|
||||||
|
///
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case Subclass(:final field):
|
||||||
|
/// return ...;
|
||||||
|
/// case _:
|
||||||
|
/// return orElse();
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( RequestStatus status, List orders)? $default,{required TResult orElse(),}) {final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _BasketState() when $default != null:
|
||||||
|
return $default(_that.status,_that.orders);case _:
|
||||||
|
return orElse();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A `switch`-like method, using callbacks.
|
||||||
|
///
|
||||||
|
/// As opposed to `map`, this offers destructuring.
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case Subclass(:final field):
|
||||||
|
/// return ...;
|
||||||
|
/// case Subclass2(:final field2):
|
||||||
|
/// return ...;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( RequestStatus status, List orders) $default,) {final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _BasketState():
|
||||||
|
return $default(_that.status,_that.orders);case _:
|
||||||
|
throw StateError('Unexpected subclass');
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// A variant of `when` that fallback to returning `null`
|
||||||
|
///
|
||||||
|
/// It is equivalent to doing:
|
||||||
|
/// ```dart
|
||||||
|
/// switch (sealedClass) {
|
||||||
|
/// case Subclass(:final field):
|
||||||
|
/// return ...;
|
||||||
|
/// case _:
|
||||||
|
/// return null;
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
|
||||||
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( RequestStatus status, List orders)? $default,) {final _that = this;
|
||||||
|
switch (_that) {
|
||||||
|
case _BasketState() when $default != null:
|
||||||
|
return $default(_that.status,_that.orders);case _:
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
|
||||||
|
class _BasketState implements BasketState {
|
||||||
|
const _BasketState({this.status = RequestStatus.initial, final List orders = const []}): _orders = orders;
|
||||||
|
|
||||||
|
|
||||||
|
@override@JsonKey() final RequestStatus status;
|
||||||
|
final List _orders;
|
||||||
|
@override@JsonKey() List get orders {
|
||||||
|
if (_orders is EqualUnmodifiableListView) return _orders;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(_orders);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Create a copy of BasketState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$BasketStateCopyWith<_BasketState> get copyWith => __$BasketStateCopyWithImpl<_BasketState>(this, _$identity);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _BasketState&&(identical(other.status, status) || other.status == status)&&const DeepCollectionEquality().equals(other._orders, _orders));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType,status,const DeepCollectionEquality().hash(_orders));
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'BasketState(status: $status, orders: $orders)';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract mixin class _$BasketStateCopyWith<$Res> implements $BasketStateCopyWith<$Res> {
|
||||||
|
factory _$BasketStateCopyWith(_BasketState value, $Res Function(_BasketState) _then) = __$BasketStateCopyWithImpl;
|
||||||
|
@override @useResult
|
||||||
|
$Res call({
|
||||||
|
RequestStatus status, List orders
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
/// @nodoc
|
||||||
|
class __$BasketStateCopyWithImpl<$Res>
|
||||||
|
implements _$BasketStateCopyWith<$Res> {
|
||||||
|
__$BasketStateCopyWithImpl(this._self, this._then);
|
||||||
|
|
||||||
|
final _BasketState _self;
|
||||||
|
final $Res Function(_BasketState) _then;
|
||||||
|
|
||||||
|
/// Create a copy of BasketState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@override @pragma('vm:prefer-inline') $Res call({Object? status = null,Object? orders = null,}) {
|
||||||
|
return _then(_BasketState(
|
||||||
|
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||||
|
as RequestStatus,orders: null == orders ? _self._orders : orders // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// dart format on
|
||||||
6
lib/feature/basket/presentation/blocs/basket_event.dart
Normal file
6
lib/feature/basket/presentation/blocs/basket_event.dart
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
part of 'basket_bloc.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class BasketEvent with _$BasketEvent {
|
||||||
|
const factory BasketEvent.started() = _Started;
|
||||||
|
}
|
||||||
9
lib/feature/basket/presentation/blocs/basket_state.dart
Normal file
9
lib/feature/basket/presentation/blocs/basket_state.dart
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
part of 'basket_bloc.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
abstract class BasketState with _$BasketState {
|
||||||
|
const factory BasketState({
|
||||||
|
@Default(RequestStatus.initial) RequestStatus status,
|
||||||
|
@Default([]) List orders,
|
||||||
|
}) = _BasketState;
|
||||||
|
}
|
||||||
@@ -1,6 +1,3 @@
|
|||||||
import 'package:food_delivery_client/feature/basket/presentation/pages/basket_page/widgets/w_basket_empty.dart';
|
|
||||||
import 'package:food_delivery_client/feature/basket/presentation/pages/basket_page/widgets/w_basket_header.dart';
|
|
||||||
|
|
||||||
import '../../../../../food_delivery_client.dart';
|
import '../../../../../food_delivery_client.dart';
|
||||||
|
|
||||||
class BasketPage extends StatelessWidget {
|
class BasketPage extends StatelessWidget {
|
||||||
@@ -8,10 +5,13 @@ class BasketPage extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return WLayout(
|
return BlocProvider(
|
||||||
child: Scaffold(body: Column(children: [
|
create: (context) => sl<BasketBloc>()..add(BasketEvent.started()),
|
||||||
WBasketHeader(),
|
child: BlocBuilder<BasketBloc, BasketState>(
|
||||||
WBasketEmpty()])),
|
builder: (context, state) {
|
||||||
|
return WLayout(child: Scaffold(body: WBasketBody()));
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import 'package:food_delivery_client/feature/basket/presentation/pages/basket_page/widgets/w_basket_loading.dart';
|
||||||
|
|
||||||
|
import '../../../../../../food_delivery_client.dart';
|
||||||
|
|
||||||
|
class WBasketBody extends StatelessWidget {
|
||||||
|
const WBasketBody({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BlocBuilder<BasketBloc, BasketState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
WBasketHeader(),
|
||||||
|
OrderItem(),
|
||||||
|
|
||||||
|
if (state.status.isLoading()) Text("Loading"),
|
||||||
|
if (state.status.isLoaded())
|
||||||
|
if (state.orders.isEmpty) WBasketEmpty(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import '../../../../../../food_delivery_client.dart';
|
||||||
|
|
||||||
|
class WBasketLoading extends StatelessWidget {
|
||||||
|
const WBasketLoading({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(children: []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class OrderItem extends StatelessWidget {
|
||||||
|
const OrderItem({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: () {},
|
||||||
|
child: Ink(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: AppUtils.kBorderRadius40,
|
||||||
|
child: CachedNetworkImage(
|
||||||
|
imageUrl: AppLocaleKeys.imageUrl,
|
||||||
|
height: 70,
|
||||||
|
width: 70,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
16.horizontalSpace,
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text("Begs & Megs", style: AppTextStyles.size16Medium),
|
||||||
|
Text(
|
||||||
|
"1 item",
|
||||||
|
style: AppTextStyles.size14Regular.copyWith(
|
||||||
|
color: AppColors.c6B6B6B,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"Deliver to San Franciscao Bay Area",
|
||||||
|
style: AppTextStyles.size14Regular.copyWith(
|
||||||
|
color: AppColors.c6B6B6B,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Icon(Icons.arrow_forward_ios_outlined),
|
||||||
|
],
|
||||||
|
).paddingSymmetric(vertical: 10, horizontal: 16),
|
||||||
|
10.verticalSpace,
|
||||||
|
WDivider(indent: 120, endIndent: 20, height: 1),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,8 +18,8 @@ class WDivider extends StatelessWidget {
|
|||||||
color: AppColors.cF6F6F6,
|
color: AppColors.cF6F6F6,
|
||||||
height: height,
|
height: height,
|
||||||
thickness: height,
|
thickness: height,
|
||||||
endIndent: 0,
|
endIndent: endIndent??0,
|
||||||
indent: 0,
|
indent:indent?? 0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user