The document discusses Jetpack Compose, a declarative UI toolkit for Android. It covers topics such as:
- Thinking in Compose by describing what the UI should look like, not how to build it
- Creating composable functions that can run in any order and in parallel
- Using the Compose toolkit which includes MaterialTheme, Scaffold, and Surface
- State management with MutableState and remember to control the UI
- Ensuring composables are side-effect free and may run frequently on recomposition
In this tutorial on Kotlin Jetpack, we will learn why Jetpack compose, What is Kotlin Jetpack compose, and How does compose works?. We will also learn about Composable function, Layouts, and material design. At last, we will have a look at the List and animations.
What is Kotlin Jetpack compose?
Why Jetpack compose?
How does the compose work?
Composable function
Layouts
Material design
List and animations
Android Jetpack compose completely written in Kotlin, Declarative UI, new way of UI designing in Android.
This presentation tells you what it is Jetpack Compose? Why it was introduced? How to implement it? How it works? What happens behind the scenes?
Jetpack Compose is a Declarative UI toolkit written in 100% Kotlin. What is Declarative UI? Why should we use it? We will talk about data flow and the benefits of Declarative UI. Then we’ll show the way to setup Jetpack Compose, write some basic samples and let it works with the MVVM architecture.
In this tutorial on Kotlin Jetpack, we will learn why Jetpack compose, What is Kotlin Jetpack compose, and How does compose works?. We will also learn about Composable function, Layouts, and material design. At last, we will have a look at the List and animations.
What is Kotlin Jetpack compose?
Why Jetpack compose?
How does the compose work?
Composable function
Layouts
Material design
List and animations
Android Jetpack compose completely written in Kotlin, Declarative UI, new way of UI designing in Android.
This presentation tells you what it is Jetpack Compose? Why it was introduced? How to implement it? How it works? What happens behind the scenes?
Jetpack Compose is a Declarative UI toolkit written in 100% Kotlin. What is Declarative UI? Why should we use it? We will talk about data flow and the benefits of Declarative UI. Then we’ll show the way to setup Jetpack Compose, write some basic samples and let it works with the MVVM architecture.
Jetpack Compose is the new Android UI framework that allows you to create rich user interfaces in a declarative way using Kotlin language. In this presentation, it will be demonstrated how to take the first steps with Compose, learn its main concepts and understand how to be prepared for this change of paradigm on the front-end development of native Android applications.
Kotlin Basics & Introduction to Jetpack Compose.pptxtakshilkunadia
In our fast and ever-changing world of tech, creating a great UI is not just indispensable but also an obligation as a developer. A great UI makes the whole experience of accessing the products/services an absolute pleasure.
Hour 1: Basics of Kotlin
Hour 2: Introduction to Jetpack Compose Development Kit
Jetpack Compose - Android’s modern toolkit for building native UIGilang Ramadhan
Jetpack Compose simplifies and accelerates UI development on Android. Quickly bring your app to life with less code, powerful tools, and intuitive Kotlin APIs.
A complete Android UI development guideline with Jetpack Compose is described here.
Reference link:
https://developer.android.com/jetpack/compose/documentation
Intro To React Native
with Varun Vachhar
OVERVIEW
React Native introduces a new way to write native mobile apps. You can take everything that you know and love about React and apply it to native apps. Unlike hybrid apps, it gives you access to both native APIs and UI components. The application logic uses JavaScript whereas, the UI is fully native! It also brings the best of the web to native, things like – flexbox layout model, XMLHttpRequest, requestAnimationFrame, etc.
OBJECTIVE
To introduce the audience to React Native. Show how they can leverage their knowledge of web development to build native apps.
TARGET AUDIENCE
Developers familiar with React who are interested in building native mobile apps.
ASSUMED AUDIENCE KNOWLEDGE
Basic knowledge of React, ES6 and CSS.
FIVE THINGS AUDIENCE MEMBERS WILL LEARN
What is React Native
How it is an extension of hybrid
How to use polyfills to leverage the best of the web while getting native performance
How to debug React Native apps
How to use Flexbox and CSS for styling a React Native app
ReactJS is arguably the most popular Javascript framework around for web development today. With more and more teams exploring and adopting React, here is TechTalks presentation elaborating fundamentals of React, in a code along session
Tutorial Videos: https://www.youtube.com/playlist?list=PLD8nQCAhR3tQ7KXnvIk_v_SLK-Fb2y_k_
Day 1 : Introduction to React, Babel and Webpack
Prerequisites of starting the workshop ( Basic understanding of Node & Express )
What is Virtual DOM?
What is React and why should we use it?
Install and set up React:
a-Using create-react-app
b-From scratch using Babel and Webpack. We will use Webpack Dev Server.
Day 2 : React Basic Concepts
Types of Components: Class-based and Functional based Components
Use of JSX
Parent, Child, and Nested Components
Difference between State and Props
Create and Handle Routes
Component Lifecycle Methods
Create a form and handling form inputs
Use of arrow functions and Spread Operator
Day 3: Advanced Concepts in React
Use of Refs
What are Higher Order Components( HOC )?
How to use HOC
Understanding Context in React
A presentation made for the AngularJS-IL meetup group that took place in oct 2014 at Google TLV Campus (http://www.meetup.com/AngularJS-IL/events/207559572/)
its an overview of how to use services in your app. this slideshow contain a link for a reference code on github.
(link in the last slide)
Jetpack Compose is the new Android UI framework that allows you to create rich user interfaces in a declarative way using Kotlin language. In this presentation, it will be demonstrated how to take the first steps with Compose, learn its main concepts and understand how to be prepared for this change of paradigm on the front-end development of native Android applications.
Kotlin Basics & Introduction to Jetpack Compose.pptxtakshilkunadia
In our fast and ever-changing world of tech, creating a great UI is not just indispensable but also an obligation as a developer. A great UI makes the whole experience of accessing the products/services an absolute pleasure.
Hour 1: Basics of Kotlin
Hour 2: Introduction to Jetpack Compose Development Kit
Jetpack Compose - Android’s modern toolkit for building native UIGilang Ramadhan
Jetpack Compose simplifies and accelerates UI development on Android. Quickly bring your app to life with less code, powerful tools, and intuitive Kotlin APIs.
A complete Android UI development guideline with Jetpack Compose is described here.
Reference link:
https://developer.android.com/jetpack/compose/documentation
Intro To React Native
with Varun Vachhar
OVERVIEW
React Native introduces a new way to write native mobile apps. You can take everything that you know and love about React and apply it to native apps. Unlike hybrid apps, it gives you access to both native APIs and UI components. The application logic uses JavaScript whereas, the UI is fully native! It also brings the best of the web to native, things like – flexbox layout model, XMLHttpRequest, requestAnimationFrame, etc.
OBJECTIVE
To introduce the audience to React Native. Show how they can leverage their knowledge of web development to build native apps.
TARGET AUDIENCE
Developers familiar with React who are interested in building native mobile apps.
ASSUMED AUDIENCE KNOWLEDGE
Basic knowledge of React, ES6 and CSS.
FIVE THINGS AUDIENCE MEMBERS WILL LEARN
What is React Native
How it is an extension of hybrid
How to use polyfills to leverage the best of the web while getting native performance
How to debug React Native apps
How to use Flexbox and CSS for styling a React Native app
ReactJS is arguably the most popular Javascript framework around for web development today. With more and more teams exploring and adopting React, here is TechTalks presentation elaborating fundamentals of React, in a code along session
Tutorial Videos: https://www.youtube.com/playlist?list=PLD8nQCAhR3tQ7KXnvIk_v_SLK-Fb2y_k_
Day 1 : Introduction to React, Babel and Webpack
Prerequisites of starting the workshop ( Basic understanding of Node & Express )
What is Virtual DOM?
What is React and why should we use it?
Install and set up React:
a-Using create-react-app
b-From scratch using Babel and Webpack. We will use Webpack Dev Server.
Day 2 : React Basic Concepts
Types of Components: Class-based and Functional based Components
Use of JSX
Parent, Child, and Nested Components
Difference between State and Props
Create and Handle Routes
Component Lifecycle Methods
Create a form and handling form inputs
Use of arrow functions and Spread Operator
Day 3: Advanced Concepts in React
Use of Refs
What are Higher Order Components( HOC )?
How to use HOC
Understanding Context in React
A presentation made for the AngularJS-IL meetup group that took place in oct 2014 at Google TLV Campus (http://www.meetup.com/AngularJS-IL/events/207559572/)
its an overview of how to use services in your app. this slideshow contain a link for a reference code on github.
(link in the last slide)
This Android development workshop is a gateway to the exciting world of mobile app development. Whether you're a complete beginner or have some programming expertise, this class will provide you with the core skills and knowledge required to create great Android apps.
Learn the basics of building Android apps with the Kotlin programming language and develop a collection of simple apps to start your journey as an Android developer!
Pre-requisites
1. Basic Math Skills
2. Basic Computer Literacy
Curriculum Used
Android Basics in Kotlin Course with six pathways currently available on Android Developers Website.
Android Study Jams - New to Programming [27th december]PragatiVerma31
Hey Droids!
We are coming up with our next session of Android Study Jams.
Join us on ️ December 27, 2020, 4 PM - 6 PM
What are Android Study Jams?
Android Study Jams are community-organized study groups for students and professionals to learn how to build Android apps in the Kotlin programming language, using a curriculum provided by Google.
Know more about it here: https://g.co/android/studyjams
There are two tracks available:
Track 1: New to Programming Track - For people who are new to programming, follows the Android Basics in Kotlin course.
Track 2: Prior Programming Track - For people who already have programming experience, follows the Android Kotlin Fundamental course. Also includes a pre-work section using Kotlin Koans from JetBrains for those who are new to Kotlin.
During the course, you will get a general overview of mobile development for Android, learn basic programming concepts as well as core vocabulary and concepts in Android, get hands-on experience building a small app using the Kotlin language, and understand what opportunities exist for you in the vibrant Berlin tech scene as an Android programmer.
Note : This session will be appropriate for anyone interested in learning more about the field and prior programming knowledge will not be necessary.
Our speakers will tell you in detail how you can learn android in kotlin and after that each unit has badges earn the 10 badges and get a certificate direct from Google.
Android Study Jam for DSC JSS will be conducted by Dheeraj Kotwani, our Android Study Jam Facilitator. Reach out to him on the following links:
Instagram: https://www.instagram.com/dheeraj_kotwani/
GitHub: https://github.com/dheerajkotwani
Twitter: https://twitter.com/kotwani_dheeraj
LinkedIn: https://www.linkedin.com/in/dheerajkotwani/
Also, join us on discord to stay updated and seek guidance from the best in the arena of android development.
Discord Link: https://bit.ly/DSCJSSATEN-DISCORD
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Safalta Digital marketing institute in Noida, provide complete applications that encompass a huge range of virtual advertising and marketing additives, which includes search engine optimization, virtual communication advertising, pay-per-click on marketing, content material advertising, internet analytics, and greater. These university courses are designed for students who possess a comprehensive understanding of virtual marketing strategies and attributes.Safalta Digital Marketing Institute in Noida is a first choice for young individuals or students who are looking to start their careers in the field of digital advertising. The institute gives specialized courses designed and certification.
for beginners, providing thorough training in areas such as SEO, digital communication marketing, and PPC training in Noida. After finishing the program, students receive the certifications recognised by top different universitie, setting a strong foundation for a successful career in digital marketing.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
1. This work is licensed under the Apache 2.0 License
Jetpack Compose
for Android Developers
2. This work is licensed under the Apache 2.0 License
Whiston Borja
Android Developer
Camp leaders
3. This work is licensed under the Apache 2.0 License
● Thinking in Compose
● Composable functions
● Compose toolkit
● Tooling
Agenda
4. This work is licensed under the Apache 2.0 License
Thinking in
Compose
5. This work is licensed under the Apache 2.0 License
Construct UI by
describing what,
not how.
6. This work is licensed under the Apache 2.0 License
goo.gle/compose-samples
7. This work is licensed under the Apache 2.0 License
8. This work is licensed under the Apache 2.0 License
Survey
answer
Image Text Radio button
9. This work is licensed under the Apache 2.0 License
<LinearLayout android:orientation=“horizontal” >
<ImageView
android:id=”@+id/answer_image” ... />
<TextView
android:id=”@+id/answer_text” ... />
<RadioButton
android:id=”@+id/answer_radio_button” ... />
</LinearLayout>
<!-- survey_answer.xml -->
10. This work is licensed under the Apache 2.0 License
class SurveyQuestionActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val image = findViewById(R.id.answer_image)
val text = findViewById(R.id.answer_text)
val radioButton =
findViewById(R.id.answer_radio_button)
// ...
}
}
// SurveyQuestionActivity.kt
11. This work is licensed under the Apache 2.0 License
class SurveyQuestionActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
// ...
image.setImage(...)
text.setText(...)
// ...
}
}
// SurveyQuestionActivity.kt
12. This work is licensed under the Apache 2.0 License
13. This work is licensed under the Apache 2.0 License
14. This work is licensed under the Apache 2.0 License
15. This work is licensed under the Apache 2.0 License
16. This work is licensed under the Apache 2.0 License
17. This work is licensed under the Apache 2.0 License
Survey
answer
Image Text Radio button
18. This work is licensed under the Apache 2.0 License
@Composable
fun SurveyAnswer(answer: Answer) {
Row {
Image(answer.image)
Text(answer.text)
RadioButton(false, onClick = { /* … */ })
}
}
// SurveyAnswer.kt
19. This work is licensed under the Apache 2.0 License
@Composable
fun SurveyAnswer(answer: Answer) {
Row {
Image(answer.image)
Text(answer.text)
RadioButton(false, onClick = { /* … */ })
}
}
// SurveyAnswer.kt
20. This work is licensed under the Apache 2.0 License
@Composable
fun SurveyAnswer(answer: Answer) {
Row {
Image(answer.image)
Text(answer.text)
RadioButton(false, onClick = { /* … */ })
}
}
// SurveyAnswer.kt
21. This work is licensed under the Apache 2.0 License
Construct UI by
describing what,
not how.
22. This work is licensed under the Apache 2.0 License
Event
handler
UI element
onClick()
23. This work is licensed under the Apache 2.0 License
UI
State
24. This work is licensed under the Apache 2.0 License
UI 2
State 2
25. This work is licensed under the Apache 2.0 License
@Composable
fun SurveyAnswer(answer: Answer) {
Row {
/ * ... */
var selected: Boolean = // ...
RadioButton(selected, onClick = { /* … */ })
}
}
// SurveyAnswer.kt
26. This work is licensed under the Apache 2.0 License
@Composable
fun SurveyAnswer(answer: Answer) {
Row {
/ * ... */
var selected: Boolean = // ...
RadioButton(selected, onClick = {
selected = !selected
})
}
}
// SurveyAnswer.kt
27. This work is licensed under the Apache 2.0 License
@Composable
fun SurveyAnswer(answer: Answer) {
Row {
/ * ... */
var selected: Boolean = // ...
RadioButton(selected, onClick = {
selected = !selected
})
}
}
// SurveyAnswer.kt
28. Describe what, not how
UI elements are functions
State controls UI
Events control State
1
2
3
4
29. This work is licensed under the Apache 2.0 License
Composable
functions
30. This work is licensed under the Apache 2.0 License
goo.gle/compose-samples
31. This work is licensed under the Apache 2.0 License
32. This work is licensed under the Apache 2.0 License
// SurveyAnswer.kt
@Composable
fun SurveyAnswer(answer: Answer) {
Row {
Image(answer.image)
Text(answer.text)
RadioButton(false, onClick = { /* … */ })
}
}
33. This work is licensed under the Apache 2.0 License
// SurveyAnswer.kt
@Composable
fun SurveyAnswer(answer: Answer) {
Row {
Image(answer.image)
Text(answer.text)
RadioButton(false, onClick = { /* … */ })
}
}
34. This work is licensed under the Apache 2.0 License
// SurveyAnswer.kt
@Composable
fun SurveyAnswer(answer: Answer) { /* … */ }
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
Column {
answers.forEach { answer ->
SurveyAnswer(answer = answer)
}
}
}
35. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
Column {
answers.forEach { answer ->
SurveyAnswer(answer = answer)
}
}
}
36. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
Column {
answers.forEach { answer ->
SurveyAnswer(answer = answer)
}
}
}
37. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
38. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
Column {
answers.forEach { answer ->
// Can’t do this!!
val answer = SurveyAnswer(answer = answer)
}
}
}
39. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
Column {
answers.forEach { answer ->
SurveyAnswer(answer = answer)
}
}
}
40. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
Column {
if (answers.isEmpty()) {
Text(“There are no answers to choose from!”)
} else {
answers.forEach { answer ->
SurveyAnswer(answer = answer)
}
}
}
}
41. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
// Don’t do this! There shouldn’t be side-effects
SurveyApp.didShowSingleChoiceQuestion = true
Column {
if (answers.isEmpty()) { /* ... */ }
else { /* ... */ }
}
}
42. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
// Fast and no side-effects
Column {
if (answers.isEmpty()) { /* ... */ }
else { /* ... */ }
}
}
43. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
Column {
answers.forEach { answer ->
SurveyAnswer(answer = answer)
}
}
}
44. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
answers.forEach { answer ->
SurveyAnswer(
answer = answer,
isSelected = false,
)
}
}
45. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
answers.forEach { answer ->
SurveyAnswer(
answer = answer,
isSelected = false,
)
}
}
46. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
answers.forEach { answer ->
SurveyAnswer(
answer = answer,
isSelected = false,
)
}
}
47. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
var selectedAnswer: Answer? = null
answers.forEach { answer ->
SurveyAnswer(
answer = answer,
isSelected = false,
)
}
}
48. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
var selectedAnswer: Answer? = null
answers.forEach { answer ->
SurveyAnswer(
answer = answer,
isSelected = false,
)
}
}
49. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
var selectedAnswer: MutableState<Answer?> =
mutableStateOf(null)
answers.forEach { answer ->
SurveyAnswer(
answer = answer,
isSelected = false,
)
}
}
50. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
var selectedAnswer: MutableState<Answer?> =
mutableStateOf(null)
answers.forEach { answer ->
SurveyAnswer(
answer = answer,
isSelected = false,
)
}
}
51. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
var selectedAnswer: MutableState<Answer?> =
mutableStateOf(null)
answers.forEach { answer ->
SurveyAnswer(
answer = answer,
isSelected = (selectedAnswer.state == answer),
)
}
}
52. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
var selectedAnswer: MutableState<Answer?> =
remember { mutableStateOf(null) }
answers.forEach { answer ->
SurveyAnswer(
answer = answer,
isSelected = (selectedAnswer.state == answer),
)
}
}
53. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
var selectedAnswer: MutableState<Answer?> =
rememberSaveable { mutableStateOf(null) }
answers.forEach { answer ->
SurveyAnswer(
answer = answer,
isSelected = (selectedAnswer.state == answer),
)
}
}
54. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
var selectedAnswer: Answer? by
rememberSaveable { mutableStateOf(null) }
answers.forEach { answer ->
SurveyAnswer(
answer = answer,
isSelected = (selectedAnswer.state == answer),
)
}
}
55. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
var selectedAnswer: Answer? by
rememberSaveable { mutableStateOf(null) }
answers.forEach { answer ->
SurveyAnswer(
answer = answer,
isSelected = (selectedAnswer == answer),
)
}
}
56. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
var selectedAnswer: Answer? by
rememberSaveable { mutableStateOf(null) }
answers.forEach { answer ->
SurveyAnswer(
answer = answer,
isSelected = (selectedAnswer == answer),
onAnswerSelected = { answer -> selectedAnswer = answer }
)
}
}
57. This work is licensed under the Apache 2.0 License
Event
handler
UI element
event
state
Events change State
58. This work is licensed under the Apache 2.0 License
Event
handler
UI element
onAnswerSelecte
d
answer
Events change State
59. This work is licensed under the Apache 2.0 License
// SingleChoiceQuestion.kt
@Composable
fun SingleChoiceQuestion(answers: List<Answer>) {
val selectedAnswer: Answer? by
rememberSaveable { mutableStateOf<Answer>(null) }
answers.forEach { answer ->
SurveyAnswer(
answer = answer,
isSelected = (selectedAnswer == answer),
onAnswerSelected = { answer -> selectedAnswer = answer }
)
}
}
60. This work is licensed under the Apache 2.0 License
Composable
functions can
execute in any
order.
61. This work is licensed under the Apache 2.0 License
// ButtonRow.kt
@Composable
fun ButtonRow() {
MyFancyNavigation {
StartScreen()
MiddleScreen()
EndScreen()
}
}
62. This work is licensed under the Apache 2.0 License
Composable
functions can run
in parallel.
63. This work is licensed under the Apache 2.0 License
@Composable
fun ListComposable(myList: List<String>) {
Row(horizontalArrangement = Arrangement.SpaceBetween) {
Column {
for (item in myList) {
Text("Item: $item")
}
}
Text("Count: ${myList.size}")
}
}
// ListComposable.kt
64. This work is licensed under the Apache 2.0 License
@Composable
fun ListWithBug(myList: List<String>) {
var items = 0
Row(horizontalArrangement = Arrangement.SpaceBetween) {
Column {
for (item in myList) {
Text("Item: $item”)
items++ // Avoid! Side-effect of the column recomposing.
}
}
Text("Count: $items")
}
}
// ListComposable.kt
65. This work is licensed under the Apache 2.0 License
Recomposition skips
as much as possible.
66. This work is licensed under the Apache 2.0 License
@Composable
fun GreetingScreen(name: String) {
Column {
Header()
Greeting(name = name)
Footer()
}
}
// GreenScreen.kt
67. This work is licensed under the Apache 2.0 License
Recomposition is
optimistic.
68. This work is licensed under the Apache 2.0 License
Composable
functions might run
frequently.
69. This work is licensed under the Apache 2.0 License
Summary
Create composables using the @Composable annotation
It’s quick & easy to create composables
Composables accept parameters
Use MutableState and remember
Composables should be side-effect free
70. This work is licensed under the Apache 2.0 License
Composables can:
Execute in any order
Run in parallel
Be skipped
Run frequently
1
2
3
4
71. This work is licensed under the Apache 2.0 License
Compose Toolkit
72. This work is licensed under the Apache 2.0 License
goo.gle/compose-samples
73. This work is licensed under the Apache 2.0 License
74. This work is licensed under the Apache 2.0 License
75. This work is licensed under the Apache 2.0 License
MaterialTheme(
colorScheme = MyAppsColorScheme,
typography = MyAppsTypography,
shapes = MyAppsShapes
) {
// Content goes here
}
76. This work is licensed under the Apache 2.0 License
77. This work is licensed under the Apache 2.0 License
78. This work is licensed under the Apache 2.0 License
79. This work is licensed under the Apache 2.0 License
80. This work is licensed under the Apache 2.0 License
81. This work is licensed under the Apache 2.0 License
Scaffold(
topBar = { SmallTopAppBar(/* ... */) },
floatingActionButtonPosition = FabPosition.End,
floatingActionButton = {
FloatingActionButton(/* ... */)
},
content = { /* ... */ }
)
82. This work is licensed under the Apache 2.0 License
SurveyTopAppBa
r
SurveyBottomBa
r
Question
83. This work is licensed under the Apache 2.0 License
84. This work is licensed under the Apache 2.0 License
85. This work is licensed under the Apache 2.0 License
86. This work is licensed under the Apache 2.0 License
87. This work is licensed under the Apache 2.0 License
88. This work is licensed under the Apache 2.0 License
Surface {
Text("Hello Compose")
}
Hello Compose
89. This work is licensed under the Apache 2.0 License
Surface(
color = MaterialTheme.colorScheme.primary,
) {
Text("Hello Compose")
}
Hello Compose
90. This work is licensed under the Apache 2.0 License
Surface(
color = MaterialTheme.colorScheme.primary,
shape = RoundedCornerShape(8.dp),
) {
Text("Hello Compose")
}
Hello Compose
91. This work is licensed under the Apache 2.0 License
Surface(
color = MaterialTheme.colorScheme.surface,
shape = RoundedCornerShape(8.dp),
border = BorderStroke(2.dp,
MaterialTheme.colorScheme.outline
)
) {
Text("Hello Compose")
}
Hello Compose
92. This work is licensed under the Apache 2.0 License
Surface(
color = MaterialTheme.colorScheme.surface,
shape = RoundedCornerShape(8.dp),
border = BorderStroke(2.dp,
MaterialTheme.colorScheme.surfaceVariant
),
shadowElevation = 8.dp,
tonalElevation = 8.dp,
) {
Text("Hello Compose")
}
Hello Compose
93. This work is licensed under the Apache 2.0 License
94. This work is licensed under the Apache 2.0 License
96. This work is licensed under the Apache 2.0 License
Standard layouts
97. This work is licensed under the Apache 2.0 License
Row {
Component1()
Component2()
Component3()
} 1 2 3
Row
98. This work is licensed under the Apache 2.0 License
1
2
3
Column
Column {
Component1()
Component2()
Component3()
}
99. This work is licensed under the Apache 2.0 License
2
1
3
Box
Box {
Component1()
Component2()
Component3()
}
100. This work is licensed under the Apache 2.0 License
@Composable
fun SurveyAnswer(answer: Answer)
{
Row {
Image(answer.image)
Text(answer.text)
RadioButton(/* … */)
}
}
101. This work is licensed under the Apache 2.0 License
@Composable
fun SurveyAnswer(answer: Answer)
{
Row(
verticalAlignment =
Alignment.CenterVertically
) {
/* ... */
}
}
102. This work is licensed under the Apache 2.0 License
@Composable
fun SurveyAnswer(answer: Answer)
{
Row(
verticalAlignment =
Alignment.CenterVertically,
horizontalArrangement =
Arrangement.SpaceBetween
) {
/* ... */
}
}
104. This work is licensed under the Apache 2.0 License
Modifiers
105. This work is licensed under the Apache 2.0 License
Text("Hello
Compose")
Hello
Compose
106. This work is licensed under the Apache 2.0 License
Text(
"Hello Compose!",
Modifier.background(Color.Magenta)
)
Hello
Compose
107. This work is licensed under the Apache 2.0 License
Text(
"Hello Compose!",
Modifier.background(Color.Magenta)
.size(200.dp, 30.dp)
)
Hello Compose
108. This work is licensed under the Apache 2.0 License
Text(
"Hello Compose!",
Modifier.background(Color.Magenta)
.size(200.dp, 30.dp)
.padding(5.dp)
)
Hello Compose
109. This work is licensed under the Apache 2.0 License
Text(
"Hello Compose!",
Modifier.background(Color.Magenta)
.size(200.dp, 30.dp)
.padding(5.dp)
.alpha(0.5f)
)
Hello Compose
110. This work is licensed under the Apache 2.0 License
Text(
"Hello Compose!",
Modifier.background(Color.Magenta)
.size(200.dp, 30.dp)
.padding(5.dp)
.alpha(0.5f)
.clickable {
// Called when Text clicked
}
)
Hello Compose
111. This work is licensed under the Apache 2.0 License
Box(Modifier.size(150.dp)) {
Text("Hello Compose")
}
Hello
Compose
112. This work is licensed under the Apache 2.0 License
Box(Modifier.size(150.dp)) {
Text(
"Hello Compose!",
Modifier.align(
Alignment.BottomEnd
)
)
}
Hello
Compose
113. This work is licensed under the Apache 2.0 License
@Composable
fun SurveyAnswer(answer: Answer) {
Row(...) {
Image(answer.image)
Text(answer.text)
RadioButton(/* … */)
}
}
Desired
Current
114. This work is licensed under the Apache 2.0 License
@Composable
fun SurveyAnswer(answer: Answer) {
Row(
Modifier.fillMaxWidth(),
/* ... */
) {
Image(answer.image)
Text(answer.text)
RadioButton(/* ... */)
}
}
Desired
Current
115. This work is licensed under the Apache 2.0 License
@Composable
fun SurveyAnswer(answer: Answer) {
Row(
Modifier.fillMaxWidth()
.padding(16.dp),
/* ... */
) {
Image(answer.image)
Text(answer.text)
RadioButton(/* ... */)
}
}
Desired
Current
116. This work is licensed under the Apache 2.0 License
@Composable
fun SurveyAnswer(answer: Answer) {
Surface(
border = BorderStroke(
1.dp,
MaterialTheme.colorScheme.outline
),
shape = MaterialTheme.shapes.small
) {
Row(/* ... */) { }
}
}
Desired
Current