Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Xamarin & MvvmCross

Xamarin & MvvmCross

Building Native Cross-Platform Apps with Xamarin & MvvmCross

Martijn van Dijk

November 12, 2015
Tweet

More Decks by Martijn van Dijk

Other Decks in Technology

Transcript

  1. 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
  2. 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
  3. 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
  4. 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
  5. Cross-platform Supported platforms ▪ Android ▪ iOS ▪ Windows ▪

    Xamarin.Forms ▪ tvOS ▪ Google wear ▪ iWatch ▪ Mac
  6. 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
  7. 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
  8. 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
  9. Generics ▪ MvvmCross uses CoC (Convention over Configuration) by default

    - LoginView > LoginViewModel ▪ Generics can be used too - LoginView : MvxActivity<LoginViewModel> - MainView : MvxActivity<SomeDifferentNameViewModel> ▪ Possible to override in setup - protected override IDictionary<Type, Type> GetViewModelViewLookup()
  10. 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<T>();
  11. 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