This commit is contained in:
Moustapha Kodjo Amadou 2025-01-21 15:53:10 +01:00
parent 478c408db7
commit e139dc3247

View file

@ -1476,6 +1476,9 @@ class _MangaChapterPageGalleryState
.watch(currentIndexProvider(chapter));
return SliderTheme(
data: SliderTheme.of(context).copyWith(
valueIndicatorShape:
_CustomValueIndicatorShape(
tranform: _isReverseHorizontal),
overlayShape:
const RoundSliderOverlayShape(
overlayRadius: 5.0),
@ -2378,3 +2381,61 @@ class CustomPopupMenuButton<T> extends StatelessWidget {
);
}
}
class _CustomValueIndicatorShape extends SliderComponentShape {
final _indicatorShape = const PaddleSliderValueIndicatorShape();
final bool tranform;
const _CustomValueIndicatorShape({this.tranform = false});
@override
Size getPreferredSize(bool isEnabled, bool isDiscrete) {
return const Size(40, 40);
}
@override
void paint(PaintingContext context, Offset center,
{required Animation<double> activationAnimation,
required Animation<double> enableAnimation,
required bool isDiscrete,
required TextPainter labelPainter,
required RenderBox parentBox,
required SliderThemeData sliderTheme,
required TextDirection textDirection,
required double value,
required double textScaleFactor,
required Size sizeWithOverflow}) {
final textSpan = TextSpan(
text: labelPainter.text?.toPlainText(),
style: sliderTheme.valueIndicatorTextStyle,
);
final textPainter = TextPainter(
text: textSpan,
textAlign: labelPainter.textAlign,
textDirection: textDirection,
);
textPainter.layout();
context.canvas.save();
context.canvas.translate(center.dx, center.dy);
context.canvas.scale(tranform ? -1.0 : 1.0, 1.0);
context.canvas.translate(-center.dx, -center.dy);
_indicatorShape.paint(
context,
center,
activationAnimation: activationAnimation,
enableAnimation: enableAnimation,
labelPainter: textPainter,
parentBox: parentBox,
sliderTheme: sliderTheme,
value: value,
textScaleFactor: textScaleFactor,
sizeWithOverflow: sizeWithOverflow,
isDiscrete: isDiscrete,
textDirection: textDirection,
);
context.canvas.restore();
}
}