Merge branch 'fix'

This commit is contained in:
guozhigq
2024-11-02 23:42:57 +08:00
2 changed files with 38 additions and 92 deletions

View File

@ -235,32 +235,33 @@ class ReplyItem extends StatelessWidget {
// title // title
Container( Container(
margin: const EdgeInsets.only(top: 10, left: 45, right: 6, bottom: 4), margin: const EdgeInsets.only(top: 10, left: 45, right: 6, bottom: 4),
child: !replySave child: Text.rich(
? LayoutBuilder(builder: overflow: TextOverflow.ellipsis,
(BuildContext context, BoxConstraints boxConstraints) { maxLines:
String text = replyItem?.content?.message ?? ''; replyLevel == '1' && replyItem!.content!.isText! ? 5 : 999,
bool didExceedMaxLines = false; style: const TextStyle(height: 1.75),
final double maxWidth = boxConstraints.maxWidth; TextSpan(
TextPainter? textPainter; children: [
final int maxLines = if (replyItem!.isTop!)
replyItem!.content!.isText! && replyLevel == '1' const WidgetSpan(
? 6 alignment: PlaceholderAlignment.top,
: 999; child: PBadge(
try { text: 'TOP',
textPainter = TextPainter( size: 'small',
text: TextSpan(text: text), stack: 'normal',
maxLines: maxLines, type: 'line',
textDirection: Directionality.of(context), fs: 9,
); ),
textPainter.layout(maxWidth: maxWidth); ),
didExceedMaxLines = textPainter.didExceedMaxLines; buildContent(
} catch (e) { context,
debugPrint('Error while measuring text: $e'); replyItem!,
didExceedMaxLines = false; replyReply,
} null,
return replyContent(context, didExceedMaxLines, textPainter); ),
}) ],
: replyContent(context, false, null), ),
),
), ),
// 操作区域 // 操作区域
bottonAction(context, replyItem!.replyControl, replySave), bottonAction(context, replyItem!.replyControl, replySave),
@ -281,36 +282,6 @@ class ReplyItem extends StatelessWidget {
); );
} }
Widget replyContent(
BuildContext context, bool? didExceedMaxLines, TextPainter? textPainter) {
return Text.rich(
style: const TextStyle(height: 1.75),
TextSpan(
children: [
if (replyItem!.isTop!)
const WidgetSpan(
alignment: PlaceholderAlignment.top,
child: PBadge(
text: 'TOP',
size: 'small',
stack: 'normal',
type: 'line',
fs: 9,
),
),
buildContent(
context,
replyItem!,
replyReply,
null,
didExceedMaxLines ?? false,
textPainter,
),
],
),
);
}
// 感谢、回复、复制 // 感谢、回复、复制
Widget bottonAction(BuildContext context, replyControl, replySave) { Widget bottonAction(BuildContext context, replyControl, replySave) {
ColorScheme colorScheme = Theme.of(context).colorScheme; ColorScheme colorScheme = Theme.of(context).colorScheme;
@ -493,8 +464,12 @@ class ReplyItemRow extends StatelessWidget {
fs: 9, fs: 9,
), ),
), ),
buildContent(context, replies![i], replyReply, buildContent(
replyItem, false, null), context,
replies![i],
replyReply,
replyItem,
),
], ],
), ),
), ),
@ -540,8 +515,6 @@ InlineSpan buildContent(
replyItem, replyItem,
replyReply, replyReply,
fReplyItem, fReplyItem,
bool didExceedMaxLines,
TextPainter? textPainter,
) { ) {
final String routePath = Get.currentRoute; final String routePath = Get.currentRoute;
bool isVideoPage = routePath.startsWith('/video'); bool isVideoPage = routePath.startsWith('/video');
@ -553,25 +526,6 @@ InlineSpan buildContent(
final content = replyItem.content; final content = replyItem.content;
final List<InlineSpan> spanChilds = <InlineSpan>[]; final List<InlineSpan> spanChilds = <InlineSpan>[];
if (didExceedMaxLines && content.message != '') {
final textSize = textPainter!.size;
var position = textPainter.getPositionForOffset(
Offset(
textSize.width,
textSize.height,
),
);
final endOffset = textPainter.getOffsetBefore(position.offset);
if (endOffset != null && endOffset > 0) {
content.message = content.message.substring(0, endOffset);
} else {
content.message = content.message.substring(0, position.offset);
}
} else {
content.message = content.message2;
}
// 投票 // 投票
if (content.vote.isNotEmpty) { if (content.vote.isNotEmpty) {
content.message.splitMapJoin(RegExp(r"\{vote:.*?\}"), content.message.splitMapJoin(RegExp(r"\{vote:.*?\}"),
@ -921,17 +875,6 @@ InlineSpan buildContent(
} }
} }
if (didExceedMaxLines) {
spanChilds.add(
TextSpan(
text: '\n查看更多',
style: TextStyle(
color: colorScheme.primary,
),
),
);
}
// 图片渲染 // 图片渲染
if (content.pictures.isNotEmpty) { if (content.pictures.isNotEmpty) {
final List<String> picList = <String>[]; final List<String> picList = <String>[];

View File

@ -101,7 +101,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
videoSourceInit(); videoSourceInit();
appbarStreamListen(); appbarStreamListen();
fullScreenStatusListener(); if (autoPlayEnable) {
fullScreenStatusListener();
}
if (Platform.isAndroid) { if (Platform.isAndroid) {
floating = vdCtr.floating!; floating = vdCtr.floating!;
} }
@ -137,7 +139,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
autoEnterPip(status: status); autoEnterPip(status: status);
if (status == PlayerStatus.completed) { if (status == PlayerStatus.completed) {
// 结束播放退出全屏 // 结束播放退出全屏
if (autoExitFullcreen) { if (autoExitFullcreen && plPlayerController!.isFullScreen.value) {
plPlayerController!.triggerFullScreen(status: false); plPlayerController!.triggerFullScreen(status: false);
} }
shutdownTimerService.handleWaitingFinished(); shutdownTimerService.handleWaitingFinished();
@ -184,6 +186,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
await vdCtr.playerInit(autoplay: true); await vdCtr.playerInit(autoplay: true);
plPlayerController = vdCtr.plPlayerController; plPlayerController = vdCtr.plPlayerController;
plPlayerController!.addStatusLister(playerListener); plPlayerController!.addStatusLister(playerListener);
fullScreenStatusListener();
vdCtr.autoPlay.value = true; vdCtr.autoPlay.value = true;
vdCtr.isShowCover.value = false; vdCtr.isShowCover.value = false;
isShowing.value = true; isShowing.value = true;