Permalink
Browse files

Version 0.1.0

  • Loading branch information...
1 parent d5bab5e commit b73520fbe7b26f5e77caacb1a5c148e2b951347d @soffes committed Mar 22, 2016
Showing with 20 additions and 11 deletions.
  1. +4 −0 Countdown.xcodeproj/project.pbxproj
  2. +13 −8 Sources/CountdownView.swift
  3. +1 −1 Sources/Preferences.swift
  4. +2 −2 Support/Info.plist
@@ -21,6 +21,8 @@
212EA6001CA10FDB0049BD16 /* Configuration.xib in Resources */ = {isa = PBXBuildFile; fileRef = 212EA5E91CA10D430049BD16 /* Configuration.xib */; };
212EA6021CA110920049BD16 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = 212EA6011CA110920049BD16 /* Label.swift */; };
212EA6041CA110F80049BD16 /* PlaceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 212EA6031CA110F80049BD16 /* PlaceView.swift */; };
+ 212EA6051CA118970049BD16 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = 212EA6011CA110920049BD16 /* Label.swift */; };
+ 212EA6061CA118970049BD16 /* PlaceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 212EA6031CA110F80049BD16 /* PlaceView.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -237,6 +239,8 @@
files = (
212EA5F31CA10D430049BD16 /* Preferences.swift in Sources */,
212EA5F11CA10D430049BD16 /* ConfigurationWindowController.swift in Sources */,
+ 212EA6061CA118970049BD16 /* PlaceView.swift in Sources */,
+ 212EA6051CA118970049BD16 /* Label.swift in Sources */,
212EA5F01CA10D430049BD16 /* CountdownView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -17,6 +17,8 @@ class CountdownView: ScreenSaverView {
let view = Label()
view.translatesAutoresizingMaskIntoConstraints = false
view.stringValue = "Open Screen Saver Options to set your date."
+ view.textColor = .whiteColor()
+ view.hidden = true
return view
}()
@@ -51,6 +53,7 @@ class CountdownView: ScreenSaverView {
private let placesView: NSStackView = {
let view = NSStackView()
view.translatesAutoresizingMaskIntoConstraints = false
+ view.hidden = true
return view
}()
@@ -114,10 +117,10 @@ class CountdownView: ScreenSaverView {
let now = NSDate()
let components = NSCalendar.currentCalendar().components(units, fromDate: now, toDate: date, options: [])
- daysView.textLabel.stringValue = String(format: "%02d", components.day)
- hoursView.textLabel.stringValue = String(format: "%02d", components.hour)
- minutesView.textLabel.stringValue = String(format: "%02d", components.minute)
- secondsView.textLabel.stringValue = String(format: "%02d", components.second)
+ daysView.textLabel.stringValue = String(format: "%02d", abs(components.day))
+ hoursView.textLabel.stringValue = String(format: "%02d", abs(components.hour))
+ minutesView.textLabel.stringValue = String(format: "%02d", abs(components.minute))
+ secondsView.textLabel.stringValue = String(format: "%02d", abs(components.second))
}
override func hasConfigureSheet() -> Bool {
@@ -148,6 +151,8 @@ class CountdownView: ScreenSaverView {
placesView.addArrangedSubview(secondsView)
addSubview(placesView)
+ updateFonts()
+
addConstraints([
placeholderLabel.centerXAnchor.constraintEqualToAnchor(centerXAnchor),
placeholderLabel.centerYAnchor.constraintEqualToAnchor(centerYAnchor),
@@ -172,13 +177,13 @@ class CountdownView: ScreenSaverView {
/// Update the font for the current size
private func updateFonts() {
- placesView.spacing = max(32, round(bounds.width * 0.05))
+ placesView.spacing = floor(bounds.width * 0.05)
- placeholderLabel.font = fontWithSize(round(bounds.width / 30), monospace: false)
+ placeholderLabel.font = fontWithSize(floor(bounds.width / 30), monospace: false)
let places = [daysView, hoursView, minutesView, secondsView]
let textFont = fontWithSize(round(bounds.width / 8), weight: NSFontWeightUltraLight)
- let detailTextFont = fontWithSize(round(bounds.width / 38), weight: NSFontWeightThin)
+ let detailTextFont = fontWithSize(floor(bounds.width / 38), weight: NSFontWeightThin)
for place in places {
place.textLabel.font = textFont
@@ -204,6 +209,6 @@ class CountdownView: ScreenSaverView {
fontDescriptor = font.fontDescriptor
}
- return NSFont(descriptor: fontDescriptor, size: fontSize)!
+ return NSFont(descriptor: fontDescriptor, size: max(4, fontSize))!
}
}
@@ -14,7 +14,7 @@ class Preferences: NSObject {
// MARK: - Properties
static let dateDidChangeNotificationName = "Preferences.dateDidChangeNotification"
- private static let dateKey = "Date"
+ private static let dateKey = "Date2"
var date: NSDate? {
get {
View
@@ -15,14 +15,14 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
- <string>0.2.1</string>
+ <string>0.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 Sam Soffes. All rights reserved.</string>
<key>NSPrincipalClass</key>
- <string>Motivation.AgeView</string>
+ <string>Countdown.CountdownView</string>
</dict>
</plist>

0 comments on commit b73520f

Please sign in to comment.