Cross-Platform app with C# and Uno Platform - Part 2
Tags: csharp, mobile, dotnet
Published: 2021-08-09 18:10:00

In part 1, I covered a bit of intro to Uno Platform and the app built on it. I'll close with some thoughts on cross platform development, challenges and alternatives for Uno Platform here and wrap up.   


### Let's talk Cross Platform

Single codebase means simpler maintenance - a feature upgrade is a single change for all platforms. This also means simpler testing and build pipeline too, as you don't need one for every platform or the associated language used for that platform. It does make a good case for itself and seems pretty logical when you think about it, right? If your team is proficient in C# then you're good. If not, how long are you willing to wait, if you are willing to? 

You can visit the technology showcase section of [Uno Platform](https://platform.uno/showcases/), [React Native](https://reactnative.dev/showcase), [Flutter](https://flutter.dev/showcase) and [Xamarin](https://dotnet.microsoft.com/platform/customers/xamarin) and it looks like there are quite a few of them. 
On the flip side, there's this article from [Airbnb](https://medium.com/airbnb-engineering/sunsetting-react-native-1868ba28e30a) and one from [Dropbox](https://dropbox.tech/mobile/the-not-so-hidden-cost-of-sharing-code-between-ios-and-android) as well, where they went back to native. 

So, does a single, shared codebase work for everyone or not? Only way to find out is probably by trying out a sample (and slightly complicated app) and see how it goes, or an internal non-customer facing app to get a feel of how it would work. 

### Third-Party UI Controls for Uno Platform 

In the previous post, I mentioned Windows Community Toolkit for UI controls, but in .NET apps on Windows (WPF, UWP, ASP.NET Core etc.) you have a lot of options for third party controls. With Uno, the [documentation](https://platform.uno/docs/articles/supported-libraries.html?q=syncfusion#control-libraries) lists Syncfusion and Infragistics. Now this app that I have created, is a cut-down version of the Web Assembly version that I created with Blazor. The main reason for this is I don't have those chart controls here for me.

With Syncfusion, it required adding their entire project locally to the solution to integrate it and there was no license specified at that time, so I skipped it. It seems to be [resolved now though](https://github.com/syncfusion/Uno.SfChart/issues/11). Infragistics looks good too but they have a trial license which I didn't go for at that time.

I cannot comment on these as I haven't used them but they are available for Uno. 

### What about Mac?

I started out with the target to have the app run on Windows, Mac, Linux and Android. It worked fine on all except for the Mac. This is due to the way I have created the sample and let's see what that is. UWP allows us to set visual breakpoints and set visual state for each of those. As seen in [this example](https://docs.microsoft.com/en-us/windows/apps/design/basics/xaml-basics-adaptive-layout) -

```
<x:Double x:Key="MinWindowBreakpoint">0</x:Double>
<x:Double x:Key="MediumWindowBreakpoint">641</x:Double>
<x:Double x:Key="LargeWindowBreakpoint">1008</x:Double>

```
We can then specify the Data Template, to optimize the view for that size, and this gets triggered depending on the dimensions specified in the breakpoint. Think of this as a CSS media query, to make it easier to relate to.
In our case, I also have the [command in the viewmodel](https://github.com) that fetches data on startup, asynchronously. This data is being bound to the DataGrid which is present in the above Data Template. This somehow doesn't work on Mac, while it works fine on other platforms. 
I have [opened a GitHub issue](https://github.com/unoplatform/uno/issues/6375) for this and until then, I have the app in Mac without any data, to show that it does launch and also is responsive (visual adaptive breakpoints).

<figure> 
  ![App with default width on Mac](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4wm38d6r126s7213d6nk.png) 
  <figcaption>With Default Width</figcaption> 
</figure> 

if I minimize the app horizontally, it gets to the small breakpoint and readjusts accordingly/

<figure> 
  ![Responsive small width](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1vljxfgtntzt3dq8rp7a.png) 
  <figcaption>Reduced width to see the responsive UI</figcaption> 
</figure> 

### The Players 

There are quite a few alternatives and I'll just list them here as I haven't tried all of them.

* [Flutter](https://flutter.dev/) - Google's UI toolkit offering, using Dart.
* [React Native](https://reactnative.dev/) - Apps for Android and iOS, using React.
* [React Native for Windows and Mac](https://microsoft.github.io/react-native-windows/) - An interesting option to bring React Native apps to Windows and Mac! 
* [Xamarin](https://dotnet.microsoft.com/apps/xamarin) - Extending .NET to multiple platforms including watchOS and tvOS. 
* [.NET MAUI](https://docs.microsoft.com/en-us/dotnet/maui/what-is-maui) - Evolution of Xamarin.Forms, currently in preview.
* [Electron](https://www.electronjs.org/) - Cross platform desktop apps for Windows\Mac\Linux. VS Code is built with Electron. 

### What Next? 

Probably one last port of this app to .NET MAUI, Microsoft's upcoming offering, for comparison. React Native for Windows and Mac looks good for experimenting too.
 
Choice is good.

Cover image [credit](https://pixabay.com/photos/doors-choices-choose-decision-1767562/)