Skip to content

Commit 3c5d9f9

Browse files
Tamilarasan-ParanthamanNafeelaNazhirgithub-actions[bot]
authored andcommitted
Fix up relevant CA1416 warnings - Set 3 (#26751)
* [Testing] Feature Matrix UITest Cases for CollectionView Dynamic changes (#29424) * Added FeatureTests for CollectionView * changes updated * changes updated * [create-pull-request] automated change (#29505) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * CA1416 warning fix * Added snapshots * Reverting files changes * Removed the old approach * Revert unwanted changes * Reverted unwanted changes * Reverted unwanted changes * Revert unwanted changes --------- Co-authored-by: NafeelaNazhir <nafeela.nazhirhussain@syncfusion.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent f456a4e commit 3c5d9f9

File tree

10 files changed

+78
-122
lines changed

10 files changed

+78
-122
lines changed
7.41 KB
Loading
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.None, 26593, "FontImage UI Test", PlatformAffected.iOS)]
4+
public partial class FontImageUITest : ContentPage
5+
{
6+
public FontImageUITest()
7+
{
8+
Grid grid = new Grid();
9+
10+
Image image = new Image
11+
{
12+
Source = new FontImageSource
13+
{
14+
FontFamily = "FA",
15+
Color = Colors.YellowGreen,
16+
Glyph = "\xf133"
17+
},
18+
HeightRequest = 50,
19+
WidthRequest = 50,
20+
AutomationId = "Image"
21+
};
22+
23+
grid.Children.Add(image);
24+
25+
Content = grid;
26+
}
27+
}
43 KB
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues
6+
{
7+
public class FontImageUITest : _IssuesUITest
8+
{
9+
public override string Issue => "FontImage UI Test";
10+
11+
public FontImageUITest(TestDevice device)
12+
: base(device)
13+
{ }
14+
15+
[Test]
16+
[Category(UITestCategories.Image)]
17+
public void VerifyFontImage()
18+
{
19+
App.WaitForElement("Image");
20+
VerifyScreenshot();
21+
}
22+
}
23+
}
5.77 KB
Loading
14.8 KB
Loading

src/Core/src/Hosting/LifecycleEvents/AppHostBuilderExtensions.iOS.cs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,9 @@ static void OnConfigureLifeCycle(IiOSLifecycleBuilder iOS)
4949
app.GetWindow()?.Stopped();
5050
});
5151

52-
53-
// Pre iOS 13 doesn't support scenes
54-
if (!OperatingSystem.IsIOSVersionAtLeast(13))
55-
return;
56-
57-
5852
iOS
5953
.SceneWillEnterForeground(scene =>
6054
{
61-
if (!OperatingSystem.IsIOSVersionAtLeast(13))
62-
return;
63-
6455
if (scene.Delegate is IUIWindowSceneDelegate windowScene &&
6556
scene.ActivationState != UISceneActivationState.Unattached)
6657
{
@@ -69,51 +60,33 @@ static void OnConfigureLifeCycle(IiOSLifecycleBuilder iOS)
6960
})
7061
.SceneOnActivated(scene =>
7162
{
72-
if (!OperatingSystem.IsIOSVersionAtLeast(13))
73-
return;
74-
7563
if (scene.Delegate is IUIWindowSceneDelegate sd)
7664
sd.GetWindow().GetWindow()?.Activated();
7765
})
7866
.SceneOnResignActivation(scene =>
7967
{
80-
if (!OperatingSystem.IsIOSVersionAtLeast(13))
81-
return;
82-
8368
if (scene.Delegate is IUIWindowSceneDelegate sd)
8469
sd.GetWindow().GetWindow()?.Deactivated();
8570
})
8671
.SceneDidEnterBackground(scene =>
8772
{
88-
if (!OperatingSystem.IsIOSVersionAtLeast(13))
89-
return;
90-
9173
if (scene.Delegate is IUIWindowSceneDelegate sd)
9274
sd.GetWindow().GetWindow()?.Stopped();
9375
})
9476
.SceneDidDisconnect(scene =>
9577
{
96-
if (!OperatingSystem.IsIOSVersionAtLeast(13))
97-
return;
98-
9978
if (scene.Delegate is IUIWindowSceneDelegate sd)
10079
sd.GetWindow().GetWindow()?.Destroying();
10180
});
10281
}
10382

