forked from eatvio/eatvio_app
added plan pagination and updated plans creation screen
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/features/feed/models/comment_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/feed_blog_post_settings_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/recipes_pagination_model.dart';
|
||||
import 'package:retrofit/retrofit.dart';
|
||||
|
||||
@@ -27,10 +28,15 @@ abstract class FeedService {
|
||||
@GET('/api/diets/index')
|
||||
Future<DietsPagination> getDiets({
|
||||
@Query('page') required int page,
|
||||
@Query('filters[name][\$startsWith]') String? query,
|
||||
@Query('filters[type][\$contains]') String? types,
|
||||
@Query('filters[duration][\$eq]') int? duration,
|
||||
@Query('sort') String? sorting,
|
||||
@Query('filters[name][\$startsWith]') String? query,
|
||||
@Query('filters[type][\$contains]') String? types,
|
||||
@Query('filters[duration][\$eq]') int? duration,
|
||||
@Query('sort') String? sorting,
|
||||
});
|
||||
|
||||
@GET('/api/plans/index')
|
||||
Future<PlanPaginationModel> getPlans({
|
||||
@Query('page') required int page,
|
||||
});
|
||||
|
||||
@GET('/api/blogPosts/{id}/comments/show')
|
||||
@@ -77,6 +83,5 @@ abstract class FeedService {
|
||||
@POST('/api/blogPosts/{id}/unliked')
|
||||
Future<void> unlikedBlogPost({
|
||||
@Path() required int id,
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -149,6 +149,39 @@ class _FeedService implements FeedService {
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PlanPaginationModel> getPlans({required int page}) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{r'page': page};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _options = _setStreamType<PlanPaginationModel>(Options(
|
||||
method: 'GET',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/api/plans/index',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
)));
|
||||
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
|
||||
late PlanPaginationModel _value;
|
||||
try {
|
||||
_value = PlanPaginationModel.fromJson(_result.data!);
|
||||
} on Object catch (e, s) {
|
||||
errorLogger?.logError(e, s, _options);
|
||||
rethrow;
|
||||
}
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CommentModel> getBlogPostComments({required String id}) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
|
||||
Reference in New Issue
Block a user