Skip to content

Commit

Permalink
Implement UI changes (#78)
Browse files Browse the repository at this point in the history
* Implement UI changes

* Center information button and ajust kerning

* Update kerning

* Update MainController.swift

* Fix unit tests
  • Loading branch information
marijnschilling authored and 3lvis committed Jan 11, 2017
1 parent c3427b4 commit e11a4f7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions Library/Message.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions Tests/MessageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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)
}

Expand Down
6 changes: 3 additions & 3 deletions iOS/Source/InformationButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ 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
}()

override init(frame: CGRect) {
super.init(frame: frame)

self.nameLabel.text = NSLocalizedString("About", comment: "")
self.nameLabel.text = NSLocalizedString("About Daylight", comment: "")
self.addSubviewsAndConstraints()
}

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions iOS/Source/MainController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions iOS/Source/SunView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e11a4f7

Please sign in to comment.