feat: recipe like

This commit is contained in:
BLoC
2025-01-24 14:34:55 +03:00
parent 394e6d8bbf
commit ae7c72cd53
19 changed files with 1117 additions and 1504 deletions

2
.gitignore vendored
View File

@@ -7,3 +7,5 @@
/.flutter-plugins-dependencies /.flutter-plugins-dependencies
/.packages /.packages
/node_modules/ /node_modules/
/android/app/release/app-release.aab
/android/app/upload-keystore.jks

View File

@@ -9,11 +9,7 @@ part of 'ws_service.dart';
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _WsService implements WsService { class _WsService implements WsService {
_WsService( _WsService(this._dio, {this.baseUrl, this.errorLogger});
this._dio, {
this.baseUrl,
this.errorLogger,
});
final Dio _dio; final Dio _dio;
@@ -27,22 +23,16 @@ class _WsService implements WsService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<WebsocketInfoModel>(Options( final _options = _setStreamType<WebsocketInfoModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/profile/ws/params',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/profile/ws/params', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late WebsocketInfoModel _value; late WebsocketInfoModel _value;
try { try {
@@ -67,10 +57,7 @@ class _WsService implements WsService {
return requestOptions; return requestOptions;
} }
String _combineBaseUrls( String _combineBaseUrls(String dioBaseUrl, String? baseUrl) {
String dioBaseUrl,
String? baseUrl,
) {
if (baseUrl == null || baseUrl.trim().isEmpty) { if (baseUrl == null || baseUrl.trim().isEmpty) {
return dioBaseUrl; return dioBaseUrl;
} }

View File

@@ -9,11 +9,7 @@ part of 'chat_service.dart';
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _ChatService implements ChatService { class _ChatService implements ChatService {
_ChatService( _ChatService(this._dio, {this.baseUrl, this.errorLogger});
this._dio, {
this.baseUrl,
this.errorLogger,
});
final Dio _dio; final Dio _dio;
@@ -28,22 +24,16 @@ class _ChatService implements ChatService {
queryParameters.removeWhere((k, v) => v == null); queryParameters.removeWhere((k, v) => v == null);
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<ChatRoomPreviewModel>(Options( final _options = _setStreamType<ChatRoomPreviewModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/chat/index',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/chat/index', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late ChatRoomPreviewModel _value; late ChatRoomPreviewModel _value;
try { try {
@@ -61,27 +51,23 @@ class _ChatService implements ChatService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<Map<String, ChatRoomModel>>(Options( final _options = _setStreamType<Map<String, ChatRoomModel>>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/chat/show/${id}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/chat/show/${id}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late Map<String, ChatRoomModel> _value; late Map<String, ChatRoomModel> _value;
try { try {
_value = _result.data!.map((k, dynamic v) => _value = _result.data!.map(
MapEntry(k, ChatRoomModel.fromJson(v as Map<String, dynamic>))); (k, dynamic v) =>
MapEntry(k, ChatRoomModel.fromJson(v as Map<String, dynamic>)),
);
} on Object catch (e, s) { } on Object catch (e, s) {
errorLogger?.logError(e, s, _options); errorLogger?.logError(e, s, _options);
rethrow; rethrow;
@@ -101,31 +87,26 @@ class _ChatService implements ChatService {
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
final _data = FormData(); final _data = FormData();
if (data != null) { if (data != null) {
_data.fields.add(MapEntry( _data.fields.add(MapEntry('data', data));
'data',
data,
));
} }
if (media_data != null) { if (media_data != null) {
_data.files.addAll(media_data.map((i) => MapEntry('media_data[]', i))); _data.files.addAll(media_data.map((i) => MapEntry('media_data[]', i)));
} }
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(
headers: _headers, method: 'POST',
extra: _extra, headers: _headers,
contentType: 'multipart/form-data', extra: _extra,
) contentType: 'multipart/form-data',
.compose( )
_dio.options, .compose(
'/api/chat/${id}/message/send', _dio.options,
queryParameters: queryParameters, '/api/chat/${id}/message/send',
data: _data, queryParameters: queryParameters,
) data: _data,
.copyWith( )
baseUrl: _combineBaseUrls( .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
_dio.options.baseUrl, );
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -138,22 +119,16 @@ class _ChatService implements ChatService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<ChatMessagesModel>(Options( final _options = _setStreamType<ChatMessagesModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/chat/show/${id}/messages?page=${page}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/chat/show/${id}/messages?page=${page}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late ChatMessagesModel _value; late ChatMessagesModel _value;
try { try {
@@ -171,22 +146,16 @@ class _ChatService implements ChatService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<ChatRoomModel>(Options( final _options = _setStreamType<ChatRoomModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/chat/get_by_user/${user}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/chat/get_by_user/${user}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late ChatRoomModel _value; late ChatRoomModel _value;
try { try {
@@ -211,10 +180,7 @@ class _ChatService implements ChatService {
return requestOptions; return requestOptions;
} }
String _combineBaseUrls( String _combineBaseUrls(String dioBaseUrl, String? baseUrl) {
String dioBaseUrl,
String? baseUrl,
) {
if (baseUrl == null || baseUrl.trim().isEmpty) { if (baseUrl == null || baseUrl.trim().isEmpty) {
return dioBaseUrl; return dioBaseUrl;
} }

View File

@@ -9,11 +9,7 @@ part of 'diet_service.dart';
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _DietService implements DietService { class _DietService implements DietService {
_DietService( _DietService(this._dio, {this.baseUrl, this.errorLogger});
this._dio, {
this.baseUrl,
this.errorLogger,
});
final Dio _dio; final Dio _dio;
@@ -27,22 +23,16 @@ class _DietService implements DietService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<DietLikesModel>(Options( final _options = _setStreamType<DietLikesModel>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/diets/${id}/like',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/diets/${id}/like', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late DietLikesModel _value; late DietLikesModel _value;
try { try {
@@ -60,22 +50,16 @@ class _DietService implements DietService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<Diet>(Options( final _options = _setStreamType<Diet>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/diets/${id}/add_to_favorite',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/diets/${id}/add_to_favorite', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late Diet _value; late Diet _value;
try { try {
@@ -93,22 +77,16 @@ class _DietService implements DietService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<Diet>(Options( final _options = _setStreamType<Diet>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/diets/${id}/remove_from_favorite',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/diets/${id}/remove_from_favorite', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late Diet _value; late Diet _value;
try { try {
@@ -126,22 +104,16 @@ class _DietService implements DietService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<Diet>(Options( final _options = _setStreamType<Diet>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/diets/show/${id}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/diets/show/${id}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late Diet _value; late Diet _value;
try { try {
@@ -163,22 +135,16 @@ class _DietService implements DietService {
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
final _data = <String, dynamic>{}; final _data = <String, dynamic>{};
_data.addAll(body); _data.addAll(body);
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/diets/${id}/start',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/diets/${id}/start', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -188,22 +154,16 @@ class _DietService implements DietService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/diets/${id}/cancel',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/diets/${id}/cancel', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -220,10 +180,7 @@ class _DietService implements DietService {
return requestOptions; return requestOptions;
} }
String _combineBaseUrls( String _combineBaseUrls(String dioBaseUrl, String? baseUrl) {
String dioBaseUrl,
String? baseUrl,
) {
if (baseUrl == null || baseUrl.trim().isEmpty) { if (baseUrl == null || baseUrl.trim().isEmpty) {
return dioBaseUrl; return dioBaseUrl;
} }

View File

@@ -18,7 +18,7 @@ class FeedBlogPostModel with _$FeedBlogPostModel {
required String title, required String title,
@JsonKey(name: "total_likes") required int totalLikes, @JsonKey(name: "total_likes") required int totalLikes,
@JsonKey(name: "total_views") required int totalViews, @JsonKey(name: "total_views") required int totalViews,
@JsonKey(name: "total_comments") int? totalComments, @JsonKey(name: "total_comments") required int totalComments,
@JsonKey(name: "was_liked_by_me") required bool wasLikedByMe, @JsonKey(name: "was_liked_by_me") required bool wasLikedByMe,
}) = _FeedBlogPostModel; }) = _FeedBlogPostModel;

View File

@@ -37,7 +37,7 @@ mixin _$FeedBlogPostModel {
@JsonKey(name: "total_views") @JsonKey(name: "total_views")
int get totalViews => throw _privateConstructorUsedError; int get totalViews => throw _privateConstructorUsedError;
@JsonKey(name: "total_comments") @JsonKey(name: "total_comments")
int? get totalComments => throw _privateConstructorUsedError; int get totalComments => throw _privateConstructorUsedError;
@JsonKey(name: "was_liked_by_me") @JsonKey(name: "was_liked_by_me")
bool get wasLikedByMe => throw _privateConstructorUsedError; bool get wasLikedByMe => throw _privateConstructorUsedError;
@@ -69,7 +69,7 @@ abstract class $FeedBlogPostModelCopyWith<$Res> {
String title, String title,
@JsonKey(name: "total_likes") int totalLikes, @JsonKey(name: "total_likes") int totalLikes,
@JsonKey(name: "total_views") int totalViews, @JsonKey(name: "total_views") int totalViews,
@JsonKey(name: "total_comments") int? totalComments, @JsonKey(name: "total_comments") int totalComments,
@JsonKey(name: "was_liked_by_me") bool wasLikedByMe}); @JsonKey(name: "was_liked_by_me") bool wasLikedByMe});
$AuthorCopyWith<$Res> get author; $AuthorCopyWith<$Res> get author;
@@ -101,7 +101,7 @@ class _$FeedBlogPostModelCopyWithImpl<$Res, $Val extends FeedBlogPostModel>
Object? title = null, Object? title = null,
Object? totalLikes = null, Object? totalLikes = null,
Object? totalViews = null, Object? totalViews = null,
Object? totalComments = freezed, Object? totalComments = null,
Object? wasLikedByMe = null, Object? wasLikedByMe = null,
}) { }) {
return _then(_value.copyWith( return _then(_value.copyWith(
@@ -149,10 +149,10 @@ class _$FeedBlogPostModelCopyWithImpl<$Res, $Val extends FeedBlogPostModel>
? _value.totalViews ? _value.totalViews
: totalViews // ignore: cast_nullable_to_non_nullable : totalViews // ignore: cast_nullable_to_non_nullable
as int, as int,
totalComments: freezed == totalComments totalComments: null == totalComments
? _value.totalComments ? _value.totalComments
: totalComments // ignore: cast_nullable_to_non_nullable : totalComments // ignore: cast_nullable_to_non_nullable
as int?, as int,
wasLikedByMe: null == wasLikedByMe wasLikedByMe: null == wasLikedByMe
? _value.wasLikedByMe ? _value.wasLikedByMe
: wasLikedByMe // ignore: cast_nullable_to_non_nullable : wasLikedByMe // ignore: cast_nullable_to_non_nullable
@@ -191,7 +191,7 @@ abstract class _$$FeedBlogPostModelImplCopyWith<$Res>
String title, String title,
@JsonKey(name: "total_likes") int totalLikes, @JsonKey(name: "total_likes") int totalLikes,
@JsonKey(name: "total_views") int totalViews, @JsonKey(name: "total_views") int totalViews,
@JsonKey(name: "total_comments") int? totalComments, @JsonKey(name: "total_comments") int totalComments,
@JsonKey(name: "was_liked_by_me") bool wasLikedByMe}); @JsonKey(name: "was_liked_by_me") bool wasLikedByMe});
@override @override
@@ -222,7 +222,7 @@ class __$$FeedBlogPostModelImplCopyWithImpl<$Res>
Object? title = null, Object? title = null,
Object? totalLikes = null, Object? totalLikes = null,
Object? totalViews = null, Object? totalViews = null,
Object? totalComments = freezed, Object? totalComments = null,
Object? wasLikedByMe = null, Object? wasLikedByMe = null,
}) { }) {
return _then(_$FeedBlogPostModelImpl( return _then(_$FeedBlogPostModelImpl(
@@ -270,10 +270,10 @@ class __$$FeedBlogPostModelImplCopyWithImpl<$Res>
? _value.totalViews ? _value.totalViews
: totalViews // ignore: cast_nullable_to_non_nullable : totalViews // ignore: cast_nullable_to_non_nullable
as int, as int,
totalComments: freezed == totalComments totalComments: null == totalComments
? _value.totalComments ? _value.totalComments
: totalComments // ignore: cast_nullable_to_non_nullable : totalComments // ignore: cast_nullable_to_non_nullable
as int?, as int,
wasLikedByMe: null == wasLikedByMe wasLikedByMe: null == wasLikedByMe
? _value.wasLikedByMe ? _value.wasLikedByMe
: wasLikedByMe // ignore: cast_nullable_to_non_nullable : wasLikedByMe // ignore: cast_nullable_to_non_nullable
@@ -297,7 +297,7 @@ class _$FeedBlogPostModelImpl implements _FeedBlogPostModel {
required this.title, required this.title,
@JsonKey(name: "total_likes") required this.totalLikes, @JsonKey(name: "total_likes") required this.totalLikes,
@JsonKey(name: "total_views") required this.totalViews, @JsonKey(name: "total_views") required this.totalViews,
@JsonKey(name: "total_comments") this.totalComments, @JsonKey(name: "total_comments") required this.totalComments,
@JsonKey(name: "was_liked_by_me") required this.wasLikedByMe}); @JsonKey(name: "was_liked_by_me") required this.wasLikedByMe});
factory _$FeedBlogPostModelImpl.fromJson(Map<String, dynamic> json) => factory _$FeedBlogPostModelImpl.fromJson(Map<String, dynamic> json) =>
@@ -332,7 +332,7 @@ class _$FeedBlogPostModelImpl implements _FeedBlogPostModel {
final int totalViews; final int totalViews;
@override @override
@JsonKey(name: "total_comments") @JsonKey(name: "total_comments")
final int? totalComments; final int totalComments;
@override @override
@JsonKey(name: "was_liked_by_me") @JsonKey(name: "was_liked_by_me")
final bool wasLikedByMe; final bool wasLikedByMe;
@@ -420,7 +420,7 @@ abstract class _FeedBlogPostModel implements FeedBlogPostModel {
required final String title, required final String title,
@JsonKey(name: "total_likes") required final int totalLikes, @JsonKey(name: "total_likes") required final int totalLikes,
@JsonKey(name: "total_views") required final int totalViews, @JsonKey(name: "total_views") required final int totalViews,
@JsonKey(name: "total_comments") final int? totalComments, @JsonKey(name: "total_comments") required final int totalComments,
@JsonKey(name: "was_liked_by_me") required final bool wasLikedByMe}) = @JsonKey(name: "was_liked_by_me") required final bool wasLikedByMe}) =
_$FeedBlogPostModelImpl; _$FeedBlogPostModelImpl;
@@ -456,7 +456,7 @@ abstract class _FeedBlogPostModel implements FeedBlogPostModel {
int get totalViews; int get totalViews;
@override @override
@JsonKey(name: "total_comments") @JsonKey(name: "total_comments")
int? get totalComments; int get totalComments;
@override @override
@JsonKey(name: "was_liked_by_me") @JsonKey(name: "was_liked_by_me")
bool get wasLikedByMe; bool get wasLikedByMe;

View File

@@ -20,7 +20,7 @@ _$FeedBlogPostModelImpl _$$FeedBlogPostModelImplFromJson(
title: json['title'] as String, title: json['title'] as String,
totalLikes: (json['total_likes'] as num).toInt(), totalLikes: (json['total_likes'] as num).toInt(),
totalViews: (json['total_views'] as num).toInt(), totalViews: (json['total_views'] as num).toInt(),
totalComments: (json['total_comments'] as num?)?.toInt(), totalComments: (json['total_comments'] as num).toInt(),
wasLikedByMe: json['was_liked_by_me'] as bool, wasLikedByMe: json['was_liked_by_me'] as bool,
); );

View File

@@ -84,4 +84,8 @@ class RecipesCubit extends Cubit<RecipesState> {
), ),
); );
} }
likeRecipe(String slug) async => await feedRepository.likeRecipe(slug: slug);
unlikeRecipe(String slug) async => await feedRepository.unlikeRecipe(slug: slug);
} }

View File

@@ -20,7 +20,10 @@ class Recipes extends StatelessWidget {
shrinkWrap: true, shrinkWrap: true,
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
itemBuilder: (context, index) { itemBuilder: (context, index) {
return RecipesWidget(recipes: state.recipesList[index]); return RecipesWidget(
recipes: state.recipesList[index],
index: index,
);
}, },
separatorBuilder: (context, index) { separatorBuilder: (context, index) {
return SizedBox(height: 8); return SizedBox(height: 8);
@@ -47,4 +50,4 @@ class Recipes extends StatelessWidget {
), ),
); );
} }
} }

View File

@@ -5,16 +5,24 @@ import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/widgets/feed_icon_button.dart'; import 'package:eatvio_app/core/widgets/feed_icon_button.dart';
import 'package:eatvio_app/features/feed/models/recipes_model.dart'; import 'package:eatvio_app/features/feed/models/recipes_model.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_cubit.dart';
import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_state.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:share_plus/share_plus.dart'; import 'package:share_plus/share_plus.dart';
class RecipesWidget extends StatefulWidget { class RecipesWidget extends StatefulWidget {
final int index;
final Recipes recipes; final Recipes recipes;
const RecipesWidget({super.key, required this.recipes}); const RecipesWidget({
super.key,
required this.recipes,
required this.index,
});
@override @override
State<RecipesWidget> createState() => _RecipesWidgetState(); State<RecipesWidget> createState() => _RecipesWidgetState();
@@ -22,6 +30,7 @@ class RecipesWidget extends StatefulWidget {
class _RecipesWidgetState extends State<RecipesWidget> { class _RecipesWidgetState extends State<RecipesWidget> {
late bool isLiked; late bool isLiked;
late int totalLikes;
@override @override
void initState() { void initState() {
@@ -31,158 +40,167 @@ class _RecipesWidgetState extends State<RecipesWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return InkWell( return BlocBuilder<RecipesCubit, RecipesState>(
borderRadius: BorderRadius.circular(12), builder: (BuildContext context, RecipesState state) {
onTap: () => GoRouter.of(context).pushNamed('aboutRecipesScreen', extra: widget.recipes), if (state is RecipesStateLoaded) {
child: Ink( isLiked = state.recipesList[widget.index].wasLikedByMe;
decoration: BoxDecoration( totalLikes = state.recipesList[widget.index].likesCount;
borderRadius: BorderRadius.circular(12), return InkWell(
color: Colors.white, borderRadius: BorderRadius.circular(12),
), onTap: () => GoRouter.of(context).pushNamed('aboutRecipesScreen', extra: widget.recipes),
child: Column( child: Ink(
mainAxisSize: MainAxisSize.min, decoration: BoxDecoration(
crossAxisAlignment: CrossAxisAlignment.start, borderRadius: BorderRadius.circular(12),
children: [ color: Colors.white,
Stack( ),
children: [ child: Column(
ClipRRect( mainAxisSize: MainAxisSize.min,
borderRadius: BorderRadius.vertical(top: Radius.circular(12)), crossAxisAlignment: CrossAxisAlignment.start,
child: CachedNetworkImage( children: [
imageUrl: baseUrl + '/storage/' + widget.recipes.image, Stack(
fit: BoxFit.fitWidth,
width: MediaQuery.of(context).size.width,
),
),
Positioned(
left: 8,
bottom: 8,
child: Wrap(
runSpacing: 8,
children: [ children: [
_iconButton('assets/icons/clock.svg', widget.recipes.cookingTime.toString() + ' минут'), ClipRRect(
SizedBox(width: 8), borderRadius: BorderRadius.vertical(top: Radius.circular(12)),
_iconButton('assets/icons/steps.svg', widget.recipes.steps.length.toString() + ' этапов'), child: CachedNetworkImage(
SizedBox(width: 8), imageUrl: baseUrl + '/storage/' + widget.recipes.image,
_iconButton('assets/icons/calories.svg', '139.9 ккал'), fit: BoxFit.fitWidth,
width: MediaQuery.of(context).size.width,
),
),
Positioned(
left: 8,
bottom: 8,
child: Wrap(
runSpacing: 8,
children: [
_iconButton('assets/icons/clock.svg', widget.recipes.cookingTime.toString() + ' минут'),
SizedBox(width: 8),
_iconButton('assets/icons/steps.svg', widget.recipes.steps.length.toString() + ' этапов'),
SizedBox(width: 8),
_iconButton('assets/icons/calories.svg', widget.recipes.calories.toStringAsFixed(0) + ' ккал'),
],
),
),
], ],
), ),
), SizedBox(height: 12),
], Padding(
), padding: const EdgeInsets.symmetric(horizontal: 12),
SizedBox(height: 12), child: Text(
Padding( widget.recipes.title,
padding: const EdgeInsets.symmetric(horizontal: 12), style: TextStyle(
child: Text( fontWeight: FontWeight.w600,
widget.recipes.title, color: Colors.black87,
style: TextStyle(
fontWeight: FontWeight.w600,
color: Colors.black87,
),
),
),
if (widget.recipes.description.isNotEmpty)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Html(
data: widget.recipes.description.length > 200 ? widget.recipes.description.substring(0, 200) : widget.recipes.description,
style: {
"*": Style(
color: Colors.black87,
),
},
),
),
if (widget.recipes.description.length > 200)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
'Читать полностью...',
style: TextStyle(
height: 1,
color: appTheme.blueA400,
decoration: TextDecoration.underline,
),
),
),
SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
children: [
FeedIconButton(
icon: true ? Icons.favorite_rounded : Icons.favorite_border_rounded,
text: widget.recipes.likesCount.toString(),
iconColor: true ? Colors.red.withValues(alpha: 0.8) : null,
backgroundColor: true ? Colors.red.withValues(alpha: 0.1) : null,
textColor: true ? Colors.red.withValues(alpha: 0.8) : null,
onTap: () async {
// setState(() {
// isLiked = !isLiked;
// isLiked ? totalLikes++ : totalLikes--;
// });
// isLiked
// ? await context.read<FeedCubit>().likePost(state.feedBlogPostList[widget.index].id)
// : await context.read<FeedCubit>().unlikedPost(state.feedBlogPostList[widget.index].id);
// await context.read<FeedCubit>().loadFeedBlogPostList();
},
),
SizedBox(width: 8),
FeedIconButton(
svgIcon: SvgPicture.asset(
'assets/icons/comment.svg',
height: 20,
width: 20,
colorFilter: ColorFilter.mode(
appTheme.gray600,
BlendMode.srcIn,
), ),
), ),
text: widget.recipes.commentsCount.toString(),
onTap: () => GoRouter.of(context).pushNamed(
'aboutRecipesScreen',
extra: widget.recipes,
),
), ),
SizedBox(width: 8), if (widget.recipes.description.isNotEmpty)
FeedIconButton( Padding(
svgIcon: SvgPicture.asset( padding: const EdgeInsets.symmetric(horizontal: 4),
height: 20, child: Html(
width: 20, data: widget.recipes.description.length > 200 ? widget.recipes.description.substring(0, 200) : widget.recipes.description,
'assets/icons/share.svg', style: {
colorFilter: ColorFilter.mode(appTheme.gray600, BlendMode.srcIn), "*": Style(
color: Colors.black87,
),
},
),
), ),
onTap: () { if (widget.recipes.description.length > 200)
final box = context.findRenderObject() as RenderBox?; Padding(
Share.shareUri( padding: const EdgeInsets.symmetric(horizontal: 16),
Uri.parse( child: Text(
baseUrl + '/ru/blog_post/' + widget.recipes.id.toString(), 'Читать полностью...',
style: TextStyle(
height: 1,
color: appTheme.blueA400,
decoration: TextDecoration.underline,
), ),
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, ),
); ),
}, SizedBox(height: 12),
), Padding(
Spacer(), padding: const EdgeInsets.symmetric(horizontal: 12),
Icon( child: Row(
Icons.visibility_rounded, children: [
size: 16, FeedIconButton(
color: appTheme.gray500, icon: isLiked ? Icons.favorite_rounded : Icons.favorite_border_rounded,
), text: widget.recipes.likesCount.toString(),
SizedBox(width: 4), iconColor: isLiked ? Colors.red.withValues(alpha: 0.8) : null,
Text( backgroundColor: isLiked ? Colors.red.withValues(alpha: 0.1) : null,
widget.recipes.viewsCount.toString(), textColor: isLiked ? Colors.red.withValues(alpha: 0.8) : null,
style: TextStyle( onTap: () async {
fontSize: 12, setState(() {
color: appTheme.gray500, isLiked = !isLiked;
fontWeight: FontWeight.w400, isLiked ? totalLikes++ : totalLikes--;
});
isLiked
? await context.read<RecipesCubit>().likeRecipe(state.recipesList[widget.index].slug)
: await context.read<RecipesCubit>().unlikeRecipe(state.recipesList[widget.index].slug);
await context.read<RecipesCubit>().loadRecipesList();
},
),
SizedBox(width: 8),
FeedIconButton(
svgIcon: SvgPicture.asset(
'assets/icons/comment.svg',
height: 20,
width: 20,
colorFilter: ColorFilter.mode(
appTheme.gray600,
BlendMode.srcIn,
),
),
text: widget.recipes.commentsCount.toString(),
onTap: () => GoRouter.of(context).pushNamed(
'aboutRecipesScreen',
extra: widget.recipes,
),
),
SizedBox(width: 8),
FeedIconButton(
svgIcon: SvgPicture.asset(
height: 20,
width: 20,
'assets/icons/share.svg',
colorFilter: ColorFilter.mode(appTheme.gray600, BlendMode.srcIn),
),
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(
Icons.visibility_rounded,
size: 16,
color: appTheme.gray500,
),
SizedBox(width: 4),
Text(
widget.recipes.viewsCount.toString(),
style: TextStyle(
fontSize: 12,
color: appTheme.gray500,
fontWeight: FontWeight.w400,
),
),
],
), ),
), ),
SizedBox(height: 12),
], ],
), ),
), ),
SizedBox(height: 12), );
], }
), return Container();
), },
); );
} }

View File

@@ -217,4 +217,24 @@ class FeedRepository {
rethrow; rethrow;
} }
} }
Future<void> likeRecipe({
required String slug,
}) async {
try {
await feedService.likeRecipe(slug: slug);
} catch (e) {
rethrow;
}
}
Future<void> unlikeRecipe({
required String slug,
}) async {
try {
await feedService.unlikeRecipe(slug: slug);
} catch (e) {
rethrow;
}
}
} }

View File

@@ -103,6 +103,16 @@ abstract class FeedService {
@Path() required int id, @Path() required int id,
}); });
@POST('/api/recipes/{slug}/like')
Future<void> likeRecipe({
@Path() required String slug,
});
@POST('/api/recipes/{slug}/unliked')
Future<void> unlikeRecipe({
@Path() required String slug,
});
@GET('/api/consultants/index') @GET('/api/consultants/index')
Future<FeedConsultantPaginationModel> getConsultants(); Future<FeedConsultantPaginationModel> getConsultants();
} }

View File

@@ -9,11 +9,7 @@ part of 'feed_service.dart';
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _FeedService implements FeedService { class _FeedService implements FeedService {
_FeedService( _FeedService(this._dio, {this.baseUrl, this.errorLogger});
this._dio, {
this.baseUrl,
this.errorLogger,
});
final Dio _dio; final Dio _dio;
@@ -34,22 +30,16 @@ class _FeedService implements FeedService {
queryParameters.removeWhere((k, v) => v == null); queryParameters.removeWhere((k, v) => v == null);
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<FeedBlogPostSettingsModel>(Options( final _options = _setStreamType<FeedBlogPostSettingsModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/blogPosts/index',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/blogPosts/index', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late FeedBlogPostSettingsModel _value; late FeedBlogPostSettingsModel _value;
try { try {
@@ -76,22 +66,16 @@ class _FeedService implements FeedService {
queryParameters.removeWhere((k, v) => v == null); queryParameters.removeWhere((k, v) => v == null);
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<RecipesPagination>(Options( final _options = _setStreamType<RecipesPagination>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/recipes/index',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/recipes/index', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late RecipesPagination _value; late RecipesPagination _value;
try { try {
@@ -122,22 +106,16 @@ class _FeedService implements FeedService {
queryParameters.removeWhere((k, v) => v == null); queryParameters.removeWhere((k, v) => v == null);
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<DietsPagination>(Options( final _options = _setStreamType<DietsPagination>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/diets/index',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/diets/index', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late DietsPagination _value; late DietsPagination _value;
try { try {
@@ -170,22 +148,16 @@ class _FeedService implements FeedService {
queryParameters.removeWhere((k, v) => v == null); queryParameters.removeWhere((k, v) => v == null);
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<PlanPaginationModel>(Options( final _options = _setStreamType<PlanPaginationModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/plans/index',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/plans/index', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late PlanPaginationModel _value; late PlanPaginationModel _value;
try { try {
@@ -203,22 +175,16 @@ class _FeedService implements FeedService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<CommentModel>(Options( final _options = _setStreamType<CommentModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/blogPosts/${id}/comments/show',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/blogPosts/${id}/comments/show', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late CommentModel _value; late CommentModel _value;
try { try {
@@ -241,32 +207,20 @@ class _FeedService implements FeedService {
queryParameters.removeWhere((k, v) => v == null); queryParameters.removeWhere((k, v) => v == null);
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
final _data = FormData(); final _data = FormData();
_data.fields.add(MapEntry( _data.fields.add(MapEntry('body', body));
'body',
body,
));
if (parentCommentId != null) { if (parentCommentId != null) {
_data.fields.add(MapEntry( _data.fields.add(MapEntry('parentCommentId', parentCommentId.toString()));
'parentCommentId',
parentCommentId.toString(),
));
} }
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/blogPosts/${id}/comment/create',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/blogPosts/${id}/comment/create', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -276,22 +230,16 @@ class _FeedService implements FeedService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<CommentModel>(Options( final _options = _setStreamType<CommentModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/diets/${id}/comments/show',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/diets/${id}/comments/show', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late CommentModel _value; late CommentModel _value;
try { try {
@@ -314,32 +262,20 @@ class _FeedService implements FeedService {
queryParameters.removeWhere((k, v) => v == null); queryParameters.removeWhere((k, v) => v == null);
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
final _data = FormData(); final _data = FormData();
_data.fields.add(MapEntry( _data.fields.add(MapEntry('body', body));
'body',
body,
));
if (parentCommentId != null) { if (parentCommentId != null) {
_data.fields.add(MapEntry( _data.fields.add(MapEntry('parentCommentId', parentCommentId.toString()));
'parentCommentId',
parentCommentId.toString(),
));
} }
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/diets/${id}/comment/create',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/diets/${id}/comment/create', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -349,22 +285,16 @@ class _FeedService implements FeedService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<CommentModel>(Options( final _options = _setStreamType<CommentModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/plans/${slug}/comments/show',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/plans/${slug}/comments/show', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late CommentModel _value; late CommentModel _value;
try { try {
@@ -387,32 +317,20 @@ class _FeedService implements FeedService {
queryParameters.removeWhere((k, v) => v == null); queryParameters.removeWhere((k, v) => v == null);
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
final _data = FormData(); final _data = FormData();
_data.fields.add(MapEntry( _data.fields.add(MapEntry('body', body));
'body',
body,
));
if (parentCommentId != null) { if (parentCommentId != null) {
_data.fields.add(MapEntry( _data.fields.add(MapEntry('parentCommentId', parentCommentId.toString()));
'parentCommentId',
parentCommentId.toString(),
));
} }
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/plans/${slug}/comment/create',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/plans/${slug}/comment/create', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -422,22 +340,16 @@ class _FeedService implements FeedService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<CommentModel>(Options( final _options = _setStreamType<CommentModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/recipes/${id}/comments/show',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/recipes/${id}/comments/show', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late CommentModel _value; late CommentModel _value;
try { try {
@@ -460,32 +372,20 @@ class _FeedService implements FeedService {
queryParameters.removeWhere((k, v) => v == null); queryParameters.removeWhere((k, v) => v == null);
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
final _data = FormData(); final _data = FormData();
_data.fields.add(MapEntry( _data.fields.add(MapEntry('body', body));
'body',
body,
));
if (parentCommentId != null) { if (parentCommentId != null) {
_data.fields.add(MapEntry( _data.fields.add(MapEntry('parentCommentId', parentCommentId.toString()));
'parentCommentId',
parentCommentId.toString(),
));
} }
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/recipes/${id}/comment/create',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/recipes/${id}/comment/create', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -495,22 +395,16 @@ class _FeedService implements FeedService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/blogPosts/${id}/like',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/blogPosts/${id}/like', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -520,22 +414,54 @@ class _FeedService implements FeedService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/blogPosts/${id}/unliked',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/blogPosts/${id}/unliked', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
) await _dio.fetch<void>(_options);
.copyWith( }
baseUrl: _combineBaseUrls(
_dio.options.baseUrl, @override
baseUrl, Future<void> likeRecipe({required String slug}) async {
))); final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _options = _setStreamType<void>(
Options(method: 'POST', headers: _headers, extra: _extra)
.compose(
_dio.options,
'/api/recipes/${slug}/like',
queryParameters: queryParameters,
data: _data,
)
.copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
);
await _dio.fetch<void>(_options);
}
@override
Future<void> unlikeRecipe({required String slug}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _options = _setStreamType<void>(
Options(method: 'POST', headers: _headers, extra: _extra)
.compose(
_dio.options,
'/api/recipes/${slug}/unliked',
queryParameters: queryParameters,
data: _data,
)
.copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
);
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -545,22 +471,16 @@ class _FeedService implements FeedService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<FeedConsultantPaginationModel>(Options( final _options = _setStreamType<FeedConsultantPaginationModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/consultants/index',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/consultants/index', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late FeedConsultantPaginationModel _value; late FeedConsultantPaginationModel _value;
try { try {
@@ -585,10 +505,7 @@ class _FeedService implements FeedService {
return requestOptions; return requestOptions;
} }
String _combineBaseUrls( String _combineBaseUrls(String dioBaseUrl, String? baseUrl) {
String dioBaseUrl,
String? baseUrl,
) {
if (baseUrl == null || baseUrl.trim().isEmpty) { if (baseUrl == null || baseUrl.trim().isEmpty) {
return dioBaseUrl; return dioBaseUrl;
} }

View File

@@ -9,11 +9,7 @@ part of 'my_diets_service.dart';
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _MyDietsService implements MyDietsService { class _MyDietsService implements MyDietsService {
_MyDietsService( _MyDietsService(this._dio, {this.baseUrl, this.errorLogger});
this._dio, {
this.baseUrl,
this.errorLogger,
});
final Dio _dio; final Dio _dio;
@@ -40,22 +36,16 @@ class _MyDietsService implements MyDietsService {
queryParameters.removeWhere((k, v) => v == null); queryParameters.removeWhere((k, v) => v == null);
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<DietsPagination>(Options( final _options = _setStreamType<DietsPagination>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/profile/my_diets',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/profile/my_diets', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late DietsPagination _value; late DietsPagination _value;
try { try {
@@ -73,22 +63,16 @@ class _MyDietsService implements MyDietsService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/diets/delete/${dietId}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/diets/delete/${dietId}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -105,10 +89,7 @@ class _MyDietsService implements MyDietsService {
return requestOptions; return requestOptions;
} }
String _combineBaseUrls( String _combineBaseUrls(String dioBaseUrl, String? baseUrl) {
String dioBaseUrl,
String? baseUrl,
) {
if (baseUrl == null || baseUrl.trim().isEmpty) { if (baseUrl == null || baseUrl.trim().isEmpty) {
return dioBaseUrl; return dioBaseUrl;
} }

View File

@@ -9,11 +9,7 @@ part of 'my_plans_service.dart';
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _MyPlansService implements MyPlansService { class _MyPlansService implements MyPlansService {
_MyPlansService( _MyPlansService(this._dio, {this.baseUrl, this.errorLogger});
this._dio, {
this.baseUrl,
this.errorLogger,
});
final Dio _dio; final Dio _dio;
@@ -42,22 +38,16 @@ class _MyPlansService implements MyPlansService {
queryParameters.removeWhere((k, v) => v == null); queryParameters.removeWhere((k, v) => v == null);
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<PlanPaginationModel>(Options( final _options = _setStreamType<PlanPaginationModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/plans/index',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/plans/index', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late PlanPaginationModel _value; late PlanPaginationModel _value;
try { try {
@@ -75,22 +65,16 @@ class _MyPlansService implements MyPlansService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/plans/delete/${slug}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/plans/delete/${slug}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -107,10 +91,7 @@ class _MyPlansService implements MyPlansService {
return requestOptions; return requestOptions;
} }
String _combineBaseUrls( String _combineBaseUrls(String dioBaseUrl, String? baseUrl) {
String dioBaseUrl,
String? baseUrl,
) {
if (baseUrl == null || baseUrl.trim().isEmpty) { if (baseUrl == null || baseUrl.trim().isEmpty) {
return dioBaseUrl; return dioBaseUrl;
} }

View File

@@ -9,11 +9,7 @@ part of 'plan_service.dart';
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _PlanService implements PlanService { class _PlanService implements PlanService {
_PlanService( _PlanService(this._dio, {this.baseUrl, this.errorLogger});
this._dio, {
this.baseUrl,
this.errorLogger,
});
final Dio _dio; final Dio _dio;
@@ -27,22 +23,16 @@ class _PlanService implements PlanService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<PlanModel>(Options( final _options = _setStreamType<PlanModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/plans/show/${slug}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/plans/show/${slug}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late PlanModel _value; late PlanModel _value;
try { try {
@@ -60,22 +50,16 @@ class _PlanService implements PlanService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/plans/${slug}/like',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/plans/${slug}/like', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -85,22 +69,16 @@ class _PlanService implements PlanService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/plans/${slug}/add_to_favorite',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/plans/${slug}/add_to_favorite', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -110,22 +88,16 @@ class _PlanService implements PlanService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/plans/${slug}/remove_from_favorite',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/plans/${slug}/remove_from_favorite', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -142,10 +114,7 @@ class _PlanService implements PlanService {
return requestOptions; return requestOptions;
} }
String _combineBaseUrls( String _combineBaseUrls(String dioBaseUrl, String? baseUrl) {
String dioBaseUrl,
String? baseUrl,
) {
if (baseUrl == null || baseUrl.trim().isEmpty) { if (baseUrl == null || baseUrl.trim().isEmpty) {
return dioBaseUrl; return dioBaseUrl;
} }

View File

@@ -9,11 +9,7 @@ part of 'plans_service.dart';
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _PlansService implements PlansService { class _PlansService implements PlansService {
_PlansService( _PlansService(this._dio, {this.baseUrl, this.errorLogger});
this._dio, {
this.baseUrl,
this.errorLogger,
});
final Dio _dio; final Dio _dio;
@@ -27,22 +23,16 @@ class _PlansService implements PlansService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<PlanPaginationModel>(Options( final _options = _setStreamType<PlanPaginationModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/plans/get_by_author/${author}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/plans/get_by_author/${author}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late PlanPaginationModel _value; late PlanPaginationModel _value;
try { try {
@@ -67,10 +57,7 @@ class _PlansService implements PlansService {
return requestOptions; return requestOptions;
} }
String _combineBaseUrls( String _combineBaseUrls(String dioBaseUrl, String? baseUrl) {
String dioBaseUrl,
String? baseUrl,
) {
if (baseUrl == null || baseUrl.trim().isEmpty) { if (baseUrl == null || baseUrl.trim().isEmpty) {
return dioBaseUrl; return dioBaseUrl;
} }

View File

@@ -9,11 +9,7 @@ part of 'profile_service.dart';
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _ProfileService implements ProfileService { class _ProfileService implements ProfileService {
_ProfileService( _ProfileService(this._dio, {this.baseUrl, this.errorLogger});
this._dio, {
this.baseUrl,
this.errorLogger,
});
final Dio _dio; final Dio _dio;
@@ -27,22 +23,16 @@ class _ProfileService implements ProfileService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<ProfileModel>(Options( final _options = _setStreamType<ProfileModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/profile/show/${slug}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/profile/show/${slug}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late ProfileModel _value; late ProfileModel _value;
try { try {
@@ -60,22 +50,16 @@ class _ProfileService implements ProfileService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<ProfileModel>(Options( final _options = _setStreamType<ProfileModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/profile/index',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/profile/index', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late ProfileModel _value; late ProfileModel _value;
try { try {
@@ -93,22 +77,16 @@ class _ProfileService implements ProfileService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<ProfileDetailsModel>(Options( final _options = _setStreamType<ProfileDetailsModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/profile/detailz',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/profile/detailz', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late ProfileDetailsModel _value; late ProfileDetailsModel _value;
try { try {
@@ -121,28 +99,23 @@ class _ProfileService implements ProfileService {
} }
@override @override
Future<ProfileDetailsModel> getProfileDetailsBySlug( Future<ProfileDetailsModel> getProfileDetailsBySlug({
{required String slug}) async { required String slug,
}) async {
final _extra = <String, dynamic>{}; final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<ProfileDetailsModel>(Options( final _options = _setStreamType<ProfileDetailsModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/profile/detailz/${slug}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/profile/detailz/${slug}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late ProfileDetailsModel _value; late ProfileDetailsModel _value;
try { try {
@@ -164,34 +137,25 @@ class _ProfileService implements ProfileService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
final _data = FormData(); final _data = FormData();
_data.fields.add(MapEntry( _data.fields.add(
'chest_circumference', MapEntry('chest_circumference', chestCircumference.toString()),
chestCircumference.toString(), );
)); _data.fields.add(
_data.fields.add(MapEntry( MapEntry('waist_circumference', waistCircumference.toString()),
'waist_circumference', );
waistCircumference.toString(), _data.fields.add(
)); MapEntry('hip_circumference', hipCircumference.toString()),
_data.fields.add(MapEntry( );
'hip_circumference', final _options = _setStreamType<void>(
hipCircumference.toString(), Options(method: 'POST', headers: _headers, extra: _extra)
)); .compose(
final _options = _setStreamType<void>(Options( _dio.options,
method: 'POST', '/api/profile/addCircumference',
headers: _headers, queryParameters: queryParameters,
extra: _extra, data: _data,
) )
.compose( .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
_dio.options, );
'/api/profile/addCircumference',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -201,58 +165,46 @@ class _ProfileService implements ProfileService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
final _data = FormData(); final _data = FormData();
_data.fields.add(MapEntry( _data.fields.add(MapEntry('weight', weight.toString()));
'weight', final _options = _setStreamType<void>(
weight.toString(), Options(method: 'POST', headers: _headers, extra: _extra)
)); .compose(
final _options = _setStreamType<void>(Options( _dio.options,
method: 'POST', '/api/profile/addWeight',
headers: _headers, queryParameters: queryParameters,
extra: _extra, data: _data,
) )
.compose( .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
_dio.options, );
'/api/profile/addWeight',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@override @override
Future<List<FeedBlogPostModel>> getBlogPostByAuthorSlug( Future<List<FeedBlogPostModel>> getBlogPostByAuthorSlug({
{required String slug}) async { required String slug,
}) async {
final _extra = <String, dynamic>{}; final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<List<FeedBlogPostModel>>(Options( final _options = _setStreamType<List<FeedBlogPostModel>>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/blogPosts/search_by_author/${slug}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/blogPosts/search_by_author/${slug}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<List<dynamic>>(_options); final _result = await _dio.fetch<List<dynamic>>(_options);
late List<FeedBlogPostModel> _value; late List<FeedBlogPostModel> _value;
try { try {
_value = _result.data! _value = _result.data!
.map((dynamic i) => .map(
FeedBlogPostModel.fromJson(i as Map<String, dynamic>)) (dynamic i) =>
FeedBlogPostModel.fromJson(i as Map<String, dynamic>),
)
.toList(); .toList();
} on Object catch (e, s) { } on Object catch (e, s) {
errorLogger?.logError(e, s, _options); errorLogger?.logError(e, s, _options);
@@ -267,27 +219,23 @@ class _ProfileService implements ProfileService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<List<WeightModel>>(Options( final _options = _setStreamType<List<WeightModel>>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/profile/measure/weight/${period}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/profile/measure/weight/${period}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<List<dynamic>>(_options); final _result = await _dio.fetch<List<dynamic>>(_options);
late List<WeightModel> _value; late List<WeightModel> _value;
try { try {
_value = _result.data! _value = _result.data!
.map((dynamic i) => WeightModel.fromJson(i as Map<String, dynamic>)) .map(
(dynamic i) => WeightModel.fromJson(i as Map<String, dynamic>),
)
.toList(); .toList();
} on Object catch (e, s) { } on Object catch (e, s) {
errorLogger?.logError(e, s, _options); errorLogger?.logError(e, s, _options);
@@ -305,27 +253,23 @@ class _ProfileService implements ProfileService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<List<WeightModel>>(Options( final _options = _setStreamType<List<WeightModel>>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/profile/measure/weight/${period}/${slug}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/profile/measure/weight/${period}/${slug}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<List<dynamic>>(_options); final _result = await _dio.fetch<List<dynamic>>(_options);
late List<WeightModel> _value; late List<WeightModel> _value;
try { try {
_value = _result.data! _value = _result.data!
.map((dynamic i) => WeightModel.fromJson(i as Map<String, dynamic>)) .map(
(dynamic i) => WeightModel.fromJson(i as Map<String, dynamic>),
)
.toList(); .toList();
} on Object catch (e, s) { } on Object catch (e, s) {
errorLogger?.logError(e, s, _options); errorLogger?.logError(e, s, _options);
@@ -335,34 +279,31 @@ class _ProfileService implements ProfileService {
} }
@override @override
Future<List<CircumferenceModel>> getCircumferences( Future<List<CircumferenceModel>> getCircumferences({
{required String period}) async { required String period,
}) async {
final _extra = <String, dynamic>{}; final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<List<CircumferenceModel>>(Options( final _options = _setStreamType<List<CircumferenceModel>>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/profile/measure/circumferences/${period}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/profile/measure/circumferences/${period}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<List<dynamic>>(_options); final _result = await _dio.fetch<List<dynamic>>(_options);
late List<CircumferenceModel> _value; late List<CircumferenceModel> _value;
try { try {
_value = _result.data! _value = _result.data!
.map((dynamic i) => .map(
CircumferenceModel.fromJson(i as Map<String, dynamic>)) (dynamic i) =>
CircumferenceModel.fromJson(i as Map<String, dynamic>),
)
.toList(); .toList();
} on Object catch (e, s) { } on Object catch (e, s) {
errorLogger?.logError(e, s, _options); errorLogger?.logError(e, s, _options);
@@ -380,28 +321,24 @@ class _ProfileService implements ProfileService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<List<CircumferenceModel>>(Options( final _options = _setStreamType<List<CircumferenceModel>>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/profile/measure/circumferences/${period}/{user}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/profile/measure/circumferences/${period}/{user}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<List<dynamic>>(_options); final _result = await _dio.fetch<List<dynamic>>(_options);
late List<CircumferenceModel> _value; late List<CircumferenceModel> _value;
try { try {
_value = _result.data! _value = _result.data!
.map((dynamic i) => .map(
CircumferenceModel.fromJson(i as Map<String, dynamic>)) (dynamic i) =>
CircumferenceModel.fromJson(i as Map<String, dynamic>),
)
.toList(); .toList();
} on Object catch (e, s) { } on Object catch (e, s) {
errorLogger?.logError(e, s, _options); errorLogger?.logError(e, s, _options);
@@ -417,27 +354,21 @@ class _ProfileService implements ProfileService {
}) async { }) async {
final _extra = <String, dynamic>{}; final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{ final queryParameters = <String, dynamic>{
r'filters[name][$startsWith]': query r'filters[name][$startsWith]': query,
}; };
queryParameters.removeWhere((k, v) => v == null); queryParameters.removeWhere((k, v) => v == null);
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<SubPaginationModel>(Options( final _options = _setStreamType<SubPaginationModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/profile/${slug}/subscribers',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/profile/${slug}/subscribers', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late SubPaginationModel _value; late SubPaginationModel _value;
try { try {
@@ -456,27 +387,21 @@ class _ProfileService implements ProfileService {
}) async { }) async {
final _extra = <String, dynamic>{}; final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{ final queryParameters = <String, dynamic>{
r'filters[name][$startsWith]': query r'filters[name][$startsWith]': query,
}; };
queryParameters.removeWhere((k, v) => v == null); queryParameters.removeWhere((k, v) => v == null);
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<SubPaginationModel>(Options( final _options = _setStreamType<SubPaginationModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/profile/${slug}/subscriptions',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/profile/${slug}/subscriptions', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late SubPaginationModel _value; late SubPaginationModel _value;
try { try {
@@ -494,22 +419,16 @@ class _ProfileService implements ProfileService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/profile/subscribe/${slug}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/profile/subscribe/${slug}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -519,22 +438,16 @@ class _ProfileService implements ProfileService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(method: 'POST', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/profile/unsubscribe/${slug}',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/profile/unsubscribe/${slug}', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -544,30 +457,30 @@ class _ProfileService implements ProfileService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
final _data = FormData(); final _data = FormData();
_data.files.add(MapEntry( _data.files.add(
'photo', MapEntry(
MultipartFile.fromFileSync( 'photo',
photo.path, MultipartFile.fromFileSync(
filename: photo.path.split(Platform.pathSeparator).last, photo.path,
filename: photo.path.split(Platform.pathSeparator).last,
),
), ),
)); );
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'POST', Options(
headers: _headers, method: 'POST',
extra: _extra, headers: _headers,
contentType: 'multipart/form-data', extra: _extra,
) contentType: 'multipart/form-data',
.compose( )
_dio.options, .compose(
'/api/profile/photo/upload', _dio.options,
queryParameters: queryParameters, '/api/profile/photo/upload',
data: _data, queryParameters: queryParameters,
) data: _data,
.copyWith( )
baseUrl: _combineBaseUrls( .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
_dio.options.baseUrl, );
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -577,22 +490,16 @@ class _ProfileService implements ProfileService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<void>(Options( final _options = _setStreamType<void>(
method: 'DELETE', Options(method: 'DELETE', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/profile/photo/delete',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/profile/photo/delete', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options); await _dio.fetch<void>(_options);
} }
@@ -602,22 +509,16 @@ class _ProfileService implements ProfileService {
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{}; final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null; const Map<String, dynamic>? _data = null;
final _options = _setStreamType<ChosenDietsPaginationModel>(Options( final _options = _setStreamType<ChosenDietsPaginationModel>(
method: 'GET', Options(method: 'GET', headers: _headers, extra: _extra)
headers: _headers, .compose(
extra: _extra, _dio.options,
) '/api/profile/chosen_diets',
.compose( queryParameters: queryParameters,
_dio.options, data: _data,
'/api/profile/chosen_diets', )
queryParameters: queryParameters, .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
data: _data, );
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options); final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late ChosenDietsPaginationModel _value; late ChosenDietsPaginationModel _value;
try { try {
@@ -642,10 +543,7 @@ class _ProfileService implements ProfileService {
return requestOptions; return requestOptions;
} }
String _combineBaseUrls( String _combineBaseUrls(String dioBaseUrl, String? baseUrl) {
String dioBaseUrl,
String? baseUrl,
) {
if (baseUrl == null || baseUrl.trim().isEmpty) { if (baseUrl == null || baseUrl.trim().isEmpty) {
return dioBaseUrl; return dioBaseUrl;
} }

View File

@@ -1,4 +1,4 @@
// Mocks generated by Mockito 5.4.4 from annotations // Mocks generated by Mockito 5.4.5 from annotations
// in eatvio_app/test/features/profile/services/profile_service_test.dart. // in eatvio_app/test/features/profile/services/profile_service_test.dart.
// Do not manually edit this file. // Do not manually edit this file.
@@ -27,52 +27,33 @@ import 'package:mockito/mockito.dart' as _i1;
// ignore_for_file: deprecated_member_use_from_same_package // ignore_for_file: deprecated_member_use_from_same_package
// ignore_for_file: implementation_imports // ignore_for_file: implementation_imports
// ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: invalid_use_of_visible_for_testing_member
// ignore_for_file: must_be_immutable
// ignore_for_file: prefer_const_constructors // ignore_for_file: prefer_const_constructors
// ignore_for_file: unnecessary_parenthesis // ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types // ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class // ignore_for_file: subtype_of_sealed_class
class _FakeProfileModel_0 extends _i1.SmartFake implements _i2.ProfileModel { class _FakeProfileModel_0 extends _i1.SmartFake implements _i2.ProfileModel {
_FakeProfileModel_0( _FakeProfileModel_0(Object parent, Invocation parentInvocation)
Object parent, : super(parent, parentInvocation);
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
} }
class _FakeProfileDetailsModel_1 extends _i1.SmartFake class _FakeProfileDetailsModel_1 extends _i1.SmartFake
implements _i2.ProfileDetailsModel { implements _i2.ProfileDetailsModel {
_FakeProfileDetailsModel_1( _FakeProfileDetailsModel_1(Object parent, Invocation parentInvocation)
Object parent, : super(parent, parentInvocation);
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
} }
class _FakeSubPaginationModel_2 extends _i1.SmartFake class _FakeSubPaginationModel_2 extends _i1.SmartFake
implements _i3.SubPaginationModel { implements _i3.SubPaginationModel {
_FakeSubPaginationModel_2( _FakeSubPaginationModel_2(Object parent, Invocation parentInvocation)
Object parent, : super(parent, parentInvocation);
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
} }
class _FakeChosenDietsPaginationModel_3 extends _i1.SmartFake class _FakeChosenDietsPaginationModel_3 extends _i1.SmartFake
implements _i4.ChosenDietsPaginationModel { implements _i4.ChosenDietsPaginationModel {
_FakeChosenDietsPaginationModel_3( _FakeChosenDietsPaginationModel_3(Object parent, Invocation parentInvocation)
Object parent, : super(parent, parentInvocation);
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
} }
/// A class which mocks [ProfileService]. /// A class which mocks [ProfileService].
@@ -82,106 +63,78 @@ class MockProfileService extends _i1.Mock implements _i5.ProfileService {
@override @override
_i6.Future<_i2.ProfileModel> getProfileBySlug({required String? slug}) => _i6.Future<_i2.ProfileModel> getProfileBySlug({required String? slug}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(#getProfileBySlug, [], {#slug: slug}),
#getProfileBySlug, returnValue: _i6.Future<_i2.ProfileModel>.value(
[], _FakeProfileModel_0(
{#slug: slug}, this,
), Invocation.method(#getProfileBySlug, [], {#slug: slug}),
returnValue: _i6.Future<_i2.ProfileModel>.value(_FakeProfileModel_0( ),
this, ),
Invocation.method( returnValueForMissingStub: _i6.Future<_i2.ProfileModel>.value(
#getProfileBySlug, _FakeProfileModel_0(
[], this,
{#slug: slug}, Invocation.method(#getProfileBySlug, [], {#slug: slug}),
), ),
)), ),
returnValueForMissingStub: )
_i6.Future<_i2.ProfileModel>.value(_FakeProfileModel_0( as _i6.Future<_i2.ProfileModel>);
this,
Invocation.method(
#getProfileBySlug,
[],
{#slug: slug},
),
)),
) as _i6.Future<_i2.ProfileModel>);
@override @override
_i6.Future<_i2.ProfileModel> getMyProfile() => (super.noSuchMethod( _i6.Future<_i2.ProfileModel> getMyProfile() =>
Invocation.method( (super.noSuchMethod(
#getMyProfile, Invocation.method(#getMyProfile, []),
[], returnValue: _i6.Future<_i2.ProfileModel>.value(
), _FakeProfileModel_0(this, Invocation.method(#getMyProfile, [])),
returnValue: _i6.Future<_i2.ProfileModel>.value(_FakeProfileModel_0( ),
this, returnValueForMissingStub: _i6.Future<_i2.ProfileModel>.value(
Invocation.method( _FakeProfileModel_0(this, Invocation.method(#getMyProfile, [])),
#getMyProfile, ),
[], )
), as _i6.Future<_i2.ProfileModel>);
)),
returnValueForMissingStub:
_i6.Future<_i2.ProfileModel>.value(_FakeProfileModel_0(
this,
Invocation.method(
#getMyProfile,
[],
),
)),
) as _i6.Future<_i2.ProfileModel>);
@override @override
_i6.Future<_i2.ProfileDetailsModel> getMyProfileDetails() => _i6.Future<_i2.ProfileDetailsModel> getMyProfileDetails() =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(#getMyProfileDetails, []),
#getMyProfileDetails, returnValue: _i6.Future<_i2.ProfileDetailsModel>.value(
[], _FakeProfileDetailsModel_1(
), this,
returnValue: _i6.Future<_i2.ProfileDetailsModel>.value( Invocation.method(#getMyProfileDetails, []),
_FakeProfileDetailsModel_1( ),
this, ),
Invocation.method( returnValueForMissingStub:
#getMyProfileDetails, _i6.Future<_i2.ProfileDetailsModel>.value(
[], _FakeProfileDetailsModel_1(
), this,
)), Invocation.method(#getMyProfileDetails, []),
returnValueForMissingStub: _i6.Future<_i2.ProfileDetailsModel>.value( ),
_FakeProfileDetailsModel_1( ),
this, )
Invocation.method( as _i6.Future<_i2.ProfileDetailsModel>);
#getMyProfileDetails,
[],
),
)),
) as _i6.Future<_i2.ProfileDetailsModel>);
@override @override
_i6.Future<_i2.ProfileDetailsModel> getProfileDetailsBySlug( _i6.Future<_i2.ProfileDetailsModel> getProfileDetailsBySlug({
{required String? slug}) => required String? slug,
}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(#getProfileDetailsBySlug, [], {#slug: slug}),
#getProfileDetailsBySlug, returnValue: _i6.Future<_i2.ProfileDetailsModel>.value(
[], _FakeProfileDetailsModel_1(
{#slug: slug}, this,
), Invocation.method(#getProfileDetailsBySlug, [], {#slug: slug}),
returnValue: _i6.Future<_i2.ProfileDetailsModel>.value( ),
_FakeProfileDetailsModel_1( ),
this, returnValueForMissingStub:
Invocation.method( _i6.Future<_i2.ProfileDetailsModel>.value(
#getProfileDetailsBySlug, _FakeProfileDetailsModel_1(
[], this,
{#slug: slug}, Invocation.method(#getProfileDetailsBySlug, [], {
), #slug: slug,
)), }),
returnValueForMissingStub: _i6.Future<_i2.ProfileDetailsModel>.value( ),
_FakeProfileDetailsModel_1( ),
this, )
Invocation.method( as _i6.Future<_i2.ProfileDetailsModel>);
#getProfileDetailsBySlug,
[],
{#slug: slug},
),
)),
) as _i6.Future<_i2.ProfileDetailsModel>);
@override @override
_i6.Future<void> addCircumference({ _i6.Future<void> addCircumference({
@@ -190,59 +143,53 @@ class MockProfileService extends _i1.Mock implements _i5.ProfileService {
required int? hipCircumference, required int? hipCircumference,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(#addCircumference, [], {
#addCircumference, #chestCircumference: chestCircumference,
[], #waistCircumference: waistCircumference,
{ #hipCircumference: hipCircumference,
#chestCircumference: chestCircumference, }),
#waistCircumference: waistCircumference, returnValue: _i6.Future<void>.value(),
#hipCircumference: hipCircumference, returnValueForMissingStub: _i6.Future<void>.value(),
}, )
), as _i6.Future<void>);
returnValue: _i6.Future<void>.value(),
returnValueForMissingStub: _i6.Future<void>.value(),
) as _i6.Future<void>);
@override @override
_i6.Future<void> addWeight({required double? weight}) => (super.noSuchMethod( _i6.Future<void> addWeight({required double? weight}) =>
Invocation.method(
#addWeight,
[],
{#weight: weight},
),
returnValue: _i6.Future<void>.value(),
returnValueForMissingStub: _i6.Future<void>.value(),
) as _i6.Future<void>);
@override
_i6.Future<List<_i7.FeedBlogPostModel>> getBlogPostByAuthorSlug(
{required String? slug}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(#addWeight, [], {#weight: weight}),
#getBlogPostByAuthorSlug, returnValue: _i6.Future<void>.value(),
[], returnValueForMissingStub: _i6.Future<void>.value(),
{#slug: slug}, )
), as _i6.Future<void>);
returnValue: _i6.Future<List<_i7.FeedBlogPostModel>>.value(
<_i7.FeedBlogPostModel>[]), @override
returnValueForMissingStub: _i6.Future<List<_i7.FeedBlogPostModel>> getBlogPostByAuthorSlug({
_i6.Future<List<_i7.FeedBlogPostModel>>.value( required String? slug,
<_i7.FeedBlogPostModel>[]), }) =>
) as _i6.Future<List<_i7.FeedBlogPostModel>>); (super.noSuchMethod(
Invocation.method(#getBlogPostByAuthorSlug, [], {#slug: slug}),
returnValue: _i6.Future<List<_i7.FeedBlogPostModel>>.value(
<_i7.FeedBlogPostModel>[],
),
returnValueForMissingStub:
_i6.Future<List<_i7.FeedBlogPostModel>>.value(
<_i7.FeedBlogPostModel>[],
),
)
as _i6.Future<List<_i7.FeedBlogPostModel>>);
@override @override
_i6.Future<List<_i8.WeightModel>> getWeight({required String? period}) => _i6.Future<List<_i8.WeightModel>> getWeight({required String? period}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(#getWeight, [], {#period: period}),
#getWeight, returnValue: _i6.Future<List<_i8.WeightModel>>.value(
[], <_i8.WeightModel>[],
{#period: period}, ),
), returnValueForMissingStub: _i6.Future<List<_i8.WeightModel>>.value(
returnValue: <_i8.WeightModel>[],
_i6.Future<List<_i8.WeightModel>>.value(<_i8.WeightModel>[]), ),
returnValueForMissingStub: )
_i6.Future<List<_i8.WeightModel>>.value(<_i8.WeightModel>[]), as _i6.Future<List<_i8.WeightModel>>);
) as _i6.Future<List<_i8.WeightModel>>);
@override @override
_i6.Future<List<_i8.WeightModel>> getWeightBySlug({ _i6.Future<List<_i8.WeightModel>> getWeightBySlug({
@@ -250,35 +197,34 @@ class MockProfileService extends _i1.Mock implements _i5.ProfileService {
required String? slug, required String? slug,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(#getWeightBySlug, [], {
#getWeightBySlug, #period: period,
[], #slug: slug,
{ }),
#period: period, returnValue: _i6.Future<List<_i8.WeightModel>>.value(
#slug: slug, <_i8.WeightModel>[],
}, ),
), returnValueForMissingStub: _i6.Future<List<_i8.WeightModel>>.value(
returnValue: <_i8.WeightModel>[],
_i6.Future<List<_i8.WeightModel>>.value(<_i8.WeightModel>[]), ),
returnValueForMissingStub: )
_i6.Future<List<_i8.WeightModel>>.value(<_i8.WeightModel>[]), as _i6.Future<List<_i8.WeightModel>>);
) as _i6.Future<List<_i8.WeightModel>>);
@override @override
_i6.Future<List<_i9.CircumferenceModel>> getCircumferences( _i6.Future<List<_i9.CircumferenceModel>> getCircumferences({
{required String? period}) => required String? period,
}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(#getCircumferences, [], {#period: period}),
#getCircumferences, returnValue: _i6.Future<List<_i9.CircumferenceModel>>.value(
[], <_i9.CircumferenceModel>[],
{#period: period}, ),
), returnValueForMissingStub:
returnValue: _i6.Future<List<_i9.CircumferenceModel>>.value( _i6.Future<List<_i9.CircumferenceModel>>.value(
<_i9.CircumferenceModel>[]), <_i9.CircumferenceModel>[],
returnValueForMissingStub: ),
_i6.Future<List<_i9.CircumferenceModel>>.value( )
<_i9.CircumferenceModel>[]), as _i6.Future<List<_i9.CircumferenceModel>>);
) as _i6.Future<List<_i9.CircumferenceModel>>);
@override @override
_i6.Future<List<_i9.CircumferenceModel>> getCircumferencesBySlug({ _i6.Future<List<_i9.CircumferenceModel>> getCircumferencesBySlug({
@@ -286,20 +232,19 @@ class MockProfileService extends _i1.Mock implements _i5.ProfileService {
required String? slug, required String? slug,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(#getCircumferencesBySlug, [], {
#getCircumferencesBySlug, #period: period,
[], #slug: slug,
{ }),
#period: period, returnValue: _i6.Future<List<_i9.CircumferenceModel>>.value(
#slug: slug, <_i9.CircumferenceModel>[],
}, ),
), returnValueForMissingStub:
returnValue: _i6.Future<List<_i9.CircumferenceModel>>.value( _i6.Future<List<_i9.CircumferenceModel>>.value(
<_i9.CircumferenceModel>[]), <_i9.CircumferenceModel>[],
returnValueForMissingStub: ),
_i6.Future<List<_i9.CircumferenceModel>>.value( )
<_i9.CircumferenceModel>[]), as _i6.Future<List<_i9.CircumferenceModel>>);
) as _i6.Future<List<_i9.CircumferenceModel>>);
@override @override
_i6.Future<_i3.SubPaginationModel> getSubscribers({ _i6.Future<_i3.SubPaginationModel> getSubscribers({
@@ -307,39 +252,30 @@ class MockProfileService extends _i1.Mock implements _i5.ProfileService {
String? query, String? query,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(#getSubscribers, [], {
#getSubscribers,
[],
{
#slug: slug,
#query: query,
},
),
returnValue:
_i6.Future<_i3.SubPaginationModel>.value(_FakeSubPaginationModel_2(
this,
Invocation.method(
#getSubscribers,
[],
{
#slug: slug, #slug: slug,
#query: query, #query: query,
}, }),
), returnValue: _i6.Future<_i3.SubPaginationModel>.value(
)), _FakeSubPaginationModel_2(
returnValueForMissingStub: this,
_i6.Future<_i3.SubPaginationModel>.value(_FakeSubPaginationModel_2( Invocation.method(#getSubscribers, [], {
this, #slug: slug,
Invocation.method( #query: query,
#getSubscribers, }),
[], ),
{ ),
#slug: slug, returnValueForMissingStub: _i6.Future<_i3.SubPaginationModel>.value(
#query: query, _FakeSubPaginationModel_2(
}, this,
), Invocation.method(#getSubscribers, [], {
)), #slug: slug,
) as _i6.Future<_i3.SubPaginationModel>); #query: query,
}),
),
),
)
as _i6.Future<_i3.SubPaginationModel>);
@override @override
_i6.Future<_i3.SubPaginationModel> getSubscriptions({ _i6.Future<_i3.SubPaginationModel> getSubscriptions({
@@ -347,107 +283,84 @@ class MockProfileService extends _i1.Mock implements _i5.ProfileService {
String? query, String? query,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(#getSubscriptions, [], {
#getSubscriptions,
[],
{
#slug: slug,
#query: query,
},
),
returnValue:
_i6.Future<_i3.SubPaginationModel>.value(_FakeSubPaginationModel_2(
this,
Invocation.method(
#getSubscriptions,
[],
{
#slug: slug, #slug: slug,
#query: query, #query: query,
}, }),
), returnValue: _i6.Future<_i3.SubPaginationModel>.value(
)), _FakeSubPaginationModel_2(
returnValueForMissingStub: this,
_i6.Future<_i3.SubPaginationModel>.value(_FakeSubPaginationModel_2( Invocation.method(#getSubscriptions, [], {
this, #slug: slug,
Invocation.method( #query: query,
#getSubscriptions, }),
[], ),
{ ),
#slug: slug, returnValueForMissingStub: _i6.Future<_i3.SubPaginationModel>.value(
#query: query, _FakeSubPaginationModel_2(
}, this,
), Invocation.method(#getSubscriptions, [], {
)), #slug: slug,
) as _i6.Future<_i3.SubPaginationModel>); #query: query,
}),
),
),
)
as _i6.Future<_i3.SubPaginationModel>);
@override @override
_i6.Future<void> subscribe({required String? slug}) => (super.noSuchMethod( _i6.Future<void> subscribe({required String? slug}) =>
Invocation.method( (super.noSuchMethod(
#subscribe, Invocation.method(#subscribe, [], {#slug: slug}),
[], returnValue: _i6.Future<void>.value(),
{#slug: slug}, returnValueForMissingStub: _i6.Future<void>.value(),
), )
returnValue: _i6.Future<void>.value(), as _i6.Future<void>);
returnValueForMissingStub: _i6.Future<void>.value(),
) as _i6.Future<void>);
@override @override
_i6.Future<void> unsubscribe({required String? slug}) => (super.noSuchMethod( _i6.Future<void> unsubscribe({required String? slug}) =>
Invocation.method( (super.noSuchMethod(
#unsubscribe, Invocation.method(#unsubscribe, [], {#slug: slug}),
[], returnValue: _i6.Future<void>.value(),
{#slug: slug}, returnValueForMissingStub: _i6.Future<void>.value(),
), )
returnValue: _i6.Future<void>.value(), as _i6.Future<void>);
returnValueForMissingStub: _i6.Future<void>.value(),
) as _i6.Future<void>);
@override @override
_i6.Future<void> uploadPhoto({required _i10.File? photo}) => _i6.Future<void> uploadPhoto({required _i10.File? photo}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(#uploadPhoto, [], {#photo: photo}),
#uploadPhoto, returnValue: _i6.Future<void>.value(),
[], returnValueForMissingStub: _i6.Future<void>.value(),
{#photo: photo}, )
), as _i6.Future<void>);
returnValue: _i6.Future<void>.value(),
returnValueForMissingStub: _i6.Future<void>.value(),
) as _i6.Future<void>);
@override @override
_i6.Future<void> deletePhoto() => (super.noSuchMethod( _i6.Future<void> deletePhoto() =>
Invocation.method( (super.noSuchMethod(
#deletePhoto, Invocation.method(#deletePhoto, []),
[], returnValue: _i6.Future<void>.value(),
), returnValueForMissingStub: _i6.Future<void>.value(),
returnValue: _i6.Future<void>.value(), )
returnValueForMissingStub: _i6.Future<void>.value(), as _i6.Future<void>);
) as _i6.Future<void>);
@override @override
_i6.Future<_i4.ChosenDietsPaginationModel> getChosenDiets() => _i6.Future<_i4.ChosenDietsPaginationModel> getChosenDiets() =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(#getChosenDiets, []),
#getChosenDiets, returnValue: _i6.Future<_i4.ChosenDietsPaginationModel>.value(
[], _FakeChosenDietsPaginationModel_3(
), this,
returnValue: _i6.Future<_i4.ChosenDietsPaginationModel>.value( Invocation.method(#getChosenDiets, []),
_FakeChosenDietsPaginationModel_3( ),
this, ),
Invocation.method( returnValueForMissingStub:
#getChosenDiets, _i6.Future<_i4.ChosenDietsPaginationModel>.value(
[], _FakeChosenDietsPaginationModel_3(
), this,
)), Invocation.method(#getChosenDiets, []),
returnValueForMissingStub: ),
_i6.Future<_i4.ChosenDietsPaginationModel>.value( ),
_FakeChosenDietsPaginationModel_3( )
this, as _i6.Future<_i4.ChosenDietsPaginationModel>);
Invocation.method(
#getChosenDiets,
[],
),
)),
) as _i6.Future<_i4.ChosenDietsPaginationModel>);
} }