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
REXML改善のその後
naitoh
0
190
マルチモジュールにおけるテスト最適化
fxwx23
0
210
エンジニア1年目で複雑なコードの改善に取り組んだ話
mtnmr
3
2k
Amebaチョイス立ち上げの裏側 ~依存システムとの闘い~
daichi_igarashi
0
230
A New Era of Testing
mannodermaus
2
490
Go1.23で入った errorsパッケージの小さなアプデ
kuro_kurorrr
2
390
Kotlin 2.0 and Beyond
antonarhipov
2
150
Amazon Neptuneで始める初めてのグラフDB ー グラフDBを使う意味を考える ー
satoshi256kbyte
2
260
Android開発以外のAndroid開発経験の活かしどころ
konifar
2
970
Desafios e Lições Aprendidas na Migração de Monólitos para Microsserviços em Java
jessilyneh
2
150
大公開!iOS開発の悩みトップ5 〜iOSDC Japan 2024〜
ryunakayama
0
190
労務ドメインを快適に開発する方法 / How to Comfortably Develop in the Labor Domain
yuki21
1
250
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
425
64k
Scaling GitHub
holman
458
140k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
27
7.4k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
157
15k
Faster Mobile Websites
deanohume
304
30k
Atom: Resistance is Futile
akmur
261
25k
The Mythical Team-Month
searls
218
43k
Unsuck your backbone
ammeep
667
57k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
Fashionably flexible responsive web design (full day workshop)
malarkey
401
65k
What's new in Ruby 2.0
geeforr
340
31k
Rebuilding a faster, lazier Slack
samanthasiow
78
8.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