-
Notifications
You must be signed in to change notification settings - Fork 6
SDK-5762: Push template UI improvements and timer state persistence #57
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
base: develop
Are you sure you want to change the base?
Changes from all commits
a7c2600
52d00c5
4adb47c
11036c1
0a1154d
956b053
b4b33f0
a578335
b315d57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -431,14 +431,13 @@ import SDWebImage | |
|
|
||
| func setupConstraints() { | ||
| NSLayoutConstraint.activate([ | ||
| titleLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 8), | ||
| titleLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: Constraints.kCaptionLeftPadding), | ||
| titleLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 16), | ||
| titleLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16), | ||
| titleLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -Constraints.kCaptionLeftPadding), | ||
| titleLabel.heightAnchor.constraint(equalToConstant: Constraints.kCaptionHeight), | ||
| titleLabel.bottomAnchor.constraint(equalTo: subTitleLabel.topAnchor, constant: -8), | ||
|
|
||
|
|
||
| subTitleLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 8), | ||
| subTitleLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: Constraints.kCaptionLeftPadding), | ||
| subTitleLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16), | ||
|
Contributor
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. can you try rendering with wrong image url and see if template looks fine? also test for case when rating is also not displayed along with wrong image url |
||
| subTitleLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -Constraints.kCaptionLeftPadding), | ||
| subTitleLabel.heightAnchor.constraint(equalToConstant: Constraints.kSubCaptionHeight)]) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,8 @@ import SDWebImage | |
| @objc public var templateCaption: String = "" | ||
| @objc public var templateSubcaption: String = "" | ||
| @objc public var deeplinkURL: String = "" | ||
|
|
||
| @objc public var notificationDeliveryDate: Date? | ||
|
|
||
| var bgColor: String = ConstantKeys.kDefaultColor | ||
| var captionColor: String = ConstantKeys.kHexBlackColor | ||
| var subcaptionColor: String = ConstantKeys.kHexLightGrayColor | ||
|
|
@@ -104,13 +105,15 @@ import SDWebImage | |
| return | ||
| } | ||
| if let threshold = jsonContent.pt_timer_threshold { | ||
| thresholdSeconds = threshold | ||
| } else { | ||
| if let endTime = jsonContent.pt_timer_end { | ||
| let date = NSDate() | ||
| let currentTime = date.timeIntervalSince1970 | ||
| thresholdSeconds = endTime - Int(currentTime) | ||
| if let deliveredAt = notificationDeliveryDate { | ||
| let elapsed = Int(Date().timeIntervalSince(deliveredAt)) | ||
| thresholdSeconds = max(0, threshold - elapsed) | ||
| } else { | ||
| thresholdSeconds = threshold | ||
| } | ||
| } else if let endTime = jsonContent.pt_timer_end { | ||
| let currentTime = Date().timeIntervalSince1970 | ||
| thresholdSeconds = endTime - Int(currentTime) | ||
| } | ||
|
|
||
| if let title = jsonContent.pt_title, !title.isEmpty { | ||
|
|
@@ -210,15 +213,19 @@ import SDWebImage | |
| } | ||
|
|
||
| func setupConstraints() { | ||
| let timerLabelWidth: CGFloat = thresholdSeconds >= 3600 | ||
|
Contributor
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. since we are updating constraints, check if we have long text in title and message, it goes behind the timer label, we should show ... at end before timer label. Also when timer comes below 3600, the width should decrease allowing more title texts |
||
| ? Constraints.kTimerLabelWidthWithHours | ||
| : Constraints.kTimerLabelWidth | ||
|
|
||
| NSLayoutConstraint.activate([ | ||
| captionLabel.topAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -(CTUtiltiy.getCaptionHeight() - Constraints.kCaptionTopPadding)), | ||
| captionLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: Constraints.kCaptionLeftPadding), | ||
| captionLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -Constraints.kTimerLabelWidth), | ||
| captionLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -timerLabelWidth), | ||
| captionLabel.heightAnchor.constraint(equalToConstant: Constraints.kCaptionHeight), | ||
|
|
||
| subcaptionLabel.topAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -(Constraints.kSubCaptionHeight + Constraints.kSubCaptionTopPadding)), | ||
| subcaptionLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: Constraints.kCaptionLeftPadding), | ||
| subcaptionLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -Constraints.kTimerLabelWidth), | ||
| subcaptionLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -timerLabelWidth), | ||
| subcaptionLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -Constraints.kSubCaptionTopPadding), | ||
| subcaptionLabel.heightAnchor.constraint(equalToConstant: Constraints.kSubCaptionHeight), | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,8 +16,8 @@ import SDWebImage | |
| @objc public var templateSubcaption: String = "" | ||
| @objc public var deeplinkURL: String = "" | ||
|
|
||
| var captionColor: String = ConstantKeys.kHexBlackColor | ||
| var subcaptionColor: String = ConstantKeys.kHexLightGrayColor | ||
| var captionColor: String = ConstantKeys.kHexWhiteColor | ||
|
Contributor
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. why have we changed caption color? If we need change, do we need to change dark color also? |
||
| var subcaptionColor: String = ConstantKeys.kHexWhiteColor | ||
|
|
||
| // Dark mode colors | ||
| var captionColorDark: String = ConstantKeys.kHexWhiteColor | ||
|
|
@@ -54,6 +54,19 @@ import SDWebImage | |
| bigImageView.translatesAutoresizingMaskIntoConstraints = false | ||
| return bigImageView | ||
| }() | ||
| private let scrimView: UIView = { | ||
|
Contributor
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. what should be expected scrimView UI? Do you have any reference screenshot or screenshot from Android?
Author
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. Yes I checked with Anush for android and added scrim for the lower 30% part of the view for better text clarity |
||
| let v = UIView() | ||
| v.translatesAutoresizingMaskIntoConstraints = false | ||
| v.isUserInteractionEnabled = false | ||
| return v | ||
| }() | ||
| private let scrimLayer: CAGradientLayer = { | ||
| let g = CAGradientLayer() | ||
| g.colors = [UIColor.clear.cgColor, UIColor.black.withAlphaComponent(0.65).cgColor] | ||
| g.startPoint = CGPoint(x: 0.5, y: 0) | ||
| g.endPoint = CGPoint(x: 0.5, y: 1) | ||
| return g | ||
| }() | ||
|
|
||
| @objc public override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
@@ -100,6 +113,8 @@ import SDWebImage | |
| func createView() { | ||
| createFrameWithoutImage() | ||
| contentView.addSubview(bigImageView) | ||
| contentView.addSubview(scrimView) | ||
| scrimView.layer.addSublayer(scrimLayer) | ||
| contentView.addSubview(subTitleLabel) | ||
| contentView.addSubview(titleLabel) | ||
|
|
||
|
|
@@ -161,8 +176,18 @@ import SDWebImage | |
|
|
||
| } | ||
|
|
||
| public override func viewDidLayoutSubviews() { | ||
| super.viewDidLayoutSubviews() | ||
| scrimLayer.frame = scrimView.bounds | ||
| } | ||
|
|
||
| func setupConstraints() { | ||
| NSLayoutConstraint.activate([ | ||
| scrimView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), | ||
| scrimView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), | ||
| scrimView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), | ||
| scrimView.heightAnchor.constraint(equalTo: contentView.heightAnchor, multiplier: 0.3), | ||
|
|
||
| titleLabel.topAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -(CTUtiltiy.getCaptionHeight() - Constraints.kCaptionTopPadding)), | ||
| titleLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: Constraints.kCaptionLeftPadding), | ||
| titleLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -Constraints.kCaptionLeftPadding), | ||
|
|
||
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.
use constant here and other places