Skip to content
Open
1 change: 1 addition & 0 deletions CTNotificationContent/CTNotificationViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ - (void)didReceiveNotification:(UNNotification *)notification {
break;
case CTNotificationContentTypeTimerTemplate: {
CTTimerTemplateController *contentController = [[CTTimerTemplateController alloc] init];
[contentController setNotificationDeliveryDate:notification.date];
[self setupContentController:contentController];
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Copy link
Copy Markdown
Contributor

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

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),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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)])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -210,15 +213,19 @@ import SDWebImage
}

func setupConstraints() {
let timerLabelWidth: CGFloat = thresholdSeconds >= 3600
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ enum Constraints {
static let kSubCaptionHeight: CGFloat = 20.0
static let kSubCaptionTopPadding: CGFloat = 8.0
static let kBottomPadding: CGFloat = 18.0
static let kCaptionLeftPadding: CGFloat = 10.0
static let kCaptionLeftPadding: CGFloat = 16.0
static let kCaptionTopPadding: CGFloat = 8.0
static let kImageBorderWidth: CGFloat = 1.0
static let kImageLayerBorderWidth: CGFloat = 0.4
static let kPageControlViewHeight: CGFloat = 20.0
static let kTimerLabelWidth: CGFloat = 100.0
static let kTimerLabelWidthWithHours: CGFloat = 130.0
static let kLandscapeMultiplier: CGFloat = 0.5625 // 16:9 in landscape
static let kPortraitMultiplier: CGFloat = 1.777 // 16:9 in portrait
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -54,6 +54,19 @@ import SDWebImage
bigImageView.translatesAutoresizingMaskIntoConstraints = false
return bigImageView
}()
private let scrimView: UIView = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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()
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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),
Expand Down