Skip to content

Commit f9be8ff

Browse files
Addressed AI concersns
1 parent 7aff360 commit f9be8ff

3 files changed

Lines changed: 34 additions & 27 deletions

File tree

‎src/Controls/tests/TestCases.HostApp/FeatureMatrix/BoxView/BoxViewControlPage.xaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
AutomationId="FlowDirectionRTLCheckBox"
139139
IsChecked="{Binding IsRTL, Mode=TwoWay}"/>
140140
<Label Text="RTL"
141-
VerticalOptions="Center"/>
141+
VerticalOptions="Center"/>
142142
</StackLayout>
143143

144144
</VerticalStackLayout>

‎src/Controls/tests/TestCases.HostApp/FeatureMatrix/BoxView/BoxViewControlPage.xaml.cs‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,37 @@ private void OnResetChangesClicked(object sender, EventArgs e)
5757

5858
private void OnOpacityChanged(object sender, TextChangedEventArgs e)
5959
{
60-
if (double.TryParse(e.NewTextValue, NumberStyles.Float, CultureInfo.InvariantCulture, out double value))
60+
if (string.IsNullOrWhiteSpace(e.NewTextValue))
6161
{
62-
if (value >= 0 && value <= 1)
63-
_viewModel.Opacity = value;
62+
_viewModel.Opacity = 1.0;
63+
return;
6464
}
65+
66+
if (double.TryParse(e.NewTextValue, NumberStyles.Float, CultureInfo.InvariantCulture, out double value) && value >= 0 && value <= 1)
67+
_viewModel.Opacity = value;
6568
}
6669

6770
private void OnWidthChanged(object sender, TextChangedEventArgs e)
6871
{
69-
if (double.TryParse(e.NewTextValue, NumberStyles.Float, CultureInfo.InvariantCulture, out double value) && value > 0)
72+
if (string.IsNullOrWhiteSpace(e.NewTextValue))
73+
{
74+
_viewModel.Width = 200;
75+
return;
76+
}
77+
78+
if (double.TryParse(e.NewTextValue, NumberStyles.Float, CultureInfo.InvariantCulture, out double value) && value >= 0)
7079
_viewModel.Width = value;
7180
}
7281

7382
private void OnHeightChanged(object sender, TextChangedEventArgs e)
7483
{
75-
if (double.TryParse(e.NewTextValue, NumberStyles.Float, CultureInfo.InvariantCulture, out double value) && value > 0)
84+
if (string.IsNullOrWhiteSpace(e.NewTextValue))
85+
{
86+
_viewModel.Height = 100;
87+
return;
88+
}
89+
90+
if (double.TryParse(e.NewTextValue, NumberStyles.Float, CultureInfo.InvariantCulture, out double value) && value >= 0)
7691
_viewModel.Height = value;
7792
}
7893
}

‎src/Controls/tests/TestCases.HostApp/FeatureMatrix/BoxView/BoxViewViewModel.cs‎

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,7 @@ public bool IsRedChecked
104104
{
105105
_isRedChecked = value;
106106
if (value)
107-
{
108-
Color = Colors.Red;
109-
_isBlueChecked = false;
110-
OnPropertyChanged(nameof(IsBlueChecked));
111-
_isGreenChecked = false;
112-
OnPropertyChanged(nameof(IsGreenChecked));
113-
}
107+
SelectColor(Colors.Red, ref _isBlueChecked, nameof(IsBlueChecked), ref _isGreenChecked, nameof(IsGreenChecked));
114108
OnPropertyChanged();
115109
}
116110
}
@@ -125,13 +119,7 @@ public bool IsBlueChecked
125119
{
126120
_isBlueChecked = value;
127121
if (value)
128-
{
129-
Color = Colors.Blue;
130-
_isRedChecked = false;
131-
OnPropertyChanged(nameof(IsRedChecked));
132-
_isGreenChecked = false;
133-
OnPropertyChanged(nameof(IsGreenChecked));
134-
}
122+
SelectColor(Colors.Blue, ref _isRedChecked, nameof(IsRedChecked), ref _isGreenChecked, nameof(IsGreenChecked));
135123
OnPropertyChanged();
136124
}
137125
}
@@ -146,17 +134,20 @@ public bool IsGreenChecked
146134
{
147135
_isGreenChecked = value;
148136
if (value)
149-
{
150-
Color = Colors.Green;
151-
_isRedChecked = false;
152-
OnPropertyChanged(nameof(IsRedChecked));
153-
_isBlueChecked = false;
154-
OnPropertyChanged(nameof(IsBlueChecked));
155-
}
137+
SelectColor(Colors.Green, ref _isRedChecked, nameof(IsRedChecked), ref _isBlueChecked, nameof(IsBlueChecked));
156138
OnPropertyChanged();
157139
}
158140
}
159141
}
142+
143+
private void SelectColor(Color color, ref bool other1, string other1Name, ref bool other2, string other2Name)
144+
{
145+
Color = color;
146+
other1 = false;
147+
OnPropertyChanged(other1Name);
148+
other2 = false;
149+
OnPropertyChanged(other2Name);
150+
}
160151
public double Opacity
161152
{
162153
get => _opacity;
@@ -269,6 +260,7 @@ public double Height
269260
}
270261
}
271262
}
263+
272264
public bool IsRTL
273265
{
274266
get => _isRTL;

0 commit comments

Comments
 (0)