forked from eatvio/eatvio_app
feat: consultants rating
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/consultants_cubit/consultants_state.dart';
|
||||
import 'package:eatvio_app/features/feed/repositories/feed_repository.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class ConsultantsCubit extends Cubit<ConsultantsState> {
|
||||
final FeedRepository feedRepository;
|
||||
|
||||
ConsultantsCubit({
|
||||
required this.feedRepository,
|
||||
}) : super(ConsultantsState());
|
||||
|
||||
getConsultants() async {
|
||||
emit(ConsultantsState.loading());
|
||||
try {
|
||||
emit(
|
||||
ConsultantsState.loaded(
|
||||
consultantsList: await feedRepository.getConsultants(),
|
||||
isLoading: false,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
emit(ConsultantsState.error(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:eatvio_app/features/feed/models/feed_consultant_model.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'consultants_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class ConsultantsState with _$ConsultantsState {
|
||||
const factory ConsultantsState() = _ConsultantsState;
|
||||
|
||||
const factory ConsultantsState.loading() = ConsultantsStateLoading;
|
||||
|
||||
const factory ConsultantsState.loaded({
|
||||
required List<FeedConsultantModel> consultantsList,
|
||||
required bool isLoading,
|
||||
}) = ConsultantsStateLoaded;
|
||||
|
||||
const factory ConsultantsState.error({
|
||||
required String errorMessage,
|
||||
}) = ConsultantsStateError;
|
||||
}
|
||||
@@ -0,0 +1,686 @@
|
||||
// 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 'consultants_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$ConsultantsState {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(
|
||||
List<FeedConsultantModel> consultantsList, bool isLoading)
|
||||
loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(
|
||||
List<FeedConsultantModel> consultantsList, bool isLoading)?
|
||||
loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<FeedConsultantModel> consultantsList, bool isLoading)?
|
||||
loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_ConsultantsState value) $default, {
|
||||
required TResult Function(ConsultantsStateLoading value) loading,
|
||||
required TResult Function(ConsultantsStateLoaded value) loaded,
|
||||
required TResult Function(ConsultantsStateError value) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_ConsultantsState value)? $default, {
|
||||
TResult? Function(ConsultantsStateLoading value)? loading,
|
||||
TResult? Function(ConsultantsStateLoaded value)? loaded,
|
||||
TResult? Function(ConsultantsStateError value)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_ConsultantsState value)? $default, {
|
||||
TResult Function(ConsultantsStateLoading value)? loading,
|
||||
TResult Function(ConsultantsStateLoaded value)? loaded,
|
||||
TResult Function(ConsultantsStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ConsultantsStateCopyWith<$Res> {
|
||||
factory $ConsultantsStateCopyWith(
|
||||
ConsultantsState value, $Res Function(ConsultantsState) then) =
|
||||
_$ConsultantsStateCopyWithImpl<$Res, ConsultantsState>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ConsultantsStateCopyWithImpl<$Res, $Val extends ConsultantsState>
|
||||
implements $ConsultantsStateCopyWith<$Res> {
|
||||
_$ConsultantsStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ConsultantsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ConsultantsStateImplCopyWith<$Res> {
|
||||
factory _$$ConsultantsStateImplCopyWith(_$ConsultantsStateImpl value,
|
||||
$Res Function(_$ConsultantsStateImpl) then) =
|
||||
__$$ConsultantsStateImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ConsultantsStateImplCopyWithImpl<$Res>
|
||||
extends _$ConsultantsStateCopyWithImpl<$Res, _$ConsultantsStateImpl>
|
||||
implements _$$ConsultantsStateImplCopyWith<$Res> {
|
||||
__$$ConsultantsStateImplCopyWithImpl(_$ConsultantsStateImpl _value,
|
||||
$Res Function(_$ConsultantsStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of ConsultantsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ConsultantsStateImpl implements _ConsultantsState {
|
||||
const _$ConsultantsStateImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ConsultantsState()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$ConsultantsStateImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(
|
||||
List<FeedConsultantModel> consultantsList, bool isLoading)
|
||||
loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return $default();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(
|
||||
List<FeedConsultantModel> consultantsList, bool isLoading)?
|
||||
loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return $default?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<FeedConsultantModel> consultantsList, bool isLoading)?
|
||||
loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if ($default != null) {
|
||||
return $default();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_ConsultantsState value) $default, {
|
||||
required TResult Function(ConsultantsStateLoading value) loading,
|
||||
required TResult Function(ConsultantsStateLoaded value) loaded,
|
||||
required TResult Function(ConsultantsStateError value) error,
|
||||
}) {
|
||||
return $default(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_ConsultantsState value)? $default, {
|
||||
TResult? Function(ConsultantsStateLoading value)? loading,
|
||||
TResult? Function(ConsultantsStateLoaded value)? loaded,
|
||||
TResult? Function(ConsultantsStateError value)? error,
|
||||
}) {
|
||||
return $default?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_ConsultantsState value)? $default, {
|
||||
TResult Function(ConsultantsStateLoading value)? loading,
|
||||
TResult Function(ConsultantsStateLoaded value)? loaded,
|
||||
TResult Function(ConsultantsStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if ($default != null) {
|
||||
return $default(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _ConsultantsState implements ConsultantsState {
|
||||
const factory _ConsultantsState() = _$ConsultantsStateImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ConsultantsStateLoadingImplCopyWith<$Res> {
|
||||
factory _$$ConsultantsStateLoadingImplCopyWith(
|
||||
_$ConsultantsStateLoadingImpl value,
|
||||
$Res Function(_$ConsultantsStateLoadingImpl) then) =
|
||||
__$$ConsultantsStateLoadingImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ConsultantsStateLoadingImplCopyWithImpl<$Res>
|
||||
extends _$ConsultantsStateCopyWithImpl<$Res, _$ConsultantsStateLoadingImpl>
|
||||
implements _$$ConsultantsStateLoadingImplCopyWith<$Res> {
|
||||
__$$ConsultantsStateLoadingImplCopyWithImpl(
|
||||
_$ConsultantsStateLoadingImpl _value,
|
||||
$Res Function(_$ConsultantsStateLoadingImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of ConsultantsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ConsultantsStateLoadingImpl implements ConsultantsStateLoading {
|
||||
const _$ConsultantsStateLoadingImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ConsultantsState.loading()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ConsultantsStateLoadingImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(
|
||||
List<FeedConsultantModel> consultantsList, bool isLoading)
|
||||
loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return loading();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(
|
||||
List<FeedConsultantModel> consultantsList, bool isLoading)?
|
||||
loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return loading?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<FeedConsultantModel> consultantsList, bool isLoading)?
|
||||
loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_ConsultantsState value) $default, {
|
||||
required TResult Function(ConsultantsStateLoading value) loading,
|
||||
required TResult Function(ConsultantsStateLoaded value) loaded,
|
||||
required TResult Function(ConsultantsStateError value) error,
|
||||
}) {
|
||||
return loading(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_ConsultantsState value)? $default, {
|
||||
TResult? Function(ConsultantsStateLoading value)? loading,
|
||||
TResult? Function(ConsultantsStateLoaded value)? loaded,
|
||||
TResult? Function(ConsultantsStateError value)? error,
|
||||
}) {
|
||||
return loading?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_ConsultantsState value)? $default, {
|
||||
TResult Function(ConsultantsStateLoading value)? loading,
|
||||
TResult Function(ConsultantsStateLoaded value)? loaded,
|
||||
TResult Function(ConsultantsStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class ConsultantsStateLoading implements ConsultantsState {
|
||||
const factory ConsultantsStateLoading() = _$ConsultantsStateLoadingImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ConsultantsStateLoadedImplCopyWith<$Res> {
|
||||
factory _$$ConsultantsStateLoadedImplCopyWith(
|
||||
_$ConsultantsStateLoadedImpl value,
|
||||
$Res Function(_$ConsultantsStateLoadedImpl) then) =
|
||||
__$$ConsultantsStateLoadedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({List<FeedConsultantModel> consultantsList, bool isLoading});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ConsultantsStateLoadedImplCopyWithImpl<$Res>
|
||||
extends _$ConsultantsStateCopyWithImpl<$Res, _$ConsultantsStateLoadedImpl>
|
||||
implements _$$ConsultantsStateLoadedImplCopyWith<$Res> {
|
||||
__$$ConsultantsStateLoadedImplCopyWithImpl(
|
||||
_$ConsultantsStateLoadedImpl _value,
|
||||
$Res Function(_$ConsultantsStateLoadedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of ConsultantsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? consultantsList = null,
|
||||
Object? isLoading = null,
|
||||
}) {
|
||||
return _then(_$ConsultantsStateLoadedImpl(
|
||||
consultantsList: null == consultantsList
|
||||
? _value._consultantsList
|
||||
: consultantsList // ignore: cast_nullable_to_non_nullable
|
||||
as List<FeedConsultantModel>,
|
||||
isLoading: null == isLoading
|
||||
? _value.isLoading
|
||||
: isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ConsultantsStateLoadedImpl implements ConsultantsStateLoaded {
|
||||
const _$ConsultantsStateLoadedImpl(
|
||||
{required final List<FeedConsultantModel> consultantsList,
|
||||
required this.isLoading})
|
||||
: _consultantsList = consultantsList;
|
||||
|
||||
final List<FeedConsultantModel> _consultantsList;
|
||||
@override
|
||||
List<FeedConsultantModel> get consultantsList {
|
||||
if (_consultantsList is EqualUnmodifiableListView) return _consultantsList;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_consultantsList);
|
||||
}
|
||||
|
||||
@override
|
||||
final bool isLoading;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ConsultantsState.loaded(consultantsList: $consultantsList, isLoading: $isLoading)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ConsultantsStateLoadedImpl &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._consultantsList, _consultantsList) &&
|
||||
(identical(other.isLoading, isLoading) ||
|
||||
other.isLoading == isLoading));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,
|
||||
const DeepCollectionEquality().hash(_consultantsList), isLoading);
|
||||
|
||||
/// Create a copy of ConsultantsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ConsultantsStateLoadedImplCopyWith<_$ConsultantsStateLoadedImpl>
|
||||
get copyWith => __$$ConsultantsStateLoadedImplCopyWithImpl<
|
||||
_$ConsultantsStateLoadedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(
|
||||
List<FeedConsultantModel> consultantsList, bool isLoading)
|
||||
loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return loaded(consultantsList, isLoading);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(
|
||||
List<FeedConsultantModel> consultantsList, bool isLoading)?
|
||||
loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return loaded?.call(consultantsList, isLoading);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<FeedConsultantModel> consultantsList, bool isLoading)?
|
||||
loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(consultantsList, isLoading);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_ConsultantsState value) $default, {
|
||||
required TResult Function(ConsultantsStateLoading value) loading,
|
||||
required TResult Function(ConsultantsStateLoaded value) loaded,
|
||||
required TResult Function(ConsultantsStateError value) error,
|
||||
}) {
|
||||
return loaded(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_ConsultantsState value)? $default, {
|
||||
TResult? Function(ConsultantsStateLoading value)? loading,
|
||||
TResult? Function(ConsultantsStateLoaded value)? loaded,
|
||||
TResult? Function(ConsultantsStateError value)? error,
|
||||
}) {
|
||||
return loaded?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_ConsultantsState value)? $default, {
|
||||
TResult Function(ConsultantsStateLoading value)? loading,
|
||||
TResult Function(ConsultantsStateLoaded value)? loaded,
|
||||
TResult Function(ConsultantsStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class ConsultantsStateLoaded implements ConsultantsState {
|
||||
const factory ConsultantsStateLoaded(
|
||||
{required final List<FeedConsultantModel> consultantsList,
|
||||
required final bool isLoading}) = _$ConsultantsStateLoadedImpl;
|
||||
|
||||
List<FeedConsultantModel> get consultantsList;
|
||||
bool get isLoading;
|
||||
|
||||
/// Create a copy of ConsultantsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ConsultantsStateLoadedImplCopyWith<_$ConsultantsStateLoadedImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ConsultantsStateErrorImplCopyWith<$Res> {
|
||||
factory _$$ConsultantsStateErrorImplCopyWith(
|
||||
_$ConsultantsStateErrorImpl value,
|
||||
$Res Function(_$ConsultantsStateErrorImpl) then) =
|
||||
__$$ConsultantsStateErrorImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String errorMessage});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ConsultantsStateErrorImplCopyWithImpl<$Res>
|
||||
extends _$ConsultantsStateCopyWithImpl<$Res, _$ConsultantsStateErrorImpl>
|
||||
implements _$$ConsultantsStateErrorImplCopyWith<$Res> {
|
||||
__$$ConsultantsStateErrorImplCopyWithImpl(_$ConsultantsStateErrorImpl _value,
|
||||
$Res Function(_$ConsultantsStateErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of ConsultantsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? errorMessage = null,
|
||||
}) {
|
||||
return _then(_$ConsultantsStateErrorImpl(
|
||||
errorMessage: null == errorMessage
|
||||
? _value.errorMessage
|
||||
: errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ConsultantsStateErrorImpl implements ConsultantsStateError {
|
||||
const _$ConsultantsStateErrorImpl({required this.errorMessage});
|
||||
|
||||
@override
|
||||
final String errorMessage;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ConsultantsState.error(errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ConsultantsStateErrorImpl &&
|
||||
(identical(other.errorMessage, errorMessage) ||
|
||||
other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, errorMessage);
|
||||
|
||||
/// Create a copy of ConsultantsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ConsultantsStateErrorImplCopyWith<_$ConsultantsStateErrorImpl>
|
||||
get copyWith => __$$ConsultantsStateErrorImplCopyWithImpl<
|
||||
_$ConsultantsStateErrorImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(
|
||||
List<FeedConsultantModel> consultantsList, bool isLoading)
|
||||
loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return error(errorMessage);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(
|
||||
List<FeedConsultantModel> consultantsList, bool isLoading)?
|
||||
loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return error?.call(errorMessage);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<FeedConsultantModel> consultantsList, bool isLoading)?
|
||||
loaded,
|
||||
TResult Function(String errorMessage)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(errorMessage);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>(
|
||||
TResult Function(_ConsultantsState value) $default, {
|
||||
required TResult Function(ConsultantsStateLoading value) loading,
|
||||
required TResult Function(ConsultantsStateLoaded value) loaded,
|
||||
required TResult Function(ConsultantsStateError value) error,
|
||||
}) {
|
||||
return error(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>(
|
||||
TResult? Function(_ConsultantsState value)? $default, {
|
||||
TResult? Function(ConsultantsStateLoading value)? loading,
|
||||
TResult? Function(ConsultantsStateLoaded value)? loaded,
|
||||
TResult? Function(ConsultantsStateError value)? error,
|
||||
}) {
|
||||
return error?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>(
|
||||
TResult Function(_ConsultantsState value)? $default, {
|
||||
TResult Function(ConsultantsStateLoading value)? loading,
|
||||
TResult Function(ConsultantsStateLoaded value)? loaded,
|
||||
TResult Function(ConsultantsStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class ConsultantsStateError implements ConsultantsState {
|
||||
const factory ConsultantsStateError({required final String errorMessage}) =
|
||||
_$ConsultantsStateErrorImpl;
|
||||
|
||||
String get errorMessage;
|
||||
|
||||
/// Create a copy of ConsultantsState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ConsultantsStateErrorImplCopyWith<_$ConsultantsStateErrorImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import 'package:eatvio_app/core/widgets/custom_search_bar.dart';
|
||||
import 'package:eatvio_app/features/create_diet/presentation/create_diet_screen.dart';
|
||||
import 'package:eatvio_app/core/widgets/loader.dart';
|
||||
import 'package:eatvio_app/features/create_plan/presentation/create_plan_screen.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/consultants_cubit/consultants_cubit.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/consultants_cubit/consultants_state.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_cubit.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_state.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart';
|
||||
@@ -14,6 +16,7 @@ import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_state.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/blog_post_widget.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/choice_chip_widget.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/consultant_widget.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/diet_filter_bottom_sheet.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/diets_widget.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/widgets/filter_badge.dart';
|
||||
@@ -43,6 +46,7 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
final RecipesCubit recipesCubit = sl<RecipesCubit>()..loadRecipesList();
|
||||
final DietsCubit dietsCubit = sl<DietsCubit>()..loadDiets();
|
||||
final PlansCubit plansCubit = sl<PlansCubit>()..loadPlans();
|
||||
final ConsultantsCubit consultantsCubit = sl<ConsultantsCubit>()..getConsultants();
|
||||
|
||||
final searchController = TextEditingController();
|
||||
final List<String> chipsLabelList = ['Все', 'Рецепты', 'Диеты', 'Планы питания', 'Консультанты'];
|
||||
@@ -51,6 +55,7 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
final recipesScrollController = ScrollController();
|
||||
final dietsScrollController = ScrollController();
|
||||
final plansScrollController = ScrollController();
|
||||
final consultantsScrollController = ScrollController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -59,6 +64,7 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
recipesScrollController.addListener(_onScrollRecipes);
|
||||
dietsScrollController.addListener(_onScrollDiets);
|
||||
plansScrollController.addListener(_onScrollPlans);
|
||||
consultantsScrollController.addListener(_onScrollConsultants);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@@ -86,6 +92,10 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
_onScrollConsultants() {
|
||||
if (consultantsScrollController.offset >= consultantsScrollController.position.maxScrollExtent && !consultantsScrollController.position.outOfRange) {}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
blogPostsScrollController.dispose();
|
||||
@@ -111,6 +121,9 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
BlocProvider<PlansCubit>(
|
||||
create: (context) => sl<PlansCubit>()..loadPlans(),
|
||||
),
|
||||
BlocProvider<ConsultantsCubit>(
|
||||
create: (context) => sl<ConsultantsCubit>()..getConsultants(),
|
||||
),
|
||||
],
|
||||
child: Scaffold(
|
||||
floatingActionButton: _selectedChipIndex == 1
|
||||
@@ -145,6 +158,7 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
1 => recipesScrollController,
|
||||
2 => dietsScrollController,
|
||||
3 => plansScrollController,
|
||||
4 => consultantsScrollController,
|
||||
_ => blogPostsScrollController
|
||||
},
|
||||
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||
@@ -186,6 +200,9 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
case 3:
|
||||
plansCubit.loadPlans(query: query);
|
||||
break;
|
||||
case 4:
|
||||
consultantsCubit.getConsultants();
|
||||
break;
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -207,6 +224,9 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
case 3:
|
||||
plansCubit.loadPlans();
|
||||
break;
|
||||
case 4:
|
||||
consultantsCubit.getConsultants();
|
||||
break;
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -238,6 +258,7 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
1 => _buildAllRecipes(),
|
||||
2 => _buildDiets(),
|
||||
3 => _buildPlans(),
|
||||
4 => _buildConsultants(),
|
||||
_ => Center(child: Text(chipsLabelList[_selectedChipIndex])),
|
||||
},
|
||||
),
|
||||
@@ -287,6 +308,56 @@ class _FeedScreenState extends State<FeedScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
_buildConsultants() {
|
||||
return RefreshIndicator(
|
||||
onRefresh: () => consultantsCubit.getConsultants(),
|
||||
child: BlocBuilder<ConsultantsCubit, ConsultantsState>(
|
||||
bloc: consultantsCubit,
|
||||
builder: (BuildContext context, ConsultantsState state) {
|
||||
if (state is ConsultantsStateLoaded) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: Material(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: ListView.separated(
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
shrinkWrap: true,
|
||||
physics: BouncingScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
return ConsultantWidget(consultant: state.consultantsList[index]);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return SizedBox(height: 12);
|
||||
},
|
||||
itemCount: state.consultantsList.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (state is ConsultantsStateError) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey.shade200,
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Center(
|
||||
child: Text(state.errorMessage),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey.shade200,
|
||||
body: const Loader(),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_buildAllRecipes() {
|
||||
return RefreshIndicator(
|
||||
onRefresh: () => recipesCubit.loadRecipesList(),
|
||||
|
||||
@@ -207,11 +207,15 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
|
||||
'assets/icons/share.svg',
|
||||
colorFilter: ColorFilter.mode(appTheme.gray600, BlendMode.srcIn),
|
||||
),
|
||||
onTap: () => Share.shareUri(
|
||||
Uri.parse(
|
||||
baseUrl + '/ru/blog_post/' + state.feedBlogPostList[widget.index].id.toString(),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
Share.shareUri(
|
||||
Uri.parse(
|
||||
baseUrl + '/ru/blog_post/' + state.feedBlogPostList[widget.index].id.toString(),
|
||||
),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
);
|
||||
},
|
||||
),
|
||||
Spacer(),
|
||||
Icon(
|
||||
|
||||
138
lib/features/feed/presentation/widgets/consultant_widget.dart
Normal file
138
lib/features/feed/presentation/widgets/consultant_widget.dart
Normal file
@@ -0,0 +1,138 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:eatvio_app/core/const.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/feed_consultant_model.dart';
|
||||
import 'package:eatvio_app/features/profile/models/badge_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class ConsultantWidget extends StatelessWidget {
|
||||
final FeedConsultantModel consultant;
|
||||
|
||||
const ConsultantWidget({
|
||||
super.key,
|
||||
required this.consultant,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
GoRouter.of(context).pushNamed(
|
||||
'profileScreen',
|
||||
extra: Author(
|
||||
authorSlug: consultant.slug,
|
||||
authorName: consultant.name,
|
||||
authorProfileIcon: consultant.photo,
|
||||
authorIsMe: false,
|
||||
),
|
||||
);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Ink(
|
||||
padding: EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
color: Color(0xFFF6F6F6),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Ink(
|
||||
padding: EdgeInsets.symmetric(vertical: 4, horizontal: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
'${consultant.ratingPlace}',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: appTheme.blueA400,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
CircleAvatar(
|
||||
foregroundImage: NetworkImage(consultant.photo),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
consultant.name,
|
||||
style: TextStyle(
|
||||
height: 1,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 15,
|
||||
color: Color(0xFF323F4B),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'Рейтинг: RATING',
|
||||
style: TextStyle(
|
||||
color: appTheme.blueA400,
|
||||
height: 1,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Ink(
|
||||
padding: EdgeInsets.all(6),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
color: Colors.white,
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
'assets/icons/go_to_arrow.svg',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text('description'),
|
||||
if (consultant.badges.isNotEmpty) const SizedBox(height: 8),
|
||||
_badges(consultant.badges, context),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_badges(List<BadgeModel> badges, BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
for (int i = 0; i < badges.length; i++) ...[
|
||||
badges[i].image.contains('svg')
|
||||
? SvgPicture.network(
|
||||
baseUrl + '/storage/' + badges[i].image,
|
||||
width: 28,
|
||||
height: 28,
|
||||
)
|
||||
: CachedNetworkImage(
|
||||
imageUrl: baseUrl + '/storage/' + badges[i].image,
|
||||
),
|
||||
i < badges.length - 1 ? const SizedBox(width: 8) : const SizedBox.shrink(),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -144,10 +144,12 @@ class _DietsWidgetState extends State<DietsWidget> {
|
||||
FeedIconButton(
|
||||
svgIcon: SvgPicture.asset('assets/icons/repost.svg'),
|
||||
onTap: () async {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
final result = await Share.shareUri(
|
||||
Uri.parse(
|
||||
baseUrl + '/ru/diet/' + widget.diet.id.toString(),
|
||||
),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
);
|
||||
switch (result.status) {
|
||||
case ShareResultStatus.success:
|
||||
|
||||
@@ -201,10 +201,12 @@ class _PlanWidgetState extends State<PlanWidget> {
|
||||
FeedIconButton(
|
||||
svgIcon: SvgPicture.asset('assets/icons/repost.svg'),
|
||||
onTap: () async {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
final result = await Share.shareUri(
|
||||
Uri.parse(
|
||||
baseUrl + '/ru/diet/' + widget.plan.id.toString(),
|
||||
),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
);
|
||||
switch (result.status) {
|
||||
case ShareResultStatus.success:
|
||||
|
||||
@@ -21,6 +21,14 @@ class RecipesWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _RecipesWidgetState extends State<RecipesWidget> {
|
||||
late bool isLiked;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
isLiked = false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
@@ -143,11 +151,15 @@ class _RecipesWidgetState extends State<RecipesWidget> {
|
||||
'assets/icons/share.svg',
|
||||
colorFilter: ColorFilter.mode(appTheme.gray600, BlendMode.srcIn),
|
||||
),
|
||||
onTap: () => Share.shareUri(
|
||||
Uri.parse(
|
||||
baseUrl + '/ru/blog_post/' + widget.recipes.id.toString(),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
Share.shareUri(
|
||||
Uri.parse(
|
||||
baseUrl + '/ru/blog_post/' + widget.recipes.id.toString(),
|
||||
),
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
);
|
||||
},
|
||||
),
|
||||
Spacer(),
|
||||
Icon(
|
||||
|
||||
Reference in New Issue
Block a user