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

Make Device.Idiom and Device.RuntimePlatform use Essentials #4548

Merged
merged 11 commits into from
Feb 9, 2022

Conversation

mattleibow
Copy link
Member

@mattleibow mattleibow commented Feb 7, 2022

Description of Change

This PR makes the Device.Idiom property get the value from Essentials instead of IPlatformServices.

Swapping out of this feature for testing can now be done in essentials using the DeviceInfo.SetCurrent(IDeviceInfo) member.

Additions made

  • Removes Device.SetIdiom and Device.SetTargetIdiom
  • Removes IPlatformServices.RuntimePlatform
  • Device.Idiom now just returns DeviceInfo.Idiom
  • Device.RuntimePlatform now just returns DeviceInfo.Platform
  • Added a MockDeviceInfo for unit testing

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)
  • Targets a single property for a single control (or intertwined few properties)
  • Adds the property to the appropriate interface
  • Avoids any changes not essential to the handler property
  • Adds the mapping to the PropertyMapper in the handler
  • Adds the mapping method to the WinUI, Android, iOS, and Standard aspects of the handler
  • Implements the actual property updates (usually in extension methods in the Platform section of Core)
  • Tags ported renderer methods with [PortHandler]
  • Adds an example of the property to the sample project (MainPage)
  • Adds the property to the stub class
  • Implements basic property tests in DeviceTests

Does this PR touch anything that might affect accessibility?

  • Does this PR introduce a new control? (If yes, add an example using SemanticProperties to the SemanticsPage)
  • APIs that modify focusability?
  • APIs that modify any text property on a control?
  • Does this PR modify view nesting or view arrangement in anyway?
  • Is there the smallest possibility that your PR will change accessibility?
  • I'm not sure, please help me

If any of the above checkboxes apply to your PR, then the PR will need to provide testing to demonstrate that accessibility still works.

@mattleibow mattleibow self-assigned this Feb 7, 2022
@mattleibow mattleibow added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Feb 7, 2022
@mattleibow mattleibow added this to the 6.0.300-preview.14 milestone Feb 7, 2022
Comment on lines +35 to +52
public static TargetIdiom Idiom
{
get
{
var idiom = DeviceInfo.Idiom;
if (idiom == DeviceIdiom.Tablet)
return TargetIdiom.Tablet;
if (idiom == DeviceIdiom.Phone)
return TargetIdiom.Phone;
if (idiom == DeviceIdiom.Desktop)
return TargetIdiom.Desktop;
if (idiom == DeviceIdiom.TV)
return TargetIdiom.TV;
if (idiom == DeviceIdiom.Watch)
return TargetIdiom.Watch;
return TargetIdiom.Unsupported;
}
}
Copy link
Member Author

@mattleibow mattleibow Feb 7, 2022

Choose a reason for hiding this comment

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

This is technically not very extensible, but in reality, this API needs to be obsoleted. I'll do that in another PR because that will involve many code changes. #4549

@mattleibow mattleibow changed the title Make Device.Idiom use Essentials Make Device.Idiom and Device.RuntimePlatform use Essentials Feb 8, 2022
@@ -152,7 +152,6 @@ Task("dotnet-test")
"**/Core.UnitTests.csproj",
"**/Essentials.UnitTests.csproj",
"**/Resizetizer.UnitTests.csproj",
"**/Controls.Sample.Tests.csproj"
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved these tests into Controls.Core.UnitTests.csproj since that is all it really was.

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@mattleibow mattleibow enabled auto-merge (squash) February 8, 2022 17:11
@mattleibow mattleibow merged commit 0809cee into main Feb 9, 2022
@mattleibow mattleibow deleted the dev/device-idiom branch February 9, 2022 05:16
@jsuarezruiz jsuarezruiz mentioned this pull request Feb 10, 2022
2 tasks
@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 2023
@samhouts samhouts added the fixed-in-6.0.200-preview.14.2 Look for this fix in 6.0.200-preview.14.2! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-6.0.200-preview.14.2 Look for this fix in 6.0.200-preview.14.2! legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor
Projects
No open projects
Status: Done
4 participants