|
@@ -1,6 +1,7 @@
|
|
import 'package:cpt_community/router/page/community_page_router.dart';
|
|
import 'package:cpt_community/router/page/community_page_router.dart';
|
|
import 'package:cs_resources/generated/assets.dart';
|
|
import 'package:cs_resources/generated/assets.dart';
|
|
import 'package:cs_resources/theme/app_colors_theme.dart';
|
|
import 'package:cs_resources/theme/app_colors_theme.dart';
|
|
|
|
+import 'package:domain/entity/newsfeed_detail_entity.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:auto_route/auto_route.dart';
|
|
import 'package:auto_route/auto_route.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
@@ -8,6 +9,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:plugin_basic/provider/app_config/app_config.dart';
|
|
import 'package:plugin_basic/provider/app_config/app_config.dart';
|
|
import 'package:router/ext/auto_router_extensions.dart';
|
|
import 'package:router/ext/auto_router_extensions.dart';
|
|
import 'package:shared/utils/color_utils.dart';
|
|
import 'package:shared/utils/color_utils.dart';
|
|
|
|
+import 'package:shared/utils/ext_dart.dart';
|
|
import 'package:shared/utils/log_utils.dart';
|
|
import 'package:shared/utils/log_utils.dart';
|
|
import 'package:widgets/ext/ex_widget.dart';
|
|
import 'package:widgets/ext/ex_widget.dart';
|
|
import 'package:widgets/load_state_layout.dart';
|
|
import 'package:widgets/load_state_layout.dart';
|
|
@@ -30,9 +32,9 @@ class NewsfeedDetailPage extends HookConsumerWidget {
|
|
final int? id;
|
|
final int? id;
|
|
final String? type; // news following foryou
|
|
final String? type; // news following foryou
|
|
|
|
|
|
- const NewsfeedDetailPage({Key? key, required this.id, required this.type}) : super(key: key);
|
|
|
|
|
|
+ const NewsfeedDetailPage({Key? key, @PathParam('id') required this.id, @PathParam('type') required this.type}) : super(key: key);
|
|
// 启动当前页面
|
|
// 启动当前页面
|
|
- static void startInstance({BuildContext? context, int? id, String? type='news'}) {
|
|
|
|
|
|
+ static void startInstance({BuildContext? context, int? id, String? type = 'news'}) {
|
|
if (context != null) {
|
|
if (context != null) {
|
|
context.router.push(NewsfeedDetailPageRoute(id: id, type: type));
|
|
context.router.push(NewsfeedDetailPageRoute(id: id, type: type));
|
|
} else {
|
|
} else {
|
|
@@ -47,9 +49,14 @@ class NewsfeedDetailPage extends HookConsumerWidget {
|
|
final state = ref.watch(newsfeedDetailVmProvider);
|
|
final state = ref.watch(newsfeedDetailVmProvider);
|
|
GlobalKey _likeButtonKey = GlobalKey<MyLikeButtonState>();
|
|
GlobalKey _likeButtonKey = GlobalKey<MyLikeButtonState>();
|
|
|
|
|
|
|
|
+ NewsfeedDetailEntity? detailInfo = state.detailInfo!;
|
|
|
|
+
|
|
|
|
+ List<NewsfeedDetailComments>? commentList = detailInfo!.comments;
|
|
|
|
+
|
|
useEffect((){
|
|
useEffect((){
|
|
|
|
+ vm.setCurrentDetailType(type!);
|
|
// 组件挂载时执行 - 执行接口请求
|
|
// 组件挂载时执行 - 执行接口请求
|
|
- Future.microtask(() => vm.initPageData(id: id));
|
|
|
|
|
|
+ Future.microtask(() => vm.initPageData(id: id, type: type));
|
|
return () {
|
|
return () {
|
|
// 组件卸载时执行
|
|
// 组件卸载时执行
|
|
};
|
|
};
|
|
@@ -66,52 +73,66 @@ class NewsfeedDetailPage extends HookConsumerWidget {
|
|
body: Column(
|
|
body: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisSize: MainAxisSize.max,
|
|
children:[
|
|
children:[
|
|
- Expanded(
|
|
|
|
|
|
+ Expanded(
|
|
child: EasyRefresh(
|
|
child: EasyRefresh(
|
|
controller: vm.refreshController,
|
|
controller: vm.refreshController,
|
|
// 上拉加载
|
|
// 上拉加载
|
|
onLoad: () async{
|
|
onLoad: () async{
|
|
Log.d("----onLoad");
|
|
Log.d("----onLoad");
|
|
- vm.loadMore();
|
|
|
|
|
|
+ vm.loadMore(id:id, type: type);
|
|
},
|
|
},
|
|
// 下拉刷新
|
|
// 下拉刷新
|
|
onRefresh: () async{
|
|
onRefresh: () async{
|
|
Log.d("----onRefresh");
|
|
Log.d("----onRefresh");
|
|
- vm.onRefresh();
|
|
|
|
|
|
+ vm.onRefresh(id:id, type: type);
|
|
},
|
|
},
|
|
child: LoadStateLayout(
|
|
child: LoadStateLayout(
|
|
state: state.loadingState,
|
|
state: state.loadingState,
|
|
errorMessage: state.errorMessage,
|
|
errorMessage: state.errorMessage,
|
|
errorRetry: () {
|
|
errorRetry: () {
|
|
- vm.retryRequest();
|
|
|
|
|
|
+ vm.retryRequest(id:id, type: type);
|
|
},
|
|
},
|
|
successSliverWidget: [
|
|
successSliverWidget: [
|
|
SliverList(
|
|
SliverList(
|
|
delegate: SliverChildListDelegate(
|
|
delegate: SliverChildListDelegate(
|
|
[
|
|
[
|
|
- _buildTopCard(context, ref),
|
|
|
|
- ConstrainedBox(
|
|
|
|
- constraints: BoxConstraints(
|
|
|
|
- minHeight: MediaQuery.of(context).size.height - 250 - 150,
|
|
|
|
- ),
|
|
|
|
- child: _buildCommentListCard(context, ref),
|
|
|
|
- )
|
|
|
|
- ]
|
|
|
|
|
|
+ _buildTopCard(context, ref, detailInfo),
|
|
|
|
+ ConstrainedBox(
|
|
|
|
+ constraints: BoxConstraints(
|
|
|
|
+ minHeight: MediaQuery.of(context).size.height - 250 - 150,
|
|
|
|
+ ),
|
|
|
|
+ child: _buildCommentListCard(context, ref, detailInfo),
|
|
|
|
+ )
|
|
|
|
+ ]
|
|
),
|
|
),
|
|
)
|
|
)
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
- _buildBottomActionSection(context, ref, _likeButtonKey),
|
|
|
|
|
|
+ (detailInfo != null && detailInfo.id != null)? _buildBottomActionSection(context, ref,vm, _likeButtonKey): SizedBox.shrink(),
|
|
]
|
|
]
|
|
)
|
|
)
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- Widget _buildTopCard(BuildContext context, WidgetRef ref){
|
|
|
|
|
|
+ Widget _buildTopCard(BuildContext context, WidgetRef ref,NewsfeedDetailEntity detailInfo ){
|
|
final vm = ref.read(newsfeedDetailVmProvider.notifier);
|
|
final vm = ref.read(newsfeedDetailVmProvider.notifier);
|
|
- final state = ref.watch(newsfeedDetailVmProvider);
|
|
|
|
|
|
+ String card_title = "";
|
|
|
|
+ int card_id = detailInfo!.id??0;
|
|
|
|
+ String card_created_at = detailInfo!.createdAt ?? "";
|
|
|
|
+ NewsfeedDetailAccount card_account = detailInfo!.account?? NewsfeedDetailAccount();
|
|
|
|
+ int card_count_id = card_account!.id??0;
|
|
|
|
+ String card_avator = card_account!.avatar?? '';
|
|
|
|
+ String card_count_name = card_account!.name?? '';
|
|
|
|
+ bool card_followed = card_account!.followed??false;
|
|
|
|
+ String card_content = detailInfo!.content??"";
|
|
|
|
+ bool? card_liked = detailInfo!.liked;
|
|
|
|
+ num card_likes_count = detailInfo!.likesCount?? 0;
|
|
|
|
+ num card_comments_count = detailInfo!.commentsCount?? 0;
|
|
|
|
+ List? card_resources = detailInfo!.resources?? [];
|
|
|
|
+
|
|
|
|
+
|
|
return Stack(
|
|
return Stack(
|
|
children: [
|
|
children: [
|
|
Container(
|
|
Container(
|
|
@@ -136,16 +157,16 @@ class NewsfeedDetailPage extends HookConsumerWidget {
|
|
// 卡片头部(头像 标题 时间)
|
|
// 卡片头部(头像 标题 时间)
|
|
NewsFeedCardHeader(
|
|
NewsFeedCardHeader(
|
|
key: UniqueKey(),
|
|
key: UniqueKey(),
|
|
- title: state?.detailInfo!['title'],
|
|
|
|
- avator: state?.detailInfo['avator'],
|
|
|
|
- time: state?.detailInfo['time'],
|
|
|
|
|
|
+ title: card_count_name,
|
|
|
|
+ avator: card_avator,
|
|
|
|
+ time: card_created_at,
|
|
),
|
|
),
|
|
const SizedBox(height: 15),
|
|
const SizedBox(height: 15),
|
|
// 卡片中间 (文字和图片)
|
|
// 卡片中间 (文字和图片)
|
|
NewsFeedCardContent(
|
|
NewsFeedCardContent(
|
|
key: UniqueKey(),
|
|
key: UniqueKey(),
|
|
- content: state.detailInfo['content'],
|
|
|
|
- imageUrls: state.detailInfo['imageUrls'],
|
|
|
|
|
|
+ content: card_content,
|
|
|
|
+ imageUrls: card_resources,
|
|
textMaxLines: 5000,
|
|
textMaxLines: 5000,
|
|
),
|
|
),
|
|
const SizedBox(height: 26),
|
|
const SizedBox(height: 26),
|
|
@@ -153,134 +174,182 @@ class NewsfeedDetailPage extends HookConsumerWidget {
|
|
),
|
|
),
|
|
),
|
|
),
|
|
// 右上角 关注/取消关注 按钮
|
|
// 右上角 关注/取消关注 按钮
|
|
- Visibility(
|
|
|
|
- visible: !state.detailInfo['isFollow'],
|
|
|
|
- child: Positioned(
|
|
|
|
- right: 40,
|
|
|
|
- top: 35,
|
|
|
|
- child: Container(
|
|
|
|
- width: 83.5,
|
|
|
|
- height: 45.5,
|
|
|
|
- alignment: Alignment.center,
|
|
|
|
- // decoration: BoxDecoration(
|
|
|
|
- // color: ColorUtils.string2Color('#4161D0'),
|
|
|
|
- // borderRadius: BorderRadius.circular(5),
|
|
|
|
- // ),
|
|
|
|
- child: MyButton(
|
|
|
|
- text: '+Follow',
|
|
|
|
- textColor: Colors.white,
|
|
|
|
- backgroundColor: ColorUtils.string2Color('#4161D0'),
|
|
|
|
- radius: 8,
|
|
|
|
- minHeight: 27.5,
|
|
|
|
- padding: const EdgeInsets.only(left: 5, right: 5,top:9,bottom:9),
|
|
|
|
- fontWeight: FontWeight.w400,
|
|
|
|
- fontSize: 14,
|
|
|
|
- onPressed: (){
|
|
|
|
- // Navigator.pop(context);
|
|
|
|
- },
|
|
|
|
- ),
|
|
|
|
- )
|
|
|
|
- ),
|
|
|
|
|
|
+ Positioned(
|
|
|
|
+ right: 40,
|
|
|
|
+ top: 35,
|
|
|
|
+ child: Container(
|
|
|
|
+ width: 83.5,
|
|
|
|
+ height: 45.5,
|
|
|
|
+ alignment: Alignment.center,
|
|
|
|
+ // decoration: BoxDecoration(
|
|
|
|
+ // color: ColorUtils.string2Color('#4161D0'),
|
|
|
|
+ // borderRadius: BorderRadius.circular(5),
|
|
|
|
+ // ),
|
|
|
|
+ child: HookBuilder(
|
|
|
|
+ builder: (context) {
|
|
|
|
+ final isFollowedState = useState<bool>(card_followed);
|
|
|
|
+ return MyButton(
|
|
|
|
+ text: isFollowedState.value ? 'Followed': '+Follow',
|
|
|
|
+ textColor: isFollowedState.value ? context.appColors.disEnableGray: context.appColors.textWhite,
|
|
|
|
+ disabledTextColor: context.appColors.disEnableGray,
|
|
|
|
+ backgroundColor: isFollowedState.value ? Colors.transparent : ColorUtils.string2Color('#4161D0'),
|
|
|
|
+ side: BorderSide(color: !isFollowedState.value ? Colors.transparent : context.appColors.disEnableGray, width: 0.5),
|
|
|
|
+ radius: 8,
|
|
|
|
+ minHeight: 27.5,
|
|
|
|
+ padding: const EdgeInsets.only(left: 5, right: 5,top:9,bottom:9),
|
|
|
|
+ fontWeight: FontWeight.w400,
|
|
|
|
+ fontSize: 14,
|
|
|
|
+ onPressed: () async{
|
|
|
|
+ bool asyncResult = await vm.handlerFollow(context,card_count_id, card_id, isFollowedState.value );
|
|
|
|
+ if(asyncResult){
|
|
|
|
+ // 成功 关注->取消关注 取消关注->关注
|
|
|
|
+ isFollowedState.value = !isFollowedState.value;
|
|
|
|
+ // 修改该item
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ ),
|
|
|
|
+ )
|
|
)
|
|
)
|
|
],
|
|
],
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- Widget _buildCommentListCard(BuildContext context, WidgetRef ref){
|
|
|
|
|
|
+ Widget _buildCommentListCard(BuildContext context, WidgetRef ref, NewsfeedDetailEntity detailInfo){
|
|
final vm = ref.read(newsfeedDetailVmProvider.notifier);
|
|
final vm = ref.read(newsfeedDetailVmProvider.notifier);
|
|
- return Container(
|
|
|
|
- margin: const EdgeInsets.only(left: 15, right: 15,top: 18,bottom: 18),
|
|
|
|
- padding: const EdgeInsets.only(bottom: 30),
|
|
|
|
- decoration: BoxDecoration(
|
|
|
|
- color: context.appColors.textWhite,
|
|
|
|
- borderRadius: BorderRadius.circular(10),
|
|
|
|
- boxShadow: [
|
|
|
|
- BoxShadow(
|
|
|
|
- color: ColorUtils.string2Color("#E4E7EB").withOpacity(0.5),
|
|
|
|
- spreadRadius: 0,
|
|
|
|
- blurRadius: 4,
|
|
|
|
- offset: const Offset(0, 4), // changes position of shadow
|
|
|
|
- ),
|
|
|
|
- ]
|
|
|
|
- ),
|
|
|
|
- child: Column(
|
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
- mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
- children: [
|
|
|
|
- // 总评论数 总收藏数等
|
|
|
|
- Row(
|
|
|
|
|
|
+ int likeCount = detailInfo!.likesCount??0;
|
|
|
|
+ List<NewsfeedDetailComments>? commentList = detailInfo!.comments;
|
|
|
|
+ num commentCount = commentList?.length?? 0;
|
|
|
|
+ return HookBuilder(
|
|
|
|
+ builder: (context) {
|
|
|
|
+ return Container(
|
|
|
|
+ margin: const EdgeInsets.only(left: 15, right: 15,top: 18,bottom: 18),
|
|
|
|
+ padding: const EdgeInsets.only(bottom: 30),
|
|
|
|
+ decoration: BoxDecoration(
|
|
|
|
+ color: context.appColors.textWhite,
|
|
|
|
+ borderRadius: BorderRadius.circular(10),
|
|
|
|
+ boxShadow: [
|
|
|
|
+ BoxShadow(
|
|
|
|
+ color: ColorUtils.string2Color("#E4E7EB").withOpacity(0.5),
|
|
|
|
+ spreadRadius: 0,
|
|
|
|
+ blurRadius: 4,
|
|
|
|
+ offset: const Offset(0, 4), // changes position of shadow
|
|
|
|
+ ),
|
|
|
|
+ ]
|
|
|
|
+ ),
|
|
|
|
+ child: Column(
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
children: [
|
|
- Expanded(
|
|
|
|
- child: Container(
|
|
|
|
- padding: const EdgeInsets.only(left: 15, right: 15,top: 14,bottom: 14),
|
|
|
|
- child: Row(
|
|
|
|
- children: [
|
|
|
|
- MyTextView('Comments', textColor: ColorUtils.string2Color("#2956B7"), fontSize: 15, isFontLight: true,),
|
|
|
|
- const SizedBox(width: 5,),
|
|
|
|
- MyTextView('(95)', textColor: ColorUtils.string2Color("#2956B7"), fontSize: 15, isFontLight: true,),
|
|
|
|
- ]
|
|
|
|
- )
|
|
|
|
- )
|
|
|
|
- ),
|
|
|
|
- // 收藏数
|
|
|
|
- Expanded(
|
|
|
|
- child: Container(
|
|
|
|
- padding: const EdgeInsets.only(right: 20),
|
|
|
|
- child: Row(
|
|
|
|
- mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
- children: [
|
|
|
|
- const MyAssetImage(
|
|
|
|
- Assets.communityLikeActive,
|
|
|
|
- width: 15,
|
|
|
|
- height: 15,
|
|
|
|
- ),
|
|
|
|
- const SizedBox(width: 5,),
|
|
|
|
- MyTextView(
|
|
|
|
- '105K',
|
|
|
|
- textColor: ColorUtils.string2Color("#767676"),
|
|
|
|
- fontSize: 14,
|
|
|
|
- isFontLight: true,
|
|
|
|
|
|
+ // 总评论数 总收藏数等
|
|
|
|
+ Row(
|
|
|
|
+ children: [
|
|
|
|
+ Expanded(
|
|
|
|
+ child: Container(
|
|
|
|
+ padding: const EdgeInsets.only(left: 15, right: 15,top: 14,bottom: 14),
|
|
|
|
+ child: Row(
|
|
|
|
+ children: [
|
|
|
|
+ MyTextView('Comments', textColor: ColorUtils.string2Color("#2956B7"), fontSize: 15, isFontLight: true,),
|
|
|
|
+ const SizedBox(width: 5,),
|
|
|
|
+ MyTextView('(${commentCount})', textColor: ColorUtils.string2Color("#2956B7"), fontSize: 15, isFontLight: true,),
|
|
|
|
+ ]
|
|
|
|
+ )
|
|
|
|
+ )
|
|
|
|
+ ),
|
|
|
|
+ // 收藏数
|
|
|
|
+ Expanded(
|
|
|
|
+ child: Container(
|
|
|
|
+ padding: const EdgeInsets.only(right: 20),
|
|
|
|
+ child: Row(
|
|
|
|
+ mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
+ children: [
|
|
|
|
+ const MyAssetImage(
|
|
|
|
+ Assets.communityLikeActive,
|
|
|
|
+ width: 15,
|
|
|
|
+ height: 15,
|
|
|
|
+ ),
|
|
|
|
+ const SizedBox(width: 5,),
|
|
|
|
+ MyTextView(
|
|
|
|
+ '${likeCount}',
|
|
|
|
+ textColor: ColorUtils.string2Color("#767676"),
|
|
|
|
+ fontSize: 14,
|
|
|
|
+ isFontLight: true,
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
),
|
|
),
|
|
- ],
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- )
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
|
|
+ ),
|
|
|
|
+ )
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
|
|
- // 分割线
|
|
|
|
- Container(
|
|
|
|
- height: 1,
|
|
|
|
- color: context.appColors.dividerDefault,
|
|
|
|
- ),
|
|
|
|
|
|
+ // 分割线
|
|
|
|
+ Container(
|
|
|
|
+ height: 1,
|
|
|
|
+ color: context.appColors.dividerDefault,
|
|
|
|
+ ),
|
|
|
|
|
|
- Padding(
|
|
|
|
- padding: const EdgeInsets.only(top: 16),
|
|
|
|
- child: Column(
|
|
|
|
- children: (vm.state.list.isNotEmpty )? vm.state.list.asMap().entries.map((entry) {
|
|
|
|
- final item = entry.value;
|
|
|
|
- final index = entry.key;
|
|
|
|
- final lastIdx = vm.state.list.length - 1;
|
|
|
|
- return _buildCommentItem(context, ref, item, index, lastIdx);
|
|
|
|
- }).toList(): [
|
|
|
|
- Center(
|
|
|
|
- child: SizedBox(
|
|
|
|
- height: 200,
|
|
|
|
- child: MyTextView("NO DATA"),
|
|
|
|
- ),
|
|
|
|
- )
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
|
|
+ Padding(
|
|
|
|
+ padding: const EdgeInsets.only(top: 16),
|
|
|
|
+ child: Column(
|
|
|
|
+ children: (commentList?.isNotEmpty ?? false)? commentList!.asMap().entries.map((entry) {
|
|
|
|
+ NewsfeedDetailComments item = entry.value;
|
|
|
|
+ final index = entry.key;
|
|
|
|
+ final lastIdx = commentList.length - 1;
|
|
|
|
+ int newsfeedId = detailInfo!.id!;
|
|
|
|
+ int to_user_id = item.id!;
|
|
|
|
+ String to_user_name = item!.account!.name!;
|
|
|
|
+ return _buildCommentItem(context, ref, item, index, lastIdx).onTap((){
|
|
|
|
+ // 点击 单条 评论 则对 此评论进行评论
|
|
|
|
+ vm.handlerCommentClick(context, newsfeedId, to_user_id, to_user_name, true);
|
|
|
|
+ });
|
|
|
|
+ }).toList(): [
|
|
|
|
+ // 没有数据的显示
|
|
|
|
+ const Center(
|
|
|
|
+ child: SizedBox(
|
|
|
|
+ height: 250,
|
|
|
|
+ child: MyAssetImage(Assets.baseServicePageNoData, width: 123.5, height: 115.5, fit: BoxFit.contain),
|
|
|
|
+ ),
|
|
|
|
+ )
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ ]
|
|
),
|
|
),
|
|
- ]
|
|
|
|
- ),
|
|
|
|
- ).borderRadius(all:8);
|
|
|
|
|
|
+ ).borderRadius(all:8);
|
|
|
|
+ }
|
|
|
|
+ );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildCommentItem(BuildContext context, WidgetRef ref, item, index, lastIdx){
|
|
Widget _buildCommentItem(BuildContext context, WidgetRef ref, item, index, lastIdx){
|
|
final vm = ref.read(newsfeedDetailVmProvider.notifier);
|
|
final vm = ref.read(newsfeedDetailVmProvider.notifier);
|
|
final state = ref.watch(newsfeedDetailVmProvider);
|
|
final state = ref.watch(newsfeedDetailVmProvider);
|
|
|
|
+ final detailInfo = state.detailInfo!;
|
|
|
|
+ List<NewsfeedDetailComments>? commentList = detailInfo!.comments;
|
|
|
|
+ num commentCount = commentList?.length?? 0;
|
|
|
|
+
|
|
|
|
+ NewsfeedDetailComments? comment_Item = commentList?[index];
|
|
|
|
+ int comment_id = comment_Item!.id?? 0;
|
|
|
|
+ String comment_content = comment_Item!.content?? '';
|
|
|
|
+
|
|
|
|
+ String comment_time = comment_Item!.createdAt?? '';
|
|
|
|
+ NewsfeedDetailCommentsAccount? commentAccount_Item = commentList?[index].account;
|
|
|
|
+ String comment_avatar = commentAccount_Item?.avatar?? '';
|
|
|
|
+ int comment_account_id = commentAccount_Item?.id?? 0;
|
|
|
|
+ String comment_name = commentAccount_Item?.name?? "";
|
|
|
|
+
|
|
|
|
+ NewsfeedDetailCommentsToAccount? commentToAccount_Item = commentList?[index].toAccount;
|
|
|
|
+ String comment_toAccount_avatar = commentToAccount_Item?.avatar?? '';
|
|
|
|
+ int comment_toAccount_id = commentToAccount_Item?.id?? 0;
|
|
|
|
+ String comment_toAccount_name = commentToAccount_Item?.name?? "";
|
|
|
|
+
|
|
|
|
+ if(commentToAccount_Item !=null && comment_toAccount_name != null){
|
|
|
|
+ comment_content = '@$comment_toAccount_name: $comment_content';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
return Container(
|
|
return Container(
|
|
padding: const EdgeInsets.only(left: 20,right: 20),
|
|
padding: const EdgeInsets.only(left: 20,right: 20),
|
|
margin: EdgeInsets.only(top: index> 0? 16: 0),
|
|
margin: EdgeInsets.only(top: index> 0? 16: 0),
|
|
@@ -290,7 +359,7 @@ class NewsfeedDetailPage extends HookConsumerWidget {
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
children: [
|
|
MyLoadImage(
|
|
MyLoadImage(
|
|
- item['avator'],
|
|
|
|
|
|
+ comment_avatar,
|
|
width: 43,
|
|
width: 43,
|
|
height: 43,
|
|
height: 43,
|
|
isCircle: true,
|
|
isCircle: true,
|
|
@@ -308,7 +377,7 @@ class NewsfeedDetailPage extends HookConsumerWidget {
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
children: [
|
|
MyTextView(
|
|
MyTextView(
|
|
- item['userName'],
|
|
|
|
|
|
+ comment_name,
|
|
isFontRegular: true,
|
|
isFontRegular: true,
|
|
fontSize: 14,
|
|
fontSize: 14,
|
|
textColor: ColorUtils.string2Color('#2956B7'),
|
|
textColor: ColorUtils.string2Color('#2956B7'),
|
|
@@ -316,7 +385,7 @@ class NewsfeedDetailPage extends HookConsumerWidget {
|
|
isTextEllipsis: true,
|
|
isTextEllipsis: true,
|
|
),
|
|
),
|
|
MyTextView(
|
|
MyTextView(
|
|
- item['time'],
|
|
|
|
|
|
+ comment_time,
|
|
isFontLight: true,
|
|
isFontLight: true,
|
|
fontSize: 12,
|
|
fontSize: 12,
|
|
marginTop: 10,
|
|
marginTop: 10,
|
|
@@ -325,7 +394,7 @@ class NewsfeedDetailPage extends HookConsumerWidget {
|
|
isTextEllipsis: true,
|
|
isTextEllipsis: true,
|
|
),
|
|
),
|
|
MyTextView(
|
|
MyTextView(
|
|
- item['content'],
|
|
|
|
|
|
+ comment_content,
|
|
isFontLight: true,
|
|
isFontLight: true,
|
|
fontSize: 15,
|
|
fontSize: 15,
|
|
marginTop: 10,
|
|
marginTop: 10,
|
|
@@ -347,11 +416,23 @@ class NewsfeedDetailPage extends HookConsumerWidget {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- Widget _buildBottomActionSection(BuildContext context, WidgetRef ref , _likeButtonKey){
|
|
|
|
|
|
+ Widget _buildBottomActionSection(BuildContext context, WidgetRef ref ,vm, _likeButtonKey){
|
|
final state = ref.watch(newsfeedDetailVmProvider);
|
|
final state = ref.watch(newsfeedDetailVmProvider);
|
|
final vm = ref.read(newsfeedDetailVmProvider.notifier);
|
|
final vm = ref.read(newsfeedDetailVmProvider.notifier);
|
|
- bool isLike = state.detailInfo['isLike'];
|
|
|
|
|
|
+
|
|
|
|
+ NewsfeedDetailEntity detailInfo = state.detailInfo!;
|
|
|
|
+
|
|
|
|
+ int newsfeedId = detailInfo!.id!;
|
|
|
|
+
|
|
|
|
+ int to_user_id = detailInfo!.account!.id!;
|
|
|
|
+ String to_user_name = detailInfo!.account!.name!;
|
|
|
|
+
|
|
|
|
+ // List<NewsfeedDetailComments>? commentList = detailInfo!.comments;
|
|
|
|
+
|
|
|
|
+ bool isLike = detailInfo!.liked?? false;
|
|
|
|
+
|
|
return SafeArea(
|
|
return SafeArea(
|
|
|
|
+ bottom: true,
|
|
child: Visibility(
|
|
child: Visibility(
|
|
visible: state.loadingState == LoadState.State_Success,
|
|
visible: state.loadingState == LoadState.State_Success,
|
|
child: Container(
|
|
child: Container(
|
|
@@ -374,14 +455,19 @@ class NewsfeedDetailPage extends HookConsumerWidget {
|
|
children: [
|
|
children: [
|
|
MyLikeButton(
|
|
MyLikeButton(
|
|
key: _likeButtonKey,
|
|
key: _likeButtonKey,
|
|
- isLiked: false,
|
|
|
|
|
|
+ isLiked: isLike,
|
|
isCustomIcon: true,
|
|
isCustomIcon: true,
|
|
customIconWidth: 20,
|
|
customIconWidth: 20,
|
|
customIconHeight: 18,
|
|
customIconHeight: 18,
|
|
customIconActiveAssets: Assets.communityLikeActive,
|
|
customIconActiveAssets: Assets.communityLikeActive,
|
|
customIconUnActiveAssets: Assets.communityNewsfeedDetailLike,
|
|
customIconUnActiveAssets: Assets.communityNewsfeedDetailLike,
|
|
- onLike: () {
|
|
|
|
|
|
+ onLike: () async {
|
|
Log.d('点击了like button');
|
|
Log.d('点击了like button');
|
|
|
|
+ bool asyncResult = await vm.handlerLikeClick(context, detailInfo!.id as int, isLike);
|
|
|
|
+ if(asyncResult){
|
|
|
|
+ // 成功
|
|
|
|
+
|
|
|
|
+ }
|
|
},
|
|
},
|
|
),
|
|
),
|
|
const SizedBox(width: 10,),
|
|
const SizedBox(width: 10,),
|
|
@@ -426,7 +512,7 @@ class NewsfeedDetailPage extends HookConsumerWidget {
|
|
],
|
|
],
|
|
),
|
|
),
|
|
).onTap((){
|
|
).onTap((){
|
|
- vm.handlerCommentClick(context);
|
|
|
|
|
|
+ vm.handlerCommentClick(context, newsfeedId, to_user_id, to_user_name, false);
|
|
})
|
|
})
|
|
],
|
|
],
|
|
),
|
|
),
|