Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ざっくり Jetpack Compose / Cookpad.apk #3
Search
star_zero
July 23, 2019
Programming
2
930
ざっくり Jetpack Compose / Cookpad.apk #3
star_zero
July 23, 2019
Tweet
Share
More Decks by star_zero
See All by star_zero
Jetpack Compose の Side-effect を使いこなす / DroidKaigi 2023
star_zero
4
4k
Android 14 新機能 / Android 14 Meetup Nagoya
star_zero
1
500
Android 14 と Predictive back gesture / Shibuya.apk #42
star_zero
0
300
Coroutines Test 入門 / Android Test Night #8
star_zero
2
740
What's new in Jetpack / I/O Extended Japan 2022
star_zero
1
580
Kotlin 2021 Recap / DevFest 2021
star_zero
3
1.2k
Kotlin Symbol Processing (KSP) を使ったコード生成 / DroidKaigi 2021
star_zero
2
5k
What's new Android 12
star_zero
0
520
これからはじめるAndroid開発 / DevFest 2020
star_zero
4
670
Other Decks in Programming
See All in Programming
Webアプリをできるだけコードを手書きしないで作ってみる
tomokusaba
2
190
禅の心を手に入れよ
eltociear
1
420
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
12
4.2k
Documentation for users with AsciiDoc and Antora
ahus1
0
370
大規模Reactアプリのリアーキテクチャ~8万行のTanStack Query移行の軌跡~
kj455
4
1k
業務ツールとして使うPostman
msys75
0
120
Behind VS Code Extensions for JavaScript / TypeScript Linnting and Formatting
unvalley
6
1.3k
Ruby on Fails - effective error handling with Rails conventions
talyssonoc
0
200
The Cutting Edge Of Versioning (LambdaConf 2024)
chriskrycho
0
210
From Spring Boot 2 to Spring Boot 3 with Java 21 and Jakarta EE
ivargrimstad
0
830
Git Lint
bkuhlmann
4
770
Anthropic Cookbook のおすすめレシピ
schroneko
7
1.4k
Featured
See All Featured
XXLCSS - How to scale CSS and keep your sanity
sugarenia
242
1.2M
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
14
8.4k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
123
39k
Mobile First: as difficult as doing things right
swwweet
217
8.6k
Testing 201, or: Great Expectations
jmmastey
30
6.4k
A Tale of Four Properties
chriscoyier
153
22k
What the flash - Photography Introduction
edds
64
11k
Building an army of robots
kneath
300
41k
Scaling GitHub
holman
457
140k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
34
6.1k
Gamification - CAS2011
davidbonilla
77
4.6k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
22
1.6k
Transcript
ざっくり Jetpack Compose Cookpad.apk #3 2019/07/23
About me •Kenji Abe •メディアプロダクト開発部 •cookpadLive, storeTV •Twitter: @STAR_ZERO
⚠注意⚠ まだAlphaにもなってないので、 今後変更されると思います。 2019/07/20のコードでやっています。
Jetpack Compose
Jetpack Compose •Google I/O 2019で発表 •UIを宣言的に書いてく •Kotlinを使う •React, Litho, Vue.js,
Flutterみたいな感じ
Jetpack Composeで アプリを作ってみた https://github.com/STAR-ZERO/GithubCompose
Hello World
Hello World override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent {
MaterialTheme { Text(text = "Hello World") } } }
レイアウト
レイアウト MaterialTheme { Container( padding = EdgeInsets(16.dp), alignment = Alignment.TopLeft,
width = 240.dp, height = 120.dp ) { Text(text = "Hello World") } }
レイアウト MaterialTheme { Column { Row { Text(text = "123")
Text(text = "456") } Row { Text(text = "abc") Text(text = "def") } } }
レイアウト MaterialTheme { Table { for (i in 0 until
20) { tableRow { for (j in 0 until 2) { Padding(16.dp) { Text(text = "Cell $i - $j") } } } } } }
ステート
ステート Column { val counter = +state { 0 }
Text(text = "count = ${counter.value}") Button( text = "Button", onClick = { counter.value++ } ) }
ステート Column { val flag = +state { false }
if (flag.value) { Text(text = "Jepack") } else { Text(text = "Compose") } Button( text = "Button", onClick = { flag.value = !flag.value } ) }
Commit Scope? (Lifecycle?)
Commit Scope Column { +onActive { } // 最初の1回 +onCommit
{ // 描画されるたび onDispose { } // 破棄されるとき } val flag = +state { false } if (flag.value) { Container { +onCommit { onDispose { } } } } else { // ... } }
まとめ
まとめ •直感的でよさそう ‣ でも、すべてJetpack Composeはツライかも? •ステートやライフサイクルは今までと異なるので注意 ‣ 設計どうしよう
まとめ •ただし、今やるべきではない ‣ Alphaにもなってないので当然 ‣ 正式リリースまではだいぶ時間かかりそうな印象
ありがとうございました