blackberry - cascades 101 - how to build astonishing user interfaces for blackberry 10

49
Cascades 101 How To Build Astonishing User Interfaces for BlackBerry 10 Luca Filigheddu BlackBerry Developer Evangelist [email protected] @filos

Upload: israel-mobile-summit

Post on 26-Jun-2015

2.106 views

Category:

Technology


1 download

DESCRIPTION

Presented at the Israel Mobile Summit 2013 http://www.israelmobilesummit.com

TRANSCRIPT

Page 1: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Cascades 101How To Build Astonishing User Interfaces for BlackBerry 10

Luca Filigheddu

BlackBerry Developer Evangelist

[email protected]

@filos

Page 2: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Why Use Cascades?

Elegant UI Framework• Great looking core UI components• Easy to build custom UI components• Dedicated UI tooling including design

preview (w/ Photoshop Plugin)

Increase Productivity• Higher level APIs• QT flavoured C++ and declarative UI

approach

Page 3: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

The NDK – Two layers

High Level – Cascades High level APIs / C++ Qt + QML + JavaScript Built-in Elegance, beautiful UI Provides the BlackBerry 10 UXLow Level Posix/Low level C; great for porting Raw OS access, windowing, etc. OpenGL ES, OpenAL, ...Excellent for

games Great for Open Source Integration

3

Page 4: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Easy to Read, Declaritive QML

4

Objects

Properties

Arrays (also properties)

JavaScript functions (also properties)

Page 5: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Visual Tooling

5

Page 6: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Standard UI Components

6

Page 7: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Cascades APIs

7

• Advertising Service• App Integration (Invocation Framework)• BBM integration• Location• Payment services (in-app purchases)• Push services and notifications• Audio and Video• Imaging• Camera• Sensors• Networking

Page 8: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

A typical Cascades app

8

Qt/C++ Base

QML-based UI structure

JavaScript-based UI logic

Page 9: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

C++ layer

9

Qt/C++Base

Qt makes C++ easy to use and provides structure

APIs and platform services exposed as C++ classes

UI framework exposed as C++ classes

Access to the underlying low level NDK and OpenGL

Page 10: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

C++ layer

10

QMLUI structure

JavaScript

Declarative UI model – Declare the structure of your app, Cascades will piece it together for you

Add runtime logic and react to user events in JavaScript

Realtime UI preview in the tool

Many platform features exposed in QML as well

Page 11: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Any mix is possible

11

QMLUI structure

JavaScript

Qt/C++Base

Page 12: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Moving between QML and C++ is easy

12

C++

QML

JavaScript

myCppFunction()

myCppFunction {}

myJSFunction{}

myJSFunction() class MyClass { int property;}

MyObject { MyProperty: x}

QmlDocument::create("asset:///main.qml")

MyObject { MyOtherObj {…}}

Page 13: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Controls

Page 14: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Hello World!

14

Page 15: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Hello world

import bb.cascades 1.0

Page { content: Label { text: "Hello World" }}

Page 16: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Same thing in C++

Page* root = new Page;Label* label = Label::create() .text("Hello World");root->setContent(label);Application::instance()->setScene(root);

Page 17: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

What to choose?

C++ QML

Page 18: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Application structure controls

Page

Action bar

Tab menu Action menu Context menu

Page 19: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Application structure controls

“navigation transition”

Navigation pane

Title bar “peek”

Page 20: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

More controls…

CheckboxRadio group Button, Toggle button

Label Text field Date/time picker

Slider, Text area

ImageView

Page 21: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Custom controls

Page 22: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Architecture

Page 23: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

23

60 fps!

Page 24: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Client server architecture

Client Server

Tell the server what to render

Get events back

Page 25: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Client Server

Application

Cascades Tap

React

Scroll list

Fetch data

Do something

else

Start animation

Page 26: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Scene Graph

Page 27: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Scene Graph

RootContainer

Text: “Hello World”

Container

Hello World

RotationZScaleOpacity

Page 28: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

In QML

Container { opacity: 0.5 scaleX: 1.5; scaleY: 1.5 rotationZ: 45 ImageView { … } Label { … }}

Page 29: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

C++

Container *bubble= new Container();bubble->setOpacity(0.5f);bubble->setScale(1.5f);bubble->setRotationZ(45);bubble->add(ImageView::create() ... );bubble->add(Label::create() ... );…

Page 30: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Animations

Page 31: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Animations

Translate, rotate, scale, fade Implicit animations Explicit animations Duration, start/end, easing curve Grouped animations

31

Page 32: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Events

Page 33: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Demo

Page 34: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Handling Touch Events in QML

Container{ onTouch: { if (event.isDown()) { scaleX = 2; scaleY = 2;

rotationZ = 45; } else if (event.isUp()){ scaleX = 1; scaleY = 1;

rotationZ = 0; } } }}

Page 35: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Layouts

Page 36: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

StackLayout & DockLayout

Page 37: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Container { layout: DockLayout {} Cow { horizontalAlignment: HorizontalAlignment.Center verticalAlignment: VerticalAlignment.Top } Cow { horizontalAlignment: HorizontalAlignment.Center verticalAlignment: VerticalAlignment.Center }}

Page 38: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Container { layout: StackLayout { orientation: LayoutOrientation.TopToBottom } Cow { layoutProperties: StackLayoutProperties { spaceQuota: 1 } } Cow { layoutProperties: StackLayoutProperties { spaceQuota: 2 } }}

Page 39: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Custom controls

Page 40: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10
Page 41: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

ContainerDockLayout

SpeedGauge

RotationZ (-10) RotationZ (-40)

TranslationY (30) TranslationY(30)

Page 42: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Lists

Page 43: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

List Items

Prepackaged item types Header StandardListItem

Custom list item “Anything”

43

Page 44: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Data binding

DataModel

JSON SQL

XMLGroupedArray QList custom

Page 45: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

UI adaptability

Page 46: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Multiple Form Factors

Page 47: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

How create an adaptable UI?

Built in controls adapt to device type Layouts, space quota, 9-sliced images, … Unique (sub)set of assets per configuration

Page 48: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Asset selectors

Based on resolution and/or visual style

assets/ main_screen.qml dialog.qml picture.png icon.png 720x720/ main_screen.qml picture.png

Page 49: BlackBerry - Cascades 101 - How To Build Astonishing User Interfaces for BlackBerry 10

Questions? / Answers!

Feel free to email me:

[email protected]

49