Slide 1

Slide 1 text

Building dynamic interfaces πŸͺ„ Implementing Server-Driven UI on Android Ar Razy Fathan Rabbani Mobile Engineer @gamatechno

Slide 2

Slide 2 text

What is Server-Driven UI? Why Server-Driven UI? Advantages of Server-Driven UI Implementation Server-Driven UI on Android Concern using Server-Driven UI Conclusion Outline

Slide 3

Slide 3 text

What is Server-Driven UI Server Driven UI is a powerful approach to building user interfaces that puts the server in charge of generating the UI. This means that the client-side code only needs to know how to render the UI, while the server-side code is responsible for deciding what the UI should look like. [7]

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Traditional Approach Source : https://www.judo.app/blog/server-driven-ui

Slide 6

Slide 6 text

Server-Driven UI Source : https://www.judo.app/blog/server-driven-ui

Slide 7

Slide 7 text

Why Server Driven UI ? Source : https://www.judo.app/blog/server-driven-ui UI Changes : Add rating & label

Slide 8

Slide 8 text

Why Server Driven UI ? Source : https://www.judo.app/blog/server-driven-ui UI Changes : Add rating & label πŸ™…

Slide 9

Slide 9 text

Why Server Driven UI ? Source : https://www.judo.app/blog/server-driven-ui UI Changes : Add rating & label

Slide 10

Slide 10 text

The Problem Source : https://www.judo.app/blog/server-driven-ui 1) Slow down experimentation and iteration. 2) Versioning Problem The necessity to run through a full release cycle for even simple UI changes comes with a few problems

Slide 11

Slide 11 text

Advantages Of Server-Driven

Slide 12

Slide 12 text

Reduced App Upgrades Fast updates and delivery Increased Time to Market Experimentation friendly Code reusability πŸ“‰

Slide 13

Slide 13 text

Reduced App Upgrades Fast updates and delivery Increased Time to Market Experimentation friendly Code reusability πŸš€

Slide 14

Slide 14 text

Reduced App Upgrades Fast updates and delivery Increased Time to Market Experimentation friendly Code reusability ⏰

Slide 15

Slide 15 text

Reduced App Upgrades Fast updates and delivery Increased Time to Market Experimentation friendly Code reusability πŸ‘¨πŸ”¬

Slide 16

Slide 16 text

Experimentation friendly Source : https://splitmetrics.com/resources/what-is-ab-testing-and-why-it-matters-for-mobile-developers/

Slide 17

Slide 17 text

Reduced App Upgrades Fast updates and delivery Increased Time to Market Experimentation friendly Code reusability β™»

Slide 18

Slide 18 text

How to implement Server-Driven UI on Android ?

Slide 19

Slide 19 text

Design

Slide 20

Slide 20 text

Identify each component TopAppBar - category - share button Featured Image Content Footer - content text - card - carousel - image - caption - title - blurred background

Slide 21

Slide 21 text

Translate component as JSON { "featured_image": { "article_title": "2022: The ...", "article_title_size": 40, "blurred_background": true, "caption_size": 10, "image_caption": "With victory...", "image_height": 240, "image_corner_radius": 16, "image_padding": 16, "image_url": "https://example.com/", "image_width": 0 } }

Slide 22

Slide 22 text

