Skip to content

Commit

Permalink
added night time mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamik423 committed Feb 9, 2022
1 parent dbcc026 commit 7857bdf
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 25 deletions.
3 changes: 2 additions & 1 deletion Padbury Clock Revived.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
3AA5BF5125C98A31005B39FE /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1240;
LastUpgradeCheck = 1320;
TargetAttributes = {
3AA5BF5925C98A31005B39FE = {
CreatedOnToolsVersion = 12.4;
Expand Down Expand Up @@ -265,6 +265,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
};
name = Release;
};
Expand Down
Binary file not shown.
11 changes: 7 additions & 4 deletions Padbury Clock Revived/ClockView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ final class ClockView: ScreenSaverView {
var fontSize: CGFloat = 0
var vOffset: CGFloat = 0

var backgroundColor: NSColor = .red
var foregroundColor: NSColor = .red
var backgroundColor: NSColor = .blue
var foregroundColor: NSColor = .blue

var dateFormatter: DateFormatter = DateFormatter()
var attributes: [NSAttributedString.Key: Any] = [:]
Expand All @@ -41,12 +41,15 @@ final class ClockView: ScreenSaverView {
if force || !hasSetup {
hasSetup = true

let currentHour = Calendar.current.component(.hour, from: Date())
let useNightTimeMode = preferences.nightTimeMode && (currentHour >= (10 + 12) || currentHour < 6)

if preferences.darkTheme {
backgroundColor = .black
foregroundColor = .white
foregroundColor = useNightTimeMode ? NSColor(red: 2.0 / 3.0, green: 0, blue: 0, alpha: 1) : .white
} else {
backgroundColor = .white
foregroundColor = .black
foregroundColor = useNightTimeMode ? .red : .black
}

let separator = preferences.showTimeSeparators ? ":" : " "
Expand Down
73 changes: 54 additions & 19 deletions Padbury Clock Revived/ConfigureSheet.xib
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19529"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="ConfigureSheetController" customModule="Padbury_Clock_Revived" customModuleProvider="target">
<connections>
<outlet property="darkThemeCheckbox" destination="S00-ph-A7z" id="O8B-jv-brD"/>
<outlet property="fontWeightSelector" destination="ZPr-3s-mEV" id="Lvz-Is-N9l"/>
<outlet property="nightTimeModeCheckbox" destination="Amm-Fe-f9G" id="Vqv-0P-PuV"/>
<outlet property="showSecondsCheckbox" destination="ZBS-KB-BcL" id="SKH-Ql-p3d"/>
<outlet property="showTimeSeparatorsCheckbox" destination="Ck4-Uf-5fZ" id="ajJ-vn-UIw"/>
<outlet property="twentyfourHoursCheckbox" destination="vcR-gm-DgE" id="3c6-40-Jtw"/>
Expand All @@ -22,19 +24,19 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="708" y="509" width="462" height="284"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1200"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1175"/>
<value key="minSize" type="size" width="256" height="256"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="462" height="284"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<gridView xPlacement="leading" yPlacement="fill" rowAlignment="firstBaseline" rowSpacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="gJC-Fu-Ran">
<rect key="frame" x="6" y="55" width="450" height="223"/>
<rect key="frame" x="6" y="10" width="450" height="268"/>
<rows>
<gridRow yPlacement="top" rowAlignment="firstBaseline" id="qR4-PX-gJf"/>
<gridRow yPlacement="top" rowAlignment="firstBaseline" id="hNR-Sn-yK5"/>
<gridRow yPlacement="top" rowAlignment="firstBaseline" id="IXm-94-IO3"/>
<gridRow yPlacement="top" rowAlignment="firstBaseline" id="q22-gN-81A"/>
<gridRow id="Cxt-q9-mTi"/>
</rows>
<columns>
<gridColumn xPlacement="trailing" width="100" id="zi3-Ws-PdH"/>
Expand All @@ -43,7 +45,7 @@
<gridCells>
<gridCell row="qR4-PX-gJf" column="zi3-Ws-PdH" id="0fO-xp-vHq">
<textField key="contentView" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="nvf-RD-QbQ">
<rect key="frame" x="52" y="207" width="50" height="16"/>
<rect key="frame" x="52" y="252" width="50" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Theme:" id="LXO-Ih-MrQ">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
Expand All @@ -52,16 +54,49 @@
</textField>
</gridCell>
<gridCell row="qR4-PX-gJf" column="Ci0-4x-MqC" id="Wxv-Fj-hWb">
<button key="contentView" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="S00-ph-A7z">
<rect key="frame" x="104" y="206" width="346" height="18"/>
<buttonCell key="cell" type="check" title="Dark Theme" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="lIc-rj-tyA">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="toggledCheckbox:" target="-2" id="GfI-fe-sKG"/>
</connections>
</button>
<stackView key="contentView" distribution="fill" orientation="vertical" alignment="leading" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="sea-gl-kUy">
<rect key="frame" x="106" y="207" width="344" height="61"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="S00-ph-A7z">
<rect key="frame" x="-2" y="44" width="100" height="18"/>
<buttonCell key="cell" type="check" title="Dark Theme" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="lIc-rj-tyA">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="toggledCheckbox:" target="-2" id="GfI-fe-sKG"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Amm-Fe-f9G">
<rect key="frame" x="-2" y="20" width="130" height="18"/>
<buttonCell key="cell" type="check" title="Night Time Mode" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="vLg-7I-fzF">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="toggledCheckbox:" target="-2" id="jYV-wW-lPa"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="7rt-9a-dIK">
<rect key="frame" x="-2" y="0.0" width="244" height="13"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Displays the time in red from 10:00 PM – 6:00 AM" id="Yi1-BS-phx">
<font key="font" textStyle="footnote" name=".SFNS-Regular"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</gridCell>
<gridCell row="hNR-Sn-yK5" column="zi3-Ws-PdH" id="rFd-tF-pe7">
<textField key="contentView" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Eiq-ey-ljG">
Expand Down Expand Up @@ -186,8 +221,8 @@
</customSpacing>
</stackView>
</gridCell>
<gridCell row="q22-gN-81A" column="zi3-Ws-PdH" id="Dyt-Ub-EYx"/>
<gridCell row="q22-gN-81A" column="Ci0-4x-MqC" xPlacement="fill" id="4oo-jB-n0f"/>
<gridCell row="Cxt-q9-mTi" column="zi3-Ws-PdH" id="IX2-H5-KXd"/>
<gridCell row="Cxt-q9-mTi" column="Ci0-4x-MqC" id="nk2-EC-GlA"/>
</gridCells>
</gridView>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2Gw-oF-LdS">
Expand Down
3 changes: 3 additions & 0 deletions Padbury Clock Revived/ConfigureSheetController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ConfigureSheetController: NSObject {
@IBOutlet var window: NSWindow?

@IBOutlet var darkThemeCheckbox: NSButton!
@IBOutlet var nightTimeModeCheckbox: NSButton!
@IBOutlet var twentyfourHoursCheckbox: NSButton!
@IBOutlet var showSecondsCheckbox: NSButton!
@IBOutlet var showTimeSeparatorsCheckbox: NSButton!
Expand All @@ -33,6 +34,7 @@ class ConfigureSheetController: NSObject {
func setup() {
if let preferences = Preferences.shared {
darkThemeCheckbox.state = preferences.darkTheme ? .on : .off
nightTimeModeCheckbox.state = preferences.nightTimeMode ? .on : .off
twentyfourHoursCheckbox.state = preferences.useAmPm ? .off : .on
showSecondsCheckbox.state = preferences.showSeconds ? .on : .off
showTimeSeparatorsCheckbox.state = preferences.showTimeSeparators ? .on : .off
Expand All @@ -54,6 +56,7 @@ class ConfigureSheetController: NSObject {
@IBAction func toggledCheckbox(_ sender: NSObject) {
if let preferences = Preferences.shared {
preferences.darkTheme = darkThemeCheckbox.state == .on
preferences.nightTimeMode = nightTimeModeCheckbox.state == .on
preferences.useAmPm = twentyfourHoursCheckbox.state == .off
preferences.showSeconds = showSecondsCheckbox.state == .on
preferences.showTimeSeparators = showTimeSeparatorsCheckbox.state == .on
Expand Down
8 changes: 8 additions & 0 deletions Padbury Clock Revived/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ class Preferences: NSObject {
defaults.synchronize()
}
}

var nightTimeMode: Bool {
get { return (defaults.value(forKey: "NightTimeMode") as? Bool) ?? false }
set {
defaults.setValue(newValue, forKey: "NightTimeMode")
defaults.synchronize()
}
}

var useAmPm: Bool {
get { return !((defaults.value(forKey: "24h") as? Bool) ?? true) }
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ The [Padbury Clock](https://padbury.app) is a minimalist screensaver created by
It has not been updated in ages and actually broke for me during the Big Sur beta cycle (although that issue resolved itself).
At that point I decided to recreate it.

This new version retains most of the settings from the original (if you require the red mode feel free to add a pull request) and ads a new font family and font weight selection system.
This new version retains most of the settings from the original (if you require the single monitor setting feel free to add a pull request) and ads a new font family and font weight selection system.
The original screensaver used Helvetia Neue Ultra Light.
With the new version you will also be able to select San Francisco, Apple's new system font as the font used.
The night time mode from the original is also supported.

<img src="screenshots/screenshot-1.png" width=50%><img src="screenshots/screenshot-2.png" width=50%>

Expand All @@ -21,6 +22,7 @@ Download [the latest version](https://github.com/Kamik423/Padbury-Clock-Revived/

### 1.0.2 (2022-02-10)

* Added night time mode
* Fixed settings not saving correctly

### 1.0.1 (2022-02-09)
Expand Down
Binary file modified screenshots/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7857bdf

Please sign in to comment.