|
@@ -39,6 +39,7 @@ class NewsfeedPage extends HookConsumerWidget {
|
|
|
width: double.infinity,
|
|
|
padding: const EdgeInsets.only(left: 15, right: 15,top: 14,bottom: 14),
|
|
|
child: NewsfeedTabs(
|
|
|
+ key: UniqueKey(),
|
|
|
tabsList: vm.state.tabsList,
|
|
|
),
|
|
|
);
|
|
@@ -105,6 +106,7 @@ class NewsfeedPage extends HookConsumerWidget {
|
|
|
children: [
|
|
|
// 卡片头部(头像 标题 时间)
|
|
|
NewsFeedCardHeader(
|
|
|
+ key: UniqueKey(),
|
|
|
title: item['title'],
|
|
|
avator: item['avator'],
|
|
|
time: item['time'],
|
|
@@ -113,6 +115,7 @@ class NewsfeedPage extends HookConsumerWidget {
|
|
|
// 卡片中间 (文字和图片)
|
|
|
Expanded(
|
|
|
child: NewsFeedCardContent(
|
|
|
+ key: UniqueKey(),
|
|
|
content: item['content'],
|
|
|
imageUrls: item['imageUrls'],
|
|
|
),
|
|
@@ -120,35 +123,50 @@ class NewsfeedPage extends HookConsumerWidget {
|
|
|
const SizedBox(height: 26),
|
|
|
// // 卡片底部 (点赞 评论 分享)
|
|
|
NewsFeedCardFooter(
|
|
|
- isLike: item['isLike'],
|
|
|
+ key: UniqueKey(),
|
|
|
+ isLike: item['isLike'],
|
|
|
+ onLike: (){
|
|
|
+ vm.handlerClickActionBtn('like', item);
|
|
|
+ },
|
|
|
+ onComment: (){
|
|
|
+ vm.handlerClickActionBtn('comments', item);
|
|
|
+ },
|
|
|
+ onShare: (){
|
|
|
+ vm.handlerClickActionBtn('share', item);
|
|
|
+ },
|
|
|
),
|
|
|
]
|
|
|
),
|
|
|
),
|
|
|
// 右上角 关注/取消关注 按钮
|
|
|
- Positioned(
|
|
|
- right: 20,
|
|
|
- top: 20,
|
|
|
- child: Container(
|
|
|
- width: 100,
|
|
|
- alignment: Alignment.center,
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: item['isFollow'] ? ColorUtils.string2Color('#FFEBEE') : ColorUtils.string2Color('#F2F3F6'),
|
|
|
- borderRadius: BorderRadius.circular(15),
|
|
|
- ),
|
|
|
- child: MyButton(
|
|
|
- text: item['isFollow'] ? 'Following' : 'Follow',
|
|
|
- textColor: item['isFollow'] ? ColorUtils.string2Color('#FF0000') : ColorUtils.string2Color('#000000'),
|
|
|
- backgroundColor: item['isFollow'] ? ColorUtils.string2Color('#F2F3F6') : ColorUtils.string2Color('#FFEBEE'),
|
|
|
- radius: 0,
|
|
|
- minHeight: 50,
|
|
|
- fontWeight: FontWeight.w500,
|
|
|
- fontSize: 14,
|
|
|
- onPressed: (){
|
|
|
- // Navigator.pop(context);
|
|
|
- },
|
|
|
- ),
|
|
|
- )
|
|
|
+ Visibility(
|
|
|
+ visible: !item['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);
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ),
|
|
|
)
|
|
|
],
|
|
|
),
|
|
@@ -162,6 +180,7 @@ class NewsfeedPage extends HookConsumerWidget {
|
|
|
}else {
|
|
|
List itemsList = vm.state.list.toList();
|
|
|
return ListView.builder(
|
|
|
+ key: UniqueKey(),
|
|
|
itemCount: itemsList.length,
|
|
|
itemBuilder: (context, index) {
|
|
|
return _buildNewsItem(context, ref, itemsList[index], vm);
|
|
@@ -179,8 +198,9 @@ class NewsfeedPage extends HookConsumerWidget {
|
|
|
backgroundColor: ColorUtils.string2Color("#F2F3F6"),
|
|
|
body: Column(
|
|
|
children: [
|
|
|
+ // 顶部的 tab
|
|
|
_buildTabsSection(context, ref, vm),
|
|
|
-
|
|
|
+ // post 组件
|
|
|
_buildPostSection(context, ref, vm),
|
|
|
|
|
|
// Expanded(
|
|
@@ -200,42 +220,42 @@ class NewsfeedPage extends HookConsumerWidget {
|
|
|
// )
|
|
|
NotificationListener <ScrollNotification>(
|
|
|
onNotification: (ScrollNotification notification) {
|
|
|
- // 检查当前页面是否是可见的
|
|
|
- bool isDownOrUp = notification.metrics.axis == Axis.vertical;
|
|
|
- if (notification is UserScrollNotification) {
|
|
|
- // 检查滚动方向
|
|
|
- switch (notification.direction) {
|
|
|
- case ScrollDirection.forward:
|
|
|
- print('Scrolling down');
|
|
|
- break;
|
|
|
- case ScrollDirection.reverse:
|
|
|
- print('Scrolling up');
|
|
|
- break;
|
|
|
- case ScrollDirection.idle:
|
|
|
- print('Scrolling stopped');
|
|
|
- break;
|
|
|
- }
|
|
|
- } else if (notification is ScrollUpdateNotification) {
|
|
|
- // 检查滚动位置变化
|
|
|
- double currentScrollPosition = notification.metrics.pixels;
|
|
|
- double maxScrollExtent = notification.metrics.maxScrollExtent;
|
|
|
-
|
|
|
- // 判断是否满足某个条件
|
|
|
- if (currentScrollPosition > 0 && currentScrollPosition < maxScrollExtent) {
|
|
|
- print('Current scroll position: $currentScrollPosition');
|
|
|
- // 在这里添加你的条件判断逻辑
|
|
|
- }
|
|
|
-
|
|
|
- // 只有当上下滚动时才拦截通知
|
|
|
- if (notification.metrics.axis == Axis.vertical) {
|
|
|
- final tabsRouter = ref.watch(communityVmProvider).tabsRouter;
|
|
|
- final curUseTag = ref.watch(communityVmProvider).useTag;
|
|
|
- if(curUseTag != 0 ){
|
|
|
- // 非当前 页面都阻止滚动
|
|
|
- return true; // 返回 true 表示已处理通知
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // // 检查当前页面是否是可见的
|
|
|
+ // bool isDownOrUp = notification.metrics.axis == Axis.vertical;
|
|
|
+ // if (notification is UserScrollNotification) {
|
|
|
+ // // 检查滚动方向
|
|
|
+ // switch (notification.direction) {
|
|
|
+ // case ScrollDirection.forward:
|
|
|
+ // print('Scrolling down');
|
|
|
+ // break;
|
|
|
+ // case ScrollDirection.reverse:
|
|
|
+ // print('Scrolling up');
|
|
|
+ // break;
|
|
|
+ // case ScrollDirection.idle:
|
|
|
+ // print('Scrolling stopped');
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // } else if (notification is ScrollUpdateNotification) {
|
|
|
+ // // 检查滚动位置变化
|
|
|
+ // double currentScrollPosition = notification.metrics.pixels;
|
|
|
+ // double maxScrollExtent = notification.metrics.maxScrollExtent;
|
|
|
+ //
|
|
|
+ // // 判断是否满足某个条件
|
|
|
+ // if (currentScrollPosition > 0 && currentScrollPosition < maxScrollExtent) {
|
|
|
+ // print('Current scroll position: $currentScrollPosition');
|
|
|
+ // // 在这里添加你的条件判断逻辑
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // // 只有当上下滚动时才拦截通知
|
|
|
+ // if (notification.metrics.axis == Axis.vertical) {
|
|
|
+ // final tabsRouter = ref.watch(communityVmProvider).tabsRouter;
|
|
|
+ // final curUseTag = ref.watch(communityVmProvider).useTag;
|
|
|
+ // if(curUseTag != 0 ){
|
|
|
+ // // 非当前 页面都阻止滚动
|
|
|
+ // return true; // 返回 true 表示已处理通知
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
return false; // 返回 false 表示不拦截通知
|
|
|
},
|
|
|
child: Expanded(
|