xclud / flutter_crop

Crop any widget/image in Android, iOS, Web and Desktop with fancy and customizable UI, in pure Dart code.
https://pub.dev/packages/crop
MIT License
259 stars 84 forks source link

Drop in replacement slider #26

Closed deakjahn closed 3 years ago

deakjahn commented 4 years ago

A slider with a tape measure look:

Annotation 2020-07-18 230217

There will be a snapping effect around the main ticks (the green ones, 45, 90, etc degrees in my sample).

The code is not very nice, I know, I needed to copy quite large a part of the original slider.dart just to be able to modify the drawing of the ticks. The original Slider simply calculates if there are too many ticks and decides not to draw at all in that case. Because we don't draw every tick now, this calculation is wrong.

You can easily use it in your existing example as:

TapeMeasureSlider(
  value: _rotation,
  min: -180,
  max: 180,
  divisions: 361,
  smallTickEvery: 5,
  bigTickEvery: 15,
  mainTickEvery: 45,
  mainSnapDistance: 3,
  tickColor: Colors.black54,
  onChanged: (angle) {
    setState(() {
      _rotation = angle.roundToDouble();
      controller.rotation = _rotation;
    });
  },
),
deakjahn commented 4 years ago

@xclud Changed the thumb coloring a bit, it's more visible now.

xclud commented 4 years ago

Thank you for whole lot of contributions. Please give me some time to review :)

deakjahn commented 4 years ago

Oh, I will, I will, but I probably go forth and take a look at that other, outdated PR with the rotate gesture because I need everything, including the kitchen sink. :-)