Skip to content

Commit

Permalink
Merge branch 'feature-updateVideoDetailStructure'
Browse files Browse the repository at this point in the history
  • Loading branch information
guozhigq committed Mar 28, 2024
2 parents 9845f03 + 8f9fbf5 commit 5cb3e57
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 14 deletions.
62 changes: 48 additions & 14 deletions lib/pages/video/detail/introduction/view.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:expandable/expandable.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart';
Expand All @@ -16,7 +17,6 @@ import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/utils/utils.dart';
import '../../../../http/user.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 @@ -140,6 +140,8 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
late bool enableAi;
bool isProcessing = false;
RxBool isExpand = false.obs;
late ExpandableController _expandableCtr;

void Function()? handleState(Future Function() action) {
return isProcessing
? null
Expand All @@ -163,6 +165,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
follower = Utils.numFormat(videoIntroController.userStat['follower']);
followStatus = videoIntroController.followStatus;
enableAi = setting.get(SettingBoxKey.enableAi, defaultValue: true);
_expandableCtr = ExpandableController(initialExpanded: false);
}

// 收藏
Expand Down Expand Up @@ -216,6 +219,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
showIntroDetail() {
feedBack();
isExpand.value = !(isExpand.value);
_expandableCtr.toggle();
}

// 用户主页
Expand All @@ -239,6 +243,12 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
);
}

@override
void dispose() {
_expandableCtr.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
final ThemeData t = Theme.of(context);
Expand All @@ -256,14 +266,34 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () => showIntroDetail(),
child: Text(
widget.videoDetail!.title!,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
child: ExpandablePanel(
controller: _expandableCtr,
collapsed: Text(
widget.videoDetail!.title!,
softWrap: true,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
expanded: Text(
widget.videoDetail!.title!,
softWrap: true,
maxLines: 4,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
theme: const ExpandableThemeData(
animationDuration: Duration(milliseconds: 300),
scrollAnimationDuration: Duration(milliseconds: 300),
crossFadePoint: 0,
fadeCurve: Curves.ease,
sizeCurve: Curves.linear,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
Stack(
Expand Down Expand Up @@ -328,12 +358,16 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
),

/// 视频简介
Obx(
() => ExpandedSection(
expand: isExpand.value,
begin: 0,
end: 1,
child: IntroDetail(videoDetail: widget.videoDetail!),
ExpandablePanel(
controller: _expandableCtr,
collapsed: const SizedBox(height: 0),
expanded: IntroDetail(videoDetail: widget.videoDetail!),
theme: const ExpandableThemeData(
animationDuration: Duration(milliseconds: 300),
scrollAnimationDuration: Duration(milliseconds: 300),
crossFadePoint: 0,
fadeCurve: Curves.ease,
sizeCurve: Curves.linear,
),
),

Expand Down
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,14 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.0.3"
expandable:
dependency: "direct main"
description:
name: expandable
sha256: "9604d612d4d1146dafa96c6d8eec9c2ff0994658d6d09fed720ab788c7f5afc2"
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.0.1"
extended_image:
dependency: "direct main"
description:
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ dependencies:
path: 1.8.3
# 电池优化
disable_battery_optimization: ^1.1.1
# 展开/收起
expandable: ^5.0.1

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 5cb3e57

Please sign in to comment.