Browse Source

Remove references for legacy future slider.

master
Abhishek Banthia 5 months ago
parent
commit
95940bab49
  1. 55
      Clocker/Clocker/en.lproj/Panel.xib
  2. 3
      Clocker/Panel/FloatingWindowController.swift
  3. 12
      Clocker/Panel/PanelController.swift
  4. 74
      Clocker/Panel/ParentPanelController.swift
  5. 6
      Clocker/Preferences/Appearance/AppearanceViewController.swift

55
Clocker/Clocker/en.lproj/Panel.xib

@ -10,8 +10,6 @@
<customObject id="-2" userLabel="File's Owner" customClass="PanelController" customModule="Clocker" customModuleProvider="target"> <customObject id="-2" userLabel="File's Owner" customClass="PanelController" customModule="Clocker" customModuleProvider="target">
<connections> <connections>
<outlet property="backgroundView" destination="6" id="20"/> <outlet property="backgroundView" destination="6" id="20"/>
<outlet property="futureSlider" destination="Vf2-uI-yf3" id="waZ-HW-18U"/>
<outlet property="futureSliderView" destination="C7R-Dq-MFr" id="IsR-aV-vjD"/>
<outlet property="goBackwardsButton" destination="aW8-hr-4Zh" id="EWT-EA-AGP"/> <outlet property="goBackwardsButton" destination="aW8-hr-4Zh" id="EWT-EA-AGP"/>
<outlet property="goForwardButton" destination="Bmz-Z2-OvH" id="6bR-Ph-Nit"/> <outlet property="goForwardButton" destination="Bmz-Z2-OvH" id="6bR-Ph-Nit"/>
<outlet property="leftButton" destination="WVY-D9-AAX" id="M2W-xG-chN"/> <outlet property="leftButton" destination="WVY-D9-AAX" id="M2W-xG-chN"/>
@ -25,11 +23,9 @@
<outlet property="resetModernSliderButton" destination="TK5-db-7bd" id="Mie-WC-5YN"/> <outlet property="resetModernSliderButton" destination="TK5-db-7bd" id="Mie-WC-5YN"/>
<outlet property="reviewView" destination="TDn-Kk-KkV" id="YdI-Y4-zrg"/> <outlet property="reviewView" destination="TDn-Kk-KkV" id="YdI-Y4-zrg"/>
<outlet property="rightButton" destination="w3d-CG-aBO" id="rcF-Gw-CtM"/> <outlet property="rightButton" destination="w3d-CG-aBO" id="rcF-Gw-CtM"/>
<outlet property="roundedDateView" destination="I2Z-NZ-795" id="Oa9-q9-gZx"/>
<outlet property="scrollViewHeight" destination="dff-DX-W1o" id="vYe-lb-h9x"/> <outlet property="scrollViewHeight" destination="dff-DX-W1o" id="vYe-lb-h9x"/>
<outlet property="sharingButton" destination="Hc7-fH-V7i" id="sXz-Cx-VaA"/> <outlet property="sharingButton" destination="Hc7-fH-V7i" id="sXz-Cx-VaA"/>
<outlet property="shutdownButton" destination="1cR-pI-osG" id="ZFz-9l-yNi"/> <outlet property="shutdownButton" destination="1cR-pI-osG" id="ZFz-9l-yNi"/>
<outlet property="sliderDatePicker" destination="zN8-JF-j7O" id="c06-EE-0kh"/>
<outlet property="stackView" destination="OZA-6o-SbE" id="lIT-4b-8WZ"/> <outlet property="stackView" destination="OZA-6o-SbE" id="lIT-4b-8WZ"/>
<outlet property="upcomingEventCollectionView" destination="Tp2-pl-yIm" id="gLE-03-1cZ"/> <outlet property="upcomingEventCollectionView" destination="Tp2-pl-yIm" id="gLE-03-1cZ"/>
<outlet property="upcomingEventContainerView" destination="Akn-cR-W4G" id="1cy-z6-392"/> <outlet property="upcomingEventContainerView" destination="Akn-cR-W4G" id="1cy-z6-392"/>
@ -261,55 +257,6 @@
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
</scrollView> </scrollView>
<customView wantsLayer="YES" focusRingType="none" translatesAutoresizingMaskIntoConstraints="NO" id="C7R-Dq-MFr" userLabel="Slider View">
<rect key="frame" x="0.0" y="245" width="350" height="30"/>
<subviews>
<slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Vf2-uI-yf3">
<rect key="frame" x="7" y="2" width="203" height="23"/>
<constraints>
<constraint firstAttribute="height" constant="15" id="cS7-i2-mHU"/>
</constraints>
<sliderCell key="cell" alignment="left" maxValue="1440" doubleValue="726.0119047619047" tickMarkPosition="above" sliderType="linear" id="lxm-k1-c5E" customClass="CustomSliderCell" customModule="Clocker" customModuleProvider="target"/>
<connections>
<action selector="sliderMoved:" target="-2" id="WsJ-lL-tRO"/>
</connections>
</slider>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="I2Z-NZ-795">
<rect key="frame" x="210" y="2" width="135" height="27"/>
<subviews>
<datePicker focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="zN8-JF-j7O">
<rect key="frame" x="0.0" y="2" width="135" height="23"/>
<datePickerCell key="cell" focusRingType="none" alignment="left" drawsBackground="NO" datePickerStyle="textField" id="Zg1-OT-OMw">
<font key="font" size="13" name="Avenir-Roman"/>
<date key="date" timeIntervalSinceReferenceDate="622949605.16002405">
<!--2020-09-28 01:33:25 +0000-->
</date>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<datePickerElements key="datePickerElements" year="YES" month="YES" day="YES" hour="YES" minute="YES"/>
</datePickerCell>
<connections>
<action selector="sliderPickerChanged:" target="-2" id="Rek-ik-2Tt"/>
</connections>
</datePicker>
</subviews>
<constraints>
<constraint firstItem="zN8-JF-j7O" firstAttribute="top" secondItem="I2Z-NZ-795" secondAttribute="top" constant="2" id="aiD-wv-HEn"/>
<constraint firstItem="zN8-JF-j7O" firstAttribute="leading" secondItem="I2Z-NZ-795" secondAttribute="leading" id="beq-J7-oUI"/>
<constraint firstAttribute="trailing" secondItem="zN8-JF-j7O" secondAttribute="trailing" id="elj-hH-a8y"/>
<constraint firstAttribute="bottom" secondItem="zN8-JF-j7O" secondAttribute="bottom" constant="2" id="swV-fS-frm"/>
</constraints>
</customView>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="30" id="ELw-ee-72z"/>
<constraint firstItem="I2Z-NZ-795" firstAttribute="centerY" secondItem="Vf2-uI-yf3" secondAttribute="centerY" id="GHK-f6-nwX"/>
<constraint firstItem="Vf2-uI-yf3" firstAttribute="leading" secondItem="C7R-Dq-MFr" secondAttribute="leading" constant="9" id="UPM-fg-1uv"/>
<constraint firstItem="I2Z-NZ-795" firstAttribute="leading" secondItem="Vf2-uI-yf3" secondAttribute="trailing" constant="2" id="Vt7-Rs-Liq"/>
<constraint firstItem="Vf2-uI-yf3" firstAttribute="centerY" secondItem="C7R-Dq-MFr" secondAttribute="centerY" id="Wno-LD-sb9"/>
<constraint firstAttribute="trailing" secondItem="I2Z-NZ-795" secondAttribute="trailing" constant="5" id="ju8-FH-nE8"/>
</constraints>
</customView>
<customView wantsLayer="YES" focusRingType="none" id="8W7-rS-Uob" userLabel="Modern Slider" customClass="ModernSliderContainerView" customModule="Clocker" customModuleProvider="target"> <customView wantsLayer="YES" focusRingType="none" id="8W7-rS-Uob" userLabel="Modern Slider" customClass="ModernSliderContainerView" customModule="Clocker" customModuleProvider="target">
<rect key="frame" x="0.0" y="175" width="350" height="70"/> <rect key="frame" x="0.0" y="175" width="350" height="70"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
@ -647,7 +594,6 @@
<integer value="1000"/> <integer value="1000"/>
<integer value="1000"/> <integer value="1000"/>
<integer value="1000"/> <integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities> </visibilityPriorities>
<customSpacing> <customSpacing>
<real value="3.4028234663852886e+38"/> <real value="3.4028234663852886e+38"/>
@ -655,7 +601,6 @@
<real value="3.4028234663852886e+38"/> <real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/> <real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/> <real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing> </customSpacing>
</stackView> </stackView>
</subviews> </subviews>

