Home

Lessons learned: Updating an app from copied Duo lib files to Xamarin.Forms.DualScreen NuGet package

%3CLINGO-SUB%20id%3D%22lingo-sub-1172368%22%20slang%3D%22en-US%22%3ELessons%20learned%3A%20Updating%20an%20app%20from%20copied%20Duo%20lib%20files%20to%20Xamarin.Forms.DualScreen%20NuGet%20package%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1172368%22%20slang%3D%22en-US%22%3E%3CP%3EI%20just%20updated%20my%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Ftscholze%2Fxamarin-road-to-surface-duo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%22existing%22%20Surface%20Duo%20app%3C%2FA%3E%20to%20use%20the%20freshly%20released%20%3CA%20title%3D%22Xamarin.Forms.DualScreen%20NuGet%20package%22%20href%3D%22https%3A%2F%2Fwww.nuget.org%2Fpackages%2FXamarin.Forms.DualScreen%2F4.5.0.282-pre4%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EXamarin.Forms.DualScreen%20NuGet%20package%3C%2FA%3E.%20That's%20why%20I%20wanna%20share%20my%20lessons%20learned%2C%20maybe%20some%20will%20be%20for%20others%20obvious%2C%20maybe%20not.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EDo%20not%20forget%3C%2FSTRONG%3E%3C%2FP%3E%3CUL%3E%3CLI%3E%3CU%3EUpdate%3C%2FU%3E%20%3CEM%3EXamarin.Forms%3C%2FEM%3E%20package%2C%20to%20the%20latest%20pre-release%20(don't%20forget%20to%20mark%20the%20checkbox)%3C%2FLI%3E%3CLI%3E%3CU%3EInstall%3C%2FU%3E%20the%20%3CEM%3EXamarin.Forms.DualScreen%3C%2FEM%3E%20package%2C%20it's%20a%20pre-release%26nbsp%3B(don't%20forget%20to%20mark%20the%20checkbox)%3C%2FLI%3E%3CLI%3E%3CU%3EDelete%3C%2FU%3E%20all%20old%20copy-and-pasted%20%22Duo%20Lib%22%20that%20you%20copy%20pasted%20from%20the%20very%20first%20sample%20project%3C%2FLI%3E%3CLI%3E%3CU%3EEmbed%3C%2FU%3E%20new%20namespace%20in%20duo-specific%20(e.g.%20master%2Fdetail%20pages)%20files%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Exmlns%3AdualScreen%3D%22clr-namespace%3AXamarin.Forms.DualScreen%3Bassembly%3DXamarin.Forms.DualScreen%22%E2%80%8B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3E%3CU%3EUpdate%3C%2FU%3E%2C%20usage%20of%20TwoPaneView%20to%20new%20syntax%20with%20child%20elements%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3CTWOPANEVIEW%3E%0A%20%20%20%20%3CTWOPANEVIEW.PANE1%3E%0A%20%20%20%20%20%20%20%20%3CITEMSVIEW%20name%3D%22MasterPane%22%3E%3C%2FITEMSVIEW%3E%0A%20%20%20%20%3C%2FTWOPANEVIEW.PANE1%3E%0A%0A%20%20%20%20%3CTWOPANEVIEW.PANE2%3E%0A%20%20%20%20%20%20%20%20%3CITEMVIEW%20name%3D%22DetailPane%22%3E%3C%2FITEMVIEW%3E%0A%20%20%20%20%3C%2FTWOPANEVIEW.PANE2%3E%0A%3C%2FTWOPANEVIEW%3E%E2%80%8B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3E%3CU%3ECheck%3C%2FU%3E%20if%20you%20set%20the%20config%20values%20correct%20in%20the%20MainActivity.cs%20to%20listen%20on%20Duo-specific%20changes%26nbsp%3B%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EConfigurationChanges%20%3D%20ConfigChanges.ScreenSize%20%7C%20ConfigChanges.Orientation%20%7C%20ConfigChanges.ScreenLayout%20%7C%20ConfigChanges.SmallestScreenSize%E2%80%8B%E2%80%8B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EConclusion%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EIt's%20great%20to%20see%20that%20you%20do%20not%20longer%20need%20copy%20%26amp%3B%20(w%2Fp)asted%20files%20in%20your%20library.%20There%20are%20not%20really%20breaking%20changes.%20It%20took%20me%20max.%20an%20hour%20to%20update%20my%20app.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1172368%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ELessons%20learned%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Contributor

I just updated my "existing" Surface Duo app to use the freshly released Xamarin.Forms.DualScreen NuGet package. That's why I wanna share my lessons learned, maybe some will be for others obvious, maybe not.

 

Do not forget

  • Update Xamarin.Forms package, to the latest pre-release (don't forget to mark the checkbox)
  • Install the Xamarin.Forms.DualScreen package, it's a pre-release (don't forget to mark the checkbox)
  • Delete all old copy-and-pasted "Duo Lib" that you copy pasted from the very first sample project
  • Embed new namespace in duo-specific (e.g. master/detail pages) files

 

 

xmlns:dualScreen="clr-namespace:Xamarin.Forms.DualScreen;assembly=Xamarin.Forms.DualScreen"​

 

 

  • Update, usage of TwoPaneView to new syntax with child elements

 

 

<dualScreen:TwoPaneView>
    <dualScreen:TwoPaneView.Pane1>
        <views:ItemsView x:Name="MasterPane" />
    </dualScreen:TwoPaneView.Pane1>

    <dualScreen:TwoPaneView.Pane2>
        <views:ItemView x:Name="DetailPane" />
    </dualScreen:TwoPaneView.Pane2>
</dualScreen:TwoPaneView>​

 

 

  • Check if you set the config values correct in the MainActivity.cs to listen on Duo-specific changes 

 

 

ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize​​

 

 

Conclusion

It's great to see that you do not longer need copy & (w/p)asted files in your library. There are not really breaking changes. It took me max. an hour to update my app.