65
Developing of weMoin: a “hybrid” web-application. CWEP SansWord Huang # 557 黃文楷 2014/5/27 @ GSS Tech Talk

PhoneGap Introduction

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: PhoneGap Introduction

Developing of weMoin: a “hybrid” web-application.

CWEP SansWord Huang # 557 黃文楷

2014/5/27 @ GSS Tech Talk

Page 2: PhoneGap Introduction

outlineWhat is PhoneGap

tools for weMoin

mobile-specific javascript implementation (optional)

Page 3: PhoneGap Introduction

What is PhoneGapHybrid architecture

Hybrid deployment (CWEP-Specific)

Barrier

Break through

Page 4: PhoneGap Introduction

Hybrid ArchitectureWriting app via html(5), javascript, css(3)

Interact with native device features via javascript interface.

Page 5: PhoneGap Introduction

Hybrid ArchitectureProsWrite once, run everywhere. System as black box.

ConsPerformance bound by javascript engine.

Page 6: PhoneGap Introduction

Hybrid ArchitectureProsWrite once, run everywhere. System as black box.

ConsPerformance bound by javascript engine.

something might goes wrong

Page 7: PhoneGap Introduction

Hybrid ArchitectureProsWrite once, run everywhere. System as black box.

ConsPerformance bound by javascript engine.

something might goes wrong

System as black box.

Page 8: PhoneGap Introduction

Hybrid ArchitectureLearning Curve

Page 9: PhoneGap Introduction

Hybrid ArchitectureLearning Curve

Easy to produce hello world.

Page 10: PhoneGap Introduction

Hybrid ArchitectureLearning Curve

Easy to produce hello world.

Easy to port static website directly intophonegap-application.

Page 11: PhoneGap Introduction

Hybrid ArchitectureLearning Curve

Easy to produce hello world.

Easy to port static website directly intophonegap-application.

But: application != website

Page 12: PhoneGap Introduction

Hybrid ArchitectureLearning Curve

Easy to produce hello world.

Easy to port static website directly intophonegap-application.

But: application != website

UX is different Events are different Code will be different

Page 13: PhoneGap Introduction

Hybrid Deployment

Client Side - Server Side

Page 14: PhoneGap Introduction

Hybrid Deployment

Client Side - Server Side

Page 15: PhoneGap Introduction

Hybrid DeploymentServer Side:Main Content

Client Side: Login Page

Page 16: PhoneGap Introduction

Hybrid DeploymentPros:No need to update app to update content. (Thanks… Apple…)

Cons:

Bandwidth intensive.

Phonegap is not build for this usage, hence some barriers introduced.

Page 17: PhoneGap Introduction
Page 18: PhoneGap Introduction

Barrier

Page 19: PhoneGap Introduction

Barrierlogout button

login

logout

Page 20: PhoneGap Introduction

Barrierlogout button

login

logout

Page 21: PhoneGap Introduction

Barrierlogout button

login

logout

Page 22: PhoneGap Introduction

Barrierlogout button

security constraintlogin

logout

Page 23: PhoneGap Introduction

Barrierlogout button

login

logout

Page 24: PhoneGap Introduction

Barrierlogout button

login

Page 25: PhoneGap Introduction

BarrierPlatform-Specific Plugins:

Page 26: PhoneGap Introduction

BarrierPlatform-Specific Plugins:

plugin for iOS plugin for android

Page 27: PhoneGap Introduction

BarrierPlatform-Specific Plugins:

plugin for iOS plugin for android

plugin for ?????

Page 28: PhoneGap Introduction

Barrierplatform specific plugins:

security constraint:

Page 29: PhoneGap Introduction

Break Throughplatform specific plugins:

security constraint:

Page 30: PhoneGap Introduction

Break Throughplatform specific plugins: using user agent to determine what plugins to serve. (Conditional Plugins)

security constraint:communication via file system content. (FS bridge)

Page 31: PhoneGap Introduction

Conditional Plugins

Page 32: PhoneGap Introduction

Conditional Pluginsinitial javascript files:cordova.js cordova_plugin.js

