feat(feed): добавлен аватар автора, имя и время создания поста. добавлено количетсво лайков, комментариев и просмотров. при нажатии на комментарий, открываеться экран с постом

This commit is contained in:
mso7nueh
2024-08-14 14:32:33 +03:00
parent eee0282de0
commit d636857b05
8 changed files with 263 additions and 140 deletions

View File

@@ -15,3 +15,13 @@ extension DateTimeExtension on DateTime {
return DateFormat(pattern, locale).format(this);
}
}
String calculateDifference(DateTime dateTime) {
if (dateTime.difference(DateTime.now()).inDays == 0) {
return 'Сегодня';
} else if (dateTime.difference(DateTime.now()).inDays == -1) {
return 'Вчера';
} else {
return dateTime.format('d MMMM', 'ru');
}
}

View File

@@ -14,7 +14,8 @@ 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');
UserRegistrationSheet _$UserRegistrationSheetFromJson(Map<String, dynamic> json) {
UserRegistrationSheet _$UserRegistrationSheetFromJson(
Map<String, dynamic> json) {
return _UserRegistrationSheet.fromJson(json);
}
@@ -22,88 +23,62 @@ UserRegistrationSheet _$UserRegistrationSheetFromJson(Map<String, dynamic> json)
mixin _$UserRegistrationSheet {
@JsonKey(name: 'first_name')
String get firstName => throw _privateConstructorUsedError;
@JsonKey(name: 'last_name')
String get lastName => throw _privateConstructorUsedError;
String get email => throw _privateConstructorUsedError;
String get password => throw _privateConstructorUsedError;
@JsonKey(name: 'password_confirmation')
String get passwordConfirmation => throw _privateConstructorUsedError;
@JsonKey(name: 'terms')
String get termsAccepted => throw _privateConstructorUsedError;
String get birthdate => throw _privateConstructorUsedError;
String get gender => throw _privateConstructorUsedError;
String get location => throw _privateConstructorUsedError;
@JsonKey(name: 'response_body')
String get responseBody => throw _privateConstructorUsedError;
String get lang => throw _privateConstructorUsedError;
int get weight => throw _privateConstructorUsedError;
int get height => throw _privateConstructorUsedError;
@JsonKey(name: 'chest_circumference')
int get chestCircumference => throw _privateConstructorUsedError;
@JsonKey(name: 'waist_circumference')
int get waistCircumference => throw _privateConstructorUsedError;
@JsonKey(name: 'hip_circumference')
int get hipCircumference => throw _privateConstructorUsedError;
@JsonKey(name: 'blood_pressure_up')
int get bloodPressureUp => throw _privateConstructorUsedError;
@JsonKey(name: 'blood_pressure_down')
int get bloodPressureDown => throw _privateConstructorUsedError;
@JsonKey(name: 'has_hypo')
int get hasHypo => throw _privateConstructorUsedError;
@JsonKey(name: 'has_hyper')
int get hasHyper => throw _privateConstructorUsedError;
@JsonKey(name: 'about_alergy')
String get aboutAllergy => throw _privateConstructorUsedError;
@JsonKey(name: 'about_taking_pils')
String get aboutTakingPils => throw _privateConstructorUsedError;
@JsonKey(name: 'about_sport_hobbies')
String get aboutSportHobbies => throw _privateConstructorUsedError;
@JsonKey(name: 'favorite_foods')
String get favoriteFoods => throw _privateConstructorUsedError;
@JsonKey(name: 'unfavorite_foods')
String get unfavoriteFoods => throw _privateConstructorUsedError;
@JsonKey(name: 'additional_info')
String get additionalInfo => throw _privateConstructorUsedError;
@JsonKey(name: 'activity_coefficient')
double get activityCoefficient => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$UserRegistrationSheetCopyWith<UserRegistrationSheet> get copyWith => throw _privateConstructorUsedError;
$UserRegistrationSheetCopyWith<UserRegistrationSheet> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $UserRegistrationSheetCopyWith<$Res> {
factory $UserRegistrationSheetCopyWith(UserRegistrationSheet value, $Res Function(UserRegistrationSheet) then) =
factory $UserRegistrationSheetCopyWith(UserRegistrationSheet value,
$Res Function(UserRegistrationSheet) then) =
_$UserRegistrationSheetCopyWithImpl<$Res, UserRegistrationSheet>;
@useResult
$Res call(
{@JsonKey(name: 'first_name') String firstName,
@@ -136,12 +111,13 @@ abstract class $UserRegistrationSheetCopyWith<$Res> {
}
/// @nodoc
class _$UserRegistrationSheetCopyWithImpl<$Res, $Val extends UserRegistrationSheet> implements $UserRegistrationSheetCopyWith<$Res> {
class _$UserRegistrationSheetCopyWithImpl<$Res,
$Val extends UserRegistrationSheet>
implements $UserRegistrationSheetCopyWith<$Res> {
_$UserRegistrationSheetCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@@ -290,10 +266,12 @@ class _$UserRegistrationSheetCopyWithImpl<$Res, $Val extends UserRegistrationShe
}
/// @nodoc
abstract class _$$UserRegistrationSheetImplCopyWith<$Res> implements $UserRegistrationSheetCopyWith<$Res> {
factory _$$UserRegistrationSheetImplCopyWith(_$UserRegistrationSheetImpl value, $Res Function(_$UserRegistrationSheetImpl) then) =
abstract class _$$UserRegistrationSheetImplCopyWith<$Res>
implements $UserRegistrationSheetCopyWith<$Res> {
factory _$$UserRegistrationSheetImplCopyWith(
_$UserRegistrationSheetImpl value,
$Res Function(_$UserRegistrationSheetImpl) then) =
__$$UserRegistrationSheetImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
@@ -327,9 +305,13 @@ abstract class _$$UserRegistrationSheetImplCopyWith<$Res> implements $UserRegist
}
/// @nodoc
class __$$UserRegistrationSheetImplCopyWithImpl<$Res> extends _$UserRegistrationSheetCopyWithImpl<$Res, _$UserRegistrationSheetImpl>
class __$$UserRegistrationSheetImplCopyWithImpl<$Res>
extends _$UserRegistrationSheetCopyWithImpl<$Res,
_$UserRegistrationSheetImpl>
implements _$$UserRegistrationSheetImplCopyWith<$Res> {
__$$UserRegistrationSheetImplCopyWithImpl(_$UserRegistrationSheetImpl _value, $Res Function(_$UserRegistrationSheetImpl) _then) : super(_value, _then);
__$$UserRegistrationSheetImplCopyWithImpl(_$UserRegistrationSheetImpl _value,
$Res Function(_$UserRegistrationSheetImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
@@ -483,7 +465,8 @@ class _$UserRegistrationSheetImpl implements _UserRegistrationSheet {
@JsonKey(name: 'last_name') required this.lastName,
required this.email,
required this.password,
@JsonKey(name: 'password_confirmation') required this.passwordConfirmation,
@JsonKey(name: 'password_confirmation')
required this.passwordConfirmation,
@JsonKey(name: 'terms') this.termsAccepted = 'accepted',
required this.birthdate,
required this.gender,
@@ -507,7 +490,8 @@ class _$UserRegistrationSheetImpl implements _UserRegistrationSheet {
@JsonKey(name: 'additional_info') required this.additionalInfo,
@JsonKey(name: 'activity_coefficient') this.activityCoefficient = 1.2});
factory _$UserRegistrationSheetImpl.fromJson(Map<String, dynamic> json) => _$$UserRegistrationSheetImplFromJson(json);
factory _$UserRegistrationSheetImpl.fromJson(Map<String, dynamic> json) =>
_$$UserRegistrationSheetImplFromJson(json);
@override
@JsonKey(name: 'first_name')
@@ -593,33 +577,54 @@ class _$UserRegistrationSheetImpl implements _UserRegistrationSheet {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$UserRegistrationSheetImpl &&
(identical(other.firstName, firstName) || other.firstName == firstName) &&
(identical(other.lastName, lastName) || other.lastName == lastName) &&
(identical(other.firstName, firstName) ||
other.firstName == firstName) &&
(identical(other.lastName, lastName) ||
other.lastName == lastName) &&
(identical(other.email, email) || other.email == email) &&
(identical(other.password, password) || other.password == password) &&
(identical(other.passwordConfirmation, passwordConfirmation) || other.passwordConfirmation == passwordConfirmation) &&
(identical(other.termsAccepted, termsAccepted) || other.termsAccepted == termsAccepted) &&
(identical(other.birthdate, birthdate) || other.birthdate == birthdate) &&
(identical(other.password, password) ||
other.password == password) &&
(identical(other.passwordConfirmation, passwordConfirmation) ||
other.passwordConfirmation == passwordConfirmation) &&
(identical(other.termsAccepted, termsAccepted) ||
other.termsAccepted == termsAccepted) &&
(identical(other.birthdate, birthdate) ||
other.birthdate == birthdate) &&
(identical(other.gender, gender) || other.gender == gender) &&
(identical(other.location, location) || other.location == location) &&
(identical(other.responseBody, responseBody) || other.responseBody == responseBody) &&
(identical(other.location, location) ||
other.location == location) &&
(identical(other.responseBody, responseBody) ||
other.responseBody == responseBody) &&
(identical(other.lang, lang) || other.lang == lang) &&
(identical(other.weight, weight) || other.weight == weight) &&
(identical(other.height, height) || other.height == height) &&
(identical(other.chestCircumference, chestCircumference) || other.chestCircumference == chestCircumference) &&
(identical(other.waistCircumference, waistCircumference) || other.waistCircumference == waistCircumference) &&
(identical(other.hipCircumference, hipCircumference) || other.hipCircumference == hipCircumference) &&
(identical(other.bloodPressureUp, bloodPressureUp) || other.bloodPressureUp == bloodPressureUp) &&
(identical(other.bloodPressureDown, bloodPressureDown) || other.bloodPressureDown == bloodPressureDown) &&
(identical(other.chestCircumference, chestCircumference) ||
other.chestCircumference == chestCircumference) &&
(identical(other.waistCircumference, waistCircumference) ||
other.waistCircumference == waistCircumference) &&
(identical(other.hipCircumference, hipCircumference) ||
other.hipCircumference == hipCircumference) &&
(identical(other.bloodPressureUp, bloodPressureUp) ||
other.bloodPressureUp == bloodPressureUp) &&
(identical(other.bloodPressureDown, bloodPressureDown) ||
other.bloodPressureDown == bloodPressureDown) &&
(identical(other.hasHypo, hasHypo) || other.hasHypo == hasHypo) &&
(identical(other.hasHyper, hasHyper) || other.hasHyper == hasHyper) &&
(identical(other.aboutAllergy, aboutAllergy) || other.aboutAllergy == aboutAllergy) &&
(identical(other.aboutTakingPils, aboutTakingPils) || other.aboutTakingPils == aboutTakingPils) &&
(identical(other.aboutSportHobbies, aboutSportHobbies) || other.aboutSportHobbies == aboutSportHobbies) &&
(identical(other.favoriteFoods, favoriteFoods) || other.favoriteFoods == favoriteFoods) &&
(identical(other.unfavoriteFoods, unfavoriteFoods) || other.unfavoriteFoods == unfavoriteFoods) &&
(identical(other.additionalInfo, additionalInfo) || other.additionalInfo == additionalInfo) &&
(identical(other.activityCoefficient, activityCoefficient) || other.activityCoefficient == activityCoefficient));
(identical(other.hasHyper, hasHyper) ||
other.hasHyper == hasHyper) &&
(identical(other.aboutAllergy, aboutAllergy) ||
other.aboutAllergy == aboutAllergy) &&
(identical(other.aboutTakingPils, aboutTakingPils) ||
other.aboutTakingPils == aboutTakingPils) &&
(identical(other.aboutSportHobbies, aboutSportHobbies) ||
other.aboutSportHobbies == aboutSportHobbies) &&
(identical(other.favoriteFoods, favoriteFoods) ||
other.favoriteFoods == favoriteFoods) &&
(identical(other.unfavoriteFoods, unfavoriteFoods) ||
other.unfavoriteFoods == unfavoriteFoods) &&
(identical(other.additionalInfo, additionalInfo) ||
other.additionalInfo == additionalInfo) &&
(identical(other.activityCoefficient, activityCoefficient) ||
other.activityCoefficient == activityCoefficient));
}
@JsonKey(ignore: true)
@@ -658,8 +663,9 @@ class _$UserRegistrationSheetImpl implements _UserRegistrationSheet {
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$UserRegistrationSheetImplCopyWith<_$UserRegistrationSheetImpl> get copyWith =>
__$$UserRegistrationSheetImplCopyWithImpl<_$UserRegistrationSheetImpl>(this, _$identity);
_$$UserRegistrationSheetImplCopyWith<_$UserRegistrationSheetImpl>
get copyWith => __$$UserRegistrationSheetImplCopyWithImpl<
_$UserRegistrationSheetImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
@@ -675,7 +681,8 @@ abstract class _UserRegistrationSheet implements UserRegistrationSheet {
@JsonKey(name: 'last_name') required final String lastName,
required final String email,
required final String password,
@JsonKey(name: 'password_confirmation') required final String passwordConfirmation,
@JsonKey(name: 'password_confirmation')
required final String passwordConfirmation,
@JsonKey(name: 'terms') final String termsAccepted,
required final String birthdate,
required final String gender,
@@ -684,124 +691,104 @@ abstract class _UserRegistrationSheet implements UserRegistrationSheet {
required final String lang,
required final int weight,
required final int height,
@JsonKey(name: 'chest_circumference') required final int chestCircumference,
@JsonKey(name: 'waist_circumference') required final int waistCircumference,
@JsonKey(name: 'chest_circumference')
required final int chestCircumference,
@JsonKey(name: 'waist_circumference')
required final int waistCircumference,
@JsonKey(name: 'hip_circumference') required final int hipCircumference,
@JsonKey(name: 'blood_pressure_up') required final int bloodPressureUp,
@JsonKey(name: 'blood_pressure_down') required final int bloodPressureDown,
@JsonKey(name: 'blood_pressure_down')
required final int bloodPressureDown,
@JsonKey(name: 'has_hypo') required final int hasHypo,
@JsonKey(name: 'has_hyper') required final int hasHyper,
@JsonKey(name: 'about_alergy') required final String aboutAllergy,
@JsonKey(name: 'about_taking_pils') required final String aboutTakingPils,
@JsonKey(name: 'about_sport_hobbies') required final String aboutSportHobbies,
@JsonKey(name: 'about_sport_hobbies')
required final String aboutSportHobbies,
@JsonKey(name: 'favorite_foods') required final String favoriteFoods,
@JsonKey(name: 'unfavorite_foods') required final String unfavoriteFoods,
@JsonKey(name: 'additional_info') required final String additionalInfo,
@JsonKey(name: 'activity_coefficient') final double activityCoefficient}) = _$UserRegistrationSheetImpl;
@JsonKey(name: 'activity_coefficient')
final double activityCoefficient}) = _$UserRegistrationSheetImpl;
factory _UserRegistrationSheet.fromJson(Map<String, dynamic> json) = _$UserRegistrationSheetImpl.fromJson;
factory _UserRegistrationSheet.fromJson(Map<String, dynamic> json) =
_$UserRegistrationSheetImpl.fromJson;
@override
@JsonKey(name: 'first_name')
String get firstName;
@override
@JsonKey(name: 'last_name')
String get lastName;
@override
String get email;
@override
String get password;
@override
@JsonKey(name: 'password_confirmation')
String get passwordConfirmation;
@override
@JsonKey(name: 'terms')
String get termsAccepted;
@override
String get birthdate;
@override
String get gender;
@override
String get location;
@override
@JsonKey(name: 'response_body')
String get responseBody;
@override
String get lang;
@override
int get weight;
@override
int get height;
@override
@JsonKey(name: 'chest_circumference')
int get chestCircumference;
@override
@JsonKey(name: 'waist_circumference')
int get waistCircumference;
@override
@JsonKey(name: 'hip_circumference')
int get hipCircumference;
@override
@JsonKey(name: 'blood_pressure_up')
int get bloodPressureUp;
@override
@JsonKey(name: 'blood_pressure_down')
int get bloodPressureDown;
@override
@JsonKey(name: 'has_hypo')
int get hasHypo;
@override
@JsonKey(name: 'has_hyper')
int get hasHyper;
@override
@JsonKey(name: 'about_alergy')
String get aboutAllergy;
@override
@JsonKey(name: 'about_taking_pils')
String get aboutTakingPils;
@override
@JsonKey(name: 'about_sport_hobbies')
String get aboutSportHobbies;
@override
@JsonKey(name: 'favorite_foods')
String get favoriteFoods;
@override
@JsonKey(name: 'unfavorite_foods')
String get unfavoriteFoods;
@override
@JsonKey(name: 'additional_info')
String get additionalInfo;
@override
@JsonKey(name: 'activity_coefficient')
double get activityCoefficient;
@override
@JsonKey(ignore: true)
_$$UserRegistrationSheetImplCopyWith<_$UserRegistrationSheetImpl> get copyWith => throw _privateConstructorUsedError;
_$$UserRegistrationSheetImplCopyWith<_$UserRegistrationSheetImpl>
get copyWith => throw _privateConstructorUsedError;
}

View File

@@ -6,7 +6,9 @@ part of 'user_registration_model.dart';
// JsonSerializableGenerator
// **************************************************************************
_$UserRegistrationSheetImpl _$$UserRegistrationSheetImplFromJson(Map<String, dynamic> json) => _$UserRegistrationSheetImpl(
_$UserRegistrationSheetImpl _$$UserRegistrationSheetImplFromJson(
Map<String, dynamic> json) =>
_$UserRegistrationSheetImpl(
firstName: json['first_name'] as String,
lastName: json['last_name'] as String,
email: json['email'] as String,
@@ -33,10 +35,13 @@ _$UserRegistrationSheetImpl _$$UserRegistrationSheetImplFromJson(Map<String, dyn
favoriteFoods: json['favorite_foods'] as String,
unfavoriteFoods: json['unfavorite_foods'] as String,
additionalInfo: json['additional_info'] as String,
activityCoefficient: (json['activity_coefficient'] as num?)?.toDouble() ?? 1.2,
activityCoefficient:
(json['activity_coefficient'] as num?)?.toDouble() ?? 1.2,
);
Map<String, dynamic> _$$UserRegistrationSheetImplToJson(_$UserRegistrationSheetImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$UserRegistrationSheetImplToJson(
_$UserRegistrationSheetImpl instance) =>
<String, dynamic>{
'first_name': instance.firstName,
'last_name': instance.lastName,
'email': instance.email,

View File

@@ -16,6 +16,12 @@ class FeedBlogPostModel with _$FeedBlogPostModel {
@JsonKey(name: "created_at") required DateTime createdAt,
@JsonKey(name: "updated_at") required DateTime updatedAt,
required String title,
@JsonKey(name: "total_likes")
required int totalLikes,
@JsonKey(name: "total_views")
required int totalViews,
@JsonKey(name: "total_comments")
required int totalComments,
}) = _FeedBlogPostModel;
factory FeedBlogPostModel.fromJson(Map<String, Object?> json) => _$FeedBlogPostModelFromJson(json);

View File

@@ -32,6 +32,12 @@ mixin _$FeedBlogPostModel {
@JsonKey(name: "updated_at")
DateTime get updatedAt => throw _privateConstructorUsedError;
String get title => throw _privateConstructorUsedError;
@JsonKey(name: "total_likes")
int get totalLikes => throw _privateConstructorUsedError;
@JsonKey(name: "total_views")
int get totalViews => throw _privateConstructorUsedError;
@JsonKey(name: "total_comments")
int get totalComments => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
@@ -54,7 +60,10 @@ abstract class $FeedBlogPostModelCopyWith<$Res> {
@JsonKey(name: "youtube_url") String youtubeUrl,
@JsonKey(name: "created_at") DateTime createdAt,
@JsonKey(name: "updated_at") DateTime updatedAt,
String title});
String title,
@JsonKey(name: "total_likes") int totalLikes,
@JsonKey(name: "total_views") int totalViews,
@JsonKey(name: "total_comments") int totalComments});
$AuthorCopyWith<$Res> get author;
}
@@ -81,6 +90,9 @@ class _$FeedBlogPostModelCopyWithImpl<$Res, $Val extends FeedBlogPostModel>
Object? createdAt = null,
Object? updatedAt = null,
Object? title = null,
Object? totalLikes = null,
Object? totalViews = null,
Object? totalComments = null,
}) {
return _then(_value.copyWith(
id: null == id
@@ -119,6 +131,18 @@ class _$FeedBlogPostModelCopyWithImpl<$Res, $Val extends FeedBlogPostModel>
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
totalLikes: null == totalLikes
? _value.totalLikes
: totalLikes // ignore: cast_nullable_to_non_nullable
as int,
totalViews: null == totalViews
? _value.totalViews
: totalViews // ignore: cast_nullable_to_non_nullable
as int,
totalComments: null == totalComments
? _value.totalComments
: totalComments // ignore: cast_nullable_to_non_nullable
as int,
) as $Val);
}
@@ -148,7 +172,10 @@ abstract class _$$FeedBlogPostModelImplCopyWith<$Res>
@JsonKey(name: "youtube_url") String youtubeUrl,
@JsonKey(name: "created_at") DateTime createdAt,
@JsonKey(name: "updated_at") DateTime updatedAt,
String title});
String title,
@JsonKey(name: "total_likes") int totalLikes,
@JsonKey(name: "total_views") int totalViews,
@JsonKey(name: "total_comments") int totalComments});
@override
$AuthorCopyWith<$Res> get author;
@@ -174,6 +201,9 @@ class __$$FeedBlogPostModelImplCopyWithImpl<$Res>
Object? createdAt = null,
Object? updatedAt = null,
Object? title = null,
Object? totalLikes = null,
Object? totalViews = null,
Object? totalComments = null,
}) {
return _then(_$FeedBlogPostModelImpl(
id: null == id
@@ -212,6 +242,18 @@ class __$$FeedBlogPostModelImplCopyWithImpl<$Res>
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
totalLikes: null == totalLikes
? _value.totalLikes
: totalLikes // ignore: cast_nullable_to_non_nullable
as int,
totalViews: null == totalViews
? _value.totalViews
: totalViews // ignore: cast_nullable_to_non_nullable
as int,
totalComments: null == totalComments
? _value.totalComments
: totalComments // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
@@ -228,7 +270,10 @@ class _$FeedBlogPostModelImpl implements _FeedBlogPostModel {
@JsonKey(name: "youtube_url") required this.youtubeUrl,
@JsonKey(name: "created_at") required this.createdAt,
@JsonKey(name: "updated_at") required this.updatedAt,
required this.title});
required this.title,
@JsonKey(name: "total_likes") required this.totalLikes,
@JsonKey(name: "total_views") required this.totalViews,
@JsonKey(name: "total_comments") required this.totalComments});
factory _$FeedBlogPostModelImpl.fromJson(Map<String, dynamic> json) =>
_$$FeedBlogPostModelImplFromJson(json);
@@ -254,10 +299,19 @@ class _$FeedBlogPostModelImpl implements _FeedBlogPostModel {
final DateTime updatedAt;
@override
final String title;
@override
@JsonKey(name: "total_likes")
final int totalLikes;
@override
@JsonKey(name: "total_views")
final int totalViews;
@override
@JsonKey(name: "total_comments")
final int totalComments;
@override
String toString() {
return 'FeedBlogPostModel(id: $id, state: $state, image: $image, description: $description, author: $author, youtubeUrl: $youtubeUrl, createdAt: $createdAt, updatedAt: $updatedAt, title: $title)';
return 'FeedBlogPostModel(id: $id, state: $state, image: $image, description: $description, author: $author, youtubeUrl: $youtubeUrl, createdAt: $createdAt, updatedAt: $updatedAt, title: $title, totalLikes: $totalLikes, totalViews: $totalViews, totalComments: $totalComments)';
}
@override
@@ -277,13 +331,31 @@ class _$FeedBlogPostModelImpl implements _FeedBlogPostModel {
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt) &&
(identical(other.title, title) || other.title == title));
(identical(other.title, title) || other.title == title) &&
(identical(other.totalLikes, totalLikes) ||
other.totalLikes == totalLikes) &&
(identical(other.totalViews, totalViews) ||
other.totalViews == totalViews) &&
(identical(other.totalComments, totalComments) ||
other.totalComments == totalComments));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, id, state, image, description,
author, youtubeUrl, createdAt, updatedAt, title);
int get hashCode => Object.hash(
runtimeType,
id,
state,
image,
description,
author,
youtubeUrl,
createdAt,
updatedAt,
title,
totalLikes,
totalViews,
totalComments);
@JsonKey(ignore: true)
@override
@@ -302,15 +374,19 @@ class _$FeedBlogPostModelImpl implements _FeedBlogPostModel {
abstract class _FeedBlogPostModel implements FeedBlogPostModel {
const factory _FeedBlogPostModel(
{required final int id,
required final String state,
required final String image,
required final String description,
required final Author author,
@JsonKey(name: "youtube_url") required final String youtubeUrl,
@JsonKey(name: "created_at") required final DateTime createdAt,
@JsonKey(name: "updated_at") required final DateTime updatedAt,
required final String title}) = _$FeedBlogPostModelImpl;
{required final int id,
required final String state,
required final String image,
required final String description,
required final Author author,
@JsonKey(name: "youtube_url") required final String youtubeUrl,
@JsonKey(name: "created_at") required final DateTime createdAt,
@JsonKey(name: "updated_at") required final DateTime updatedAt,
required final String title,
@JsonKey(name: "total_likes") required final int totalLikes,
@JsonKey(name: "total_views") required final int totalViews,
@JsonKey(name: "total_comments") required final int totalComments}) =
_$FeedBlogPostModelImpl;
factory _FeedBlogPostModel.fromJson(Map<String, dynamic> json) =
_$FeedBlogPostModelImpl.fromJson;
@@ -337,6 +413,15 @@ abstract class _FeedBlogPostModel implements FeedBlogPostModel {
@override
String get title;
@override
@JsonKey(name: "total_likes")
int get totalLikes;
@override
@JsonKey(name: "total_views")
int get totalViews;
@override
@JsonKey(name: "total_comments")
int get totalComments;
@override
@JsonKey(ignore: true)
_$$FeedBlogPostModelImplCopyWith<_$FeedBlogPostModelImpl> get copyWith =>
throw _privateConstructorUsedError;

View File

@@ -18,6 +18,9 @@ _$FeedBlogPostModelImpl _$$FeedBlogPostModelImplFromJson(
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
title: json['title'] as String,
totalLikes: (json['total_likes'] as num).toInt(),
totalViews: (json['total_views'] as num).toInt(),
totalComments: (json['total_comments'] as num).toInt(),
);
Map<String, dynamic> _$$FeedBlogPostModelImplToJson(
@@ -32,4 +35,7 @@ Map<String, dynamic> _$$FeedBlogPostModelImplToJson(
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'title': instance.title,
'total_likes': instance.totalLikes,
'total_views': instance.totalViews,
'total_comments': instance.totalComments,
};

View File

@@ -38,13 +38,19 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
children: [
CircleAvatar(radius: 20),
CircleAvatar(
radius: 20,
backgroundColor: Colors.black12,
foregroundImage: NetworkImage(
widget.feedBlogPostModel.author.authorProfileIcon,
),
),
SizedBox(width: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Имя автора'),
Text('Время поста'),
Text(widget.feedBlogPostModel.author.authorName),
Text(calculateDifference(widget.feedBlogPostModel.createdAt)),
],
),
],
@@ -94,9 +100,16 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
children: [
_iconButton(Icons.favorite_border_rounded),
_iconButton(Icons.favorite_border_rounded, widget.feedBlogPostModel.totalLikes.toString()),
SizedBox(width: 8),
_iconButton(Icons.mode_comment_outlined),
_iconButton(
Icons.mode_comment_outlined,
widget.feedBlogPostModel.totalComments.toString(),
() => GoRouter.of(context).pushNamed(
'blogPostScreen',
extra: widget.feedBlogPostModel,
),
),
SizedBox(width: 8),
_iconButton(Icons.reply_rounded),
Spacer(),
@@ -107,7 +120,7 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
),
SizedBox(width: 4),
Text(
'0',
widget.feedBlogPostModel.totalViews.toString(),
style: TextStyle(
fontSize: 12,
color: appTheme.gray500,
@@ -124,9 +137,9 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
);
}
_iconButton(IconData icon, [String? text]) {
_iconButton(IconData icon, [String? text, Function()? onTap]) {
return InkWell(
onTap: () {},
onTap: onTap ?? () {},
borderRadius: BorderRadius.circular(16),
child: Ink(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 4),

View File

@@ -19,13 +19,15 @@ mixin _$RegistrationState {
UserRegistrationSheet get sheet => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$RegistrationStateCopyWith<RegistrationState> get copyWith => throw _privateConstructorUsedError;
$RegistrationStateCopyWith<RegistrationState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $RegistrationStateCopyWith<$Res> {
factory $RegistrationStateCopyWith(RegistrationState value, $Res Function(RegistrationState) then) = _$RegistrationStateCopyWithImpl<$Res, RegistrationState>;
factory $RegistrationStateCopyWith(
RegistrationState value, $Res Function(RegistrationState) then) =
_$RegistrationStateCopyWithImpl<$Res, RegistrationState>;
@useResult
$Res call({UserRegistrationSheet sheet});
@@ -33,12 +35,12 @@ abstract class $RegistrationStateCopyWith<$Res> {
}
/// @nodoc
class _$RegistrationStateCopyWithImpl<$Res, $Val extends RegistrationState> implements $RegistrationStateCopyWith<$Res> {
class _$RegistrationStateCopyWithImpl<$Res, $Val extends RegistrationState>
implements $RegistrationStateCopyWith<$Res> {
_$RegistrationStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@@ -65,10 +67,11 @@ class _$RegistrationStateCopyWithImpl<$Res, $Val extends RegistrationState> impl
}
/// @nodoc
abstract class _$$RegistrationStateImplCopyWith<$Res> implements $RegistrationStateCopyWith<$Res> {
factory _$$RegistrationStateImplCopyWith(_$RegistrationStateImpl value, $Res Function(_$RegistrationStateImpl) then) =
abstract class _$$RegistrationStateImplCopyWith<$Res>
implements $RegistrationStateCopyWith<$Res> {
factory _$$RegistrationStateImplCopyWith(_$RegistrationStateImpl value,
$Res Function(_$RegistrationStateImpl) then) =
__$$RegistrationStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({UserRegistrationSheet sheet});
@@ -78,9 +81,12 @@ abstract class _$$RegistrationStateImplCopyWith<$Res> implements $RegistrationSt
}
/// @nodoc
class __$$RegistrationStateImplCopyWithImpl<$Res> extends _$RegistrationStateCopyWithImpl<$Res, _$RegistrationStateImpl>
class __$$RegistrationStateImplCopyWithImpl<$Res>
extends _$RegistrationStateCopyWithImpl<$Res, _$RegistrationStateImpl>
implements _$$RegistrationStateImplCopyWith<$Res> {
__$$RegistrationStateImplCopyWithImpl(_$RegistrationStateImpl _value, $Res Function(_$RegistrationStateImpl) _then) : super(_value, _then);
__$$RegistrationStateImplCopyWithImpl(_$RegistrationStateImpl _value,
$Res Function(_$RegistrationStateImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
@@ -112,7 +118,9 @@ class _$RegistrationStateImpl implements _RegistrationState {
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$RegistrationStateImpl && (identical(other.sheet, sheet) || other.sheet == sheet));
(other.runtimeType == runtimeType &&
other is _$RegistrationStateImpl &&
(identical(other.sheet, sheet) || other.sheet == sheet));
}
@override
@@ -121,16 +129,19 @@ class _$RegistrationStateImpl implements _RegistrationState {
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$RegistrationStateImplCopyWith<_$RegistrationStateImpl> get copyWith => __$$RegistrationStateImplCopyWithImpl<_$RegistrationStateImpl>(this, _$identity);
_$$RegistrationStateImplCopyWith<_$RegistrationStateImpl> get copyWith =>
__$$RegistrationStateImplCopyWithImpl<_$RegistrationStateImpl>(
this, _$identity);
}
abstract class _RegistrationState implements RegistrationState {
const factory _RegistrationState({required final UserRegistrationSheet sheet}) = _$RegistrationStateImpl;
const factory _RegistrationState(
{required final UserRegistrationSheet sheet}) = _$RegistrationStateImpl;
@override
UserRegistrationSheet get sheet;
@override
@JsonKey(ignore: true)
_$$RegistrationStateImplCopyWith<_$RegistrationStateImpl> get copyWith => throw _privateConstructorUsedError;
_$$RegistrationStateImplCopyWith<_$RegistrationStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}