diff --git a/lib/widgets/story_view.dart b/lib/widgets/story_view.dart index 3a6e8db1..3ff016f5 100644 --- a/lib/widgets/story_view.dart +++ b/lib/widgets/story_view.dart @@ -627,6 +627,8 @@ class StoryViewState extends State with TickerProviderStateMixin { _nextDebouncer = Timer(Duration(milliseconds: 500), () {}); } + bool get _isRightToLeft => Directionality.of(context) == TextDirection.ltr; + @override Widget build(BuildContext context) { return Container( @@ -713,13 +715,15 @@ class StoryViewState extends State with TickerProviderStateMixin { }, )), Align( - alignment: Alignment.centerLeft, + alignment: + _isRightToLeft ? Alignment.centerLeft : Alignment.centerRight, heightFactor: 1, child: SizedBox( - child: GestureDetector(onTap: () { - widget.controller.previous(); - }), - width: 70), + child: GestureDetector(onTap: () { + widget.controller.previous(); + }), + width: MediaQuery.of(context).size.width * 0.2, + ), ), ], ), @@ -792,8 +796,8 @@ class PageBarState extends State { children: widget.pages.map((it) { return Expanded( child: Container( - padding: EdgeInsets.only( - right: widget.pages.last == it ? 0 : this.spacing), + padding: EdgeInsetsDirectional.only( + end: widget.pages.last == it ? 0 : this.spacing), child: StoryProgressIndicator( isPlaying(it) ? widget.animation!.value : (it.shown ? 1 : 0), indicatorHeight: @@ -833,10 +837,12 @@ class StoryProgressIndicator extends StatelessWidget { foregroundPainter: IndicatorOval( this.indicatorForegroundColor?? Colors.white.withOpacity(0.8), this.value, + Directionality.of(context), ), painter: IndicatorOval( this.indicatorColor?? Colors.white.withOpacity(0.4), 1.0, + Directionality.of(context), ), ); } @@ -845,16 +851,22 @@ class StoryProgressIndicator extends StatelessWidget { class IndicatorOval extends CustomPainter { final Color color; final double widthFactor; + final TextDirection direction; - IndicatorOval(this.color, this.widthFactor); + IndicatorOval(this.color, this.widthFactor, this.direction); @override void paint(Canvas canvas, Size size) { final paint = Paint()..color = this.color; + final double left = direction == TextDirection.ltr ? 0 : size.width; + final double width = direction == TextDirection.ltr + ? size.width * this.widthFactor + : size.width * -this.widthFactor; canvas.drawRRect( RRect.fromRectAndRadius( - Rect.fromLTWH(0, 0, size.width * this.widthFactor, size.height), - Radius.circular(3)), + Rect.fromLTWH(left, 0, width, size.height), + Radius.circular(3), + ), paint); }