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
66
20分でわかる!速習resultBuilder(iOSDC 2022)
chocoyama
6
2.6k
SwiftUIとGraphQLでプロダクトの継続的な破壊に立ち向かう
chocoyama
6
2.4k
Other Decks in Programming
See All in Programming
From Subtype Polymorphism To Typeclass-based Ad hoc Polymorphism- An Example
philipschwarz
PRO
0
170
Go言語でターミナルフレンドリーなAIコマンド、afaを作った/fukuokago20_afa
monochromegane
2
140
Universal Linksの実装方法と陥りがちな罠
kaitokudou
1
220
qmuntal/stateless のススメ
sgash708
0
120
Modern Angular: Renovation for Your Applications
manfredsteyer
PRO
0
210
Realtime API 入門
riofujimon
0
110
Vaporモードを大規模サービスに最速導入して学びを共有する
kazukishimamoto
4
4.3k
Googleのテストサイズを活用したテスト環境の構築
toms74209200
0
270
Dev ContainersとGitHub Codespacesの素敵な関係
ymd65536
1
130
Tuning GraphQL on Rails
pyama86
2
1k
CSC509 Lecture 08
javiergs
PRO
0
110
EventSourcingの理想と現実
wenas
6
2.1k
Featured
See All Featured
Building an army of robots
kneath
302
42k
Building Applications with DynamoDB
mza
90
6.1k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Writing Fast Ruby
sferik
626
61k
The Cost Of JavaScript in 2023
addyosmani
45
6.6k
Designing on Purpose - Digital PM Summit 2013
jponch
115
6.9k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
328
21k
A Philosophy of Restraint
colly
203
16k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
41
2.1k
Git: the NoSQL Database
bkeepers
PRO
425
64k
Optimizing for Happiness
mojombo
376
69k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
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͍ॴΛݟۃΊΔͱ͏·͘ػೳ͢Δ •
ʢཚ༻͗͢͠ΔͱٯʹΘ͔ΓͮΒ͘ͳΔҙʣ
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ ͖ͯ͢ͳϨγʔτҹϥΠϑΛʂ