|
|
@@ -21,7 +21,9 @@ class CartoonMaterialControls extends StatefulWidget {
|
|
|
final ValueNotifier<int> isCollect;
|
|
|
final ValueNotifier<int> isLoadingVideo;
|
|
|
|
|
|
- const CartoonMaterialControls({Key key, this.enableQuickControl = false, this.moreVideo, this.onTapMoreVideo, this.onTapNext, this.onTapPrevious, this.onTapLove, this.isCollect, this.isLoadingVideo}) : super(key: key);
|
|
|
+ const CartoonMaterialControls(
|
|
|
+ {Key key, this.enableQuickControl = false, this.moreVideo, this.onTapMoreVideo, this.onTapNext, this.onTapPrevious, this.onTapLove, this.isCollect, this.isLoadingVideo})
|
|
|
+ : super(key: key);
|
|
|
|
|
|
@override
|
|
|
State<StatefulWidget> createState() {
|
|
|
@@ -56,6 +58,7 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
double lastDx;
|
|
|
Duration dragDuration;
|
|
|
Duration updateDragDuration;
|
|
|
+
|
|
|
/// 竖向音量亮度拖动 100%调整的逻辑
|
|
|
double startDy;
|
|
|
double endDy;
|
|
|
@@ -93,12 +96,18 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
return;
|
|
|
}
|
|
|
// 判断距离 只响应2/5的左边和2/5的右边
|
|
|
- if (details.globalPosition.dx < MediaQuery.of(context).size.width / 5 * 2) {
|
|
|
+ if (details.globalPosition.dx < MediaQuery
|
|
|
+ .of(context)
|
|
|
+ .size
|
|
|
+ .width / 5 * 2) {
|
|
|
// 响应亮度
|
|
|
startDy = details.globalPosition.dy;
|
|
|
_CartoonVerticalMode = CartoonVerticalMode.Bright;
|
|
|
currentBright = await Screen.brightness;
|
|
|
- } else if (details.globalPosition.dx > MediaQuery.of(context).size.width / 5 * 3) {
|
|
|
+ } else if (details.globalPosition.dx > MediaQuery
|
|
|
+ .of(context)
|
|
|
+ .size
|
|
|
+ .width / 5 * 3) {
|
|
|
// 响应音量
|
|
|
startDy = details.globalPosition.dy;
|
|
|
_CartoonVerticalMode = CartoonVerticalMode.Volume;
|
|
|
@@ -123,34 +132,59 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
setState(() {
|
|
|
endDy = details.globalPosition.dy;
|
|
|
});
|
|
|
- if (_CartoonVerticalMode != null && endDy != null && startDy != null) {
|
|
|
+ if (_CartoonVerticalMode != null && endDy != null &&
|
|
|
+ startDy != null) {
|
|
|
double value;
|
|
|
if (_CartoonVerticalMode == CartoonVerticalMode.Bright) {
|
|
|
if (currentBright == null) return;
|
|
|
if (endDy > startDy) {
|
|
|
// 降低操作 竖屏环境?????
|
|
|
- value = (currentBright - (endDy - startDy) / MediaQuery.of(context).size.height) < 0
|
|
|
+ value = (currentBright - (endDy - startDy) / MediaQuery
|
|
|
+ .of(context)
|
|
|
+ .size
|
|
|
+ .height) < 0
|
|
|
? 0
|
|
|
- : (currentBright - (endDy - startDy) / MediaQuery.of(context).size.height);
|
|
|
+ : (currentBright - (endDy - startDy) / MediaQuery
|
|
|
+ .of(context)
|
|
|
+ .size
|
|
|
+ .height);
|
|
|
} else {
|
|
|
// 拉高操作 竖屏环境?????
|
|
|
- value = (currentBright + (startDy - endDy) / MediaQuery.of(context).size.height) >= 1
|
|
|
+ value = (currentBright + (startDy - endDy) / MediaQuery
|
|
|
+ .of(context)
|
|
|
+ .size
|
|
|
+ .height) >= 1
|
|
|
? 1
|
|
|
- : (currentBright + (startDy - endDy) / MediaQuery.of(context).size.height);
|
|
|
+ : (currentBright + (startDy - endDy) / MediaQuery
|
|
|
+ .of(context)
|
|
|
+ .size
|
|
|
+ .height);
|
|
|
}
|
|
|
Screen.setBrightness(value);
|
|
|
} else {
|
|
|
if (currentVolume == null) return;
|
|
|
if (endDy > startDy) {
|
|
|
// 降低操作 竖屏环境?????
|
|
|
- value = (currentVolume - (endDy - startDy) / MediaQuery.of(context).size.height) < 0
|
|
|
+ value = (currentVolume - (endDy - startDy) / MediaQuery
|
|
|
+ .of(context)
|
|
|
+ .size
|
|
|
+ .height) < 0
|
|
|
? 0
|
|
|
- : (currentVolume - (endDy - startDy) / MediaQuery.of(context).size.height);
|
|
|
+ : (currentVolume - (endDy - startDy) / MediaQuery
|
|
|
+ .of(context)
|
|
|
+ .size
|
|
|
+ .height);
|
|
|
} else {
|
|
|
// 拉高操作 竖屏环境?????
|
|
|
- value = (currentVolume + (startDy - endDy) / MediaQuery.of(context).size.height) >= 1
|
|
|
+ value = (currentVolume + (startDy - endDy) / MediaQuery
|
|
|
+ .of(context)
|
|
|
+ .size
|
|
|
+ .height) >= 1
|
|
|
? 1
|
|
|
- : (currentVolume + (startDy - endDy) / MediaQuery.of(context).size.height);
|
|
|
+ : (currentVolume + (startDy - endDy) / MediaQuery
|
|
|
+ .of(context)
|
|
|
+ .size
|
|
|
+ .height);
|
|
|
}
|
|
|
FlutterVolume.set(value);
|
|
|
}
|
|
|
@@ -164,10 +198,9 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
valueText = (value * 100).toStringAsFixed(0);
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
},
|
|
|
- onVerticalDragEnd: (DragEndDetails details){
|
|
|
+ onVerticalDragEnd: (DragEndDetails details) {
|
|
|
if (!widget.enableQuickControl) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -201,7 +234,7 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
updateDragDuration = finalDuration;
|
|
|
});
|
|
|
},
|
|
|
- onHorizontalDragCancel: (){
|
|
|
+ onHorizontalDragCancel: () {
|
|
|
if (!widget.enableQuickControl) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -216,7 +249,8 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
if (!widget.enableQuickControl) {
|
|
|
return;
|
|
|
}
|
|
|
- if (startDx != null && lastDx != null && _latestValue.duration != null && dragDuration != null) {
|
|
|
+ if (startDx != null && lastDx != null &&
|
|
|
+ _latestValue.duration != null && dragDuration != null) {
|
|
|
Duration finalDuration = getDragDuration();
|
|
|
chewieController.seekTo(finalDuration);
|
|
|
}
|
|
|
@@ -228,29 +262,29 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
});
|
|
|
},
|
|
|
child: AbsorbPointer(
|
|
|
- absorbing: _hideStuff,
|
|
|
- child: Stack(
|
|
|
- children: <Widget>[
|
|
|
- Column(
|
|
|
- children: <Widget>[
|
|
|
- _latestValue != null &&
|
|
|
- !_latestValue.isPlaying &&
|
|
|
- _latestValue.duration == null ||
|
|
|
- _latestValue.isBuffering
|
|
|
- ? const Expanded(
|
|
|
- child: const Center(
|
|
|
- child: const CircularProgressIndicator(),
|
|
|
- ),
|
|
|
- )
|
|
|
- : _buildHitArea(),
|
|
|
- _buildBottomBar(context),
|
|
|
- ],
|
|
|
- ),
|
|
|
- _buildTopBar(context),
|
|
|
- _buildDragProgress(),
|
|
|
- _buildVerticalWidget(),
|
|
|
- ],
|
|
|
- )
|
|
|
+ absorbing: _hideStuff,
|
|
|
+ child: Stack(
|
|
|
+ children: <Widget>[
|
|
|
+ Column(
|
|
|
+ children: <Widget>[
|
|
|
+ _latestValue != null &&
|
|
|
+ !_latestValue.isPlaying &&
|
|
|
+ _latestValue.duration == null ||
|
|
|
+ _latestValue.isBuffering
|
|
|
+ ? const Expanded(
|
|
|
+ child: const Center(
|
|
|
+ child: const CircularProgressIndicator(),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ : _buildHitArea(),
|
|
|
+ _buildBottomBar(context),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ _buildTopBar(context),
|
|
|
+ _buildDragProgress(),
|
|
|
+ _buildVerticalWidget(),
|
|
|
+ ],
|
|
|
+ )
|
|
|
),
|
|
|
),
|
|
|
);
|
|
|
@@ -264,11 +298,12 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
|
|
|
void _initState() async {
|
|
|
FlutterVolume.disableUI();
|
|
|
- _eventBusStreamSubscription = i2ControlEventBus.on<I2ControllerEvent>().listen((event){
|
|
|
- if (event == I2ControllerEvent.ShowControl) {
|
|
|
- _showControlWithoutTimer();
|
|
|
- }
|
|
|
- });
|
|
|
+ _eventBusStreamSubscription =
|
|
|
+ i2ControlEventBus.on<I2ControllerEvent>().listen((event) {
|
|
|
+ if (event == I2ControllerEvent.ShowControl) {
|
|
|
+ _showControlWithoutTimer();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
@@ -305,29 +340,46 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
// 前进
|
|
|
int forwardSec;
|
|
|
if (_latestValue.duration.inSeconds > 90) {
|
|
|
- forwardSec = ((lastDx - startDx) / MediaQuery.of(context).size.width * 90).toInt();
|
|
|
+ forwardSec = ((lastDx - startDx) / MediaQuery
|
|
|
+ .of(context)
|
|
|
+ .size
|
|
|
+ .width * 90).toInt();
|
|
|
} else {
|
|
|
- forwardSec = ((lastDx - startDx) / MediaQuery.of(context).size.width * _latestValue.duration.inSeconds * 0.8).toInt();
|
|
|
+ forwardSec = ((lastDx - startDx) / MediaQuery
|
|
|
+ .of(context)
|
|
|
+ .size
|
|
|
+ .width * _latestValue.duration.inSeconds * 0.8).toInt();
|
|
|
}
|
|
|
Duration duration = dragDuration + Duration(seconds: forwardSec);
|
|
|
- return duration >= _latestValue.duration ? _latestValue.duration : duration;
|
|
|
+ return duration >= _latestValue.duration
|
|
|
+ ? _latestValue.duration
|
|
|
+ : duration;
|
|
|
} else {
|
|
|
// 后退
|
|
|
int backwardSec;
|
|
|
if (_latestValue.duration.inSeconds > 90) {
|
|
|
- backwardSec = ((lastDx - startDx) * -1 / MediaQuery.of(context).size.width * 90).toInt();
|
|
|
+ backwardSec = ((lastDx - startDx) * -1 / MediaQuery
|
|
|
+ .of(context)
|
|
|
+ .size
|
|
|
+ .width * 90).toInt();
|
|
|
} else {
|
|
|
- backwardSec = ((lastDx - startDx) * -1 / MediaQuery.of(context).size.width * _latestValue.duration.inSeconds * 0.8).toInt();
|
|
|
+ backwardSec = ((lastDx - startDx) * -1 / MediaQuery
|
|
|
+ .of(context)
|
|
|
+ .size
|
|
|
+ .width * _latestValue.duration.inSeconds * 0.8).toInt();
|
|
|
}
|
|
|
- Duration duration = (Duration(seconds: backwardSec) > dragDuration) ? Duration.zero : dragDuration - Duration(seconds: backwardSec);
|
|
|
+ Duration duration = (Duration(seconds: backwardSec) > dragDuration)
|
|
|
+ ? Duration.zero
|
|
|
+ : dragDuration - Duration(seconds: backwardSec);
|
|
|
return duration;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Widget _buildDragProgress() {
|
|
|
- final position = updateDragDuration ?? (_latestValue != null && _latestValue.position != null
|
|
|
- ? _latestValue.position
|
|
|
- : Duration.zero);
|
|
|
+ final position = updateDragDuration ??
|
|
|
+ (_latestValue != null && _latestValue.position != null
|
|
|
+ ? _latestValue.position
|
|
|
+ : Duration.zero);
|
|
|
return Offstage(
|
|
|
offstage: updateDragDuration == null,
|
|
|
child: Align(
|
|
|
@@ -340,7 +392,9 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
borderRadius: BorderRadius.circular(4),
|
|
|
),
|
|
|
alignment: Alignment.center,
|
|
|
- child: Text("${formatDuration(position)}/${formatDuration(_latestValue.duration)}", style: TextStyle(color: Colors.white, fontSize: 12),),
|
|
|
+ child: Text("${formatDuration(position)}/${formatDuration(
|
|
|
+ _latestValue.duration)}",
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 12),),
|
|
|
),
|
|
|
),
|
|
|
);
|
|
|
@@ -365,10 +419,13 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
children: <Widget>[
|
|
|
- Icon(_CartoonVerticalMode == CartoonVerticalMode.Volume ? Icons.volume_up : Icons.brightness_6, color: Colors.white, size: 24,),
|
|
|
+ Icon(_CartoonVerticalMode == CartoonVerticalMode.Volume ? Icons
|
|
|
+ .volume_up : Icons.brightness_6, color: Colors.white,
|
|
|
+ size: 24,),
|
|
|
Padding(
|
|
|
padding: const EdgeInsets.only(top: 10),
|
|
|
- child: Text("${valueText}%", style: TextStyle(color: Colors.white, fontSize: 15,),),
|
|
|
+ child: Text("${valueText}%",
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 15,),),
|
|
|
),
|
|
|
],
|
|
|
),
|
|
|
@@ -377,20 +434,22 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- AnimatedOpacity _buildTopBar(
|
|
|
- BuildContext context,
|
|
|
- ) {
|
|
|
+ AnimatedOpacity _buildTopBar(BuildContext context,) {
|
|
|
return AnimatedOpacity(
|
|
|
opacity: _hideStuff ? 0.0 : 1.0,
|
|
|
duration: Duration(milliseconds: 300),
|
|
|
child: Container(
|
|
|
decoration: BoxDecoration(
|
|
|
color: Colors.white,
|
|
|
- borderRadius: BorderRadius.only(bottomRight: Radius.circular(10), bottomLeft: Radius.circular(10)),
|
|
|
+ borderRadius: BorderRadius.only(bottomRight: Radius.circular(10),
|
|
|
+ bottomLeft: Radius.circular(10)),
|
|
|
),
|
|
|
// color: chewieController.isFullScreen ? Colors.black26 : Colors.transparent,
|
|
|
alignment: Alignment.center,
|
|
|
- margin: EdgeInsets.only(left: (MediaQuery.of(context).size.width - 280) / 2),
|
|
|
+ margin: EdgeInsets.only(left: (MediaQuery
|
|
|
+ .of(context)
|
|
|
+ .size
|
|
|
+ .width - 280) / 2),
|
|
|
width: 300,
|
|
|
height: 46,
|
|
|
// margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top != 0 ? MediaQuery.of(context).padding.top : 0),
|
|
|
@@ -399,41 +458,57 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
children: <Widget>[
|
|
|
Expanded(
|
|
|
child: GestureDetector(
|
|
|
- child: Image(image: AssetImage("assets/dub_user_play/back2.png", package: 'chewie'), width: 20, height: 20,),
|
|
|
+ child: Image(image: AssetImage(
|
|
|
+ "assets/dub_user_play/back2.png", package: 'chewie'),
|
|
|
+ width: 20,
|
|
|
+ height: 20,),
|
|
|
onTap: onTapBack,
|
|
|
),
|
|
|
),
|
|
|
Expanded(
|
|
|
- child: GestureDetector(
|
|
|
- child: Image(image: AssetImage("assets/dub_user_play/rightyou.png", package: 'chewie'), width: 20, height: 20,),
|
|
|
- onTap: widget.onTapPrevious,
|
|
|
- ),
|
|
|
+ child: GestureDetector(
|
|
|
+ child: Image(image: AssetImage(
|
|
|
+ "assets/dub_user_play/rightyou.png", package: 'chewie'),
|
|
|
+ width: 20,
|
|
|
+ height: 20,),
|
|
|
+ onTap: widget.onTapPrevious,
|
|
|
+ ),
|
|
|
),
|
|
|
Expanded(
|
|
|
- child: GestureDetector(
|
|
|
- child: Image(image: AssetImage(controller.value.isPlaying ? "assets/dub_user_play/top_stop.png" : "assets/dub_user_play/top_bof.png" , package: 'chewie'), width: 20, height: 20,),
|
|
|
- onTap: _playPause,
|
|
|
- ),
|
|
|
+ child: GestureDetector(
|
|
|
+ child: Image(image: AssetImage(controller.value.isPlaying
|
|
|
+ ? "assets/dub_user_play/top_stop.png"
|
|
|
+ : "assets/dub_user_play/top_bof.png", package: 'chewie'),
|
|
|
+ width: 20,
|
|
|
+ height: 20,),
|
|
|
+ onTap: _playPause,
|
|
|
+ ),
|
|
|
),
|
|
|
Expanded(
|
|
|
- child: GestureDetector(
|
|
|
- child: Image(image: AssetImage("assets/dub_user_play/rightji.png", package: 'chewie'), width: 20, height: 20,),
|
|
|
- onTap: widget.onTapNext,
|
|
|
- ),
|
|
|
+ child: GestureDetector(
|
|
|
+ child: Image(image: AssetImage(
|
|
|
+ "assets/dub_user_play/rightji.png", package: 'chewie'),
|
|
|
+ width: 20,
|
|
|
+ height: 20,),
|
|
|
+ onTap: widget.onTapNext,
|
|
|
+ ),
|
|
|
),
|
|
|
Expanded(
|
|
|
- child: GestureDetector(
|
|
|
- child: ValueListenableBuilder(
|
|
|
- valueListenable: widget.isCollect,
|
|
|
- builder: (BuildContext context, int value, Widget child){
|
|
|
- return Image(image: AssetImage("assets/dub_user_play/${widget.isCollect.value == 1 ? "xin.png" : "hxin.png"}", package: 'chewie'), width: 20, height: 20,);
|
|
|
- }
|
|
|
- ),
|
|
|
- onTap: () {
|
|
|
- _cancelAndRestartTimer();
|
|
|
- widget.onTapLove();
|
|
|
- },
|
|
|
+ child: GestureDetector(
|
|
|
+ child: ValueListenableBuilder(
|
|
|
+ valueListenable: widget.isCollect,
|
|
|
+ builder: (BuildContext context, int value, Widget child) {
|
|
|
+ return Image(
|
|
|
+ image: AssetImage("assets/dub_user_play/${widget
|
|
|
+ .isCollect.value == 1 ? "xin.png" : "hxin.png"}",
|
|
|
+ package: 'chewie'), width: 20, height: 20,);
|
|
|
+ }
|
|
|
),
|
|
|
+ onTap: () {
|
|
|
+ _cancelAndRestartTimer();
|
|
|
+ widget.onTapLove();
|
|
|
+ },
|
|
|
+ ),
|
|
|
),
|
|
|
],
|
|
|
)
|
|
|
@@ -441,96 +516,119 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- AnimatedOpacity _buildBottomBar(
|
|
|
- BuildContext context,
|
|
|
- ) {
|
|
|
- final iconColor = Theme.of(context).textTheme.button.color;
|
|
|
+ AnimatedOpacity _buildBottomBar(BuildContext context,) {
|
|
|
+ final iconColor = Theme
|
|
|
+ .of(context)
|
|
|
+ .textTheme
|
|
|
+ .button
|
|
|
+ .color;
|
|
|
|
|
|
return AnimatedOpacity(
|
|
|
- opacity: _hideStuff ? 0.0 : 1.0,
|
|
|
- duration: Duration(milliseconds: 300),
|
|
|
- child: Column(
|
|
|
- children: <Widget>[
|
|
|
- Container(
|
|
|
- height: barHeight + (widget.moreVideo.length == 0 ? 0 : 80),
|
|
|
- decoration: BoxDecoration(
|
|
|
- gradient: const LinearGradient(
|
|
|
- colors: [Colors.black38, Colors.transparent], begin: Alignment.bottomCenter, end: Alignment.topCenter, stops: [0.0, 1]),
|
|
|
- ),
|
|
|
- child: Column(
|
|
|
- children: <Widget>[
|
|
|
- SizedBox(
|
|
|
- height: barHeight,
|
|
|
- child: Row(
|
|
|
- children: <Widget>[
|
|
|
- chewieController.isLive
|
|
|
- ? Expanded(child: const Text('LIVE'))
|
|
|
- : _buildPosition(iconColor),
|
|
|
- chewieController.isLive ? const SizedBox() : _buildProgressBar(),
|
|
|
- chewieController.isLive
|
|
|
- ? const SizedBox()
|
|
|
- : _buildFullPosition(iconColor),
|
|
|
- ],
|
|
|
- ),
|
|
|
+ opacity: _hideStuff ? 0.0 : 1.0,
|
|
|
+ duration: Duration(milliseconds: 300),
|
|
|
+ child: Column(
|
|
|
+ children: <Widget>[
|
|
|
+ Container(
|
|
|
+ height: barHeight + (widget.moreVideo.length == 0 ? 0 : 80),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ gradient: const LinearGradient(
|
|
|
+ colors: [Colors.black38, Colors.transparent],
|
|
|
+ begin: Alignment.bottomCenter,
|
|
|
+ end: Alignment.topCenter,
|
|
|
+ stops: [0.0, 1]),
|
|
|
),
|
|
|
- Offstage(
|
|
|
- offstage: widget.moreVideo.length == 0,
|
|
|
- child: SizedBox(
|
|
|
- height: 80,
|
|
|
- child: Listener(
|
|
|
- child: ListView.builder(
|
|
|
- scrollDirection: Axis.horizontal,
|
|
|
- physics: AlwaysScrollableScrollPhysics(),
|
|
|
- shrinkWrap: false,
|
|
|
- itemCount: widget.moreVideo.length,
|
|
|
- itemBuilder: (ctx, index){
|
|
|
- return GestureDetector(
|
|
|
- child: Container(
|
|
|
- width: 100,
|
|
|
- height: 60,
|
|
|
- alignment: Alignment.center,
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: Colors.white,
|
|
|
- borderRadius: BorderRadius.circular(15),
|
|
|
- border: widget.moreVideo[index].isSelect ? Border.all(color: Color(0xFFEF765E), width: 3) : null,
|
|
|
- ),
|
|
|
- margin: EdgeInsets.only(left: 10, right: 10, bottom: 10),
|
|
|
- child: Stack(
|
|
|
- children: <Widget>[
|
|
|
- ClipRRect(
|
|
|
+ child: Column(
|
|
|
+ children: <Widget>[
|
|
|
+ SizedBox(
|
|
|
+ height: barHeight,
|
|
|
+ child: Row(
|
|
|
+ children: <Widget>[
|
|
|
+ chewieController.isLive
|
|
|
+ ? Expanded(child: const Text('LIVE'))
|
|
|
+ : _buildPosition(iconColor),
|
|
|
+ chewieController.isLive
|
|
|
+ ? const SizedBox()
|
|
|
+ : _buildProgressBar(),
|
|
|
+ chewieController.isLive
|
|
|
+ ? const SizedBox()
|
|
|
+ : _buildFullPosition(iconColor),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Offstage(
|
|
|
+ offstage: widget.moreVideo.length == 0,
|
|
|
+ child: SizedBox(
|
|
|
+ height: 80,
|
|
|
+ child: Listener(
|
|
|
+ child: ListView.builder(
|
|
|
+ scrollDirection: Axis.horizontal,
|
|
|
+ physics: AlwaysScrollableScrollPhysics(),
|
|
|
+ shrinkWrap: false,
|
|
|
+ itemCount: widget.moreVideo.length,
|
|
|
+ itemBuilder: (ctx, index) {
|
|
|
+ return GestureDetector(
|
|
|
+ child: Container(
|
|
|
+ width: 100,
|
|
|
+ height: 60,
|
|
|
+ alignment: Alignment.center,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Colors.white,
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
- child: Image.network(widget.moreVideo[index].imageUrl, fit: BoxFit.cover, width: 100, height: 60,),
|
|
|
+ border: widget.moreVideo[index].isSelect
|
|
|
+ ? Border.all(
|
|
|
+ color: Color(0xFFEF765E), width: 3)
|
|
|
+ : null,
|
|
|
),
|
|
|
- Align(
|
|
|
- alignment: Alignment.bottomRight,
|
|
|
- child: Container(
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: Colors.black26,
|
|
|
- borderRadius: BorderRadius.circular(20),
|
|
|
+ margin: EdgeInsets.only(
|
|
|
+ left: 10, right: 10, bottom: 10),
|
|
|
+ child: Stack(
|
|
|
+ children: <Widget>[
|
|
|
+ ClipRRect(
|
|
|
+ borderRadius: BorderRadius.circular(
|
|
|
+ 15),
|
|
|
+ child: Image.network(
|
|
|
+ widget.moreVideo[index].imageUrl,
|
|
|
+ fit: BoxFit.cover,
|
|
|
+ width: 100,
|
|
|
+ height: 60,),
|
|
|
),
|
|
|
- padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
|
|
|
- child: Text(formatDuration(widget.moreVideo[index].duration), style: TextStyle(color: Colors.white, fontSize: 11.0,),),
|
|
|
- ),
|
|
|
+ Align(
|
|
|
+ alignment: Alignment.bottomRight,
|
|
|
+ child: Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Colors.black26,
|
|
|
+ borderRadius: BorderRadius
|
|
|
+ .circular(20),
|
|
|
+ ),
|
|
|
+ padding: const EdgeInsets.symmetric(
|
|
|
+ horizontal: 4, vertical: 2),
|
|
|
+ child: Text(formatDuration(
|
|
|
+ widget.moreVideo[index]
|
|
|
+ .duration),
|
|
|
+ style: TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontSize: 11.0,),),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- onTap: () {
|
|
|
- widget?.onTapMoreVideo(index);
|
|
|
+ ),
|
|
|
+ onTap: () {
|
|
|
+ widget?.onTapMoreVideo(index);
|
|
|
+ },
|
|
|
+ );
|
|
|
},
|
|
|
- );
|
|
|
- },
|
|
|
- ),
|
|
|
- onPointerDown: onMoreVideoPointerDown,
|
|
|
- onPointerUp: onMoreVideoPointerUp,
|
|
|
- )
|
|
|
- ),
|
|
|
- ),
|
|
|
- ],
|
|
|
- )
|
|
|
- ),
|
|
|
- ],
|
|
|
- )
|
|
|
+ ),
|
|
|
+ onPointerDown: onMoreVideoPointerDown,
|
|
|
+ onPointerUp: onMoreVideoPointerUp,
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ )
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -564,12 +662,15 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
child: GestureDetector(
|
|
|
child: Container(
|
|
|
decoration: BoxDecoration(
|
|
|
- color: Theme.of(context).dialogBackgroundColor,
|
|
|
+ color: Theme
|
|
|
+ .of(context)
|
|
|
+ .dialogBackgroundColor,
|
|
|
borderRadius: BorderRadius.circular(48.0),
|
|
|
),
|
|
|
child: Padding(
|
|
|
padding: EdgeInsets.all(12.0),
|
|
|
- child: Icon(Icons.play_arrow, size: 32.0, color: Colors.black,),
|
|
|
+ child: Icon(
|
|
|
+ Icons.play_arrow, size: 32.0, color: Colors.black,),
|
|
|
),
|
|
|
),
|
|
|
),
|
|
|
@@ -581,9 +682,10 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
}
|
|
|
|
|
|
Widget _buildPosition(Color iconColor) {
|
|
|
- final position = updateDragDuration ?? (_latestValue != null && _latestValue.position != null
|
|
|
- ? _latestValue.position
|
|
|
- : Duration.zero);
|
|
|
+ final position = updateDragDuration ??
|
|
|
+ (_latestValue != null && _latestValue.position != null
|
|
|
+ ? _latestValue.position
|
|
|
+ : Duration.zero);
|
|
|
final duration = _latestValue != null && _latestValue.duration != null
|
|
|
? _latestValue.duration
|
|
|
: Duration.zero;
|
|
|
@@ -639,8 +741,7 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
|
|
|
Future<Null> _initialize() async {
|
|
|
controller.addListener(_updateState);
|
|
|
-
|
|
|
- _updateState();
|
|
|
+ _latestValue = controller.value;
|
|
|
|
|
|
if ((controller.value != null && controller.value.isPlaying) ||
|
|
|
chewieController.autoPlay) {
|
|
|
@@ -692,10 +793,11 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- void _updateState() {
|
|
|
- setState(() {
|
|
|
- _latestValue = controller.value;
|
|
|
- });
|
|
|
+ void _updateState() async {
|
|
|
+ if (_latestValue.position != controller.value.position)
|
|
|
+ setState(() {
|
|
|
+ _latestValue = controller.value;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
Widget _buildProgressBar() {
|
|
|
@@ -720,7 +822,7 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
|
|
|
ChewieProgressColors(
|
|
|
playedColor: Color(0xFFC7000B),
|
|
|
handleColor: Color(0xFFC7000B),
|
|
|
- bufferedColor: Color(0x5AC7000B),
|
|
|
+ bufferedColor: Color(0x5AC7000B),
|
|
|
backgroundColor: Color(0x5AFFFFFF)),
|
|
|
millionSec: updateDragDuration?.inMilliseconds,
|
|
|
),
|