Skip to content

Commit

Permalink
Merge branch 'main' into release-5.20.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ifosli committed Oct 17, 2024
2 parents ad99ab4 + 7184ab9 commit 973892c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,10 @@ final class WithShippingRewardsCollectionViewController: UICollectionViewControl

self.viewModel.outputs.rewardsCollectionViewIsHidden
.observeForUI()
.observeValues { [weak self] shimmerLoadingViewIsHidden in
.observeValues { [weak self] rewardsCollectionViewIsHidden in
guard let self else { return }

self.collectionView.isHidden = !shimmerLoadingViewIsHidden
self.collectionView.layoutIfNeeded()
self.collectionView.isHidden = rewardsCollectionViewIsHidden
}

self.viewModel.outputs.rewardsCollectionViewFooterIsHidden
Expand Down
7 changes: 6 additions & 1 deletion Library/ViewModels/NoShippingPledgeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public class NoShippingPledgeViewModel: NoShippingPledgeViewModelType, NoShippin
context.map { $0.confirmationLabelHidden }
)

let shippingSummaryViewData = Signal.combineLatest(
let shippingSummaryViewDataNonnil = Signal.combineLatest(
selectedShippingRule.skipNil().map(\.location.localizedName),
project.map(\.stats.omitUSCurrencyCode),
project.map { project in
Expand All @@ -252,6 +252,11 @@ public class NoShippingPledgeViewModel: NoShippingPledgeViewModelType, NoShippin
)
.map(PledgeShippingSummaryViewData.init)

let shippingSummaryViewData = Signal.merge(
shippingSummaryViewDataNonnil.wrapInOptional(),
selectedShippingRule.filter(isNil).mapConst(nil)
)

self.configurePledgeRewardsSummaryViewWithData = Signal.combineLatest(
initialData,
pledgeTotal,
Expand Down
29 changes: 13 additions & 16 deletions Library/ViewModels/WithShippingRewardsCollectionViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,14 @@ public final class WithShippingRewardsCollectionViewModel: WithShippingRewardsCo

// MARK: Shipping Location

self.shippingLocationViewHidden = project
.map { project in
projectHasShippableRewards(project) == false
}
let hasShippableRewards = project.map(projectHasShippableRewards)

self.shippingLocationViewHidden = hasShippableRewards.map(negate)

// Only shown for regular non-add-ons based rewards
self.configureShippingLocationViewWithData = Signal.combineLatest(
project,
self.shippingLocationViewHidden.filter(isFalse)
hasShippableRewards.filter(isTrue)
)
.map { project, _ in
// TODO: Reward will be removed from ShippingLocationViewData once we remove the selector from Add-Ons
Expand Down Expand Up @@ -210,9 +209,16 @@ public final class WithShippingRewardsCollectionViewModel: WithShippingRewardsCo
)

/// Temporary loading state solution. Proper designs will be explored in this ticket [mbl-1678](https://kickstarter.atlassian.net/browse/MBL-1678)
self.rewardsCollectionViewIsHidden = self.pledgeShippingLocationViewControllerDidUpdateProperty.signal
let locationShimmerHidden = self.pledgeShippingLocationViewControllerDidUpdateProperty.signal
.map { $0 }

// Rewards collection view should only be hidden while the location shimmer is showing.
// If the project doesn't have shippable rewards, show immediately.
self.rewardsCollectionViewIsHidden = Signal.merge(
locationShimmerHidden.negate(),
hasShippableRewards.filter(isFalse).mapConst(false)
)

self.rewardsCollectionViewFooterIsHidden = self.traitCollectionChangedProperty.signal
.skipNil()
.map { isFalse($0.verticalSizeClass == .regular) }
Expand Down Expand Up @@ -476,19 +482,10 @@ private func filteredRewardsByLocation(
let isUnrestrictedShippingReward = reward.isUnRestrictedShippingPreference
let isRestrictedShippingReward = reward.isRestrictedShippingPreference

// return all rewards that are no reward, digital, or ship anywhere in the world.
// Return all rewards that are no reward, digital, local pickup, or ship anywhere in the world.
if rewards.first?.id == reward.id || isRewardLocalOrDigital || isUnrestrictedShippingReward {
shouldDisplayReward = true

// if add on is local pickup, ensure locations are equal.
if isRewardLocalPickup(reward) {
if let rewardLocation = reward.localPickup?.country,
let shippingRuleLocation = shippingRule?.location.country, rewardLocation == shippingRuleLocation {
shouldDisplayReward = true
} else {
shouldDisplayReward = false
}
}
// If restricted shipping, compare against selected shipping location.
} else if isRestrictedShippingReward {
shouldDisplayReward = rewardShipsTo(selectedLocation: shippingRule?.location.id, reward)
Expand Down

0 comments on commit 973892c

Please sign in to comment.