Skip to content

Commit

Permalink
[WEB-983] Prelaunch Page Existing Project Page UI (#1797)
Browse files Browse the repository at this point in the history
* fixed redirect of prelaunch projects to safari now they will open in app

* let the optional dates through the guard check on GQL fragment.

* corrected test

* don't display more than base navigation tabs if displaying a prelaunch project.

* hiding nav selection, comments, updates and stats view on project page when it is prelaunch

* adding coming soon label

* Update to Strings

* Strings related update.

* Updated coming soon label display logic

* updated pledge states to include prelaunch (unsaved)

* adds state for prelaunch cta and corrected an issue with hiding the pledge button.

* fix minor glitch with showing followers under pledge button

* fixed pre-existing project page bug on orientation change where campaign tab was showing images if they were downloaded before the user went to campaign tab.

* removed some default values that were getting reset during orientation change.

* formatting

* accidentally removed the package resolved.

* added watchesCount to ProjectFragment

* added update to watchesCount

* watchprojectviewmodel reflect in pledge cta accurately.

* working prelaunch pages cta with watch project in navigation bar.

* fixed a weird issue with spacing after cancelling pledge on pledge cta with backing.

* corrected existing tests.

* project page prelaunch state snapshot tests

* added view model tests

* missed name change on vc
  • Loading branch information
msadoon committed Mar 22, 2023
1 parent f78b71c commit 284ef75
Show file tree
Hide file tree
Showing 75 changed files with 1,342 additions and 189 deletions.
7 changes: 2 additions & 5 deletions Kickstarter-iOS/AppDelegateViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,7 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi
let resolvedRedirectUrl = deepLinkUrl
.filter { Navigation.deepLinkMatch($0) == nil }

self.goToMobileSafari = Signal.merge(
resolvedRedirectUrl,
Signal.zip(deepLinkUrl, projectPreviewLink).map(first)
)
self.goToMobileSafari = resolvedRedirectUrl

self.goToDashboard = deepLink
.map { link -> Param?? in
Expand All @@ -598,7 +595,7 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi
}
.skipNil()

let projectRootLink = projectLink
let projectRootLink = Signal.merge(projectLink, projectPreviewLink)
.filter { _, subpage, _, _ in subpage == .root }
.map { _, _, vcs, _ in vcs }

Expand Down
4 changes: 2 additions & 2 deletions Kickstarter-iOS/AppDelegateViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,8 @@ final class AppDelegateViewModelTests: TestCase {
)
XCTAssertTrue(result)

self.presentViewController.assertValues([])
XCTAssertEqual(self.goToMobileSafari.values.map { $0.absoluteString }, [projectUrl])
self.presentViewController.assertValues([1])
self.goToMobileSafari.assertValues([])
}
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ -299,6 +299,12 @@ public final class ProjectPageViewController: UIViewController, MessageBannerVie
defaultNavigationBarView.scrollEdgeAppearance?.shadowColor = .ksr_white
}

self.viewModel.outputs.updateWatchProjectWithPrelaunchProjectState
.observeForUI()
.observeValues { [weak self] prelaunchState in
self?.navigationDelegate?.configureSaveWatchPrelaunchProject(with: prelaunchState)
}

self.viewModel.outputs.goToRewards
.observeForControllerAction()
.observeValues { [weak self] params in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,6 @@ internal final class ProjectPageViewControllerTests: TestCase {
}
}

// MARK: - Logged Out

func testLoggedIn_NonBacker_NonLiveProject() {
let config = Config.template
let project = Project.cosmicSurgery
Expand Down Expand Up @@ -719,6 +717,92 @@ internal final class ProjectPageViewControllerTests: TestCase {
}
}

func testLoggedIn_NonBacker_PrelaunchProject_Unsaved_ShowsUnsavedPledgeCTAWithFollowers_Success() {
let config = Config.template
let project = Project.cosmicSurgery
|> Project.lens.displayPrelaunch .~ true
|> Project.lens.personalization.isStarred .~ false
|> Project.lens.watchesCount .~ 10
|> Project.lens.photo.full .~ ""
|> (Project.lens.creator.avatar .. User.Avatar.lens.small) .~ ""
|> Project.lens.personalization.isBacking .~ false
|> Project.lens.state .~ .successful
|> Project.lens.stats.convertedPledgedAmount .~ 29_236
|> Project.lens.rewardData.rewards .~ []
|> \.extendedProjectProperties .~ self.extendedProjectProperties

let projectPamphletData = Project.ProjectPamphletData(project: project, backingId: nil)

let mockService = MockService(
fetchProjectPamphletResult: .success(projectPamphletData)
)

combos(Language.allLanguages, [Device.phone4inch, Device.pad]).forEach { language, device in
withEnvironment(
apiService: mockService,
config: config, currentUser: .template, language: language
) {
let vc = ProjectPageViewController.configuredWith(
projectOrParam: .left(project), refTag: nil
)

let (parent, _) = traitControllers(device: device, orientation: .portrait, child: vc)
parent.view.frame.size.height = device == .pad ? 1_200 : parent.view.frame.size.height

scheduler.run()

assertSnapshot(
matching: parent.view,
as: .image(perceptualPrecision: 0.98),
named: "lang_\(language)_device_\(device)"
)
}
}
}

