From e11a4f71f9f64c83003da8d6face44807140a453 Mon Sep 17 00:00:00 2001 From: marijnschilling Date: Wed, 11 Jan 2017 17:01:36 +0100 Subject: [PATCH] Implement UI changes (#78) * Implement UI changes * Center information button and ajust kerning * Update kerning * Update MainController.swift * Fix unit tests --- Library/Message.swift | 1 + Tests/MessageTests.swift | 2 ++ iOS/Source/InformationButton.swift | 6 +++--- iOS/Source/MainController.swift | 4 ++-- iOS/Source/SunView.swift | 4 ++-- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Library/Message.swift b/Library/Message.swift index ceddd99..45b6e6f 100644 --- a/Library/Message.swift +++ b/Library/Message.swift @@ -72,6 +72,7 @@ struct Message { let range = (self.content as NSString).range(of: self.coloredPart) let attributedString = NSMutableAttributedString(string: self.content) attributedString.addAttribute(NSForegroundColorAttributeName, value: textColor, range: range) + attributedString.addAttribute(NSKernAttributeName, value: -0.75, range: NSMakeRange(0, self.content.characters.count)) return attributedString } diff --git a/Tests/MessageTests.swift b/Tests/MessageTests.swift index 619342f..cc780a3 100644 --- a/Tests/MessageTests.swift +++ b/Tests/MessageTests.swift @@ -38,6 +38,7 @@ class MessageTests: XCTestCase { var range = (content as NSString).range(of: coloredPart) var attributedString = NSMutableAttributedString(string: content) attributedString.addAttribute(NSForegroundColorAttributeName, value: UIColor.red, range: range) + attributedString.addAttribute(NSKernAttributeName, value: -0.75, range: NSMakeRange(0, content.characters.count)) XCTAssertEqual(message.attributedString(withTextColor: UIColor.red), attributedString) format = "**%@ minutes** more." @@ -48,6 +49,7 @@ class MessageTests: XCTestCase { range = (content as NSString).range(of: coloredPart) attributedString = NSMutableAttributedString(string: content) attributedString.addAttribute(NSForegroundColorAttributeName, value: UIColor.red, range: range) + attributedString.addAttribute(NSKernAttributeName, value: -0.75, range: NSMakeRange(0, content.characters.count)) XCTAssertEqual(message.attributedString(withTextColor: UIColor.red), attributedString) } diff --git a/iOS/Source/InformationButton.swift b/iOS/Source/InformationButton.swift index 6143147..0f2f139 100644 --- a/iOS/Source/InformationButton.swift +++ b/iOS/Source/InformationButton.swift @@ -15,7 +15,7 @@ class InformationButton: UIButton { lazy var nameLabel: UILabel = { let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false - label.font = Theme.light(size: 12) + label.font = Theme.light(size: 16) return label }() @@ -23,7 +23,7 @@ class InformationButton: UIButton { override init(frame: CGRect) { super.init(frame: frame) - self.nameLabel.text = NSLocalizedString("About", comment: "") + self.nameLabel.text = NSLocalizedString("About Daylight", comment: "") self.addSubviewsAndConstraints() } @@ -36,7 +36,7 @@ class InformationButton: UIButton { self.addSubview(self.nameLabel) self.sun.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 40).isActive = true - self.sun.topAnchor.constraint(equalTo: self.topAnchor, constant: 40).isActive = true + self.sun.centerYAnchor.constraint(equalTo: self.nameLabel.centerYAnchor).isActive = true self.sun.widthAnchor.constraint(equalToConstant: InformationButton.sunSize).isActive = true self.sun.heightAnchor.constraint(equalToConstant: InformationButton.sunSize).isActive = true diff --git a/iOS/Source/MainController.swift b/iOS/Source/MainController.swift index f8a09d7..d3faf47 100644 --- a/iOS/Source/MainController.swift +++ b/iOS/Source/MainController.swift @@ -168,7 +168,7 @@ class MainController: UIViewController { self.informationButton.updateInterface(withBackgroundColor: backgroundColor, andTextColor: textColor) - self.shareButton.setTitleColor(textColor, for: .normal) + self.shareButton.setTitleColor(textColor.withAlphaComponent(0.6), for: .normal) self.locationLabel.textColor = textColor.withAlphaComponent(0.6) self.messageLabel.textColor = textColor.withAlphaComponent(0.6) self.messageLabel.attributedText = attributedString @@ -234,7 +234,7 @@ class MainController: UIViewController { let screenshot = UIScreen.screenshot(frame: overlayView.frame) - self.informationButton.nameLabel.text = NSLocalizedString("About", comment: "") + self.informationButton.nameLabel.text = NSLocalizedString("About Daylight", comment: "") self.locationLabel.textAlignment = .left screenshotLocationLeftAnchor.isActive = false diff --git a/iOS/Source/SunView.swift b/iOS/Source/SunView.swift index da2bcfc..4a1892b 100644 --- a/iOS/Source/SunView.swift +++ b/iOS/Source/SunView.swift @@ -109,8 +109,8 @@ class SunView: UIView { let labelWidth = CGFloat(35.0) - self.sunriseLabel.frame = CGRect(x: 0, y: 108, width: labelWidth, height: 16) - self.sunsetLabel.frame = CGRect(x: self.bounds.width - labelWidth, y: 108, width: labelWidth, height: 16) + self.sunriseLabel.frame = CGRect(x: 0, y: 116, width: labelWidth, height: 16) + self.sunsetLabel.frame = CGRect(x: self.bounds.width - labelWidth, y: 116, width: labelWidth, height: 16) self.sun.frame = CGRect(x: self.sunViewLocation.x, y: self.sunViewLocation.y, width: SunView.sunSize, height: SunView.sunSize) self.sunMask.frame = CGRect(x: 0, y: 0, width: self.bounds.width, height: 108) self.horizon.frame = CGRect(x: 0, y: 108, width: self.bounds.width, height: 1)