Skip to content

Commit

Permalink
fix: searching in shops page
Browse files Browse the repository at this point in the history
  • Loading branch information
p0dyakov committed Dec 19, 2022
1 parent 839dd13 commit 17557e7
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 129 deletions.
8 changes: 4 additions & 4 deletions lib/src/feature/shop/model/shop_data/shop_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import 'package:syncfusion_flutter_sliders/sliders.dart';
part 'shop_data.freezed.dart';

@freezed
class ShopData with _$ShopData {
factory ShopData({
class ShopsData with _$ShopsData {
factory ShopsData({
required List<Shop> shops,
required String query,
required SfRangeValues weightValues,
required SfRangeValues priceValues,
}) = _ShopData;
}) = _ShopsData;

factory ShopData.initial() => ShopData(
factory ShopsData.initial() => ShopsData(
query: '',
shops: [],
weightValues: const SfRangeValues(0, 1000),
Expand Down
56 changes: 28 additions & 28 deletions lib/src/feature/shop/model/shop_data/shop_data.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ 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#custom-getters-and-methods');

/// @nodoc
mixin _$ShopData {
mixin _$ShopsData {
List<Shop> get shops => throw _privateConstructorUsedError;
String get query => throw _privateConstructorUsedError;
SfRangeValues get weightValues => throw _privateConstructorUsedError;
SfRangeValues get priceValues => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
$ShopDataCopyWith<ShopData> get copyWith =>
$ShopsDataCopyWith<ShopsData> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $ShopDataCopyWith<$Res> {
factory $ShopDataCopyWith(ShopData value, $Res Function(ShopData) then) =
_$ShopDataCopyWithImpl<$Res, ShopData>;
abstract class $ShopsDataCopyWith<$Res> {
factory $ShopsDataCopyWith(ShopsData value, $Res Function(ShopsData) then) =
_$ShopsDataCopyWithImpl<$Res, ShopsData>;
@useResult
$Res call(
{List<Shop> shops,
Expand All @@ -39,9 +39,9 @@ abstract class $ShopDataCopyWith<$Res> {
}

/// @nodoc
class _$ShopDataCopyWithImpl<$Res, $Val extends ShopData>
implements $ShopDataCopyWith<$Res> {
_$ShopDataCopyWithImpl(this._value, this._then);
class _$ShopsDataCopyWithImpl<$Res, $Val extends ShopsData>
implements $ShopsDataCopyWith<$Res> {
_$ShopsDataCopyWithImpl(this._value, this._then);

// ignore: unused_field
final $Val _value;
Expand Down Expand Up @@ -78,10 +78,10 @@ class _$ShopDataCopyWithImpl<$Res, $Val extends ShopData>
}

/// @nodoc
abstract class _$$_ShopDataCopyWith<$Res> implements $ShopDataCopyWith<$Res> {
factory _$$_ShopDataCopyWith(
_$_ShopData value, $Res Function(_$_ShopData) then) =
__$$_ShopDataCopyWithImpl<$Res>;
abstract class _$$_ShopsDataCopyWith<$Res> implements $ShopsDataCopyWith<$Res> {
factory _$$_ShopsDataCopyWith(
_$_ShopsData value, $Res Function(_$_ShopsData) then) =
__$$_ShopsDataCopyWithImpl<$Res>;
@override
@useResult
$Res call(
Expand All @@ -92,11 +92,11 @@ abstract class _$$_ShopDataCopyWith<$Res> implements $ShopDataCopyWith<$Res> {
}

/// @nodoc
class __$$_ShopDataCopyWithImpl<$Res>
extends _$ShopDataCopyWithImpl<$Res, _$_ShopData>
implements _$$_ShopDataCopyWith<$Res> {
__$$_ShopDataCopyWithImpl(
_$_ShopData _value, $Res Function(_$_ShopData) _then)
class __$$_ShopsDataCopyWithImpl<$Res>
extends _$ShopsDataCopyWithImpl<$Res, _$_ShopsData>
implements _$$_ShopsDataCopyWith<$Res> {
__$$_ShopsDataCopyWithImpl(
_$_ShopsData _value, $Res Function(_$_ShopsData) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
Expand All @@ -107,7 +107,7 @@ class __$$_ShopDataCopyWithImpl<$Res>
Object? weightValues = null,
Object? priceValues = null,
}) {
return _then(_$_ShopData(
return _then(_$_ShopsData(
shops: null == shops
? _value._shops
: shops // ignore: cast_nullable_to_non_nullable
Expand All @@ -130,8 +130,8 @@ class __$$_ShopDataCopyWithImpl<$Res>

/// @nodoc
class _$_ShopData implements _ShopData {
_$_ShopData(
class _$_ShopsData implements _ShopsData {
_$_ShopsData(
{required final List<Shop> shops,
required this.query,
required this.weightValues,
Expand All @@ -154,14 +154,14 @@ class _$_ShopData implements _ShopData {

@override
String toString() {
return 'ShopData(shops: $shops, query: $query, weightValues: $weightValues, priceValues: $priceValues)';
return 'ShopsData(shops: $shops, query: $query, weightValues: $weightValues, priceValues: $priceValues)';
}

@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_ShopData &&
other is _$_ShopsData &&
const DeepCollectionEquality().equals(other._shops, _shops) &&
(identical(other.query, query) || other.query == query) &&
(identical(other.weightValues, weightValues) ||
Expand All @@ -181,16 +181,16 @@ class _$_ShopData implements _ShopData {
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_ShopDataCopyWith<_$_ShopData> get copyWith =>
__$$_ShopDataCopyWithImpl<_$_ShopData>(this, _$identity);
_$$_ShopsDataCopyWith<_$_ShopsData> get copyWith =>
__$$_ShopsDataCopyWithImpl<_$_ShopsData>(this, _$identity);
}

abstract class _ShopData implements ShopData {
factory _ShopData(
abstract class _ShopsData implements ShopsData {
factory _ShopsData(
{required final List<Shop> shops,
required final String query,
required final SfRangeValues weightValues,
required final SfRangeValues priceValues}) = _$_ShopData;
required final SfRangeValues priceValues}) = _$_ShopsData;

@override
List<Shop> get shops;
Expand All @@ -202,6 +202,6 @@ abstract class _ShopData implements ShopData {
SfRangeValues get priceValues;
@override
@JsonKey(ignore: true)
_$$_ShopDataCopyWith<_$_ShopData> get copyWith =>
_$$_ShopsDataCopyWith<_$_ShopsData> get copyWith =>
throw _privateConstructorUsedError;
}
11 changes: 8 additions & 3 deletions lib/src/feature/shop/shops_bloc/shops_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ class ShopsBloc extends StreamBloc<ShopsEvent, ShopsState> {
ShopsBloc(
IShopRepository shopRepository,
) : _shopRepository = shopRepository,
super(_Loading(data: ShopData.initial())) {
super(_Loading(data: ShopsData.initial())) {
add(const ShopsEvent.getStoredShops());
add(const ShopsEvent.getShops());
}

ShopData get _data => state.data;
ShopsData get _data => state.data;

@override
Stream<ShopsState> mapEventToStates(ShopsEvent event) => event.when(
Expand Down Expand Up @@ -91,8 +91,13 @@ class ShopsBloc extends StreamBloc<ShopsEvent, ShopsState> {
}

return _SearchSuccess(
data: _data,
results: results,
data: ShopsData(
priceValues: priceValues,
weightValues: weightValues,
query: query,
shops: _data.shops,
),
);
},
);
Expand Down
Loading

0 comments on commit 17557e7

Please sign in to comment.