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
Data Essentials in SwiftUI
Search
ry-itto
July 09, 2020
Programming
1
430
Data Essentials in SwiftUI
集まれSwift好き!Swift愛好会スピンオフ WWDC20セッション要約会 @オンライン
ry-itto
July 09, 2020
Tweet
Share
More Decks by ry-itto
See All by ry-itto
決定版!?OSSアプリプロジェクトでのBeta版アプリ配布の方法「Xcode Cloud + TestFlight」
ryitto
0
280
CA.swift#14
ryitto
3
5k
swift-argument-parserで 簡単 CLI ツール作り
ryitto
1
110
Composable Architecture
ryitto
0
700
CollectionViewの 新しいレイアウトの作り方
ryitto
0
46
Swift5.1 SwiftUI
ryitto
0
120
Other Decks in Programming
See All in Programming
CSC509 Lecture 09
javiergs
PRO
0
140
CSC509 Lecture 12
javiergs
PRO
0
160
CSC509 Lecture 13
javiergs
PRO
0
110
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
140
flutterkaigi_2024.pdf
kyoheig3
0
140
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
230
Jakarta EE meets AI
ivargrimstad
0
580
Outline View in SwiftUI
1024jp
1
330
Contemporary Test Cases
maaretp
0
140
Quine, Polyglot, 良いコード
qnighy
4
640
C++でシェーダを書く
fadis
6
4.1k
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
480
Featured
See All Featured
Designing for Performance
lara
604
68k
Navigating Team Friction
lara
183
14k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
A Philosophy of Restraint
colly
203
16k
Writing Fast Ruby
sferik
627
61k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Why Our Code Smells
bkeepers
PRO
334
57k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Ruby is Unlike a Banana
tanoku
97
11k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Six Lessons from altMBA
skipperchong
27
3.5k
Transcript
3ZPZB*UP !SZJUUP %BUB&TTFOUJBMTJO4XJGU6* ू·Ε4XJGU͖ʂ4XJGUѪձεϐϯΦϑ88%$ηογϣϯཁձ!ΦϯϥΠϯ
ࣗݾհ ҏ౻྇ !SZJUUP ձେֶֶ෦ੜ Χϐόϥ͕͖
ηογϣϯͷ༰ w 4XJGU6*Ͱͷσʔλϑϩʔ w ΞϓϦͷσʔλϞσϧઃܭ w ࣮ࡍʹΞϓϦʹऔΓೖΕΔࡍͷςΫχοΫ
ηογϣϯͷ༰ w 4XJGU6*Ͱͷσʔλϑϩʔ w ΞϓϦͷσʔλϞσϧઃܭ w ࣮ࡍʹΞϓϦʹऔΓೖΕΔࡍͷςΫχοΫ
4XJGU6*Ͱͷσʔλϑϩʔ ϏϡʔΛ࡞Δ࣌ʹߟ͍͑ͨ̏ͭͷ࣭ w ࡞͢ΔϏϡʔͰඞཁͳσʔλԿ͔ʁ w ࡞͢ΔϏϡʔͰσʔλΛͲͷΑ͏ʹૢ࡞͢Δ͔ʁ w σʔλͲ͔͜ΒདྷΔʢ͞ΕΔʣͷ͔ʁ
4XJGU6*Ͱͷσʔλϑϩʔ ϏϡʔΛ࡞Δ࣌ʹߟ͍͑ͨ̏ͭͷ࣭ w ࡞͢ΔϏϡʔͰඞཁͳσʔλԿ͔ʁ CPPLͱ͍͏#PPLܕͷ QSPHSFTTͱ͍͏%PVCMFܕͷ ͦΕͧΕ͕͋ΕϏϡʔΛදࣔͰ͖ͦ͏ɻ w ࡞͢ΔϏϡʔͰσʔλΛͲͷΑ͏ʹૢ࡞͢Δ ͔ʁ
ಛʹͳͦ͞͏ w σʔλͲ͔͜ΒདྷΔʢ͞ΕΔʣͷ͔ʁ ͜ͷϏϡʔΛ͏ϏϡʔͰ͞ΕΔ͜ͱʹͳΓͦ͏ɻ struct BookCard : View { let book: Book let progress: Double var body: some View { HStack { Cover(book.coverName) VStack(alignment: .leading) { TitleText(book.title) AuthorText(book.author) } Spacer() RingProgressView(value: progress) } } }
4XJGU6*Ͱͷσʔλϑϩʔ ϏϡʔΛ࡞Δ࣌ʹߟ͍͑ͨ̏ͭͷ࣭ w ࡞͢ΔϏϡʔͰඞཁͳσʔλԿ͔ʁ CPPLͱ͍͏#PPLܕͷ QSPHSFTTͱ͍͏%PVCMFܕͷ ͦΕͧΕ͕͋ΕϏϡʔΛදࣔͰ͖ͦ͏ɻ w ࡞͢ΔϏϡʔͰσʔλΛͲͷΑ͏ʹૢ࡞͢ Δ͔ʁ
ಛʹͳͦ͞͏ w σʔλͲ͔͜ΒདྷΔʢ͞ΕΔʣͷ͔ʁ ͜ͷϏϡʔΛ͏ϏϡʔͰ͞ΕΔ͜ͱʹͳΓͦ͏ɻ struct BookCard : View { let book: Book let progress: Double var body: some View { HStack { Cover(book.coverName) VStack(alignment: .leading) { TitleText(book.title) AuthorText(book.author) } Spacer() RingProgressView(value: progress) } } } l4PVSDFPG5SVUIzͱ͍͏ݴ༿ͰηογϣϯͰѻΘΕΔ
4XJGU6*Ͱͷσʔλϑϩʔ ϏϡʔͰͷσʔλอ࣋ɺͦΕͧΕͲΜͳ࣌ʹ͏ʁ ϓϩύςΟϏϡʔʹΑͬͯมߋ͞Εͳ͍σʔλ !4UBUFϏϡʔʹΑͬͯอ࣋͞ΕΔҰ࣌తͳσʔλΛѻ͏ !#JOEJOHଞͷϏϡʔʹΑͬͯอ࣋͞Ε͍ͯΔσʔλΛมߋ͍ͨ͠߹
ηογϣϯͷ༰ w 4XJGU6*Ͱͷσʔλϑϩʔ w ΞϓϦͷσʔλϞσϧઃܭ w ࣮ࡍʹΞϓϦʹऔΓೖΕΔࡍͷςΫχοΫ
ΞϓϦͷσʔλϞσϧઃܭ σʔλϞσϧఆٛ w 0CTFSWBCMF0CKFDUΛ͏ w !1VCMJTIFEΛ͏ w ̎ͭͷ࣭ ࡞͢ΔϏϡʔͰσʔλΛͲͷΑ͏ʹૢ࡞͢ Δ͔ʁ
ʹ͑Δͷ༰қ class CurrentlyReading: ObservableObject { let book: Book @Published var progress = ReadingProgress() @Published var isFinished = false var currentProgress: Double { isFinished ? 1.0 : progress.progress } }
ΞϓϦͷσʔλϞσϧઃܭ ϏϡʔͰ࡞ͬͨϞσϧΛ͏ w ଞͷ̎ͭͷ࣭ʹ͍ͭͯʁ w ࡞͢ΔϏϡʔͰඞཁͳσʔλԿ͔ʁ w ࡞͢ΔϏϡʔͰσʔλΛͲͷΑ͏ʹૢ࡞͢Δ͔ʁ w σʔλͲ͔͜ΒདྷΔʢ͞ΕΔʣͷ͔ʁ
ΞϓϦͷσʔλϞσϧઃܭ ϏϡʔͰ࡞ͬͨϞσϧΛ͏ w ѻ͏ͨΊͷ1SPQFSUZ8SBQQFS͕̏ͭ w !0CTFSWFE0CKFDU w !&OWJSPONFOU0CKFDU w !4UBUF0CKFDU
/FX
ΞϓϦͷσʔλϞσϧઃܭ ϏϡʔͰ࡞ͬͨϞσϧΛ͏ !0CTFSWFE0CKFDU σʔλͷґଘؔΛ࡞Δ !&OWJSPONFOU0CKFDU Ϗϡʔ֊ؒͷ0CTFSWBCMF0CKFDUͷѻ͍Λศརʹ͢Δ !4UBUF0CKFDU /FX 0CTFSWBCMF0CKFDUΛϏϡʔͷϥΠϑαΠΫϧʹ݁ͼ͚ͭΔ
ηογϣϯͷ༰ w 4XJGU6*Ͱͷσʔλϑϩʔ w ΞϓϦͷσʔλϞσϧઃܭ w ࣮ࡍʹΞϓϦʹऔΓೖΕΔࡍͷςΫχοΫ
࣮ࡍʹΞϓϦʹऔΓೖΕΔࡍͷςΫχοΫ w ࢠͷϏϡʔͰϞσϧΛϓϩύςΟͰ ͍࣋ͬͯͯɺͦ͜ͰॳظԽ͍ͯ͠Δ ߹ w 3FBEJOH-JTU7JFXFS͕ࡍϨϯμϦϯά͞ ΕΔͨͼʹϞσϧͷΠϯελϯε͕ੜ ͞Εͯ͠·͏
struct ReadingListViewer: View { var body: some View { NavigationView { ReadingList() Placeholder() } } } struct ReadingList: View { @ObservedObject var store = ReadingListStore() var body: some View { // ... } }
࣮ࡍʹΞϓϦʹऔΓೖΕΔࡍͷςΫχοΫ ղܾࡦ w !4UBUF0CKFDUΛΘΓʹ͏͜ͱ Ͱղܾ͕Ͱ͖ΔʢΒ͍͠ʣ w !4UBUF0CKFDUΛ༻͢Δͱ4XJGU6*͕ దͳλΠϛϯάͰΠϯελϯεԽΛ͠ ͯ͘ΕΔͱͷ͜ͱ struct
ReadingListViewer: View { var body: some View { NavigationView { ReadingList() Placeholder() } } } struct ReadingList: View { @StateObject var store = ReadingListStore() var body: some View { // ... } }
࣮ࡍʹΞϓϦʹऔΓೖΕΔࡍͷςΫχοΫ ୭͕σʔλΛ࣋ͭͷ͔ w ڞ௨ͷઌʹ࣋ͭ w !4UBUF0CKFDUΛͬͯͦͷϏϡʔ͕ࣗ࣋ͭ w ΞϓϦͷάϩʔόϧͳσʔλͱͯ࣋ͭ͠ w "QQΛܧঝͨ͠Ϗϡʔʹ!4UBUFͳͲΛར༻ͯ͠એݴͯ͋͛͠Δ
࣮ࡍʹΞϓϦʹऔΓೖΕΔࡍͷςΫχοΫ σʔλͷӬଓԽ w 4DFOF4UPSBHF w 4XJGU6*͕ཧ͍ͯ͠ΔϏϡʔͰ͔͑͠ͳ͍ w ߲ͷબঢ়ଶͳͲΛอଘ w "QQ4UPSBHF
w 6TFS%FGBVMUΛ༻ͨ͠άϩʔόϧετϨʔδ w ઃఆͳͲͷখ͞ͳσʔλΛอଘ
͓·͚ ৽͘͠Ճ͞ΕͨΠϕϯτιʔε w PO$IBOHF w PO0QFO63- w PO$POUJOVF6TFS"DUJWJUZ