Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MBL-1207] Pledge Button on Project Page #1951

Merged
merged 6 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions Library/RewardCellProjectBackingStateType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public enum RewardCellProjectBackingStateType: Equatable {
public enum ProjectState {
case nonLive
case live
case successful
scottkicks marked this conversation as resolved.
Show resolved Hide resolved
}

case backedError
Expand All @@ -13,6 +14,11 @@ public enum RewardCellProjectBackingStateType: Equatable {

static func state(with project: Project) -> RewardCellProjectBackingStateType {
guard let backing = project.personalization.backing else {
if featurePostCampaignPledgeEnabled(), project.postCampaignPledgingEnabled,
project.isInPostCampaignPledgingPhase {
scottkicks marked this conversation as resolved.
Show resolved Hide resolved
return (.nonBacked(live: .successful))
}

return .nonBacked(live: project.state == .live ? .live : .nonLive)
}

Expand Down
9 changes: 9 additions & 0 deletions Library/SharedFunctions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,15 @@ public func rewardsCarouselCanNavigateToReward(_ reward: Reward, in project: Pro
let isAvailableForNewBacker = rewardIsAvailable(project: project, reward: reward) && !isBacking
let isAvailableForExistingBackerToEdit = (isBacking && reward.hasAddOns)

if featurePostCampaignPledgeEnabled(), project.postCampaignPledgingEnabled,
project.isInPostCampaignPledgingPhase {
return [
project.state == .successful,
isAvailableForNewBacker || isAvailableForExistingBackerToEdit
scottkicks marked this conversation as resolved.
Show resolved Hide resolved
]
.allSatisfy(isTrue)
}

return [
project.state == .live,
isAvailableForNewBacker || isAvailableForExistingBackerToEdit
Expand Down
5 changes: 5 additions & 0 deletions Library/ViewModels/PledgeCTAContainerViewViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ private func pledgeCTA(project: Project, backing: Backing?) -> PledgeStateCTATyp
return PledgeStateCTAType.viewYourRewards
}

if featurePostCampaignPledgeEnabled(), project.postCampaignPledgingEnabled,
project.isInPostCampaignPledgingPhase {
scottkicks marked this conversation as resolved.
Show resolved Hide resolved
return PledgeStateCTAType.pledge
}

return project.state == .live ? PledgeStateCTAType.pledge : PledgeStateCTAType.viewRewards
}

Expand Down
6 changes: 5 additions & 1 deletion Library/ViewModels/RewardCardContainerViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ private func pledgeButtonTitle(project: Project, reward: Reward) -> String? {
case (.nonBacked(.live), _, true):
return Strings.Select()
case (.backed(.nonLive), false, _),
(.nonBacked(.nonLive), _, _):
(.nonBacked(.nonLive), _, _), (.backed(live: .successful), _, _):
scottkicks marked this conversation as resolved.
Show resolved Hide resolved
return nil
case (_, _, false):
return Strings.No_longer_available()
case (.nonBacked(.successful), _, _):
return Strings.Select()
}
}

Expand Down Expand Up @@ -146,6 +148,8 @@ private func buttonStyleType(project: Project, reward: Reward) -> ButtonStyleTyp
return .none
case .nonBacked(.nonLive):
return .none
case .nonBacked(live: .successful), .backed(live: .successful):
scottkicks marked this conversation as resolved.
Show resolved Hide resolved
return .green
}

return .green
Expand Down