Skip to content

Commit

Permalink
mod: 视频详情页简介查看&操作栏
Browse files Browse the repository at this point in the history
  • Loading branch information
guozhigq committed Mar 24, 2024
1 parent 031d57e commit a925ef6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 133 deletions.
33 changes: 17 additions & 16 deletions lib/pages/video/detail/introduction/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:pilipala/pages/video/detail/widgets/ai_detail.dart';
import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/utils/utils.dart';
import '../widgets/expandable_section.dart';
import 'widgets/action_item.dart';
import 'widgets/fav_panel.dart';
import 'widgets/intro_detail.dart';
Expand Down Expand Up @@ -137,6 +138,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
late String memberHeroTag;
late bool enableAi;
bool isProcessing = false;
RxBool isExpand = false.obs;
void Function()? handleState(Future Function() action) {
return isProcessing
? null
Expand Down Expand Up @@ -212,13 +214,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
// 视频介绍
showIntroDetail() {
feedBack();
showBottomSheet(
context: context,
enableDrag: true,
builder: (BuildContext context) {
return IntroDetail(videoDetail: widget.videoDetail!);
},
);
isExpand.value = !(isExpand.value);
}

// 用户主页
Expand Down Expand Up @@ -330,6 +326,16 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
],
),

/// 视频简介
Obx(
() => ExpandedSection(
expand: isExpand.value,
begin: 0,
end: 1,
child: IntroDetail(videoDetail: widget.videoDetail!),
),
),

/// 点赞收藏转发
actionGrid(context, videoIntroController),
// 合集
Expand Down Expand Up @@ -438,6 +444,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
margin: const EdgeInsets.only(top: 6, bottom: 4),
height: constraints.maxWidth / 5 * 0.8,
child: GridView.count(
physics: const NeverScrollableScrollPhysics(),
primary: false,
padding: EdgeInsets.zero,
crossAxisCount: 5,
Expand All @@ -451,12 +458,6 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
selectStatus: videoIntroController.hasLike.value,
text: widget.videoDetail!.stat!.like!.toString()),
),
// ActionItem(
// icon: const Icon(FontAwesomeIcons.clock),
// onTap: () => videoIntroController.actionShareVideo(),
// selectStatus: false,
// loadingStatus: loadingStatus,
// text: '稍后再看'),
Obx(
() => ActionItem(
icon: const Icon(FontAwesomeIcons.b),
Expand All @@ -477,10 +478,10 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
),
),
ActionItem(
icon: const Icon(FontAwesomeIcons.comment),
onTap: () => videoDetailCtr.tabCtr.animateTo(1),
icon: const Icon(FontAwesomeIcons.clock),
onTap: () => videoIntroController.actionShareVideo(),
selectStatus: false,
text: widget.videoDetail!.stat!.reply!.toString(),
text: '稍后看',
),
ActionItem(
icon: const Icon(FontAwesomeIcons.shareFromSquare),
Expand Down
130 changes: 29 additions & 101 deletions lib/pages/video/detail/introduction/widgets/intro_detail.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/common/widgets/stat/danmu.dart';
import 'package:pilipala/common/widgets/stat/view.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/utils/utils.dart';

Box localCache = GStrorage.localCache;
late double sheetHeight;

class IntroDetail extends StatelessWidget {
const IntroDetail({
super.key,
Expand All @@ -20,105 +14,39 @@ class IntroDetail extends StatelessWidget {

@override
Widget build(BuildContext context) {
sheetHeight = localCache.get('sheetHeight');
return Container(
color: Theme.of(context).colorScheme.background,
padding: EdgeInsets.only(
left: 14,
right: 14,
bottom: MediaQuery.of(context).padding.bottom + 20),
height: sheetHeight,
return SizedBox(
width: double.infinity,
child: SelectableRegion(
focusNode: FocusNode(),
selectionControls: MaterialTextSelectionControls(),
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))),
),
),
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const SizedBox(height: 4),
GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(text: videoDetail!.bvid!));
SmartDialog.showToast('已复制');
},
child: Text(
videoDetail!.bvid!,
style: TextStyle(
fontSize: 13, color: Theme.of(context).colorScheme.primary),
),
),
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!.danmaku,
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: 4),
Text.rich(
style: const TextStyle(height: 1.4),
TextSpan(
children: [
buildContent(context, videoDetail!),
],
),
)
),
],
));
),
),
);
}

InlineSpan buildContent(BuildContext context, content) {
Expand Down
20 changes: 4 additions & 16 deletions lib/pages/video/detail/widgets/expandable_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,14 @@ class _ExpandedSectionState extends State<ExpandedSection>
_runExpandCheck();
}

///Setting up the animation
// void prepareAnimations() {
// expandController = AnimationController(
// vsync: this, duration: const Duration(milliseconds: 500));
// animation = CurvedAnimation(
// parent: expandController,
// curve: Curves.fastOutSlowIn,
// );
// }

void prepareAnimations() {
expandController = AnimationController(
vsync: this, duration: const Duration(milliseconds: 400));
Animation<double> curve = CurvedAnimation(
parent: expandController,
curve: Curves.fastOutSlowIn,
curve: Curves.linear,
);
animation = Tween(begin: widget.begin, end: widget.end).animate(curve);
// animation = CurvedAnimation(
// parent: expandController,
// curve: Curves.fastOutSlowIn,
// );
}

void _runExpandCheck() {
Expand All @@ -67,7 +53,9 @@ class _ExpandedSectionState extends State<ExpandedSection>
@override
void didUpdateWidget(ExpandedSection oldWidget) {
super.didUpdateWidget(oldWidget);
_runExpandCheck();
if (widget.expand != oldWidget.expand) {
_runExpandCheck();
}
}

@override
Expand Down

0 comments on commit a925ef6

Please sign in to comment.