Skip to content

Commit e79e5c1

Browse files
authored
Merge pull request #68 from MykhailoDav/slider_min_max
Slider min max Value
2 parents 98502a3 + 1741002 commit e79e5c1

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/AlohaKit.Gallery/Views/SliderView.xaml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="utf-8" ?>
2-
<ContentPage
2+
<ContentPage
33
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
44
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
55
x:Class="AlohaKit.Gallery.SliderView"
66
xmlns:controls="clr-namespace:AlohaKit.Controls;assembly=AlohaKit"
77
Title="Slider">
88
<ContentPage.Resources>
99
<ResourceDictionary>
10-
10+
1111
<Style x:Key="SettingsTextStyle" TargetType="Label">
1212
<Setter Property="FontSize" Value="9" />
1313
</Style>
@@ -17,7 +17,7 @@
1717
<Setter Property="WidthRequest" Value="80" />
1818
<Setter Property="Margin" Value="6, 0" />
1919
</Style>
20-
20+
2121
</ResourceDictionary>
2222
</ContentPage.Resources>
2323
<Grid>
@@ -34,7 +34,7 @@
3434
Text="Slider is a horizontal bar that can be manipulated by the user to select a double value from a continuous range."/>
3535
</StackLayout>
3636
<!-- FEATURES -->
37-
<StackLayout
37+
<StackLayout
3838
Grid.Row="1"
3939
BackgroundColor="{AppThemeBinding Light={StaticResource LightBackgroundSecondaryColor}, Dark={StaticResource DarkBackgroundSecondaryColor}}"
4040
Style="{StaticResource SectionContainerStyle}">
@@ -48,7 +48,7 @@
4848
<StackLayout
4949
Grid.Row="2"
5050
Style="{StaticResource SectionContainerStyle}">
51-
<Label
51+
<Label
5252
Text="Settings"
5353
Style="{StaticResource SectionTitleStyle}"/>
5454
<StackLayout
@@ -64,11 +64,11 @@
6464
Text="#DD5E89"
6565
TextChanged="OnMinimumBrushStartColorEntryTextChanged"
6666
Style="{StaticResource SettingsEntryStyle}"/>
67-
<Label
67+
<Label
6868
Text="MinimumBrush End Color"
6969
VerticalOptions="Center"
7070
Style="{StaticResource SettingsTextStyle}"/>
71-
<Entry
71+
<Entry
7272
x:Name="MinimumBrushEndColorEntry"
7373
Placeholder="MinimumBrush"
7474
Text="#F7BB97"
@@ -78,7 +78,7 @@
7878
<StackLayout
7979
Orientation="Horizontal"
8080
Margin="0, 6">
81-
<Label
81+
<Label
8282
Text="MaximumBrush Start Color"
8383
VerticalOptions="Center"
8484
Style="{StaticResource SettingsTextStyle}"/>
@@ -88,11 +88,11 @@
8888
Text="#CC2B5E"
8989
TextChanged="OnMaximumBrushStartColorEntryTextChanged"
9090
Style="{StaticResource SettingsEntryStyle}"/>
91-
<Label
91+
<Label
9292
Text="MaximumBrush End Color"
9393
VerticalOptions="Center"
9494
Style="{StaticResource SettingsTextStyle}"/>
95-
<Entry
95+
<Entry
9696
x:Name="MaximumBrushEndColorEntry"
9797
Placeholder="Color"
9898
Text="#753A88"
@@ -102,7 +102,7 @@
102102
<StackLayout
103103
Orientation="Horizontal"
104104
Margin="0, 6">
105-
<Label
105+
<Label
106106
Text="ThumbBrush Start Color"
107107
VerticalOptions="Center"
108108
Style="{StaticResource SettingsTextStyle}"/>
@@ -112,20 +112,21 @@
112112
Text="#CCCCCC"
113113
TextChanged="OnThumbBrushStartColorEntryTextChanged"
114114
Style="{StaticResource SettingsEntryStyle}"/>
115-
<Label
115+
<Label
116116
Text="ThumbBrush End Color"
117117
VerticalOptions="Center"
118118
Style="{StaticResource SettingsTextStyle}"/>
119-
<Entry
119+
<Entry
120120
x:Name="ThumbBrushEndColorEntry"
121121
Placeholder="ThumbBrush"
122122
Text="#BDC3C7"
123123
TextChanged="OnThumbBrushEndColorEntryTextChanged"
124124
Style="{StaticResource SettingsEntryStyle}"/>
125125
</StackLayout>
126126
</StackLayout>
127-
<controls:Slider
128-
Grid.Row="3"
129-
x:Name="Slider" />
127+
<VerticalStackLayout Grid.Row="3">
128+
<Label HorizontalOptions="Center" Text="{Binding Source={x:Reference Slider}, Path=Value}" />
129+
<controls:Slider x:Name="Slider" />
130+
</VerticalStackLayout>
130131
</Grid>
131132
</ContentPage>

src/AlohaKit/Controls/Slider/Slider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ void UpdateValue()
198198
if (SliderDrawable == null)
199199
return;
200200

201+
Value = Math.Clamp(Value, Minimum, Maximum);
201202
SliderDrawable.Value = Value;
202203

203204
Invalidate();

0 commit comments

Comments
 (0)