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
SwiftUIっぽくした話
Search
たまねぎ
February 16, 2022
Programming
1
610
SwiftUIっぽくした話
たまねぎ
February 16, 2022
Tweet
Share
More Decks by たまねぎ
See All by たまねぎ
iOSDC2023:聴いて話すiOS 現実世界の「音」との連携
chocoyama
0
290
ハードウェア対応のリアル.pdf
chocoyama
0
67
20分でわかる!速習resultBuilder(iOSDC 2022)
chocoyama
6
2.7k
SwiftUIとGraphQLでプロダクトの継続的な破壊に立ち向かう
chocoyama
6
2.4k
Other Decks in Programming
See All in Programming
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
290
EventSourcingの理想と現実
wenas
6
2.3k
Amazon Qを使ってIaCを触ろう!
maruto
0
400
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
100
Better Code Design in PHP
afilina
PRO
0
120
C++でシェーダを書く
fadis
6
4.1k
CSC509 Lecture 12
javiergs
PRO
0
160
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
430
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
89
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Rails Girls Zürich Keynote
gr2m
94
13k
The World Runs on Bad Software
bkeepers
PRO
65
11k
The Invisible Side of Design
smashingmag
298
50k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
How to Ace a Technical Interview
jacobian
276
23k
Ruby is Unlike a Banana
tanoku
97
11k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Transcript
SwiftUIͬΆͨ͘͠ ϥΫϚ x STORES LTΠϕϯτ ~ iOS։ൃͷཪଆ ~ @_chocoyama
ࣗݾհ • ͨ·Ͷ͗ʢ@_chocoyamaʣ • 201912݄~ ϔΠגࣜձࣾ • STORES ϨδͷiOSΞϓϦ։ൃ
ΞδΣϯμ 1. STORES Ϩδͱ 2. ϨγʔτͱҹͷྲྀΕ 3. ϨγʔτϨΠΞτ࣮ͷมભ 4. ;Γ͔͑Γ
STORES Ϩδͱ • 2021.06ʹϦϦʔε • ࣮ళฮۀΛαϙʔτ͢ΔPOSΞϓϦ • ϑϧSwiftUI • ձܭɾཧɾϨγʔτҹ
etc…
ϑϧSwiftUIʹͨ͠ SwiftUIͬΆͨ͘͠
ϨγʔτͱҹͷྲྀΕ ձܭϨγʔτ ਫ਼ࢉϨγʔτ
ϨγʔτͱҹͷྲྀΕ XML CALayer CGImage ϓϦϯλʔ ϨΠΞτΛಈతʹఆٛ XMLΛύʔεͯ͠CALayerʹม CALayerΛը૾σʔλԽ ը૾ͷόΠφϦσʔλΛBluetoothͰૹ৴
ϨγʔτͱҹͷྲྀΕ XML CALayer CGImage ϓϦϯλʔ ϨΠΞτΛಈతʹఆٛ XMLΛύʔεͯ͠CALayerʹม CALayerΛը૾σʔλԽ ը૾ͷόΠφϦσʔλΛBluetoothͰૹ৴ ॳظஈ֊
Ͳ͏SwiftUIͬΆ͘վળ͖͔ͯͨ͠
ϨγʔτϨΠΞτ࣮ͷมભ • ͬΆ͞Lv1ɿXMLϕλॻ͖Ͱͷ࣮ • ͬΆ͞Lv2ɿFlutterͬΆ͍IFͷϑϨʔϜϫʔΫ࡞ • ͬΆ͞Lv3ɿresultBuilderʹΑΔSwiftUIͬΆ͍IFͷఏڙ
ಠࣗϧʔϧʹج͍ͮͨλά+ଐੑ ↓ Stringͷ݁߹ ↓ XMLจࣈྻΛ࡞ ͬΆ͘ͳ͍ʙʙʙ ͬΆ͞Lv1 : XMLϕλॻ͖Ͱͷ࣮ 9.-
• ܕ҆શͰͳ͘ɺఆ֎ͷจࣈ͕͋ΔͱऴΘΔ • ίʔυͱΞτϓοτͷߏ͕ඇରԠͰɺશମ૾͕ಡΈऔΓͮΒ͍ • Ͱॏෳͨ͠هड़ଟ͍ • มߋʹऑ͍ XMLจࣈྻΛੜ͢Δ͜ͱͷ
XMLએݴత ↓ એݴతUI ↓ SwiftUI ↓ ϨγʔτUISwiftUIͬΆ͘࡞ΕΔͷͰʁ ͰͲ͏͢Δ͔ʁ
• SwiftUIͷΑ͏ʹγϯϓϧͰએݴతͳϨΠΞτఆٛ • ܕͰݎ࿚ͯ͠ɺ͖์͔͚Δهड़Λഉআ • ΤσΟλͷิʹΑΓࣄલࣝͳ͠Ͱॻ͚ΔIF • ࠓޙͷཁૉ֦ுΛݟਾ͑ͯɺՃɾมߋ͍͢͠ → ܕ҆શͰXMLੜΛநԽͨ͠IFΛఏڙ͢Δ
վળํ
·͋·͋ ͬΆ͍ʙʙʙ ֤ཁૉ͝ͱʹΫϥεΛఆٛ ↓ ΠϯελϯεΛReceiptΫϥεʹ͢ ↓ ෦తʹXMLจࣈྻΛ࡞ ʢXMLΛॻ͔ͳͯ͘ྑ͍ʣ ͬΆ͞Lv2 :
FlutterͬΆ͍IFͷϑϨʔϜϫʔΫ࡞ 9.-
Textͷ߹ • ߏΛଊ͑͘͢ • ࢦఆՄೳύϥϝʔλΛܕͰݫ֨ʹ੍ޚ • ࣄલࣝͳ͠ͰɺิʹΑΓબՄೳͳΛѲ
۩ମతͳ࣮ ʮXMLλά1ͭʹ૬͢ΔจࣈྻΛੜʯ͢ΔIFΛఆٛ ଐੑΛؚΊͯλάจࣈྻΛੜ
۩ମతͳ࣮ ͯ͢ͷจࣈྻΛ1ͭͷXMLʹ·ͱΊ্͛Δ
՝ ཁૉΛྻʹͯ͢͠ ↓ ੍ࣜޚߏจΛॻ͚ͳ͍ ↓ ผΫϥεΛ࡞۪ͯ͠ʹରԠ
• resultBuilderͰߋʹSwiftUIͬΆ͘ • ذ܁Γฦ͠هड़Մೳʹ ͔ͳΓ ͬΆ͍ʙʙʙ ͬΆ͞Lv3 : resultBuilderʹΑΔSwiftUIͬΆ͍IFͷఏڙ 9.-
resultBuilder • Swift5.4ͰՃ͞ΕͨAttributeͰɺ෦DSLੜʹ׆༻Ͱ͖Δ ʢSwiftUIͷViewBuilderʹΘΕ͍ͯΔʣ • ؔͳͲʹద༻͢ΔͱɺྻڍΛऩूͯ͠࠷ऴతͳܕʹ·ͱΊΒΕΔ • ͷྻڍʹΧϯϚ͕ඞཁͳ͘ɺ੍ࣜޚߏจهड़Ͱ͖Δ •
ϓϩτλΠϓͷ@_functionBuilderͰɺػೳ੍͕ݶ͞Ε͍ͯͨ ྻڍͨ͠ SFTVMU#VJMEFS ࠷ऴతͳ
୯७ͳͷྻڍ < > CVJME#MPDL
ذ͕͋Δ߹ <><><><> CVJME&YQSFTTJPO <<> <>> < > CVJME#MPDL <
> < > CVJME&JUIFS fi STU <<> <> < >> < > CVJME#MPDL
elseઅͷͳ͍ذ͕͋Δ߹ <> CVJME0QUJPOBM
ϧʔϓ͕͋Δ߹ <<> <> <> <>> < > CVJME"SSBZ
ʂ ड͚͞ΕΔͷύλʔϯʹԠͯ͡ɺରԠ͢ΔbuildؔΛ࣮ → ݁Ռͷܕʹม͍ͯ͘͠
ϨγʔτϨΠΞτ༻ͷ࣮ [ReceiptElement] ྻڍͨ͠ SFTVMU#VJMEFS ࠷ऴతͳ
࠷ऴܗ ͬΆ͘ͳͬͨʂ
࠷ऴܗ
;Γ͔͑Γ • ཧܗ͔Βߟ͑ͨͷ͕ྑ͔ͬͨ • ࣮ݱͷͨΊɺΒͳ͍ࣝͷΠϯϓοτػձ͕ੜ·ΕΔ • ܗ͕ελʔτ࣌Ͱݟ͍͑ͯΔͨΊɺઃܭʹϒϨ͕ੜ·Εͳ͍ • ಠࣗSDK͍ॴΛݟۃΊΔͱ͏·͘ػೳ͢Δ •
ʢཚ༻͗͢͠ΔͱٯʹΘ͔ΓͮΒ͘ͳΔҙʣ
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ ͖ͯ͢ͳϨγʔτҹϥΠϑΛʂ