Skip to content

Commit

Permalink
fix: pen modal not expanding in
Browse files Browse the repository at this point in the history
  • Loading branch information
adil192 committed Mar 27, 2024
1 parent 33a500d commit ad677ed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
20 changes: 12 additions & 8 deletions lib/components/toolbar/size_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class SizePicker extends StatefulWidget {

@override
State<SizePicker> createState() => _SizePickerState();

static const double smallLength = 25;
static const double largeLength = 150;
}

/// Returns a string representation of [num] that:
Expand Down Expand Up @@ -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.
///
Expand All @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions lib/components/toolbar/toolbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -212,10 +213,11 @@ class _ToolbarState extends State<Toolbar> {
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,
Expand Down

0 comments on commit ad677ed

Please sign in to comment.