feat(diary): add diary, calendar, meals, products, add product button, modal add product

This commit is contained in:
mso7nueh
2024-10-30 11:44:16 +03:00
parent 1883b93315
commit 784b550673
55 changed files with 867 additions and 1407 deletions

View File

@@ -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 {

View File

@@ -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

View File

@@ -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
}

View File

@@ -1,21 +0,0 @@
/*
import 'package:eatvio_app/features/blog_post_create/models/blog_post_create_credentials_model.dart';
import 'package:eatvio_app/features/blog_post_create/services/blog_service.dart';
class BlogRepository {
final BlogService blogService;
BlogRepository({
required this.blogService,
});
Future<BlogPostCreateCredentialsModel> createBlogPost(BlogPostCreateCredentialsModel model) async {
try {
return (await blogService.createBlogPost(model));
} catch (e) {
print(e);
throw (e);
}
}
}
*/

View File

@@ -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(

View File

@@ -16,7 +16,6 @@ class ProfileAvatarCubit extends Cubit<ProfileAvatarState> {
));
} catch (e) {
emit(ProfileAvatarState.error(errorMessage: e.toString()));
print(e);
}
}
}

View File

@@ -163,7 +163,6 @@ class CalendarScreen extends StatelessWidget {
);
} else {
diary = state.calendarList[index].diary as Map<String, dynamic>;
print(state.calendarList[index]);
return InkWell(
borderRadius: BorderRadiusStyle.circleBorder8,
onTap: () => GoRouter.of(context).go(

View File

@@ -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(

View File

@@ -53,7 +53,6 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
currentPage++;
} catch (e) {
print(e);
emit(ChatRoomState.error(errorMessage: 'Ошибка получеия данных'));
}
}
@@ -75,7 +74,6 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
isLoading: isLoading,
));
} catch (e) {
print(e);
emit(ChatRoomState.error(errorMessage: 'Ошибка получеия данных'));
}
}

View File

@@ -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;
}
}

View File

@@ -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(

View File

@@ -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;
}
}

View File

