27

Georgiy Shur: Bring onboarding to life

Embed Size (px)

Citation preview

Page 1: Georgiy Shur: Bring onboarding to life
Page 2: Georgiy Shur: Bring onboarding to life

GEORGIY SHURAndroid Developer, Ackee

Page 3: Georgiy Shur: Bring onboarding to life

Bring onboarding to lifewith ViewPager-based animations

Page 4: Georgiy Shur: Bring onboarding to life

Onboarding techniques

● Walkthroughs and tours

● Contextual tips and tutorials

● Empty states

● Dummy data, chatbots, etc....

Page 5: Georgiy Shur: Bring onboarding to life

Onboarding techniques

● Walkthroughs and tours

● Contextual tips and tutorials

● Empty states

● Dummy data, chatbots, etc....

Page 6: Georgiy Shur: Bring onboarding to life

Onboarding techniques

● Walkthroughs and tours

● Contextual tips and tutorials

● Empty states

● Dummy data, chatbots, etc....

Page 7: Georgiy Shur: Bring onboarding to life

Onboarding techniques

● Walkthroughs and tours

● Contextual tips and tutorials

● Empty states

● Dummy data, chatbots, etc....

Page 8: Georgiy Shur: Bring onboarding to life

Onboarding techniques

● Walkthroughs and tours

● Contextual tips and tutorials

● Empty states

● Dummy data, chatbots, etc....

Page 9: Georgiy Shur: Bring onboarding to life

Onboarding techniques

● Walkthroughs and tours

● Contextual tips and tutorials

● Empty states

● Dummy data, chatbots, etc....

Page 10: Georgiy Shur: Bring onboarding to life

Static screens are boring?

● Animated

● Interactive

Page 11: Georgiy Shur: Bring onboarding to life

ViewPager-based animations concept● Offset between pages

Page 12: Georgiy Shur: Bring onboarding to life

ViewPager-based animations concept● Offset between pages

● Parameter to animate (position, scale, color, …)

Page 13: Georgiy Shur: Bring onboarding to life

ViewPager-based animations concept● Offset between pages

● Parameter to animate (position, scale, color, …)

● Relation between them (linear, …)

Page 14: Georgiy Shur: Bring onboarding to life

ViewPager-based animations concept● Offset between pages

● Parameter to animate (position, scale, color, …)

● Relation between them (linear, …)

● Pages involved

Page 15: Georgiy Shur: Bring onboarding to life

Between pages 1 and 2 I want to change x position of view with relation x = offset/2

Page 16: Georgiy Shur: Bring onboarding to life

Parameters to animate● Position (translation)

● Angle (rotation)

● Scale (size)

● Color

● Alpha (fade in/out)

● Progress (GIF, Lottie view)

● Custom, ...

Page 18: Georgiy Shur: Bring onboarding to life

private void initHandWithPhone() {

ImageView hand = (ImageView) LayoutInflater. from(mPagerLayout.getContext())

.inflate(R.layout. decor_hand_with_phone, mPagerLayout, false);

Decor handDecor = new Decor.Builder(hand).setPage(Page. pageRange(2, 3))

.behindViewPage().withLayer().build();

RotationAnimation handRotateInAnim = new RotationAnimation(Page. singlePage(2), 30, 0);

handRotateInAnim.setInterpolator( new DecelerateInterpolator());

TranslationAnimation handMoveInAnim = new TranslationAnimation(Page. singlePage(2),

mCircleRadius + hand.getDrawable().getIntrinsicWidth() / 2,

-UiUtils. dpToPx(this, 16), UiUtils.dpToPx(this, 28), 0, true);

handMoveInAnim.setInterpolator( new DecelerateInterpolator());

RotationAnimation handRotateOutAnim = new RotationAnimation(Page. singlePage(3), 0, -60);

TranslationAnimation handMoveOutAnim = new TranslationAnimation(Page. singlePage(3),

UiUtils. dpToPx(this, 28), 0,

-mCircleRadius - hand.getDrawable().getIntrinsicWidth() / 2,

UiUtils. dpToPx(this, 166), true);

mSparkleMotion.animate(handRotateInAnim).animate(handMoveInAnim)

.animate(handRotateOutAnim).animate(handMoveOutAnim).on(handDecor);

}

