Skip to content

Commit fe0d15e

Browse files
Merge pull request #104 from TheEightBot/develop
2 parents 6200eb0 + 5ae76c0 commit fe0d15e

11 files changed

+441
-19
lines changed

AuroraControls.TestApp/CardViewLayoutPage.xaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@
2020
ValueChanged="OnCornerRadiusChanged" />
2121
</StackLayout>
2222

23+
<!-- Shadow Radius -->
24+
<StackLayout>
25+
<Label Text="{Binding Source={x:Reference shadowRadiusSlider}, Path=Value, StringFormat='Shadow Radius: {0:F1}'}" />
26+
<Slider x:Name="shadowRadiusSlider"
27+
Minimum="0"
28+
Maximum="30"
29+
Value="0"
30+
ValueChanged="OnShadowRadiusChanged" />
31+
</StackLayout>
32+
2333
<!-- Elevation -->
2434
<StackLayout>
2535
<Label Text="{Binding Source={x:Reference elevationSlider}, Path=Value, StringFormat='Elevation: {0:F1}'}" />
@@ -84,6 +94,7 @@
8494
<!-- Sample CardViewLayout -->
8595
<aurora:CardViewLayout x:Name="sampleCard"
8696
CornerRadius="0"
97+
ShadowRadius="0"
8798
Elevation="2"
8899
ShadowColor="#576076"
89100
BorderColor="Transparent"
@@ -107,7 +118,7 @@
107118
TextColor="White"
108119
CornerRadius="5"
109120
HorizontalOptions="Center" />
110-
<Label Text="Adjust the settings above to see how they affect this card's appearance."
121+
<Label Text="Adjust the settings above to see how corner radius and shadow radius can be controlled independently."
111122
FontSize="12"
112123
TextColor="DarkGray"
113124
HorizontalTextAlignment="Center" />

AuroraControls.TestApp/CardViewLayoutPage.xaml.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ private void OnCornerRadiusChanged(object sender, ValueChangedEventArgs e)
1212
sampleCard.CornerRadius = e.NewValue;
1313
}
1414

15+
private void OnShadowRadiusChanged(object sender, ValueChangedEventArgs e)
16+
{
17+
sampleCard.ShadowRadius = e.NewValue;
18+
}
19+
1520
private void OnElevationChanged(object sender, ValueChangedEventArgs e)
1621
{
1722
sampleCard.Elevation = e.NewValue;

AuroraControls.TestApp/MainPage.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public TestMvvmToolkitViewModel MvvmToolkitViewModel
8383

8484
private CalendarPicker _calendarPicker;
8585

86+
private Label _calendarPickerValue;
87+
8688
private Button _clearNullableDatePicker;
8789

8890
public MainPage(ILogger<TestRxViewModel> logger)
@@ -157,6 +159,13 @@ await this.Navigation.PushAsync(new SvgImageViewTestPage())),
157159
.BindClicked(async () =>
158160
await this.Navigation.PushAsync(new SvgImageButtonTestPage())),
159161

162+
new Button { Text = "View SetSvgIcon Extensions Test Page", }
163+
.BindClicked(async () =>
164+
{
165+
var page = await Task.Run(() => new SetSvgIconExtensionsTestPage());
166+
await this.Navigation.PushAsync(page);
167+
}),
168+
160169
new Button { Text = "View GradientCircularButton Test Page", }
161170
.BindClicked(async () =>
162171
await this.Navigation.PushAsync(new GradientCircularButtonTestPage())),
@@ -224,8 +233,13 @@ await this.Navigation.PushAsync(new GridImagePage())),
224233
Placeholder = "Nullable Date Picker",
225234
Content =
226235
new CalendarPicker()
236+
{
237+
UpdateMode = CalendarPickerUpdateMode.Immediately,
238+
}
227239
.Assign(out _calendarPicker),
228240
},
241+
new Label()
242+
.Assign(out _calendarPickerValue),
229243
new Button { Text = "Clear Nullable Date Picker", }
230244
.Assign(out _clearNullableDatePicker),
231245
new StyledInputLayout
@@ -545,6 +559,10 @@ await this.Navigation.PushAsync(new GridImagePage())),
545559
},
546560
};
547561

