Xamarin: From Zero to Hero: KEMBIT Meetup 29 september 2016

Post on 13-Jan-2017

62 views 2 download

Transcript of Xamarin: From Zero to Hero: KEMBIT Meetup 29 september 2016

www.bestppt.com

Xamarin

FROM ZERO TO HERO

29 september 2016

INTRODUCTIE

2

Gerald Versluis@jfversluis

blog.verslu.is

gerald@verslu.is

INTRODUCTIE

3

Gerald Versluis@jfversluis

blog.verslu.is

gerald@verslu.is

www.bestppt.com

XAMARIN: FROM ZERO TO HERO

Alles wat je nodig hebt om te beginnen met Xamarin development

Op de agenda…

5

1 Wat is Xamarin? Hoe onderscheidt Xamarin zich van de rest?

Xamarin

2 Wat is Xamarin.Forms? Hoe werkt het? Wat zijn de mogelijkheden?

Xamarin.Forms

3 DependencyService, Custom RenderersDeep dive

4 Niet te missen NuGet packages voor het ontwikkelen met Xamarin

NuGet Nuggets

5 Samenvatting, lessons learned, applaus en borrelen!

It’s a wrap

www.bestppt.com

XAMARIN Wat is dat nou eigenlijk?

Xamarin is a better way to…

7

Build Test Monitor

Verschillende manieren van ontwikkelen

8

Bouw dezelfde app meerdere keren

• Meerdere teams• Meerdere code bases• Verschillende tools en talen

silo/vendor

Verschillende manieren van ontwikkelen

9

Bouw één app voor alle platformen

• Grootste gemene deler• Browser fragmentatie• Cordova, PhoneGap• Updates niet altijd via de App Store

hybride

Verschillende manieren van ontwikkelen

10

Bouw één app voor alle platformen

• Native User Interface• Native Performance• Gedeelde code over alle platformen• C# & .NET Framework (inclusief C# 6.0!)• Full API Coverage

Xamarin way

Waarom Xamarin?

11Ontwikkel alles in C#

C# draait op 2,6 miljard apparaten

Waarom Xamarin?

12

Xamarin.iOS does full Ahead Of Time (AOT) compilation to produce an ARM binary for Apple’s App Store.

Xamarin.Android takes advantage of Just In Time (JIT) compilation on the Android device. “

Native performance

Hoe doet Xamarin het?

13

.NET + Windows APIs

Hoe doet Xamarin het?

14

.NET + iOS APIs | 100% coverage

Hoe doet Xamarin het?

15

.NET + Android APIs | 100% coverage

Hoe gebruik je Xamarin?

16

Xamarin StudioWindows of Mac

Visual Studio 2010+ Windows

Hoe gebruik je Xamarin?

17

Visual Studio

Alles werkt zoals je gewend bent

• Alle platformen in een solution• Solution te openen in VS & XS• Alle Visual Studio plug-ins te gebruiken• iOS & Android designer

Hoe gebruik je Xamarin?

18

Xamarin Studio

Geoptimaliseerd voor cross-platform development

• Visual Studio kloon inclusief meeste belangrijke features• iOS & Android designer• Snelheid!

Xamarin apps te distribueren via App Stores

19

20

Anything you can do in Objective-C, Swift, or Java can be done in C# with Xamarin (using Visual Studio)“

Enter Microsoft

21

GratisOpen-source

live inspector

Insights -> HockeyApp

www.bestppt.com

Demo

www.bestppt.com

XAMARIN.FORMS Nu met nog meer gedeelde code!

Wat is Xamarin.Forms?

24

Cross-platform UI framework te gebruiken op:

• Android 4.0+• iOS 6.1+• Windows Phone 8.x

(Silverlight)• Windows Phone 8.1 (RT)• Windows 10 (UWP)

Traditionele Xamarin vs. Xamarin.Forms

25

Shared UI Code

Up to 99% code sharing, always some specific (initialisation) code.60-80% code sharing

What’s included?

26

• 40+ Pages, Layouts en Controls• Te gebruiken vanuit code of XAML

• Two-way Data Binding• Navigation• Animation API• Dependency Service• Messaging Center

“If you are used to MVVM development you should feel right at home

What’s included?

27

Pages

What’s included?

28

Layouts

What’s included? (worst slide ever…)

29

Controls

ActivityIndicator BoxView Button DatePicker Editor

Entry Image Label ListView Map

OpenGLView Picker ProgressBar SearchBar Slider

Stepper TableView TimePicker WebView EntryCell

ImageCell SwitchCell TextCell ViewCell

Xamarin.Forms in actie

30

Use a single API to generate native, platform-specific user interfaces

At runtime, each Xamarin.Forms page and its controls are mapped to platform-specific native user interface elements

Xamarin.Forms in actie

31

To Forms or not to Forms?

32

Xamarin.Forms best geschikt voor:

• Weinig platform specifieke functionaliteit

• Code sharing over custom UI• Ontwikkelaars met XAML kennis

Xamarin.iOS/Android best geschikt voor:

• Veel platform specifieke functionaliteit

• Custom UI over code sharing• Veel gebruik van native APIs

Platform specifiek

33

Platform specifieke code uitvoeren middels delegates

Kan gebruikt worden om per platform een specifieke waarde te voorzien

Device.OnPlatform

Platform specifiek

34

Detecteren op welk besturingssysteem de app draait of wat voor apparaat

Device

Ingebouwde platform specifieke features

35

Device.OpenUriOpenen van een URL

Page.DisplayAlertToont een messagebox

Device.StartTimer Acties uitvoeren op interval

Device.BeginInvoke

OnMainThread

UI thread marshalling

Xamarin.Forms.Maps

Toont kaarten en locatiediensten

www.bestppt.com

Demonstratie

www.bestppt.com

Deep dive Wat meer geavanceerde onderwerpen

DependencyService

38

Service locator maakt platform specifieke code mogelijk door abstractie

DependencyService

39

Implementeer de interface in het platform project

Registreer deze bij de DependencyService (boven namespace)

Roep abstractie aan vanuit gedeelde code

MyFirstEntry_Android

Xamarin.Platform. Android.EntryRenderer

MyFirstEntry_iOS

Xamarin.Platform. iOS.EntryRenderer

Custom Renderers

40

Maak je eigen implementatie van hoe een control naar native wordt vertaald

Entry MyFirstEntry

Xamarin.Platform. Windows.EntryRenderer

MyFirstEntry_WinPhone

www.bestppt.com

NuGet Nuggets Met deze NuGet packages wordt het ontwikkelen nóg makkelijker

NuGet packages die we allemaal zouden moeten gebruiken!

42

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

Let op! Bij Forms vaak packages ook installerenop platform project!

www.bestppt.com

It’s a wrap Nog héél even volhouden…

Lessons learned

44

1 Do not underestimate publishing

2 Upgrading? Backup!

3

4

Test altijd op een fysiek apparaat

Weinig grip op je app in het wild

Leuk voor thuis

45

1Xamarin documentatie

2Xamarin forums

3

4

5

https://developer.xamarin.com/

https://forums.xamarin.com/

Xamarin GitHub

https://github.com/xamarin/

Planet Xamarin

http://planet.xamarin.com/

Xamarin University

https://www.xamarin.com/university

#schaamtelozezelfpromotie

46

Gerald Versluis@jfversluis

blog.verslu.is

gerald@verslu.is

From Legislation to Organisation Privacy by Design 101

17 November - Michel Gulpen