Merge remote-tracking branch 'upstream/main'

This commit is contained in:
Username1548
2024-12-04 22:08:00 +07:00
37 changed files with 1513 additions and 380 deletions

View File

@@ -46,6 +46,7 @@ class Author with _$Author {
@JsonKey(name: "author_name") required String authorName,
@JsonKey(name: "author_profile_icon") required String authorProfileIcon,
@JsonKey(name: "author_is_me") required bool authorIsMe,
@JsonKey(name: "is_entity_subscribed_by_me") required bool isEntitySubscribedByMe,
}) = _Author;
factory Author.fromJson(Map<String, dynamic> json) => _$AuthorFromJson(json);

View File

@@ -812,6 +812,8 @@ mixin _$Author {
String get authorProfileIcon => throw _privateConstructorUsedError;
@JsonKey(name: "author_is_me")
bool get authorIsMe => throw _privateConstructorUsedError;
@JsonKey(name: "is_entity_subscribed_by_me")
bool get isEntitySubscribedByMe => throw _privateConstructorUsedError;
/// Serializes this Author to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@@ -831,7 +833,9 @@ abstract class $AuthorCopyWith<$Res> {
{@JsonKey(name: "author_slug") String authorSlug,
@JsonKey(name: "author_name") String authorName,
@JsonKey(name: "author_profile_icon") String authorProfileIcon,
@JsonKey(name: "author_is_me") bool authorIsMe});
@JsonKey(name: "author_is_me") bool authorIsMe,
@JsonKey(name: "is_entity_subscribed_by_me")
bool isEntitySubscribedByMe});
}
/// @nodoc
@@ -853,6 +857,7 @@ class _$AuthorCopyWithImpl<$Res, $Val extends Author>
Object? authorName = null,
Object? authorProfileIcon = null,
Object? authorIsMe = null,
Object? isEntitySubscribedByMe = null,
}) {
return _then(_value.copyWith(
authorSlug: null == authorSlug
@@ -871,6 +876,10 @@ class _$AuthorCopyWithImpl<$Res, $Val extends Author>
? _value.authorIsMe
: authorIsMe // ignore: cast_nullable_to_non_nullable
as bool,
isEntitySubscribedByMe: null == isEntitySubscribedByMe
? _value.isEntitySubscribedByMe
: isEntitySubscribedByMe // ignore: cast_nullable_to_non_nullable
as bool,
) as $Val);
}
}
@@ -886,7 +895,9 @@ abstract class _$$AuthorImplCopyWith<$Res> implements $AuthorCopyWith<$Res> {
{@JsonKey(name: "author_slug") String authorSlug,
@JsonKey(name: "author_name") String authorName,
@JsonKey(name: "author_profile_icon") String authorProfileIcon,
@JsonKey(name: "author_is_me") bool authorIsMe});
@JsonKey(name: "author_is_me") bool authorIsMe,
@JsonKey(name: "is_entity_subscribed_by_me")
bool isEntitySubscribedByMe});
}
/// @nodoc
@@ -906,6 +917,7 @@ class __$$AuthorImplCopyWithImpl<$Res>
Object? authorName = null,
Object? authorProfileIcon = null,
Object? authorIsMe = null,
Object? isEntitySubscribedByMe = null,
}) {
return _then(_$AuthorImpl(
authorSlug: null == authorSlug
@@ -924,6 +936,10 @@ class __$$AuthorImplCopyWithImpl<$Res>
? _value.authorIsMe
: authorIsMe // ignore: cast_nullable_to_non_nullable
as bool,
isEntitySubscribedByMe: null == isEntitySubscribedByMe
? _value.isEntitySubscribedByMe
: isEntitySubscribedByMe // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
@@ -935,7 +951,9 @@ class _$AuthorImpl implements _Author {
{@JsonKey(name: "author_slug") required this.authorSlug,
@JsonKey(name: "author_name") required this.authorName,
@JsonKey(name: "author_profile_icon") required this.authorProfileIcon,
@JsonKey(name: "author_is_me") required this.authorIsMe});
@JsonKey(name: "author_is_me") required this.authorIsMe,
@JsonKey(name: "is_entity_subscribed_by_me")
required this.isEntitySubscribedByMe});
factory _$AuthorImpl.fromJson(Map<String, dynamic> json) =>
_$$AuthorImplFromJson(json);
@@ -952,10 +970,13 @@ class _$AuthorImpl implements _Author {
@override
@JsonKey(name: "author_is_me")
final bool authorIsMe;
@override
@JsonKey(name: "is_entity_subscribed_by_me")
final bool isEntitySubscribedByMe;
@override
String toString() {
return 'Author(authorSlug: $authorSlug, authorName: $authorName, authorProfileIcon: $authorProfileIcon, authorIsMe: $authorIsMe)';
return 'Author(authorSlug: $authorSlug, authorName: $authorName, authorProfileIcon: $authorProfileIcon, authorIsMe: $authorIsMe, isEntitySubscribedByMe: $isEntitySubscribedByMe)';
}
@override
@@ -970,13 +991,15 @@ class _$AuthorImpl implements _Author {
(identical(other.authorProfileIcon, authorProfileIcon) ||
other.authorProfileIcon == authorProfileIcon) &&
(identical(other.authorIsMe, authorIsMe) ||
other.authorIsMe == authorIsMe));
other.authorIsMe == authorIsMe) &&
(identical(other.isEntitySubscribedByMe, isEntitySubscribedByMe) ||
other.isEntitySubscribedByMe == isEntitySubscribedByMe));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType, authorSlug, authorName, authorProfileIcon, authorIsMe);
int get hashCode => Object.hash(runtimeType, authorSlug, authorName,
authorProfileIcon, authorIsMe, isEntitySubscribedByMe);
/// Create a copy of Author
/// with the given fields replaced by the non-null parameter values.
@@ -996,12 +1019,13 @@ class _$AuthorImpl implements _Author {
abstract class _Author implements Author {
const factory _Author(
{@JsonKey(name: "author_slug") required final String authorSlug,
@JsonKey(name: "author_name") required final String authorName,
@JsonKey(name: "author_profile_icon")
required final String authorProfileIcon,
@JsonKey(name: "author_is_me") required final bool authorIsMe}) =
_$AuthorImpl;
{@JsonKey(name: "author_slug") required final String authorSlug,
@JsonKey(name: "author_name") required final String authorName,
@JsonKey(name: "author_profile_icon")
required final String authorProfileIcon,
@JsonKey(name: "author_is_me") required final bool authorIsMe,
@JsonKey(name: "is_entity_subscribed_by_me")
required final bool isEntitySubscribedByMe}) = _$AuthorImpl;
factory _Author.fromJson(Map<String, dynamic> json) = _$AuthorImpl.fromJson;
@@ -1017,6 +1041,9 @@ abstract class _Author implements Author {
@override
@JsonKey(name: "author_is_me")
bool get authorIsMe;
@override
@JsonKey(name: "is_entity_subscribed_by_me")
bool get isEntitySubscribedByMe;
/// Create a copy of Author
/// with the given fields replaced by the non-null parameter values.

View File

@@ -74,6 +74,7 @@ _$AuthorImpl _$$AuthorImplFromJson(Map<String, dynamic> json) => _$AuthorImpl(
authorName: json['author_name'] as String,
authorProfileIcon: json['author_profile_icon'] as String,
authorIsMe: json['author_is_me'] as bool,
isEntitySubscribedByMe: json['is_entity_subscribed_by_me'] as bool,
);
Map<String, dynamic> _$$AuthorImplToJson(_$AuthorImpl instance) =>
@@ -82,6 +83,7 @@ Map<String, dynamic> _$$AuthorImplToJson(_$AuthorImpl instance) =>
'author_name': instance.authorName,
'author_profile_icon': instance.authorProfileIcon,
'author_is_me': instance.authorIsMe,
'is_entity_subscribed_by_me': instance.isEntitySubscribedByMe,
};
_$DailyScheduleImpl _$$DailyScheduleImplFromJson(Map<String, dynamic> json) =>

View File

@@ -1,3 +1,4 @@
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_state.dart';
import 'package:eatvio_app/features/feed/repositories/feed_repository.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -9,7 +10,24 @@ class FeedCubit extends Cubit<FeedState> {
bool isLoading = false;
String? _query;
FeedCubit({required this.feedRepository}) : super(const FeedState.loading());
FeedCubit({
required this.feedRepository,
}) : super(const FeedState.loading());
updateFeedBlogPostList(FeedBlogPostModel feedBlogPostModel, bool wasLikedByMe) {
List<FeedBlogPostModel> feedBlogPostList = [...(state as FeedStateLoaded).feedBlogPostList];
final int index = feedBlogPostList.indexOf(feedBlogPostModel);
feedBlogPostList[index] = feedBlogPostModel.copyWith(
wasLikedByMe: wasLikedByMe,
totalLikes: wasLikedByMe == false ? feedBlogPostList[index].totalLikes - 1 : feedBlogPostList[index].totalLikes + 1,
);
emit(
FeedState.loaded(
feedBlogPostList: feedBlogPostList,
isLoading: isLoading,
),
);
}
loadFeedBlogPostList({
String? query,

View File

@@ -34,7 +34,7 @@ class FeedScreen extends StatefulWidget {
}
class _FeedScreenState extends State<FeedScreen> {
final FeedCubit feedCubit = sl<FeedCubit>()..loadFeedBlogPostList();
final FeedCubit feedCubit = sl<FeedCubit>();
final RecipesCubit recipesCubit = sl<RecipesCubit>()..loadRecipesList();
final DietsCubit dietsCubit = sl<DietsCubit>()..loadDiets();
final PlansCubit plansCubit = sl<PlansCubit>()..loadPlans();
@@ -49,6 +49,7 @@ class _FeedScreenState extends State<FeedScreen> {
@override
void initState() {
feedCubit.loadFeedBlogPostList();
blogPostsScrollController.addListener(_onScrollBlogPosts);
recipesScrollController.addListener(_onScrollRecipes);
dietsScrollController.addListener(_onScrollDiets);
@@ -185,7 +186,7 @@ class _FeedScreenState extends State<FeedScreen> {
if (index == state.feedBlogPostList.length) {
return const Loader();
}
return BlogPostWidget(feedBlogPostModel: state.feedBlogPostList[index]);
return BlogPostWidget(index: index);
},
separatorBuilder: (context, index) {
return SizedBox(height: 8);
@@ -445,7 +446,7 @@ class _FeedScreenState extends State<FeedScreen> {
GoRouter.of(context).pushNamed(CreatePlanScreen.name);
break;
default:
GoRouter.of(context).pushNamed('blogPostCreateScreen', extra: feedCubit);
GoRouter.of(context).pushNamed('blogPostCreateScreen');
}
},
borderRadius: BorderRadius.circular(64),
@@ -470,6 +471,7 @@ class _FeedScreenState extends State<FeedScreen> {
width: MediaQuery.of(context).size.width - 84,
child: TextFormField(
controller: searchController,
autofocus: false,
style: TextStyle(
fontSize: 12,
),

View File

@@ -4,21 +4,24 @@ import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/utils/date_time_utils.dart';
import 'package:eatvio_app/core/widgets/feed_icon_button.dart';
import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart';
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_state.dart';
import 'package:eatvio_app/features/feed/presentation/widgets/subscribe_button_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:go_router/go_router.dart';
import 'package:share_plus/share_plus.dart';
class BlogPostWidget extends StatefulWidget {
final FeedBlogPostModel feedBlogPostModel;
final int index;
const BlogPostWidget({super.key, required this.feedBlogPostModel});
const BlogPostWidget({
super.key,
required this.index,
});
@override
State<BlogPostWidget> createState() => _BlogPostWidgetState();
@@ -28,224 +31,209 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
late bool isLiked;
late int totalLikes;
@override
void initState() {
isLiked = widget.feedBlogPostModel.wasLikedByMe;
totalLikes = widget.feedBlogPostModel.totalLikes;
super.initState();
}
@override
Widget build(BuildContext context) {
return InkWell(
borderRadius: BorderRadius.circular(12),
onTap: () => GoRouter.of(context).pushNamed(
'blogPostScreen',
extra: widget.feedBlogPostModel,
),
child: Ink(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white,
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
return BlocBuilder<FeedCubit, FeedState>(
builder: (BuildContext context, FeedState state) {
if (state is FeedStateLoaded) {
isLiked = state.feedBlogPostList[widget.index].wasLikedByMe;
totalLikes = state.feedBlogPostList[widget.index].totalLikes;
return InkWell(
borderRadius: BorderRadius.circular(12),
onTap: () => GoRouter.of(context).pushNamed(
'blogPostScreen',
extra: state.feedBlogPostList[widget.index],
),
child: Ink(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white,
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
radius: 20,
backgroundColor: Colors.black12,
foregroundImage: NetworkImage(
widget.feedBlogPostModel.author.authorProfileIcon,
SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
children: [
CircleAvatar(
radius: 20,
backgroundColor: Colors.black12,
foregroundImage: NetworkImage(
state.feedBlogPostList[widget.index].author.authorProfileIcon,
),
),
SizedBox(width: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
state.feedBlogPostList[widget.index].author.authorName,
style: TextStyle(
height: 1,
color: Colors.black87,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 4),
Text(
'${calculateDifference(state.feedBlogPostList[widget.index].createdAt)} в ${state.feedBlogPostList[widget.index].createdAt.hour.toString().padLeft(2, '0')}:${state.feedBlogPostList[widget.index].createdAt.minute.toString().padLeft(2, '0')}',
style: TextStyle(
height: 1,
color: Colors.black45,
),
),
],
),
const Spacer(),
if (!state.feedBlogPostList[widget.index].author.isEntitySubscribedByMe && !state.feedBlogPostList[widget.index].author.authorIsMe)
SubscribeButtonWidget(
slug: state.feedBlogPostList[widget.index].author.authorSlug,
),
],
),
),
SizedBox(width: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.feedBlogPostModel.author.authorName,
style: TextStyle(
height: 1,
color: Colors.black87,
fontWeight: FontWeight.w500,
),
if (state.feedBlogPostList[widget.index].title.isNotEmpty || state.feedBlogPostList[widget.index].description.isNotEmpty)
SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Text(
state.feedBlogPostList[widget.index].title,
style: TextStyle(
fontWeight: FontWeight.w600,
color: Colors.black87,
),
const SizedBox(height: 4),
Text(
calculateDifference(
widget.feedBlogPostModel.createdAt,
),
style: TextStyle(
height: 1,
color: Colors.black45,
),
),
],
),
),
const Spacer(),
InkWell(
onTap: () {
Fluttertoast.showToast(msg: 'ща доделаем');
},
borderRadius: BorderRadius.circular(8),
child: Ink(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: appTheme.gray200,
if (state.feedBlogPostList[widget.index].title.isNotEmpty && state.feedBlogPostList[widget.index].description.isNotEmpty) SizedBox(height: 8),
if (state.feedBlogPostList[widget.index].description.isNotEmpty)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Html(
data: state.feedBlogPostList[widget.index].description.length > 200
? state.feedBlogPostList[widget.index].description.substring(0, 200)
: state.feedBlogPostList[widget.index].description,
style: {
"*": Style(
color: Colors.black87,
),
},
),
),
if (state.feedBlogPostList[widget.index].description.length > 200)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
'Подписаться',
'Читать полностью...',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w500,
height: 1,
color: appTheme.blueA400,
decoration: TextDecoration.underline,
),
),
),
),
],
),
),
if (widget.feedBlogPostModel.title.isNotEmpty || widget.feedBlogPostModel.description.isNotEmpty) SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Text(
widget.feedBlogPostModel.title,
style: TextStyle(
fontWeight: FontWeight.w600,
color: Colors.black87,
),
),
),
if (widget.feedBlogPostModel.title.isNotEmpty && widget.feedBlogPostModel.description.isNotEmpty) SizedBox(height: 8),
if (widget.feedBlogPostModel.description.isNotEmpty)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Html(
data: widget.feedBlogPostModel.description.length > 200
? widget.feedBlogPostModel.description.substring(0, 200)
: widget.feedBlogPostModel.description,
style: {
"*": Style(
color: Colors.black87,
),
},
),
),
if (widget.feedBlogPostModel.description.length > 200)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
'Читать полностью...',
style: TextStyle(
height: 1,
color: appTheme.blueA400,
decoration: TextDecoration.underline,
),
),
),
if (widget.feedBlogPostModel.title.isNotEmpty || widget.feedBlogPostModel.description.isNotEmpty) SizedBox(height: 8),
GestureDetector(
onTap: () {
context.pushTransparentRoute(
rootNavigator: true,
PhotoViewScreen(
imageUrls: [baseUrl + '/storage/' + widget.feedBlogPostModel.image],
index: 0,
),
);
},
child: Hero(
tag: baseUrl + '/storage/' + widget.feedBlogPostModel.image,
child: CachedNetworkImage(
fit: BoxFit.fitWidth,
width: MediaQuery.of(context).size.width,
imageUrl: baseUrl + '/storage/' + widget.feedBlogPostModel.image,
errorWidget: (context, str, object) => SizedBox.shrink(),
),
),
),
SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
children: [
FeedIconButton(
icon: isLiked ? Icons.favorite_rounded : Icons.favorite_border_rounded,
text: totalLikes.toString(),
iconColor: isLiked ? Colors.red.withOpacity(0.8) : null,
backgroundColor: isLiked ? Colors.red.withOpacity(0.1) : null,
textColor: isLiked ? Colors.red.withOpacity(0.8) : null,
onTap: () async {
setState(() {
isLiked = !isLiked;
isLiked ? totalLikes++ : totalLikes--;
});
isLiked
? await context.read<FeedCubit>().likePost(widget.feedBlogPostModel.id)
: await context.read<FeedCubit>().unlikedPost(widget.feedBlogPostModel.id);
await context.read<FeedCubit>().loadFeedBlogPostList();
if (state.feedBlogPostList[widget.index].title.isNotEmpty || state.feedBlogPostList[widget.index].description.isNotEmpty) SizedBox(height: 8),
GestureDetector(
onTap: () {
context.pushTransparentRoute(
rootNavigator: true,
PhotoViewScreen(
imageUrls: [baseUrl + '/storage/' + state.feedBlogPostList[widget.index].image],
index: 0,
),
);
},
),
SizedBox(width: 8),
FeedIconButton(
svgIcon: SvgPicture.asset(
'assets/icons/comment.svg',
height: 20,
width: 20,
colorFilter: ColorFilter.mode(
appTheme.gray600,
BlendMode.srcIn,
),
),
text: widget.feedBlogPostModel.totalComments.toString(),
onTap: () => GoRouter.of(context).pushNamed(
'blogPostScreen',
extra: widget.feedBlogPostModel,
),
),
SizedBox(width: 8),
FeedIconButton(
svgIcon: SvgPicture.asset(
height: 20,
width: 20,
'assets/icons/share.svg',
colorFilter: ColorFilter.mode(appTheme.gray600, BlendMode.srcIn),
),
onTap: () => Share.shareUri(
Uri.parse(
baseUrl + '/ru/blog_post/' + widget.feedBlogPostModel.id.toString(),
child: Hero(
tag: baseUrl + '/storage/' + state.feedBlogPostList[widget.index].image,
child: CachedNetworkImage(
fit: BoxFit.fitWidth,
width: MediaQuery.of(context).size.width,
imageUrl: baseUrl + '/storage/' + state.feedBlogPostList[widget.index].image,
errorWidget: (context, str, object) => SizedBox.shrink(),
),
),
),
Spacer(),
Icon(
Icons.visibility_rounded,
size: 16,
color: appTheme.gray500,
),
SizedBox(width: 4),
Text(
widget.feedBlogPostModel.totalViews.toString(),
style: TextStyle(
fontSize: 12,
color: appTheme.gray500,
fontWeight: FontWeight.w400,
SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
children: [
FeedIconButton(
icon: isLiked ? Icons.favorite_rounded : Icons.favorite_border_rounded,
text: totalLikes.toString(),
iconColor: isLiked ? Colors.red.withOpacity(0.8) : null,
backgroundColor: isLiked ? Colors.red.withOpacity(0.1) : null,
textColor: isLiked ? Colors.red.withOpacity(0.8) : null,
onTap: () async {
setState(() {
isLiked = !isLiked;
isLiked ? totalLikes++ : totalLikes--;
});
isLiked
? await context.read<FeedCubit>().likePost(state.feedBlogPostList[widget.index].id)
: await context.read<FeedCubit>().unlikedPost(state.feedBlogPostList[widget.index].id);
await context.read<FeedCubit>().loadFeedBlogPostList();
},
),
SizedBox(width: 8),
FeedIconButton(
svgIcon: SvgPicture.asset(
'assets/icons/comment.svg',
height: 20,
width: 20,
colorFilter: ColorFilter.mode(
appTheme.gray600,
BlendMode.srcIn,
),
),
text: state.feedBlogPostList[widget.index].totalComments.toString(),
onTap: () => GoRouter.of(context).pushNamed(
'blogPostScreen',
extra: state.feedBlogPostList[widget.index],
),
),
SizedBox(width: 8),
FeedIconButton(
svgIcon: SvgPicture.asset(
height: 20,
width: 20,
'assets/icons/share.svg',
colorFilter: ColorFilter.mode(appTheme.gray600, BlendMode.srcIn),
),
onTap: () => Share.shareUri(
Uri.parse(
baseUrl + '/ru/blog_post/' + state.feedBlogPostList[widget.index].id.toString(),
),
),
),
Spacer(),
Icon(
Icons.visibility_rounded,
size: 16,
color: appTheme.gray500,
),
SizedBox(width: 4),
Text(
state.feedBlogPostList[widget.index].totalViews.toString(),
style: TextStyle(
fontSize: 12,
color: appTheme.gray500,
fontWeight: FontWeight.w400,
),
),
],
),
),
SizedBox(height: 8),
],
),
),
SizedBox(height: 8),
],
),
),
);
}
return const SizedBox.shrink();
},
);
}
}