562+
this.Bind(ViewModel, x => x.NullableDateTimeValue, x => x._calendarPicker.Date);
563+
564+
this.OneWayBind(ViewModel, x => x.NullableDateTimeValue, x => x._calendarPickerValue.Text, x => x?.ToString("D") ?? "null");
565+
548566
_clearNullableDatePicker.Clicked +=
549567
(sender, args) => { _calendarPicker.Date = null; };
550568

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="AuroraControls.TestApp.SetSvgIconExtensionsTestPage"
5+
Title="SetSvgIcon Extensions Test Page">
6+
<ScrollView>
7+
<VerticalStackLayout Spacing="15" Padding="20">
8+
<Label Text="SetSvgIcon Extension Methods Test"
9+
FontSize="Title"
10+
FontAttributes="Bold"
11+
HorizontalOptions="Center" />
12+
13+
<Label x:Name="StatusLabel"
14+
Text="Ready"
15+
FontSize="14"
16+
HorizontalOptions="Center"
17+
BackgroundColor="LightBlue"
18+
Padding="10" />
19+
20+
<!-- Button SetSvgIcon -->
21+
<Border Stroke="Gray" Padding="15" Margin="0,10,0,0">
22+
<VerticalStackLayout Spacing="10">
23+
<Label Text="Button.SetSvgIcon()" FontSize="Subtitle" FontAttributes="Bold"/>
24+
<Grid ColumnDefinitions="*, *, *" ColumnSpacing="15" RowSpacing="15">
25+
<Button x:Name="TestButton1" Text="Button 1" Clicked="OnButtonClicked"/>
26+
<Button x:Name="TestButton2" Text="Button 2" Grid.Column="1" Clicked="OnButtonClicked"/>
27+
<Button x:Name="TestButton3" Text="Button 3" Grid.Column="2" Clicked="OnButtonClicked"/>
28+
</Grid>
29+
</VerticalStackLayout>
30+
</Border>
31+
32+
<!-- ImageButton SetSvgIcon -->
33+
<Border Stroke="Gray" Padding="15">
34+
<VerticalStackLayout Spacing="10">
35+
<Label Text="ImageButton.SetSvgIcon()" FontSize="Subtitle" FontAttributes="Bold"/>
36+
<Grid ColumnDefinitions="*, *, *" ColumnSpacing="15" RowSpacing="15">
37+
<ImageButton x:Name="TestImageButton1" HeightRequest="60" WidthRequest="60" Clicked="OnImageButtonClicked"/>
38+
<ImageButton x:Name="TestImageButton2" HeightRequest="60" WidthRequest="60" Grid.Column="1" Clicked="OnImageButtonClicked"/>
39+
<ImageButton x:Name="TestImageButton3" HeightRequest="60" WidthRequest="60" Grid.Column="2" Clicked="OnImageButtonClicked"/>
40+
</Grid>
41+
</VerticalStackLayout>
42+
</Border>
43+
44+
<!-- Image SetSvgIcon -->
45+
<Border Stroke="Gray" Padding="15">
46+
<VerticalStackLayout Spacing="10">
47+
<Label Text="Image.SetSvgIcon()" FontSize="Subtitle" FontAttributes="Bold"/>
48+
<Grid ColumnDefinitions="*, *, *" ColumnSpacing="15" RowSpacing="15">
49+
<VerticalStackLayout HorizontalOptions="Center">
50+
<Image x:Name="TestImage1" HeightRequest="60" WidthRequest="60"/>
51+
<Label Text="Default Size" HorizontalOptions="Center" FontSize="12"/>
52+
</VerticalStackLayout>
53+
<VerticalStackLayout HorizontalOptions="Center" Grid.Column="1">
54+
<Image x:Name="TestImage2" HeightRequest="60" WidthRequest="60"/>
55+
<Label Text="48px" HorizontalOptions="Center" FontSize="12"/>
56+
</VerticalStackLayout>
57+
<VerticalStackLayout HorizontalOptions="Center" Grid.Column="2">
58+
<Image x:Name="TestImage3" HeightRequest="60" WidthRequest="60"/>
59+
<Label Text="Red Color" HorizontalOptions="Center" FontSize="12"/>
60+
</VerticalStackLayout>
61+
</Grid>
62+
</VerticalStackLayout>
63+
</Border>
64+
65+
<!-- MenuItems with SetSvgIcon -->
66+
<Border Stroke="Gray" Padding="15">
67+
<VerticalStackLayout Spacing="10">
68+
<Label Text="MenuItem.SetSvgIcon() and ToolbarItem.SetSvgIcon()" FontSize="Subtitle" FontAttributes="Bold"/>
69+
<Label Text="Check the toolbar and context menu (right-click if available)" FontSize="12" FontAttributes="Italic"/>
70+
<Button Text="Show Context Menu" Clicked="OnShowContextMenuClicked"/>
71+
</VerticalStackLayout>
72+
</Border>
73+
74+
<!-- Test Controls -->
75+
<Border Stroke="Gray" Padding="15">
76+
<VerticalStackLayout Spacing="10">
77+
<Label Text="Test Controls" FontSize="Subtitle" FontAttributes="Bold"/>
78+
<Button Text="Change All Icons" Clicked="OnChangeIconsClicked"/>
79+
<Button Text="Toggle Color Override" Clicked="OnToggleColorClicked"/>
80+
<Button Text="Change Size" Clicked="OnChangeSizeClicked"/>
81+
</VerticalStackLayout>
82+
</Border>
83+
</VerticalStackLayout>
84+
</ScrollView>
85+
</ContentPage>
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
using System.ComponentModel;
2+
using System.Runtime.CompilerServices;
3+
4+
namespace AuroraControls.TestApp;
5+
6+
public partial class SetSvgIconExtensionsTestPage : ContentPage
7+
{
8+
private readonly string[] _svgIcons = { "logo.svg", "splatoon.svg", "triforce.svg", "dollar_sign.svg", "more.svg" };
9+
private readonly double[] _sizes = { 16d, 24d, 32d, 48d, 64d };
10+
private int _currentIconIndex;
11+
private bool _useColorOverride;
12+
private double _currentSize = 24d;
13+
private int _currentSizeIndex = 1; // Start with 24px
14+
15+
public SetSvgIconExtensionsTestPage()
16+
{
17+
InitializeComponent();
18+
BindingContext = this;
19+
InitializeIcons();
20+
SetupToolbarItems();
21+
}
22+
23+
private void InitializeIcons()
24+
{
25+
// Test Button.SetSvgIcon() with different parameters
26+
TestButton1.SetSvgIcon("logo.svg");
27+
TestButton2.SetSvgIcon("splatoon.svg", 32d);
28+
TestButton3.SetSvgIcon("triforce.svg", 24d, Colors.Blue);
29+
30+
// Test ImageButton.SetSvgIcon() with different parameters
31+
TestImageButton1.SetSvgIcon("dollar_sign.svg");
32+
TestImageButton2.SetSvgIcon("more.svg", 48d);
33+
TestImageButton3.SetSvgIcon("logo.svg", 40d, Colors.Green);
34+
35+
// Test Image.SetSvgIcon() with different parameters
36+
TestImage1.SetSvgIcon("triforce.svg"); // Default size (24px)
37+
TestImage2.SetSvgIcon("splatoon.svg", 48d); // Custom size
38+
TestImage3.SetSvgIcon("dollar_sign.svg", 32d, Colors.Red); // Custom size and color
39+
40+
UpdateStatus("Icons initialized with various SetSvgIcon() configurations");
41+
}
42+
43+
private void SetupToolbarItems()
44+
{
45+
// Test ToolbarItem.SetSvgIcon()
46+
var toolbarItem1 = new ToolbarItem { Text = "Tool 1" };
47+
toolbarItem1.SetSvgIcon("logo.svg");
48+
toolbarItem1.Clicked += OnToolbarItemClicked;
49+
50+
var toolbarItem2 = new ToolbarItem { Text = "Tool 2" };
51+
toolbarItem2.SetSvgIcon("more.svg", 24d, Colors.Purple);
52+
toolbarItem2.Clicked += OnToolbarItemClicked;
53+
54+
ToolbarItems.Add(toolbarItem1);
55+
ToolbarItems.Add(toolbarItem2);
56+
57+
// Test Page.SetSvgIcon() - Set icon for this page
58+
this.SetSvgIcon("triforce.svg");
59+
}
60+
61+
private void OnButtonClicked(object sender, EventArgs e)
62+
{
63+
if (sender is Button button)
64+
{
65+
UpdateStatus($"Button clicked: {button.Text}");
66+
}
67+
}
68+
69+
private void OnImageButtonClicked(object sender, EventArgs e)
70+
{
71+
UpdateStatus("ImageButton clicked");
72+
}
73+
74+
private void OnToolbarItemClicked(object sender, EventArgs e)
75+
{
76+
if (sender is ToolbarItem toolbarItem)
77+
{
78+
UpdateStatus($"ToolbarItem clicked: {toolbarItem.Text}");
79+
}
80+
}
81+
82+
private void OnShowContextMenuClicked(object sender, EventArgs e)
83+
{
84+
// Create context menu with MenuItem.SetSvgIcon()
85+
var menuItem1 = new MenuFlyoutItem { Text = "Menu Item 1" };
86+
menuItem1.SetSvgIcon("logo.svg", 20d);
87+
menuItem1.Clicked += (_, _) => UpdateStatus("Context Menu Item 1 clicked");
88+
89+
var menuItem2 = new MenuFlyoutItem { Text = "Menu Item 2" };
90+
menuItem2.SetSvgIcon("splatoon.svg", 20d, Colors.Orange);
91+
menuItem2.Clicked += (_, _) => UpdateStatus("Context Menu Item 2 clicked");
92+
93+
var menuFlyout = new MenuFlyout();
94+
menuFlyout.Add(menuItem1);
95+
menuFlyout.Add(menuItem2);
96+
97+
if (sender is Button button)
98+
{
99+
FlyoutBase.SetContextFlyout(button, menuFlyout);
100+
}
101+
102+
UpdateStatus("Context menu with SetSvgIcon() MenuItems created");
103+
}
104+
105+
private void OnChangeIconsClicked(object sender, EventArgs e)
106+
{
107+
// Cycle through different icons
108+
_currentIconIndex = (_currentIconIndex + 1) % _svgIcons.Length;
109+
var newIcon = _svgIcons[_currentIconIndex];
110+
111+
// Update all controls with new icons
112+
TestButton1.SetSvgIcon(newIcon, _currentSize, _useColorOverride ? Colors.Purple : null);
113+
TestButton2.SetSvgIcon(newIcon, _currentSize, _useColorOverride ? Colors.Teal : null);
114+
TestButton3.SetSvgIcon(newIcon, _currentSize, _useColorOverride ? Colors.Orange : null);
115+
116+
TestImageButton1.SetSvgIcon(newIcon, _currentSize, _useColorOverride ? Colors.Navy : null);
117+
TestImageButton2.SetSvgIcon(newIcon, _currentSize, _useColorOverride ? Colors.Maroon : null);
118+
TestImageButton3.SetSvgIcon(newIcon, _currentSize, _useColorOverride ? Colors.DarkGreen : null);
119+
120+
TestImage1.SetSvgIcon(newIcon, _currentSize, _useColorOverride ? Colors.Crimson : null);
121+
TestImage2.SetSvgIcon(newIcon, _currentSize, _useColorOverride ? Colors.DarkBlue : null);
122+
TestImage3.SetSvgIcon(newIcon, _currentSize, _useColorOverride ? Colors.DarkOrange : null);
123+
124+
UpdateStatus($"All icons changed to: {newIcon}");
125+
}
126+
127+
private void OnToggleColorClicked(object sender, EventArgs e)
128+
{
129+
_useColorOverride = !_useColorOverride;
130+
OnChangeIconsClicked(sender, e); // Apply the color change
131+
UpdateStatus($"Color override: {(_useColorOverride ? "Enabled" : "Disabled")}");
132+
}
133+
134+
private void OnChangeSizeClicked(object sender, EventArgs e)
135+
{
136+
_currentSizeIndex = (_currentSizeIndex + 1) % _sizes.Length;
137+
_currentSize = _sizes[_currentSizeIndex];
138+
OnChangeIconsClicked(sender, e); // Apply the size change
139+
UpdateStatus($"Icon size changed to: {_currentSize}px");
140+
}
141+
142+
private void UpdateStatus(string message)
143+
{
144+
StatusLabel.Text = $"{DateTime.Now:HH:mm:ss} - {message}";
145+
}
146+
}

