From ad677ed6f256d80de19add6982c4f9c8d666511a Mon Sep 17 00:00:00 2001 From: Adil Hanney Date: Wed, 27 Mar 2024 08:16:39 +0000 Subject: [PATCH] fix: pen modal not expanding in --- lib/components/toolbar/size_picker.dart | 20 ++++++++++++-------- lib/components/toolbar/toolbar.dart | 6 ++++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/components/toolbar/size_picker.dart b/lib/components/toolbar/size_picker.dart index 64e09843e..b14889397 100644 --- a/lib/components/toolbar/size_picker.dart +++ b/lib/components/toolbar/size_picker.dart @@ -16,6 +16,9 @@ class SizePicker extends StatefulWidget { @override State createState() => _SizePickerState(); + + static const double smallLength = 25; + static const double largeLength = 150; } /// Returns a string representation of [num] that: @@ -75,9 +78,6 @@ class _SizeSlider extends StatelessWidget { final Axis axis; final void Function(void Function()) setState; - static const double _smallLength = 25; - static const double _largeLength = 150; - /// [percent] is a value between 0 and 1 /// where 0 is the start of the slider and 1 is the end. /// @@ -97,21 +97,25 @@ class _SizeSlider extends StatelessWidget { final colorScheme = Theme.of(context).colorScheme; return GestureDetector( onHorizontalDragStart: axis == Axis.horizontal - ? (details) => onDrag(details.localPosition.dx / _largeLength) + ? (details) => + onDrag(details.localPosition.dx / SizePicker.largeLength) : null, onHorizontalDragUpdate: axis == Axis.horizontal - ? (details) => onDrag(details.localPosition.dx / _largeLength) + ? (details) => + onDrag(details.localPosition.dx / SizePicker.largeLength) : null, onVerticalDragStart: axis == Axis.vertical - ? (details) => onDrag(details.localPosition.dy / _largeLength) + ? (details) => + onDrag(details.localPosition.dy / SizePicker.largeLength) : null, onVerticalDragUpdate: axis == Axis.vertical - ? (details) => onDrag(details.localPosition.dy / _largeLength) + ? (details) => + onDrag(details.localPosition.dy / SizePicker.largeLength) : null, child: RotatedBox( quarterTurns: axis == Axis.horizontal ? 0 : 1, child: CustomPaint( - size: const Size(_largeLength, _smallLength), + size: const Size(SizePicker.largeLength, SizePicker.smallLength), painter: _SizeSliderPainter( axis: axis, minSize: pen.sizeMin, diff --git a/lib/components/toolbar/toolbar.dart b/lib/components/toolbar/toolbar.dart index d7179df01..2cd3cf3f9 100644 --- a/lib/components/toolbar/toolbar.dart +++ b/lib/components/toolbar/toolbar.dart @@ -11,6 +11,7 @@ import 'package:saber/components/toolbar/color_bar.dart'; import 'package:saber/components/toolbar/export_bar.dart'; import 'package:saber/components/toolbar/pen_modal.dart'; import 'package:saber/components/toolbar/selection_bar.dart'; +import 'package:saber/components/toolbar/size_picker.dart'; import 'package:saber/components/toolbar/toolbar_button.dart'; import 'package:saber/data/editor/page.dart'; import 'package:saber/data/extensions/color_extensions.dart'; @@ -212,10 +213,11 @@ class _ToolbarState extends State { axis: isToolbarVertical ? CollapsibleAxis.horizontal : CollapsibleAxis.vertical, - maintainState: false, + maintainState: true, collapsed: toolOptionsType == ToolOptions.hide, child: switch (toolOptionsType) { - ToolOptions.hide => const SizedBox(), + ToolOptions.hide => + const SizedBox.square(dimension: SizePicker.smallLength), ToolOptions.pen => PenModal( getTool: () => Pen.currentPen, setTool: widget.setTool,