mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: 代码优化
This commit is contained in:
@@ -73,10 +73,10 @@ class _PlDanmakuState extends State<PlDanmaku> {
|
||||
// 播放器状态监听
|
||||
void playerListener(PlayerStatus? status) {
|
||||
if (status == PlayerStatus.paused) {
|
||||
_controller!.pause();
|
||||
_controller?.pause();
|
||||
}
|
||||
if (status == PlayerStatus.playing) {
|
||||
_controller!.onResume();
|
||||
_controller?.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -553,7 +553,9 @@ class PlPlayerController {
|
||||
|
||||
/// 触发回调事件
|
||||
for (var element in _statusListeners) {
|
||||
element(event ? PlayerStatus.playing : PlayerStatus.paused);
|
||||
if (element != null) {
|
||||
element(event ? PlayerStatus.playing : PlayerStatus.paused);
|
||||
}
|
||||
}
|
||||
if (videoPlayerController!.state.position.inSeconds != 0) {
|
||||
makeHeartBeat(positionSeconds.value, type: 'status');
|
||||
|
||||
@@ -655,36 +655,36 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
timeLabelLocation: TimeLabelLocation.none,
|
||||
thumbColor: colorTheme,
|
||||
barHeight: 3.5,
|
||||
thumbRadius: draggingFixedProgressBar.value ? 7 : 4,
|
||||
onDragStart: (duration) {
|
||||
draggingFixedProgressBar.value = true;
|
||||
feedBack();
|
||||
_.onChangedSliderStart();
|
||||
},
|
||||
onDragUpdate: (duration) {
|
||||
double newProgress = duration.timeStamp.inSeconds / max;
|
||||
if ((newProgress - _lastAnnouncedValue).abs() > 0.02) {
|
||||
_accessibilityDebounce?.cancel();
|
||||
_accessibilityDebounce =
|
||||
Timer(const Duration(milliseconds: 200), () {
|
||||
SemanticsService.announce(
|
||||
"${(newProgress * 100).round()}%",
|
||||
TextDirection.ltr);
|
||||
_lastAnnouncedValue = newProgress;
|
||||
});
|
||||
}
|
||||
_.onUpdatedSliderProgress(duration.timeStamp);
|
||||
},
|
||||
onSeek: (duration) {
|
||||
draggingFixedProgressBar.value = false;
|
||||
_.onChangedSliderEnd();
|
||||
_.onChangedSlider(duration.inSeconds.toDouble());
|
||||
_.seekTo(Duration(seconds: duration.inSeconds),
|
||||
type: 'slider');
|
||||
SemanticsService.announce(
|
||||
"${(duration.inSeconds / max * 100).round()}%",
|
||||
TextDirection.ltr);
|
||||
},
|
||||
thumbRadius: draggingFixedProgressBar.value ? 7 : 2.5,
|
||||
// onDragStart: (duration) {
|
||||
// draggingFixedProgressBar.value = true;
|
||||
// feedBack();
|
||||
// _.onChangedSliderStart();
|
||||
// },
|
||||
// onDragUpdate: (duration) {
|
||||
// double newProgress = duration.timeStamp.inSeconds / max;
|
||||
// if ((newProgress - _lastAnnouncedValue).abs() > 0.02) {
|
||||
// _accessibilityDebounce?.cancel();
|
||||
// _accessibilityDebounce =
|
||||
// Timer(const Duration(milliseconds: 200), () {
|
||||
// SemanticsService.announce(
|
||||
// "${(newProgress * 100).round()}%",
|
||||
// TextDirection.ltr);
|
||||
// _lastAnnouncedValue = newProgress;
|
||||
// });
|
||||
// }
|
||||
// _.onUpdatedSliderProgress(duration.timeStamp);
|
||||
// },
|
||||
// onSeek: (duration) {
|
||||
// draggingFixedProgressBar.value = false;
|
||||
// _.onChangedSliderEnd();
|
||||
// _.onChangedSlider(duration.inSeconds.toDouble());
|
||||
// _.seekTo(Duration(seconds: duration.inSeconds),
|
||||
// type: 'slider');
|
||||
// SemanticsService.announce(
|
||||
// "${(duration.inSeconds / max * 100).round()}%",
|
||||
// TextDirection.ltr);
|
||||
// },
|
||||
),
|
||||
// SlideTransition(
|
||||
// position: Tween<Offset>(
|
||||
|
||||
@@ -6,6 +6,9 @@ class Grid {
|
||||
static double calculateActualWidth(BuildContext context, double maxCrossAxisExtent, double crossAxisSpacing) {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
int columnCount = ((screenWidth - crossAxisSpacing) / (maxCrossAxisExtent + crossAxisSpacing)).ceil();
|
||||
if (columnCount < 1){
|
||||
columnCount = 1;
|
||||
}
|
||||
double columnWidth = (screenWidth - crossAxisSpacing) ~/ columnCount - crossAxisSpacing;
|
||||
return columnWidth;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user