Xamarin and MvvmCross = cross-platform coolness
Click here to load reader
-
Upload
juha-ristolainen -
Category
Software
-
view
790 -
download
0
description
Transcript of Xamarin and MvvmCross = cross-platform coolness
Juha Ristolainen (@Riussi) / Futurice Ltd (@futurice)
Xamarin + MvvmCross = cross-platform coolness8/14/2014
Xamarin
Mobile app development
*Image borrowed from Miguel de Icaza’s BUILD 2014 presentation
Traditional approach• Native apps developed in silos• No code re-use
8/14/2014
Mobile app development
*Image borrowed from Miguel de Icaza’s BUILD 2014 presentation
Xamarin approach• Share common code between
apps• Write native apps with C#
• Amount of platform specific code from a few case studies from Xamarin:
• iOS: 20-30%• Android: 15-20%• Windows Phone: 10-15%
8/14/2014
What Xamarin offers
» C# + Full .NET Runtime (also F# compiler)
» Native UI (iOS + Android)
› Same native UI components
» Native performance
› Compiles from MSIL/CIL into native ARM-code
*Image borrowed from Miguel de Icaza’s BUILD 2014 presentation
Xamarin approach
• Write native apps with C#
• App per platform, use normal platform idioms
• Native APIs wrapped in strongly typed C#
• Share common code between them
• Models, ViewModels, etc.
• Anything you can do on iOS and Android with Obj-C and Java you can do with Xamarin C#
68/14/2014 Futurice
Sharing code
» Shared project
» New Universal App shared
» PCL (Portable Class Library)
» PCL + nuget
› Stick to public API contract that a PCL profile can compile
› Reference assembly that projects use
› Actual implementations can be platform specific and use which ever packages they want
MvvmCross
MvvmCross Manifesto
» Portability
» Interface Driven Development
» Code for Test
» MVVM
» Native Uis
» Your opinion matters
» The app is King
https://github.com/MvvmCross/MvvmCross/wiki/The-MvvmCross-Manifesto
First things
first
› Source code on GitHubhttps://github.com/MvvmCross/MvvmCross
› Get Ninja Coder extension to Visual Studiohttp://bit.ly/ninjacoder-mvvmcross
› I still prefer Visual Studio over Xamarin Studio
App Architecture
› Common Core which contains
› Models
› ViewModels
› Connections to web APIs, etc
› App logic (navigation, etc)
› UI-project per platform
› Platform views
› Android, iOS, Windows Phone, Windows
Service Location
and Inversion of
Control
› MvvmCross uses Service Locator pattern and Inversion of Control heavily
› For more Service Locator basics, see http://msdn.microsoft.com/en-us/library/ff648968.aspx
› For more IoC basics see http://joelabrahamsson.com/inversion-of-control-an-introduction-with-examples-in-net/
› Code against interfaces
› Register implementations with framework
› Mvx.Register methods
› Singletons, lazy initialization, etc.
› Framework handles ctor injection
› Mvx.Resolve methods
Convention over
configuration
› MvvmCross uses Convention over Configuration
› FooViewModel maps to FooView
Navigation
› MvvmCross was born for page-based applications
› Navigation logic in Core
› Icommand
› Capsulate actions to ICommands
› Navigate from ViewModel to ViewModel
› Framework does the page transitions
Plugins
› A lot of functionality available via plugins
› Not everything in a monolithic core lib
› Example: location
› Full list at https://github.com/MvvmCross/MvvmCross/wiki/MvvmCross-plugins
Demo › Creating an app skeleton with MvvmCross