adjusted RulerSlider ticks height

This commit is contained in:
Vadim 2024-04-11 20:10:45 +02:00
parent 06f6e45bcb
commit 2759894397

View file

@ -77,43 +77,48 @@ class _Ruler extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final mainTicksFontSize = Theme.of(context).textTheme.bodySmall!.fontSize!;
return LayoutBuilder( return LayoutBuilder(
builder: (context, constraints) { builder: (context, constraints) {
final bool showAllMainTicks = Dimens.cameraSliderHandleArea * mainTicksCount <= constraints.maxHeight; final bool showAllMainTicks =
return Column( mainTicksFontSize * mainTicksCount + (1 * mainTicksCount - 1) <= constraints.maxHeight;
crossAxisAlignment: CrossAxisAlignment.end, return Padding(
mainAxisAlignment: MainAxisAlignment.spaceBetween, padding: EdgeInsets.symmetric(vertical: (Dimens.cameraSliderHandleArea - mainTicksFontSize) / 2),
children: List.generate( child: Column(
itemsCount, crossAxisAlignment: CrossAxisAlignment.end,
(index) { mainAxisAlignment: MainAxisAlignment.spaceBetween,
final bool isMainTick = index % 2 == 0.0; children: List.generate(
if (!showAllMainTicks && !isMainTick) { itemsCount,
return const SizedBox(); (index) {
} final bool isMainTick = index % 2 == 0.0;
final bool showValue = (index % (showAllMainTicks ? 2 : 4) == 0.0); if (!showAllMainTicks && !isMainTick) {
return SizedBox( return const SizedBox();
height: index == itemsCount - 1 || showValue ? Dimens.cameraSliderHandleArea : 1, }
child: Row( final bool showValue = (index % (showAllMainTicks ? 2 : 4) == 0.0);
mainAxisAlignment: MainAxisAlignment.end, return SizedBox(
children: [ height: index == itemsCount - 1 || showValue ? mainTicksFontSize : 1,
if (showValue) child: Row(
Text( mainAxisAlignment: MainAxisAlignment.end,
rulerValueAdapter(index / 2 + min), children: [
style: Theme.of(context).textTheme.bodySmall, 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, ).reversed.toList(),
width: isMainTick ? Dimens.grid8 : Dimens.grid4, ),
),
),
],
),
);
},
).reversed.toList(),
); );
}, },
); );