Slide 1

Slide 1 text

Xamarin & MvvmCross Building Native Cross-Platform Apps Martijn van Dijk @mhvdijk [email protected] github.com/martijn00 speakerdeck.com/martijn00

Slide 2

Slide 2 text

Why Xamarin? ⓘ Always look at the requirements of a project ■ 100% Native ■ Full access to platform SDKs ■ BCL, Async, LINQ, etc ■ Shared code across platforms (PCL) using C# and F# ■ Plugins - Nuget - Xamarin Component store

Slide 3

Slide 3 text

Xamarin products ■ Xamarin.Android ■ Xamarin.iOS ■ Xamarin.Mac ■ Xamarin.tvOS ■ Xamarin.WatchOS ■ Xamarin.Forms ■ Xamarin.Apple ■ Xamarin.UITest ■ Xamarin Studio ■ Xamarin Android player ■ Xamarin Insights ■ Xamarin Inspector ■ Xamarin Test Cloud ■ Xamarin Profiler ■ Xamarin Sketches ■ Xamarin CI ■ CocosSharp

Slide 4

Slide 4 text

Why Mvvm? View Binder ViewModel Model Button Text 1. Action 1. Action 3. Command 5. Notify change 6. Change data 4. Access data 2. Event handling

Slide 5

Slide 5 text

Why MvvmCross? ■ Support for all major platforms ■ Most advanced Mvvm library for Xamarin / .NET cross platform ■ Large and engaged community ■ Fast release cycle ■ Clean and easy conventions ■ Used by many enterprise companies e.g: - Microsoft - Xamarin inc. - Dutch government - Olo - Nokia

Slide 6

Slide 6 text

Cross-platform Supported platforms ■ Android ■ iOS ■ Windows ■ Xamarin.Forms ■ tvOS ■ Google wear ■ iWatch ■ Mac

Slide 7

Slide 7 text

MvvmCross details Highlights ■ Flexible architecture ■ PCL based ■ Inversion of Control ■ Dependency injection ■ Value Converters ■ Bindings ■ Testable ■ Plugins Resources ■ Github.com/MvvmCross ■ MvvmCross.com ■ Slack ■ Stackoverflow ■ Xamarin Forums

Slide 8

Slide 8 text

Presenters Specifications ■ Customize view presentation ■ Platform-specific ■ Still retain View Model logic ■ Presentation hints Examples ■ Tabs / Panorama ■ Split View / Master-Detail ■ Fragments ■ Modals ■ Hamburger menu

Slide 9

Slide 9 text

Plugins Xamarin 1. UriTemplates 2. ModernHttpClient 3. Json.Net 4. Akavache 5. Reactive 6. Splat 7. Android Support 8. UserDialogs ■ Messenger ■ Phone Call ■ Picture Chooser ■ SQLite ■ Visibility ■ Web Browser + Many More! MvvmCross ■ Accelerometer ■ Download Cache ■ Email ■ File ■ Json ■ Localization ■ Location Plugins available at https://github.com/MvvmCross/MvvmCross-Plugins

Slide 10

Slide 10 text

Generics ■ MvvmCross uses CoC (Convention over Configuration) by default - LoginView > LoginViewModel ■ Generics can be used too - LoginView : MvxActivity - MainView : MvxActivity ■ Possible to override in setup - protected override IDictionary GetViewModelViewLookup()

Slide 11

Slide 11 text

IoC (Inversion of Control) 1. Use interfaces 2. Choose what implements those interfaces at runtime 3. Job done ■ Singleton: Mvx.RegisterSingleton ■ Lazy: Mvx.ConstructAndRegisterSingleton ■ Dynamic: Mvx.RegisterType Mvx.Resolve();

Slide 12

Slide 12 text

Tips ■ Keep it simple ■ Separation of Concerns ■ Use Xamarin player or GenyMotion as simulator ■ Test all changes (UITest, Unit test, etc) ■ Use a common PCL profile (profile7 or profile259) or .NET Platform Standard ■ Don’t try to invent the wheel again, use plugins, samples, etc ■ Enable “Analysis” XS > Preferences > Text Editor > Source Analysis > Enable ■ Get help on Slack: https://xamarinchat.herokuapp.com/ ■ Follow influencers on Twitter #Xamarin #MvvmCross