forked from eatvio/eatvio_app
feat(diary): add diary, calendar, meals, products, add product button, modal add product
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
import 'package:eatvio_app/features/blog_post_create/models/blog_post_create_credentials_model.dart';
|
||||
import 'package:eatvio_app/features/blog_post_create/services/blog_service.dart';
|
||||
|
||||
class BlogRepository {
|
||||
final BlogService blogService;
|
||||
|
||||
BlogRepository({
|
||||
required this.blogService,
|
||||
});
|
||||
|
||||
Future<BlogPostCreateCredentialsModel> createBlogPost(BlogPostCreateCredentialsModel model) async {
|
||||
try {
|
||||
return (await blogService.createBlogPost(model));
|
||||
} catch (e) {
|
||||
print(e);
|
||||
throw (e);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'blog_post_service.dart';
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
|
||||
|
||||
class _BlogPostService implements BlogPostService {
|
||||
_BlogPostService(
|
||||
|
||||
@@ -16,7 +16,6 @@ class ProfileAvatarCubit extends Cubit<ProfileAvatarState> {
|
||||
));
|
||||
} catch (e) {
|
||||
emit(ProfileAvatarState.error(errorMessage: e.toString()));
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,6 @@ class CalendarScreen extends StatelessWidget {
|
||||
);
|
||||
} else {
|
||||
diary = state.calendarList[index].diary as Map<String, dynamic>;
|
||||
print(state.calendarList[index]);
|
||||
return InkWell(
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
onTap: () => GoRouter.of(context).go(
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'calendar_service.dart';
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
|
||||
|
||||
class _CalendarService implements CalendarService {
|
||||
_CalendarService(
|
||||
|
||||
@@ -53,7 +53,6 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
|
||||
|
||||
currentPage++;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
emit(ChatRoomState.error(errorMessage: 'Ошибка получеия данных'));
|
||||
}
|
||||
}
|
||||
@@ -75,7 +74,6 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
|
||||
isLoading: isLoading,
|
||||
));
|
||||
} catch (e) {
|
||||
print(e);
|
||||
emit(ChatRoomState.error(errorMessage: 'Ошибка получеия данных'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ class ChatRepository {
|
||||
media_data: multipartFiles.isEmpty ? null : multipartFiles,
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
@@ -50,7 +49,6 @@ class ChatRepository {
|
||||
try {
|
||||
return (await chatService.getChatRoom(id: chatId))['chatRoom']!;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
@@ -59,7 +57,6 @@ class ChatRepository {
|
||||
try {
|
||||
return (await chatService.getChatRoomPreviews(query: query)).chatRooms;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
@@ -68,7 +65,6 @@ class ChatRepository {
|
||||
try {
|
||||
return (await chatService.getChatMessages(id: chatId, page: page));
|
||||
} catch (e) {
|
||||
print(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
@@ -77,7 +73,6 @@ class ChatRepository {
|
||||
try {
|
||||
return (await chatService.getWebsocket());
|
||||
} catch (e) {
|
||||
print(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
@@ -86,7 +81,6 @@ class ChatRepository {
|
||||
try {
|
||||
return (await chatService.getChatRoomIdByUserSlug(user: slug));
|
||||
} catch (e) {
|
||||
print(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'chat_service.dart';
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
|
||||
|
||||
class _ChatService implements ChatService {
|
||||
_ChatService(
|
||||
|
||||
@@ -19,7 +19,6 @@ class ConsultantRepository {
|
||||
consultantModel: consultant,
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
@@ -44,7 +43,6 @@ class ConsultantRepository {
|
||||
photos: multipartFiles.isEmpty ? null : multipartFiles,
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'consultant_service.dart';
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
|
||||
|
||||
class _ConsultantService implements ConsultantService {
|
||||
_ConsultantService(
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
|
||||
import 'package:eatvio_app/features/diary/repositories/diary_repository.dart';
|
||||
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
|
||||
import 'package:eatvio_app/features/glossary/repositories/glossary_repository.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class DiaryCubit extends Cubit<DiaryState> {
|
||||
final DiaryRepository diaryRepository;
|
||||
final GlossaryRepository glossaryRepository;
|
||||
|
||||
DiaryCubit({
|
||||
required this.diaryRepository,
|
||||
required this.glossaryRepository,
|
||||
}) : super(const DiaryState.loading());
|
||||
|
||||
getDiaryDay(String date) async {
|
||||
print(date);
|
||||
emit(const DiaryState.loading());
|
||||
getDiaryDay(String date, [bool needLoading = true]) async {
|
||||
if (needLoading) emit(const DiaryState.loading());
|
||||
try {
|
||||
emit(DiaryState.loaded(diary: await diaryRepository.getDiaryByDate(date)));
|
||||
} catch (e) {
|
||||
@@ -19,4 +22,26 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
addProductToMeal({
|
||||
required int diaryId,
|
||||
required int mealId,
|
||||
required String productName,
|
||||
required String portion,
|
||||
required int quantity,
|
||||
required String date,
|
||||
}) async {
|
||||
await diaryRepository.addPortionToMeal(
|
||||
diaryId: diaryId,
|
||||
mealId: mealId,
|
||||
productName: productName,
|
||||
portion: portion,
|
||||
quantity: quantity,
|
||||
);
|
||||
await getDiaryDay(date, false);
|
||||
}
|
||||
|
||||
Future<List<GlossaryModel>> getGlossaryListByQuery(String query) async {
|
||||
return await glossaryRepository.getGlossaryListByQuery(query);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import 'package:eatvio_app/features/diary/models/diary_day_model.dart';
|
||||
import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart';
|
||||
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
|
||||
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
|
||||
import 'package:eatvio_app/locator_service.dart';
|
||||
import 'package:eatvio_app/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
import 'package:table_calendar/table_calendar.dart';
|
||||
|
||||
@@ -21,6 +24,9 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
||||
DateTime _focusedDay = DateTime.now();
|
||||
DateTime? _selectedDay = DateTime.now();
|
||||
int currentSelectedMealNumber = 1;
|
||||
GlossaryModel? selectedGlossary;
|
||||
final productNameController = TextEditingController();
|
||||
final quantityController = TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -47,6 +53,7 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
||||
_calendar(state),
|
||||
if (state is DiaryStateLoading) _loader(),
|
||||
if (state is DiaryStateLoaded) _meals(state.diary),
|
||||
const SizedBox(height: 32),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -57,23 +64,12 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
||||
}
|
||||
|
||||
_arrowDown() {
|
||||
return GestureDetector(
|
||||
onTapDown: (_) {
|
||||
setState(() {
|
||||
if (_calendarFormat == CalendarFormat.week) {
|
||||
_calendarFormat = CalendarFormat.month;
|
||||
} else {
|
||||
_calendarFormat = CalendarFormat.week;
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(top: 8, bottom: 16),
|
||||
width: double.infinity,
|
||||
child: Icon(
|
||||
_calendarFormat == CalendarFormat.month ? Icons.keyboard_arrow_up_rounded : Icons.keyboard_arrow_down_rounded,
|
||||
color: Colors.grey.shade600,
|
||||
),
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(top: 8, bottom: 16),
|
||||
width: double.infinity,
|
||||
child: Icon(
|
||||
_calendarFormat == CalendarFormat.month ? Icons.keyboard_arrow_up_rounded : Icons.keyboard_arrow_down_rounded,
|
||||
color: Colors.grey.shade600,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -97,6 +93,7 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
||||
_product(
|
||||
portions[i].productName,
|
||||
portions[i].quantity,
|
||||
portions[i].portion,
|
||||
),
|
||||
i < portions.length - 1 ? const SizedBox(height: 8) : const SizedBox.shrink(),
|
||||
],
|
||||
@@ -104,12 +101,13 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
_product(String product, int portion) {
|
||||
_product(String product, int quantity, String portion) {
|
||||
portion == 'gr' ? portion = 'г' : portion = 'шт';
|
||||
return ListTile(
|
||||
onTap: () {},
|
||||
trailing: Icon(Icons.more_vert_rounded),
|
||||
title: Text(product),
|
||||
subtitle: Text('$portion г'),
|
||||
subtitle: Text('$quantity $portion'),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
@@ -161,7 +159,7 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
||||
const SizedBox(height: 12),
|
||||
_products(diaryDay.meals[currentSelectedMealNumber - 1].portions),
|
||||
const SizedBox(height: 16),
|
||||
_addProductButton(),
|
||||
_addProductButton(diaryDay),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -240,6 +238,7 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
||||
setState(() {
|
||||
_selectedDay = selectedDay;
|
||||
_focusedDay = focusedDay;
|
||||
currentSelectedMealNumber = 1;
|
||||
});
|
||||
diaryCubit.getDiaryDay(_selectedDay!.toString());
|
||||
}
|
||||
@@ -255,6 +254,14 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
||||
_focusedDay = focusedDay;
|
||||
},
|
||||
calendarStyle: CalendarStyle(
|
||||
weekendDecoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
defaultDecoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
selectedDecoration: BoxDecoration(
|
||||
color: appTheme.blueA400,
|
||||
shape: BoxShape.circle,
|
||||
@@ -267,6 +274,7 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
||||
color: appTheme.blueA400,
|
||||
width: 2,
|
||||
),
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
@@ -277,9 +285,134 @@ class _DiaryScreenState extends State<DiaryScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
_addProductButton() {
|
||||
_addProductButton(DiaryDayModel diaryDay) {
|
||||
return InkWell(
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
setState(() {
|
||||
selectedGlossary = null;
|
||||
productNameController.clear();
|
||||
quantityController.clear();
|
||||
});
|
||||
showModalBottomSheet(
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(12)),
|
||||
),
|
||||
isScrollControlled: true,
|
||||
builder: (context) {
|
||||
return StatefulBuilder(
|
||||
builder: (BuildContext context, void Function(void Function()) setState) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16) + EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Добавление блюда',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF323F4B),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TypeAheadField(
|
||||
controller: productNameController,
|
||||
itemBuilder: (context, glossary) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
glossary.name,
|
||||
style: TextStyle(
|
||||
height: 1,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
itemSeparatorBuilder: (context, index) => _divider(context),
|
||||
onSelected: (newSelectedGlossary) {
|
||||
setState(() {
|
||||
selectedGlossary = newSelectedGlossary;
|
||||
productNameController.text = selectedGlossary!.name;
|
||||
});
|
||||
},
|
||||
suggestionsCallback: (query) async {
|
||||
if (query.length < 1) return [];
|
||||
return await diaryCubit.getGlossaryListByQuery(query);
|
||||
},
|
||||
builder: (context, controller, focusNode) {
|
||||
return CustomTextFormField(
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
autofocus: true,
|
||||
hintText: 'Введите название продукта/блюда',
|
||||
);
|
||||
},
|
||||
emptyBuilder: (context) => const SizedBox.shrink(),
|
||||
errorBuilder: (context, object) => Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text('Нет подходящих вариантов'),
|
||||
),
|
||||
),
|
||||
if (selectedGlossary != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: CustomTextFormField(
|
||||
controller: quantityController,
|
||||
keyboardType: TextInputType.number,
|
||||
hintText: selectedGlossary!.grInPortion == 0 ? '100' : '1',
|
||||
suffixText: selectedGlossary != null
|
||||
? selectedGlossary!.grInPortion == 0
|
||||
? 'гр'
|
||||
: 'шт'
|
||||
: null,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
diaryCubit.addProductToMeal(
|
||||
diaryId: diaryDay.id,
|
||||
mealId: diaryDay.meals[currentSelectedMealNumber - 1].id,
|
||||
productName: productNameController.text,
|
||||
portion: selectedGlossary!.grInPortion == 0 ? 'gr' : 'pcs',
|
||||
quantity: int.parse(quantityController.text),
|
||||
date: _selectedDay.toString(),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Ink(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
color: appTheme.blueA400,
|
||||
),
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width - 32,
|
||||
padding: const EdgeInsets.all(16),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'Добавить',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Ink(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
|
||||
@@ -9,13 +9,29 @@ class DiaryRepository {
|
||||
});
|
||||
|
||||
Future<DiaryDayModel> getDiaryByDate(String date) async {
|
||||
print(await _getDiaryIndexByDate(date));
|
||||
return (await diaryService.getDiaryDay(
|
||||
index: await _getDiaryIndexByDate(date),
|
||||
)).diary;
|
||||
))
|
||||
.diary;
|
||||
}
|
||||
|
||||
Future<int> _getDiaryIndexByDate(String date) async {
|
||||
return (await diaryService.getDiaryIndexByDate(date: date)).id;
|
||||
}
|
||||
|
||||
Future<void> addPortionToMeal({
|
||||
required int diaryId,
|
||||
required int mealId,
|
||||
required String productName,
|
||||
required String portion,
|
||||
required int quantity,
|
||||
}) async {
|
||||
return await diaryService.addProductToMeal(
|
||||
diaryId: diaryId,
|
||||
mealId: mealId,
|
||||
productName: productName,
|
||||
portion: portion,
|
||||
quantity: quantity,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,13 @@ abstract class DiaryService {
|
||||
Future<DiaryDayWrapperModel> getDiaryDay({
|
||||
@Path('diary_id') required int index,
|
||||
});
|
||||
|
||||
@POST('/api/diary/{diary_id}/meal/{meal_id}/portions/create')
|
||||
Future<void> addProductToMeal({
|
||||
@Path('diary_id') required int diaryId,
|
||||
@Path('meal_id') required int mealId,
|
||||
@Part(name: 'product_name') required String productName,
|
||||
@Part(name: 'portion') required String portion,
|
||||
@Part(name: 'quantity') required int quantity,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'diary_service.dart';
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
|
||||
|
||||
class _DiaryService implements DiaryService {
|
||||
_DiaryService(
|
||||
@@ -87,6 +87,49 @@ class _DiaryService implements DiaryService {
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> addProductToMeal({
|
||||
required int diaryId,
|
||||
required int mealId,
|
||||
required String productName,
|
||||
required String portion,
|
||||
required int quantity,
|
||||
}) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{};
|
||||
final _headers = <String, dynamic>{};
|
||||
final _data = FormData();
|
||||
_data.fields.add(MapEntry(
|
||||
'product_name',
|
||||
productName,
|
||||
));
|
||||
_data.fields.add(MapEntry(
|
||||
'portion',
|
||||
portion,
|
||||
));
|
||||
_data.fields.add(MapEntry(
|
||||
'quantity',
|
||||
quantity.toString(),
|
||||
));
|
||||
final _options = _setStreamType<void>(Options(
|
||||
method: 'POST',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/api/diary/${diaryId}/meal/${mealId}/portions/create',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
)));
|
||||
await _dio.fetch<void>(_options);
|
||||
}
|
||||
|
||||
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
|
||||
if (T != dynamic &&
|
||||
!(requestOptions.responseType == ResponseType.bytes ||
|
||||
|
||||
@@ -37,9 +37,7 @@ class FeedCubit extends Cubit<FeedState> {
|
||||
|
||||
try {
|
||||
if (currentPage < lastPage) {
|
||||
print('before: $currentPage');
|
||||
currentPage++;
|
||||
print('after: $currentPage');
|
||||
final feedBlogPosts = await feedRepository.getFeedBlogPosts(
|
||||
page: currentPage,
|
||||
query: _query,
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'feed_service.dart';
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
|
||||
|
||||
class _FeedService implements FeedService {
|
||||
_FeedService(
|
||||
|
||||
24
lib/features/glossary/models/glossary_model.dart
Normal file
24
lib/features/glossary/models/glossary_model.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'glossary_model.freezed.dart';
|
||||
part 'glossary_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class GlossaryPaginationModel with _$GlossaryPaginationModel {
|
||||
const factory GlossaryPaginationModel({
|
||||
@JsonKey(name: 'data') required List<GlossaryModel> glossariesList,
|
||||
}) = _GlossaryPaginationModel;
|
||||
|
||||
factory GlossaryPaginationModel.fromJson(Map<String, Object?> json) => _$GlossaryPaginationModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class GlossaryModel with _$GlossaryModel {
|
||||
const factory GlossaryModel({
|
||||
required int id,
|
||||
required String name,
|
||||
@JsonKey(name: 'portion_mass_gr') required int grInPortion,
|
||||
}) = _GlossaryModel;
|
||||
|
||||
factory GlossaryModel.fromJson(Map<String, Object?> json) => _$GlossaryModelFromJson(json);
|
||||
}
|
||||
380
lib/features/glossary/models/glossary_model.freezed.dart
Normal file
380
lib/features/glossary/models/glossary_model.freezed.dart
Normal file
@@ -0,0 +1,380 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'glossary_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
GlossaryPaginationModel _$GlossaryPaginationModelFromJson(
|
||||
Map<String, dynamic> json) {
|
||||
return _GlossaryPaginationModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GlossaryPaginationModel {
|
||||
@JsonKey(name: 'data')
|
||||
List<GlossaryModel> get glossariesList => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this GlossaryPaginationModel to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of GlossaryPaginationModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$GlossaryPaginationModelCopyWith<GlossaryPaginationModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $GlossaryPaginationModelCopyWith<$Res> {
|
||||
factory $GlossaryPaginationModelCopyWith(GlossaryPaginationModel value,
|
||||
$Res Function(GlossaryPaginationModel) then) =
|
||||
_$GlossaryPaginationModelCopyWithImpl<$Res, GlossaryPaginationModel>;
|
||||
@useResult
|
||||
$Res call({@JsonKey(name: 'data') List<GlossaryModel> glossariesList});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$GlossaryPaginationModelCopyWithImpl<$Res,
|
||||
$Val extends GlossaryPaginationModel>
|
||||
implements $GlossaryPaginationModelCopyWith<$Res> {
|
||||
_$GlossaryPaginationModelCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of GlossaryPaginationModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? glossariesList = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
glossariesList: null == glossariesList
|
||||
? _value.glossariesList
|
||||
: glossariesList // ignore: cast_nullable_to_non_nullable
|
||||
as List<GlossaryModel>,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$GlossaryPaginationModelImplCopyWith<$Res>
|
||||
implements $GlossaryPaginationModelCopyWith<$Res> {
|
||||
factory _$$GlossaryPaginationModelImplCopyWith(
|
||||
_$GlossaryPaginationModelImpl value,
|
||||
$Res Function(_$GlossaryPaginationModelImpl) then) =
|
||||
__$$GlossaryPaginationModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({@JsonKey(name: 'data') List<GlossaryModel> glossariesList});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$GlossaryPaginationModelImplCopyWithImpl<$Res>
|
||||
extends _$GlossaryPaginationModelCopyWithImpl<$Res,
|
||||
_$GlossaryPaginationModelImpl>
|
||||
implements _$$GlossaryPaginationModelImplCopyWith<$Res> {
|
||||
__$$GlossaryPaginationModelImplCopyWithImpl(
|
||||
_$GlossaryPaginationModelImpl _value,
|
||||
$Res Function(_$GlossaryPaginationModelImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of GlossaryPaginationModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? glossariesList = null,
|
||||
}) {
|
||||
return _then(_$GlossaryPaginationModelImpl(
|
||||
glossariesList: null == glossariesList
|
||||
? _value._glossariesList
|
||||
: glossariesList // ignore: cast_nullable_to_non_nullable
|
||||
as List<GlossaryModel>,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$GlossaryPaginationModelImpl implements _GlossaryPaginationModel {
|
||||
const _$GlossaryPaginationModelImpl(
|
||||
{@JsonKey(name: 'data')
|
||||
required final List<GlossaryModel> glossariesList})
|
||||
: _glossariesList = glossariesList;
|
||||
|
||||
factory _$GlossaryPaginationModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$GlossaryPaginationModelImplFromJson(json);
|
||||
|
||||
final List<GlossaryModel> _glossariesList;
|
||||
@override
|
||||
@JsonKey(name: 'data')
|
||||
List<GlossaryModel> get glossariesList {
|
||||
if (_glossariesList is EqualUnmodifiableListView) return _glossariesList;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_glossariesList);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GlossaryPaginationModel(glossariesList: $glossariesList)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$GlossaryPaginationModelImpl &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._glossariesList, _glossariesList));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType, const DeepCollectionEquality().hash(_glossariesList));
|
||||
|
||||
/// Create a copy of GlossaryPaginationModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$GlossaryPaginationModelImplCopyWith<_$GlossaryPaginationModelImpl>
|
||||
get copyWith => __$$GlossaryPaginationModelImplCopyWithImpl<
|
||||
_$GlossaryPaginationModelImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$GlossaryPaginationModelImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _GlossaryPaginationModel implements GlossaryPaginationModel {
|
||||
const factory _GlossaryPaginationModel(
|
||||
{@JsonKey(name: 'data')
|
||||
required final List<GlossaryModel> glossariesList}) =
|
||||
_$GlossaryPaginationModelImpl;
|
||||
|
||||
factory _GlossaryPaginationModel.fromJson(Map<String, dynamic> json) =
|
||||
_$GlossaryPaginationModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'data')
|
||||
List<GlossaryModel> get glossariesList;
|
||||
|
||||
/// Create a copy of GlossaryPaginationModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$GlossaryPaginationModelImplCopyWith<_$GlossaryPaginationModelImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
GlossaryModel _$GlossaryModelFromJson(Map<String, dynamic> json) {
|
||||
return _GlossaryModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GlossaryModel {
|
||||
int get id => throw _privateConstructorUsedError;
|
||||
String get name => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'portion_mass_gr')
|
||||
int get grInPortion => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this GlossaryModel to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of GlossaryModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$GlossaryModelCopyWith<GlossaryModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $GlossaryModelCopyWith<$Res> {
|
||||
factory $GlossaryModelCopyWith(
|
||||
GlossaryModel value, $Res Function(GlossaryModel) then) =
|
||||
_$GlossaryModelCopyWithImpl<$Res, GlossaryModel>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{int id, String name, @JsonKey(name: 'portion_mass_gr') int grInPortion});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$GlossaryModelCopyWithImpl<$Res, $Val extends GlossaryModel>
|
||||
implements $GlossaryModelCopyWith<$Res> {
|
||||
_$GlossaryModelCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of GlossaryModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? name = null,
|
||||
Object? grInPortion = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
name: null == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
grInPortion: null == grInPortion
|
||||
? _value.grInPortion
|
||||
: grInPortion // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$GlossaryModelImplCopyWith<$Res>
|
||||
implements $GlossaryModelCopyWith<$Res> {
|
||||
factory _$$GlossaryModelImplCopyWith(
|
||||
_$GlossaryModelImpl value, $Res Function(_$GlossaryModelImpl) then) =
|
||||
__$$GlossaryModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{int id, String name, @JsonKey(name: 'portion_mass_gr') int grInPortion});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$GlossaryModelImplCopyWithImpl<$Res>
|
||||
extends _$GlossaryModelCopyWithImpl<$Res, _$GlossaryModelImpl>
|
||||
implements _$$GlossaryModelImplCopyWith<$Res> {
|
||||
__$$GlossaryModelImplCopyWithImpl(
|
||||
_$GlossaryModelImpl _value, $Res Function(_$GlossaryModelImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of GlossaryModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? name = null,
|
||||
Object? grInPortion = null,
|
||||
}) {
|
||||
return _then(_$GlossaryModelImpl(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
name: null == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
grInPortion: null == grInPortion
|
||||
? _value.grInPortion
|
||||
: grInPortion // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$GlossaryModelImpl implements _GlossaryModel {
|
||||
const _$GlossaryModelImpl(
|
||||
{required this.id,
|
||||
required this.name,
|
||||
@JsonKey(name: 'portion_mass_gr') required this.grInPortion});
|
||||
|
||||
factory _$GlossaryModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$GlossaryModelImplFromJson(json);
|
||||
|
||||
@override
|
||||
final int id;
|
||||
@override
|
||||
final String name;
|
||||
@override
|
||||
@JsonKey(name: 'portion_mass_gr')
|
||||
final int grInPortion;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GlossaryModel(id: $id, name: $name, grInPortion: $grInPortion)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$GlossaryModelImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.name, name) || other.name == name) &&
|
||||
(identical(other.grInPortion, grInPortion) ||
|
||||
other.grInPortion == grInPortion));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, id, name, grInPortion);
|
||||
|
||||
/// Create a copy of GlossaryModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$GlossaryModelImplCopyWith<_$GlossaryModelImpl> get copyWith =>
|
||||
__$$GlossaryModelImplCopyWithImpl<_$GlossaryModelImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$GlossaryModelImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _GlossaryModel implements GlossaryModel {
|
||||
const factory _GlossaryModel(
|
||||
{required final int id,
|
||||
required final String name,
|
||||
@JsonKey(name: 'portion_mass_gr') required final int grInPortion}) =
|
||||
_$GlossaryModelImpl;
|
||||
|
||||
factory _GlossaryModel.fromJson(Map<String, dynamic> json) =
|
||||
_$GlossaryModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
int get id;
|
||||
@override
|
||||
String get name;
|
||||
@override
|
||||
@JsonKey(name: 'portion_mass_gr')
|
||||
int get grInPortion;
|
||||
|
||||
/// Create a copy of GlossaryModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$GlossaryModelImplCopyWith<_$GlossaryModelImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
35
lib/features/glossary/models/glossary_model.g.dart
Normal file
35
lib/features/glossary/models/glossary_model.g.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'glossary_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$GlossaryPaginationModelImpl _$$GlossaryPaginationModelImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$GlossaryPaginationModelImpl(
|
||||
glossariesList: (json['data'] as List<dynamic>)
|
||||
.map((e) => GlossaryModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$GlossaryPaginationModelImplToJson(
|
||||
_$GlossaryPaginationModelImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'data': instance.glossariesList,
|
||||
};
|
||||
|
||||
_$GlossaryModelImpl _$$GlossaryModelImplFromJson(Map<String, dynamic> json) =>
|
||||
_$GlossaryModelImpl(
|
||||
id: (json['id'] as num).toInt(),
|
||||
name: json['name'] as String,
|
||||
grInPortion: (json['portion_mass_gr'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$GlossaryModelImplToJson(_$GlossaryModelImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'portion_mass_gr': instance.grInPortion,
|
||||
};
|
||||
18
lib/features/glossary/repositories/glossary_repository.dart
Normal file
18
lib/features/glossary/repositories/glossary_repository.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
|
||||
import 'package:eatvio_app/features/glossary/services/glossary_service.dart';
|
||||
|
||||
class GlossaryRepository {
|
||||
final GlossaryService glossaryService;
|
||||
|
||||
GlossaryRepository({
|
||||
required this.glossaryService,
|
||||
});
|
||||
|
||||
Future<List<GlossaryModel>> getGlossaryListByQuery(String query) async {
|
||||
try {
|
||||
return (await glossaryService.getGlossaryByQuery(query: query)).glossariesList;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
lib/features/glossary/services/glossary_service.dart
Normal file
15
lib/features/glossary/services/glossary_service.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
|
||||
import 'package:retrofit/retrofit.dart';
|
||||
|
||||
part 'glossary_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class GlossaryService {
|
||||
factory GlossaryService(Dio dio, {String baseUrl}) = _GlossaryService;
|
||||
|
||||
@GET('/api/glossaries/search')
|
||||
Future<GlossaryPaginationModel> getGlossaryByQuery({
|
||||
@Query('search') required String query,
|
||||
});
|
||||
}
|
||||
87
lib/features/glossary/services/glossary_service.g.dart
Normal file
87
lib/features/glossary/services/glossary_service.g.dart
Normal file
@@ -0,0 +1,87 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'glossary_service.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
|
||||
|
||||
class _GlossaryService implements GlossaryService {
|
||||
_GlossaryService(
|
||||
this._dio, {
|
||||
this.baseUrl,
|
||||
this.errorLogger,
|
||||
});
|
||||
|
||||
final Dio _dio;
|
||||
|
||||
String? baseUrl;
|
||||
|
||||
final ParseErrorLogger? errorLogger;
|
||||
|
||||
@override
|
||||
Future<GlossaryPaginationModel> getGlossaryByQuery(
|
||||
{required String query}) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{r'search': query};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _options = _setStreamType<GlossaryPaginationModel>(Options(
|
||||
method: 'GET',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/api/glossaries/search',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
)));
|
||||
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
|
||||
late GlossaryPaginationModel _value;
|
||||
try {
|
||||
_value = GlossaryPaginationModel.fromJson(_result.data!);
|
||||
} on Object catch (e, s) {
|
||||
errorLogger?.logError(e, s, _options);
|
||||
rethrow;
|
||||
}
|
||||
return _value;
|
||||
}
|
||||
|
||||
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
|
||||
if (T != dynamic &&
|
||||
!(requestOptions.responseType == ResponseType.bytes ||
|
||||
requestOptions.responseType == ResponseType.stream)) {
|
||||
if (T == String) {
|
||||
requestOptions.responseType = ResponseType.plain;
|
||||
} else {
|
||||
requestOptions.responseType = ResponseType.json;
|
||||
}
|
||||
}
|
||||
return requestOptions;
|
||||
}
|
||||
|
||||
String _combineBaseUrls(
|
||||
String dioBaseUrl,
|
||||
String? baseUrl,
|
||||
) {
|
||||
if (baseUrl == null || baseUrl.trim().isEmpty) {
|
||||
return dioBaseUrl;
|
||||
}
|
||||
|
||||
final url = Uri.parse(baseUrl);
|
||||
|
||||
if (url.isAbsolute) {
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
return Uri.parse(dioBaseUrl).resolveUri(url).toString();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ part of 'plans_service.dart';
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
|
||||
|
||||
class _PlansService implements PlansService {
|
||||
_PlansService(
|
||||
|
||||
@@ -22,7 +22,6 @@ class ProfileCubit extends Cubit<ProfileState> {
|
||||
));
|
||||
} catch (e) {
|
||||
emit(ProfileState.error(errorMessage: e.toString()));
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +40,6 @@ class ProfileCubit extends Cubit<ProfileState> {
|
||||
));
|
||||
} catch (e) {
|
||||
emit(ProfileState.error(errorMessage: e.toString()));
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +57,6 @@ class ProfileCubit extends Cubit<ProfileState> {
|
||||
await getMyProfile(period: _currentPeriod);
|
||||
} catch (e) {
|
||||
emit(ProfileState.error(errorMessage: e.toString()));
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +68,6 @@ class ProfileCubit extends Cubit<ProfileState> {
|
||||
await getMyProfile(period: _currentPeriod);
|
||||
} catch (e) {
|
||||
emit(ProfileState.error(errorMessage: e.toString()));
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +77,6 @@ class ProfileCubit extends Cubit<ProfileState> {
|
||||
try {
|
||||
return (await chatRepository.getChatRoomIdByUserSlug(slug: slug)).id;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width - 4,
|
||||
width: MediaQuery.of(context).size.width - 2,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Material(
|
||||
color: Colors.white,
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'profile_service.dart';
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
|
||||
|
||||
class _ProfileService implements ProfileService {
|
||||
_ProfileService(
|
||||
|
||||
@@ -258,7 +258,7 @@ class RecipeCreateCubit extends Cubit<RecipeCreateState> {
|
||||
var currentState = state as RecipeCreateStateLoaded;
|
||||
|
||||
final Map<String, List<Product>> productNutritionalValues = await recipeRepository.inputProduct(input);
|
||||
print(productNutritionalValues);
|
||||
|
||||
var updatedState = currentState.copyWith(
|
||||
productNameController: TextEditingController(text: input),
|
||||
autocompleteList: productNutritionalValues['product_nutritional_value'] ?? [],
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:eatvio_app/features/recipes/models/product.dart';
|
||||
import 'package:eatvio_app/features/recipes/models/ingredient.dart';
|
||||
import 'package:eatvio_app/features/recipes/models/recipe_model.dart';
|
||||
@@ -512,7 +510,7 @@ class RecipeCreateScreen extends StatelessWidget {
|
||||
image: state.recipeImage?.path,
|
||||
video_url: state.youtubeLinkController.text.isNotEmpty ? state.youtubeLinkController.text : null,
|
||||
);
|
||||
print(jsonDecode(jsonEncode(recipe)));
|
||||
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,7 +354,6 @@ class RecipeEditScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
_buildStep(BuildContext context, int stepNumber, RecipeCreateStateLoaded state) {
|
||||
print(baseUrl + '/storage/' + state.stepImages[stepNumber]!.path);
|
||||
return Column(
|
||||
children: [
|
||||
Row(children: [Text('Шаг ${stepNumber + 1}'), Spacer(), Text('Всего шагов: ${state.numberOfSteps}')]),
|
||||
|
||||
@@ -39,8 +39,7 @@ class RecipeRepository {
|
||||
};
|
||||
}).toList() ??
|
||||
[];
|
||||
print(ingredientsMap);
|
||||
print(stepsMap);
|
||||
|
||||
return await recipeService.publishRecipe(
|
||||
recipe.type,
|
||||
recipe.state,
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'recipe_service.dart';
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
|
||||
|
||||
class _RecipeService implements RecipeService {
|
||||
_RecipeService(
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'registration_service.dart';
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
|
||||
|
||||
class _RegistrationService implements RegistrationService {
|
||||
_RegistrationService(
|
||||
|
||||
@@ -34,7 +34,6 @@ class SettingsCubit extends Cubit<SettingsState> {
|
||||
profileDetailsModel: profileDetailsModel,
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
rethrow;
|
||||
} finally {
|
||||
await init();
|
||||
@@ -49,7 +48,6 @@ class SettingsCubit extends Cubit<SettingsState> {
|
||||
profileSettingsModel: profileSettingsModel,
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
rethrow;
|
||||
} finally {
|
||||
await init();
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'settings_service.dart';
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
|
||||
|
||||
class _SettingsService implements SettingsService {
|
||||
_SettingsService(
|
||||
|
||||
Reference in New Issue
Block a user