diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index fb34f970..7bdafabd 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:PiliPlus/http/init.dart'; import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/member.dart'; import 'package:PiliPlus/pages/dynamics/repost_dyn_panel.dart'; @@ -38,6 +39,7 @@ class VideoIntroController extends GetxController // 视频详情 上个页面传入 Map videoItem = {}; + late final RxMap staffRelations = {}.obs; // 请求状态 RxBool isLoading = false.obs; @@ -148,6 +150,23 @@ class VideoIntroController extends GetxController } videoDetail.value = result['data']; videoItem['staff'] = result['data'].staff; + if (result['data'].staff?.isNotEmpty == true) { + Request().get( + '/x/relation/relations', + queryParameters: { + 'fids': (result['data'].staff as List) + .map((item) => item.mid) + .join(',') + }, + ).then((res) { + if (res.data['code'] == 0) { + staffRelations.value = { + 'status': true, + ...res.data['data'], + }; + } + }); + } try { final videoDetailController = Get.find(tag: heroTag); diff --git a/lib/pages/video/detail/introduction/view.dart b/lib/pages/video/detail/introduction/view.dart index 69b628b1..89e01e03 100644 --- a/lib/pages/video/detail/introduction/view.dart +++ b/lib/pages/video/detail/introduction/view.dart @@ -473,6 +473,64 @@ class _VideoInfoState extends State with TickerProviderStateMixin { ), ), ), + Positioned( + top: 0, + right: -6, + child: Obx(() => videoIntroController + .staffRelations[ + 'status'] == + true && + videoIntroController + .staffRelations[ + '${videoItem['staff'][index].mid}'] == + null + ? Material( + color: Colors.transparent, + child: InkWell( + customBorder: + const CircleBorder(), + onTap: () { + Utils + .actionRelationMod( + context: context, + mid: videoItem[ + 'staff'] + [index] + .mid, + isFollow: false, + callback: (val) { + videoIntroController + .staffRelations[ + '${videoItem['staff'][index].mid}'] = true; + }, + ); + }, + child: Ink( + padding: + const EdgeInsets + .all(2), + decoration: + BoxDecoration( + color: Theme.of( + context) + .colorScheme + .secondaryContainer, + shape: + BoxShape.circle, + ), + child: Icon( + MdiIcons.plus, + size: 16, + color: Theme.of( + context) + .colorScheme + .onSecondaryContainer, + ), + ), + ), + ) + : const SizedBox.shrink()), + ), ], ), const SizedBox(width: 8),