10483
static void OnConfigureWindow(IiOSLifecycleBuilder iOS)
10584
{
106-
// Pre iOS 13 doesn't support scenes
107-
if (!OperatingSystem.IsIOSVersionAtLeast(13))
108-
{
109-
return;
110-
}
111-
11285
iOS = iOS
11386
.WindowSceneDidUpdateCoordinateSpace((windowScene, _, _, _) =>
11487
{
11588
// Mac Catalyst version 16+ supports effectiveGeometry property on window scenes.
116-
if (!OperatingSystem.IsIOSVersionAtLeast(13) || (OperatingSystem.IsMacCatalystVersionAtLeast(16)))
89+
if (OperatingSystem.IsMacCatalystVersionAtLeast(16))
11790
{
11891
return;
11992
}

src/Core/src/Platform/iOS/ColorExtensions.cs

Lines changed: 11 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -14,126 +14,57 @@ public static class ColorExtensions
1414

1515
internal static UIColor LabelColor
1616
{
17-
get
18-
{
19-
if (OperatingSystem.IsIOSVersionAtLeast(13) || OperatingSystem.IsTvOSVersionAtLeast(13))
20-
return UIColor.Label;
21-
22-
return UIColor.Black;
23-
}
17+
get => UIColor.Label;
2418
}
2519

2620
internal static UIColor PlaceholderColor
2721
{
28-
get
29-
{
30-
31-
if (OperatingSystem.IsIOSVersionAtLeast(13) || OperatingSystem.IsTvOSVersionAtLeast(13))
32-
return UIColor.PlaceholderText;
33-
34-
return SeventyPercentGrey;
35-
}
22+
get => UIColor.PlaceholderText;
3623
}
3724

3825
internal static UIColor SecondaryLabelColor
3926
{
40-
get
41-
{
42-
43-
if (OperatingSystem.IsIOSVersionAtLeast(13) || OperatingSystem.IsTvOSVersionAtLeast(13))
44-
return UIColor.SecondaryLabel;
45-
46-
return new Color(.32f, .4f, .57f).ToPlatform();
47-
}
27+
get => UIColor.SecondaryLabel;
4828
}
4929

5030
internal static UIColor BackgroundColor
5131
{
52-
get
53-
{
54-
55-
if (OperatingSystem.IsIOSVersionAtLeast(13))
56-
return UIColor.SystemBackground;
57-
58-
return UIColor.White;
59-
}
32+
get => UIColor.SystemBackground;
6033
}
6134

6235
internal static UIColor SeparatorColor
6336
{
64-
get
65-
{
66-
if (OperatingSystem.IsIOSVersionAtLeast(13) || OperatingSystem.IsTvOSVersionAtLeast(13))
67-
return UIColor.Separator;
68-
69-
return UIColor.Gray;
70-
}
37+
get => UIColor.Separator;
7138
}
7239

7340
internal static UIColor OpaqueSeparatorColor
7441
{
75-
get
76-
{
77-
if (OperatingSystem.IsIOSVersionAtLeast(13) || OperatingSystem.IsTvOSVersionAtLeast(13))
78-
return UIColor.OpaqueSeparator;
79-
80-
return UIColor.Black;
81-
}
42+
get => UIColor.OpaqueSeparator;
8243
}
8344

8445
internal static UIColor GroupedBackground
8546
{
86-
get
87-
{
88-
if (OperatingSystem.IsIOSVersionAtLeast(13))
89-
return UIColor.SystemGroupedBackground;
90-
91-
return new UIColor(247f / 255f, 247f / 255f, 247f / 255f, 1);
92-
}
47+
get => UIColor.SystemGroupedBackground;
9348
}
9449

9550
internal static UIColor AccentColor
9651
{
97-
get
98-
{
99-
if (OperatingSystem.IsIOSVersionAtLeast(13) || OperatingSystem.IsTvOSVersionAtLeast(13))
100-
return UIColor.SystemBlue;
101-
102-
return Color.FromRgba(50, 79, 133, 255).ToPlatform();
103-
}
52+
get => UIColor.SystemBlue;
10453
}
10554

10655
internal static UIColor Red
10756
{
108-
get
109-
{
110-
if (OperatingSystem.IsIOSVersionAtLeast(13) || OperatingSystem.IsTvOSVersionAtLeast(13))
111-
return UIColor.SystemRed;
112-
113-
return UIColor.FromRGBA(255, 0, 0, 255);
114-
}
57+
get => UIColor.SystemRed;
11558
}
11659

11760
internal static UIColor Gray
11861
{
119-
get
120-
{
121-
if (OperatingSystem.IsIOSVersionAtLeast(13) || OperatingSystem.IsTvOSVersionAtLeast(13))
122-
return UIColor.SystemGray;
123-
124-
return UIColor.Gray;
125-
}
62+
get => UIColor.SystemGray;
12663
}
12764

12865
internal static UIColor LightGray
12966
{
130-
get
131-
{
132-
if (OperatingSystem.IsIOSVersionAtLeast(13))
133-
return UIColor.SystemGray2;
134-
135-
return UIColor.LightGray;
136-
}
67+
get => UIColor.SystemGray2;
13768
}
13869

13970
public static CGColor ToCGColor(this Color color)

src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,7 @@ internal static void AdjustPosition()
368368
}
369369
else
370370
{
371-
if (OperatingSystem.IsIOSVersionAtLeast(13, 0))
372-
statusBarHeight = window.WindowScene?.StatusBarManager?.StatusBarFrame.Height ?? 0;
373-
else
374-
statusBarHeight = UIApplication.SharedApplication.StatusBarFrame.Height;
371+
statusBarHeight = window.WindowScene?.StatusBarManager?.StatusBarFrame.Height ?? 0;
375372

376373
navigationBarAreaHeight = statusBarHeight;
377374
}

src/Graphics/src/Graphics/Platforms/iOS/UIImageExtensions.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,21 @@ public static UIImage ScaleImage(this UIImage target, float maxWidth, float maxH
2727

2828
public static UIImage ScaleImage(this UIImage target, CGSize size, bool disposeOriginal = false)
2929
{
30-
UIGraphics.BeginImageContext(size);
31-
target.Draw(new CGRect(CGPoint.Empty, size));
32-
var image = UIGraphics.GetImageFromCurrentImageContext();
33-
UIGraphics.EndImageContext();
34-
35-
if (disposeOriginal)
30+
using (var renderer = new UIGraphicsImageRenderer(target.Size))
3631
{
37-
target.Dispose();
38-
}
32+
var resultImage = renderer.CreateImage((UIGraphicsImageRendererContext imageContext) =>
33+
{
34+
var cgcontext = imageContext.CGContext;
35+
cgcontext.DrawImage(new CGRect(CGPoint.Empty, size), target.CGImage);
3936

40-
return image;
37+
if (disposeOriginal)
38+
{
39+
target.Dispose();
40+
}
41+
});
42+
43+
return resultImage;
44+
}
4145
}
4246

4347
public static UIImage NormalizeOrientation(this UIImage target, bool disposeOriginal = false)
@@ -58,6 +62,7 @@ public static UIImage NormalizeOrientation(this UIImage target, bool disposeOrig
5862
target.Draw(CGPoint.Empty);
5963
});
6064

65+
6166
if (disposeOriginal)
6267
{
6368
target.Dispose();
@@ -66,4 +71,4 @@ public static UIImage NormalizeOrientation(this UIImage target, bool disposeOrig
6671
return image;
6772
}
6873
}
69-
}
74+
}

0 commit comments

Comments
 (0)