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
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
860
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
540
Jakarta EE meets AI
ivargrimstad
0
610
CSC509 Lecture 11
javiergs
PRO
0
180
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
120
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
170
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
900
RubyLSPのマルチバイト文字対応
notfounds
0
120
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.1k
Jakarta EE meets AI
ivargrimstad
0
540
Amazon Qを使ってIaCを触ろう!
maruto
0
400
役立つログに取り組もう
irof
28
9.6k
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Being A Developer After 40
akosma
86
590k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Visualization
eitanlees
145
15k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Code Reviewing Like a Champion
maltzj
520
39k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
It's Worth the Effort
3n
183
27k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
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