Skip to content

Commit

Permalink
mod: 视频介绍部分重构
Browse files Browse the repository at this point in the history
  • Loading branch information
orz12 committed Nov 8, 2024
1 parent 2f91eaf commit 659455e
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 197 deletions.
207 changes: 106 additions & 101 deletions lib/pages/video/introduction/detail/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,19 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
}

// 视频介绍
showIntroDetail() {
if (loadingStatus) {
return;
}
feedBack();
showBottomSheet(
context: context,
enableDrag: true,
builder: (BuildContext context) {
return IntroDetail(videoDetail: widget.videoDetail!);
},
);
}
// showIntroDetail() {
// if (loadingStatus) {
// return;
// }
// feedBack();
// showBottomSheet(
// context: context,
// enableDrag: true,
// builder: (BuildContext context) {
// return IntroDetail(videoDetail: widget.videoDetail!);
// },
// );
// }

// 用户主页
onPushMember() {
Expand Down Expand Up @@ -217,6 +217,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
builder: (BuildContext context, SliverConstraints constraints) {
bool isHorizontal = constraints.crossAxisExtent >
constraints.viewportMainAxisExtent * 1.25;
bool isExpanded = isHorizontal;
return SliverPadding(
padding: const EdgeInsets.only(
left: StyleString.safeSpace,
Expand Down Expand Up @@ -285,13 +286,25 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
Expanded(child: actionGrid(context, videoIntroController)),
]
]),
const SizedBox(height: 8),
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () => showIntroDetail(),
child: Row(children: [
Expanded(
child: Text(
ListTileTheme(
key: const PageStorageKey<String>('视频信息'),
contentPadding: EdgeInsets.zero,
dense: true,
horizontalTitleGap: 0.0,
minLeadingWidth: 0,
minVerticalPadding: 0,
child: ExpansionTile(
initiallyExpanded: isHorizontal,
collapsedShape: const RoundedRectangleBorder(),
shape: const RoundedRectangleBorder(),
showTrailingIcon: false,
onExpansionChanged: (bool expanded) {
feedBack();
setState(() {
isExpanded = expanded;
});
},
title: Text(
widget.videoDetail?.title ?? videoItem['title'] ?? "",
// !loadingStatus
// ? "${widget.videoDetail?.title}"
Expand All @@ -300,97 +313,88 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
fontSize: 16,
fontWeight: FontWeight.w500,
),
maxLines: 2,
maxLines: isExpanded ? 999 : 2,
overflow: TextOverflow.ellipsis,
)),
Icon(
Icons.arrow_forward_ios,
size: 16,
color: t.colorScheme.outline,
),
]),
),
Stack(
children: [
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () => showIntroDetail(),
child: Padding(
padding: const EdgeInsets.only(top: 7, bottom: 6),
child: Row(
children: <Widget>[
StatView(
theme: 'gray',
view: !loadingStatus
? widget.videoDetail?.stat?.view ?? '-'
: videoItem['stat']?.view ?? '-',
size: 'medium',
),
const SizedBox(width: 10),
StatDanMu(
theme: 'gray',
danmu: !loadingStatus
? widget.videoDetail?.stat?.danmu ?? '-'
: videoItem['stat']?.danmu ?? '-',
size: 'medium',
subtitle: Padding(
padding: const EdgeInsets.only(top: 7),
child: Row(
children: <Widget>[
StatView(
theme: 'gray',
view: !loadingStatus
? widget.videoDetail?.stat?.view ?? '-'
: videoItem['stat']?.view ?? '-',
size: 'medium',
),
const SizedBox(width: 10),
StatDanMu(
theme: 'gray',
danmu: !loadingStatus
? widget.videoDetail?.stat?.danmu ?? '-'
: videoItem['stat']?.danmu ?? '-',
size: 'medium',
),
const SizedBox(width: 10),
Text(
Utils.dateFormat(
!loadingStatus
? widget.videoDetail?.pubdate
: videoItem['pubdate'],
formatType: 'detail'),
style: TextStyle(
fontSize: 12,
color: t.colorScheme.outline,
),
),
if (MineController.anonymity) ...<Widget>[
const SizedBox(width: 10),
Text(
Utils.dateFormat(
!loadingStatus
? widget.videoDetail?.pubdate
: videoItem['pubdate'],
formatType: 'detail'),
style: TextStyle(
fontSize: 12,
color: t.colorScheme.outline,
),
Icon(
MdiIcons.incognito,
size: 15,
color: t.colorScheme.outline,
semanticLabel: '无痕',
),
if (MineController.anonymity) ...<Widget>[
const SizedBox(width: 10),
Icon(
MdiIcons.incognito,
size: 15,
color: t.colorScheme.outline,
semanticLabel: '无痕',
),
],
const SizedBox(width: 10),
if (videoIntroController.isShowOnlineTotal)
Obx(
() => Text(
'${videoIntroController.total.value}人在看',
style: TextStyle(
fontSize: 12,
color: t.colorScheme.outline,
),
],
const SizedBox(width: 10),
if (videoIntroController.isShowOnlineTotal)
Obx(
() => Text(
'${videoIntroController.total.value}人在看',
style: TextStyle(
fontSize: 12,
color: t.colorScheme.outline,
),
),
],
),
),
const Spacer(),
if (enableAi)
Semantics(
label: 'AI总结',
child: GestureDetector(
onTap: () async {
final res =
await videoIntroController.aiConclusion();
if (res['status']) {
showAiBottomSheet();
}
},
child: Image.asset('assets/images/ai.png',
height: 22),
)),
const SizedBox(width: 10),
],
),
),
if (enableAi)
Positioned(
right: 10,
top: 6,
child: Semantics(
label: 'AI总结',
child: GestureDetector(
onTap: () async {
final res =
await videoIntroController.aiConclusion();
if (res['status']) {
showAiBottomSheet();
}
},
child:
Image.asset('assets/images/ai.png', height: 22),
)),
)
],
children: [
Row(children: [
if (widget.videoDetail != null)
Expanded(
child: IntroDetail(videoDetail: widget.videoDetail))
]),
],
),
),

Obx(
() => videoIntroController.queryVideoIntroData.value["status"]
? const SizedBox()
Expand All @@ -406,6 +410,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
),
),
),
const SizedBox(height: 8),
// 点赞收藏转发 布局样式1
// SingleChildScrollView(
// padding: const EdgeInsets.only(top: 7, bottom: 7),
Expand Down
117 changes: 21 additions & 96 deletions lib/pages/video/introduction/widgets/intro_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,102 +15,27 @@ class IntroDetail extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Container(
color: Theme.of(context).colorScheme.background,
padding: const EdgeInsets.only(left: 14, right: 14),
height: Utils.getSheetHeight(context),
child: Column(
children: [
InkWell(
onTap: () => Get.back(),
child: Container(
height: 35,
padding: const EdgeInsets.only(bottom: 2),
child: Center(
child: Container(
width: 32,
height: 3,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary,
borderRadius:
const BorderRadius.all(Radius.circular(3))),
),
),
),
),
Expanded(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
videoDetail!.title,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 6),
Row(
children: [
StatView(
theme: 'gray',
view: videoDetail!.stat!.view,
size: 'medium',
),
const SizedBox(width: 10),
StatDanMu(
theme: 'gray',
danmu: videoDetail!.stat!.danmu,
size: 'medium',
),
const SizedBox(width: 10),
Text(
Utils.dateFormat(videoDetail!.pubdate,
formatType: 'detail'),
style: TextStyle(
fontSize: 12,
color: Theme.of(context).colorScheme.outline,
),
),
],
),
const SizedBox(height: 20),
SizedBox(
width: double.infinity,
child: SelectableRegion(
focusNode: FocusNode(),
selectionControls: MaterialTextSelectionControls(),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
videoDetail!.bvid!,
style: const TextStyle(fontSize: 13),
),
const SizedBox(height: 4),
Text.rich(
style: const TextStyle(
height: 1.4,
// fontSize: 13,
),
TextSpan(
children: [
buildContent(context, videoDetail!),
],
),
),
],
),
),
),
const SizedBox(height: 100),
],
),
),
)
],
));
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
videoDetail!.bvid!,
style: const TextStyle(fontSize: 13),
),
const SizedBox(height: 4),
Text.rich(
style: const TextStyle(
height: 1.4,
// fontSize: 13,
),
TextSpan(
children: [
buildContent(context, videoDetail!),
],
),
),
],
);
}

InlineSpan buildContent(BuildContext context, content) {
Expand Down

0 comments on commit 659455e

Please sign in to comment.