-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[NT-730] Pledge screen header #1033
Changes from 10 commits
e5bc6b0
90a5ac2
22e467b
190d31a
b841324
645fd46
62f1211
cfc3c55
c70b0bd
1423dbe
d242773
45a2774
bd88fdc
965adc9
19b2259
eabf393
1b8c91d
22a9555
e18be1c
c73910c
0e2c13a
0216735
9dc6c53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Foundation | ||
|
||
public extension NSAttributedString { | ||
func setAsLink(textToFind: String, linkURL: String) -> NSAttributedString { | ||
let string = NSMutableAttributedString(attributedString: self) | ||
let foundRange = string.mutableString.range(of: textToFind) | ||
if foundRange.location != NSNotFound { | ||
string.addAttribute(.link, value: linkURL, range: foundRange) | ||
return string | ||
} | ||
return self | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@testable import Library | ||
import XCTest | ||
|
||
final class NSAttributedString_LinkTests: TestCase { | ||
func testAttributedLink() { | ||
let string = "My special string with " | ||
let linkString = "link" | ||
|
||
let fullString = string + linkString | ||
|
||
let attributed = NSAttributedString(string: fullString) | ||
.setAsLink(textToFind: linkString, linkURL: "https://ksr.com") | ||
|
||
let linkRange = (fullString as NSString).range(of: linkString) | ||
|
||
let linkAttributes = attributed.attributes( | ||
at: linkRange.location, | ||
longestEffectiveRange: nil, | ||
in: linkRange | ||
) | ||
|
||
XCTAssertEqual(linkAttributes[NSAttributedString.Key.link] as? String, "https://ksr.com") | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,11 @@ public protocol PledgeDescriptionViewModelInputs { | |
} | ||
|
||
public protocol PledgeDescriptionViewModelOutputs { | ||
var configureRewardCardViewWithData: Signal<(Project, Either<Reward, Backing>), Never> { get } | ||
var estimatedDeliveryStackViewIsHidden: Signal<Bool, Never> { get } | ||
var estimatedDeliveryText: Signal<String, Never> { get } | ||
var popViewController: Signal<(), Never> { get } | ||
var presentTrustAndSafety: Signal<Void, Never> { get } | ||
var rewardTitle: Signal<String, Never> { get } | ||
} | ||
|
||
public protocol PledgeDescriptionViewModelType { | ||
|
@@ -32,10 +33,16 @@ public final class PledgeDescriptionViewModel: PledgeDescriptionViewModelType, | |
.skipNil() | ||
.map { Format.date(secondsInUTC: $0, template: DateFormatter.monthYear, timeZone: UTCTimeZone) } | ||
|
||
self.estimatedDeliveryStackViewIsHidden = self.configDataProperty.signal | ||
.skipNil() | ||
.map(second) | ||
.map { $0.shipping.enabled } | ||
.negate() | ||
|
||
self.presentTrustAndSafety = self.learnMoreTappedProperty.signal | ||
self.configureRewardCardViewWithData = self.configDataProperty.signal | ||
self.rewardTitle = self.configDataProperty.signal | ||
.skipNil() | ||
.map { project, reward in (project, .init(left: reward)) } | ||
.map { _, reward in reward.title ?? Strings.Back_it_because_you_believe_in_it() } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make sense to check if title is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
||
self.popViewController = self.rewardCardTappedSignal | ||
} | ||
|
@@ -55,10 +62,11 @@ public final class PledgeDescriptionViewModel: PledgeDescriptionViewModelType, | |
self.rewardCardTappedObserver.send(value: ()) | ||
} | ||
|
||
public let configureRewardCardViewWithData: Signal<(Project, Either<Reward, Backing>), Never> | ||
public let estimatedDeliveryStackViewIsHidden: Signal<Bool, Never> | ||
public let estimatedDeliveryText: Signal<String, Never> | ||
public let popViewController: Signal<(), Never> | ||
public let presentTrustAndSafety: Signal<Void, Never> | ||
public let rewardTitle: Signal<String, Never> | ||
|
||
public var inputs: PledgeDescriptionViewModelInputs { return self } | ||
public var outputs: PledgeDescriptionViewModelOutputs { return self } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of deleting all of this code, I decided to keep this structure here since we discussed in standup that we may revisit the custom animation in an Investment Day.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought I think we should remove the animation, I think it's unlikely we'll make it work with this new layout.