Skip to content

Commit ced5193

Browse files
Macos slider (#337)
* chore: run flutter format . * chore: fix analysis * chore: Bump version and update CHANGELOG.md * chore: Update images to self taken ones as MacOS images are outdated * fix: fix position offset by a small value * fix: PR review feedback * Update lib/src/indicators/slider.dart --------- Co-authored-by: Reuben Turner <groovinchip@gmail.com>
1 parent 9894aba commit ced5193

File tree

10 files changed

+552
-7
lines changed

10 files changed

+552
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## [1.9.0]
2+
* Implement `MacosSlider`
3+
14
## [1.8.0]
25
🚨 Breaking Changes 🚨
36
* `ContentArea.builder` has been changed from a `ScrollableWidgetBuilder` to a `WidgetBuilder` due to

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,29 @@ CapacityIndicator(
858858

859859
You can set `discrete` to `true` to make it a discrete capacity indicator.
860860

861+
### MacosSlider
862+
863+
A slider is a control that lets people select a value from a continuous or discrete range of values by moving the slider thumb.
864+
865+
Continuous | Discrete |
866+
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
867+
| ![Continuous Slider Example](https://i.imgur.com/dc4YjoX.png) | ![Discrete Slider Example](https://i.imgur.com/KckOTUf.png) |
868+
| A horizontal slider where any value continuous value between a min and max can be selected | A horizontal slider where only discrete values between a min and max can be selected. Tick marks are often displayed to provide context. |
869+
870+
871+
Here's an example of how to create an interactive continuous slider:
872+
873+
```dart
874+
double value = 0.5;
875+
876+
MacosSlider(
877+
value: value,
878+
onChanged: (v) {
879+
setState(() => value = v);
880+
},
881+
),
882+
```
883+
861884
### RatingIndicator
862885

863886
A rating indicator uses a series of horizontally arranged graphical symbols to communicate a ranking level. The default

example/lib/pages/indicators_page.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class IndicatorsPage extends StatefulWidget {
1111

1212
class _IndicatorsPageState extends State<IndicatorsPage> {
1313
double ratingValue = 0;
14-
double sliderValue = 0;
14+
double capacitorValue = 0;
15+
double sliderValue = 0.3;
1516

1617
@override
1718
Widget build(BuildContext context) {
@@ -48,6 +49,17 @@ class _IndicatorsPageState extends State<IndicatorsPage> {
4849
onChanged: (v) => setState(() => sliderValue = v),
4950
),
5051
const SizedBox(height: 20),
52+
MacosSlider(
53+
value: sliderValue,
54+
onChanged: (v) => setState(() => sliderValue = v),
55+
),
56+
const SizedBox(height: 20),
57+
MacosSlider(
58+
value: sliderValue,
59+
discrete: true,
60+
onChanged: (v) => setState(() => sliderValue = v),
61+
),
62+
const SizedBox(height: 20),
5163
RatingIndicator(
5264
value: ratingValue,
5365
onChanged: (v) => setState(() => ratingValue = v),

example/pubspec.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ packages:
9797
path: ".."
9898
relative: true
9999
source: path
100-
version: "1.8.0"
100+
version: "1.9.0"
101101
matcher:
102102
dependency: transitive
103103
description:
@@ -208,5 +208,5 @@ packages:
208208
source: hosted
209209
version: "2.1.4"
210210
sdks:
211-
dart: ">=2.18.0 <4.0.0"
211+
dart: ">=2.18.0 <3.0.0"
212212
flutter: ">=1.20.0"

lib/macos_ui.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export 'src/indicators/progress_indicators.dart';
3737
export 'src/indicators/rating_indicator.dart';
3838
export 'src/indicators/relevance_indicator.dart';
3939
export 'src/indicators/scrollbar.dart';
40+
export 'src/indicators/slider.dart';
4041
export 'src/labels/label.dart';
4142
export 'src/labels/tooltip.dart';
4243
export 'src/layout/content_area.dart';

0 commit comments

Comments
 (0)