View File

@@ -77,13 +77,16 @@ class _CommentsWidgetState extends State<CommentsWidget> {
),
),
SizedBox(height: 4),
Text(
comment.body,
style: TextStyle(
height: 1,
color: appTheme.black,
fontSize: 12,
fontWeight: FontWeight.w500,
SizedBox(
width: MediaQuery.of(context).size.width * 0.8,
child: Text(
comment.body,
style: TextStyle(
height: 1,
color: appTheme.black,
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
),
SizedBox(height: 4),

View File

@@ -0,0 +1,57 @@
import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/profile/presentation/bloc/sub_cubit/sub_cubit.dart';
import 'package:flutter/material.dart';
class SubscribeButtonWidget extends StatefulWidget {
final String slug;
const SubscribeButtonWidget({
super.key,
required this.slug,
});
@override
State<SubscribeButtonWidget> createState() => _SubscribeButtonWidgetState();
}
class _SubscribeButtonWidgetState extends State<SubscribeButtonWidget> {
bool isSubscribe = false;
@override
Widget build(BuildContext context) {
return AnimatedOpacity(
opacity: isSubscribe ? 0 : 1,
duration: Duration(milliseconds: 250),
child: InkWell(
onTap: () async {
try {
setState(() {
isSubscribe = true;
});
await sl<SubCubit>().subscribe(widget.slug);
} catch (e) {
setState(() {
isSubscribe = false;
});
}
},
borderRadius: BorderRadius.circular(8),
child: Ink(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: appTheme.gray200,
),
child: Text(
'Подписаться',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w500,
),
),
),
),
);
}
}