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.8k
モーダルの遷移を理解する
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
510
オーディオ波形を表示するために知っておくべきこと
objectiveaudio
0
860
AVAudioEngineでリアルタイムレンダリング
objectiveaudio
1
710
リファクタリング・チャレンジ リバーシ編
objectiveaudio
0
130
UIKitは2度ベルを鳴らす
objectiveaudio
0
280
iOSDC2018.pdf
objectiveaudio
1
2k
Objective-C++を使ってMRCで快適に開発する
objectiveaudio
0
22k
Other Decks in Programming
See All in Programming
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
これでLambdaが不要に?!Step FunctionsのJSONata対応について
iwatatomoya
2
3.6k
14 Years of iOS: Lessons and Key Points
seyfoyun
1
770
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
3
950
今からはじめるAndroidアプリ開発 2024 / DevFest 2024
star_zero
0
1k
ソフトウェアの振る舞いに着目し 複雑な要件の開発に立ち向かう
rickyban
0
890
Recoilを剥がしている話
kirik
5
6.6k
As an Engineers, let's build the CRM system via LINE Official Account 2.0
clonn
1
670
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
640
Discord Bot with AI -for English learners-
xin9le
1
120
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
180
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
4 Signs Your Business is Dying
shpigford
181
21k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Embracing the Ebb and Flow
colly
84
4.5k
YesSQL, Process and Tooling at Scale
rocio
169
14k
The Cost Of JavaScript in 2023
addyosmani
45
7k
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