Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Switch Off Track Color - Fixes #10099 #10758

Merged
merged 28 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
786613e
Add a default color to the track in the off position
Oct 11, 2022
0292d5d
Merge remote-tracking branch 'origin/main' into FixSwitchTrackColor
Oct 17, 2022
ee176d7
remove unneeded using statement
Oct 17, 2022
8b91c27
Use UIColor to handle dark mode
Oct 20, 2022
890ddd5
remove noise
Oct 20, 2022
614cc22
Merge remote-tracking branch 'origin/main' into FixSwitchTrackColor
Oct 31, 2022
60ea991
Merge remote-tracking branch 'origin/main' into FixSwitchTrackColor
Nov 8, 2022
47b8af2
Add tests and add null checks for getting subviews
Nov 9, 2022
6bf4edf
add new lines
Nov 9, 2022
6defdbe
Merge branch 'main' into FixSwitchTrackColor
tj-devel709 Nov 11, 2022
bf7d903
Merge remote-tracking branch 'origin/main' into FixSwitchTrackColor
Nov 14, 2022
feb48a7
Move the tests into the iOS Test
Nov 14, 2022
11db0f9
remove UIKit on the shared file
Nov 14, 2022
dbfb115
- fix checkbox test
PureWeen Nov 16, 2022
cd6f4b4
fix style
Nov 18, 2022
f0c1b46
Merge remote-tracking branch 'origin/main' into FixSwitchTrackColor
Nov 18, 2022
e366576
removing the few unneeded changes
Nov 21, 2022
84b29ff
move the code from the mapper to the extensions
Nov 22, 2022
c887721
Merge branch 'main' into FixSwitchTrackColor
PureWeen Dec 1, 2022
34743d5
move from extension to mapper and use FirstOrDefault
Mar 29, 2023
f8a41d2
Merge remote-tracking branch 'TJ/FixSwitchTrackColor' into FixSwitchT…
Mar 29, 2023
d210eff
Merge remote-tracking branch 'origin/main' into FixSwitchTrackColor
Mar 29, 2023
de13bee
Auto-format source code
Mar 29, 2023
b2eae95
change test name and make color a static var
Mar 29, 2023
daf8876
Merge remote-tracking branch 'TJ/FixSwitchTrackColor' into FixSwitchT…
Mar 29, 2023
92bc1f9
use Manuels NoLink alternative
Mar 31, 2023
f34cc10
move to arrayExtensions and use different implementation
Mar 31, 2023
50fbc8f
allow param to be null
Apr 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Core/src/Extensions/ArrayExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,7 @@ public static T[] RemoveAt<T>(this T[] self, int index)
/// <param name="self">The array to retrieve the last item from.</param>
/// <returns>An object of type <typeparamref name="T"/> that is the last item in the collection.</returns>
public static T Last<T>(this T[] self) => self[self.Length - 1];

internal static T? FirstOrDefaultNoLinq<T>(this T[] items) => items is null || items.Length == 0 ? default : items[0];
Copy link
Member

@PureWeen PureWeen Apr 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mandel-macaque this look alright to you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I am surprise the compiler is not printing a warning with nullability enabled saying something like 'items is not set as nullable'. I think we probably want to do something like:

Suggested change
internal static T? FirstOrDefaultNoLinq<T>(this T[] items) => items is null || items.Length == 0 ? default : items[0];
internal static T? FirstOrDefaultNoLinq<T>(this T[]? items) => items is null || items.Length == 0 ? default : items[0];

Right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at FirstOrDefaults behavior, this sounds like the correct approach :)

}
}
11 changes: 0 additions & 11 deletions src/Core/src/Platform/iOS/SwitchExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Linq;
using ObjCRuntime;
using UIKit;

namespace Microsoft.Maui.Platform
Expand Down Expand Up @@ -60,14 +58,5 @@ public static void UpdateThumbColor(this UISwitch uiSwitch, ISwitch view)
{
return uISwitch.GetTrackSubview()?.BackgroundColor;
}

internal static T? FirstOrDefaultNoLinq<T>(this T[] items)
{
return items switch
{
[var i, ..] => i,
[] => default,
};
}
}
}