Recently, the Uno Platform team brought a significant new feature – full-fledged cross-platform support for dual-screen devices with the TwoPaneView
. Today, Uno Platform gets support for another unique aspect of the upcoming Surface devices – the hinge angle sensor, just in time for the Microsoft 365 Developer Day for dual-screen devices! So how does it work?
UWP & Surface Neo
On Windows 10X with Universal Windows Platform we can use the Windows.Devices.Sensors.HingeAngleSensor
API to be notified when the hinge's angle changes:
The HingeAngleReading.AngleInDegrees
property gives us the hinge's current angle in degrees. Super easy!
Uno Platform & Surface Duo
Surface Duo runs Android, so its API for hinge sensor is different. However, you don't need to care about these differences if you use the Uno Platform! Just follow three simple steps:
- Reference the
Uno.UI.DualScreen
NuGet package in the Android project and update all Uno Platform packages to version 2.1.0-dev.1181 or newer - Write your UWP code using
Windows.Devices.Sensors.HingeAngleSensor
in the shared project - Run on Android!
With Uno Platform, your UWP implementation just works on Android. No platform-specific code required! Note: The current version of the Surface Duo Emulator does not allow us to change the hinge angle yet. However, this is coming soon, according to the team. In the meantime, you can start developing your app today and it will then just light up once the sensor is available in the emulator. https://twitter.com/gmerin/status/1224868148769198081?s=20
Sample app
To showcase the cross-platform API, I have created a sample Uno Platform application which isavailable here on my GitHub.
Summary
It's exciting to see the new dual screen device coming soon! Even though Surface Neo runs Windows 10X and Surface Duo runs Android, we can write our code once and run everywhere thanks to Uno Platform and new TwoPaneView
and HingeAngleSensor
APIs. So let's Uno, Duo, Neo!