Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-05-25 13:18:59 +08:00
parent 525dce989b
commit 94063ab1f9
11 changed files with 175 additions and 187 deletions

View File

@@ -43,6 +43,7 @@ class ProgressBar extends LeafRenderObjectWidget {
required this.thumbGlowColor,
this.thumbGlowRadius = 30.0,
this.thumbCanPaintOutsideBar = true,
this.strokeCap = .round,
});
/// The elapsed playing time of the media.
@@ -170,6 +171,8 @@ class ProgressBar extends LeafRenderObjectWidget {
/// is happening during this time, though.
final bool thumbCanPaintOutsideBar;
final StrokeCap strokeCap;
@override
RenderObject createRenderObject(BuildContext context) {
return RenderProgressBar(
@@ -189,6 +192,7 @@ class ProgressBar extends LeafRenderObjectWidget {
thumbGlowColor: thumbGlowColor,
thumbGlowRadius: thumbGlowRadius,
thumbCanPaintOutsideBar: thumbCanPaintOutsideBar,
strokeCap: strokeCap,
);
}
@@ -336,6 +340,7 @@ class RenderProgressBar extends RenderBox implements MouseTrackerAnnotation {
required this._thumbGlowColor,
double thumbGlowRadius = 30.0,
this._thumbCanPaintOutsideBar = true,
required this._strokeCap,
}) : _onDragStartUserCallback = onDragStart,
_onDragUpdateUserCallback = onDragUpdate,
_onDragEndUserCallback = onDragEnd,
@@ -363,6 +368,8 @@ class RenderProgressBar extends RenderBox implements MouseTrackerAnnotation {
super.dispose();
}
final StrokeCap _strokeCap;
// This is the gesture recognizer used to move the thumb.
_EagerHorizontalDragGestureRecognizer? _drag;
@@ -690,7 +697,9 @@ class RenderProgressBar extends RenderBox implements MouseTrackerAnnotation {
_drawBaseBar(canvas, localSize);
_drawBufferedBar(canvas, localSize);
_drawCurrentProgressBar(canvas, localSize);
_drawThumb(canvas, localSize);
if (thumbRadius > 0.0) {
_drawThumb(canvas, localSize);
}
canvas.restore();
}
@@ -729,7 +738,7 @@ class RenderProgressBar extends RenderBox implements MouseTrackerAnnotation {
}) {
final baseBarPaint = Paint()
..color = color
..strokeCap = .square
..strokeCap = _strokeCap
..strokeWidth = _barHeight;
final capRadius = _barHeight / 2;
final adjustedWidth = availableSize.width - barHeight;

View File

@@ -1,3 +1,5 @@
import 'dart:io' show Platform;
import 'package:flutter/gestures.dart' show PointerDeviceKind;
import 'package:flutter/material.dart';
@@ -16,17 +18,26 @@ class CustomScrollBehavior extends MaterialScrollBehavior {
BuildContext context,
Widget child,
ScrollableDetails details,
) => child;
) {
if (Platform.isAndroid) {
return StretchingOverscrollIndicator(
axisDirection: details.direction,
clipBehavior: details.decorationClipBehavior ?? .hardEdge,
child: child,
);
}
return child;
}
@override
Set<PointerDeviceKind> get dragDevices => desktopDragDevices;
}
const Set<PointerDeviceKind> desktopDragDevices = <PointerDeviceKind>{
PointerDeviceKind.touch,
PointerDeviceKind.stylus,
PointerDeviceKind.invertedStylus,
PointerDeviceKind.trackpad,
PointerDeviceKind.unknown,
PointerDeviceKind.mouse,
const Set<PointerDeviceKind> desktopDragDevices = {
.touch,
.stylus,
.invertedStylus,
.trackpad,
.unknown,
.mouse,
};