SlideShare uma empresa Scribd logo
1 de 48
Baixar para ler offline
Declarative UIs with
Jetpack @Compose
Ramon Ribeiro Rabello
about.me/ramonrabello
Ramon Rabello
Android Developer
Motivation
The reasons behind Compose
Past mistakes - “API design is
building future regret”
~Chet Haase
View.java - The “God View” legacy
Weird inheritance
public class Button extends TextView {
Old View namings
public class Spinner extends AbsSpinner {
Old View namings
public class Spinner extends AbsSpinner {
DropDown
Old View namings
public class Spinner extends AbsSpinner {
ComboBox
Simplify building UI
Building UI is boilerplate
MyCustomView.[kt | java]
my_custom_view.xml
attrs.xml
style.xml
Building UI is boilerplate
MyCustomView.[kt | java]
my_custom_view.xml
attrs.xml
style.xml
Building UI is boilerplate
MyCustomView.[kt | java]
my_custom_view.xml
attrs.xml
style.xml
Building UI is boilerplate
MyCustomView.[kt | java]
my_custom_view.xml
attrs.xml
style.xml
Presentation architectures
Presentation Architectures
MVC
MVP
MVVM
MVI
Presentation Architectures Data Flow questions
- What is the source of truth?
Presentation Architectures Data Flow questions
- What is the source of truth?
- Who is the owner?
Presentation Architectures Data Flow questions
- What is the source of truth?
- Who is the owner?
- Who can change it?
Spinner: the weirdest case
public class MainActivity extends AppCompatActivity
implements Spinner.OnItemChangedListener {
What is the source of truth?
Who is the owner?
Who can change it?
onItemStateChanged() will be called after the event has happened
It turns out that android.widget
mixes state ownership and event
handling concepts
New UI toolkit goals
- Unbundled from platform releases (AndroidX)
- Fewer technology stack flowcharts (Custom View? Fragment?)
- Distinguish state ownership and event handling
- Write less code
What about building UI as simple as printing lines?
fun main(){
println("Hello Jetpack Compose")
}
Jetpack Compose
goes on stage
Introducing Jetpack Compose
What is Compose?
- Unbundled new set of UI widgets
- Inspired by React, Litho, Vue.js, Flutter
- A Kotlin compiler plugin
- Fully compatible with existing app code
- Experimental (0.1.0-dev02) - ** not ready for production yet **
Jetpack Compose Principles
UI as a function
@Composable
fun Hello(name: String){
Text(“Hello $name”)
}
Qualifier for Composables
Intercept and recompose the UI
tree
UI as a function (List of Composables)
@Composable
fun Trendings(newsList: List<News>){
for (news in newsList) {
NewsCard(news)
}
}
UI as a function (Dynamic composables)
@Composable
fun Trendings(news: List<News>){
if (news.isEmpty()) {
Text("You have no news today.")
} else {
NewsCard(news)
}
}
Composable building blocks
@Composable
fun Counter(model: CounterModel){
CounterTitle(model)
CounterContent(model)
CounterButtons(model)
}
@Composable
fun CounterHeader(model: CounterModel)
@Composable
fun CounterContent(model: CounterModel)
@Composable
fun CounterButtons(model: CounterModel)
Reactive UI upon model changes
@Composable
fun Counter(){
val model = CounterModel()
Column { Button(“Count”, onClick = { model.increment() }) }
Text(“Counter: ${model.value}”)
}
@Model
data class CounterModel(var value: Int = 0) {
fun increment() = value++
}
Indicates that composable updates
upon model changes
Top-down Data Flow
DataEvent
Top-down Data Flow
@Composable
fun Counter(model: CounterModel){
Column { Button(“Count”, onClick = { model.increment() }) }
Text(“Counter: ${model.value}”)
}
@Model
data class CounterModel(var value: Int = 0) {
fun increment() = value++
}
Data
Top-down Data Flow
@Composable
fun Counter(model: CounterModel){
Column { Button(“Count”, onClick = { model.increment() }) }
Text(“Counter: ${model.value}”)
}
@Model
data class CounterModel(var value: Int = 0) {
fun increment() = value++
}
Data
Top-down Data Flow
@Composable
fun Counter(model: CounterModel){
Column { Button(“Count”, onClick = { model.increment() }) }
Text(“Counter: ${model.value}”)
}
@Model
data class CounterModel(var value: Int = 0) {
fun increment() = value++
}
Data
Top-down Data Flow
@Composable
fun Counter(model: CounterModel){
Column { Button(“Count”, onClick = { model.increment() }) }
Text(“Counter: ${model.value}”)
}
@Model
data class CounterModel(var value: Int = 0) {
fun increment() = value++
}
Event
Getting Started
Download Android Studio
3.5+
(Gradle dependencies)
AS 4.0 Canary 1
(Built-in Compose Support)
UPDATE:
Add compose dev preview dependencies
def compose_version = '0.1.0-dev02'
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.50"
implementation "androidx.compose:compose-runtime:$compose_version"
kapt "androidx.compose:compose-compiler:$compose_version"
implementation "androidx.ui:ui-layout:$compose_version"
implementation "androidx.ui:ui-android-text:$compose_version"
Add compose dev preview dependencies
def compose_version = '0.1.0-dev02'
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.50"
implementation "androidx.compose:compose-runtime:$compose_version"
kapt "androidx.compose:compose-compiler:$compose_version"
implementation "androidx.ui:ui-layout:$compose_version"
implementation "androidx.ui:ui-android-text:$compose_version"
AS 4.0 Canary 1 - Create Composable Activity
Create a @Composable
@Composable
fun Counter() = MaterialTheme {
val model = CounterModel()
Row { Button(“Count”, onClick = { model.increment() }) }
Text(“Counter: ${model.value}”)
}
Add a @Model to represent the composable state
@Model
data class CounterModel(var value: Int = 0) {
fun hitCount() = value++
}
Enclose root composable inside setContent{ }
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent { Counter() }
}
}
Demo
What’s Next?
Learn more about Jetpack Compose
Learn more about Jetpack Compose
Jetpack Compose | Android Developers
Playing with Jetpack Compose dev preview
Diving into Jetpack Compose - Q42 Engineering - Medium
Declarative UI Patterns - Google I/O 2019
Android Jetpack Compose Review - Karumi Blog
https://www.github.com/ramonrabello/Compose-Counter
Thank you!
about.me/ramonrabello

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Jetpack Compose.pdf
Jetpack Compose.pdfJetpack Compose.pdf
Jetpack Compose.pdf
 
Kotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptxKotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptx
 
Jetpack Compose beginner.pdf
Jetpack Compose beginner.pdfJetpack Compose beginner.pdf
Jetpack Compose beginner.pdf
 
Jetpack Compose - Android’s modern toolkit for building native UI
Jetpack Compose - Android’s modern toolkit for building native UIJetpack Compose - Android’s modern toolkit for building native UI
Jetpack Compose - Android’s modern toolkit for building native UI
 
Compose Camp - Jetpack Compose for Android Developers Introduction Session De...
Compose Camp - Jetpack Compose for Android Developers Introduction Session De...Compose Camp - Jetpack Compose for Android Developers Introduction Session De...
Compose Camp - Jetpack Compose for Android Developers Introduction Session De...
 
Deep dive into swift UI
Deep dive into swift UIDeep dive into swift UI
Deep dive into swift UI
 
Introduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformIntroduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platform
 
Kotlin InDepth Tutorial for beginners 2022
Kotlin InDepth Tutorial for beginners 2022Kotlin InDepth Tutorial for beginners 2022
Kotlin InDepth Tutorial for beginners 2022
 
Android Jetpack
Android Jetpack Android Jetpack
Android Jetpack
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
 
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
 
A quick and fast intro to Kotlin
A quick and fast intro to Kotlin A quick and fast intro to Kotlin
A quick and fast intro to Kotlin
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Nestjs MasterClass Slides
Nestjs MasterClass SlidesNestjs MasterClass Slides
Nestjs MasterClass Slides
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
 
Flutter presentation.pptx
Flutter presentation.pptxFlutter presentation.pptx
Flutter presentation.pptx
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
Kotlin Language powerpoint show file
Kotlin Language powerpoint show fileKotlin Language powerpoint show file
Kotlin Language powerpoint show file
 
Writing and using Hamcrest Matchers
Writing and using Hamcrest MatchersWriting and using Hamcrest Matchers
Writing and using Hamcrest Matchers
 
Swift in SwiftUI
Swift in SwiftUISwift in SwiftUI
Swift in SwiftUI
 

Semelhante a Declarative UIs with Jetpack Compose

Semelhante a Declarative UIs with Jetpack Compose (20)

mobl
moblmobl
mobl
 
Android DataBinding (ViewModel, UI Modularization and Testing)
Android DataBinding (ViewModel, UI Modularization and Testing)Android DataBinding (ViewModel, UI Modularization and Testing)
Android DataBinding (ViewModel, UI Modularization and Testing)
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
Writing HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAEWriting HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAE
 
Introduction to Shiny for building web apps in R
Introduction to Shiny for building web apps in RIntroduction to Shiny for building web apps in R
Introduction to Shiny for building web apps in R
 
Designing REST API automation tests in Kotlin
Designing REST API automation tests in KotlinDesigning REST API automation tests in Kotlin
Designing REST API automation tests in Kotlin
 
Prompt engineering for iOS developers (How LLMs and GenAI work)
Prompt engineering for iOS developers (How LLMs and GenAI work)Prompt engineering for iOS developers (How LLMs and GenAI work)
Prompt engineering for iOS developers (How LLMs and GenAI work)
 
shiny.pdf
shiny.pdfshiny.pdf
shiny.pdf
 
How to create an Angular builder
How to create an Angular builderHow to create an Angular builder
How to create an Angular builder
 
MOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app developmentMOPCON 2014 - Best software architecture in app development
MOPCON 2014 - Best software architecture in app development
 
Linguistic Abstraction for the Web
Linguistic Abstraction for the WebLinguistic Abstraction for the Web
Linguistic Abstraction for the Web
 
SCALA - Functional domain
SCALA -  Functional domainSCALA -  Functional domain
SCALA - Functional domain
 
eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017
eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017
eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017
 
Jsf intro
Jsf introJsf intro
Jsf intro
 
Full Stack Scala
Full Stack ScalaFull Stack Scala
Full Stack Scala
 
Reactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bisReactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bis
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
 
Flask and Angular: An approach to build robust platforms
Flask and Angular:  An approach to build robust platformsFlask and Angular:  An approach to build robust platforms
Flask and Angular: An approach to build robust platforms
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 

Mais de Ramon Ribeiro Rabello

Mais de Ramon Ribeiro Rabello (20)

Android Jetpack + Coroutines: To infinity and beyond
Android Jetpack + Coroutines: To infinity and beyondAndroid Jetpack + Coroutines: To infinity and beyond
Android Jetpack + Coroutines: To infinity and beyond
 
Create Modern Apps with Android Jetpack
Create Modern Apps with Android JetpackCreate Modern Apps with Android Jetpack
Create Modern Apps with Android Jetpack
 
Cultura de testes em times mobile
Cultura de testes em times mobileCultura de testes em times mobile
Cultura de testes em times mobile
 
Ninja Productivity in Android Studio
Ninja Productivity in Android StudioNinja Productivity in Android Studio
Ninja Productivity in Android Studio
 
Produtividade ninja com android studio
Produtividade ninja com android studioProdutividade ninja com android studio
Produtividade ninja com android studio
 
Automatize seus testes de UI com a Espresso!
Automatize seus testes de UI com a Espresso!Automatize seus testes de UI com a Espresso!
Automatize seus testes de UI com a Espresso!
 
Os caminhos da Agilidade em Empresa Pública
Os caminhos da Agilidade em Empresa PúblicaOs caminhos da Agilidade em Empresa Pública
Os caminhos da Agilidade em Empresa Pública
 
Making your app see with Mobile Vision API
Making your app see with Mobile Vision APIMaking your app see with Mobile Vision API
Making your app see with Mobile Vision API
 
Inovar em tempos de crise? Yes, We Can!
Inovar em tempos de crise?  Yes, We Can!Inovar em tempos de crise?  Yes, We Can!
Inovar em tempos de crise? Yes, We Can!
 
O ecossistema android
O ecossistema androidO ecossistema android
O ecossistema android
 
Android Marshmallow na prática
Android Marshmallow na práticaAndroid Marshmallow na prática
Android Marshmallow na prática
 
Android Wear: Estendendo sua app para relógios inteligentes
Android Wear: Estendendo sua app para relógios inteligentesAndroid Wear: Estendendo sua app para relógios inteligentes
Android Wear: Estendendo sua app para relógios inteligentes
 
Introdução ao Android Studio
Introdução ao Android StudioIntrodução ao Android Studio
Introdução ao Android Studio
 
O caminho de um desenvolvedor android
O caminho de um desenvolvedor androidO caminho de um desenvolvedor android
O caminho de um desenvolvedor android
 
Criando Apps Sociais em Android
Criando Apps Sociais em AndroidCriando Apps Sociais em Android
Criando Apps Sociais em Android
 
Porque Aprender Android
Porque Aprender AndroidPorque Aprender Android
Porque Aprender Android
 
Workshop Android em Ambientes de Integração
Workshop Android em Ambientes de IntegraçãoWorkshop Android em Ambientes de Integração
Workshop Android em Ambientes de Integração
 
De idealista à empreendedor - como desenvolver aplicações em android que conq...
De idealista à empreendedor - como desenvolver aplicações em android que conq...De idealista à empreendedor - como desenvolver aplicações em android que conq...
De idealista à empreendedor - como desenvolver aplicações em android que conq...
 
Desenvolvimento Web para Android
Desenvolvimento Web para AndroidDesenvolvimento Web para Android
Desenvolvimento Web para Android
 
Agora é Android, Tá Safo? - #tasafoemacaocastanhal
Agora é Android, Tá Safo? - #tasafoemacaocastanhalAgora é Android, Tá Safo? - #tasafoemacaocastanhal
Agora é Android, Tá Safo? - #tasafoemacaocastanhal
 

Último

Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Cara Menggugurkan Kandungan 087776558899
 

Último (6)

FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRFULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
 
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
 
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
 
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost LoverPowerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
 
Leading Mobile App Development Companies in India (2).pdf
Leading Mobile App Development Companies in India (2).pdfLeading Mobile App Development Companies in India (2).pdf
Leading Mobile App Development Companies in India (2).pdf
 
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
 

Declarative UIs with Jetpack Compose

