feat(diary): add diary page, calendar, meals

This commit is contained in:
mso7nueh
2024-10-24 16:59:51 +03:00
parent e2b54cca99
commit 1883b93315
52 changed files with 2480 additions and 5592 deletions

View File

@@ -12,7 +12,6 @@ class BadgeModel with _$BadgeModel {
required String description,
required String image,
required String type,
required List<String> parameters,
}) = _BadgeModel;
factory BadgeModel.fromJson(Map<String, Object?> json) => _$BadgeModelFromJson(json);

View File

@@ -25,7 +25,6 @@ mixin _$BadgeModel {
String get description => throw _privateConstructorUsedError;
String get image => throw _privateConstructorUsedError;
String get type => throw _privateConstructorUsedError;
List<String> get parameters => throw _privateConstructorUsedError;
/// Serializes this BadgeModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@@ -44,12 +43,7 @@ abstract class $BadgeModelCopyWith<$Res> {
_$BadgeModelCopyWithImpl<$Res, BadgeModel>;
@useResult
$Res call(
{int id,
String title,
String description,
String image,
String type,
List<String> parameters});
{int id, String title, String description, String image, String type});
}
/// @nodoc
@@ -72,7 +66,6 @@ class _$BadgeModelCopyWithImpl<$Res, $Val extends BadgeModel>
Object? description = null,
Object? image = null,
Object? type = null,
Object? parameters = null,
}) {
return _then(_value.copyWith(
id: null == id
@@ -95,10 +88,6 @@ class _$BadgeModelCopyWithImpl<$Res, $Val extends BadgeModel>
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as String,
parameters: null == parameters
? _value.parameters
: parameters // ignore: cast_nullable_to_non_nullable
as List<String>,
) as $Val);
}
}
@@ -112,12 +101,7 @@ abstract class _$$BadgeModelImplCopyWith<$Res>
@override
@useResult
$Res call(
{int id,
String title,
String description,
String image,
String type,
List<String> parameters});
{int id, String title, String description, String image, String type});
}
/// @nodoc
@@ -138,7 +122,6 @@ class __$$BadgeModelImplCopyWithImpl<$Res>
Object? description = null,
Object? image = null,
Object? type = null,
Object? parameters = null,
}) {
return _then(_$BadgeModelImpl(
id: null == id
@@ -161,10 +144,6 @@ class __$$BadgeModelImplCopyWithImpl<$Res>
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as String,
parameters: null == parameters
? _value._parameters
: parameters // ignore: cast_nullable_to_non_nullable
as List<String>,
));
}
}
@@ -177,9 +156,7 @@ class _$BadgeModelImpl implements _BadgeModel {
required this.title,
required this.description,
required this.image,
required this.type,
required final List<String> parameters})
: _parameters = parameters;
required this.type});
factory _$BadgeModelImpl.fromJson(Map<String, dynamic> json) =>
_$$BadgeModelImplFromJson(json);
@@ -194,17 +171,10 @@ class _$BadgeModelImpl implements _BadgeModel {
final String image;
@override
final String type;
final List<String> _parameters;
@override
List<String> get parameters {
if (_parameters is EqualUnmodifiableListView) return _parameters;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_parameters);
}
@override
String toString() {
return 'BadgeModel(id: $id, title: $title, description: $description, image: $image, type: $type, parameters: $parameters)';
return 'BadgeModel(id: $id, title: $title, description: $description, image: $image, type: $type)';
}
@override
@@ -217,15 +187,13 @@ class _$BadgeModelImpl implements _BadgeModel {
(identical(other.description, description) ||
other.description == description) &&
(identical(other.image, image) || other.image == image) &&
(identical(other.type, type) || other.type == type) &&
const DeepCollectionEquality()
.equals(other._parameters, _parameters));
(identical(other.type, type) || other.type == type));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, id, title, description, image,
type, const DeepCollectionEquality().hash(_parameters));
int get hashCode =>
Object.hash(runtimeType, id, title, description, image, type);
/// Create a copy of BadgeModel
/// with the given fields replaced by the non-null parameter values.
@@ -249,8 +217,7 @@ abstract class _BadgeModel implements BadgeModel {
required final String title,
required final String description,
required final String image,
required final String type,
required final List<String> parameters}) = _$BadgeModelImpl;
required final String type}) = _$BadgeModelImpl;
factory _BadgeModel.fromJson(Map<String, dynamic> json) =
_$BadgeModelImpl.fromJson;
@@ -265,8 +232,6 @@ abstract class _BadgeModel implements BadgeModel {
String get image;
@override
String get type;
@override
List<String> get parameters;
/// Create a copy of BadgeModel
/// with the given fields replaced by the non-null parameter values.

View File

@@ -13,9 +13,6 @@ _$BadgeModelImpl _$$BadgeModelImplFromJson(Map<String, dynamic> json) =>
description: json['description'] as String,
image: json['image'] as String,
type: json['type'] as String,
parameters: (json['parameters'] as List<dynamic>)
.map((e) => e as String)
.toList(),
);
Map<String, dynamic> _$$BadgeModelImplToJson(_$BadgeModelImpl instance) =>
@@ -25,5 +22,4 @@ Map<String, dynamic> _$$BadgeModelImplToJson(_$BadgeModelImpl instance) =>
'description': instance.description,
'image': instance.image,
'type': instance.type,
'parameters': instance.parameters,
};