@@ -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(

View File

@@ -1,17 +1,20 @@
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
import 'package:eatvio_app/features/diary/repositories/diary_repository.dart';
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
import 'package:eatvio_app/features/glossary/repositories/glossary_repository.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class DiaryCubit extends Cubit<DiaryState> {
final DiaryRepository diaryRepository;
final GlossaryRepository glossaryRepository;
DiaryCubit({
required this.diaryRepository,
required this.glossaryRepository,
}) : super(const DiaryState.loading());
getDiaryDay(String date) async {
print(date);
emit(const DiaryState.loading());
getDiaryDay(String date, [bool needLoading = true]) async {
if (needLoading) emit(const DiaryState.loading());
try {
emit(DiaryState.loaded(diary: await diaryRepository.getDiaryByDate(date)));
} catch (e) {
@@ -19,4 +22,26 @@ class DiaryCubit extends Cubit<DiaryState> {
throw e;
}
}
addProductToMeal({
required int diaryId,
required int mealId,
required String productName,
required String portion,
required int quantity,
required String date,
}) async {
await diaryRepository.addPortionToMeal(
diaryId: diaryId,
mealId: mealId,
productName: productName,
portion: portion,
quantity: quantity,
);
await getDiaryDay(date, false);
}
Future<List<GlossaryModel>> getGlossaryListByQuery(String query) async {
return await glossaryRepository.getGlossaryListByQuery(query);
}
}

View File

@@ -1,10 +1,13 @@
import 'package:eatvio_app/features/diary/models/diary_day_model.dart';
import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart';
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
import 'package:eatvio_app/locator_service.dart';
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_typeahead/flutter_typeahead.dart';
import 'package:rive/rive.dart';
import 'package:table_calendar/table_calendar.dart';
@@ -21,6 +24,9 @@ class _DiaryScreenState extends State<DiaryScreen> {
DateTime _focusedDay = DateTime.now();
DateTime? _selectedDay = DateTime.now();
int currentSelectedMealNumber = 1;
GlossaryModel? selectedGlossary;
final productNameController = TextEditingController();
final quantityController = TextEditingController();
@override
Widget build(BuildContext context) {
@@ -47,6 +53,7 @@ class _DiaryScreenState extends State<DiaryScreen> {
_calendar(state),
if (state is DiaryStateLoading) _loader(),
if (state is DiaryStateLoaded) _meals(state.diary),
const SizedBox(height: 32),
],
),
),
@@ -57,23 +64,12 @@ class _DiaryScreenState extends State<DiaryScreen> {
}
_arrowDown() {
return GestureDetector(
onTapDown: (_) {
setState(() {
if (_calendarFormat == CalendarFormat.week) {
_calendarFormat = CalendarFormat.month;
} else {
_calendarFormat = CalendarFormat.week;
}
});
},
child: Container(
padding: const EdgeInsets.only(top: 8, bottom: 16),
width: double.infinity,
child: Icon(
_calendarFormat == CalendarFormat.month ? Icons.keyboard_arrow_up_rounded : Icons.keyboard_arrow_down_rounded,
color: Colors.grey.shade600,
),
return Container(
padding: const EdgeInsets.only(top: 8, bottom: 16),
width: double.infinity,
child: Icon(
_calendarFormat == CalendarFormat.month ? Icons.keyboard_arrow_up_rounded : Icons.keyboard_arrow_down_rounded,
color: Colors.grey.shade600,
),
);
}
@@ -97,6 +93,7 @@ class _DiaryScreenState extends State<DiaryScreen> {
_product(
portions[i].productName,
portions[i].quantity,
portions[i].portion,
),
i < portions.length - 1 ? const SizedBox(height: 8) : const SizedBox.shrink(),
],
@@ -104,12 +101,13 @@ class _DiaryScreenState extends State<DiaryScreen> {
);
}
_product(String product, int portion) {
_product(String product, int quantity, String portion) {
portion == 'gr' ? portion = 'г' : portion = 'шт';
return ListTile(
onTap: () {},
trailing: Icon(Icons.more_vert_rounded),
title: Text(product),
subtitle: Text('$portion г'),
subtitle: Text('$quantity $portion'),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
@@ -161,7 +159,7 @@ class _DiaryScreenState extends State<DiaryScreen> {
const SizedBox(height: 12),
_products(diaryDay.meals[currentSelectedMealNumber - 1].portions),
const SizedBox(height: 16),
_addProductButton(),
_addProductButton(diaryDay),
],
),
),
@@ -240,6 +238,7 @@ class _DiaryScreenState extends State<DiaryScreen> {
setState(() {
_selectedDay = selectedDay;
_focusedDay = focusedDay;
currentSelectedMealNumber = 1;
});
diaryCubit.getDiaryDay(_selectedDay!.toString());
}
@@ -255,6 +254,14 @@ class _DiaryScreenState extends State<DiaryScreen> {
_focusedDay = focusedDay;
},
calendarStyle: CalendarStyle(
weekendDecoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
defaultDecoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
selectedDecoration: BoxDecoration(
color: appTheme.blueA400,
shape: BoxShape.circle,
@@ -267,6 +274,7 @@ class _DiaryScreenState extends State<DiaryScreen> {
color: appTheme.blueA400,
width: 2,
),
color: Colors.white,
shape: BoxShape.circle,
),
),
@@ -277,9 +285,134 @@ class _DiaryScreenState extends State<DiaryScreen> {
);
}
_addProductButton() {
_addProductButton(DiaryDayModel diaryDay) {
return InkWell(
onTap: () {},
onTap: () {
setState(() {
selectedGlossary = null;
productNameController.clear();
quantityController.clear();
});
showModalBottomSheet(
useRootNavigator: true,
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(12)),
),
isScrollControlled: true,
builder: (context) {
return StatefulBuilder(
builder: (BuildContext context, void Function(void Function()) setState) {
return Padding(
padding: const EdgeInsets.all(16) + EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
'Добавление блюда',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w600,
color: Color(0xFF323F4B),
),
),
const SizedBox(height: 16),
TypeAheadField(
controller: productNameController,
itemBuilder: (context, glossary) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
glossary.name,
style: TextStyle(
height: 1,
fontSize: 16,
),
),
);
},
itemSeparatorBuilder: (context, index) => _divider(context),
onSelected: (newSelectedGlossary) {
setState(() {
selectedGlossary = newSelectedGlossary;
productNameController.text = selectedGlossary!.name;
});
},
suggestionsCallback: (query) async {
if (query.length < 1) return [];
return await diaryCubit.getGlossaryListByQuery(query);
},
builder: (context, controller, focusNode) {
return CustomTextFormField(
controller: controller,
focusNode: focusNode,
autofocus: true,
hintText: 'Введите название продукта/блюда',
);
},
emptyBuilder: (context) => const SizedBox.shrink(),
errorBuilder: (context, object) => Padding(
padding: const EdgeInsets.all(8.0),
child: Text('Нет подходящих вариантов'),
),
),
if (selectedGlossary != null)
Padding(
padding: const EdgeInsets.only(top: 8),
child: CustomTextFormField(
controller: quantityController,
keyboardType: TextInputType.number,
hintText: selectedGlossary!.grInPortion == 0 ? '100' : '1',
suffixText: selectedGlossary != null
? selectedGlossary!.grInPortion == 0
? 'гр'
: 'шт'
: null,
),
),
const SizedBox(height: 16),
InkWell(
onTap: () {
diaryCubit.addProductToMeal(
diaryId: diaryDay.id,
mealId: diaryDay.meals[currentSelectedMealNumber - 1].id,
productName: productNameController.text,
portion: selectedGlossary!.grInPortion == 0 ? 'gr' : 'pcs',
quantity: int.parse(quantityController.text),
date: _selectedDay.toString(),
);
Navigator.of(context).pop();
},
borderRadius: BorderRadius.circular(20),
child: Ink(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: appTheme.blueA400,
),
child: Container(
width: MediaQuery.of(context).size.width - 32,
padding: const EdgeInsets.all(16),
alignment: Alignment.center,
child: Text(
'Добавить',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Colors.white,
),
),
),
),
),
],
),
);
},
);
},
);
},
borderRadius: BorderRadius.circular(20),
child: Ink(
padding: EdgeInsets.symmetric(horizontal: 16),

View File

@@ -9,13 +9,29 @@ class DiaryRepository {
});
Future<DiaryDayModel> getDiaryByDate(String date) async {
print(await _getDiaryIndexByDate(date));
return (await diaryService.getDiaryDay(
index: await _getDiaryIndexByDate(date),
)).diary;
))
.diary;
}
Future<int> _getDiaryIndexByDate(String date) async {
return (await diaryService.getDiaryIndexByDate(date: date)).id;
}
Future<void> addPortionToMeal({
required int diaryId,
required int mealId,
required String productName,
required String portion,
required int quantity,
}) async {
return await diaryService.addProductToMeal(
diaryId: diaryId,
mealId: mealId,
productName: productName,
portion: portion,
quantity: quantity,
);
}
}

