Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1255e4f

Browse files
author
wz
committed
add expand view and display desc
1 parent 88a919a commit 1255e4f

3 files changed

Lines changed: 161 additions & 43 deletions

File tree

lib/pages/video_detail_page.dart

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import 'package:new_fl/models/video_detail_model.dart';
44
import 'package:new_fl/models/video_model.dart';
55
import 'package:new_fl/util/color.dart';
66
import 'package:new_fl/widget/bi_tabbar.dart';
7+
import 'package:new_fl/widget/expand_video_content.dart';
78
import 'package:new_fl/widget/top_navigator_bar.dart';
9+
import 'package:new_fl/widget/video_list_header.dart';
810
import 'package:new_fl/widget/video_view.dart';
911

1012
class VideoPlayRoute extends StatefulWidget {
@@ -88,6 +90,7 @@ class _VideoPlayRouteState extends State<VideoPlayRoute>
8890

8991
/// 创建两个tabview
9092
Widget _buildTabView() {
93+
// ExpansionTile
9194
return Flexible(
9295
child: TabBarView(
9396
controller: _tabController,
@@ -97,52 +100,17 @@ class _VideoPlayRouteState extends State<VideoPlayRoute>
97100
/// 作者相关列表
98101
Widget _authorListView() {
99102
return ListView(children: [
100-
_authorInfo(),
101-
_titleInfo(),
103+
VideoListHeader(
104+
owner: widget.model.owner!,
105+
),
106+
ExpandVideoInfoContent(model: widget.model),
107+
Container(
108+
color: Colors.blue,
109+
height: 100,
110+
)
102111
]);
103112
}
104113

105-
/// 作者头部信息
106-
Widget _authorInfo() {
107-
return Padding(
108-
padding: EdgeInsets.only(left: 15, right: 15, top: 10),
109-
child: Row(
110-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
111-
children: [
112-
Row(
113-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
114-
children: [
115-
ClipOval(
116-
child: Image.network(
117-
widget.model.owner!.face,
118-
height: 30,
119-
),
120-
),
121-
Padding(
122-
padding: const EdgeInsets.only(left: 5),
123-
child: Column(
124-
crossAxisAlignment: CrossAxisAlignment.start,
125-
children: [
126-
Text(
127-
widget.model.owner!.name,
128-
style: const TextStyle(fontSize: 16, color: primaryCor),
129-
),
130-
Text('${widget.model.owner!.mid}粉丝',
131-
style: TextStyle(fontSize: 11, color: defalutCor)),
132-
],
133-
),
134-
)
135-
],
136-
),
137-
MaterialButton(
138-
onPressed: () {},
139-
child: const Text('+ 关注', style: TextStyle(color: Colors.white)),
140-
color: primaryCor,
141-
),
142-
],
143-
));
144-
}
145-
146114
Widget _titleInfo() {
147115
return Container();
148116
}

lib/util/color.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,24 @@ const MaterialColor primaryCor = const MaterialColor(
2323
);
2424

2525
const MaterialColor defalutCor = Colors.grey;
26+
27+
/// 简单 图标文字组合
28+
Widget simpleIconText(IconData? icon, String txt) {
29+
return Padding(
30+
padding: const EdgeInsets.only(left: 5, right: 5),
31+
child: Row(
32+
children: [
33+
if (icon != null)
34+
Icon(
35+
icon,
36+
size: 10,
37+
color: defalutCor,
38+
),
39+
const Padding(padding: EdgeInsets.only(left: 2)),
40+
Text(
41+
txt,
42+
style: const TextStyle(fontSize: 10, color: defalutCor),
43+
)
44+
],
45+
));
46+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:new_fl/models/video_model.dart';
3+
import 'package:new_fl/util/color.dart';
4+
5+
/// 点击可展开的info
6+
class ExpandVideoInfoContent extends StatefulWidget {
7+
ExpandVideoInfoContent({Key? key, required this.model}) : super(key: key);
8+
9+
final VideoModel model;
10+
11+
@override
12+
_ExpandVideoInfoContentState createState() => _ExpandVideoInfoContentState();
13+
}
14+
15+
class _ExpandVideoInfoContentState extends State<ExpandVideoInfoContent>
16+
with SingleTickerProviderStateMixin {
17+
bool isExpanded = false;
18+
19+
Animatable<double> _easeTween = CurveTween(curve: Curves.easeIn);
20+
late AnimationController _animationController;
21+
late Animation<double> _heightFac;
22+
23+
late CurvedAnimation _curvedAnimation;
24+
@override
25+
void initState() {
26+
super.initState();
27+
28+
_animationController = AnimationController(
29+
vsync: this, duration: const Duration(milliseconds: 500))
30+
..addListener(() {
31+
print('动画的只');
32+
print(_animationController.value);
33+
print('----${_heightFac.value}');
34+
});
35+
_heightFac = _animationController.drive(_easeTween);
36+
37+
_curvedAnimation =
38+
CurvedAnimation(parent: _animationController, curve: Curves.easeIn);
39+
}
40+
41+
@override
42+
void dispose() {
43+
_animationController.dispose();
44+
45+
super.dispose();
46+
}
47+
48+
@override
49+
Widget build(BuildContext context) {
50+
return Container(
51+
child: Padding(
52+
padding: EdgeInsets.only(left: 15, right: 15, top: 5),
53+
child: Column(
54+
children: [
55+
_topView(),
56+
_centerView(),
57+
_bottomView(),
58+
],
59+
),
60+
),
61+
);
62+
}
63+
64+
Widget _topView() {
65+
return InkWell(
66+
onTap: () {
67+
setState(() {
68+
isExpanded = !isExpanded;
69+
if (isExpanded) {
70+
_animationController.forward();
71+
} else {
72+
_animationController.reverse();
73+
}
74+
});
75+
},
76+
child: Row(
77+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
78+
children: [
79+
Text(
80+
widget.model.title,
81+
overflow: TextOverflow.ellipsis,
82+
style: const TextStyle(fontSize: 18, color: Colors.black87),
83+
),
84+
Icon(
85+
isExpanded ? Icons.expand_more : Icons.expand_less,
86+
color: defalutCor,
87+
)
88+
],
89+
),
90+
);
91+
}
92+
93+
_bottomView() {
94+
Widget? textW;
95+
if (isExpanded) {
96+
textW = Text(
97+
widget.model.desc,
98+
style: const TextStyle(fontSize: 12, color: defalutCor),
99+
);
100+
} else {
101+
textW = null;
102+
}
103+
104+
return AnimatedBuilder(
105+
animation: _animationController.view,
106+
child: textW,
107+
builder: (ctx, child) {
108+
return Align(
109+
heightFactor: _curvedAnimation.value,
110+
alignment: Alignment.topCenter,
111+
child: Container(
112+
alignment: Alignment.topLeft,
113+
padding: EdgeInsets.only(top: 5),
114+
child: child,
115+
),
116+
);
117+
});
118+
}
119+
}
120+
121+
Widget _centerView() {
122+
return Row(
123+
children: [
124+
simpleIconText(Icons.live_tv_sharp, '观看'),
125+
simpleIconText(Icons.tv_rounded, '观看'),
126+
Text('日期')
127+
],
128+
);
129+
}

0 commit comments

Comments
 (0)