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
モーダルの遷移を理解する
Search
Yuki Yasoshima
August 29, 2023
Programming
4
1.6k
モーダルの遷移を理解する
iOSDC Japan 2023
2023年9月1日
Yuki Yasoshima
August 29, 2023
Tweet
Share
More Decks by Yuki Yasoshima
See All by Yuki Yasoshima
Swift Concurrencyとレースコンディション
objectiveaudio
1
410
オーディオ波形を表示するために知っておくべきこと
objectiveaudio
0
810
AVAudioEngineでリアルタイムレンダリング
objectiveaudio
1
650
リファクタリング・チャレンジ リバーシ編
objectiveaudio
0
120
UIKitは2度ベルを鳴らす
objectiveaudio
0
260
iOSDC2018.pdf
objectiveaudio
1
1.9k
Objective-C++を使ってMRCで快適に開発する
objectiveaudio
0
21k
Other Decks in Programming
See All in Programming
Jakarta EE meets AI
ivargrimstad
1
490
REXML改善のその後
naitoh
0
190
エンジニア1年目で複雑なコードの改善に取り組んだ話
mtnmr
3
2k
Why Prism?
kddnewton
4
1.7k
Modern Angular with the NGRX Signal Store New Rules for Your Architecture @BASTA! 2024 in Mainz
manfredsteyer
PRO
0
120
Amebaチョイス立ち上げの裏側 ~依存システムとの闘い~
daichi_igarashi
0
230
Shinjuku.rb#95:心の技術書紹介
free_world21
1
110
Hono・Prisma・AWSでGeoなAPI開発
nokonoko1203
5
680
マルチモジュールにおけるテスト最適化
fxwx23
0
210
Scala におけるコンパイラエラーとの付き合い方
chencmd
2
430
Jakarta EE meets AI
ivargrimstad
0
380
Using Livebook to build and deploy internal tools @ ElixirConf 2024
hugobarauna
0
250
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
39
2.3k
BBQ
matthewcrist
83
9.2k
Principles of Awesome APIs and How to Build Them.
keavy
125
16k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.4k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
38
9.2k
How To Stay Up To Date on Web Technology
chriscoyier
786
250k
4 Signs Your Business is Dying
shpigford
179
21k
Fantastic passwords and where to find them - at NoRuKo
philnash
48
2.8k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
230
17k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
157
15k
Practical Orchestrator
shlominoach
185
10k
Building Your Own Lightsaber
phodgson
101
6k
Transcript
ϞʔμϧͷભҠΛཧղ͢Δ :VLJ:BTPTIJNB !ZBTP@TBO
͡Ίʹ w ͕͍࣌ؒͷͰɺओʹ4XJGU6*ʹߜͬͯ͠·͢ w ಛʹݴٴ͍ͯ͠ͳ͚ΕɺJ04J1BE04ͷγϛϡϨʔλͰಈ࡞֬ೝͨ͠ ڍಈΛͱʹ͍ͯ͠·͢
͢͜ͱ w Ϟʔμϧʹ͍ͭͯ w Ϟʔμϧͷ w ϞʔμϧͷΛղܾ͢Δ
͜ͷτʔΫͰ͏༻ޠ
Ϟʔμϧ w ͜ͷτʔΫͰJ04ͷը໘શମͷ্ʹ෴ͬͯผͷը໘Λલ໘ʹදࣔ͢ΔػೳΛ ද͢ w 4IFFU"MFSUͳͲͷ͜ͱ w ࣙॻతͳҙຯؾʹ͠ͳ͍
σʔλιʔε w !4UBUF0CTFSWBCMF0CKFDUɺ͞Βʹͦͷઌʹ͋Δ7JFXΛදࣔ͢ΔͨΊͷ σʔλ w ͜ͷτʔΫͰɺ7JFXͱσʔλιʔε͘Β͍ͷϨΠϠʔ͚Ͱ͢
Ϟʔμϧʹ͍ͭͯ
Ϟʔμϧͷछྨ w 4IFFU w 'VMM4DSFFO$PWFS w "MFSU w 1PQPWFS w
$PO fi SNBUJPO%JBMPHʢ"DUJPO4IFFUʣ w .FOV1JDLFS
Ϟʔμϧͷ֊ w Ϟʔμϧʹ֊͕͋Δ w 4IFFUɾ'VMM4DSFFO$PWFSɾ1PQPWFSෳ֊ੵΈॏͶΒΕΔ
ϧʔτͷ6*֊ 5BC /BWJHBUJPO 7JFX 5FYU *NBHF -JTU 8JOEPX Ϟʔμϧͷ֊ 4IFFUͷ߹
Ϟʔμϧୈ֊ 5BC /BWJHBUJPO 7JFX 5FYU *NBHF -JTU ։͘ 8JOEPX Ϟʔμϧͷ֊
4IFFUͷ߹ ϧʔτͷ6*֊ 5BC /BWJHBUJPO 7JFX 5FYU *NBHF -JTU
Ϟʔμϧୈ֊ 5BC /BWJHBUJPO 7JFX 5FYU *NBHF -JTU 8JOEPX 5BC /BWJHBUJPO
7JFX 5FYU *NBHF -JTU Ϟʔμϧͷ֊ 4IFFUͷ߹ ❌։͚ͳ͍ ϧʔτͷ6*֊
Ϟʔμϧୈ֊ Ϟʔμϧୈ֊ 5BC /BWJHBUJPO 7JFX 5FYU *NBHF -JTU ։͘ 8JOEPX
5BC /BWJHBUJPO 7JFX 5FYU *NBHF -JTU Ϟʔμϧͷ֊ 4IFFUͷ߹ ϧʔτͷ6*֊
5BC /BWJHBUJPO 7JFX 5FYU *NBHF -JTU 8JOEPX Ϟʔμϧͷ֊ 4IFFUͷ߹ ด͡Δ
ϧʔτͷ6*֊
5BC /BWJHBUJPO 7JFX 5FYU *NBHF -JTU 8JOEPX Ϟʔμϧͷ֊ 4IFFUͷ߹ ❌
ด͡Εͳ͍ ϧʔτͷ6*֊
Ϟʔμϧͷର w 1PQPWFSɾ$PO fi SNBUJPO%JBMPHͳͲ ࢦࣔ͢͠ઌͷ7JFX͕ඞཁ w 4IFFUɾ'VMM4DSFFO$PWFSɾ"MFSUͳͲ ը໘શମ͔Βग़Δʢಉ͡֊Ͱ͋Ε NPEJ
fi FSΛ͚Δ7JFXͲ͜ʹͯ͠ಈ ࡞ʹҧ͍ͳ͍ʣ
ϞʔμϧͷભҠͷίʔυ JT1SFTFOUFE struct ContentView: View { @State var isPresented: Bool
= false var body: some View { Button(“Show") { isPresented = true } .sheet(isPresented: $isPresented) { ... } } } όΠϯυͨ͠Λมߋ͢ΔͱભҠ #PPMͷΛόΠϯυ͢Δ
ϞʔμϧͷભҠͷίʔυ JUFN struct ContentView: View { @State var item: Item?
= nil var body: some View { Button("Show Sheet") { item = .foo } .sheet(item: $item) { ... } } } όΠϯυͨ͠Ληοτ͢ΔͱભҠ ҙͷ0QUJPOBMͷΛόΠϯυ͢Δ
։͘ ด͡Δ ด͡ऴΘΔ ભҠͷ࣌ؒ࣠ͷྲྀΕ ભҠͷঢ়ଶ JT1SFTFOUFEGBMTF ։͖ऴΘΔ JT1SFTFOUFEUSVF
։͘ ด͡Δ ด͡ऴΘ͔ͬͯΒग़Δ ͔ ϞʔμϧදࣔதͷભҠ ભҠͷঢ়ଶ ଞͷϞʔμϧग़ͤͳ͍
खಈͰด͡Δ w ϞʔμϧͷछྨʹΑͬͯɺεϫΠϓϘλϯλοϓͳͲͰด͡ΒΕΔ w 4IFFUˠεϫΠϓ w "MFSUͳͲˠϘλϯλοϓ w 1PQPWFSͳͲˠ֎ଆΛλοϓ
.FOV w બࢶͷ6*1PQPWFSతͳϞʔμϧͷ Ұछ w JT1SFTFOUFEͳͲͳ͘ɺϢʔβʔૢ ࡞ͰͷΈભҠ͢Δ
։͖ํ ด͡ํ ্ͷ֊ දࣔઌͷ7JFX 4IFFU όΠϯυ όΠϯυ εϫΠϓ ։͚Δ ͍Βͳ͍
'VMM4DSFFO$PWFS όΠϯυ όΠϯυ ։͚Δ ͍Βͳ͍ 1PQPWFS όΠϯυ όΠϯυ ֎Λλοϓ ։͚Δ ͍Δ "MFSU όΠϯυ όΠϯυ Ϙλϯબ ։͚ͳ͍ ͍Βͳ͍ $PO fi SNBUJPO %JBMPH όΠϯυ όΠϯυ Ϙλϯબ ։͚ͳ͍ ͍Δ .FOV λοϓ Ϙλϯબ ֎Λλοϓ ։͚ͳ͍ Ϟʔμϧͷछྨ
ϞʔμϧͰΓͨ͘ͳΔ͜ͱ w %FFQ-JOLඇಉظॲཧͷྃ࣌ͳͲɺϢʔβʔૢ࡞Ҏ֎ͷλΠϛϯάͰϞ ʔμϧͷભҠΛ͍ͨ͠ w ϞʔμϧͷσʔλιʔεΛมߋͨ͠Βɺͦͷঢ়ଶ͕ͦͷ··6*ʹө͞ΕΔΑ ͏ʹ͍ͨ͠ w ͦΕΒΛ࣮ݱ͠Α͏ͱ͢Δͱɺ৭ʑ͕ى͖Δ
Ϟʔμϧͷ
var body: some View { Button("Show") { isFirstPresented = true
isSecondPresented = true isThirdPresented = true } .sheet(isPresented: $isFirstPresented) { Text("1") .sheet(isPresented: $isSecondPresented) { Text("2") .sheet(isPresented: $isThirdPresented) { Text("3") } ... ֊Ҏ্ಉ࣌ʹ։͚ͳ͍ ❌ͭ։͔ͳ͍
J04Ҏલෳ֊ಉ࣌ʹด͡Εͳ͍ var body: some View { Button("Show") { ... }
.sheet(isPresented: $isFirstPresented) { Text("1") .sheet(isPresented: $isSecondPresented) { Button("Close") { isFirstPresented = false } ... J040, ❌J04શ෦ด͡ͳ͍
var body: some View { ... .sheet(isPresented: $isSheetPresented) { Button("Switch
to FullScreen") { isSheetPresented = false isFullPresented = true } } .fullScreenCover( isPresented: $isFullPresented) { Text("Full Screen") } } ϞʔμϧͷΓସ͑ 'VMM4DSFFO͕4IFFUͰදࣔ͞ΕΔ ❌4IFFUͰදࣔ͞ΕΔ
var body: some View { ... .sheet(isPresented: $isSheetPresented) { Button("Show
Alert") { isSheetPresented = false isAlertPresented = true } } .alert("Alert", isPresented: $isAlertPresented) { ... } } ϞʔμϧͷΓସ͑ "MFSU͕දࣔ͞Εͳ͍ ❌දࣔ͞Εͳ͍
ϞʔμϧͷΓସ͑ 1PQPWFSܥ w ਧ͖ग़͠ͷ֎ଆԼͷ֊ͷ7JFXʹ λοϓ͕௨Δ w 1PQPWFSΛ։͍ͨ··ɺ4IFFUΛλοϓ ͯ͠։͜͏ͱͯ͠։͚ͳ͍ w σʔλιʔεͱ7JFXͷ߹ੑ͕औΕͳ
͘ͳΔͱͱ։͚ͳ͘ͳΔ ❌λοϓͰ͖Δ͕ 4IFFUදࣔ͞Εͳ͍
var body: some View { Button("Freeze") { isFirstPresented = true
isSecondPresented = true Task { try await Task.sleep(for: .milliseconds(100)) isFirstPresented = false } } .sheet(isPresented: $isFirstPresented) { ... .sheet(isPresented: $isSecondPresented) { ... } ભҠதʹด͡Α͏ͱ͢ΔͱϑϦʔζ ❌ϑϦʔζ͢Δ
var body: some View { Button("Crash") { item = .one
Task { try await Task.sleep(for: .milliseconds(100)) item = .two try await Task.sleep(for: .milliseconds(100)) item = .three } } .sheet(item: $item, content: { item in ... }) } ϞʔμϧΓସ͑தʹ͞ΒʹΓସ͑ΔͱΫϥογϡ ❌Ϋϥογϡ͢Δ
ϞʔμϧͷΛղܾ͢Δ
ํ w σʔλιʔεͰϞʔμϧͷঢ়ଶΛηοτͨ͠Βɺͦͷ··6*ʹө͞ΕΔΑ͏ ʹ͍ͨ͠ w J04Ҏ߱Λରʹͯ͠ด͡Δ࣌ͷΛճආ w ϞʔμϧͷભҠதʹผͷભҠ͕ߦΘΕͳ͍Α͏ʹͯ͠Λճආ w .FOVͷϞʔμϧ͕։͍͍ͯͯଞͷϞʔμϧ͕։͚ΔΑ͏ʹ͢Δ
enum Modal { case sheet(Item) case alert(...) ... } σʔλιʔε
.PEBM 7JFX 1PQPWFS OJM "MFSU OJM 4IFFU OJM Ϟʔμϧͷঢ়ଶΛͭͷͰද͢ ม 1PQPWFS OJM OJM
enum Modal { case sheet(Item) case alert(...) ... } σʔλιʔε
.PEBM TIFFU GPP 7JFX 1PQPWFS OJM "MFSU OJM 4IFFU GPP Ϟʔμϧͷঢ়ଶΛͭͷͰද͢ ม 1PQPWFS OJM
enum Modal { case sheet(Item) case alert(...) ... } σʔλιʔε
.PEBM BMFSU CBS 7JFX 1PQPWFS OJM "MFSU CBS 4IFFU OJM Ϟʔμϧͷঢ়ଶΛͭͷͰද͢ ม 1PQPWFS OJM
σʔλιʔεͷөΛΒͤΔ ։͘ ด͡Δ ։͘ ݩσʔλ όΠϯυ͢Δσʔλ CBS ભҠͷঢ়ଶ OJM OJM
GPP GPP CBS OJM
σʔλιʔεͷөΛΒͤΔ ։͘ ด͡Δ ։͘ ݩσʔλ όΠϯυ͢Δσʔλ GPP CBS OJM GPP
OJM IPH ભҠͷঢ়ଶ IPH OJM
։͘ ด͡Δ ։͘ ݩσʔλ όΠϯυ͢Δσʔλ GPP OJM OJM CBS σʔλιʔεͷөΛΒͤΔ
ભҠͷঢ়ଶ OJM CBS GPP
.FOVΛͳΜͱ͔͢Δ w JT1SFTFOUFEͳ͍͕ɺͷ7JFX͔Β .FOVΛফ͢͜ͱͰਧ͖ग़͠Λඇදࣔʹ Ͱ͖Δ w ϞʔμϧΛදࣔ͢Δલʹ.FOVΛೖΕସ ͑ͯด͓ͯ͘͡ struct MenuView:
View { ... var body: some View { if flag { Menu(...) } else { Menu(...) } } }
.FOVΛดͨ͡ޙͷભҠ w .FOVΛೖΕସ͑ͨͷͱಉ࣌ʹผͷϞʔμϧΛදࣔ͠Α͏ͱͯ͠ɺදࣔ͞ Εͳ͍͜ͱ͕͋Δ w .FOVΛด͔ͯ͡ΒϞʔμϧͷભҠΛ։࢝͢Δ·Ͱʹগؒ͠Λ։͚Δ
7JFXͷߋ৽ 4XJGU6*ͷ7JFXͷߋ৽αΠΫϧ 7JFX͕ߋ৽͞ΕΔλΠϛϯά
σʔλιʔεͷมߋ σʔλιʔεͷมߋ σʔλιʔεͷมߋ 4XJGU6*ͷ7JFXͷߋ৽αΠΫϧ 7JFXͷߋ৽ ఆظతʹ·ͱΊͯσʔλΛ औಘͯ͠ɺ͕ࠩ͋Ε 7JFX͕ߋ৽͞ΕΔ
.FOVඇදࣔޙͷϞʔμϧөλΠϛϯά ❌ ⭕ 7JFXͷߋ৽ .FOVΛด͡Δ ࣮ࡍʹ.FOV͕ด͡ΒΕΔ ผͷϞʔμϧͷ ࣮ࡍͷදࣔ։࢝
ભҠͷλΠϛϯάऔಘ 4IFFU'VMM4DSFFO$PWFS1PQPWFS ։͘ ด͡Δ ભҠͷঢ়ଶ 7JFX$POUSPMMFSͷ WJFX%JE"QQFBS Ϟʔμϧͷ PO%JTBQQFBS
ભҠͷλΠϛϯάऔಘ ։͘ ด͡Δ ભҠͷঢ়ଶ "MFSU$PO fi SNBUJPO%JBMPH PO"QQFBS PO%JTBQQFBS ඵ͘Β͍
ભҠͷλΠϛϯάऔಘ ։͘ ด͡Δ ભҠͷঢ়ଶ "MFSU$PO fi SNBUJPO%JBMPH PO"QQFBS PO%JTBQQFBS Ϙλϯλοϓ͞ΕͨΒ
ڧ੍తʹดͨ͜͡ͱʹ͢Δ ඵ͘Β͍
·ͱΊ Ϟʔμϧͷ w Ϟʔμϧ͕։͚ͳ͍ͱͱ։͚ͳ͘ͳΔ w σʔλιʔεΛมߋ͢ΔλΠϛϯάʹΑͬͯΫϥογϡϑϦʔζ͕ى͖Δ w J04ҎલͰෳ֊ͷϞʔμϧΛಉ࣌ʹด͡Εͳ͍ w .FOVʹભҠͷঢ়ଶΛཧ͢Δ"1*͕ͳ͍
·ͱΊ Ϟʔμϧͷͷղܾ w J04Ҏ߱ʹݶఆ͢Δʢด͡Δͷָ͕ʣ w ಉ͡֊ͷϞʔμϧͷσʔλιʔεΛͭʹ·ͱΊΔ w ϞʔμϧભҠதผͷભҠΛ͡Ίͳ͍ w .FOVͷ7JFX͔ΒೖΕସ͑ͯด͡ɺ࣍ͷϞʔμϧͷભҠ։࢝ΛΒͤΔ
αϯϓϧίʔυ Ϟʔμϧͷͷ࠶ݱ IUUQTHJUIVCDPNPCKFDUJWFBVEJP.PEBM1SPCMFN ϞʔμϧͷΛղܾͨ͠ྫ IUUQTHJUIVCDPNPCKFDUJWFBVEJP.PEBM"SDIJUFDUVSF