View File

@@ -18,4 +18,13 @@ abstract class DiaryService {
Future<DiaryDayWrapperModel> getDiaryDay({
@Path('diary_id') required int index,
});
@POST('/api/diary/{diary_id}/meal/{meal_id}/portions/create')
Future<void> addProductToMeal({
@Path('diary_id') required int diaryId,
@Path('meal_id') required int mealId,
@Part(name: 'product_name') required String productName,
@Part(name: 'portion') required String portion,
@Part(name: 'quantity') required int quantity,
});
}

View File

@@ -6,7 +6,7 @@ part of 'diary_service.dart';
// RetrofitGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _DiaryService implements DiaryService {
_DiaryService(
@@ -87,6 +87,49 @@ class _DiaryService implements DiaryService {
return _value;
}
@override
Future<void> addProductToMeal({
required int diaryId,
required int mealId,
required String productName,
required String portion,
required int quantity,
}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
final _data = FormData();
_data.fields.add(MapEntry(
'product_name',
productName,
));
_data.fields.add(MapEntry(
'portion',
portion,
));
_data.fields.add(MapEntry(
'quantity',
quantity.toString(),
));
final _options = _setStreamType<void>(Options(
method: 'POST',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/diary/${diaryId}/meal/${mealId}/portions/create',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
await _dio.fetch<void>(_options);
}
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
if (T != dynamic &&
!(requestOptions.responseType == ResponseType.bytes ||

View File

@@ -37,9 +37,7 @@ class FeedCubit extends Cubit<FeedState> {
try {
if (currentPage < lastPage) {
print('before: $currentPage');
currentPage++;
print('after: $currentPage');
final feedBlogPosts = await feedRepository.getFeedBlogPosts(
page: currentPage,
query: _query,

View File

@@ -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(

View File

@@ -0,0 +1,24 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'glossary_model.freezed.dart';
part 'glossary_model.g.dart';
@freezed
class GlossaryPaginationModel with _$GlossaryPaginationModel {
const factory GlossaryPaginationModel({
@JsonKey(name: 'data') required List<GlossaryModel> glossariesList,
}) = _GlossaryPaginationModel;
factory GlossaryPaginationModel.fromJson(Map<String, Object?> json) => _$GlossaryPaginationModelFromJson(json);
}
@freezed
class GlossaryModel with _$GlossaryModel {
const factory GlossaryModel({
required int id,
required String name,
@JsonKey(name: 'portion_mass_gr') required int grInPortion,
}) = _GlossaryModel;
factory GlossaryModel.fromJson(Map<String, Object?> json) => _$GlossaryModelFromJson(json);
}

View File

@@ -0,0 +1,380 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'glossary_model.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
GlossaryPaginationModel _$GlossaryPaginationModelFromJson(
Map<String, dynamic> json) {
return _GlossaryPaginationModel.fromJson(json);
}
/// @nodoc
mixin _$GlossaryPaginationModel {
@JsonKey(name: 'data')
List<GlossaryModel> get glossariesList => throw _privateConstructorUsedError;
/// Serializes this GlossaryPaginationModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of GlossaryPaginationModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$GlossaryPaginationModelCopyWith<GlossaryPaginationModel> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $GlossaryPaginationModelCopyWith<$Res> {
factory $GlossaryPaginationModelCopyWith(GlossaryPaginationModel value,
$Res Function(GlossaryPaginationModel) then) =
_$GlossaryPaginationModelCopyWithImpl<$Res, GlossaryPaginationModel>;
@useResult
$Res call({@JsonKey(name: 'data') List<GlossaryModel> glossariesList});
}
/// @nodoc
class _$GlossaryPaginationModelCopyWithImpl<$Res,
$Val extends GlossaryPaginationModel>
implements $GlossaryPaginationModelCopyWith<$Res> {
_$GlossaryPaginationModelCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of GlossaryPaginationModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? glossariesList = null,
}) {
return _then(_value.copyWith(
glossariesList: null == glossariesList
? _value.glossariesList
: glossariesList // ignore: cast_nullable_to_non_nullable
as List<GlossaryModel>,
) as $Val);
}
}
/// @nodoc
abstract class _$$GlossaryPaginationModelImplCopyWith<$Res>
implements $GlossaryPaginationModelCopyWith<$Res> {
factory _$$GlossaryPaginationModelImplCopyWith(
_$GlossaryPaginationModelImpl value,
$Res Function(_$GlossaryPaginationModelImpl) then) =
__$$GlossaryPaginationModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({@JsonKey(name: 'data') List<GlossaryModel> glossariesList});
}
/// @nodoc
class __$$GlossaryPaginationModelImplCopyWithImpl<$Res>
extends _$GlossaryPaginationModelCopyWithImpl<$Res,
_$GlossaryPaginationModelImpl>
implements _$$GlossaryPaginationModelImplCopyWith<$Res> {
__$$GlossaryPaginationModelImplCopyWithImpl(
_$GlossaryPaginationModelImpl _value,
$Res Function(_$GlossaryPaginationModelImpl) _then)
: super(_value, _then);
/// Create a copy of GlossaryPaginationModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? glossariesList = null,
}) {
return _then(_$GlossaryPaginationModelImpl(
glossariesList: null == glossariesList
? _value._glossariesList
: glossariesList // ignore: cast_nullable_to_non_nullable
as List<GlossaryModel>,
));
}
}
/// @nodoc
@JsonSerializable()
class _$GlossaryPaginationModelImpl implements _GlossaryPaginationModel {
const _$GlossaryPaginationModelImpl(
{@JsonKey(name: 'data')
required final List<GlossaryModel> glossariesList})
: _glossariesList = glossariesList;
factory _$GlossaryPaginationModelImpl.fromJson(Map<String, dynamic> json) =>
_$$GlossaryPaginationModelImplFromJson(json);
final List<GlossaryModel> _glossariesList;
@override
@JsonKey(name: 'data')
List<GlossaryModel> get glossariesList {
if (_glossariesList is EqualUnmodifiableListView) return _glossariesList;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_glossariesList);
}
@override
String toString() {
return 'GlossaryPaginationModel(glossariesList: $glossariesList)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$GlossaryPaginationModelImpl &&
const DeepCollectionEquality()
.equals(other._glossariesList, _glossariesList));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType, const DeepCollectionEquality().hash(_glossariesList));
/// Create a copy of GlossaryPaginationModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$GlossaryPaginationModelImplCopyWith<_$GlossaryPaginationModelImpl>
get copyWith => __$$GlossaryPaginationModelImplCopyWithImpl<
_$GlossaryPaginationModelImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$GlossaryPaginationModelImplToJson(
this,
);
}
}
abstract class _GlossaryPaginationModel implements GlossaryPaginationModel {
const factory _GlossaryPaginationModel(
{@JsonKey(name: 'data')
required final List<GlossaryModel> glossariesList}) =
_$GlossaryPaginationModelImpl;
factory _GlossaryPaginationModel.fromJson(Map<String, dynamic> json) =
_$GlossaryPaginationModelImpl.fromJson;
@override
@JsonKey(name: 'data')
List<GlossaryModel> get glossariesList;
/// Create a copy of GlossaryPaginationModel
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$GlossaryPaginationModelImplCopyWith<_$GlossaryPaginationModelImpl>
get copyWith => throw _privateConstructorUsedError;
}
GlossaryModel _$GlossaryModelFromJson(Map<String, dynamic> json) {
return _GlossaryModel.fromJson(json);
}
/// @nodoc
mixin _$GlossaryModel {
int get id => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
@JsonKey(name: 'portion_mass_gr')
int get grInPortion => throw _privateConstructorUsedError;
/// Serializes this GlossaryModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of GlossaryModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$GlossaryModelCopyWith<GlossaryModel> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $GlossaryModelCopyWith<$Res> {
factory $GlossaryModelCopyWith(
GlossaryModel value, $Res Function(GlossaryModel) then) =
_$GlossaryModelCopyWithImpl<$Res, GlossaryModel>;
@useResult
$Res call(
{int id, String name, @JsonKey(name: 'portion_mass_gr') int grInPortion});
}
/// @nodoc
class _$GlossaryModelCopyWithImpl<$Res, $Val extends GlossaryModel>
implements $GlossaryModelCopyWith<$Res> {
_$GlossaryModelCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of GlossaryModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? name = null,
Object? grInPortion = null,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
grInPortion: null == grInPortion
? _value.grInPortion
: grInPortion // ignore: cast_nullable_to_non_nullable
as int,
) as $Val);
}
}
/// @nodoc
abstract class _$$GlossaryModelImplCopyWith<$Res>
implements $GlossaryModelCopyWith<$Res> {
factory _$$GlossaryModelImplCopyWith(
_$GlossaryModelImpl value, $Res Function(_$GlossaryModelImpl) then) =
__$$GlossaryModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int id, String name, @JsonKey(name: 'portion_mass_gr') int grInPortion});
}
/// @nodoc
class __$$GlossaryModelImplCopyWithImpl<$Res>
extends _$GlossaryModelCopyWithImpl<$Res, _$GlossaryModelImpl>
implements _$$GlossaryModelImplCopyWith<$Res> {
__$$GlossaryModelImplCopyWithImpl(
_$GlossaryModelImpl _value, $Res Function(_$GlossaryModelImpl) _then)
: super(_value, _then);
/// Create a copy of GlossaryModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? name = null,
Object? grInPortion = null,
}) {
return _then(_$GlossaryModelImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
grInPortion: null == grInPortion
? _value.grInPortion
: grInPortion // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
@JsonSerializable()
class _$GlossaryModelImpl implements _GlossaryModel {
const _$GlossaryModelImpl(
{required this.id,
required this.name,
@JsonKey(name: 'portion_mass_gr') required this.grInPortion});
factory _$GlossaryModelImpl.fromJson(Map<String, dynamic> json) =>
_$$GlossaryModelImplFromJson(json);
@override
final int id;
@override
final String name;
@override
@JsonKey(name: 'portion_mass_gr')
final int grInPortion;
@override
String toString() {
return 'GlossaryModel(id: $id, name: $name, grInPortion: $grInPortion)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$GlossaryModelImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.grInPortion, grInPortion) ||
other.grInPortion == grInPortion));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, id, name, grInPortion);
/// Create a copy of GlossaryModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$GlossaryModelImplCopyWith<_$GlossaryModelImpl> get copyWith =>
__$$GlossaryModelImplCopyWithImpl<_$GlossaryModelImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$GlossaryModelImplToJson(
this,
);
}
}
abstract class _GlossaryModel implements GlossaryModel {
const factory _GlossaryModel(
{required final int id,
required final String name,
@JsonKey(name: 'portion_mass_gr') required final int grInPortion}) =
_$GlossaryModelImpl;
factory _GlossaryModel.fromJson(Map<String, dynamic> json) =
_$GlossaryModelImpl.fromJson;
@override
int get id;
@override
String get name;
@override
@JsonKey(name: 'portion_mass_gr')
int get grInPortion;
/// Create a copy of GlossaryModel
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$GlossaryModelImplCopyWith<_$GlossaryModelImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -0,0 +1,35 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'glossary_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$GlossaryPaginationModelImpl _$$GlossaryPaginationModelImplFromJson(
Map<String, dynamic> json) =>
_$GlossaryPaginationModelImpl(
glossariesList: (json['data'] as List<dynamic>)
.map((e) => GlossaryModel.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$$GlossaryPaginationModelImplToJson(
_$GlossaryPaginationModelImpl instance) =>
<String, dynamic>{
'data': instance.glossariesList,
};
_$GlossaryModelImpl _$$GlossaryModelImplFromJson(Map<String, dynamic> json) =>
_$GlossaryModelImpl(
id: (json['id'] as num).toInt(),
name: json['name'] as String,
grInPortion: (json['portion_mass_gr'] as num).toInt(),
);
Map<String, dynamic> _$$GlossaryModelImplToJson(_$GlossaryModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'name': instance.name,
'portion_mass_gr': instance.grInPortion,
};

View File

@@ -0,0 +1,18 @@
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
import 'package:eatvio_app/features/glossary/services/glossary_service.dart';
class GlossaryRepository {
final GlossaryService glossaryService;
GlossaryRepository({
required this.glossaryService,
});
Future<List<GlossaryModel>> getGlossaryListByQuery(String query) async {
try {
return (await glossaryService.getGlossaryByQuery(query: query)).glossariesList;
} catch (e) {
rethrow;
}
}
}

View File

@@ -0,0 +1,15 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
import 'package:retrofit/retrofit.dart';
part 'glossary_service.g.dart';
@RestApi()
abstract class GlossaryService {
factory GlossaryService(Dio dio, {String baseUrl}) = _GlossaryService;
@GET('/api/glossaries/search')
Future<GlossaryPaginationModel> getGlossaryByQuery({
@Query('search') required String query,
});
}

View File

@@ -0,0 +1,87 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'glossary_service.dart';
// **************************************************************************
// RetrofitGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _GlossaryService implements GlossaryService {
_GlossaryService(
this._dio, {
this.baseUrl,
this.errorLogger,
});
final Dio _dio;
String? baseUrl;
final ParseErrorLogger? errorLogger;
@override
Future<GlossaryPaginationModel> getGlossaryByQuery(
{required String query}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{r'search': query};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _options = _setStreamType<GlossaryPaginationModel>(Options(
method: 'GET',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/glossaries/search',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late GlossaryPaginationModel _value;
try {
_value = GlossaryPaginationModel.fromJson(_result.data!);
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
if (T != dynamic &&
!(requestOptions.responseType == ResponseType.bytes ||
requestOptions.responseType == ResponseType.stream)) {
if (T == String) {
requestOptions.responseType = ResponseType.plain;
} else {
requestOptions.responseType = ResponseType.json;
}
}
return requestOptions;
}
String _combineBaseUrls(
String dioBaseUrl,
String? baseUrl,
) {
if (baseUrl == null || baseUrl.trim().isEmpty) {
return dioBaseUrl;
}
final url = Uri.parse(baseUrl);
if (url.isAbsolute) {
return url.toString();
}
return Uri.parse(dioBaseUrl).resolveUri(url).toString();
}
}

View File

@@ -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(

View File

@@ -22,7 +22,6 @@ class ProfileCubit extends Cubit<ProfileState> {
));
} catch (e) {
emit(ProfileState.error(errorMessage: e.toString()));
print(e);
}
}
@@ -41,7 +40,6 @@ class ProfileCubit extends Cubit<ProfileState> {
));
} catch (e) {
emit(ProfileState.error(errorMessage: e.toString()));
print(e);
}
}
@@ -59,7 +57,6 @@ class ProfileCubit extends Cubit<ProfileState> {
await getMyProfile(period: _currentPeriod);
} catch (e) {
emit(ProfileState.error(errorMessage: e.toString()));
print(e);
}
}
@@ -71,7 +68,6 @@ class ProfileCubit extends Cubit<ProfileState> {
await getMyProfile(period: _currentPeriod);
} catch (e) {
emit(ProfileState.error(errorMessage: e.toString()));
print(e);
}
}
@@ -81,7 +77,6 @@ class ProfileCubit extends Cubit<ProfileState> {
try {
return (await chatRepository.getChatRoomIdByUserSlug(slug: slug)).id;
} catch (e) {
print(e);
rethrow;
}
}

