forked from eatvio/eatvio_app
feat(feed): add subscribe button
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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) =>
|
||||
|
||||
@@ -7,11 +7,11 @@ import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.da
|
||||
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/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';
|
||||
|
||||
@@ -89,26 +89,10 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
|
||||
],
|
||||
),
|
||||
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,
|
||||
),
|
||||
child: Text(
|
||||
'Подписаться',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
if (!widget.feedBlogPostModel.author.isEntitySubscribedByMe && !widget.feedBlogPostModel.author.authorIsMe)
|
||||
SubscribeButtonWidget(
|
||||
slug: widget.feedBlogPostModel.author.authorSlug,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ class _SubWidgetState extends State<SubWidget> {
|
||||
authorName: widget.subModel.name,
|
||||
authorProfileIcon: widget.subModel.profilePhotoUrl,
|
||||
authorIsMe: false,
|
||||
isEntitySubscribedByMe: false,
|
||||
),
|
||||
),
|
||||
child: Ink(
|
||||
|
||||
Reference in New Issue
Block a user