func testLoggedIn_NonBacker_PrelaunchProject_Saved_ShowsSavedPledgeCTAWithFollowers_Success() {
let config = Config.template
let project = Project.cosmicSurgery
|> Project.lens.displayPrelaunch .~ true
|> Project.lens.personalization.isStarred .~ true
|> Project.lens.watchesCount .~ 10
|> Project.lens.photo.full .~ ""
|> (Project.lens.creator.avatar .. User.Avatar.lens.small) .~ ""
|> Project.lens.personalization.isBacking .~ false
|> Project.lens.state .~ .successful
|> Project.lens.stats.convertedPledgedAmount .~ 29_236
|> Project.lens.rewardData.rewards .~ []
|> \.extendedProjectProperties .~ self.extendedProjectProperties

let projectPamphletData = Project.ProjectPamphletData(project: project, backingId: nil)

let mockService = MockService(
fetchProjectPamphletResult: .success(projectPamphletData)
)

combos(Language.allLanguages, [Device.phone4inch, Device.pad]).forEach { language, device in
withEnvironment(
apiService: mockService,
config: config, currentUser: .template, language: language
) {
let vc = ProjectPageViewController.configuredWith(
projectOrParam: .left(project), refTag: nil
)

let (parent, _) = traitControllers(device: device, orientation: .portrait, child: vc)
parent.view.frame.size.height = device == .pad ? 1_200 : parent.view.frame.size.height

scheduler.run()

assertSnapshot(
matching: parent.view,
as: .image(perceptualPrecision: 0.98),
named: "lang_\(language)_device_\(device)"
)
}
}
}

// MARK: - Logged Out