View File

@@ -277,7 +277,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
),
const SizedBox(height: 8),
Container(
width: MediaQuery.of(context).size.width - 4,
width: MediaQuery.of(context).size.width - 2,
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Material(
color: Colors.white,

View File

@@ -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(

View File

@@ -258,7 +258,7 @@ class RecipeCreateCubit extends Cubit<RecipeCreateState> {
var currentState = state as RecipeCreateStateLoaded;
final Map<String, List<Product>> productNutritionalValues = await recipeRepository.inputProduct(input);
print(productNutritionalValues);
var updatedState = currentState.copyWith(
productNameController: TextEditingController(text: input),
autocompleteList: productNutritionalValues['product_nutritional_value'] ?? [],

View File

@@ -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;
}
}

View File

@@ -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}')]),

View File

@@ -39,8 +39,7 @@ class RecipeRepository {
};
}).toList() ??
[];
print(ingredientsMap);
print(stepsMap);
return await recipeService.publishRecipe(
recipe.type,
recipe.state,

View File

@@ -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(

View File

@@ -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(

View File

@@ -34,7 +34,6 @@ class SettingsCubit extends Cubit<SettingsState> {
profileDetailsModel: profileDetailsModel,
);
} catch (e) {
print(e);
rethrow;
} finally {
await init();
@@ -49,7 +48,6 @@ class SettingsCubit extends Cubit<SettingsState> {
profileSettingsModel: profileSettingsModel,
);
} catch (e) {
print(e);
rethrow;
} finally {
await init();

View File

@@ -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(

View File

@@ -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<void> init() async {
sl.registerFactory<PlansCubit>(() => PlansCubit(plansRepository: sl()));
sl.registerFactory<SettingsCubit>(() => SettingsCubit(profileRepository: sl(), settingsRepository: sl()));
sl.registerFactory<RegisterConsultantCubit>(() => RegisterConsultantCubit(consultantRepository: sl()));
sl.registerFactory<DiaryCubit>(() => DiaryCubit(diaryRepository: sl()));
sl.registerFactory<DiaryCubit>(() => DiaryCubit(diaryRepository: sl(), glossaryRepository: sl()));
// Repository
sl.registerLazySingleton<ChatRepository>(() => ChatRepository(chatService: sl()));
@@ -76,6 +78,7 @@ Future<void> init() async {
sl.registerLazySingleton<SettingsRepository>(() => SettingsRepository(settingsService: sl()));
sl.registerLazySingleton<ConsultantRepository>(() => ConsultantRepository(consultantService: sl()));
sl.registerLazySingleton<DiaryRepository>(() => DiaryRepository(diaryService: sl()));
sl.registerLazySingleton<GlossaryRepository>(() => GlossaryRepository(glossaryService: sl()));
// Services
sl.registerLazySingleton<ChatService>(() => ChatService(sl()));
@@ -88,6 +91,7 @@ Future<void> init() async {
sl.registerLazySingleton<SettingsService>(() => SettingsService(sl()));
sl.registerLazySingleton<ConsultantService>(() => ConsultantService(sl()));
sl.registerLazySingleton<DiaryService>(() => DiaryService(sl()));
sl.registerLazySingleton<GlossaryService>(() => GlossaryService(sl()));
// External
sl.registerLazySingleton(

View File

@@ -181,7 +181,7 @@ class _AuthScreenState extends State<AuthScreen> {
body: json.encode(credentials),
encoding: utf8,
);
print(response.statusCode);
if (response.statusCode == 200) {
var res = await jsonDecode(response.body);
final token = res['token'];

File diff suppressed because it is too large Load Diff

View File

@@ -61,10 +61,6 @@ class DietCreateBloc extends Bloc<DietCreateEvent, DietCreateState> {
if (response.statusCode == 200) {
AppRouter.navigatorKey.currentContext?.goNamed('dietSelectScreen');
} else {
print(
'Failed to create blog post. Status Code: ${response.statusCode} ${response.body}',
);
}
}
}

View File

@@ -78,7 +78,7 @@ class DietEditBloc extends Bloc<DietEditEvent, DietEditState> {
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<DietEditEvent, DietEditState> {
'dietScreen',
extra: currentState.diet?['id'].toString(),
);
} else {
print('Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}');
}
} else {}
}
}

View File

@@ -36,14 +36,11 @@ class DietSelectBloc extends Bloc<DietSelectEvent, DietSelectState> {
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
},
);
print('Got response');
if (response.statusCode == 200) {
print('Got 200');
final data = jsonDecode(response.body);
if (data is List<dynamic>) {
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<DietSelectEvent, DietSelectState> {
),
);
} else {
print('Got unloaded');
emit(
DietSelectLoadedState(
posts: data,

View File

@@ -69,9 +69,7 @@ class BlogPostCreateBloc extends Bloc<BlogPostCreateEvent, BlogPostCreateState>
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 {}
}
}

View File

@@ -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<BlogPostEditEvent, BlogPostEditState> {
@@ -86,9 +87,7 @@ class BlogPostEditBloc extends Bloc<BlogPostEditEvent, BlogPostEditState> {
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 {}
}
}

View File

@@ -61,10 +61,6 @@ class PlanCreateBloc extends Bloc<PlanCreateEvent, PlanCreateState> {
if (response.statusCode == 200) {
AppRouter.navigatorKey.currentContext?.goNamed('planSelectScreen');
} else {
print(
'Failed to create blog post. Status Code: ${response.statusCode} ${response.body}',
);
}
}
}

View File

@@ -78,7 +78,7 @@ class PlanEditBloc extends Bloc<PlanEditEvent, PlanEditState> {
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<PlanEditEvent, PlanEditState> {
'planScreen',
extra: currentState.plan?['id'].toString(),
);
} else {
print('Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}');
}
} else {}
}
}

View File

@@ -33,14 +33,11 @@ class PlanSelectBloc extends Bloc<PlanSelectEvent, PlanSelectState> {
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<dynamic>) {
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<PlanSelectEvent, PlanSelectState> {
),
);
} else {
print('Got unloaded');
emit(
PlanSelectLoadedState(
posts: data,

View File

@@ -26,7 +26,6 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
MyProfileInitialEvent event,
Emitter<MyProfileState> emit,
) async {
print('1');
try {
if (!await TokenStorage.haveTokenInStorage()) {
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
@@ -37,7 +36,7 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
'Authorization': 'Bearer ${await TokenStorage.getTokenFromStorage()}',
},
);
print('2');
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
if (data is Map<String, dynamic> &&
@@ -101,10 +100,10 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
..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<MyProfileEvent, MyProfileState> {
Future<String> 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<MyProfileEvent, MyProfileState> {
if (streamedResponse.statusCode == 200) {
var response = await http.Response.fromStream(streamedResponse);
var imageUrl = response.body;
print('Image successfully uploaded');
return imageUrl;
} else {
throw Exception(

View File

@@ -119,9 +119,7 @@ class RecipeEditBloc extends Bloc<RecipeEditEvent, RecipeEditState> {
'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<RecipeEditEvent, RecipeEditState> {
}
FutureOr<void> _reloadScreen(RecipeEditEvent? event, Emitter<RecipeEditState> emit) async {
print('Reloading..');
if (!await TokenStorage.haveTokenInStorage()) {
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
}

View File

@@ -445,8 +445,7 @@ class RecipeEditScreen extends StatelessWidget {
void _trimTags(newValue) {
List<String> newTagNames = newValue!.split(',').map((tag) => tag.trim()).toList();
List<Map<String, dynamic>> newTags = newTagNames.map((tagName) => {'name': tagName}).toList();
print(newTags);
newTagNames.map((tagName) => {'name': tagName}).toList();
}
Function onTapBack(BuildContext context) {

View File

@@ -30,14 +30,11 @@ class RecipeSelectBloc extends Bloc<RecipeSelectEvent, RecipeSelectState> {
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
}
final response = await sl<Dio>().get(baseUrl + '/api/recipes/index');
print('Got response');
if (response.statusCode == 200) {
print('Got 200');
final data = response.data['data'];
if (data is List<dynamic>) {
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<RecipeSelectEvent, RecipeSelectState> {
),
);
} else {
print('Got unloaded');
emit(
RecipeSelectLoadedState(
posts: data,

View File

@@ -35,23 +35,17 @@ class SubscribersBloc extends Bloc<SubscribersEvent, SubscribersState> {
'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<dynamic>) {
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,
));

View File

@@ -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),