Slide 1

Slide 1 text

1

Slide 2

Slide 2 text

Agenda 17:00 - 18:00 Walk-in with pizza and drinks 18:00 - 18:10 Welcome and Intro 18:15 - 19:15 MvvmCross 5.0 presentation and demo by Xamarin MVP and MvvmCross lead developer Martijn van Dijk 19:15 onwards “Hack your first app” – mini hackathon where you can start building your first app with Xamarin, MvvmCross and Azure

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

4

Slide 5

Slide 5 text

5 MvvmCross Bootcamp! Build polished mobile apps with MvvmCross Github: github.com/martijn00 Martijn van Dijk Twitter: @Mhvdijk Email: [email protected]

Slide 6

Slide 6 text

What is Mvvm?

Slide 7

Slide 7 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 8

Slide 8 text

The history of MvvmCross

Slide 9

Slide 9 text

Why MvvmCross?

Slide 10

Slide 10 text

Cross platform awesomeness! Support for all major platforms Most advanced Mvvm library for Xamarin and .NET cross platform

Slide 11

Slide 11 text

Large and engaged community Fast release cycle Clean & easy conventions

Slide 12

Slide 12 text

I love MvvmCross I am really impressed with MvvmCross Miguel de Icaza Xamarin CTO Scott Hanselman Microsoft Developer Evangelist

Slide 13

Slide 13 text

Let's take a look at setting up a basic project

Slide 14

Slide 14 text

14 ■ Viewmodels are INotifyPropertyChanged aware public class MyViewModel : MvxViewModel { Task Initialize(MyObject parameter); void Appearing(); void Appeared(); void Disappearing(); void Disappeared(); } ■ ViewModels have lifecycle events ViewModels

Slide 15

Slide 15 text

15 iOS: var set = this.CreateBindingSet(); set.Bind(Label).To(vm => vm.Title); set.Apply(); Android: local:MvxBind="Text Title" Bindings

Slide 16

Slide 16 text

IoC (Inversion of Control) 1. Use interfaces 2. Define implementation of interfaces at runtime 3. Job done! :) ■ Singleton: Mvx.RegisterSingleton(); ■ Lazy: Mvx.ConstructAndRegisterSingleton(); ■ Dynamic: Mvx.RegisterType(); ■ Construct: Mvx.IocConstruct(); Mvx.Resolve();

Slide 17

Slide 17 text