func testLoggedOut_NonBacker_LiveProject_ShowEnvironmentalCommitments_Success() {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ -77,6 +77,9 @@ internal final class ProjectPageViewControllerDataSource: ValueCellDataSource {
inSection: Section.overview.rawValue
)

guard let displayPrelaunch = project.displayPrelaunch,
!displayPrelaunch else { return }

let values: [ProjectPamphletSubpage] = [
.comments(project.stats.commentsCount as Int?, .first),
.updates(project.stats.updatesCount as Int?, .last)
Expand Down Expand Up @@ -447,22 +450,14 @@ internal final class ProjectPageViewControllerDataSource: ValueCellDataSource {
}

internal func preloadCampaignImageViewElement(_ element: ImageViewElement, image: UIImage) {
self.appendRow(
value: (element, image),
cellClass: ImageViewElementCell.self,
toSection: Section.campaign.rawValue
)
self.preexistingImageViewElementsWithData.append((element, image))
}

internal func preloadCampaignAudioVideoViewElement(
_ element: AudioVideoViewElement,
player: AVPlayer,
image: UIImage?
) {
self.appendRow(
value: (element, player, image),
cellClass: AudioVideoViewElementCell.self,
toSection: Section.campaign.rawValue
)
self.preexistingAudioVideoViewElementsWithPlayer.append((element, player, image))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ final class ProjectPageViewControllerDataSourceTests: XCTestCase {

func testOverview() {
let project = Project.template
|> \.displayPrelaunch .~ false
|> \.extendedProjectProperties .~ ExtendedProjectProperties(
environmentalCommitments: [],
faqs: [],
Expand Down Expand Up @@ -565,6 +566,7 @@ final class ProjectPageViewControllerDataSourceTests: XCTestCase {

func testIndexPathIsCommentsSubpage() {
let project = Project.template
|> \.displayPrelaunch .~ false
|> \.extendedProjectProperties .~ ExtendedProjectProperties(
environmentalCommitments: [],
faqs: [],
Expand All @@ -588,6 +590,7 @@ final class ProjectPageViewControllerDataSourceTests: XCTestCase {

func testIndexPathIsUpdatesSubpage() {
let project = Project.template
|> \.displayPrelaunch .~ false
|> \.extendedProjectProperties .~ ExtendedProjectProperties(
environmentalCommitments: [],
faqs: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -284,6 +284,9 @@
<connections>
<outlet property="backersSubtitleLabel" destination="m5H-g2-PFw" id="fBh-Ou-3d9"/>
<outlet property="backersTitleLabel" destination="ZjE-DZ-Nid" id="ACD-Jv-eGq"/>
<outlet property="backingContainerView" destination="dDT-Li-H3h" id="9b8-Z1-hBK"/>
<outlet property="backingContainerViewLeadingConstraint" destination="d5a-qT-ewn" id="JZa-cF-Xoi"/>
<outlet property="backingLabel" destination="ntT-LN-gwV" id="Zxw-pe-fwR"/>
<outlet property="blurbAndReadMoreStackView" destination="CTC-V4-a6E" id="ZtT-Zz-Yzd"/>
<outlet property="blurbStackView" destination="N5v-Sa-W2B" id="dE2-PS-Kz9"/>
<outlet property="categoryAndLocationStackView" destination="Nk9-Fp-QSS" id="11G-bt-8PF"/>
Expand Down Expand Up @@ -314,9 +317,6 @@
<outlet property="readMoreStackView" destination="qVW-hB-5Kd" id="NRS-Nx-Jzr"/>
<outlet property="stateLabel" destination="t7N-l1-eTw" id="hK2-re-L6h"/>
<outlet property="statsStackView" destination="ZTt-dn-nNA" id="BvW-Qy-Yhg"/>
<outlet property="youreABackerContainerView" destination="dDT-Li-H3h" id="o6m-co-Hyc"/>
<outlet property="youreABackerContainerViewLeadingConstraint" destination="d5a-qT-ewn" id="6e1-1j-u0y"/>
<outlet property="youreABackerLabel" destination="ntT-LN-gwV" id="nk8-O9-s6v"/>
</connections>
<point key="canvasLocation" x="-155" y="65"/>
</tableViewCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ internal final class ProjectPamphletMainCell: UITableViewCell, ValueCell {
@IBOutlet fileprivate var readMoreStackView: UIStackView!
@IBOutlet fileprivate var stateLabel: UILabel!
@IBOutlet fileprivate var statsStackView: UIStackView!
@IBOutlet fileprivate var youreABackerContainerView: UIView!
@IBOutlet fileprivate var youreABackerContainerViewLeadingConstraint: NSLayoutConstraint!
@IBOutlet fileprivate var youreABackerLabel: UILabel!
@IBOutlet fileprivate var backingContainerView: UIView!
@IBOutlet fileprivate var backingContainerViewLeadingConstraint: NSLayoutConstraint!
@IBOutlet fileprivate var backingLabel: UILabel!

internal override func awakeFromNib() {
super.awakeFromNib()
Expand Down Expand Up @@ -250,18 +250,17 @@ internal final class ProjectPamphletMainCell: UITableViewCell, ValueCell {
|> UIStackView.lens.isAccessibilityElement .~ true
|> UIStackView.lens.backgroundColor .~ .ksr_white

_ = self.youreABackerContainerViewLeadingConstraint
_ = self.backingContainerViewLeadingConstraint
|> \.constant .~ leftRightInsetValue

_ = self.youreABackerContainerView
_ = self.backingContainerView
|> roundedStyle(cornerRadius: 2)
|> UIView.lens.backgroundColor .~ .ksr_create_700
|> UIView.lens.layoutMargins .~ .init(topBottom: Styles.grid(1), leftRight: Styles.gridHalf(3))

_ = self.youreABackerLabel
_ = self.backingLabel
|> UILabel.lens.textColor .~ .ksr_white
|> UILabel.lens.font .~ .ksr_headline(size: 12)
|> UILabel.lens.text %~ { _ in Strings.Youre_a_backer() }

_ = self.readMoreButton
|> readMoreButtonStyle
Expand Down Expand Up @@ -296,7 +295,9 @@ internal final class ProjectPamphletMainCell: UITableViewCell, ValueCell {
self.stateLabel.rac.textColor = self.viewModel.outputs.projectStateLabelTextColor
self.stateLabel.rac.hidden = self.viewModel.outputs.stateLabelHidden
self.statsStackView.rac.accessibilityLabel = self.viewModel.outputs.statsStackViewAccessibilityLabel
self.youreABackerContainerView.rac.hidden = self.viewModel.outputs.youreABackerLabelHidden
self.backingContainerView.rac.hidden = self.viewModel.outputs.backingLabelHidden
self.progressBarAndStatsStackView.rac.hidden = self.viewModel.outputs.isPrelaunchProject
self.backingLabel.rac.text = self.viewModel.outputs.prelaunchProjectBackingText

self.viewModel.outputs.configureVideoPlayerController
.observeForUI()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Prelude
import UIKit

protocol ProjectPageNavigationBarViewDelegate: AnyObject {
func configureSaveWatchPrelaunchProject(with: PledgeCTAPrelaunchState)
func configureSharing(with context: ShareContext)
func configureWatchProject(with context: WatchProjectValue)
func viewDidLoad()
Expand Down Expand Up @@ -264,4 +265,8 @@ extension ProjectPageNavigationBarView: ProjectPageNavigationBarViewDelegate {
self.watchProjectViewModel.inputs
.configure(with: context)
}

func configureSaveWatchPrelaunchProject(with context: PledgeCTAPrelaunchState) {
self.watchProjectViewModel.inputs.saveButtonTapped(selected: context.saved)
}
}
Loading

0 comments on commit 284ef75

Please sign in to comment.