3
Clocker/Panel/FloatingWindowController.swift

@ -20,7 +20,6 @@ class FloatingWindowController: ParentPanelController {
override func awakeFromNib() { override func awakeFromNib() {
super.awakeFromNib() super.awakeFromNib()
setup() setup()
futureSlider.isContinuous = true
windowFrameAutosaveName = NSWindow.FrameAutosaveName("FloatingWindowAutoSave") windowFrameAutosaveName = NSWindow.FrameAutosaveName("FloatingWindowAutoSave")
dateFormatter = DateFormatter() dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US") dateFormatter.locale = Locale(identifier: "en_US")
@ -151,8 +150,6 @@ extension NSView {
extension FloatingWindowController: NSWindowDelegate { extension FloatingWindowController: NSWindowDelegate {
func windowWillClose(_: Notification) { func windowWillClose(_: Notification) {
futureSlider.integerValue = 0
setTimezoneDatasourceSlider(sliderValue: 0) setTimezoneDatasourceSlider(sliderValue: 0)
if let timer = repeater { if let timer = repeater {

12
Clocker/Panel/PanelController.swift

@ -22,8 +22,6 @@ class PanelController: ParentPanelController {
// Otherwise, the panel can be dragged around while we try to scroll through the modern slider // Otherwise, the panel can be dragged around while we try to scroll through the modern slider
window?.isMovableByWindowBackground = false window?.isMovableByWindowBackground = false
futureSlider.isContinuous = true
if let panel = window { if let panel = window {
panel.acceptsMouseMovedEvents = true panel.acceptsMouseMovedEvents = true
panel.level = .popUpMenu panel.level = .popUpMenu
@ -73,9 +71,6 @@ class PanelController: ParentPanelController {
setupUpcomingEventViewCollectionViewIfNeccesary() setupUpcomingEventViewCollectionViewIfNeccesary()
//TODO: Always hide the legacy slider. Delete this once v24.01 stabilizes.
futureSliderView.isHidden = true
if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false { if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false {
modernContainerView.isHidden = true modernContainerView.isHidden = true
} else if let value = DataStore.shared().retrieve(key: UserDefaultKeys.displayFutureSliderKey) as? NSNumber, modernContainerView != nil { } else if let value = DataStore.shared().retrieve(key: UserDefaultKeys.displayFutureSliderKey) as? NSNumber, modernContainerView != nil {
@ -87,8 +82,6 @@ class PanelController: ParentPanelController {
} }
// Reset future slider value to zero // Reset future slider value to zero
futureSlider.integerValue = 0
sliderDatePicker.dateValue = Date()
closestQuarterTimeRepresentation = findClosestQuarterTimeApproximation() closestQuarterTimeRepresentation = findClosestQuarterTimeApproximation()
modernSliderLabel.stringValue = "Time Scroller" modernSliderLabel.stringValue = "Time Scroller"
resetModernSliderButton.isHidden = true resetModernSliderButton.isHidden = true
@ -367,9 +360,8 @@ class PanelController: ParentPanelController {
// We only want to move the slider if the slider is visible. // We only want to move the slider if the slider is visible.
// If the parent view is hidden, then that doesn't automatically mean that all the childViews are also hidden // If the parent view is hidden, then that doesn't automatically mean that all the childViews are also hidden
// Hence, check if the parent view is totally hidden or not.. // Hence, check if the parent view is totally hidden or not..
if futureSliderView.isHidden == false, modernSlider.isHidden { if modernSlider.isHidden {
futureSlider.doubleValue += Double(event.scrollingDeltaX) // TODO: Move modern slider
sliderMoved(futureSlider!)
} }
} }
} }

74
Clocker/Panel/ParentPanelController.swift

@ -23,9 +23,7 @@ class ParentPanelController: NSWindowController {
var dateFormatter = DateFormatter() var dateFormatter = DateFormatter()
var futureSliderValue: Int { var futureSliderValue: Int = 0
return futureSlider.integerValue
}
var parentTimer: Repeater? var parentTimer: Repeater?
@ -50,12 +48,8 @@ class ParentPanelController: NSWindowController {
@IBOutlet var stackView: NSStackView! @IBOutlet var stackView: NSStackView!
@IBOutlet var futureSlider: NSSlider!
@IBOutlet var scrollViewHeight: NSLayoutConstraint! @IBOutlet var scrollViewHeight: NSLayoutConstraint!
@IBOutlet var futureSliderView: NSView!
@IBOutlet var reviewView: NSView! @IBOutlet var reviewView: NSView!
@IBOutlet var leftField: NSTextField! @IBOutlet var leftField: NSTextField!
@ -72,8 +66,6 @@ class ParentPanelController: NSWindowController {
@IBOutlet var pinButton: NSButton! @IBOutlet var pinButton: NSButton!
@IBOutlet var sliderDatePicker: NSDatePicker!
@IBOutlet var roundedDateView: NSView! @IBOutlet var roundedDateView: NSView!
// Modern Slider // Modern Slider
@ -179,7 +171,6 @@ class ParentPanelController: NSWindowController {
#endif #endif
// Setup layers // Setup layers
futureSliderView.wantsLayer = true
reviewView.wantsLayer = true reviewView.wantsLayer = true
// Setup notifications // Setup notifications
@ -210,9 +201,6 @@ class ParentPanelController: NSWindowController {
// Setup colors based on the curren theme // Setup colors based on the curren theme
themeChanged() themeChanged()
//TODO: Always hide the legacy slider view. Delete this once v24.01 stabilizes.
futureSliderView.isHidden = true
// UI adjustments based on user preferences // UI adjustments based on user preferences
if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false { if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false {
@ -310,18 +298,6 @@ class ParentPanelController: NSWindowController {
} }
private func adjustFutureSliderBasedOnPreferences() { private func adjustFutureSliderBasedOnPreferences() {
// Setting up Slider's Date Picker
sliderDatePicker.minDate = Date()
guard let sliderRange = DataStore.shared().retrieve(key: UserDefaultKeys.futureSliderRange) as? NSNumber else {
sliderDatePicker.maxDate = Date(timeInterval: 1 * 24 * 60 * 60, since: Date())
return
}
sliderDatePicker.maxDate = Date(timeInterval: (sliderRange.doubleValue + 1) * 24 * 60 * 60, since: Date())
futureSlider.maxValue = (sliderRange.doubleValue + 1) * 24 * 60
futureSlider.integerValue = 0
setTimezoneDatasourceSlider(sliderValue: 0) setTimezoneDatasourceSlider(sliderValue: 0)
updateTableContent() updateTableContent()
} }
@ -358,8 +334,6 @@ class ParentPanelController: NSWindowController {
let rightButtonAttributedTitle = NSAttributedString(string: rightButton.title, attributes: styleAttributes) let rightButtonAttributedTitle = NSAttributedString(string: rightButton.title, attributes: styleAttributes)
rightButton.attributedTitle = rightButtonAttributedTitle rightButton.attributedTitle = rightButtonAttributedTitle
futureSliderView.layer?.backgroundColor = NSColor.clear.cgColor
} }
@objc func themeChanged() { @objc func themeChanged() {
@ -375,8 +349,6 @@ class ParentPanelController: NSWindowController {
sharingButton.image = sharedThemer.sharingImage() sharingButton.image = sharedThemer.sharingImage()
sharingButton.alternateImage = sharedThemer.sharingImageAlternate() sharingButton.alternateImage = sharedThemer.sharingImageAlternate()
sliderDatePicker.textColor = sharedThemer.mainTextColor()
if roundedDateView != nil { if roundedDateView != nil {
roundedDateView.layer?.backgroundColor = Themer.shared().textBackgroundColor().cgColor roundedDateView.layer?.backgroundColor = Themer.shared().textBackgroundColor().cgColor
} }
@ -540,24 +512,8 @@ class ParentPanelController: NSWindowController {
window?.alphaValue = 1.0 window?.alphaValue = 1.0
} }
@IBAction func sliderMoved(_: Any) {
let currentCalendar = Calendar(identifier: .gregorian)
guard let newDate = currentCalendar.date(byAdding: .minute,
value: Int(futureSlider.doubleValue),
to: Date())
else {
assertionFailure("Data was unexpectedly nil")
return
}
setTimezoneDatasourceSlider(sliderValue: futureSliderValue)
sliderDatePicker.dateValue = newDate
mainTableView.reloadData()
}
func setTimezoneDatasourceSlider(sliderValue: Int) { func setTimezoneDatasourceSlider(sliderValue: Int) {
futureSliderValue = sliderValue
datasource?.setSlider(value: sliderValue) datasource?.setSlider(value: sliderValue)
} }
@ -619,9 +575,6 @@ class ParentPanelController: NSWindowController {
let cellView = mainTableView.view(atColumn: 0, row: $0, makeIfNecessary: false) as? TimezoneCellView, let cellView = mainTableView.view(atColumn: 0, row: $0, makeIfNecessary: false) as? TimezoneCellView,
let model = TimezoneData.customObject(from: current) let model = TimezoneData.customObject(from: current)
{ {
if let futureSliderCell = futureSlider.cell as? CustomSliderCell, futureSliderCell.tracking == true {
return
}
if modernContainerView != nil, modernSlider.isHidden == false, modernContainerView.currentlyInFocus { if modernContainerView != nil, modernSlider.isHidden == false, modernContainerView.currentlyInFocus {
return return
} }
@ -646,21 +599,11 @@ class ParentPanelController: NSWindowController {
cellView.noteLabel.stringValue = UserDefaultKeys.emptyString cellView.noteLabel.stringValue = UserDefaultKeys.emptyString
} }
cellView.layout(with: model) cellView.layout(with: model)
updateDatePicker() // TODO: Update modern slider
} }
} }
} }
private func updateDatePicker() {
sliderDatePicker.minDate = Date()
guard let sliderRange = DataStore.shared().retrieve(key: UserDefaultKeys.futureSliderRange) as? NSNumber else {
sliderDatePicker.maxDate = Date(timeInterval: 1 * 24 * 60 * 60, since: Date())
return
}
sliderDatePicker.maxDate = Date(timeInterval: (sliderRange.doubleValue + 1) * 24 * 60 * 60, since: Date())
}
@discardableResult @discardableResult
func showNotesPopover(forRow row: Int, relativeTo _: NSRect, andButton target: NSButton!) -> Bool { func showNotesPopover(forRow row: Int, relativeTo _: NSRect, andButton target: NSButton!) -> Bool {
let defaults = DataStore.shared().timezones() let defaults = DataStore.shared().timezones()
@ -955,22 +898,11 @@ class ParentPanelController: NSWindowController {
// MARK: Date Picker + Slider // MARK: Date Picker + Slider
@IBAction func sliderPickerChanged(_: Any) {
let minutesDifference = minutes(from: Date(), other: sliderDatePicker.dateValue)
futureSlider.integerValue = minutesDifference
setTimezoneDatasourceSlider(sliderValue: minutesDifference)
updateTableContent()
}
func minutes(from date: Date, other: Date) -> Int { func minutes(from date: Date, other: Date) -> Int {
return Calendar.current.dateComponents([.minute], from: date, to: other).minute ?? 0 return Calendar.current.dateComponents([.minute], from: date, to: other).minute ?? 0
} }
@IBAction func resetDatePicker(_: Any) {
futureSlider.integerValue = 0
sliderDatePicker.dateValue = Date()
setTimezoneDatasourceSlider(sliderValue: 0)
}
@objc func terminateClocker() { @objc func terminateClocker() {
NSApplication.shared.terminate(nil) NSApplication.shared.terminate(nil)

6
Clocker/Preferences/Appearance/AppearanceViewController.swift

@ -288,8 +288,8 @@ class AppearanceViewController: ParentViewController {
if panel, DataStore.shared().shouldDisplay(ViewType.showAppInForeground) == false { if panel, DataStore.shared().shouldDisplay(ViewType.showAppInForeground) == false {
guard let panelController = PanelController.panel() else { return } guard let panelController = PanelController.panel() else { return }
let futureSliderBounds = panelController.futureSlider.bounds let futureSliderBounds = panelController.modernSlider.bounds
panelController.futureSlider.setNeedsDisplay(futureSliderBounds) panelController.modernSlider.setNeedsDisplay(futureSliderBounds)
panelController.updateDefaultPreferences() panelController.updateDefaultPreferences()
panelController.updateTableContent() panelController.updateTableContent()
@ -300,7 +300,7 @@ class AppearanceViewController: ParentViewController {
if DataStore.shared().shouldDisplay(ViewType.showAppInForeground) { if DataStore.shared().shouldDisplay(ViewType.showAppInForeground) {
let floatingWindow = FloatingWindowController.shared() let floatingWindow = FloatingWindowController.shared()
floatingWindow.updateTableContent() floatingWindow.updateTableContent()
floatingWindow.futureSlider.setNeedsDisplay(floatingWindow.futureSlider.bounds) floatingWindow.modernSlider.setNeedsDisplay(floatingWindow.modernSlider.bounds)
if !panel { if !panel {
floatingWindow.updatePanelColor() floatingWindow.updatePanelColor()

Loading…
Cancel
Save