View File

@@ -483,11 +483,15 @@ class _ProfileScreenState extends State<ProfileScreen> {
child: Row(
children: [
for (int i = 0; i < state.profile.badges.length; i++) ...[
SvgPicture.network(
baseUrl + '/storage/' + state.profile.badges[i].image,
width: 40,
height: 40,
),
state.profile.badges[i].image.contains('svg')
? SvgPicture.network(
baseUrl + '/storage/' + state.profile.badges[i].image,
width: 40,
height: 40,
)
: CachedNetworkImage(
imageUrl: baseUrl + '/storage/' + state.profile.badges[i].image,
),
i < state.profile.badges.length - 1 ? const SizedBox(width: 8) : const SizedBox.shrink(),
],
],
@@ -634,11 +638,15 @@ class _ProfileScreenState extends State<ProfileScreen> {
}
_additionalInfo(ProfileStateLoaded state) {
String text = state.profileDetails.additionalInfo;
if (state.profileDetails.additionalInfo.length > 250) {
text = state.profileDetails.additionalInfo.substring(0, 250);
}
return Container(
alignment: Alignment.centerLeft,
padding: const EdgeInsets.all(16),
child: Text(
state.profileDetails.additionalInfo,
text,
style: TextStyle(
color: Colors.black.withOpacity(0.4),
height: 1,

View File

@@ -65,8 +65,7 @@ class ProfileRepository {
try {
return (await profileService.getBlogPostByAuthorSlug(
slug: slug,
))
.feedBlogPostList;
));
} catch (e) {
rethrow;
}

View File

@@ -1,10 +1,9 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/feed/models/feed_blog_post_settings_model.dart';
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
import 'package:eatvio_app/features/profile/models/circumference_model.dart';
import 'package:eatvio_app/features/profile/models/profile_model.dart';
import 'package:eatvio_app/features/profile/models/weight_model.dart';
import 'package:retrofit/retrofit.dart';
part 'profile_service.g.dart';
@RestApi()
@@ -35,7 +34,7 @@ abstract class ProfileService {
});
@GET('/api/blogPosts/search_by_author/{slug}')
Future<FeedBlogPostSettingsModel> getBlogPostByAuthorSlug({
Future<List<FeedBlogPostModel>> getBlogPostByAuthorSlug({
@Path() required String slug,
});

View File

@@ -191,13 +191,13 @@ class _ProfileService implements ProfileService {
}
@override
Future<FeedBlogPostSettingsModel> getBlogPostByAuthorSlug(
Future<List<FeedBlogPostModel>> getBlogPostByAuthorSlug(
{required String slug}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _options = _setStreamType<FeedBlogPostSettingsModel>(Options(
final _options = _setStreamType<List<FeedBlogPostModel>>(Options(
method: 'GET',
headers: _headers,
extra: _extra,
@@ -213,10 +213,13 @@ class _ProfileService implements ProfileService {
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late FeedBlogPostSettingsModel _value;
final _result = await _dio.fetch<List<dynamic>>(_options);
late List<FeedBlogPostModel> _value;
try {
_value = FeedBlogPostSettingsModel.fromJson(_result.data!);
_value = _result.data!
.map((dynamic i) =>
FeedBlogPostModel.fromJson(i as Map<String, dynamic>))
.toList();
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;