Session dotNed Saturday 28 januari 2017

Preview:

Citation preview

www.bestppt.com

Playtime is over building real-world apps with Xamarin.Forms

28 January 2017

Who is that handsome gentleman anyways?

2

Gerald Versluis@jfversluis

blog.verslu.is

gerald@verslu.is

Feel free to ask

3

Gerald Versluis@jfversluis

blog.verslu.is

gerald@verslu.is

What I have for you today…

4

1 What does it look like? What does it do?The end result

2 What is the structure behind it? What concepts are used?

Architecture

3 What you are here for anyway, demo time!Code

4 Not to miss NuGets for developing with Xamarin

There’s a NuGet for that…

5 Summary, thank you, high fives all aroundIt’s a wrap

The end result

5

BudgetGaming

budgetgaming.nl

• Available in the App Store • Built with Xamarin.Forms • ~1000 users per month

www.bestppt.com

Architecture Great! But what does it look like in diagrams?

7

MVVM

• Model–view–viewmodel • Architectural pattern • Inspired by MVC • Databinding &

Commanding • Uses XAML as binder

Architecture - continued

8

Why MVVM?

ViewView markup code

WinForms, XAML, CSHTML, etc.

Code-behind

Model

• Hard to test • UI and logic is tightly

coupled

Architecture - continued

9

That’s why MVVM!

ViewView markup code

WinForms, XAML, CSHTML, etc.

Code-behind

ModelViewModel

Databinding

& Commands

PropertyChanged

Easy to combine with Dependency Injection

Architecture - continued

10

Databinding

• Crucial for MVVM • Normal class, normal properties • Assign to DataContext property • Implement INotifyChanged • One-way or two-way

Architecture - continued

11

Commands

• Instead of Events • Executes logic • Bindable • Implements ICommand

• Execute • CanExecute • CanExecuteChanged

Architecture - continued

12

FreshMvvm

• Very light-weight • Built with Xamarin.Forms in mind • PageModel to PageModel navigation • Built-in IoC • Open-source (github.com/rid00z/FreshMvvm) • MvvmCross, Prism, Light Mvvm …

Architecture - continued

13

BudgetGaming Website/API

BudgetGaming App

UI iOS

UI Xamarin.Forms

UI Android

ViewModels

Service(s)

Models

Shared code

Architecture - continued

14

Shared code

Portable Class Library Shared Project .NET Standard

Architecture - continued

www.bestppt.com

There’s a NuGet for that… With these NuGets your life will be a lot easier

NuGet packages to make all of our lives easier!

16

Xamarin.Plugins.Settings Simple type (user) settings

Xamarin.Plugins.Connectivity Network connectivity

ACR.UserDialogs Alerts, loading, ActionSheets

FreshMvvm Lightweight, easy to use MVVM framework

PropertyChanged.Fody INotifyPropertyChanged made easy

FFImageLoading Image caching, effects, etc.

Polly Fluent exception handling

Refit Type-safe REST library

Note: install on both PCL and platform project

www.bestppt.com

It’s a wrap Just one more slide

18

• MVVM is awesome • Better testability • Better maintainability • Clean architecture allows better

code sharing

In short…

#shamelessselfpromotion

19

Gerald Versluis@jfversluis

blog.verslu.is

github.com/jfversluis

Recommended