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

チームでSwiftUIを書くために / After Party iOSDC Japan 202...

チームでSwiftUIを書くために / After Party iOSDC Japan 2021 SwiftUI

2021/10/1に開催されたAfter Party iOSDC Japan 2021の登壇資料です

Atsuya Sato

October 01, 2021
Tweet

More Decks by Atsuya Sato

Other Decks in Technology

Transcript

  1. ࠤ౻ ರ໵ (͋ͭ΍) @n_atmark • iOS / Android ΤϯδχΞ •

    ݱࡏ͸ΫοΫύουAndroidΞϓϦͷʮ͔͍΋ͷʯλϒΛӶҙ։ൃத 2019/04 2021/01 • ΫοΫύου৽ଔೖࣾ • ങ෺ࣄۀຊ෦ ങ෺ϓϩμΫτ։ൃ෦ • ΫοΫύουϚʔτͷྲྀ௨޲͚ͷαʔϏε։ൃɺϋʔυ΢ΣΞ։ൃͳͲʹैࣄ • ΫοΫύουࣄۀຊ෦ ങ෺αʔϏε։ൃ෦ • ΫοΫύουiOSΞϓϦͷʮ͔͍΋ͷʯλϒͷ։ൃʹैࣄ
  2. ΞδΣϯμ • എܠ • ։ൃ͍ͯ͠ΔϓϩμΫτͷ঺հ • νʔϜ΍ϓϩμΫτͷن໛ײ • SwiftUIΛ༻͍ͯ1೥ؒ։ൃͯ͠Έͯ •

    ಡΈ΍ͯ͘͢อक͠΍͍͢ઃܭʹ͍ͭͯߟ͑ͨࣄ • ౷Ұͨ͠ॻ͖ํͰϨΠΞ΢τΛઃܭ͢ΔͨΊʹ • ෳࡶɾଟ༷ͳ৚݅ʹରॲ͢Δ • ྑ͍ઃܭ΁ͷҙࣝΛνʔϜ΁ਁಁ͢ΔͨΊʹ • ·ͱΊ
  3. ΞϓϦΛϦϦʔε͔ͯ͠Β1೥։ൃ͍ͯ͘͠தͰͷมԽ • ίʔυϕʔεͷڊେԽ • Feature ModuleͷதͰ͸ίʔυߦ਺΋VIPERγʔϯ਺΋࠷େʹ • iOS 14ɾiOS 15ͷϦϦʔε

    • iOS 13ɺ14ɺ15ͷ3όʔδϣϯαϙʔτʹ • νʔϜͷ֦େ • ϝΠϯͰ։ൃ͢ΔΤϯδχΞ΋૿͑ͨ • Πϯλʔϯੜ΋ܞΘΔΑ͏ʹ
  4. ϨΠΞ΢τ૊Έʹؔͯ͠ struct KaimonoCartView: View { var body: some View {

    ScrollView { orderDeliverySection cartPriceSection pickupNameSettingSection deliveryInformationSection pickupStepsSection } } }
  5. ෳࡶɾଟ༷ͳ৚݅ʹରॲ͢Δ struct KaimonoDeliveryDetailView: View { var body: some View {

    ScrollView { switch dataSource.delivery.deliveryStatus { case .accepting: headerSection pickupNameSection orderedProductsSection if shouldShowPickupGuide { pickupGuideSection } // Sectionͷτϧπϝ acceptedButtonSection ordersSection case .preparing: // ུ } } } }
  6. ਖ਼֬ʹಈ࡞ͤ͞ΔͨΊͷऔΓ૊Έ extension SandboxScene { static let kaimonoTopForJustSetupCompleted = SandboxScene(sceneName: "τοϓʢडऔ৔ॴઃఆࡁɾະ஫จʣ")

    { initializer in let environment = StubbableEnvironment() initializer.initialize(environment) environment.registerClientResponses(fixtures, overrideFixtures: [ .orders(.empty), .userOrderedDeliveries(.empty), ]) ɹ let viewController = KaimonoTopViewBuilder.build(environment: environment) return viewController } static let kaimonoTopForDeliveriesUnavailable = SandboxScene(sceneName: "τοϓʢ௚ۙͷ഑ૹͳ͠ʣ") { initializer in // ུ } } private let fixtures: [Fixture] = [ .cart(.normal), .promotedDeliveryProducts(.ordinary), .me(.userLocation), .feature(.popularProducts), // ུ ]
  7. ਖ਼֬ʹಈ࡞ͤ͞ΔͨΊͷऔΓ૊Έ private let fixtures: [Fixture] = [ .cart(.normal), .promotedDeliveryProducts(.ordinary), .me(.userLocation),

    .feature(.popularProducts), // ུ ] environment.registerClientResponses(fixtures, overrideFixtures: [ .orders(.empty), .userOrderedDeliveries(.empty), ]) • ը໘දࣔʹඞཁͳϨεϙϯεελϒΛFixtureԽ • ϕʔεͷFixtureͱɺ৚݅͝ͱͷoverrideFixturesΛ༻ҙ • ϛχΞϓϦͷ৚݅͝ͱͷը໘දࣔΛ؆୯ʹఆٛͰ͖ΔΑ͏ʹ
  8. ·ͱΊ • ౷Ұͨ͠ॻ͖ํͰϨΠΞ΢τΛઃܭ͢ΔͨΊʹ • ϨΠΞ΢τઃܭΛ౷ҰԽ • ίϯϙʔωϯτԽͷཻ౓Λ໌֬ʹ • ෳࡶɾଟ༷ͳ৚݅ʹରॲ͢Δ •

    ը໘ϨΠΞ΢τͷઃܭਤͱͯ͠RootViewͷbodyΛར༻ • ಈ࡞֬ೝͷͨΊʹϛχΞϓϦΛ׆༻ • ྑ͍ઃܭ΁ͷҙࣝΛνʔϜ΁ਁಁ͢ΔͨΊʹ • ఆظతʹઃܭʹ͍ͭͯٞ࿦͢Δ৔Λઃ͚Δ • υΩϡϝϯτԽ͢Δ͜ͱʹΑͬͯڞ௨ೝࣝΛऔΔ