SlideShare a Scribd company logo
1 of 39
Download to read offline
MvvmCross
Building Native Cross-Platform Apps
Martijn van Dijk
github.com/martijn00
speakerdeck.com/martijn00
@mhvdijk
mhvdijk@gmail.com
1
22
Progress is teamwork
The history of
MvvmCross
3
Started by
Stuart Lodge
Started as fork of
MonoCross (Mvc framework)
November 2012
4
Evolved into
MvvmCross
Taken over by
● Tomasz Cielecki / Cheesebaron
● Martijn van Dijk / Martijn00
+ Many others
June 2013
5
Android support
added
June 2015
Xamarin.Forms
added
August 2015
Plugin structure
added
September 2015
6
iOS support
added
February 2016 And more in the future!
7
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
8
Why
MvvmCross?
9
10
Cross platform
awesomeness!
Support for all major
platforms
Most advanced Mvvm
library for Xamarin and
.NET cross platform
11
Large and engaged
community
Fast release cycle
Clean & easy conventions
12
I love
MvvmCross
I am really
impressed
with
MvvmCross
Miguel de Icaza
Xamarin CTO
Scott Hanselman
Microsoft Developer
Evangelist
13
MvvmCross
Supported platforms
■ Android
■ iOS
■ Windows
■ Xamarin.Forms
■ Mac
■ And more!
14
MvvmCross
Highlights
■ Flexible architecture
■ PCL based
■ Inversion of Control
■ Dependency injection
■ Value Converters
■ Bindings
■ Testable
■ Plugins
15
Let take a look
at setting up a
basic project
16
1717
Bindings
iOS:
var set = this.CreateBindingSet<MainViewController,
MainViewModel>();
set.Bind(Label).To(vm => vm.Title);
set.Apply();
Android:
local:MvxBind="Text Title"
18
Device & platform fragmentation
19
■ Customize view presentation
■ Platform-specific
■ Still retain View Model logic
■ Presentation hints
The solution?
MvvmCross presenters
2020
Let’s take a look at
some samples
2121
Hamburger
menu Segmented
control
Tab bar
2222
iOS presenter
// Override the IMvxIosViewPresenter to customize iOS presentation
protected override IMvxIosViewPresenter CreatePresenter()
{
return new MvxSidePanelsPresenter((MvxApplicationDelegate)ApplicationDelegate, Window);
}
// Use the Panel attribute to indicate where a viewcontroller is shown on the screen
[MvxPanelPresentation(MvxPanelEnum.Left, MvxPanelHintType.ActivePanel, false)]
public class LeftPanelView : BaseViewController<LeftPanelViewModel>
2323
Navigation
drawer Tabs
Floating
action button
2424
Android fragment presenter
// To use a custom presenter override the IMvxAndroidViewPresenter in your Android setup.cs
protected override IMvxAndroidViewPresenter CreateViewPresenter()
{
var mvxFragmentsPresenter = new MvxFragmentsPresenter(AndroidViewAssemblies);
Mvx.RegisterSingleton<IMvxAndroidViewPresenter>(mvxFragmentsPresenter);
return mvxFragmentsPresenter;
}
// Use the Fragment attribute to show fragments within an Android Activity
[MvxFragment(typeof (MainViewModel), Resource.Id.content_frame, false)]
[Register("com.sample.droid.fragments.LoginFragment")]
public class LoginFragment : BaseFragment<LoginViewModel>
25
■ Tabs / Panorama
■ Split View / Master-Detail
■ Fragments
■ Modals
■ Hamburger menu
Technical implementations
2626
Enables the best
Native UI
Build beautiful Native Apps
using Xamarin and
MvvmCross!
Easy to implement
custom presenters
Enables you to customize the
behavior of your app without
making your app multiple
times
Most code reuse
Using the presenters saves you
budget because you only need
to code navigation once
Recap of MvvmCross presenters
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.cs
- protected override IDictionary<Type, Type>
GetViewModelViewLookup()
27
IoC (Inversion of Control)
1. Use interfaces
2. Define implementation of interfaces at runtime
3. Job done! :)
■ Singleton: Mvx.RegisterSingleton<T>();
■ Lazy: Mvx.ConstructAndRegisterSingleton<T>();
■ Dynamic: Mvx.RegisterType<T>();
Mvx.Resolve<T>();
28
Dependency Injection
public class MyViewModel : MvxViewModel
{
public MyViewModel(IMvxJsonConverter
jsonConverter, IMvxGeoLocationWatcher
locationWatcher)
{
// Do stuff....
}
}
29
■ Accelerometer
■ Download Cache
■ Email
■ File
■ Json
■ Localization
■ Location
Plugins available at
https://github.com/MvvmCross/MvvmCross-Plugins
■ Messenger
■ Phone Call
■ Picture Chooser
■ SQLite
■ Visibility
■ Web Browser
+ Many More!
30
MvvmCross
Plugins
Messenger
public class LocationViewModel
: MvxViewModel
{
private readonly MvxSubscriptionToken _token;
public LocationViewModel(IMvxMessenger messenger)
{
_token = messenger.Subscribe<LocationMessage>(OnLocationMessage);
}
private void OnLocationMessage(LocationMessage locationMessage)
{
Lat = locationMessage.Lat;
Lng = locationMessage.Lng;
}
} 31
Material Design support for MvvmCross
■ V7 AppCompat
- MvxCachingFragmentActivity
- android:Theme
- Toolbar
- DrawerToggle
■ Core.UI
- SwipeRefresh
- DrawerLayout
■ Core.Utils
- WakefulBroadcastReceiver
■ Fragments
- Support Fragment
- ViewPager (FragmentStatePager)
■ RecyclerView
- ItemTouchHelper for Xamarin
- Multiple item templates
■ Design
- NavigationView
- FloatingActionButton
■ Compat
■ Media.Compat
■ LeanBack
■ Preference
32
See it in action,
demo time!
33
Other Material &
Android support libraries
■ Cardview
■ Pallete
■ Gridlayout
■ Mediarouter
■ V8 Support
■ V13 Support
■ Annotations support
■ Custom tabs
■ Percent support
■ Recommendation support
34
3535
Testing
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
}
}
■ Github.com/MvvmCross
■ MvvmCross.com
■ Slack (#mvvmcross)
■ Stackoverflow
■ Xamarin Forums
MvvmCross
Resources
36
Tips
■ Keep it simple
■ Separation of Concerns
■ Don’t try to invent the wheel
again, use plugins, samples, etc.
■ Use the Analysis plugin to fix
common mistakes
37
Get help on Slack
xamarinchat.herokuapp.com
#MvvmCross channel
Follow influencers
#MvvmCross
@Mhvdijk
@Cheesebaron
@MvvmCross
Join the LinkedIn group
linkedin.com/groups/8456977
MvvmCross & Xamarin group
Contribute on Github
github.com/MvvmCross/MvvmCross
38
Get involved!
Questions?
Martijn van Dijk
github.com/martijn00
speakerdeck.com/martijn00
@mhvdijk
mhvdijk@gmail.com
39

More Related Content

Recently uploaded

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Recently uploaded (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Martijn Van Dijk - MvvmCross Singapore Dev Days 2016

  • 1. MvvmCross Building Native Cross-Platform Apps Martijn van Dijk github.com/martijn00 speakerdeck.com/martijn00 @mhvdijk mhvdijk@gmail.com 1
  • 4. Started by Stuart Lodge Started as fork of MonoCross (Mvc framework) November 2012 4
  • 5. Evolved into MvvmCross Taken over by ● Tomasz Cielecki / Cheesebaron ● Martijn van Dijk / Martijn00 + Many others June 2013 5
  • 6. Android support added June 2015 Xamarin.Forms added August 2015 Plugin structure added September 2015 6
  • 7. iOS support added February 2016 And more in the future! 7
  • 8. 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 8
  • 10. 10 Cross platform awesomeness! Support for all major platforms Most advanced Mvvm library for Xamarin and .NET cross platform
  • 11. 11 Large and engaged community Fast release cycle Clean & easy conventions
  • 12. 12
  • 13. I love MvvmCross I am really impressed with MvvmCross Miguel de Icaza Xamarin CTO Scott Hanselman Microsoft Developer Evangelist 13
  • 14. MvvmCross Supported platforms ■ Android ■ iOS ■ Windows ■ Xamarin.Forms ■ Mac ■ And more! 14
  • 15. MvvmCross Highlights ■ Flexible architecture ■ PCL based ■ Inversion of Control ■ Dependency injection ■ Value Converters ■ Bindings ■ Testable ■ Plugins 15
  • 16. Let take a look at setting up a basic project 16
  • 17. 1717 Bindings iOS: var set = this.CreateBindingSet<MainViewController, MainViewModel>(); set.Bind(Label).To(vm => vm.Title); set.Apply(); Android: local:MvxBind="Text Title"
  • 18. 18 Device & platform fragmentation
  • 19. 19 ■ Customize view presentation ■ Platform-specific ■ Still retain View Model logic ■ Presentation hints The solution? MvvmCross presenters
  • 20. 2020 Let’s take a look at some samples
  • 22. 2222 iOS presenter // Override the IMvxIosViewPresenter to customize iOS presentation protected override IMvxIosViewPresenter CreatePresenter() { return new MvxSidePanelsPresenter((MvxApplicationDelegate)ApplicationDelegate, Window); } // Use the Panel attribute to indicate where a viewcontroller is shown on the screen [MvxPanelPresentation(MvxPanelEnum.Left, MvxPanelHintType.ActivePanel, false)] public class LeftPanelView : BaseViewController<LeftPanelViewModel>
  • 24. 2424 Android fragment presenter // To use a custom presenter override the IMvxAndroidViewPresenter in your Android setup.cs protected override IMvxAndroidViewPresenter CreateViewPresenter() { var mvxFragmentsPresenter = new MvxFragmentsPresenter(AndroidViewAssemblies); Mvx.RegisterSingleton<IMvxAndroidViewPresenter>(mvxFragmentsPresenter); return mvxFragmentsPresenter; } // Use the Fragment attribute to show fragments within an Android Activity [MvxFragment(typeof (MainViewModel), Resource.Id.content_frame, false)] [Register("com.sample.droid.fragments.LoginFragment")] public class LoginFragment : BaseFragment<LoginViewModel>
  • 25. 25 ■ Tabs / Panorama ■ Split View / Master-Detail ■ Fragments ■ Modals ■ Hamburger menu Technical implementations
  • 26. 2626 Enables the best Native UI Build beautiful Native Apps using Xamarin and MvvmCross! Easy to implement custom presenters Enables you to customize the behavior of your app without making your app multiple times Most code reuse Using the presenters saves you budget because you only need to code navigation once Recap of MvvmCross presenters
  • 27. 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.cs - protected override IDictionary<Type, Type> GetViewModelViewLookup() 27
  • 28. IoC (Inversion of Control) 1. Use interfaces 2. Define implementation of interfaces at runtime 3. Job done! :) ■ Singleton: Mvx.RegisterSingleton<T>(); ■ Lazy: Mvx.ConstructAndRegisterSingleton<T>(); ■ Dynamic: Mvx.RegisterType<T>(); Mvx.Resolve<T>(); 28
  • 29. Dependency Injection public class MyViewModel : MvxViewModel { public MyViewModel(IMvxJsonConverter jsonConverter, IMvxGeoLocationWatcher locationWatcher) { // Do stuff.... } } 29
  • 30. ■ Accelerometer ■ Download Cache ■ Email ■ File ■ Json ■ Localization ■ Location Plugins available at https://github.com/MvvmCross/MvvmCross-Plugins ■ Messenger ■ Phone Call ■ Picture Chooser ■ SQLite ■ Visibility ■ Web Browser + Many More! 30 MvvmCross Plugins
  • 31. Messenger public class LocationViewModel : MvxViewModel { private readonly MvxSubscriptionToken _token; public LocationViewModel(IMvxMessenger messenger) { _token = messenger.Subscribe<LocationMessage>(OnLocationMessage); } private void OnLocationMessage(LocationMessage locationMessage) { Lat = locationMessage.Lat; Lng = locationMessage.Lng; } } 31
  • 32. Material Design support for MvvmCross ■ V7 AppCompat - MvxCachingFragmentActivity - android:Theme - Toolbar - DrawerToggle ■ Core.UI - SwipeRefresh - DrawerLayout ■ Core.Utils - WakefulBroadcastReceiver ■ Fragments - Support Fragment - ViewPager (FragmentStatePager) ■ RecyclerView - ItemTouchHelper for Xamarin - Multiple item templates ■ Design - NavigationView - FloatingActionButton ■ Compat ■ Media.Compat ■ LeanBack ■ Preference 32
  • 33. See it in action, demo time! 33
  • 34. Other Material & Android support libraries ■ Cardview ■ Pallete ■ Gridlayout ■ Mediarouter ■ V8 Support ■ V13 Support ■ Annotations support ■ Custom tabs ■ Percent support ■ Recommendation support 34
  • 35. 3535 Testing 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 } }
  • 36. ■ Github.com/MvvmCross ■ MvvmCross.com ■ Slack (#mvvmcross) ■ Stackoverflow ■ Xamarin Forums MvvmCross Resources 36
  • 37. Tips ■ Keep it simple ■ Separation of Concerns ■ Don’t try to invent the wheel again, use plugins, samples, etc. ■ Use the Analysis plugin to fix common mistakes 37
  • 38. Get help on Slack xamarinchat.herokuapp.com #MvvmCross channel Follow influencers #MvvmCross @Mhvdijk @Cheesebaron @MvvmCross Join the LinkedIn group linkedin.com/groups/8456977 MvvmCross & Xamarin group Contribute on Github github.com/MvvmCross/MvvmCross 38 Get involved!