Nick's .NET Travels

Continually looking for the yellow brick road so I can catch me a wizard....

Do changes to Australian media ownership laws mean the end of boutique media outlets?

I wonder how much of this discussion will be focused around new-media v's old-media.  To be honest I can't remember the last time I read the paper hoping to find out what is going on in the world - most of the Australia papers are little more than light comedy relief.  Most of my news, current affairs and technology information comes online from one of my countless rss feeds.  If I can't subscribe to it I can guarantee I'll only look at it once. 

Personally I'm looking forward to this discussion and would encourage others to attend:

 

INVITATION
Walkley Media Forum – The War of Attrition: Influence & Diversity
Thursday 23rd August 2007, 6.30pm
The Ernst & Young Building
11 Mounts Bay Rd, Perth


New federal laws are radically reshaping Australian media ownership. The first round of mergers has seen Rural Press swallow up Fairfax, Packer capture Channel Nine Perth and Seven Network seize a strategic stake in The West Australian. What does this mean for WA and where are our media industries headed?

Join our panel of experts to find out more about the future of our work. Moderated by Michael Sinclair-Jones, WA Branch Secretary, Media Entertainment & Arts Alliance

Panellists include:

· Gary Adshead, Snr Reporter Channel 7

· Bronwen Clune, founder Norg Media

· Martin Turner, Community Newspaper Group

RSVP to the Alliance call 1300 65 65 13 or email [email protected]

Comments are closed
Building a TipCalc using Platform Uno

Nick's .NET Travels

Continually looking for the yellow brick road so I can catch me a wizard....

Building a TipCalc using Platform Uno

Recently I’ve been playing around with Platform.Uno – I’ve long held the view that Microsoft’s Xamarin.Forms was a stop-gap in delivering a true cross-platform solution. Whilst Xamarin.Forms is a highly productive platform, it has some severe limitations, specifically around overriding the look and feel of the native controls. This is where Flutter has stolen a lot of mindshare, mainly because customers and companies looking to build apps, no longer look for apps that match the platform style. They’re much more focussed on strong brand presence and great user experience, meaning that a great Material app on iOS will get better reviews and usage than a mediocre app that uses the default iOS style. Platform Uno attempts to deliver on what I believe the Universal Windows Platform (UWP) should have been – taking UWP XAML across iOS, Android and Web Assembly.

Anyhow, here goes with building a TipCalc. I’ll start with the basic UWP application:

I’ll create a separate project for our ViewModel:

Running the UWP app at this point gives an operational tip calculator

image

So now, let’s add some Uno goodness. We’ll start by moving the MainPage.xaml into its own class library:

  • Add a new project based on the Class Library (.NET Standard) project template, TipCalc.UI
  • Remove class1.cs
  • Add reference to project TipCalc.Core
  • Move MainPage.xaml and MainPage.xaml.cs to the TipCalc.UI project
  • Change namespace from TipCalc.UWP to TipCalc.UI for both MainPage.xaml and MainPage.xaml.cs
  • Edit TipCalc.UI.csproj to allow it to multi-target (ie generate multiple dlls that target UWP, Droid, iOS etc) and make sure correct build action is set for MainPage.xaml
  • Add reference to Uno.UI nuget package (currently in prerelease).
  • Final TipCalc.UI.csproj should look similar to

  • <Project Sdk="MSBuild.Sdk.Extras/1.5.4">
       <PropertyGroup>
         <TargetFrameworks>xamarinios10;MonoAndroid80;uap10.0</TargetFrameworks>
       </PropertyGroup>

      <PropertyGroup Condition=" '$(TargetFramework)' == 'uap10.0' ">
         <GenerateLibraryLayout>true</GenerateLibraryLayout>
       </PropertyGroup>

      <ItemGroup Condition=" '$(TargetFramework)' == 'uap10.0' ">
         <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.1.5" />
       </ItemGroup>

      <ItemGroup>
         <PackageReference Include="Uno.UI" Version="1.31.0-dev.52" />
       </ItemGroup>

      <ItemGroup>
         <Page Include="MainPage.xaml">
           <SubType>Designer</SubType>
           <Generator>MSBuild:Compile</Generator>
         </Page>
       </ItemGroup>

      <ItemGroup>
         <ProjectReference Include="..\TipCalc.Core\TipCalc.Core.csproj" />
       </ItemGroup>
    </Project>

  • Add Uno.UI nuget reference to TipCalc.Core. Resulting csproj should look similar to

  • <Project Sdk="MSBuild.Sdk.Extras/1.5.4">
       <PropertyGroup>
         <TargetFrameworks>xamarinios10;MonoAndroid80;uap10.0</TargetFrameworks>
       </PropertyGroup>

      <ItemGroup>
         <PackageReference Include="Uno.UI" Version="1.31.0-dev.52" />
       </ItemGroup>
    </Project>

  • Add reference to TipCalc.UI to TipCalc.UWP

By all accounts at this point you’ve done a fair bit of lifting with out much to show for it. In fact, because of some absolute genius coding by Microsoft, if you run the UWP application at this point you’ll most likely see a System.AccessViolationException when attempting to navigate to MainPage

image

This seems to be an issue where you’re attempting to navigate to a page that’s defined in a separate assembly and there are no other XAML pages defined in the head (ie UWP) project. Simple solution is just to add a dummy page to the UWP project that you’ll never use…. but seriously Microsoft??? Oh, and this isn’t the first time this has been pointed out (see https://social.msdn.microsoft.com/Forums/windowsserver/en-US/4efa91ad-fa8f-45f0-9864-c2fd2b24477c/uwpc-accessviolationexception-when-navigating-froma-another-assembly?forum=wpdevelop which links to an old post http://danielvaughan.org/posts/uwp/2015/08/15/UWP-AccessViolationException-when-Navigating-to-a-Page-in-Another-Assembly/)

Right, so the question is – after all this effort, how are we any closer to having a cross platform application. Well, let’s spit out the Android build:

  • Add a new project based on the Android App (Xamarin) project template, TipCalc.Droid
    image
  • Use the Blank App template
  • Uninstall any of the Xamarin.Android.Support nuget packages that are installed by default
  • Add reference to Uno.UI nuget package
  • Add reference to both TipCalc.UI and TipCalc.Core
  • Add a reference to Mono.Android.Export
    image
  • Add App.xaml and App.xaml.cs from the TipCalc.UWP project to the TipCalc.Droid project As Link
    image
  • Alter MainActivity to the following

  • [Activity(
         MainLauncher = true,
         ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize,
         WindowSoftInputMode = SoftInput.AdjustNothing | SoftInput.StateHidden
    )]
    public class MainActivity : Windows.UI.Xaml.ApplicationActivity
    {
    }

  • Add an Application class as follows

  • [global::Android.App.ApplicationAttribute(
         Label = "@string/app_name",
         LargeHeap = true,
         HardwareAccelerated = true,
         Theme = "@style/AppTheme"
    )]
    public class Application : Windows.UI.Xaml.NativeApplication
    {
         public Application(IntPtr javaReference, JniHandleOwnership transfer)
             : base(new App(), javaReference, transfer)
         {
         }
    }

Now we’re good to go. Set the TipCalc.Droid to be the start up project and off we go. The app looks basically the same as it did on UWP

image

This took quite a bit of effort to get going but now that it’s there, you can imagine that productivity is going to be quite good. Next up I’ll add in the iOS project but I don’t envisage that, nor Web Assembly, being that hard from the samples I’ve seen to date.

Source code available at https://github.com/nickrandolph/UnoSamples

Comments are closed