Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SwiftUIっぽくした話

B1702643adfb1c2216f6db6fab3e5073?s=47 たまねぎ
February 16, 2022

 SwiftUIっぽくした話

B1702643adfb1c2216f6db6fab3e5073?s=128

たまねぎ

February 16, 2022
Tweet

More Decks by たまねぎ

Other Decks in Programming

Transcript

  1. SwiftUIͬΆͨ͘͠࿩ ϥΫϚ x STORES LTΠϕϯτ ~ iOS։ൃͷཪଆ ~ @_chocoyama

  2. ࣗݾ঺հ • ͨ·Ͷ͗ʢ@_chocoyamaʣ • 2019೥12݄~ ϔΠגࣜձࣾ • STORES ϨδͷiOSΞϓϦ։ൃ

  3. ΞδΣϯμ 1. STORES Ϩδͱ͸ 2. Ϩγʔτͱҹ࡮ͷྲྀΕ 3. ϨγʔτϨΠΞ΢τ࣮૷ͷมભ 4. ;Γ͔͑Γ

  4. STORES Ϩδͱ͸ • 2021.06ʹϦϦʔε • ࣮ళฮۀ຿Λαϙʔτ͢ΔPOSΞϓϦ • ϑϧSwiftUI • ձܭɾ঎඼؅ཧɾϨγʔτҹ࡮

    etc…
  5. ϑϧSwiftUIʹͨ͠࿩ SwiftUIͬΆͨ͘͠࿩

  6. Ϩγʔτͱҹ࡮ͷྲྀΕ ձܭϨγʔτ ਫ਼ࢉϨγʔτ

  7. Ϩγʔτͱҹ࡮ͷྲྀΕ XML CALayer CGImage ϓϦϯλʔ ϨΠΞ΢τΛಈతʹఆٛ XMLΛύʔεͯ͠CALayerʹม׵ CALayerΛը૾σʔλԽ ը૾ͷόΠφϦσʔλΛBluetoothͰૹ৴

  8. Ϩγʔτͱҹ࡮ͷྲྀΕ XML CALayer CGImage ϓϦϯλʔ ϨΠΞ΢τΛಈతʹఆٛ XMLΛύʔεͯ͠CALayerʹม׵ CALayerΛը૾σʔλԽ ը૾ͷόΠφϦσʔλΛBluetoothͰૹ৴ ॳظஈ֊

    Ͳ͏SwiftUIͬΆ͘վળ͖͔ͯͨ͠
  9. ϨγʔτϨΠΞ΢τ࣮૷ͷมભ • ͬΆ͞Lv1ɿXMLϕλॻ͖Ͱͷ࣮૷ • ͬΆ͞Lv2ɿFlutterͬΆ͍IFͷϑϨʔϜϫʔΫ࡞੒ • ͬΆ͞Lv3ɿresultBuilderʹΑΔSwiftUIͬΆ͍IFͷఏڙ

  10. ಠࣗϧʔϧʹج͍ͮͨλά+ଐੑ ↓ Stringͷ݁߹ ↓ XMLจࣈྻΛ࡞੒ ͬΆ͘ͳ͍ʙʙʙ ͬΆ͞Lv1 : XMLϕλॻ͖Ͱͷ࣮૷ 9.-

  11. • ܕ҆શͰͳ͘ɺ૝ఆ֎ͷจࣈ͕͋ΔͱऴΘΔ • ίʔυͱΞ΢τϓοτͷߏ଄͕ඇରԠͰɺશମ૾͕ಡΈऔΓͮΒ͍ • ৑௕Ͱॏෳͨ͠هड़΋ଟ͍ • มߋʹऑ͍ XMLจࣈྻΛ௚઀ੜ੒͢Δ͜ͱͷ໰୊఺

  12. XML͸એݴత ↓ એݴతUI ↓ SwiftUI ↓ ϨγʔτUI΋SwiftUIͬΆ͘࡞ΕΔͷͰ͸ʁ Ͱ͸Ͳ͏͢Δ͔ʁ

  13. • SwiftUIͷΑ͏ʹγϯϓϧͰએݴతͳϨΠΞ΢τఆٛ • ܕͰݎ࿚ͯ͠ɺ޷͖์୊͔͚Δهड़Λഉআ • ΤσΟλͷิ׬ʹΑΓࣄલ஌ࣝͳ͠Ͱॻ͚ΔIF • ࠓޙͷཁૉ֦ுΛݟਾ͑ͯɺ௥Ճɾมߋ͠΍͍͢ → ܕ҆શͰXMLੜ੒Λந৅Խͨ͠IFΛఏڙ͢Δ

    վળํ਑
  14. ·͋·͋ ͬΆ͍ʙʙʙ ֤ཁૉ͝ͱʹΫϥεΛఆٛ ↓ ΠϯελϯεΛReceiptΫϥεʹ౉͢ ↓ ಺෦తʹXMLจࣈྻΛ࡞੒ ʢ௚઀XMLΛॻ͔ͳͯ͘ྑ͍ʣ ͬΆ͞Lv2 :

    FlutterͬΆ͍IFͷϑϨʔϜϫʔΫ࡞੒ 9.-
  15. Textͷ৔߹ • ߏ଄Λଊ͑΍͘͢ • ࢦఆՄೳύϥϝʔλΛܕͰݫ֨ʹ੍ޚ • ࣄલ஌ࣝͳ͠Ͱ΋ɺิ׬ʹΑΓબ୒Մೳͳ஋Λ೺Ѳ

  16. ۩ମతͳ࣮૷ ʮXMLλά1ͭʹ૬౰͢ΔจࣈྻΛੜ੒ʯ͢ΔIFΛఆٛ ଐੑ஋ΛؚΊͯλάจࣈྻΛੜ੒

  17. ۩ମతͳ࣮૷ ͢΂ͯͷจࣈྻΛ1ͭͷXMLʹ·ͱΊ্͛Δ

  18. ՝୊ ཁૉΛ഑ྻʹͯ͠౉͢ ↓ ࣜ΍੍ޚߏจΛ௚઀ॻ͚ͳ͍ ↓ ผΫϥεΛ࡞੒۪ͯ͠௚ʹରԠ

  19. • resultBuilderͰߋʹSwiftUIͬΆ͘ • ෼ذ΍܁Γฦ͠΋௚઀هड़Մೳʹ ͔ͳΓ ͬΆ͍ʙʙʙ ͬΆ͞Lv3 : resultBuilderʹΑΔSwiftUIͬΆ͍IFͷఏڙ 9.-

  20. resultBuilder • Swift5.4Ͱ௥Ճ͞ΕͨAttributeͰɺ಺෦DSLੜ੒ʹ׆༻Ͱ͖Δ 
 ʢSwiftUIͷViewBuilderʹ΋࢖ΘΕ͍ͯΔʣ • ؔ਺ͳͲʹద༻͢Δͱɺྻڍ஋Λऩूͯ͠࠷ऴతͳܕʹ·ͱΊΒΕΔ • ஋ͷྻڍʹΧϯϚ͕ඞཁͳ͘ɺࣜ΍੍ޚߏจ΋هड़Ͱ͖Δ •

    ϓϩτλΠϓͷ@_functionBuilderͰ͸ɺػೳ੍͕ݶ͞Ε͍ͯͨ ྻڍͨ͠஋ SFTVMU#VJMEFS ࠷ऴతͳ஋
  21. ୯७ͳ஋ͷྻڍ   < > CVJME#MPDL

  22. ෼ذ͕͋Δ৔߹  <><><><> CVJME&YQSFTTJPO <<> <>> < > CVJME#MPDL <

    > < > CVJME&JUIFS fi STU <<> <> < >> <   > CVJME#MPDL
  23. elseઅͷͳ͍෼ذ͕͋Δ৔߹  <> CVJME0QUJPOBM

  24. ϧʔϓ͕͋Δ৔߹ <<> <> <> <>> <   > CVJME"SSBZ

  25. ׬੒ʂ ड͚౉͞ΕΔ஋ͷύλʔϯʹԠͯ͡ɺରԠ͢Δbuildؔ਺Λ࣮૷ → ݁Ռͷܕʹม׵͍ͯ͘͠

  26. ϨγʔτϨΠΞ΢τ༻ͷ࣮૷ [ReceiptElement] ྻڍͨ͠஋ SFTVMU#VJMEFS ࠷ऴతͳ஋

  27. ࠷ऴܗ ͬΆ͘ͳͬͨʂ

  28. ࠷ऴܗ

  29. ;Γ͔͑Γ • ཧ૝ܗ͔Βߟ͑ͨͷ͕ྑ͔ͬͨ • ࣮ݱͷͨΊɺ஌Βͳ͍஌ࣝͷΠϯϓοτػձ͕ੜ·ΕΔ • ׬੒ܗ͕ελʔτ࣌఺Ͱݟ͍͑ͯΔͨΊɺઃܭʹϒϨ͕ੜ·Εͳ͍ • ಠࣗSDK͸࢖͍ॴΛݟۃΊΔͱ͏·͘ػೳ͢Δ •

    ʢཚ༻͗͢͠ΔͱٯʹΘ͔ΓͮΒ͘ͳΔ఺͸஫ҙʣ
  30. ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ ͖ͯ͢ͳϨγʔτҹ࡮ϥΠϑΛʂ