refactor progress bar

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-06-26 12:45:41 +08:00
parent 2ba6f0d063
commit a623ceee47
12 changed files with 263 additions and 391 deletions

View File

@@ -27,24 +27,22 @@ class BottomControl extends StatelessWidget {
void onDragStart(ThumbDragDetails duration) {
feedBack();
controller.onChangedSliderStart(duration.timeStamp);
controller
..position.value = duration.seconds
..isSeeking.value = true;
}
void onDragUpdate(ThumbDragDetails duration) {
if (!controller.isFileSource && controller.showSeekPreview) {
controller.updatePreviewIndex(duration.timeStamp.inSeconds);
controller.updatePreviewIndex(duration.seconds);
}
controller.onUpdatedSliderProgress(duration.timeStamp);
controller.position.value = duration.seconds;
}
void onSeek(Duration duration) {
if (controller.showSeekPreview) {
controller.showPreview.value = false;
}
void onSeek(int milliseconds) {
controller
..onChangedSliderEnd()
..onChangedSlider(duration.inSeconds)
..seekTo(Duration(seconds: duration.inSeconds), isSeek: false);
..onSeekEnd()
..seekTo(Duration(milliseconds: milliseconds), isSeek: false);
}
@override
@@ -70,15 +68,11 @@ class BottomControl extends StatelessWidget {
clipBehavior: Clip.none,
alignment: Alignment.bottomCenter,
children: [
Obx(() {
final int value = controller.sliderPositionSeconds.value;
final int max = controller.duration.value.inSeconds;
return ProgressBar(
progress: Duration(seconds: value),
buffered: Duration(
seconds: controller.bufferedSeconds.value,
),
total: Duration(seconds: max),
Obx(
() => ProgressBar(
progress: controller.position.value,
buffered: controller.buffered.value,
total: controller.duration.value,
progressBarColor: primary,
baseBarColor: const Color(0x33FFFFFF),
bufferedBarColor: bufferedBarColor,
@@ -90,8 +84,8 @@ class BottomControl extends StatelessWidget {
onDragStart: onDragStart,
onDragUpdate: onDragUpdate,
onSeek: onSeek,
);
}),
),
),
if (controller.enableBlock &&
videoDetailController.segmentProgressList.isNotEmpty)
Positioned(