AuroraControls.TestApp/StyledInputLayoutTestPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
InactiveColor="Green"
6464
VerticalOptions="Center"
6565
BorderStyle="RoundedRectanglePlaceholderThrough">
66-
<Entry Placeholder="VerticalOptions=Center"/>
66+
<Entry Placeholder="VerticalOptions=Center" Text="Center" />
6767
</aurora:StyledInputLayout>
6868
</Border>
6969

AuroraControlsMaui/CalendarPicker.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,33 @@
11
namespace AuroraControls;
22

3+
public enum CalendarPickerUpdateMode
4+
{
5+
WhenDone = 1,
6+
Immediately = 2,
7+
}
8+
39
[ContentProperty(nameof(Date))]
410
public class CalendarPicker : DatePicker
511
{
12+
public static readonly BindableProperty UpdateModeProperty =
13+
BindableProperty.Create(
14+
nameof(CalendarPickerUpdateMode),
15+
typeof(CalendarPickerUpdateMode),
16+
typeof(CalendarPicker),
17+
CalendarPickerUpdateMode.WhenDone);
18+
19+
/// <summary>
20+
/// Gets or sets the mode to use for determining when to update the Date:
21+
/// 1. Immediately - Update Date when a date is selected.
22+
/// 2. WhenDone - Update Date when the 'Done' button is pressed.
23+
/// </summary>
24+
/// <remarks>Only applies on iOS.</remarks>
25+
public CalendarPickerUpdateMode UpdateMode
26+
{
27+
get => (CalendarPickerUpdateMode)GetValue(UpdateModeProperty);
28+
set => SetValue(UpdateModeProperty, value);
29+
}
30+
631
public new event EventHandler<NullableDateChangedEventArgs> DateSelected;
732

833
/// <summary>

0 commit comments

Comments
 (0)