Skip to content

Commit

Permalink
version 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ali.azmoude@gmail.com authored and ali.azmoude@gmail.com committed Mar 12, 2020
1 parent 767499c commit d3111f5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
.dart_tool/
.idea/

.packages
.pub/
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,11 @@

## [3.1.1] - 02/05/2020

* tooltip related bug: `The getter 'boxStyle' was called on null` fixed
* tooltip related bug: `The getter 'boxStyle' was called on null` fixed

## [3.2.0] - 03/12/2020

* tooltip value formatting feature added
* disabled trackbar draggable feature added
* trackbar reported bug: ` the active track bar is draggable even when it's not a range slider` fixed
* selectByTap positioning bug fixed
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,22 @@ FlutterSlider(
![](images/range-tooltip-prefix-suffix.gif)


### Tooltip Format

If you want to change the format of the value of tooltip you can use `format` method.

```dart
FlutterSlider(
...
tooltip: FlutterSliderTooltip(
format: (String value) {
return value + ' ! ';
}
),
...
)
```

### Tooltip Callback

If you want to fully change tooltip widget and use your own customized widget, you can use `custom` function.
Expand Down Expand Up @@ -416,7 +432,7 @@ FlutterSlider(

### Locked Handlers

If you want to lock your handlers by a certain value, you can use `lockedHandlers` and `lockedDistance` properties
If you want to lock your handlers by a certain value, you can use `lockHandlers` and `lockDistance` properties

```dart
FlutterSlider(
Expand Down Expand Up @@ -593,8 +609,8 @@ FlutterSlider(
new DateTime(2019,6,1,0,0,0).millisecondsSinceEpoch.toDouble(), // lower date : 2019-06-01
new DateTime(2019,9,1,0,0,0).millisecondsSinceEpoch.toDouble(), // upper date : 2019-09-01
],
max: new DateTime(2020,1,1,0,0,0).millisecondsSinceEpoch.toDouble(), // start date : 2019-01-01
min: new DateTime(2019,1,1,0,0,0).millisecondsSinceEpoch.toDouble(), // finish date : 2020-01-01
min: new DateTime(2019,1,1,0,0,0).millisecondsSinceEpoch.toDouble(), // start date : 2019-01-01
max: new DateTime(2020,1,1,0,0,0).millisecondsSinceEpoch.toDouble(), // finish date : 2020-01-01
step: 86400, // 1 day
...
Expand Down
40 changes: 20 additions & 20 deletions lib/flutter_xlider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,17 @@ class _FlutterSliderState extends State<FlutterSlider>
}

drawHandlers() {
Widget draggable = Draggable(
axis: widget.axis,
feedback: Container(),
child: Container(
color: Colors.redAccent,
));
if (!widget.rangeSlider ||
(widget.trackBar != null && !widget.trackBar.activeTrackBarDraggable)) {
draggable = Container();
}

List<Positioned> items = []..addAll([
Function.apply(_inactiveTrack, []),
Function.apply(_centralWidget, []),
Expand Down Expand Up @@ -1648,10 +1659,10 @@ class _FlutterSliderState extends State<FlutterSlider>

if (widget.axis == Axis.horizontal) {
tappedPositionWithPadding =
_handlersWidth + (_touchSize) - xDragTmp;
_handlersWidth / 2 + (_touchSize) - xDragTmp;
} else {
tappedPositionWithPadding =
_handlersHeight + (_touchSize) - yDragTmp;
_handlersHeight / 2 + (_touchSize) - yDragTmp;
}

if (_distanceFromLeftHandler < _distanceFromRightHandler) {
Expand Down Expand Up @@ -1708,16 +1719,7 @@ class _FlutterSliderState extends State<FlutterSlider>

setState(() {});
},
child: Visibility(
visible: widget.trackBar.activeTrackBarDraggable,
child: Draggable(
axis: widget.axis,
feedback: Container(),
child: Container(
color: Colors.redAccent,
),
),
),
child: draggable,
),
)));

Expand Down Expand Up @@ -1752,10 +1754,8 @@ class _FlutterSliderState extends State<FlutterSlider>
suffix = _tooltipData.rightSuffix ?? Container();
}
String numberFormat = value.toString();

if (_tooltipData.formatValue != null) {
numberFormat = _tooltipData.formatValue(value);
}
if (_tooltipData.format != null)
numberFormat = _tooltipData.format(numberFormat);

Widget tooltipWidget = IgnorePointer(
child: Center(
Expand Down Expand Up @@ -2164,7 +2164,7 @@ class FlutterSliderHandler {

class FlutterSliderTooltip {
Widget Function(dynamic value) custom;
String Function(dynamic value) formatValue;
String Function(String value) format;
TextStyle textStyle;
FlutterSliderTooltipBox boxStyle;
Widget leftPrefix;
Expand All @@ -2176,7 +2176,7 @@ class FlutterSliderTooltip {

FlutterSliderTooltip(
{this.custom,
this.formatValue,
this.format,
this.textStyle,
this.boxStyle,
this.leftPrefix,
Expand Down Expand Up @@ -2225,22 +2225,22 @@ class FlutterSliderTooltipBox {
class FlutterSliderTrackBar {
final BoxDecoration inactiveTrackBar;
final BoxDecoration activeTrackBar;
final bool activeTrackBarDraggable;
final Color activeDisabledTrackBarColor;
final Color inactiveDisabledTrackBarColor;
final double activeTrackBarHeight;
final double inactiveTrackBarHeight;
final Widget centralWidget;
final bool activeTrackBarDraggable;

const FlutterSliderTrackBar({
this.inactiveTrackBar,
this.activeTrackBar,
this.activeTrackBarDraggable = true,
this.activeDisabledTrackBarColor = const Color(0xffb5b5b5),
this.inactiveDisabledTrackBarColor = const Color(0xffe5e5e5),
this.activeTrackBarHeight = 3.5,
this.inactiveTrackBarHeight = 3,
this.centralWidget,
this.activeTrackBarDraggable = true,
}) : assert(activeTrackBarHeight != null &&
activeTrackBarHeight > 0 &&
inactiveTrackBarHeight != null &&
Expand Down
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: flutter_xlider
description: (Flutter Xlider) A material design slider and range slider, horizontal and vertical, with RTL support and lots of options and customizations for flutter
version: 3.2.0
author: Ali Azmoude <ali.azmoude@gmail.com>
homepage: https://github.com/Ali-Azmoud/flutter_xlider

environment:
Expand Down

0 comments on commit d3111f5

Please sign in to comment.