Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit c5adefc

Browse files
Add MaterialDoublePicker control
1 parent 8f00c60 commit c5adefc

18 files changed

Lines changed: 1621 additions & 4 deletions

MaterialDesignControls.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata minClientVersion="2.8.1">
44
<id>Plugin.MaterialDesignControls</id>
5-
<version>1.5.2</version>
5+
<version>1.6.0</version>
66
<title>MaterialDesignControls Plugin for Xamarin Forms</title>
77
<authors>Horus</authors>
88
<owners>AgustinBonillaHorus</owners>

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,22 @@ Pickers let users select an option.
111111
IsRequired="true" RequiredMessage="The color is required" />
112112
```
113113

114+
### MaterialDoublePicker
115+
Double pickers let users select two options in the same dialog.
116+
117+
**Screenshot**
118+
119+
<img src="https://github.com/HorusSoftwareUY/MaterialDesignControlsPlugin/blob/master/screenshots/doublePickerAndroid.jpg" width="300">
120+
121+
<img src="https://github.com/HorusSoftwareUY/MaterialDesignControlsPlugin/blob/master/screenshots/doublePickeriOS.jpg" width="300">
122+
123+
**Example**
124+
```XML
125+
<material:MaterialDoublePicker Type="Filled" LabelText="Double Picker" Separator=" - "
126+
ItemsSource="{Binding ItemsSource}" SecondaryItemsSource="{Binding SecondaryItemsSource}"
127+
SelectedItem="{Binding SelectedItem}" SecondarySelectedItem="{Binding SecondarySelectedItem}" />
128+
```
129+
114130
### MaterialEditor
115131
Text fields let users enter and edit text.
116132

example/ExampleMaterialDesignControls/App.xaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,21 @@
154154
<Setter Property="AssistiveSize" Value="{StaticResource Body3FontSize}" />
155155
<Setter Property="TrailingIcon" Value="arrow_drop_down.png" />
156156
</Style>
157+
158+
<!-- MaterialPicker -->
159+
<Style TargetType="material:MaterialDoublePicker">
160+
<Setter Property="LabelSize" Value="{StaticResource Body4FontSize}" />
161+
<Setter Property="LabelTextColor" Value="{StaticResource LabelTextColor}" />
162+
<Setter Property="FocusedLabelTextColor" Value="{StaticResource FocusedLabelTextColor}" />
163+
<Setter Property="TextColor" Value="{StaticResource TextColor}" />
164+
<Setter Property="FontSize" Value="{StaticResource Body2FontSize}" />
165+
<Setter Property="BackgroundColor" Value="{StaticResource BackgroundColor}" />
166+
<Setter Property="BorderColor" Value="{StaticResource BorderColor}" />
167+
<Setter Property="FocusedBorderColor" Value="{StaticResource FocusedBorderColor}" />
168+
<Setter Property="AssistiveTextColor" Value="{StaticResource AssistiveTextColor}" />
169+
<Setter Property="AssistiveSize" Value="{StaticResource Body3FontSize}" />
170+
<Setter Property="TrailingIcon" Value="arrow_drop_down.png" />
171+
</Style>
157172

158173
<!-- MaterialSelection -->
159174
<Style TargetType="material:MaterialSelection">

example/ExampleMaterialDesignControls/Pages/MaterialPickerPage.xaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626
</OnPlatform>
2727
</material:MaterialPicker.FontFamily>
2828
</material:MaterialPicker>
29+
30+
<material:MaterialDoublePicker x:Name="pckDouble" Type="Filled" LabelText="Double Picker"
31+
ItemsSource="{Binding ItemsSource}" SecondaryItemsSource="{Binding SecondaryItemsSource}"
32+
SelectedItem="{Binding SelectedItem}" SecondarySelectedItem="{Binding SecondarySelectedItem}" />
33+
<Label x:Name="lblSelectedIndexes" Text="SelectedIndexes: -" />
34+
<material:MaterialButton Text="Save" Icon="save.png" Command="{Binding Tap2Command}" />
35+
36+
<material:MaterialDoublePicker Type="Filled" LabelText="Double Picker" Separator=" - "
37+
ItemsSource="{Binding ItemsSource}" SecondaryItemsSource="{Binding SecondaryItemsSource}"
38+
SelectedItem="{Binding SelectedItem}" SecondarySelectedItem="{Binding SecondarySelectedItem}" />
2939
</StackLayout>
3040
</ScrollView>
3141
</ContentPage.Content>

example/ExampleMaterialDesignControls/Pages/MaterialPickerPage.xaml.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Windows.Input;
4+
using Plugin.MaterialDesignControls;
45
using Xamarin.Forms;
56

67
namespace ExampleMaterialDesignControls.Pages
@@ -9,6 +10,14 @@ public partial class MaterialPickerPage : ContentPage
910
{
1011
public string SelectedSizes { get; set; }
1112

13+
public string SelectedItem { get; set; }
14+
15+
public string SecondarySelectedItem { get; set; }
16+
17+
public List<string> ItemsSource { get; set; }
18+
19+
public List<string> SecondaryItemsSource { get; set; }
20+
1221
public MaterialPickerPage()
1322
{
1423
InitializeComponent();
@@ -23,11 +32,24 @@ public MaterialPickerPage()
2332
this.pckModels3.ItemsSource = new List<string> { "Model A", "Model B", "Model C", "Model D" };
2433
this.pckModels4.ItemsSource = new List<string> { "Model A", "Model B", "Model C", "Model D" };
2534

35+
this.pckDouble.SelectedIndexesChanged += PckDouble_SelectedIndexChanged;
36+
this.ItemsSource = new List<string> { "Model 1", "Model 2", "Model 3", "Model 4" };
37+
this.SecondaryItemsSource = new List<string> { "A", "B", "C", "D" };
38+
this.SelectedItem = "Model 2";
39+
this.SecondarySelectedItem = "C";
40+
2641
this.TapCommand = new Command<string>(OnTap);
2742

43+
this.Tap2Command = new Command<string>(OnTap2);
44+
2845
this.BindingContext = this;
2946
}
3047

48+
private void PckDouble_SelectedIndexChanged(object sender, SelectedIndexesEventArgs e)
49+
{
50+
this.lblSelectedIndexes.Text = $"SelectedIndexes: {e.SelectedIndexes[0]} - {e.SelectedIndexes[1]}";
51+
}
52+
3153
private void PckModels_SelectedIndexChanged(object sender, EventArgs e)
3254
{
3355
this.lblSelectedIndex.Text = $"SelectedIndex: {this.pckModels.SelectedIndex}";
@@ -47,5 +69,12 @@ public async void OnTap(object parameter)
4769
this.pckColors.AssistiveText = "The color is required";
4870
}
4971
}
72+
73+
public ICommand Tap2Command { get; set; }
74+
75+
public async void OnTap2(object parameter)
76+
{
77+
await this.DisplayAlert("Saved", $"{SelectedItem} - {SecondarySelectedItem}", "Ok");
78+
}
5079
}
5180
}
112 KB
Loading

screenshots/doublePickeriOS.png

115 KB
Loading

src/MaterialDesignControls.Android/MaterialDesignControls.Android.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
<Compile Include="Effects\TouchAndPressEffect.cs" />
134134
<Compile Include="Effects.cs" />
135135
<Compile Include="Utils\TextAlignmentHelper.cs" />
136+
<Compile Include="Renderers\MaterialDoublePickerRenderer.cs" />
136137
</ItemGroup>
137138
<ItemGroup>
138139
<None Include="Resources\AboutResources.txt" />

src/MaterialDesignControls.Android/Renderers.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public static void Init()
88
MaterialDatePickerRenderer.Init();
99
MaterialEntryRenderer.Init();
1010
MaterialPickerRenderer.Init();
11+
MaterialDoublePickerRenderer.Init();
1112
MaterialTimePickerRenderer.Init();
1213
MaterialEditorRenderer.Init();
1314
MaterialLabelRenderer.Init();

0 commit comments

Comments
 (0)