Conversation
StephaneDelcroix
left a comment
There was a problem hiding this comment.
I'd prefer to keep this simple, and do
case TargetIdiom.Phone:
return onIdiom.Phone ?? onIdiom.Default;|
@StephaneDelcroix Is there a particular reason for this? The original syntax with explicit property per idiom is still supported, but I thought it would be meaningful to have both The use of |
samhouts
left a comment
There was a problem hiding this comment.
Needs rebase. Thank you!
de2f323 to
aa3e5f7
Compare
… multiple idioms per setting and gracefully falls back to legacy
aa3e5f7 to
4aa5c2c
Compare
|
@samhouts In that case I will make it a |
StephaneDelcroix
left a comment
There was a problem hiding this comment.
The missing feature, as described in #4006, is to add a default Value. There's no point in doing the changes we did for OnPlatform (moving from an enum to a string) as the OnIdiom enum hasn't been deprecated.
|
I understand this, but this syntax is much more powerful as it allows to define the same value for multiple idioms at the same time, without possible unnecessary duplication, as shown in the sample. With the existing syntax (which is still available) we can only set the values one by one. I find this more convenient and valuable. But if you don't share this view, I can revert it back. |
|
@MartinZikmund Thank you for this PR! Please take a look at #4225 and let us know if it provides the same flexibility you're going for here. |
|
@samhouts The reasons for the new syntax still hold, as it closely mirrors how |
Description of Change
The
OnIdiom<T>was not matching the format ofOnPlatform<T>. This PR attempts to upgradeOnIdiomto include matching functionality and more friendly XAML interface.Issues Resolved
API Changes
Added:
T OnIdiom<T>.Default { get; set; }IList<OnIdiomSetting> OnIdiom.Idioms { get; private set; }Platforms Affected
Behavioral/Visual Changes
The legacy syntax for
OnIdiomis still supported and there should be no change required for existing apps.PR adds support for
Defaultvalue, which is on par with{OnIdiom}markup extension and supports even the legacy syntax.The new syntax is very similar to the one provided by
OnPlatform<T>:The only disadvantage is that it is not possible to reuse
<On>as inOnPlatform<T>, because both reside in the same namespace. It would be possible to addIdiomproperty toOnbut that could be confusing to users.Before/After Screenshots
Not applicable
Testing Procedure
I have created demonstration of the
Defaultvalue onIssue4006page in controls gallery.Functionality of
OnIdiom<T>has been covered by tests inXamarin.Forms.Core.UnitTests.OnIdiomTests.PR Checklist