Skip to content

Commit

Permalink
Merge pull request #4 from felixgabler/small_lines
Browse files Browse the repository at this point in the history
Make it possible to specify how many small lines should be between big lines
  • Loading branch information
loonix authored Feb 14, 2022
2 parents 8dc834f + 18373e6 commit 5e2f3bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,14 +503,15 @@ use `FlutterSliderHatchMark` class which has following properties:
2. `bigLine`: The widget of big lines in hatch mark
3. `smallLine`: The widget of small lines in hatch mark
4. `linesAlignment`: the direct of lines, `right` or `left` which works as `top` or `bottom` on horizontal slider
5. `density`: The amount of lines per percent. 1 is default. any number less or more than 1 will decrease and increase lines respectively
6. `displayLines`: to display lines. by default is `false` for the sake of optimization
5. `density`: The number of lines per percent. 1 is default. any number less or more than 1 will decrease and increase lines respectively
6. `smallDensity`: The number of small lines between any two big lines. 4 is default. any number less or more than 4 will decrease and increase lines respectively.
7. `displayLines`: to display lines. by default is `false` for the sake of optimization

7. `labels`: If you want to display some label or text at certain percent in your hatch mark, you can use `labels`
8. `labelBox`: The widget of label box, however, you can define a widget for each label and have it's own style
9. `labelsDistanceFromTrackBar`: The distance of labels from slider. can be negative
8. `labels`: If you want to display some label or text at certain percent in your hatch mark, you can use `labels`
9. `labelBox`: The widget of label box, however, you can define a widget for each label and have it's own style
10. `labelsDistanceFromTrackBar`: The distance of labels from slider. can be negative

10. `disabled`: to disabled the whole hatchmark ( hide )
11. `disabled`: to disabled the whole hatchmark ( hide )

**labels alignment is center**

Expand Down
9 changes: 7 additions & 2 deletions lib/another_xlider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ class _FlutterSliderState extends State<FlutterSlider>
FlutterSliderHatchMark hatchMark = FlutterSliderHatchMark();
hatchMark.disabled = widget.hatchMark!.disabled;
hatchMark.density = widget.hatchMark!.density;
hatchMark.smallDensity = widget.hatchMark!.smallDensity;
hatchMark.linesDistanceFromTrackBar =
widget.hatchMark!.linesDistanceFromTrackBar ?? 0;
hatchMark.labelsDistanceFromTrackBar =
Expand Down Expand Up @@ -518,7 +519,7 @@ class _FlutterSliderState extends State<FlutterSlider>
for (int p = 0; p <= percent; p++) {
FlutterSliderSizedBox? barLineBox = hatchMark.smallLine;

if (p % 5 - 1 == -1) {
if (p % (hatchMark.smallDensity + 1) == 0) {
barLineBox = hatchMark.bigLine;
}

Expand Down Expand Up @@ -2606,13 +2607,16 @@ class FlutterSliderHatchMark {
List<FlutterSliderHatchMarkLabel>? labels;
FlutterSliderSizedBox? smallLine;
FlutterSliderSizedBox? bigLine;
/// How many small lines to display between two big lines
int smallDensity;
FlutterSliderSizedBox? labelBox;
FlutterSliderHatchMarkAlignment linesAlignment;
bool? displayLines;

FlutterSliderHatchMark(
{this.disabled = false,
this.density = 1,
this.smallDensity = 4,
this.linesDistanceFromTrackBar,
this.labelsDistanceFromTrackBar,
this.labels,
Expand All @@ -2621,7 +2625,8 @@ class FlutterSliderHatchMark {
this.linesAlignment = FlutterSliderHatchMarkAlignment.right,
this.labelBox,
this.displayLines})
: assert(density > 0 && density <= 2);
: assert(density > 0 && density <= 2),
assert(smallDensity >= 0);

@override
String toString() {
Expand Down

0 comments on commit 5e2f3bf

Please sign in to comment.