diff --git a/android/app/build.gradle b/android/app/build.gradle index 46a74368..8a009c79 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -10,12 +10,12 @@ android { ndkVersion = "25.1.8937393" compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8 + jvmTarget = 17 } defaultConfig { diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index e6b38c2d..db18181a 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip diff --git a/android/settings.gradle b/android/settings.gradle index ff583230..b5e1b3f5 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -18,7 +18,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version "8.1.4" apply false + id "com.android.application" version "8.3.2" apply false id "org.jetbrains.kotlin.android" version "2.0.20" apply false } diff --git a/lib/features/blog_post_create/repositories/blog_repository.dart b/lib/features/blog_post_create/repositories/blog_repository.dart index 3d1846a4..e69de29b 100644 --- a/lib/features/blog_post_create/repositories/blog_repository.dart +++ b/lib/features/blog_post_create/repositories/blog_repository.dart @@ -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 createBlogPost(BlogPostCreateCredentialsModel model) async { - try { - return (await blogService.createBlogPost(model)); - } catch (e) { - print(e); - throw (e); - } - } -} -*/ diff --git a/lib/features/blog_post_create/services/blog_post_service.g.dart b/lib/features/blog_post_create/services/blog_post_service.g.dart index fab2c34d..b104b16e 100644 --- a/lib/features/blog_post_create/services/blog_post_service.g.dart +++ b/lib/features/blog_post_create/services/blog_post_service.g.dart @@ -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( diff --git a/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart b/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart index c6d83825..629e3d26 100644 --- a/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart +++ b/lib/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart @@ -16,7 +16,6 @@ class ProfileAvatarCubit extends Cubit { )); } catch (e) { emit(ProfileAvatarState.error(errorMessage: e.toString())); - print(e); } } } diff --git a/lib/features/calendar/presentation/pages/calendar_screen.dart b/lib/features/calendar/presentation/pages/calendar_screen.dart index be3f22ed..cf9ca83e 100644 --- a/lib/features/calendar/presentation/pages/calendar_screen.dart +++ b/lib/features/calendar/presentation/pages/calendar_screen.dart @@ -163,7 +163,6 @@ class CalendarScreen extends StatelessWidget { ); } else { diary = state.calendarList[index].diary as Map; - print(state.calendarList[index]); return InkWell( borderRadius: BorderRadiusStyle.circleBorder8, onTap: () => GoRouter.of(context).go( diff --git a/lib/features/calendar/services/calendar_service.g.dart b/lib/features/calendar/services/calendar_service.g.dart index 903145dc..787983c8 100644 --- a/lib/features/calendar/services/calendar_service.g.dart +++ b/lib/features/calendar/services/calendar_service.g.dart @@ -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( diff --git a/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart b/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart index 413ff885..ef4a3f3a 100644 --- a/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart +++ b/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart @@ -53,7 +53,6 @@ class ChatRoomCubit extends Cubit { currentPage++; } catch (e) { - print(e); emit(ChatRoomState.error(errorMessage: 'Ошибка получеия данных')); } } @@ -75,7 +74,6 @@ class ChatRoomCubit extends Cubit { isLoading: isLoading, )); } catch (e) { - print(e); emit(ChatRoomState.error(errorMessage: 'Ошибка получеия данных')); } } diff --git a/lib/features/chat/repositories/chat_repository.dart b/lib/features/chat/repositories/chat_repository.dart index 84347c68..228709f6 100644 --- a/lib/features/chat/repositories/chat_repository.dart +++ b/lib/features/chat/repositories/chat_repository.dart @@ -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; } } diff --git a/lib/features/chat/services/chat_service.g.dart b/lib/features/chat/services/chat_service.g.dart index 77366053..978a0e43 100644 --- a/lib/features/chat/services/chat_service.g.dart +++ b/lib/features/chat/services/chat_service.g.dart @@ -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( diff --git a/lib/features/consultant/become_consultant/repositories/consultant_repository.dart b/lib/features/consultant/become_consultant/repositories/consultant_repository.dart index f0ea7897..3abdc799 100644 --- a/lib/features/consultant/become_consultant/repositories/consultant_repository.dart +++ b/lib/features/consultant/become_consultant/repositories/consultant_repository.dart @@ -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; } } diff --git a/lib/features/consultant/become_consultant/services/consultant_service.g.dart b/lib/features/consultant/become_consultant/services/consultant_service.g.dart index 870c1d5d..d895b861 100644 --- a/lib/features/consultant/become_consultant/services/consultant_service.g.dart +++ b/lib/features/consultant/become_consultant/services/consultant_service.g.dart @@ -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( diff --git a/lib/features/diary/presentation/bloc/diary_cubit.dart b/lib/features/diary/presentation/bloc/diary_cubit.dart index da058d9e..d5b4fede 100644 --- a/lib/features/diary/presentation/bloc/diary_cubit.dart +++ b/lib/features/diary/presentation/bloc/diary_cubit.dart @@ -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 { 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 { 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> getGlossaryListByQuery(String query) async { + return await glossaryRepository.getGlossaryListByQuery(query); + } } diff --git a/lib/features/diary/presentation/pages/diary_screen.dart b/lib/features/diary/presentation/pages/diary_screen.dart index 9a6dbf4e..32b70516 100644 --- a/lib/features/diary/presentation/pages/diary_screen.dart +++ b/lib/features/diary/presentation/pages/diary_screen.dart @@ -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 { 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 { _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 { } _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 { _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 { ); } - _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 { 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 { setState(() { _selectedDay = selectedDay; _focusedDay = focusedDay; + currentSelectedMealNumber = 1; }); diaryCubit.getDiaryDay(_selectedDay!.toString()); } @@ -255,6 +254,14 @@ class _DiaryScreenState extends State { _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 { color: appTheme.blueA400, width: 2, ), + color: Colors.white, shape: BoxShape.circle, ), ), @@ -277,9 +285,134 @@ class _DiaryScreenState extends State { ); } - _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), diff --git a/lib/features/diary/repositories/diary_repository.dart b/lib/features/diary/repositories/diary_repository.dart index c11d5c0f..dde8a702 100644 --- a/lib/features/diary/repositories/diary_repository.dart +++ b/lib/features/diary/repositories/diary_repository.dart @@ -9,13 +9,29 @@ class DiaryRepository { }); Future getDiaryByDate(String date) async { - print(await _getDiaryIndexByDate(date)); return (await diaryService.getDiaryDay( index: await _getDiaryIndexByDate(date), - )).diary; + )) + .diary; } Future _getDiaryIndexByDate(String date) async { return (await diaryService.getDiaryIndexByDate(date: date)).id; } + + Future 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, + ); + } } diff --git a/lib/features/diary/services/diary_service.dart b/lib/features/diary/services/diary_service.dart index 5f5cd8c8..cdce2dd4 100644 --- a/lib/features/diary/services/diary_service.dart +++ b/lib/features/diary/services/diary_service.dart @@ -18,4 +18,13 @@ abstract class DiaryService { Future getDiaryDay({ @Path('diary_id') required int index, }); + + @POST('/api/diary/{diary_id}/meal/{meal_id}/portions/create') + Future 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, + }); } diff --git a/lib/features/diary/services/diary_service.g.dart b/lib/features/diary/services/diary_service.g.dart index ee5f5e0b..b145757c 100644 --- a/lib/features/diary/services/diary_service.g.dart +++ b/lib/features/diary/services/diary_service.g.dart @@ -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 addProductToMeal({ + required int diaryId, + required int mealId, + required String productName, + required String portion, + required int quantity, + }) async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + 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(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(_options); + } + RequestOptions _setStreamType(RequestOptions requestOptions) { if (T != dynamic && !(requestOptions.responseType == ResponseType.bytes || diff --git a/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart b/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart index f387a4eb..83df5eb0 100644 --- a/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart +++ b/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart @@ -37,9 +37,7 @@ class FeedCubit extends Cubit { try { if (currentPage < lastPage) { - print('before: $currentPage'); currentPage++; - print('after: $currentPage'); final feedBlogPosts = await feedRepository.getFeedBlogPosts( page: currentPage, query: _query, diff --git a/lib/features/feed/services/feed_service.g.dart b/lib/features/feed/services/feed_service.g.dart index 31b022c4..952b5416 100644 --- a/lib/features/feed/services/feed_service.g.dart +++ b/lib/features/feed/services/feed_service.g.dart @@ -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( diff --git a/lib/features/glossary/models/glossary_model.dart b/lib/features/glossary/models/glossary_model.dart new file mode 100644 index 00000000..8e437d95 --- /dev/null +++ b/lib/features/glossary/models/glossary_model.dart @@ -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 glossariesList, + }) = _GlossaryPaginationModel; + + factory GlossaryPaginationModel.fromJson(Map 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 json) => _$GlossaryModelFromJson(json); +} diff --git a/lib/features/glossary/models/glossary_model.freezed.dart b/lib/features/glossary/models/glossary_model.freezed.dart new file mode 100644 index 00000000..d5e1556f --- /dev/null +++ b/lib/features/glossary/models/glossary_model.freezed.dart @@ -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 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 json) { + return _GlossaryPaginationModel.fromJson(json); +} + +/// @nodoc +mixin _$GlossaryPaginationModel { + @JsonKey(name: 'data') + List get glossariesList => throw _privateConstructorUsedError; + + /// Serializes this GlossaryPaginationModel to a JSON map. + Map 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 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 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, + ) 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 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, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$GlossaryPaginationModelImpl implements _GlossaryPaginationModel { + const _$GlossaryPaginationModelImpl( + {@JsonKey(name: 'data') + required final List glossariesList}) + : _glossariesList = glossariesList; + + factory _$GlossaryPaginationModelImpl.fromJson(Map json) => + _$$GlossaryPaginationModelImplFromJson(json); + + final List _glossariesList; + @override + @JsonKey(name: 'data') + List 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 toJson() { + return _$$GlossaryPaginationModelImplToJson( + this, + ); + } +} + +abstract class _GlossaryPaginationModel implements GlossaryPaginationModel { + const factory _GlossaryPaginationModel( + {@JsonKey(name: 'data') + required final List glossariesList}) = + _$GlossaryPaginationModelImpl; + + factory _GlossaryPaginationModel.fromJson(Map json) = + _$GlossaryPaginationModelImpl.fromJson; + + @override + @JsonKey(name: 'data') + List 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 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 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 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 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 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 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; +} diff --git a/lib/features/glossary/models/glossary_model.g.dart b/lib/features/glossary/models/glossary_model.g.dart new file mode 100644 index 00000000..7fbd6b30 --- /dev/null +++ b/lib/features/glossary/models/glossary_model.g.dart @@ -0,0 +1,35 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'glossary_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$GlossaryPaginationModelImpl _$$GlossaryPaginationModelImplFromJson( + Map json) => + _$GlossaryPaginationModelImpl( + glossariesList: (json['data'] as List) + .map((e) => GlossaryModel.fromJson(e as Map)) + .toList(), + ); + +Map _$$GlossaryPaginationModelImplToJson( + _$GlossaryPaginationModelImpl instance) => + { + 'data': instance.glossariesList, + }; + +_$GlossaryModelImpl _$$GlossaryModelImplFromJson(Map json) => + _$GlossaryModelImpl( + id: (json['id'] as num).toInt(), + name: json['name'] as String, + grInPortion: (json['portion_mass_gr'] as num).toInt(), + ); + +Map _$$GlossaryModelImplToJson(_$GlossaryModelImpl instance) => + { + 'id': instance.id, + 'name': instance.name, + 'portion_mass_gr': instance.grInPortion, + }; diff --git a/lib/features/glossary/repositories/glossary_repository.dart b/lib/features/glossary/repositories/glossary_repository.dart new file mode 100644 index 00000000..c0c3233e --- /dev/null +++ b/lib/features/glossary/repositories/glossary_repository.dart @@ -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> getGlossaryListByQuery(String query) async { + try { + return (await glossaryService.getGlossaryByQuery(query: query)).glossariesList; + } catch (e) { + rethrow; + } + } +} diff --git a/lib/features/glossary/services/glossary_service.dart b/lib/features/glossary/services/glossary_service.dart new file mode 100644 index 00000000..8c28bb16 --- /dev/null +++ b/lib/features/glossary/services/glossary_service.dart @@ -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 getGlossaryByQuery({ + @Query('search') required String query, + }); +} diff --git a/lib/features/glossary/services/glossary_service.g.dart b/lib/features/glossary/services/glossary_service.g.dart new file mode 100644 index 00000000..bd3a1137 --- /dev/null +++ b/lib/features/glossary/services/glossary_service.g.dart @@ -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 getGlossaryByQuery( + {required String query}) async { + final _extra = {}; + final queryParameters = {r'search': query}; + final _headers = {}; + const Map? _data = null; + final _options = _setStreamType(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>(_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(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(); + } +} diff --git a/lib/features/plans/services/plans_service.g.dart b/lib/features/plans/services/plans_service.g.dart index bce687f0..b0e19fb9 100644 --- a/lib/features/plans/services/plans_service.g.dart +++ b/lib/features/plans/services/plans_service.g.dart @@ -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( diff --git a/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart b/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart index 9830b4be..409225e1 100644 --- a/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart +++ b/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart @@ -22,7 +22,6 @@ class ProfileCubit extends Cubit { )); } catch (e) { emit(ProfileState.error(errorMessage: e.toString())); - print(e); } } @@ -41,7 +40,6 @@ class ProfileCubit extends Cubit { )); } catch (e) { emit(ProfileState.error(errorMessage: e.toString())); - print(e); } } @@ -59,7 +57,6 @@ class ProfileCubit extends Cubit { await getMyProfile(period: _currentPeriod); } catch (e) { emit(ProfileState.error(errorMessage: e.toString())); - print(e); } } @@ -71,7 +68,6 @@ class ProfileCubit extends Cubit { await getMyProfile(period: _currentPeriod); } catch (e) { emit(ProfileState.error(errorMessage: e.toString())); - print(e); } } @@ -81,7 +77,6 @@ class ProfileCubit extends Cubit { try { return (await chatRepository.getChatRoomIdByUserSlug(slug: slug)).id; } catch (e) { - print(e); rethrow; } } diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart index 35101143..b94f2f71 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -277,7 +277,7 @@ class _ProfileScreenState extends State { ), 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, diff --git a/lib/features/profile/services/profile_service.g.dart b/lib/features/profile/services/profile_service.g.dart index aff8547f..274c84b8 100644 --- a/lib/features/profile/services/profile_service.g.dart +++ b/lib/features/profile/services/profile_service.g.dart @@ -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( diff --git a/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart b/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart index f666121c..aad1afb4 100644 --- a/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart +++ b/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart @@ -258,7 +258,7 @@ class RecipeCreateCubit extends Cubit { var currentState = state as RecipeCreateStateLoaded; final Map> productNutritionalValues = await recipeRepository.inputProduct(input); - print(productNutritionalValues); + var updatedState = currentState.copyWith( productNameController: TextEditingController(text: input), autocompleteList: productNutritionalValues['product_nutritional_value'] ?? [], diff --git a/lib/features/recipes/presentation/pages/recipe_create_screen.dart b/lib/features/recipes/presentation/pages/recipe_create_screen.dart index f5a1cd10..2398edc9 100644 --- a/lib/features/recipes/presentation/pages/recipe_create_screen.dart +++ b/lib/features/recipes/presentation/pages/recipe_create_screen.dart @@ -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; } } diff --git a/lib/features/recipes/presentation/pages/recipe_edit_screen.dart b/lib/features/recipes/presentation/pages/recipe_edit_screen.dart index 51fcd982..d1f1c7fc 100644 --- a/lib/features/recipes/presentation/pages/recipe_edit_screen.dart +++ b/lib/features/recipes/presentation/pages/recipe_edit_screen.dart @@ -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}')]), diff --git a/lib/features/recipes/reporitories/recipe_repository.dart b/lib/features/recipes/reporitories/recipe_repository.dart index e07f5dc5..bea4d06d 100644 --- a/lib/features/recipes/reporitories/recipe_repository.dart +++ b/lib/features/recipes/reporitories/recipe_repository.dart @@ -39,8 +39,7 @@ class RecipeRepository { }; }).toList() ?? []; - print(ingredientsMap); - print(stepsMap); + return await recipeService.publishRecipe( recipe.type, recipe.state, diff --git a/lib/features/recipes/services/recipe_service.g.dart b/lib/features/recipes/services/recipe_service.g.dart index c32c9e8a..20e02b55 100644 --- a/lib/features/recipes/services/recipe_service.g.dart +++ b/lib/features/recipes/services/recipe_service.g.dart @@ -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( diff --git a/lib/features/registration/services/registration_service.g.dart b/lib/features/registration/services/registration_service.g.dart index 4aaccede..c7b90410 100644 --- a/lib/features/registration/services/registration_service.g.dart +++ b/lib/features/registration/services/registration_service.g.dart @@ -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( diff --git a/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart b/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart index 488524e8..811a4bbf 100644 --- a/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart +++ b/lib/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart @@ -34,7 +34,6 @@ class SettingsCubit extends Cubit { profileDetailsModel: profileDetailsModel, ); } catch (e) { - print(e); rethrow; } finally { await init(); @@ -49,7 +48,6 @@ class SettingsCubit extends Cubit { profileSettingsModel: profileSettingsModel, ); } catch (e) { - print(e); rethrow; } finally { await init(); diff --git a/lib/features/settings/services/settings_service.g.dart b/lib/features/settings/services/settings_service.g.dart index f1d38de5..53d31175 100644 --- a/lib/features/settings/services/settings_service.g.dart +++ b/lib/features/settings/services/settings_service.g.dart @@ -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( diff --git a/lib/locator_service.dart b/lib/locator_service.dart index a1cecd73..43d3082d 100644 --- a/lib/locator_service.dart +++ b/lib/locator_service.dart @@ -23,6 +23,8 @@ import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_cubit.dart'; import 'package:eatvio_app/features/feed/repositories/feed_repository.dart'; import 'package:eatvio_app/features/feed/services/feed_service.dart'; +import 'package:eatvio_app/features/glossary/repositories/glossary_repository.dart'; +import 'package:eatvio_app/features/glossary/services/glossary_service.dart'; import 'package:eatvio_app/features/plans/presentation/bloc/plans_cubit/plans_cubit.dart'; import 'package:eatvio_app/features/plans/repositories/plans_repository.dart'; import 'package:eatvio_app/features/plans/services/plans_service.dart'; @@ -63,7 +65,7 @@ Future init() async { sl.registerFactory(() => PlansCubit(plansRepository: sl())); sl.registerFactory(() => SettingsCubit(profileRepository: sl(), settingsRepository: sl())); sl.registerFactory(() => RegisterConsultantCubit(consultantRepository: sl())); - sl.registerFactory(() => DiaryCubit(diaryRepository: sl())); + sl.registerFactory(() => DiaryCubit(diaryRepository: sl(), glossaryRepository: sl())); // Repository sl.registerLazySingleton(() => ChatRepository(chatService: sl())); @@ -76,6 +78,7 @@ Future init() async { sl.registerLazySingleton(() => SettingsRepository(settingsService: sl())); sl.registerLazySingleton(() => ConsultantRepository(consultantService: sl())); sl.registerLazySingleton(() => DiaryRepository(diaryService: sl())); + sl.registerLazySingleton(() => GlossaryRepository(glossaryService: sl())); // Services sl.registerLazySingleton(() => ChatService(sl())); @@ -88,6 +91,7 @@ Future init() async { sl.registerLazySingleton(() => SettingsService(sl())); sl.registerLazySingleton(() => ConsultantService(sl())); sl.registerLazySingleton(() => DiaryService(sl())); + sl.registerLazySingleton(() => GlossaryService(sl())); // External sl.registerLazySingleton( diff --git a/lib/old/auth/auth_screen/auth_screen.dart b/lib/old/auth/auth_screen/auth_screen.dart index 4548111e..da510bd8 100644 --- a/lib/old/auth/auth_screen/auth_screen.dart +++ b/lib/old/auth/auth_screen/auth_screen.dart @@ -181,7 +181,7 @@ class _AuthScreenState extends State { body: json.encode(credentials), encoding: utf8, ); - print(response.statusCode); + if (response.statusCode == 200) { var res = await jsonDecode(response.body); final token = res['token']; diff --git a/lib/old/diary/diary_edit_screen/diary_edit_screen.dart b/lib/old/diary/diary_edit_screen/diary_edit_screen.dart index 57e167d7..e69de29b 100644 --- a/lib/old/diary/diary_edit_screen/diary_edit_screen.dart +++ b/lib/old/diary/diary_edit_screen/diary_edit_screen.dart @@ -1,1253 +0,0 @@ -// ignore_for_file: unused_local_variable - -/*import '../../../features/diary/presentation/bloc/diary_bloc.dart'; -import 'models/diary_edit_model.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_form_builder/flutter_form_builder.dart'; -import 'package:fl_chart/fl_chart.dart'; -import 'package:image_picker/image_picker.dart'; -import 'package:flutter_dotenv/flutter_dotenv.dart'; - -import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart'; -import 'package:eatvio_app/widgets/custom_edit_drop_down.dart'; -import 'package:eatvio_app/widgets/custom_outlined_button.dart'; -import 'package:eatvio_app/widgets/custom_scale_element.dart'; -import 'package:carousel_slider/carousel_slider.dart'; - -// ignore: must_be_immutable -class DiaryEditScreen extends StatelessWidget { - DiaryEditScreen({Key? key}) : super(key: key); - - static Widget builder(BuildContext context) { - return BlocProvider( - create: (context) => DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel()))..add(DiaryEditInitialEvent()), - child: DiaryEditScreen(), - ); - } - - Widget build(BuildContext context) { - return BlocBuilder( - builder: (context, state) { - if (state is DiaryEditInitialState) { - // Это начальное состояние, данные ещё не загружены. - return Container( - color: Colors.white, - ); - } else if (state is DiaryEditLoadedState) { - // Данные загружены, можно строить экран. - return _buildDiaryEditScreen(context, state); - } else if (state is DiaryEditErrorState) { - // Произошла ошибка при загрузке данных. - return Center(child: Text(state.errorMessage)); - } else { - // Другие состояния, если они есть. - return Container(); // Пустой контейнер для необработанных состояний. - } - }, - ); - } - - Widget _buildDiaryEditScreen(BuildContext context, DiaryEditLoadedState state) { - return RefreshIndicator( - onRefresh: refreshPage(context), - child: Stack( - alignment: Alignment.bottomCenter, - children: [ - FormBuilder( - child: Scaffold( - appBar: AppBar( - toolbarHeight: 0, - automaticallyImplyLeading: false, - ), - backgroundColor: Color.fromARGB(255, 240, 242, 245), - resizeToAvoidBottomInset: true, - body: SizedBox( - width: double.maxFinite, - child: Column( - children: [ - Expanded( - child: SingleChildScrollView( - child: Padding( - padding: EdgeInsets.only(bottom: 5.v), - child: Column( - children: [ - _buildHeaderRow(context, state), - SizedBox(height: 30.v), - _buildWakupRetire(context, state), - SizedBox(height: 30.v), - _buildMeal(context, state), - SizedBox(height: 20.v), - _buildMood(context, state), - SizedBox(height: 30.v), - _buildNutritionChart(context, state), - SizedBox(height: 30.v), - _buildComment(context, state), - ], - ), - ), - ), - ), - ], - ), - ), - ), - ), - _buildEndDay(context), - ], - ), - ); - } - - _buildEndDay(BuildContext context) { - return CustomOutlinedButton( - text: "Закончить день", - margin: EdgeInsets.only( - left: 16.h, - right: 16.h, - bottom: 16.v, - ), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - decoration: BoxDecoration( - color: Colors.transparent, - ), - onPressed: onFinishDayPressed(context), - // Установите прозрачный фон - ); - } - - refreshPage(BuildContext context) { - return () async { - context.read().add(RefreshEvent()); - }; - } - - /// Section Widget - _buildHeaderRow(BuildContext context, DiaryEditLoadedState state) { - final day = state.diaryId; - return Container( - margin: EdgeInsets.symmetric(horizontal: 16.h, vertical: 16.h), - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: EdgeInsets.only(top: 1.v), - child: Column( - children: [ - Align( - alignment: Alignment.centerRight, - child: Text( - "$day день", - style: CustomTextStyles.titleMediumBlack, - ), - ), - SizedBox(height: 2.v), - Text( - state.diaryDate.toString(), - style: CustomTextStyles.bodyMediumBluegray800, - ), - ], - ), - ), - ], - ), - ); - } - - /// Section Widget - _buildAddProduct(BuildContext context, DiaryEditLoadedState state) { - return CustomOutlinedButton( - text: "Добавить продукт", - margin: EdgeInsets.symmetric(horizontal: 10.h), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: addProduct(context), - ); - } - - addProduct(BuildContext context) { - return () { - context.read().add(AddPortionEvent()); - }; - } - - /// Section Widget - _buildAddPhoto(BuildContext context, DiaryEditLoadedState state) { - bool isLoading = state.isLoading; - return GestureDetector( - onTap: addImage(context, isLoading), - child: Stack( - children: [ - if (!isLoading) - Container( - margin: EdgeInsets.symmetric(horizontal: 10.h), - padding: EdgeInsets.symmetric( - horizontal: 40.h, - vertical: 80.v, - ), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - mainAxisSize: MainAxisSize.min, - children: [ - // Показывайте прелоадер, если загрузка активна - - Padding( - padding: EdgeInsets.only( - left: 7.h, - top: 5.v, - ), - child: Text( - "Добавить фото", - selectionColor: appTheme.blueA400, - ), - ), - Spacer(), - Icon( - Icons.photo_library, - color: appTheme.blueGray300, - ), - ], - ), - ), - if (isLoading) - Container( - margin: EdgeInsets.symmetric(horizontal: 10.h), - padding: EdgeInsets.symmetric( - horizontal: 40.h, - vertical: 80.v, - ), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, - ), - child: Center( - child: CircularProgressIndicator(color: appTheme.blueGray300), // Замените на свой прелоадер при необходимости - ), - ), - ], - ), - ); - } - - addImage(BuildContext context, bool isLoading) { - if (!isLoading) { - return () async { - final picker = ImagePicker(); - List? images = await picker.pickMultiImage(); - if (images.isNotEmpty) { - for (var image in images) { - context.read().add(UploadImages(image)); - } - } - }; - } - } - - _buildMeal(BuildContext context, DiaryEditLoadedState state) { - final digitsOnly = FilteringTextInputFormatter.digitsOnly; - List _options = state.autocompleteList!.map((dynamic item) => item as String).toList(); - //print(_options); - FocusNode focusNodeName = FocusNode(); - return Container( - margin: EdgeInsets.symmetric(horizontal: 16.h), - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Время приема пищи", - style: CustomTextStyles.bodyMediumBlack900, - ), - Expanded( - // Adding Expanded widget - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), - child: ConstrainedBox( - constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width - 260, - ), - child: GestureDetector( - onTap: () => _selectMealTime(context, state), - child: AbsorbPointer( - child: CustomTextFormField( - hintText: state.mealTimeController?.format(context).toString(), - autofocus: false, - ), - ), - ), - ), - ), - ), - ], - ), - ), - SizedBox(height: 20.v), - Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), - child: BlocSelector( - selector: (state) => state.diaryEditModelObj, - builder: (context, diaryEditModelObj) { - return CustomDropDown( - hintText: "Прием пищи", - items: diaryEditModelObj?.mealList, - contentPadding: EdgeInsets.symmetric( - horizontal: 10.h, - vertical: 9.v, - ), - defaultValue: diaryEditModelObj?.mealList[0], - onChanged: changeMeal(context, state), - ); - }, - ), - ), - SizedBox(height: 20.v), - Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), - child: RawAutocomplete( - optionsBuilder: buildOptions(_options), - fieldViewBuilder: ( - BuildContext context, - TextEditingController productEditingController, - FocusNode focusNodeName, - VoidCallback onFieldSubmitted, - ) { - if (state.isAdded) { - print("Clear"); - } - return CustomTextFormField( - hintText: "Введите название продукта", - controller: productEditingController, - focusNode: focusNodeName, - onChanged: getAutocomplete(context, focusNodeName), - ); - }, - optionsViewBuilder: ( - BuildContext context, - AutocompleteOnSelected onSelected, - Iterable options, - ) { - return Align( - alignment: Alignment.topLeft, - child: Material( - elevation: 4.0, - child: SizedBox( - height: 200.0, - child: ListView.builder( - padding: const EdgeInsets.all(8.0), - itemCount: options.length, - itemBuilder: (BuildContext context, int index) { - final String option = options.elementAt(index); - return GestureDetector( - onTap: selectProduct(onSelected, option, state), - child: ListTile( - title: Text(option), - ), - ); - }, - ), - ), - ), - ); - }, - ), - ), - SizedBox(height: 20.v), - if (state.moderationExpanded) - Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), - child: GestureDetector( - onTap: () => openCaloriesDialog(context, state), - child: Text("Отправить на модерацию"), - ), - ), - SizedBox(height: 20.v), - Padding( - padding: EdgeInsets.symmetric(horizontal: 10.h), - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - CustomTextFormField( - width: 150.h, - hintText: "Кол-во", - textInputAction: TextInputAction.done, - // focusNode: focusNodeQuantity, - controller: state.productQuantityController, - keyboardType: TextInputType.number, - inputFormatters: [digitsOnly], - ), - Padding( - padding: EdgeInsets.only(left: 30.h), - child: BlocSelector( - selector: (state) => state.diaryEditModelObj, - builder: (context, diaryEditModelObj) { - return CustomDropDown( - items: diaryEditModelObj?.portionList, - defaultValue: diaryEditModelObj?.portionList?[0], - onChanged: changePortion(context, state), - ); - }, - ), - ), - ], - ), - ), - ), - SizedBox(height: 30.v), - _buildAddProduct(context, state), - SizedBox(height: 30.v), - ...state.portions!.map((portion) => _buildProduct(context, portion)).toList(), - SizedBox(height: 30.v), - /*...state.photos != null - ? state.photos!.isEmpty - ? [Text('Фото пока нет')] - : state.photos! - .map((photo) => _buildPhoto(context, photo)) - .toList() - : [Text('Фото нет')],*/ - _buildCarousel(context, state), - SizedBox(height: 20.v), - _buildAddPhoto(context, state), - SizedBox(height: 30.v), - Text( - "Ваша сытость после приёма пищи", - style: CustomTextStyles.bodyMediumBlack900, - ), - SizedBox(height: 15.v), - BlocBuilder( - builder: (context, state) { - if (state is DiaryEditLoadedState) { - return Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text("😭"), - ScaleElement( - color: Colors.red, - isSelected: state.selectedSatiety == 0, - onTap: changeSatiety(context, 0), - ), - ScaleElement( - color: Colors.orange, - isSelected: state.selectedSatiety == 1, - onTap: changeSatiety(context, 1), - ), - ScaleElement( - color: Colors.yellow, - isSelected: state.selectedSatiety == 2, - onTap: changeSatiety(context, 2), - ), - ScaleElement( - color: Colors.lime, - isSelected: state.selectedSatiety == 3, - onTap: changeSatiety(context, 3), - ), - ScaleElement( - color: Colors.lightGreen, - isSelected: state.selectedSatiety == 4, - onTap: changeSatiety(context, 4), - ), - ScaleElement( - color: Colors.green, - isSelected: state.selectedSatiety == 5, - onTap: changeSatiety(context, 5), - ), - Text("😊"), - // Остальные элементы шкалы - ], - ); - } else { - return Container(); // Возвращаем пустой контейнер, если состояние не является DiaryEditLoadedState - } - }, - ), - ], - ), - ); - } - - openCaloriesDialog(BuildContext context, DiaryEditLoadedState state) { - showDialog( - context: context, - builder: (BuildContext dialogContext) { - return AlertDialog( - title: Text('Введите информацию о продукте'), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - CustomTextFormField( - hintText: "Название", - controller: state.productNameController, - ), - SizedBox(height: 10.v), - CustomTextFormField( - hintText: "Энергетическая ценность на 100", - keyboardType: TextInputType.number, - controller: state.caloriesController, - ), - SizedBox(height: 10.v), - CustomTextFormField( - hintText: "Белки на 100г", - keyboardType: TextInputType.number, - controller: state.proteinsController, - ), - SizedBox(height: 10.v), - CustomTextFormField( - hintText: "Жиры на 100г", - keyboardType: TextInputType.number, - controller: state.fatsController, - ), - SizedBox(height: 10.v), - CustomTextFormField( - hintText: "Углеводы на 100г", - keyboardType: TextInputType.number, - controller: state.carbsController, - ), - ], - ), - actions: [ - TextButton( - onPressed: popDialog(context), - child: Text('Отмена'), - ), - TextButton( - onPressed: triggerModeration( - context, - state.productNameController!.text, - state.caloriesController!.text, - state.proteinsController!.text, - state.fatsController!.text, - state.carbsController!.text, - dialogContext, - ), - child: Text('Отправить'), - ), - ], - ); - }, - ); - } - - triggerModeration( - BuildContext context, - String name, - String energyOn100gr, - String proteinsOn100gr, - String fatsOn100gr, - String carbohydratesOn100gr, - BuildContext dialogContext, - ) { - return () { - // Call function to send moderation with the entered values - context.read().add( - SendModeration( - name: name, - energyOn100gr: energyOn100gr, - proteinsOn100gr: proteinsOn100gr, - fatsOn100gr: fatsOn100gr, - carbohydratesOn100gr: carbohydratesOn100gr, - ), - ); - Navigator.of(dialogContext).pop(); // Dismiss the dialog - }; - } - - popDialog(BuildContext dialogContext) { - return () { - Navigator.of(dialogContext).pop(); // Dismiss the dialog on Cancel button press - }; - } - - changeSatiety(BuildContext context, int satiety) { - return () { - context.read().add(ChangeSatiety(satiety)); - }; - } - - selectProduct(AutocompleteOnSelected onSelected, String option, DiaryEditLoadedState state) { - state.productNameController?.text = option; - return () { - onSelected(option); - }; - } - - getAutocomplete(BuildContext context, FocusNode focusNode) { - return (value) { - /*print(state.autocompleteList - ?.map((dynamic item) => item as String) - .toList());*/ - if (value.length > 2) { - context.read().add(ProductInput(value)); - } - }; - } - - buildOptions(List _options) { - return (TextEditingValue textEditingValue) { - return _options.where((String option) { - return true; - }); - }; - } - - changeMeal(BuildContext context, DiaryEditLoadedState state) { - return (value) { - context.read().add(ChangeMeal(meals: state.meals, value: value)); - }; - } - - changePortion(BuildContext context, DiaryEditLoadedState state) { - return (value) { - context.read().add(ChangePortion(value: value)); - }; - } - - _buildCarousel(BuildContext context, DiaryEditLoadedState state) { - if (state.photos!.isEmpty) { - return Text("Фото нет"); - } else { - return CarouselSlider( - options: CarouselOptions(height: 340.0), - items: state.photos!.map((photo) { - return _buildPhoto(context, photo); // Assuming photos are stored as strings - }).toList(), - ); - } - } - - _buildProduct(BuildContext context, Map portion) { - return Container( - margin: EdgeInsets.symmetric(horizontal: 10.h), - padding: EdgeInsets.symmetric( - horizontal: 8.h, - vertical: 6.v, - ), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: EdgeInsets.only( - left: 7.h, - top: 5.v, - ), - child: Text( - portion['product_name'].length > 8 ? portion['product_name'].substring(0, 8) : portion['product_name'], - style: CustomTextStyles.titleMedium16, - ), - ), - Padding( - padding: EdgeInsets.only( - left: 20.h, - top: 3.v, - bottom: 3.v, - ), - child: Text( - portion['quantity'].toString() + ' ' + portion['portion'].toString().tr, - ), - ), - Spacer(), - GestureDetector( - onTap: removePortion(context, portion), - child: Padding( - padding: const EdgeInsets.only(right: 10), - child: Icon( - Icons.close, - color: appTheme.blueGray300, - ), - ), - ), - ], - ), - ); - } - - _buildPhoto(BuildContext context, Map photo) { - return Stack( - children: [ - Container( - margin: EdgeInsets.symmetric(horizontal: 10.h, vertical: 10.h), - decoration: AppDecoration.fillGray.copyWith( - borderRadius: BorderRadiusStyle.roundedBorder5, - ), - child: Image.network( - dotenv.env['STORAGE_URL']! + photo['path'], - ), - ), - Positioned( - top: 5, - right: 5, - child: GestureDetector( - onTap: removePhoto(context, photo), - child: Container( - padding: EdgeInsets.all(5), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.transparent, - ), - child: Icon( - Icons.close, - color: appTheme.blueGray300, - ), - ), - ), - ), - ], - ); - } - - removePortion(BuildContext context, Map portion) { - return () { - context.read().add(RemovePortionEvent(portion['id'])); - }; - } - - removePhoto(BuildContext context, Map photo) { - return () { - context.read().add(RemoveImageEvent(photo['id'].toString(), photo['path'])); - }; - } - - _buildNutritionChart(BuildContext context, DiaryEditLoadedState state) { - final List recommendedValues = state.recommendedChartValues; // Рекомендуемые значения: калории, жиры, белки, углеводы - final List consumedValues = state.consumedChartValues; // - return Container( - margin: EdgeInsets.symmetric(horizontal: 16.h), - padding: EdgeInsets.symmetric( - horizontal: 10.h, - vertical: 16.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox(height: 3.v), - Text( - "Ваш КБЖУ", - style: theme.textTheme.titleMedium, - ), - SizedBox(height: 8.v), - Text( - "От дневной суточной нормы", - style: CustomTextStyles.bodyMediumBluegray800, - ), - SizedBox(height: 19.v), - Align( - alignment: Alignment.centerRight, - child: Padding( - padding: EdgeInsets.only( - left: 30.h, - right: 12.h, - ), - child: AspectRatio( - aspectRatio: 1.5, - child: BarChart( - BarChartData( - alignment: BarChartAlignment.spaceAround, - barTouchData: BarTouchData(enabled: false), - titlesData: FlTitlesData( - show: true, - bottomTitles: AxisTitles( - sideTitles: SideTitles( - showTitles: true, - //getTitlesWidget: (value, meta) => newMethod(value), - ), - ), - ), - borderData: FlBorderData(show: false), - barGroups: [ - BarChartGroupData( - x: 0, - barRods: [ - BarChartRodData( - toY: consumedValues[0] / recommendedValues[0] * 100, - color: checkConsumedValues([recommendedValues[0]], [consumedValues[1]]) ? Colors.red : Colors.blue, - ), - ], - ), - BarChartGroupData( - x: 1, - barRods: [ - BarChartRodData( - toY: consumedValues[1] / recommendedValues[1] * 100, - color: checkConsumedValues([recommendedValues[1]], [consumedValues[1]]) ? Colors.red : Colors.blue, - ), - ], - ), - BarChartGroupData( - x: 2, - barRods: [ - BarChartRodData( - toY: consumedValues[2] / recommendedValues[2] * 100, - color: checkConsumedValues([recommendedValues[2]], [consumedValues[2]]) ? Colors.red : Colors.blue, - ), - ], - ), - BarChartGroupData( - x: 3, - barRods: [ - BarChartRodData( - toY: consumedValues[3] / recommendedValues[3] * 100, - color: checkConsumedValues([recommendedValues[3]], [consumedValues[3]]) ? Colors.red : Colors.blue, - ), - ], - ), - ], - ), - ), - ), - ), - ), - SizedBox(height: 8.v), - SizedBox(height: 2.v), - Padding( - padding: EdgeInsets.only( - left: 10.h, - right: 2.h, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Калорий", - style: theme.textTheme.bodySmall, - ), - Padding( - padding: EdgeInsets.only( - left: 25.h, - bottom: 11.v, - ), - child: Text( - "Белков", - style: theme.textTheme.bodySmall, - ), - ), - Padding( - padding: EdgeInsets.only( - left: 19.h, - bottom: 11.v, - ), - child: Text( - "Жиров", - style: theme.textTheme.bodySmall, - ), - ), - Padding( - padding: EdgeInsets.only( - left: 14.h, - bottom: 11.v, - ), - child: Text( - "Углеводов", - style: theme.textTheme.bodySmall, - ), - ), - ], - ), - ), - SizedBox(height: 2.v), - Padding( - padding: EdgeInsets.only( - left: 10.h, - right: 2.h, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "${consumedValues[0].toInt()} из ${recommendedValues[0].toInt()}", - style: theme.textTheme.bodySmall, - ), - Padding( - padding: EdgeInsets.only( - left: 25.h, - bottom: 11.v, - ), - child: Text( - "${consumedValues[1].toInt()} из ${recommendedValues[1].toInt()}", - style: theme.textTheme.bodySmall, - ), - ), - Padding( - padding: EdgeInsets.only( - left: 19.h, - bottom: 11.v, - ), - child: Text( - "${consumedValues[2].toInt()} из ${recommendedValues[2].toInt()}", - style: theme.textTheme.bodySmall, - ), - ), - Padding( - padding: EdgeInsets.only( - left: 14.h, - bottom: 11.v, - ), - child: Text( - "${consumedValues[3].toInt()} из ${recommendedValues[3].toInt()}", - style: theme.textTheme.bodySmall, - ), - ), - ], - ), - ), - SizedBox(height: 19.v), - if (checkConsumedValues(recommendedValues, consumedValues)) - Text( - "*Превышенная суточная норма", - style: theme.textTheme.labelLarge, - ), - ], - ), - ); - } - - /// Section Widget - _buildComment(BuildContext context, DiaryEditLoadedState state) { - return Container( - margin: EdgeInsets.symmetric(horizontal: 16.h), - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Дополнительная информация для консультанта", - style: theme.textTheme.titleMedium, - textAlign: TextAlign.center, - ), - SizedBox(height: 20.v), - Container( - width: 320.h, - child: CustomTextFormField( - autofocus: false, - hintText: "Введите информацию для консультанта", - maxLines: 7, - borderDecoration: InputBorder.none, - controller: state.commentController, - ), - ), - ], - ), - ); - } - - _buildWakupRetire(BuildContext context, DiaryEditLoadedState state) { - return Container( - margin: EdgeInsets.symmetric(horizontal: 16.h), - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column( - children: [ - GestureDetector( - onTap: toggleWakeup(context), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - r"Подъем \ отход ко сну", - style: CustomTextStyles.bodyMediumBlack900, - ), - Icon(state.wakeupExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down), - ], - ), - ), - if (state.wakeupExpanded) - Padding( - padding: const EdgeInsets.only(left: 16.0), - child: Column( - children: [ - SizedBox(height: 20.v), - GestureDetector( - onTap: () => _selectWakeupTime(context, state), - child: AbsorbPointer( - child: CustomTextFormField( - hintText: state.wakeupController?.format(context).toString(), - prefix: Icon(Icons.sunny), - autofocus: false, - ), - ), - ), - SizedBox(height: 20.v), - GestureDetector( - onTap: () => _selectRetireTime(context, state), - child: AbsorbPointer( - child: CustomTextFormField( - hintText: state.retireController?.format(context).toString(), - prefix: Icon(Icons.bed), - autofocus: false, - ), - ), - ), - SizedBox(height: 20.v), - ], - ), - ), - ], - ), - ); - } - - toggleWakeup(BuildContext context) { - return () { - BlocProvider.of(context).add(ToggleWakeupExpandedEvent()); - }; - } - - /// Section Widget - - Function() onFinishDayPressed(BuildContext context) { - return () { - showDialog( - context: context, - builder: (BuildContext dialogContext) { - return AlertDialog( - title: Text("Подтвердите действие"), - content: Text("Вы уверены, что хотите завершить день?"), - actions: [ - TextButton( - child: Text("Отмена"), - onPressed: closeDialog(dialogContext), - ), - TextButton( - child: Text("Подтвердить"), - onPressed: sendFinishDayData(dialogContext, context), - ), - ], - ); - }, - ); - }; - } - - Function() sendFinishDayData(BuildContext dialogContext, BuildContext context) { - return () { - closeDialog(dialogContext); - context.read().add(FinishDay()); - }; - } - - Function() closeDialog(BuildContext dialogContext) { - return () { - Navigator.of(dialogContext).pop(); - }; - } - - _buildMood(BuildContext context, DiaryEditLoadedState state) { - return Container( - margin: EdgeInsets.symmetric(horizontal: 16.h), - padding: EdgeInsets.symmetric( - horizontal: 24.h, - vertical: 12.v, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.all(Radius.circular(12)), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 5, - offset: Offset(0, 3), - ), - ], - ), - child: Column( - children: [ - GestureDetector( - onTap: toggleMood(context), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Ваше настроение после приема пищи", - style: CustomTextStyles.bodyMediumBlack900, - ), - Icon(state.moodExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down), - ], - ), - ), - if (state.moodExpanded) - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text("😭"), - ScaleElement( - color: Colors.red, - isSelected: state.selectedMood == 0, - onTap: changeMood(context, 0), - ), - ScaleElement( - color: Colors.orange, - isSelected: state.selectedMood == 1, - onTap: changeMood(context, 1), - ), - ScaleElement( - color: Colors.yellow, - isSelected: state.selectedMood == 2, - onTap: changeMood(context, 2), - ), - ScaleElement( - color: Colors.lime, - isSelected: state.selectedMood == 3, - onTap: changeMood(context, 3), - ), - ScaleElement( - color: Colors.lightGreen, - isSelected: state.selectedMood == 4, - onTap: changeMood(context, 4), - ), - ScaleElement( - color: Colors.green, - isSelected: state.selectedMood == 5, - onTap: changeMood(context, 5), - ), - Text("😊"), - // Остальные элементы шкалы - ], - ), - ], - ), - ); - } - - changeMood(BuildContext context, int satiety) { - return () { - context.read().add(ChangeMood(satiety)); - }; - } - - toggleMood(BuildContext context) { - return () { - BlocProvider.of(context).add(ToggleMoodExpandedEvent()); - }; - } - - Future _selectWakeupTime(BuildContext context, DiaryEditLoadedState state) async { - final TimeOfDay? pickedTime = await showTimePicker( - context: context, - initialTime: state.wakeupController ?? TimeOfDay.now(), - ); - if (pickedTime != null && pickedTime != state.wakeupController) { - state.wakeupController = pickedTime; - context.read().add(WakeupEvent(pickedTime)); - } - } - - Future _selectRetireTime(BuildContext context, DiaryEditLoadedState state) async { - final TimeOfDay? pickedTime = await showTimePicker( - context: context, - initialTime: state.retireController ?? TimeOfDay.now(), - ); - if (pickedTime != null && pickedTime != state.retireController) { - state.retireController = pickedTime; - context.read().add(RetireEvent(pickedTime)); - } - } - - Future _selectMealTime(BuildContext context, DiaryEditLoadedState state) async { - final TimeOfDay? pickedTime = await showTimePicker( - context: context, - initialTime: state.mealTimeController ?? TimeOfDay.now(), - ); - if (pickedTime != null && pickedTime != state.mealTimeController) { - state.mealTimeController = pickedTime; - context.read().add(ChangeMealTime(pickedTime)); - } - } -} - -bool checkConsumedValues(List recommendedValues, List consumedValues) { - for (int i = 0; i < recommendedValues.length; i++) { - if (consumedValues[i] > recommendedValues[i]) { - // Если хотя бы одно потребленное значение превышает рекомендованное - return true; // Возвращаем false - } - } - // Если ни одно потребленное значение не превышает рекомендованное с соответствующим индексом - return false; // Возвращаем true -} -*/ diff --git a/lib/old/diets/diet_create_screen/bloc/diet_create_bloc.dart b/lib/old/diets/diet_create_screen/bloc/diet_create_bloc.dart index 3491e60f..e574c5bc 100644 --- a/lib/old/diets/diet_create_screen/bloc/diet_create_bloc.dart +++ b/lib/old/diets/diet_create_screen/bloc/diet_create_bloc.dart @@ -61,10 +61,6 @@ class DietCreateBloc extends Bloc { if (response.statusCode == 200) { AppRouter.navigatorKey.currentContext?.goNamed('dietSelectScreen'); - } else { - print( - 'Failed to create blog post. Status Code: ${response.statusCode} ${response.body}', - ); } } } diff --git a/lib/old/diets/diet_edit_screen/bloc/diet_edit_bloc.dart b/lib/old/diets/diet_edit_screen/bloc/diet_edit_bloc.dart index 1fd4610a..84fe86c8 100644 --- a/lib/old/diets/diet_edit_screen/bloc/diet_edit_bloc.dart +++ b/lib/old/diets/diet_edit_screen/bloc/diet_edit_bloc.dart @@ -78,7 +78,7 @@ class DietEditBloc extends Bloc { if (state is DietEditLoadedState) { var currentState = state as DietEditLoadedState; int duration = int.parse(currentState.duration!.text) * 7; - print(duration); + var response = await sendDiet(currentState.diet, currentState.name?.text, currentState.details?.text, duration.toString()); if (response.statusCode == 200) { @@ -86,9 +86,7 @@ class DietEditBloc extends Bloc { 'dietScreen', extra: currentState.diet?['id'].toString(), ); - } else { - print('Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}'); - } + } else {} } } diff --git a/lib/old/diets/diet_select_screen/bloc/diet_select_bloc.dart b/lib/old/diets/diet_select_screen/bloc/diet_select_bloc.dart index 69bd3d7b..6ce9ec1b 100644 --- a/lib/old/diets/diet_select_screen/bloc/diet_select_bloc.dart +++ b/lib/old/diets/diet_select_screen/bloc/diet_select_bloc.dart @@ -36,14 +36,11 @@ class DietSelectBloc extends Bloc { 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); - print('Got response'); + if (response.statusCode == 200) { - print('Got 200'); final data = jsonDecode(response.body); if (data is List) { - print('Got List'); if (state is DietSelectLoadedState) { - print('Got loaded'); var currentState = state as DietSelectLoadedState; emit( (currentState).copyWith( @@ -52,7 +49,6 @@ class DietSelectBloc extends Bloc { ), ); } else { - print('Got unloaded'); emit( DietSelectLoadedState( posts: data, diff --git a/lib/old/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart b/lib/old/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart index 05c02fbc..269a2e9e 100644 --- a/lib/old/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart +++ b/lib/old/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart @@ -69,9 +69,7 @@ class BlogPostCreateBloc extends Bloc if (response.statusCode == 200 || response.statusCode == 201) { AppRouter.navigatorKey.currentContext?.goNamed('feedScreen'); - } else { - print('Failed to create blog post. Status Code: ${response.statusCode} ${response.data}'); - } + } else {} } } diff --git a/lib/old/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart b/lib/old/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart index 553e301d..613fe6ec 100644 --- a/lib/old/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart +++ b/lib/old/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart @@ -11,7 +11,8 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; -part 'blog_post_edit_event.dart';part 'blog_post_edit_state.dart'; +part 'blog_post_edit_event.dart'; +part 'blog_post_edit_state.dart'; /// A bloc that manages the state of a BlogPostEdit according to the event that is dispatched to it. class BlogPostEditBloc extends Bloc { @@ -86,9 +87,7 @@ class BlogPostEditBloc extends Bloc { if (response.statusCode == 200) { AppRouter.navigatorKey.currentContext?.goNamed('blogPostScreen', extra: currentState.blog_post?['id'].toString()); - } else { - print('Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}'); - } + } else {} } } diff --git a/lib/old/plans/plan_create_screen/bloc/plan_create_bloc.dart b/lib/old/plans/plan_create_screen/bloc/plan_create_bloc.dart index fa446a7c..00fd741a 100644 --- a/lib/old/plans/plan_create_screen/bloc/plan_create_bloc.dart +++ b/lib/old/plans/plan_create_screen/bloc/plan_create_bloc.dart @@ -61,10 +61,6 @@ class PlanCreateBloc extends Bloc { if (response.statusCode == 200) { AppRouter.navigatorKey.currentContext?.goNamed('planSelectScreen'); - } else { - print( - 'Failed to create blog post. Status Code: ${response.statusCode} ${response.body}', - ); } } } diff --git a/lib/old/plans/plan_edit_screen/bloc/plan_edit_bloc.dart b/lib/old/plans/plan_edit_screen/bloc/plan_edit_bloc.dart index ca78a970..c98331e9 100644 --- a/lib/old/plans/plan_edit_screen/bloc/plan_edit_bloc.dart +++ b/lib/old/plans/plan_edit_screen/bloc/plan_edit_bloc.dart @@ -78,7 +78,7 @@ class PlanEditBloc extends Bloc { if (state is PlanEditLoadedState) { var currentState = state as PlanEditLoadedState; int duration = int.parse(currentState.duration!.text) * 7; - print(duration); + var response = await sendPlan(currentState.plan, currentState.name?.text, currentState.details?.text, duration.toString()); if (response.statusCode == 200) { @@ -86,9 +86,7 @@ class PlanEditBloc extends Bloc { 'planScreen', extra: currentState.plan?['id'].toString(), ); - } else { - print('Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}'); - } + } else {} } } diff --git a/lib/old/plans/plan_select_screen/bloc/plan_select_bloc.dart b/lib/old/plans/plan_select_screen/bloc/plan_select_bloc.dart index a08a00f2..4f2d6bf7 100644 --- a/lib/old/plans/plan_select_screen/bloc/plan_select_bloc.dart +++ b/lib/old/plans/plan_select_screen/bloc/plan_select_bloc.dart @@ -33,14 +33,11 @@ class PlanSelectBloc extends Bloc { final response = await http.get( Uri.parse(baseUrl + '/api/plans/index'), ); - print('Got response'); + if (response.statusCode == 200) { - print('Got 200'); final data = jsonDecode(response.body); if (data is List) { - print('Got List'); if (state is PlanSelectLoadedState) { - print('Got loaded'); var currentState = state as PlanSelectLoadedState; emit( (currentState).copyWith( @@ -49,7 +46,6 @@ class PlanSelectBloc extends Bloc { ), ); } else { - print('Got unloaded'); emit( PlanSelectLoadedState( posts: data, diff --git a/lib/old/profile/my_profile_screen/bloc/my_profile_bloc.dart b/lib/old/profile/my_profile_screen/bloc/my_profile_bloc.dart index 7d08ecfe..5f17e43c 100644 --- a/lib/old/profile/my_profile_screen/bloc/my_profile_bloc.dart +++ b/lib/old/profile/my_profile_screen/bloc/my_profile_bloc.dart @@ -26,7 +26,6 @@ class MyProfileBloc extends Bloc { MyProfileInitialEvent event, Emitter emit, ) async { - print('1'); try { if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); @@ -37,7 +36,7 @@ class MyProfileBloc extends Bloc { 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); - print('2'); + if (response.statusCode == 200) { final data = jsonDecode(response.body); if (data is Map && @@ -101,10 +100,10 @@ class MyProfileBloc extends Bloc { ..addAll(data["requestedPlan"]) ..addAll(data["initedPlan"]); - /*print(data["chartPoints"].length); - print(data["chartPoints"].runtimeType); - print(data["circumferences"].length); - print(data["circumferences"].runtimeType);*/ + /* + + + */ if (data["chartPoints"].length == 1) { data["chartPoints"] = []; } @@ -272,7 +271,7 @@ class MyProfileBloc extends Bloc { Future uploadImageToServer(String imagePath, String? token) async { String url = '${baseUrl}/api/profile/photo/upload'; - print(url); + var request = http.MultipartRequest('POST', Uri.parse(url)); request.headers['Authorization'] = 'Bearer $token'; @@ -284,7 +283,7 @@ class MyProfileBloc extends Bloc { if (streamedResponse.statusCode == 200) { var response = await http.Response.fromStream(streamedResponse); var imageUrl = response.body; - print('Image successfully uploaded'); + return imageUrl; } else { throw Exception( diff --git a/lib/old/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart b/lib/old/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart index 77866907..da258c37 100644 --- a/lib/old/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart +++ b/lib/old/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart @@ -119,9 +119,7 @@ class RecipeEditBloc extends Bloc { 'recipeScreen', extra: currentState.recipe?['id'].toString(), ); - } else { - print('Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}'); - } + } else {} } } @@ -204,7 +202,6 @@ class RecipeEditBloc extends Bloc { } FutureOr _reloadScreen(RecipeEditEvent? event, Emitter emit) async { - print('Reloading..'); if (!await TokenStorage.haveTokenInStorage()) { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } diff --git a/lib/old/recipe/recipe_edit_screen/recipe_edit_screen.dart b/lib/old/recipe/recipe_edit_screen/recipe_edit_screen.dart index 1318211a..28e34909 100644 --- a/lib/old/recipe/recipe_edit_screen/recipe_edit_screen.dart +++ b/lib/old/recipe/recipe_edit_screen/recipe_edit_screen.dart @@ -445,8 +445,7 @@ class RecipeEditScreen extends StatelessWidget { void _trimTags(newValue) { List newTagNames = newValue!.split(',').map((tag) => tag.trim()).toList(); - List> newTags = newTagNames.map((tagName) => {'name': tagName}).toList(); - print(newTags); + newTagNames.map((tagName) => {'name': tagName}).toList(); } Function onTapBack(BuildContext context) { diff --git a/lib/old/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart b/lib/old/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart index 43cad165..6353c7a7 100644 --- a/lib/old/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart +++ b/lib/old/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart @@ -30,14 +30,11 @@ class RecipeSelectBloc extends Bloc { AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final response = await sl().get(baseUrl + '/api/recipes/index'); - print('Got response'); + if (response.statusCode == 200) { - print('Got 200'); final data = response.data['data']; if (data is List) { - print('Got List'); if (state is RecipeSelectLoadedState) { - print('Got loaded'); var currentState = state as RecipeSelectLoadedState; emit( (currentState).copyWith( @@ -46,7 +43,6 @@ class RecipeSelectBloc extends Bloc { ), ); } else { - print('Got unloaded'); emit( RecipeSelectLoadedState( posts: data, diff --git a/lib/old/users/subscribers_screen/bloc/subscribers_bloc.dart b/lib/old/users/subscribers_screen/bloc/subscribers_bloc.dart index a72d6554..aec562b0 100644 --- a/lib/old/users/subscribers_screen/bloc/subscribers_bloc.dart +++ b/lib/old/users/subscribers_screen/bloc/subscribers_bloc.dart @@ -35,23 +35,17 @@ class SubscribersBloc extends Bloc { 'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}', }, ); - print('Got response'); - print(response.statusCode); - print(response.body); + if (response.statusCode == 200) { - print('Got 200'); final data = jsonDecode(response.body); if (data is List) { - print('Got List'); if (state is SubscribersLoadedState) { - print('Got loaded'); var currentState = state as SubscribersLoadedState; emit((currentState).copyWith( subscribers: data, myProfileModelObj: currentState.myProfileModelObj, )); } else { - print('Got unloaded'); emit(SubscribersLoadedState( subscribers: data, )); diff --git a/lib/widgets/custom_text_form_field.dart b/lib/widgets/custom_text_form_field.dart index 4c0b0005..b493f9c9 100644 --- a/lib/widgets/custom_text_form_field.dart +++ b/lib/widgets/custom_text_form_field.dart @@ -19,6 +19,7 @@ class CustomTextFormField extends StatelessWidget { this.prefix, this.prefixConstraints, this.suffix, + this.suffixText, this.suffixConstraints, this.contentPadding, this.inputFormatters, @@ -53,6 +54,7 @@ class CustomTextFormField extends StatelessWidget { final Widget? prefix; final BoxConstraints? prefixConstraints; final Widget? suffix; + final String? suffixText; final BoxConstraints? suffixConstraints; final EdgeInsets? contentPadding; final InputBorder? borderDecoration; @@ -87,6 +89,7 @@ class CustomTextFormField extends StatelessWidget { initialValue: initialValue, cursorColor: appTheme.blueA400, decoration: InputDecoration( + suffixText: suffixText, hintText: hintText ?? "", hintStyle: TextStyle( fontSize: 16, @@ -96,6 +99,11 @@ class CustomTextFormField extends StatelessWidget { prefixIcon: prefix, prefixIconConstraints: prefixConstraints, suffixIcon: suffix, + suffixStyle: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Color(0xFF323F4B), + ), suffixIconConstraints: suffixConstraints, isDense: false, contentPadding: EdgeInsets.symmetric(vertical: 16, horizontal: 12),