Setup Firebase Firestore dependencies { // Import the BoM for the Firebase platform implementation(platform("com.google.firebase:firebase-bom:32.3.1")) // Declare the dependency for the Cloud Firestore library // When using the BoM, you don't specify versions in Firebase library dependencies implementation("com.google.firebase:firebase-firestore-ktx") } 1. Create a new Firebase project for your Android app. 2. Register Your App with Firebase. 3. Add Firebase Firestore Dependencies

Slide 23

Slide 23 text

Setup Firebase Firestore βƒͺ βƒͺ

Slide 24

Slide 24 text

Create a model class to hold data from server Data classes in Kotlin are used to represent simple, immutable data structures

Slide 25

Slide 25 text

Make each components stateful Create a mutable state variable with an initial value

Slide 26

Slide 26 text

AnimatedVisibility(enableBlurredBackground) { FeaturedPostItemBackground(imageUrl = imageUrl) } Enable/Disable blurred background AsyncImage( model = ImageRequest.Builder(LocalContext.current) .data(imageUrl) .crossfade(true) .build(), modifier = Modifier .pressClickEffect() .padding(horizontal = imagePadding.dp) .clip(MaterialTheme.shapes.extraLarge .copy(CornerSize(imageCornerRadius.dp))) .height(imageHeight.dp) .fillMaxWidth() .background(Color.Black), contentDescription = null, contentScale = ContentScale.Crop, ) Image Text( text = imageCaption, fontSize = captionSize.sp, color = Color.White.copy(alpha = .8f), lineHeight = 12.sp, fontFamily = GoloSansRegular, textAlign = TextAlign.Start, modifier = Modifier .padding(horizontal = 16.dp, vertical = 10.dp) .fillMaxWidth(), ) Image Caption Text( text = articleTitle, fontSize = articleTitleSize.sp, lineHeight = 40.sp, fontFamily = GoloSansSemiBold, color = Color.White, modifier = Modifier .padding(horizontal = 16.dp, vertical = 0.dp) .fillMaxWidth(), ) Article Title

Slide 27

Slide 27 text

AnimatedVisibility(enableBlurredBackground) { FeaturedPostItemBackground(imageUrl = imageUrl) } Enable/Disable blurred background AsyncImage( model = ImageRequest.Builder(LocalContext.current) .data(imageUrl) .crossfade(true) .build(), modifier = Modifier .pressClickEffect() .padding(horizontal = imagePadding.dp) .clip(MaterialTheme.shapes.extraLarge .copy(CornerSize(imageCornerRadius.dp))) .height(imageHeight.dp) .fillMaxWidth() .background(Color.Black), contentDescription = null, contentScale = ContentScale.Crop, ) Image Text( text = imageCaption, fontSize = captionSize.sp, color = Color.White.copy(alpha = .8f), lineHeight = 12.sp, fontFamily = GoloSansRegular, textAlign = TextAlign.Start, modifier = Modifier .padding(horizontal = 16.dp, vertical = 10.dp) .fillMaxWidth(), ) Image Caption Text( text = articleTitle, fontSize = articleTitleSize.sp, lineHeight = 40.sp, fontFamily = GoloSansSemiBold, color = Color.White, modifier = Modifier .padding(horizontal = 16.dp, vertical = 0.dp) .fillMaxWidth(), ) Article Title

Slide 28

Slide 28 text

Get data from server ( Real-Time ) Call home screen collection Get featured image document Convert snapshot to Object This function for fetching a featured image UI data from a Firestore database and transforming it into a Flow that can be observed or collected asynchronously.

Slide 29

Slide 29 text

Let's see how it works

Slide 30

Slide 30 text

Concern Using Server-Driven UI (SDUI)

Slide 31

Slide 31 text

Latency and performance Dependency on Internet Connection Cost Complexity

Slide 32

Slide 32 text

Latency and performance Dependency on Internet Connection Cost Complexity

Slide 33

Slide 33 text

Latency and performance Dependency on Internet Connection Cost Complexity

Slide 34

Slide 34 text

Latency and performance Dependency on Internet Connection Cost Complexity

Slide 35

Slide 35 text

Conclusion So, is it the ultimate solution for mobile apps?

Slide 36

Slide 36 text

β€œIt depends” Remember that there is no silver bullet and each methodology has its own trade-offs ✨

Slide 37

Slide 37 text

References Articles Droidcon (Community Conferences) πŸ“„ https://www.judo.app/blog/server-driven-ui ( What is Server-Driven UI? ) [1] πŸ“„ https://betterprogramming.pub/server-driven-ui-does-it-solve-everything-for-mobile-apps-4b38397b2e04 ( Server-Driven UI : the Ultimate Solution for Mobile Apps? ) [2] πŸ“„ https://medium.com/airbnb-engineering/a-deep-dive-into-airbnbs-server-driven-ui-system-842244c5f5 ( A Deep Dive into Airbnb’s Server-Driven UI System ) [3] πŸ“„ https://eng.lyft.com/the-journey-to-server-driven-ui-at-lyft-bikes-and-scooters-c19264a0378e ( The Journey to Server- Driven UI at Lyft Bikes and Scooters ) [4] πŸ“„ https://doordash.engineering/2021/08/24/improving-development-velocity-with-generic-server-driven-ui-components/ (Improving Development Velocity with Generic, Server-Driven UI Components) [5] πŸ“„ https://medium.com/swlh/server-driven-ui-and-some-herbs-f17f01aa7794 ( Server-Driven UI : How to Start. ) [6] πŸ“„ https://netilbyte.medium.com/unveiling-the-advantages-of-server-driven-user-interface-ui-cf41f60c0f2 ( Unveiling the Advantages of Server-Driven UI ) [7] πŸ“„ https://medium.com/@dfs.techblog/server-driven-ui-concept-db07d7946e94 ( Server-Driven UI – Concepts and Building Blocks ) [8] πŸ“Ή https://www.droidcon.com/2023/07/20/accelerating-mobile-development-with-server-driven-technologies/ πŸ“Ή https://www.droidcon.com/2022/09/29/a-journey-to-building-a-server-driven-ui-framework/ πŸ“Ή https://www.droidcon.com/2022/08/01/life-is-too-short-to-develop-only-for-android-a-journey-to-server-driven-ui/ πŸ“Ή https://www.droidcon.com/2018/06/27/using-server-driven-ui-to-rapidly-iterate-on-android-and-across-platforms/ πŸ“Ή https://www.droidcon.com/2022/06/28/a-page-out-of-server-driven-ui-on-android-2/

Slide 38

Slide 38 text

Thank You Ar Razy Fathan Rabbani Mobile Engineer @gamatechno in/arrazyfathan /arrazyfathan 🌎 arrazyfathan.com /arrazyfathann