Page 19: Georgiy Shur: Bring onboarding to life

ImageView hand = (ImageView) LayoutInflater

.from(mPagerLayout.getContext())

.inflate(R.layout.decor_hand_with_phone,

mPagerLayout, false);

Decor handDecor = new Decor.Builder(hand)

.setPage(Page.pageRange(2, 3))

.behindViewPage().withLayer().build();

Page 20: Georgiy Shur: Bring onboarding to life

RotationAnimation handRotateInAnim = new

RotationAnimation(Page.singlePage(2), 30, 0);

handRotateInAnim.setInterpolator(new DecelerateInterpolator());

TranslationAnimation handMoveInAnim = new TranslationAnimation(

Page.singlePage(2), mCircleRadius +

hand.getDrawable().getIntrinsicWidth() / 2,

-UiUtils.dpToPx(this, 16),

UiUtils.dpToPx(this, 28), 0, true);

handMoveInAnim.setInterpolator(new DecelerateInterpolator());

Page 21: Georgiy Shur: Bring onboarding to life

RotationAnimation handRotateOutAnim = new

RotationAnimation(Page.singlePage(3), 0, -60);

TranslationAnimation handMoveOutAnim = new

TranslationAnimation(Page.singlePage(3),

UiUtils.dpToPx(this, 28), 0, -mCircleRadius -

hand.getDrawable().getIntrinsicWidth() / 2,

UiUtils.dpToPx(this, 166), true);

Page 22: Georgiy Shur: Bring onboarding to life

mSparkleMotion

.animate(handRotateInAnim)

.animate(handMoveInAnim)

.animate(handRotateOutAnim)

.animate(handMoveOutAnim)

.on(handDecor);

Page 23: Georgiy Shur: Bring onboarding to life

class CustomPageTransformer : ViewPager.PageTransformer {

override fun transformPage(view: View, position: Float) {

with(view.find<Button>(R.id.btn_first)) {

alpha = position

translationX = -(1 - position) * 1.4f * view.width

}

with(view.find<Button>(R.id.btn_second)) {

alpha = position

translationX = -(1 - position) * 1.6f * view.width

}

}

}

viewPager.setPageTransformer(false, CustomPageTransformer())

Page 24: Georgiy Shur: Bring onboarding to life

val spritz = Spritz

.with(lottieAnimationView)

.withSteps(

SpritzStep.Builder()

.withAutoPlayDuration(500, TimeUnit.MILLISECONDS)

.withSwipeDuration(500, TimeUnit.MILLISECONDS)

.build(),

SpritzStep.Builder()

.withAutoPlayDuration(500, TimeUnit.MILLISECONDS)

.withSwipeDuration(500, TimeUnit.MILLISECONDS)

.build(),

SpritzStep.Builder()

.withAutoPlayDuration(500, TimeUnit.MILLISECONDS)

.build()

)

.build()

Page 25: Georgiy Shur: Bring onboarding to life

override fun onStart() {

super.onStart()

spritz.attachTo(viewPager)

spritz.startPendingAnimations()

}

override fun onStop() {

spritz.detachFrom(viewPager)

super.onStop()

}

Page 26: Georgiy Shur: Bring onboarding to life

https://github.com/IFTTT/SparkleMotion

https://developer.android.com/reference/android/support/v4/view/ViewPager.

PageTransformer.html

https://github.com/novoda/android-demos/tree/master/spritz

Page 27: Georgiy Shur: Bring onboarding to life

WWW.MDEVTALK.CZmdevtalk