opt: viewpoint

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-01-13 10:56:14 +08:00
parent c63a32bd47
commit 042b69cc05
4 changed files with 113 additions and 82 deletions

View File

@@ -46,73 +46,87 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
return Padding(
padding: const EdgeInsets.only(left: 10, right: 10, bottom: 7),
child: Semantics(
// label: '${(value / max * 100).round()}%',
value: '${(value / max * 100).round()}%',
// enabled: false,
child: Stack(
alignment: Alignment.center,
children: [
ProgressBar(
progress: Duration(seconds: value),
buffered: Duration(seconds: buffer),
total: Duration(seconds: max),
progressBarColor: colorTheme,
baseBarColor: Colors.white.withOpacity(0.2),
bufferedBarColor: colorTheme.withOpacity(0.4),
timeLabelLocation: TimeLabelLocation.none,
thumbColor: colorTheme,
barHeight: 3.5,
thumbRadius: 7,
onDragStart: (duration) {
feedBack();
controller!.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;
});
}
controller!
.onUpdatedSliderProgress(duration.timeStamp);
},
onSeek: (duration) {
controller!.onChangedSliderEnd();
controller!
.onChangedSlider(duration.inSeconds.toDouble());
controller!.seekTo(
Duration(seconds: duration.inSeconds),
type: 'slider');
SemanticsService.announce(
"${(duration.inSeconds / max * 100).round()}%",
TextDirection.ltr);
},
// label: '${(value / max * 100).round()}%',
value: '${(value / max * 100).round()}%',
// enabled: false,
child: Stack(
alignment: Alignment.bottomCenter,
children: [
ProgressBar(
progress: Duration(seconds: value),
buffered: Duration(seconds: buffer),
total: Duration(seconds: max),
progressBarColor: colorTheme,
baseBarColor: Colors.white.withOpacity(0.2),
bufferedBarColor: colorTheme.withOpacity(0.4),
timeLabelLocation: TimeLabelLocation.none,
thumbColor: colorTheme,
barHeight: 3.5,
thumbRadius: 7,
onDragStart: (duration) {
feedBack();
controller!.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;
});
}
controller!
.onUpdatedSliderProgress(duration.timeStamp);
},
onSeek: (duration) {
controller!.onChangedSliderEnd();
controller!
.onChangedSlider(duration.inSeconds.toDouble());
controller!.seekTo(
Duration(seconds: duration.inSeconds),
type: 'slider');
SemanticsService.announce(
"${(duration.inSeconds / max * 100).round()}%",
TextDirection.ltr);
},
),
if (controller?.segmentList.isNotEmpty == true)
Positioned(
left: 0,
right: 0,
bottom: 5.25,
child: IgnorePointer(
child: CustomPaint(
size: Size(double.infinity, 3.5),
painter: SegmentProgressBar(
segmentColors: controller!.segmentList,
),
),
),
),
if (controller?.segmentList.isNotEmpty == true)
CustomPaint(
size: Size(double.infinity, 3.5),
painter: SegmentProgressBar(
segmentColors: controller!.segmentList,
if (controller?.viewPointList.isNotEmpty == true &&
controller?.showVP.value == true)
Positioned(
left: 0,
right: 0,
bottom: 5.25,
child: IgnorePointer(
child: CustomPaint(
size: Size(double.infinity, 3.5),
painter: SegmentProgressBar(
segmentColors: controller!.viewPointList,
),
),
),
if (controller?.viewPointList.isNotEmpty == true &&
controller?.showVP.value == true)
CustomPaint(
size: Size(double.infinity, 3.5),
painter: SegmentProgressBar(
segmentColors: controller!.viewPointList,
),
),
],
)),
),
],
),
),
);
},
),