  • 1. Declarative UIs with Jetpack @Compose Ramon Ribeiro Rabello
  • 4. Past mistakes - “API design is building future regret” ~Chet Haase
  • 5. View.java - The “God View” legacy
  • 6. Weird inheritance public class Button extends TextView {
  • 7. Old View namings public class Spinner extends AbsSpinner {
  • 8. Old View namings public class Spinner extends AbsSpinner { DropDown
  • 9. Old View namings public class Spinner extends AbsSpinner { ComboBox
  • 11. Building UI is boilerplate MyCustomView.[kt | java] my_custom_view.xml attrs.xml style.xml
  • 12. Building UI is boilerplate MyCustomView.[kt | java] my_custom_view.xml attrs.xml style.xml
  • 13. Building UI is boilerplate MyCustomView.[kt | java] my_custom_view.xml attrs.xml style.xml
  • 14. Building UI is boilerplate MyCustomView.[kt | java] my_custom_view.xml attrs.xml style.xml
  • 17. Presentation Architectures Data Flow questions - What is the source of truth?
  • 18. Presentation Architectures Data Flow questions - What is the source of truth? - Who is the owner?
  • 19. Presentation Architectures Data Flow questions - What is the source of truth? - Who is the owner? - Who can change it?
  • 20. Spinner: the weirdest case public class MainActivity extends AppCompatActivity implements Spinner.OnItemChangedListener { What is the source of truth? Who is the owner? Who can change it? onItemStateChanged() will be called after the event has happened
  • 21. It turns out that android.widget mixes state ownership and event handling concepts
  • 22. New UI toolkit goals - Unbundled from platform releases (AndroidX) - Fewer technology stack flowcharts (Custom View? Fragment?) - Distinguish state ownership and event handling - Write less code
  • 23. What about building UI as simple as printing lines? fun main(){ println("Hello Jetpack Compose") }
  • 24. Jetpack Compose goes on stage Introducing Jetpack Compose
  • 25. What is Compose? - Unbundled new set of UI widgets - Inspired by React, Litho, Vue.js, Flutter - A Kotlin compiler plugin - Fully compatible with existing app code - Experimental (0.1.0-dev02) - ** not ready for production yet **
  • 27. UI as a function @Composable fun Hello(name: String){ Text(“Hello $name”) } Qualifier for Composables Intercept and recompose the UI tree
  • 28. UI as a function (List of Composables) @Composable fun Trendings(newsList: List<News>){ for (news in newsList) { NewsCard(news) } }
  • 29. UI as a function (Dynamic composables) @Composable fun Trendings(news: List<News>){ if (news.isEmpty()) { Text("You have no news today.") } else { NewsCard(news) } }
  • 30. Composable building blocks @Composable fun Counter(model: CounterModel){ CounterTitle(model) CounterContent(model) CounterButtons(model) } @Composable fun CounterHeader(model: CounterModel) @Composable fun CounterContent(model: CounterModel) @Composable fun CounterButtons(model: CounterModel)
  • 31. Reactive UI upon model changes @Composable fun Counter(){ val model = CounterModel() Column { Button(“Count”, onClick = { model.increment() }) } Text(“Counter: ${model.value}”) } @Model data class CounterModel(var value: Int = 0) { fun increment() = value++ } Indicates that composable updates upon model changes
  • 33. Top-down Data Flow @Composable fun Counter(model: CounterModel){ Column { Button(“Count”, onClick = { model.increment() }) } Text(“Counter: ${model.value}”) } @Model data class CounterModel(var value: Int = 0) { fun increment() = value++ } Data
  • 34. Top-down Data Flow @Composable fun Counter(model: CounterModel){ Column { Button(“Count”, onClick = { model.increment() }) } Text(“Counter: ${model.value}”) } @Model data class CounterModel(var value: Int = 0) { fun increment() = value++ } Data
  • 35. Top-down Data Flow @Composable fun Counter(model: CounterModel){ Column { Button(“Count”, onClick = { model.increment() }) } Text(“Counter: ${model.value}”) } @Model data class CounterModel(var value: Int = 0) { fun increment() = value++ } Data
  • 36. Top-down Data Flow @Composable fun Counter(model: CounterModel){ Column { Button(“Count”, onClick = { model.increment() }) } Text(“Counter: ${model.value}”) } @Model data class CounterModel(var value: Int = 0) { fun increment() = value++ } Event
  • 38. Download Android Studio 3.5+ (Gradle dependencies) AS 4.0 Canary 1 (Built-in Compose Support) UPDATE:
  • 39. Add compose dev preview dependencies def compose_version = '0.1.0-dev02' implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.50" implementation "androidx.compose:compose-runtime:$compose_version" kapt "androidx.compose:compose-compiler:$compose_version" implementation "androidx.ui:ui-layout:$compose_version" implementation "androidx.ui:ui-android-text:$compose_version"
  • 40. Add compose dev preview dependencies def compose_version = '0.1.0-dev02' implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.50" implementation "androidx.compose:compose-runtime:$compose_version" kapt "androidx.compose:compose-compiler:$compose_version" implementation "androidx.ui:ui-layout:$compose_version" implementation "androidx.ui:ui-android-text:$compose_version"
  • 41. AS 4.0 Canary 1 - Create Composable Activity
  • 42. Create a @Composable @Composable fun Counter() = MaterialTheme { val model = CounterModel() Row { Button(“Count”, onClick = { model.increment() }) } Text(“Counter: ${model.value}”) }
  • 43. Add a @Model to represent the composable state @Model data class CounterModel(var value: Int = 0) { fun hitCount() = value++ }
  • 44. Enclose root composable inside setContent{ } class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { Counter() } } }
  • 45. Demo
  • 46. What’s Next? Learn more about Jetpack Compose
  • 47. Learn more about Jetpack Compose Jetpack Compose | Android Developers Playing with Jetpack Compose dev preview Diving into Jetpack Compose - Q42 Engineering - Medium Declarative UI Patterns - Google I/O 2019 Android Jetpack Compose Review - Karumi Blog https://www.github.com/ramonrabello/Compose-Counter