Skip to content

Commit ae8be78

Browse files
Tamilarasan-ParanthamanPaulAndersonSrmarinhojfversluisDhivya-SF4094
authored andcommitted
Fix up relevant CA1416 warnings - Set 1 (#26696)
* Changed Syncfusion toolkit version from 1.0.4 to 1.0.5 (#29659) * [ci] Update dependencies from 9.0.4 to 9.0.5 (#29667) * [ci] Update dependencies from 9.0.4 to 9.0.5 * Update the net8 version * Add missing version MicrosoftJSInteropPackageVersion * Page.OnBackButtonPressed remove outdated API documentation (#29543) * Fixed KeepLastItemInView Does Not Scroll to Last Item When Adding Items at Top (#29632) * Fixed KeepLastItem not scrolled to last item * Updated Fix * Updated test sample * Added comment line * Updated test sample for iOS and mac * Added Snapshots for android and WinUI * Added UI tests. * Test sample changes. * script changes * script changes * Added snapshots * Resaved Mac images and the gradient image size issue has been fixed * CA1416 warning changes * Reverted unwanted changes --------- Co-authored-by: Paul Anderson <42271912+PaulAndersonS@users.noreply.github.com> Co-authored-by: Rui Marinho <me@ruimarinho.net> Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com> Co-authored-by: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com>
1 parent 636bd12 commit ae8be78

File tree

17 files changed

+156
-15
lines changed

17 files changed

+156
-15
lines changed

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,4 @@
216216
<MicrosoftiOSSdkPackageVersion>$(MicrosoftiOSSdknet90_180PackageVersion)</MicrosoftiOSSdkPackageVersion>
217217
<MicrosofttvOSSdkPackageVersion>$(MicrosofttvOSSdknet90_180PackageVersion)</MicrosofttvOSSdkPackageVersion>
218218
</PropertyGroup>
219-
</Project>
219+
</Project>

src/Controls/src/Core/Compatibility/Handlers/ListView/iOS/ContextActionCell.cs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using System.Collections.Specialized;
55
using System.ComponentModel;
6+
using CoreGraphics;
67
using Foundation;
78
using Microsoft.Maui.Controls.Compatibility;
89
using Microsoft.Maui.Controls.Compatibility.iOS.Resources;
@@ -33,19 +34,15 @@ static ContextActionsCell()
3334
{
3435
var rect = new RectangleF(0, 0, 1, 1);
3536
var size = rect.Size;
36-
37-
UIGraphics.BeginImageContext(size);
38-
var context = UIGraphics.GetCurrentContext();
39-
context.SetFillColor(Microsoft.Maui.Platform.ColorExtensions.Red.CGColor);
40-
context.FillRect(rect);
41-
DestructiveBackground = UIGraphics.GetImageFromCurrentImageContext();
42-
43-
context.SetFillColor(Microsoft.Maui.Platform.ColorExtensions.LightGray.CGColor);
44-
context.FillRect(rect);
45-
46-
NormalBackground = UIGraphics.GetImageFromCurrentImageContext();
47-
48-
context.Dispose();
37+
using var renderer = new UIGraphicsImageRenderer(size);
38+
DestructiveBackground = renderer.CreateImage((UIGraphicsImageRendererContext ctx) =>
39+
{
40+
FillRect(ctx, rect, ColorExtensions.Red.CGColor);
41+
});
42+
NormalBackground = renderer.CreateImage((UIGraphicsImageRendererContext ctx) =>
43+
{
44+
FillRect(ctx, rect, ColorExtensions.LightGray.CGColor);
45+
});
4946
}
5047

5148
public ContextActionsCell() : base(UITableViewCellStyle.Default, Key)
@@ -84,6 +81,13 @@ public void Close()
8481
_scroller.ContentOffset = new PointF(0, 0);
8582
}
8683

84+
static void FillRect(UIGraphicsImageRendererContext ctx, RectangleF rect, CGColor color)
85+
{
86+
var context = ctx.CGContext;
87+
context.SetFillColor(color);
88+
context.FillRect(rect);
89+
}
90+
8791
public override void LayoutSubviews()
8892
{
8993
base.LayoutSubviews();

src/Controls/src/Core/Platform/iOS/Extensions/BrushExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static UIImage GetBackgroundImage(this UIView control, Brush brush)
120120

121121
var backgroundLayer = control.GetBackgroundLayer(brush);
122122

123-
if (backgroundLayer is null)
123+
if (backgroundLayer is null || backgroundLayer.Bounds.Size.Width <= 0 || backgroundLayer.Bounds.Size.Height <= 0)
124124
{
125125
return null;
126126
}
26.4 KB
Loading
20 KB
Loading
24.3 KB
Loading
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.None, 26593, "Table View ContextActionCell Test")]
4+
public class ContextActionCellTest : TestContentPage
5+
{
6+
TableSection dataSection;
7+
TableView tableView;
8+
9+
protected override void Init()
10+
{
11+
dataSection = new TableSection {
12+
new TextCell{ Text = "Text Cell", ContextActions = { new MenuItem{ Text = "Save" } } },
13+
new TextCell{ Text = "Text Cell 1" },
14+
new SwitchCell { Text = "Switch Cell", On = true },
15+
};
16+
17+
tableView = new TableView
18+
{
19+
Root = new TableRoot { dataSection }
20+
};
21+
22+
Content = tableView;
23+
}
24+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.None, 26593, "FlyoutTest", PlatformAffected.iOS)]
4+
public partial class FlyoutTest : TestShell
5+
{
6+
7+
Tab tabOne = new Tab { Title = "TabOne" };
8+
Tab tabTwo = new Tab { Title = "TabTwo " };
9+
protected override void Init()
10+
{
11+
var tabOnePage = new ContentPage();
12+
var stackLayout = new StackLayout();
13+
stackLayout.Children.Add(new Label { Text = "Tab 1 Page", AutomationId = "Tab1Page", HorizontalOptions = LayoutOptions.Center });
14+
tabOnePage.Content = stackLayout;
15+
tabOne.Items.Add(tabOnePage);
16+
17+
var button = new Button();
18+
button.Text = "Change Flyout Background";
19+
button.AutomationId = "ChangeFlyoutBackground";
20+
button.Clicked += ButtonClicked;
21+
stackLayout.Children.Add(button);
22+
23+
var tabTwoPage = new ContentPage();
24+
var stackLayout2 = new StackLayout();
25+
stackLayout2.Children.Add(new Label { Text = "Tab 2 Page", HorizontalOptions = LayoutOptions.Center });
26+
tabTwoPage.Content = stackLayout2;
27+
tabTwo.Items.Add(tabTwoPage);
28+
29+
var flyoutItem = new FlyoutItem
30+
{
31+
Title = "Tab 1",
32+
Icon = "bank.png",
33+
Items = { tabOne }
34+
};
35+
36+
var flyoutItem2 = new FlyoutItem
37+
{
38+
Title = "Tab 2",
39+
Icon = "coffee.png",
40+
Items = { tabTwo }
41+
};
42+
Items.Add(flyoutItem);
43+
Items.Add(flyoutItem2);
44+
}
45+
46+
private void ButtonClicked(object sender, EventArgs e)
47+
{
48+
SetValue(Shell.FlyoutBackgroundProperty, Colors.LightBlue);
49+
}
50+
51+
}
14.8 KB
Loading
9.24 KB
Loading

0 commit comments

Comments
 (0)