|
@@ -1,11 +1,13 @@
|
|
|
import 'package:cs_resources/generated/assets.dart';
|
|
|
import 'package:cs_resources/generated/l10n.dart';
|
|
|
+import 'package:domain/entity/user_me_entity.dart';
|
|
|
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:auto_route/auto_route.dart';
|
|
|
import 'package:flutter/rendering.dart';
|
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
+import 'package:plugin_basic/provider/user_config/user_config_service.dart';
|
|
|
import 'package:router/ext/auto_router_extensions.dart';
|
|
|
import 'package:shared/utils/color_utils.dart';
|
|
|
import 'package:shared/utils/ext_dart.dart';
|
|
@@ -103,6 +105,8 @@ class NewsPage extends HookConsumerWidget {
|
|
|
}
|
|
|
|
|
|
Widget _buildNewsItem(BuildContext context, WidgetRef ref, Map<String, dynamic> item, vm, int itemIdx){
|
|
|
+ UserMeEntity userInfo = UserConfigService.getState().user as UserMeEntity;
|
|
|
+ int? user_id = int.tryParse(userInfo?.id ?? "");
|
|
|
String card_title = item.getValue("title", "");
|
|
|
int card_id = item.getValue("id", null);
|
|
|
String card_created_at = item.getValue("created_at", "");
|
|
@@ -141,6 +145,7 @@ class NewsPage extends HookConsumerWidget {
|
|
|
children: [
|
|
|
// 卡片头部(头像 标题 时间)
|
|
|
Container(
|
|
|
+ width: double.infinity,
|
|
|
child: NewsFeedCardHeader(
|
|
|
key: UniqueKey(),
|
|
|
title: card_count_name,
|
|
@@ -184,42 +189,39 @@ class NewsPage extends HookConsumerWidget {
|
|
|
]
|
|
|
),
|
|
|
// 右上角 关注/取消关注 按钮
|
|
|
- Positioned(
|
|
|
- right: 10,
|
|
|
- top: -5,
|
|
|
- child: Container(
|
|
|
- width: 83.5,
|
|
|
- height: 50.5,
|
|
|
- alignment: Alignment.center,
|
|
|
- // decoration: BoxDecoration(
|
|
|
- // color: context.appColors.textPrimary,
|
|
|
- // borderRadius: BorderRadius.circular(5),
|
|
|
- // ),
|
|
|
- child: HookBuilder(
|
|
|
- builder: (context) {
|
|
|
- final isFollowedState = useState<bool>(card_followed);
|
|
|
- return MyButton(
|
|
|
- text: isFollowedState.value ? S.current.followed:S.current.to_follow,
|
|
|
- textColor: isFollowedState.value ? context.appColors.disEnableGray: context.appColors.textWhite,
|
|
|
- disabledTextColor: context.appColors.disEnableGray,
|
|
|
- backgroundColor: isFollowedState.value ? Colors.transparent : context.appColors.textPrimary,
|
|
|
- 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;
|
|
|
- }
|
|
|
- },
|
|
|
- );
|
|
|
- }
|
|
|
- ),
|
|
|
- )
|
|
|
+ Visibility(
|
|
|
+ visible: card_count_id != null && card_count_id != user_id,
|
|
|
+ child: Positioned(
|
|
|
+ right: 0,
|
|
|
+ top: 0,
|
|
|
+ child: Container(
|
|
|
+ width: 83.5,
|
|
|
+ height: 50.5,
|
|
|
+ alignment: Alignment.center,
|
|
|
+ // decoration: BoxDecoration(
|
|
|
+ // color: context.appColors.textPrimary,
|
|
|
+ // borderRadius: BorderRadius.circular(5),
|
|
|
+ // ),
|
|
|
+ child: MyButton(
|
|
|
+ text: card_followed ? S.current.followed:S.current.to_follow,
|
|
|
+ textColor: card_followed ? context.appColors.disEnableGray: context.appColors.textWhite,
|
|
|
+ disabledTextColor: context.appColors.disEnableGray,
|
|
|
+ backgroundColor: card_followed ? Colors.transparent : context.appColors.textPrimary,
|
|
|
+ side: BorderSide(color: !card_followed ? 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, card_followed );
|
|
|
+ // if(asyncResult){
|
|
|
+ // // 成功 关注->取消关注 取消关注->关注
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ),
|
|
|
)
|
|
|
],
|
|
|
),
|