@@ -4,12 +4,10 @@ import Prelude
44import ReactiveExtensions
55import ReactiveSwift
66
7- public typealias PledgeShippingLocationViewData = (
8- project: Project ,
9- reward: Reward ,
10- showAmount: Bool ,
11- selectedLocationId: Int ?
12- )
7+ public struct PledgeShippingLocationViewData {
8+ let project : Project
9+ let selectedLocationId : Int ?
10+ }
1311
1412public protocol PledgeShippingLocationViewModelInputs {
1513 func configureWith( data: PledgeShippingLocationViewData )
@@ -21,8 +19,6 @@ public protocol PledgeShippingLocationViewModelInputs {
2119
2220public protocol PledgeShippingLocationViewModelOutputs {
2321 var adaptableStackViewIsHidden : Signal < Bool , Never > { get }
24- var amountAttributedText : Signal < NSAttributedString , Never > { get }
25- var amountLabelIsHidden : Signal < Bool , Never > { get }
2622 var dismissShippingRules : Signal < Void , Never > { get }
2723 var presentShippingRules : Signal < ( Project , [ ShippingRule ] , ShippingRule ) , Never > { get }
2824 var notifyDelegateOfSelectedShippingRule : Signal < ShippingRule , Never > { get }
@@ -47,17 +43,15 @@ public final class PledgeShippingLocationViewModel: PledgeShippingLocationViewMo
4743 . map ( first)
4844
4945 let project = configData
50- . map { $0. 0 }
51- let reward = configData
52- . map { $0. 1 }
46+ . map { $0. project }
5347 let selectedLocationId = configData
54- . map { $0. 3 }
48+ . map { $0. selectedLocationId }
5549
56- let shippingShouldBeginLoading = reward
50+ let shippingShouldBeginLoading = project
5751 . mapConst ( true )
5852
59- let shippingRulesEvent = Signal . zip ( project, reward )
60- . switchMap { project, _ -> SignalProducer < Signal < [ ShippingRule ] , ErrorEnvelope > . Event , Never > in
53+ let shippingRulesEvent = project
54+ . switchMap { project -> SignalProducer < Signal < [ ShippingRule ] , ErrorEnvelope > . Event , Never > in
6155 getShippingRulesForAllRewards ( in: project)
6256 }
6357
@@ -92,22 +86,13 @@ public final class PledgeShippingLocationViewModel: PledgeShippingLocationViewMo
9286 self . shippingRuleUpdatedSignal
9387 )
9488
95- let shippingAmount = Signal . merge (
96- self . notifyDelegateOfSelectedShippingRule. map { $0. cost } ,
97- configData. mapConst ( 0 )
98- )
99-
10089 self . presentShippingRules = Signal . combineLatest (
10190 project,
10291 shippingRulesEvent. values ( ) ,
10392 self . notifyDelegateOfSelectedShippingRule
10493 )
10594 . takeWhen ( self . shippingLocationButtonTappedSignal)
10695
107- self . amountAttributedText = Signal . combineLatest ( project, shippingAmount)
108- . map { project, shippingAmount in shippingValue ( of: project, with: shippingAmount) }
109- . skipNil ( )
110-
11196 self . shippingLocationButtonTitle = self . notifyDelegateOfSelectedShippingRule
11297 . map { $0. location. localizedName }
11398
@@ -117,8 +102,6 @@ public final class PledgeShippingLocationViewModel: PledgeShippingLocationViewMo
117102 . ignoreValues ( )
118103 . ksr_debounce ( . milliseconds( 300 ) , on: AppEnvironment . current. scheduler)
119104 )
120-
121- self . amountLabelIsHidden = configData. map { $0. 2 } . negate ( )
122105 }
123106
124107 private let configDataProperty = MutableProperty < PledgeShippingLocationViewData ? > ( nil )
@@ -148,8 +131,6 @@ public final class PledgeShippingLocationViewModel: PledgeShippingLocationViewMo
148131 }
149132
150133 public let adaptableStackViewIsHidden : Signal < Bool , Never >
151- public let amountAttributedText : Signal < NSAttributedString , Never >
152- public let amountLabelIsHidden : Signal < Bool , Never >
153134 public let dismissShippingRules : Signal < Void , Never >
154135 public let presentShippingRules : Signal < ( Project , [ ShippingRule ] , ShippingRule ) , Never >
155136 public let notifyDelegateOfSelectedShippingRule : Signal < ShippingRule , Never >
0 commit comments