From 275989439780683b822b2e6c24c15cf844437e31 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Thu, 11 Apr 2024 20:10:45 +0200 Subject: [PATCH] adjusted `RulerSlider` ticks height --- .../ruler_slider/widget_slider_ruler.dart | 73 ++++++++++--------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/lib/screens/shared/ruler_slider/widget_slider_ruler.dart b/lib/screens/shared/ruler_slider/widget_slider_ruler.dart index f9f37ff..537824c 100644 --- a/lib/screens/shared/ruler_slider/widget_slider_ruler.dart +++ b/lib/screens/shared/ruler_slider/widget_slider_ruler.dart @@ -77,43 +77,48 @@ class _Ruler extends StatelessWidget { @override Widget build(BuildContext context) { + final mainTicksFontSize = Theme.of(context).textTheme.bodySmall!.fontSize!; return LayoutBuilder( builder: (context, constraints) { - final bool showAllMainTicks = Dimens.cameraSliderHandleArea * mainTicksCount <= constraints.maxHeight; - return Column( - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: List.generate( - itemsCount, - (index) { - final bool isMainTick = index % 2 == 0.0; - if (!showAllMainTicks && !isMainTick) { - return const SizedBox(); - } - final bool showValue = (index % (showAllMainTicks ? 2 : 4) == 0.0); - return SizedBox( - height: index == itemsCount - 1 || showValue ? Dimens.cameraSliderHandleArea : 1, - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - if (showValue) - Text( - rulerValueAdapter(index / 2 + min), - style: Theme.of(context).textTheme.bodySmall, + final bool showAllMainTicks = + mainTicksFontSize * mainTicksCount + (1 * mainTicksCount - 1) <= constraints.maxHeight; + return Padding( + padding: EdgeInsets.symmetric(vertical: (Dimens.cameraSliderHandleArea - mainTicksFontSize) / 2), + child: Column( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: List.generate( + itemsCount, + (index) { + final bool isMainTick = index % 2 == 0.0; + if (!showAllMainTicks && !isMainTick) { + return const SizedBox(); + } + final bool showValue = (index % (showAllMainTicks ? 2 : 4) == 0.0); + return SizedBox( + height: index == itemsCount - 1 || showValue ? mainTicksFontSize : 1, + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + if (showValue) + Text( + rulerValueAdapter(index / 2 + min), + style: Theme.of(context).textTheme.bodySmall, + ), + const SizedBox(width: Dimens.grid4), + ColoredBox( + color: Theme.of(context).colorScheme.onBackground, + child: SizedBox( + height: 1, + width: isMainTick ? Dimens.grid8 : Dimens.grid4, + ), ), - const SizedBox(width: Dimens.grid4), - ColoredBox( - color: Theme.of(context).colorScheme.onBackground, - child: SizedBox( - height: 1, - width: isMainTick ? Dimens.grid8 : Dimens.grid4, - ), - ), - ], - ), - ); - }, - ).reversed.toList(), + ], + ), + ); + }, + ).reversed.toList(), + ), ); }, );