merge main
This commit is contained in:
@ -97,8 +97,8 @@ class Api {
|
|||||||
// 操作用户关系
|
// 操作用户关系
|
||||||
static const String relationMod = '/x/relation/modify';
|
static const String relationMod = '/x/relation/modify';
|
||||||
|
|
||||||
// 相互关系查询
|
// 相互关系查询 // 失效
|
||||||
static const String relationSearch = '/x/space/wbi/acc/relation';
|
// static const String relationSearch = '/x/space/wbi/acc/relation';
|
||||||
|
|
||||||
// 评论列表
|
// 评论列表
|
||||||
// https://api.bilibili.com/x/v2/reply/main?csrf=6e22efc1a47225ea25f901f922b5cfdd&mode=3&oid=254175381&pagination_str=%7B%22offset%22:%22%22%7D&plat=1&seek_rpid=0&type=11
|
// https://api.bilibili.com/x/v2/reply/main?csrf=6e22efc1a47225ea25f901f922b5cfdd&mode=3&oid=254175381&pagination_str=%7B%22offset%22:%22%22%7D&plat=1&seek_rpid=0&type=11
|
||||||
|
|||||||
@ -251,29 +251,43 @@ class UserHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 相互关系查询
|
static Future hasFollow(int mid) async {
|
||||||
static Future relationSearch(int mid) async {
|
|
||||||
Map params = await WbiSign().makSign({
|
|
||||||
'mid': mid,
|
|
||||||
'web_location': 333.999,
|
|
||||||
});
|
|
||||||
var res = await Request().get(
|
var res = await Request().get(
|
||||||
Api.relationSearch,
|
Api.hasFollow,
|
||||||
data: {
|
data: {
|
||||||
'mid': mid,
|
'fid': mid,
|
||||||
'w_rid': params['w_rid'],
|
|
||||||
'wts': params['wts'],
|
|
||||||
'web_location': 333.999,
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
// relation 主动状态
|
|
||||||
// 被动状态
|
|
||||||
return {'status': true, 'data': res.data['data']};
|
return {'status': true, 'data': res.data['data']};
|
||||||
} else {
|
} else {
|
||||||
return {'status': false, 'msg': res.data['message']};
|
return {'status': false, 'msg': res.data['message']};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// // 相互关系查询
|
||||||
|
// static Future relationSearch(int mid) async {
|
||||||
|
// Map params = await WbiSign().makSign({
|
||||||
|
// 'mid': mid,
|
||||||
|
// 'token': '',
|
||||||
|
// 'platform': 'web',
|
||||||
|
// 'web_location': 1550101,
|
||||||
|
// });
|
||||||
|
// var res = await Request().get(
|
||||||
|
// Api.relationSearch,
|
||||||
|
// data: {
|
||||||
|
// 'mid': mid,
|
||||||
|
// 'w_rid': params['w_rid'],
|
||||||
|
// 'wts': params['wts'],
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// if (res.data['code'] == 0) {
|
||||||
|
// // relation 主动状态
|
||||||
|
// // 被动状态
|
||||||
|
// return {'status': true, 'data': res.data['data']};
|
||||||
|
// } else {
|
||||||
|
// return {'status': false, 'msg': res.data['message']};
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// 搜索历史记录
|
// 搜索历史记录
|
||||||
static Future searchHistory(
|
static Future searchHistory(
|
||||||
|
|||||||
@ -121,7 +121,14 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
late final BangumiInfoModel? bangumiItem;
|
late final BangumiInfoModel? bangumiItem;
|
||||||
late double sheetHeight;
|
late double sheetHeight;
|
||||||
int? cid;
|
int? cid;
|
||||||
|
bool isProcessing = false;
|
||||||
|
void Function()? handleState(Future Function() action) {
|
||||||
|
return isProcessing ? null : () async {
|
||||||
|
setState(() => isProcessing = true);
|
||||||
|
await action();
|
||||||
|
setState(() => isProcessing = false);
|
||||||
|
};
|
||||||
|
}
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -395,7 +402,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
||||||
onTap: () => bangumiIntroController.actionLikeVideo(),
|
onTap: handleState(bangumiIntroController.actionLikeVideo),
|
||||||
selectStatus: bangumiIntroController.hasLike.value,
|
selectStatus: bangumiIntroController.hasLike.value,
|
||||||
loadingStatus: false,
|
loadingStatus: false,
|
||||||
text: !widget.loadingStatus
|
text: !widget.loadingStatus
|
||||||
@ -406,7 +413,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: () => bangumiIntroController.actionCoinVideo(),
|
onTap: handleState(bangumiIntroController.actionCoinVideo),
|
||||||
selectStatus: bangumiIntroController.hasCoin.value,
|
selectStatus: bangumiIntroController.hasCoin.value,
|
||||||
loadingStatus: false,
|
loadingStatus: false,
|
||||||
text: !widget.loadingStatus
|
text: !widget.loadingStatus
|
||||||
@ -455,7 +462,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
Obx(
|
Obx(
|
||||||
() => ActionRowItem(
|
() => ActionRowItem(
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
onTap: () => videoIntroController.actionLikeVideo(),
|
onTap: handleState(videoIntroController.actionLikeVideo),
|
||||||
selectStatus: videoIntroController.hasLike.value,
|
selectStatus: videoIntroController.hasLike.value,
|
||||||
loadingStatus: widget.loadingStatus,
|
loadingStatus: widget.loadingStatus,
|
||||||
text: !widget.loadingStatus
|
text: !widget.loadingStatus
|
||||||
@ -467,7 +474,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
Obx(
|
Obx(
|
||||||
() => ActionRowItem(
|
() => ActionRowItem(
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: () => videoIntroController.actionCoinVideo(),
|
onTap: handleState(videoIntroController.actionCoinVideo),
|
||||||
selectStatus: videoIntroController.hasCoin.value,
|
selectStatus: videoIntroController.hasCoin.value,
|
||||||
loadingStatus: widget.loadingStatus,
|
loadingStatus: widget.loadingStatus,
|
||||||
text: !widget.loadingStatus
|
text: !widget.loadingStatus
|
||||||
|
|||||||
@ -3,74 +3,56 @@ import 'package:pilipala/models/danmaku/dm.pb.dart';
|
|||||||
import 'package:pilipala/plugin/pl_player/index.dart';
|
import 'package:pilipala/plugin/pl_player/index.dart';
|
||||||
|
|
||||||
class PlDanmakuController {
|
class PlDanmakuController {
|
||||||
PlDanmakuController(this.cid, this.playerController);
|
PlDanmakuController(this.cid);
|
||||||
final int cid;
|
final int cid;
|
||||||
final PlPlayerController playerController;
|
Map<int,List<DanmakuElem>> dmSegMap = {};
|
||||||
late Duration videoDuration;
|
|
||||||
// 按 6min 分段
|
|
||||||
int segCount = 0;
|
|
||||||
List<DmSegMobileReply> dmSegList = [];
|
|
||||||
// 已请求的段落标记
|
// 已请求的段落标记
|
||||||
List<int> hasrequestSeg = [];
|
List<bool> requestedSeg = [];
|
||||||
int currentSegIndex = 1;
|
|
||||||
int currentDmIndex = 0;
|
|
||||||
|
|
||||||
void calcSegment() {
|
bool get initiated => requestedSeg.isNotEmpty;
|
||||||
dmSegList.clear();
|
|
||||||
// 视频分段数
|
static int SEGMENT_LENGTH = 60 * 6 * 1000;
|
||||||
segCount = (videoDuration.inSeconds / (60 * 6)).ceil();
|
|
||||||
dmSegList = List<DmSegMobileReply>.generate(
|
void initiate(int videoDuration, int progress) {
|
||||||
segCount < 1 ? 1 : segCount, (index) => DmSegMobileReply());
|
if (requestedSeg.isEmpty) {
|
||||||
// 当前分段
|
int segCount = (videoDuration / SEGMENT_LENGTH).ceil();
|
||||||
try {
|
requestedSeg = List<bool>.generate(segCount, (index) => false);
|
||||||
currentSegIndex =
|
}
|
||||||
(playerController.position.value.inSeconds / (60 * 6)).ceil();
|
queryDanmaku(
|
||||||
currentSegIndex = currentSegIndex < 1 ? 1 : currentSegIndex;
|
calcSegment(progress)
|
||||||
} catch (_) {}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<DmSegMobileReply>> queryDanmaku() async {
|
void dispose() {
|
||||||
// dmSegList.clear();
|
dmSegMap.clear();
|
||||||
|
requestedSeg.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int calcSegment(int progress) {
|
||||||
|
return progress ~/ SEGMENT_LENGTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
void queryDanmaku(int segmentIndex) async {
|
||||||
|
assert(requestedSeg[segmentIndex] == false);
|
||||||
|
requestedSeg[segmentIndex] = true;
|
||||||
DmSegMobileReply result =
|
DmSegMobileReply result =
|
||||||
await DanmakaHttp.queryDanmaku(cid: cid, segmentIndex: currentSegIndex);
|
await DanmakaHttp.queryDanmaku(cid: cid, segmentIndex: segmentIndex + 1);
|
||||||
if (result.elems.isNotEmpty) {
|
if (result.elems.isNotEmpty) {
|
||||||
result.elems.sort((a, b) => (a.progress).compareTo(b.progress));
|
for (var element in result.elems) {
|
||||||
// dmSegList.add(result);
|
int pos = element.progress ~/ 100;//每0.1秒存储一次
|
||||||
currentSegIndex = currentSegIndex < 1 ? 1 : currentSegIndex;
|
if (dmSegMap[pos] == null) {
|
||||||
dmSegList[currentSegIndex - 1] = result;
|
dmSegMap[pos] = [];
|
||||||
|
}
|
||||||
|
dmSegMap[pos]!.add(element);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (dmSegList.isNotEmpty) {
|
|
||||||
findClosestPositionIndex(playerController.position.value.inMilliseconds);
|
|
||||||
}
|
|
||||||
return dmSegList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 查询当前最接近的弹幕
|
List<DanmakuElem>? getCurrentDanmaku(int progress) {
|
||||||
void findClosestPositionIndex(int position) {
|
int segmentIndex = calcSegment(progress);
|
||||||
int segIndex = (position / (6 * 60 * 1000)).ceil() - 1;
|
if (!requestedSeg[segmentIndex]) {
|
||||||
if (segIndex < 0) segIndex = 0;
|
queryDanmaku(segmentIndex);
|
||||||
List elems = dmSegList[segIndex].elems;
|
|
||||||
|
|
||||||
if (segIndex < dmSegList.length) {
|
|
||||||
int left = 0;
|
|
||||||
int right = elems.length;
|
|
||||||
|
|
||||||
while (left < right) {
|
|
||||||
int mid = (right + left) ~/ 2;
|
|
||||||
var midPosition = elems[mid].progress;
|
|
||||||
|
|
||||||
if (midPosition >= position) {
|
|
||||||
right = mid;
|
|
||||||
} else {
|
|
||||||
left = mid + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
currentSegIndex = segIndex;
|
|
||||||
currentDmIndex = right;
|
|
||||||
} else {
|
|
||||||
currentSegIndex = segIndex;
|
|
||||||
currentDmIndex = 0;
|
|
||||||
}
|
}
|
||||||
|
return dmSegMap[progress ~/ 100];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:ns_danmaku/ns_danmaku.dart';
|
import 'package:ns_danmaku/ns_danmaku.dart';
|
||||||
|
import 'package:pilipala/models/danmaku/dm.pb.dart';
|
||||||
import 'package:pilipala/pages/danmaku/index.dart';
|
import 'package:pilipala/pages/danmaku/index.dart';
|
||||||
import 'package:pilipala/plugin/pl_player/index.dart';
|
import 'package:pilipala/plugin/pl_player/index.dart';
|
||||||
import 'package:pilipala/utils/danmaku.dart';
|
import 'package:pilipala/utils/danmaku.dart';
|
||||||
@ -27,7 +28,7 @@ class _PlDanmakuState extends State<PlDanmaku> {
|
|||||||
late PlPlayerController playerController;
|
late PlPlayerController playerController;
|
||||||
late PlDanmakuController _plDanmakuController;
|
late PlDanmakuController _plDanmakuController;
|
||||||
DanmakuController? _controller;
|
DanmakuController? _controller;
|
||||||
bool danmuPlayStatus = true;
|
// bool danmuPlayStatus = true;
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
late bool enableShowDanmaku;
|
late bool enableShowDanmaku;
|
||||||
late List blockTypes;
|
late List blockTypes;
|
||||||
@ -35,6 +36,7 @@ class _PlDanmakuState extends State<PlDanmaku> {
|
|||||||
late double opacityVal;
|
late double opacityVal;
|
||||||
late double fontSizeVal;
|
late double fontSizeVal;
|
||||||
late double danmakuDurationVal;
|
late double danmakuDurationVal;
|
||||||
|
int latestAddedPosition = -1;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -42,26 +44,25 @@ class _PlDanmakuState extends State<PlDanmaku> {
|
|||||||
enableShowDanmaku =
|
enableShowDanmaku =
|
||||||
setting.get(SettingBoxKey.enableShowDanmaku, defaultValue: false);
|
setting.get(SettingBoxKey.enableShowDanmaku, defaultValue: false);
|
||||||
_plDanmakuController =
|
_plDanmakuController =
|
||||||
PlDanmakuController(widget.cid, widget.playerController);
|
PlDanmakuController(widget.cid);
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
playerController = widget.playerController;
|
playerController = widget.playerController;
|
||||||
_plDanmakuController.videoDuration = playerController.duration.value;
|
|
||||||
if (enableShowDanmaku || playerController.isOpenDanmu.value) {
|
if (enableShowDanmaku || playerController.isOpenDanmu.value) {
|
||||||
_plDanmakuController
|
_plDanmakuController.initiate(
|
||||||
..calcSegment()
|
playerController.duration.value.inMilliseconds,
|
||||||
..queryDanmaku();
|
playerController.position.value.inMilliseconds
|
||||||
|
);
|
||||||
}
|
}
|
||||||
playerController
|
playerController
|
||||||
..addStatusLister(playerListener)
|
..addStatusLister(playerListener)
|
||||||
..addPositionListener(videoPositionListen);
|
..addPositionListener(videoPositionListen);
|
||||||
}
|
}
|
||||||
playerController.isOpenDanmu.listen((p0) {
|
playerController.isOpenDanmu.listen((p0) {
|
||||||
if (p0) {
|
if (p0 && !_plDanmakuController.initiated) {
|
||||||
if (_plDanmakuController.dmSegList.isEmpty) {
|
_plDanmakuController.initiate(
|
||||||
_plDanmakuController
|
playerController.duration.value.inMilliseconds,
|
||||||
..calcSegment()
|
playerController.position.value.inMilliseconds
|
||||||
..queryDanmaku();
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
blockTypes = playerController.blockTypes;
|
blockTypes = playerController.blockTypes;
|
||||||
@ -82,68 +83,32 @@ class _PlDanmakuState extends State<PlDanmaku> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void videoPositionListen(Duration position) {
|
void videoPositionListen(Duration position) {
|
||||||
if (!danmuPlayStatus) {
|
|
||||||
_controller!.onResume();
|
|
||||||
danmuPlayStatus = true;
|
|
||||||
}
|
|
||||||
if (!playerController.isOpenDanmu.value) {
|
if (!playerController.isOpenDanmu.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlDanmakuController ctr = _plDanmakuController;
|
|
||||||
int currentPosition = position.inMilliseconds;
|
int currentPosition = position.inMilliseconds;
|
||||||
blockTypes = playerController.blockTypes;
|
currentPosition -= currentPosition % 100;//取整百的毫秒数
|
||||||
// 根据position判断是否有已缓存弹幕。没有则请求对应段
|
|
||||||
int segIndex = (currentPosition / (6 * 60 * 1000)).ceil();
|
|
||||||
segIndex = segIndex < 1 ? 1 : segIndex;
|
|
||||||
// print('🌹🌹: ${segIndex}');
|
|
||||||
// print('🌹🌹: ${ctr.dmSegList.length}');
|
|
||||||
// print('🌹🌹: ${ctr.hasrequestSeg.contains(segIndex - 1)}');
|
|
||||||
if (segIndex - 1 >= ctr.dmSegList.length ||
|
|
||||||
(ctr.dmSegList[segIndex - 1].elems.isEmpty &&
|
|
||||||
!ctr.hasrequestSeg.contains(segIndex - 1))) {
|
|
||||||
ctr.hasrequestSeg.add(segIndex - 1);
|
|
||||||
ctr.currentSegIndex = segIndex;
|
|
||||||
EasyThrottle.throttle('follow', const Duration(seconds: 1), () {
|
|
||||||
ctr.queryDanmaku();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// 超出分段数返回
|
|
||||||
if (ctr.currentSegIndex >= ctr.dmSegList.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ctr.dmSegList.isEmpty ||
|
|
||||||
ctr.dmSegList[ctr.currentSegIndex].elems.isEmpty) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 超出当前分段的弹幕总数返回
|
|
||||||
if (ctr.currentDmIndex >= ctr.dmSegList[ctr.currentSegIndex].elems.length) {
|
|
||||||
ctr.currentDmIndex = 0;
|
|
||||||
ctr.currentSegIndex++;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var element = ctr.dmSegList[ctr.currentSegIndex].elems[ctr.currentDmIndex];
|
|
||||||
var delta = currentPosition - element.progress;
|
|
||||||
|
|
||||||
if (delta >= 0 && delta < 200) {
|
if (currentPosition == latestAddedPosition) {
|
||||||
// 屏蔽彩色弹幕
|
return;
|
||||||
if (blockTypes.contains(6) ? element.color == 16777215 : true) {
|
}
|
||||||
_controller!.addItems([
|
latestAddedPosition = currentPosition;
|
||||||
DanmakuItem(
|
|
||||||
element.content,
|
List<DanmakuElem>? currentDanmakuList =
|
||||||
color: DmUtils.decimalToColor(element.color),
|
_plDanmakuController.getCurrentDanmaku(currentPosition);
|
||||||
time: element.progress,
|
|
||||||
type: DmUtils.getPosition(element.mode),
|
if (currentDanmakuList != null) {
|
||||||
)
|
Color? defaultColor = playerController.blockTypes.contains(6) ?
|
||||||
]);
|
DmUtils.decimalToColor(16777215) : null;
|
||||||
}
|
|
||||||
ctr.currentDmIndex++;
|
_controller!.addItems(
|
||||||
} else {
|
currentDanmakuList.map((e) => DanmakuItem(
|
||||||
if (!playerController.isOpenDanmu.value) {
|
e.content,
|
||||||
_controller!.pause();
|
color: defaultColor ?? DmUtils.decimalToColor(e.color),
|
||||||
danmuPlayStatus = false;
|
time: e.progress,
|
||||||
return;
|
type: DmUtils.getPosition(e.mode),
|
||||||
}
|
)).toList()
|
||||||
ctr.findClosestPositionIndex(position.inMilliseconds);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,14 @@ class ActionPanel extends StatefulWidget {
|
|||||||
class _ActionPanelState extends State<ActionPanel> {
|
class _ActionPanelState extends State<ActionPanel> {
|
||||||
final DynamicsController _dynamicsController = Get.put(DynamicsController());
|
final DynamicsController _dynamicsController = Get.put(DynamicsController());
|
||||||
late ModuleStatModel stat;
|
late ModuleStatModel stat;
|
||||||
|
bool isProcessing = false;
|
||||||
|
void Function()? handleState(Future Function() action) {
|
||||||
|
return isProcessing ? null : () async {
|
||||||
|
setState(() => isProcessing = true);
|
||||||
|
await action();
|
||||||
|
setState(() => isProcessing = false);
|
||||||
|
};
|
||||||
|
}
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -31,7 +38,7 @@ class _ActionPanelState extends State<ActionPanel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 动态点赞
|
// 动态点赞
|
||||||
onLikeDynamic() async {
|
Future onLikeDynamic() async {
|
||||||
feedBack();
|
feedBack();
|
||||||
var item = widget.item!;
|
var item = widget.item!;
|
||||||
String dynamicId = item.idStr!;
|
String dynamicId = item.idStr!;
|
||||||
@ -101,7 +108,7 @@ class _ActionPanelState extends State<ActionPanel> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: TextButton.icon(
|
child: TextButton.icon(
|
||||||
onPressed: () => onLikeDynamic(),
|
onPressed: handleState(onLikeDynamic),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
stat.like!.status!
|
stat.like!.status!
|
||||||
? FontAwesomeIcons.solidThumbsUp
|
? FontAwesomeIcons.solidThumbsUp
|
||||||
|
|||||||
@ -116,16 +116,28 @@ class MemberController extends GetxController {
|
|||||||
Future relationSearch() async {
|
Future relationSearch() async {
|
||||||
if (userInfo == null) return;
|
if (userInfo == null) return;
|
||||||
if (mid == ownerMid) return;
|
if (mid == ownerMid) return;
|
||||||
var res = await UserHttp.relationSearch(mid);
|
var res = await UserHttp.hasFollow(mid);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
attribute.value = res['data']['relation']['attribute'];
|
attribute.value = res['data']['attribute'];
|
||||||
attributeText.value = attribute.value == 0
|
switch (attribute.value) {
|
||||||
? '关注'
|
case 1:
|
||||||
: attribute.value == 2
|
attributeText.value = '悄悄关注';
|
||||||
? '已关注'
|
break;
|
||||||
: attribute.value == 6
|
case 2:
|
||||||
? '已互粉'
|
attributeText.value = '已关注';
|
||||||
: '已拉黑';
|
break;
|
||||||
|
case 6:
|
||||||
|
attributeText.value = '已互关';
|
||||||
|
break;
|
||||||
|
case 128:
|
||||||
|
attributeText.value = '已拉黑';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
attributeText.value = '关注';
|
||||||
|
}
|
||||||
|
if (res['data']['special'] == 1) {
|
||||||
|
attributeText.value += 'SP';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@ -134,7 +136,14 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
late int mid;
|
late int mid;
|
||||||
late String memberHeroTag;
|
late String memberHeroTag;
|
||||||
late bool enableAi;
|
late bool enableAi;
|
||||||
|
bool isProcessing = false;
|
||||||
|
void Function()? handleState(Future Function() action) {
|
||||||
|
return isProcessing ? null : () async {
|
||||||
|
setState(() => isProcessing = true);
|
||||||
|
await action();
|
||||||
|
setState(() => isProcessing = false);
|
||||||
|
};
|
||||||
|
}
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -477,7 +486,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
||||||
onTap: () => videoIntroController.actionLikeVideo(),
|
onTap: handleState(videoIntroController.actionLikeVideo),
|
||||||
selectStatus: videoIntroController.hasLike.value,
|
selectStatus: videoIntroController.hasLike.value,
|
||||||
loadingStatus: loadingStatus,
|
loadingStatus: loadingStatus,
|
||||||
text: !loadingStatus
|
text: !loadingStatus
|
||||||
@ -494,7 +503,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: () => videoIntroController.actionCoinVideo(),
|
onTap: handleState(videoIntroController.actionCoinVideo),
|
||||||
selectStatus: videoIntroController.hasCoin.value,
|
selectStatus: videoIntroController.hasCoin.value,
|
||||||
loadingStatus: loadingStatus,
|
loadingStatus: loadingStatus,
|
||||||
text: !loadingStatus
|
text: !loadingStatus
|
||||||
@ -538,7 +547,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
Obx(
|
Obx(
|
||||||
() => ActionRowItem(
|
() => ActionRowItem(
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
onTap: () => videoIntroController.actionLikeVideo(),
|
onTap: handleState(videoIntroController.actionLikeVideo),
|
||||||
selectStatus: videoIntroController.hasLike.value,
|
selectStatus: videoIntroController.hasLike.value,
|
||||||
loadingStatus: loadingStatus,
|
loadingStatus: loadingStatus,
|
||||||
text:
|
text:
|
||||||
@ -549,7 +558,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
Obx(
|
Obx(
|
||||||
() => ActionRowItem(
|
() => ActionRowItem(
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: () => videoIntroController.actionCoinVideo(),
|
onTap: handleState(videoIntroController.actionCoinVideo),
|
||||||
selectStatus: videoIntroController.hasCoin.value,
|
selectStatus: videoIntroController.hasCoin.value,
|
||||||
loadingStatus: loadingStatus,
|
loadingStatus: loadingStatus,
|
||||||
text:
|
text:
|
||||||
|
|||||||
@ -22,9 +22,9 @@ class ZanButton extends StatefulWidget {
|
|||||||
|
|
||||||
class _ZanButtonState extends State<ZanButton> {
|
class _ZanButtonState extends State<ZanButton> {
|
||||||
// 评论点赞
|
// 评论点赞
|
||||||
onLikeReply() async {
|
Future onLikeReply() async {
|
||||||
feedBack();
|
feedBack();
|
||||||
SmartDialog.showLoading(msg: 'pilipala ...');
|
// SmartDialog.showLoading(msg: 'pilipala ...');
|
||||||
ReplyItemModel replyItem = widget.replyItem!;
|
ReplyItemModel replyItem = widget.replyItem!;
|
||||||
int oid = replyItem.oid!;
|
int oid = replyItem.oid!;
|
||||||
int rpid = replyItem.rpid!;
|
int rpid = replyItem.rpid!;
|
||||||
@ -32,7 +32,7 @@ class _ZanButtonState extends State<ZanButton> {
|
|||||||
int action = replyItem.action == 0 ? 1 : 0;
|
int action = replyItem.action == 0 ? 1 : 0;
|
||||||
var res = await ReplyHttp.likeReply(
|
var res = await ReplyHttp.likeReply(
|
||||||
type: widget.replyType!.index, oid: oid, rpid: rpid, action: action);
|
type: widget.replyType!.index, oid: oid, rpid: rpid, action: action);
|
||||||
SmartDialog.dismiss();
|
// SmartDialog.dismiss();
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
SmartDialog.showToast(replyItem.action == 0 ? '点赞成功 👍' : '取消赞 💔');
|
SmartDialog.showToast(replyItem.action == 0 ? '点赞成功 👍' : '取消赞 💔');
|
||||||
if (action == 1) {
|
if (action == 1) {
|
||||||
@ -47,6 +47,14 @@ class _ZanButtonState extends State<ZanButton> {
|
|||||||
SmartDialog.showToast(res['msg']);
|
SmartDialog.showToast(res['msg']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool isProcessing = false;
|
||||||
|
void Function()? handleState(Future Function() action) {
|
||||||
|
return isProcessing ? null : () async {
|
||||||
|
setState(() => isProcessing = true);
|
||||||
|
await action();
|
||||||
|
setState(() => isProcessing = false);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -55,6 +63,7 @@ class _ZanButtonState extends State<ZanButton> {
|
|||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: 32,
|
height: 32,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
|
onPressed: handleState(onLikeReply),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
@ -79,7 +88,6 @@ class _ZanButtonState extends State<ZanButton> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
onPressed: () => onLikeReply(),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -237,17 +237,17 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
final double pinnedHeaderHeight =
|
final double pinnedHeaderHeight =
|
||||||
statusBarHeight + kToolbarHeight + videoHeight;
|
statusBarHeight + kToolbarHeight + videoHeight;
|
||||||
if (MediaQuery.of(context).orientation == Orientation.landscape ||
|
if (MediaQuery.of(context).orientation == Orientation.landscape ||
|
||||||
plPlayerController!.isFullScreen.value) {
|
plPlayerController?.isFullScreen.value == true) {
|
||||||
enterFullScreen();
|
enterFullScreen();
|
||||||
} else {
|
} else {
|
||||||
exitFullScreen();
|
exitFullScreen();
|
||||||
}
|
}
|
||||||
Widget childWhenDisabled = SafeArea(
|
Widget childWhenDisabled = SafeArea(
|
||||||
top: MediaQuery.of(context).orientation == Orientation.portrait,
|
top: MediaQuery.of(context).orientation == Orientation.portrait,
|
||||||
bottom: MediaQuery.of(context).orientation == Orientation.portrait
|
bottom: MediaQuery.of(context).orientation == Orientation.portrait &&
|
||||||
&& plPlayerController!.isFullScreen.value,
|
plPlayerController?.isFullScreen.value == true,
|
||||||
left: !plPlayerController!.isFullScreen.value,
|
left: plPlayerController?.isFullScreen.value != true,
|
||||||
right: !plPlayerController!.isFullScreen.value,
|
right: plPlayerController?.isFullScreen.value != true,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Scaffold(
|
Scaffold(
|
||||||
@ -259,169 +259,168 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
headerSliverBuilder:
|
headerSliverBuilder:
|
||||||
(BuildContext context, bool innerBoxIsScrolled) {
|
(BuildContext context, bool innerBoxIsScrolled) {
|
||||||
return <Widget>[
|
return <Widget>[
|
||||||
Obx(() => PopScope(
|
SliverAppBar(
|
||||||
canPop: !plPlayerController!.isFullScreen.value,
|
automaticallyImplyLeading: false,
|
||||||
onPopInvoked: (bool didPop) {
|
pinned: false,
|
||||||
if (plPlayerController!.isFullScreen.value) {
|
elevation: 0,
|
||||||
plPlayerController!
|
scrolledUnderElevation: 0,
|
||||||
.triggerFullScreen(status: false);
|
forceElevated: innerBoxIsScrolled,
|
||||||
}
|
expandedHeight:
|
||||||
if (MediaQuery.of(context).orientation ==
|
plPlayerController?.isFullScreen.value == true ||
|
||||||
Orientation.landscape) {
|
MediaQuery.of(context).orientation ==
|
||||||
verticalScreen();
|
Orientation.landscape
|
||||||
}
|
? MediaQuery.of(context).size.height -
|
||||||
},
|
(MediaQuery.of(context).orientation ==
|
||||||
child: SliverAppBar(
|
Orientation.landscape
|
||||||
automaticallyImplyLeading: false,
|
? 0
|
||||||
pinned: false,
|
: statusBarHeight)
|
||||||
elevation: 0,
|
: videoHeight,
|
||||||
scrolledUnderElevation: 0,
|
backgroundColor: Colors.black,
|
||||||
forceElevated: innerBoxIsScrolled,
|
flexibleSpace: FlexibleSpaceBar(
|
||||||
expandedHeight:
|
background: PopScope(
|
||||||
plPlayerController!.isFullScreen.value ||
|
canPop:
|
||||||
MediaQuery.of(context).orientation ==
|
plPlayerController?.isFullScreen.value != true,
|
||||||
Orientation.landscape
|
onPopInvoked: (bool didPop) {
|
||||||
? MediaQuery.of(context).size.height -
|
if (plPlayerController?.isFullScreen.value ==
|
||||||
(MediaQuery.of(context).orientation ==
|
true) {
|
||||||
Orientation.landscape
|
plPlayerController!
|
||||||
? 0
|
.triggerFullScreen(status: false);
|
||||||
: statusBarHeight)
|
}
|
||||||
: videoHeight,
|
if (MediaQuery.of(context).orientation ==
|
||||||
backgroundColor: Colors.black,
|
Orientation.landscape) {
|
||||||
flexibleSpace: FlexibleSpaceBar(
|
verticalScreen();
|
||||||
background: LayoutBuilder(
|
}
|
||||||
builder: (context, boxConstraints) {
|
},
|
||||||
double maxWidth = boxConstraints.maxWidth;
|
child: LayoutBuilder(
|
||||||
double maxHeight = boxConstraints.maxHeight;
|
builder: (context, boxConstraints) {
|
||||||
return Stack(
|
double maxWidth = boxConstraints.maxWidth;
|
||||||
children: [
|
double maxHeight = boxConstraints.maxHeight;
|
||||||
FutureBuilder(
|
return Stack(
|
||||||
future: _futureBuilderFuture,
|
children: [
|
||||||
builder: ((context, snapshot) {
|
FutureBuilder(
|
||||||
if (snapshot.hasData &&
|
future: _futureBuilderFuture,
|
||||||
snapshot.data['status']) {
|
builder: ((context, snapshot) {
|
||||||
return Obx(
|
if (snapshot.hasData &&
|
||||||
() => !videoDetailController
|
snapshot.data['status']) {
|
||||||
.autoPlay.value
|
return Obx(
|
||||||
? const SizedBox()
|
() => !videoDetailController
|
||||||
: PLVideoPlayer(
|
.autoPlay.value
|
||||||
controller:
|
? const SizedBox()
|
||||||
plPlayerController!,
|
: PLVideoPlayer(
|
||||||
headerControl:
|
controller:
|
||||||
videoDetailController
|
plPlayerController!,
|
||||||
.headerControl,
|
headerControl:
|
||||||
danmuWidget: Obx(
|
videoDetailController
|
||||||
() => PlDanmaku(
|
.headerControl,
|
||||||
key: Key(
|
danmuWidget: Obx(
|
||||||
videoDetailController
|
() => PlDanmaku(
|
||||||
.danmakuCid
|
key: Key(
|
||||||
.value
|
videoDetailController
|
||||||
.toString()),
|
.danmakuCid
|
||||||
cid:
|
.value
|
||||||
videoDetailController
|
.toString()),
|
||||||
.danmakuCid
|
cid:
|
||||||
.value,
|
videoDetailController
|
||||||
playerController:
|
.danmakuCid
|
||||||
plPlayerController!,
|
.value,
|
||||||
),
|
playerController:
|
||||||
|
plPlayerController!,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
} else {
|
);
|
||||||
return const SizedBox();
|
} else {
|
||||||
}
|
return const SizedBox();
|
||||||
}),
|
}
|
||||||
),
|
}),
|
||||||
|
),
|
||||||
|
|
||||||
Obx(
|
Obx(
|
||||||
() => Visibility(
|
() => Visibility(
|
||||||
visible: videoDetailController
|
visible: videoDetailController
|
||||||
.isShowCover.value,
|
.isShowCover.value,
|
||||||
child: Positioned(
|
child: Positioned(
|
||||||
top: 0,
|
top: 0,
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
child: NetworkImgLayer(
|
child: NetworkImgLayer(
|
||||||
type: 'emote',
|
type: 'emote',
|
||||||
src: videoDetailController
|
src: videoDetailController
|
||||||
.videoItem['pic'],
|
.videoItem['pic'],
|
||||||
width: maxWidth,
|
width: maxWidth,
|
||||||
height: maxHeight,
|
height: maxHeight,
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
/// 关闭自动播放时 手动播放
|
/// 关闭自动播放时 手动播放
|
||||||
Obx(
|
Obx(
|
||||||
() => Visibility(
|
() => Visibility(
|
||||||
visible: videoDetailController
|
visible: videoDetailController
|
||||||
.isShowCover.value &&
|
.isShowCover.value &&
|
||||||
videoDetailController
|
videoDetailController
|
||||||
.isEffective.value &&
|
.isEffective.value &&
|
||||||
!videoDetailController
|
!videoDetailController
|
||||||
.autoPlay.value,
|
.autoPlay.value,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 0,
|
top: 0,
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
child: AppBar(
|
child: AppBar(
|
||||||
primary: false,
|
primary: false,
|
||||||
foregroundColor:
|
foregroundColor: Colors.white,
|
||||||
Colors.white,
|
backgroundColor:
|
||||||
|
Colors.transparent,
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
tooltip: '稍后再看',
|
||||||
|
onPressed: () async {
|
||||||
|
var res = await UserHttp
|
||||||
|
.toViewLater(
|
||||||
|
bvid:
|
||||||
|
videoDetailController
|
||||||
|
.bvid);
|
||||||
|
SmartDialog.showToast(
|
||||||
|
res['msg']);
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons
|
||||||
|
.history_outlined),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 14)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
right: 12,
|
||||||
|
bottom: 10,
|
||||||
|
child: TextButton.icon(
|
||||||
|
style: ButtonStyle(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
Colors.transparent,
|
MaterialStateProperty
|
||||||
actions: [
|
.resolveWith(
|
||||||
IconButton(
|
(states) {
|
||||||
tooltip: '稍后再看',
|
return Theme.of(context)
|
||||||
onPressed: () async {
|
.colorScheme
|
||||||
var res = await UserHttp
|
.primaryContainer;
|
||||||
.toViewLater(
|
}),
|
||||||
bvid:
|
|
||||||
videoDetailController
|
|
||||||
.bvid);
|
|
||||||
SmartDialog.showToast(
|
|
||||||
res['msg']);
|
|
||||||
},
|
|
||||||
icon: const Icon(Icons
|
|
||||||
.history_outlined),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 14)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
onPressed: () => handlePlay(),
|
||||||
Positioned(
|
icon: const Icon(
|
||||||
right: 12,
|
Icons.play_circle_outline,
|
||||||
bottom: 10,
|
size: 20,
|
||||||
child: TextButton.icon(
|
|
||||||
style: ButtonStyle(
|
|
||||||
backgroundColor:
|
|
||||||
MaterialStateProperty
|
|
||||||
.resolveWith(
|
|
||||||
(states) {
|
|
||||||
return Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.primaryContainer;
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
onPressed: () =>
|
|
||||||
handlePlay(),
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.play_circle_outline,
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
label: const Text('Play'),
|
|
||||||
),
|
),
|
||||||
|
label: const Text('Play'),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
)),
|
],
|
||||||
),
|
)),
|
||||||
],
|
),
|
||||||
);
|
],
|
||||||
},
|
);
|
||||||
),
|
},
|
||||||
)),
|
)),
|
||||||
)),
|
)),
|
||||||
];
|
];
|
||||||
@ -433,8 +432,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
// },
|
// },
|
||||||
/// 不收回
|
/// 不收回
|
||||||
pinnedHeaderSliverHeightBuilder: () {
|
pinnedHeaderSliverHeightBuilder: () {
|
||||||
return plPlayerController!.isFullScreen.value ?
|
return plPlayerController?.isFullScreen.value == true
|
||||||
MediaQuery.of(context).size.height: pinnedHeaderHeight;
|
? MediaQuery.of(context).size.height
|
||||||
|
: pinnedHeaderHeight;
|
||||||
},
|
},
|
||||||
onlyOneScrollInBody: true,
|
onlyOneScrollInBody: true,
|
||||||
body: Container(
|
body: Container(
|
||||||
|
|||||||
Reference in New Issue
Block a user