plugin assets: merge plugin folders of www of all platforms

Page 33: PhoneGap Introduction

FS Bridge

login.html app.html

login

logout

Page 34: PhoneGap Introduction

FS Bridge

index.html login.html app.html

Page 35: PhoneGap Introduction

FS Bridge

index.html login.html app.html

login

Page 36: PhoneGap Introduction

FS Bridge

index.html

.action

login.html app.html

login

write

Page 37: PhoneGap Introduction

FS Bridge

index.html

.action

login.html app.html

login

write

history.go(1-history.length);

Page 38: PhoneGap Introduction

FS Bridge

index.html

.action

login.html app.html

login

writeread

history.go(1-history.length);

Page 39: PhoneGap Introduction

FS Bridge

index.html

.action

login.html app.html

login

writeread

redirect

history.go(1-history.length);

Page 40: PhoneGap Introduction

FS Bridge

index.html

.action

login.html app.html

login

writeread

redirect

history.go(1-history.length);login.html

setting.html

offline.html

Page 41: PhoneGap Introduction

Self-Update App (future)

index.html

.action

login.html app.html

Page 42: PhoneGap Introduction

Self-Update App (future)

index.html

.action

login.html app.html

application layer

Page 43: PhoneGap Introduction

Self-Update App (future)

index.html

.action

login.html app.html

application layer

document layer

Page 44: PhoneGap Introduction

.action

document layer

app.jsapp.html app.css

.data

application layerbootstrapping check, download, verify, update

Page 45: PhoneGap Introduction

Break ThroughProsProblem Resolved

ConsDependency between server and client

Page 46: PhoneGap Introduction

What is PhoneGapHybrid architecture native / html + css + javascript

Hybrid deployment (CWEP-Specific) client-side / server-side

Barrier platform-specific plugin communication between client /server

Break throughConditional Plugin FS Bridge

Page 47: PhoneGap Introduction

What is PhoneGapHybrid architecture native / html + css + javascript

Hybrid deployment (CWEP-Specific) client-side / server-side

Barrier platform-specific plugin communication between client /server

Break throughConditional Plugin FS Bridge

Page 48: PhoneGap Introduction

tools for weMoinRequireJSA JavaScript module loader.

sass / compass An open-source CSS Authoring Framework.

Page 49: PhoneGap Introduction

RequireJSManage dependency easily. Global variables no more!!!!

Easy to swap scripts for different configurations.

Page 50: PhoneGap Introduction

pad_areas.js

Dependency Injection

Page 51: PhoneGap Introduction

pad_areas.js

Dependency Injection

module name

Page 52: PhoneGap Introduction

pad_areas.js

Dependency Injection

dependencies

Page 53: PhoneGap Introduction

pad_areas.js

Dependency Injection

factory

Page 54: PhoneGap Introduction

pad_areas.js

Dependency Injection

module

Page 55: PhoneGap Introduction

Bye-bye Globals

pad_areas.js

area_switcher.js

Page 56: PhoneGap Introduction

Bye-bye Globals

Page 57: PhoneGap Introduction

Bye-bye Globals

Page 58: PhoneGap Introduction

Bye-bye Globals

Page 59: PhoneGap Introduction

RequireJS will …Load files for you.Provide tools to combine files for you.Import file only once, each factory will be executed only once.

Dependency Injection

Page 60: PhoneGap Introduction

Modules swappingarea_switcher.js

Page 61: PhoneGap Introduction

Modules swappingarea_switcher.js

js/area_locator.js js/offline/area_locator.js

Page 62: PhoneGap Introduction

Modules swappingapp.html @ online

app.html @ offline

Page 63: PhoneGap Introduction

Modules swapping

Page 64: PhoneGap Introduction

RequireJSPros:As above descriptions.

Cons:Not-so-clear documentation.

Transition effort: Took me 8 hrs to transfer. But might takes more time if code was bad.

Page 65: PhoneGap Introduction

Sprite Easily (compass)

Handle vendor-prefix automatically (compass)

Writing css with variables!!!

reuse css (css)

reduce # of requests via @import (css)