Dependency Injection public class MyViewModel : MvxViewModel { public MyViewModel(IMvxJsonConverter jsonConverter, IMvxGeoLocationWatcher locationWatcher) { // Do stuff.... } }

Slide 18

Slide 18 text

Generics ■ MvvmCross uses CoC (Convention over Configuration) by default LoginView > LoginViewModel ■ Generics are the preferred way LoginView : MvxActivity MyView : MvxActivity MyViewModel : MvxViewModel MyValueConverter : MvxValueConverter

Slide 19

Slide 19 text

19 ■ ViewModel to ViewModel navigation private readonly IMvxNavigationService _navigationService; public MyViewModel(IMvxNavigationService navigation) { _navigationService = navigationService; } public async Task SomeMethod() { var result = await _navigationService.Navigate (new MyObject()); //Do something with the result } Navigation

Slide 20

Slide 20 text

Presenters ■ Customize view presentation ■ One platform-specific presenter per platform ■ Still retain ViewModel logic ■ Presentation hints to customize behavior

Slide 21

Slide 21 text

21 Hamburger menu Segmented control Tab bar

Slide 22

Slide 22 text

22 Navigation drawer Tabs Floating action button

Slide 23

Slide 23 text

View attributes ■ Used to indicate how a view is presented on the screen ■ Possible to implement interface to resolve at runtime iOS [MvxRootPresentation(WrapInNavigationController = true)] public partial class MyView : MvxViewController Android MvxFragment(typeof (MainViewModel), Resource.Id.content_frame, false)] public class MyView : MvxFragment

Slide 24

Slide 24 text

24 Enables the best Native UI Easy to implement custom presenters Most code reuse Recap of MvvmCross presenters

Slide 25

Slide 25 text

See it in action, demo time!

Slide 26

Slide 26 text

Plugins ■ Easy to drop into your project ■ Extends functionality on multiple platforms ■ Lots of MvvmCross plugins available ■ Also 3th party plugins on Nuget All plugins available on Nuget

Slide 27

Slide 27 text

Messenger public class LocationViewModel : MvxViewModel { private readonly MvxSubscriptionToken _token; public LocationViewModel(IMvxMessenger messenger) { _token = messenger.Subscribe(OnLocationMessage); } private void OnLocationMessage(LocationMessage locationMessage) { Lat = locationMessage.Lat; Lng = locationMessage.Lng; } }

Slide 28

Slide 28 text

Value converters ■ Convert bindable properties into a different format public class MyTimeAgoValueConverter : MvxValueConverter { protected override string Convert(DateTime value, Type targetType, object parameter, CultureInfo cultureInfo) { var timeAgo = DateTime.UtcNow - value; if (timeAgo.TotalSeconds < 30) return "just now"; return "previously"; } }

Slide 29

Slide 29 text

Unit & UI tests using MvvmCross.Test.Core; using Moq; using NUnit.Framework; [TestFixture] public class MyTest : MvxIoCSupportingTest { [Test] public void TestViewModel() { base.Setup(); // from MvxIoCSupportingTest // your test code } }

Slide 30

Slide 30 text

30 ■ Everything from MvvmCross available for Xamarin.Forms ■ Use the Mvx base classes for Forms ■ Support for MvvmCross Bindings in Forms layouts ■ Mix native code with Forms ■ Presenters leveraging Xamarin.Forms Xamarin.Forms

Slide 31

Slide 31 text

31 Best Mvvm framework for .NET Easy to learn, extend and customize Most code reuse Recap of MvvmCross

Slide 32

Slide 32 text

What is new in MvvmCross 5

Slide 33

Slide 33 text

Introduction ■ MvvmCross repositories merged into one ■ Issues closed: 337 ■ Pull requests merged: 209 ■ Over 175 contributors

Slide 34

Slide 34 text

Major changes ■ Improved support for Xamarin.Forms ■ Lifecycle/Event hooks ■ Generic and typed bindings ■ Removal of Windows (Phone) 8.x ■ Removal and cleanup of plugins ■ Improved StarterPack ■ New documentation structure ■ CodeStyle cleanup

Slide 35

Slide 35 text

Presenting the new iOS & MacOS Presenter ■ Handles all default navigation patterns ■ Presentation Attributes ■ Override a presentation attribute at runtime ■ Extensibility

Slide 36

Slide 36 text

Navigation service ■ Async await ■ Type safe ■ Uri navigation with deeplinking ■ Events on navigation ■ Testable

Slide 37

Slide 37 text

See it in action, demo time!

Slide 38

Slide 38 text

New documentation ■ New website hosted on Github Pages with Jekyll ■ Super easy to add/modify docs! ■ Make pull requests to suggest changes ■ Available now on: www.mvvmcross.com

Slide 39

Slide 39 text

See it in action, demo time!

Slide 40

Slide 40 text

Roadmap ■ Improved documentation and getting started ■ Code cleanup ■ New presenters for Android, tvOS and other platforms ■ Refactoring of Android Fragments, and lifecycle ■ .NET Standard support ■ More Async & C#7 ■ Tizen support

Slide 41

Slide 41 text

■ MvvmCross.com ■ Github.com/MvvmCross ■ Slack (#mvvmcross) ■ Stackoverflow ■ Xamarin Forums MvvmCross Resources & Documentation 41

Slide 42

Slide 42 text

Questions?

Slide 43

Slide 43 text

Connect with us Follow us on Twitter All our news, events, insights and more @xabluHQ twitter.com/xabluHQ Follow us on Instagram Take a look behind the scenes instagram.com/xabluhq Connect on LinkedIn Link up with employees and get updates on news and events linkedin.com/company/xablu Like us on Facebook Get our news and events in your feed facebook.com/xabluhq

Slide 44

Slide 44 text

Get help on Slack xamarinchat.herokuapp.com #MvvmCross channel Follow influencers #MvvmCross @MvvmCross Support MvvmCross! Opencollective.com/mvvmcross Join the LinkedIn group linkedin.com/groups/8456977 MvvmCross & Xamarin group Contribute on Github Github.com/MvvmCross/MvvmCross 44 Get involved!

Slide 45

Slide 45 text

Hackathon Let’s build your first connected app with Xamarin and MvvmCross! - We’ve prepared an assignment for you on our Github page: http://xab.lu/meetup19