|
@@ -1,9 +1,11 @@
|
|
import 'package:cs_resources/generated/l10n.dart';
|
|
import 'package:cs_resources/generated/l10n.dart';
|
|
|
|
+import 'package:domain/entity/user_me_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/rendering.dart';
|
|
import 'package:flutter/rendering.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.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: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/ext_dart.dart';
|
|
@@ -98,17 +100,22 @@ class ForyouPage extends HookConsumerWidget {
|
|
}
|
|
}
|
|
|
|
|
|
Widget _buildNewsItem(BuildContext context, WidgetRef ref, Map<String, dynamic> item, vm, int itemIdx){
|
|
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", "");
|
|
String card_title = item.getValue("title", "");
|
|
|
|
+ int card_id = item.getValue("id", null);
|
|
String card_created_at = item.getValue("created_at", "");
|
|
String card_created_at = item.getValue("created_at", "");
|
|
- Map<String, dynamic>? card_account = item.getValue<Map<String,dynamic>>("account", {});
|
|
|
|
|
|
+ Map<String, dynamic>? card_account = item.getValue<Map<String,dynamic>>("account", null);
|
|
String card_avatar = card_account?['avatar']?? "";
|
|
String card_avatar = card_account?['avatar']?? "";
|
|
String card_count_name = card_account?['name']?? "";
|
|
String card_count_name = card_account?['name']?? "";
|
|
bool card_followed = card_account?['followed']??false;
|
|
bool card_followed = card_account?['followed']??false;
|
|
|
|
+ int card_count_id = card_account?['id']?? null;
|
|
String card_content = item.getValue("content", "");
|
|
String card_content = item.getValue("content", "");
|
|
List? card_resources = item.getValue<List>("resources", [])?? [];
|
|
List? card_resources = item.getValue<List>("resources", [])?? [];
|
|
bool card_liked = item.getValue("liked", false);
|
|
bool card_liked = item.getValue("liked", false);
|
|
int card_likes_count = item.getValue("likes_count", 0);
|
|
int card_likes_count = item.getValue("likes_count", 0);
|
|
int card_comments_count = item.getValue("comments_count", 0);
|
|
int card_comments_count = item.getValue("comments_count", 0);
|
|
|
|
+
|
|
return Container(
|
|
return Container(
|
|
margin: const EdgeInsets.only(left: 15, right: 15,top: 14,bottom: 0),
|
|
margin: const EdgeInsets.only(left: 15, right: 15,top: 14,bottom: 0),
|
|
padding: const EdgeInsets.only(left: 15, right: 15,top: 17,bottom: 0),
|
|
padding: const EdgeInsets.only(left: 15, right: 15,top: 17,bottom: 0),
|
|
@@ -176,10 +183,10 @@ class ForyouPage extends HookConsumerWidget {
|
|
),
|
|
),
|
|
// 右上角 关注/取消关注 按钮
|
|
// 右上角 关注/取消关注 按钮
|
|
Visibility(
|
|
Visibility(
|
|
- visible: card_followed ? false: true,
|
|
|
|
|
|
+ visible: card_count_id != null && card_count_id != user_id,
|
|
child: Positioned(
|
|
child: Positioned(
|
|
- right: 10,
|
|
|
|
- top: -5,
|
|
|
|
|
|
+ right: 0,
|
|
|
|
+ top: 0,
|
|
child: Container(
|
|
child: Container(
|
|
width: 83.5,
|
|
width: 83.5,
|
|
height: 45.5,
|
|
height: 45.5,
|
|
@@ -189,16 +196,21 @@ class ForyouPage extends HookConsumerWidget {
|
|
// borderRadius: BorderRadius.circular(5),
|
|
// borderRadius: BorderRadius.circular(5),
|
|
// ),
|
|
// ),
|
|
child: MyButton(
|
|
child: MyButton(
|
|
- text: S.current.to_follow,
|
|
|
|
- textColor: Colors.white,
|
|
|
|
- backgroundColor: context.appColors.textPrimary,
|
|
|
|
|
|
+ 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,
|
|
radius: 8,
|
|
minHeight: 27.5,
|
|
minHeight: 27.5,
|
|
padding: const EdgeInsets.only(left: 5, right: 5,top:9,bottom:9),
|
|
padding: const EdgeInsets.only(left: 5, right: 5,top:9,bottom:9),
|
|
fontWeight: FontWeight.w400,
|
|
fontWeight: FontWeight.w400,
|
|
fontSize: 14,
|
|
fontSize: 14,
|
|
- onPressed: (){
|
|
|
|
- vm.handlerFollow(context, card_followed);
|
|
|
|
|
|
+ onPressed: () async{
|
|
|
|
+ bool asyncResult = await vm.handlerFollow(context,card_count_id, card_id, card_followed );
|
|
|
|
+ // if(asyncResult){
|
|
|
|
+ // // 成功 关注->取消关注 取消关注->关注
|
|
|
|
+ // }
|
|
},
|
|
},
|
|
),
|
|
),
|
|
)
|
|
)
|