feat: follow staff

Closes #481

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-03-23 13:40:41 +08:00
parent 68d11d7638
commit 9d0ac30fad
2 changed files with 77 additions and 0 deletions

View File

@@ -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<Staff>)
.map((item) => item.mid)
.join(',')
},
).then((res) {
if (res.data['code'] == 0) {
staffRelations.value = {
'status': true,
...res.data['data'],
};
}
});
}
try {
final videoDetailController =
Get.find<VideoDetailController>(tag: heroTag);

View File

@@ -473,6 +473,64 @@ class _VideoInfoState extends State<VideoInfo> 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),