Browse Source

Finishing touch-ups.

pull/101/head
Abhishek 3 years ago
parent
commit
3744582f1a
  1. 13
      Clocker/Panel/PanelController.swift
  2. 4
      Clocker/Panel/ParentPanelController+ModernSlider.swift
  3. 9
      Clocker/Panel/ParentPanelController.swift
  4. 15
      Clocker/Panel/Rate Controller/UpcomingEventView.swift
  5. 4
      Clocker/Panel/UI/FloatingWindow.xib

13
Clocker/Panel/PanelController.swift

@ -25,6 +25,8 @@ class PanelController: ParentPanelController {
window?.title = "Clocker Panel"
window?.setAccessibilityIdentifier("Clocker Panel")
// Otherwise, the panel can be dragged around while we try to scroll through the modern slider
window?.isMovableByWindowBackground = false
futureSlider.isContinuous = true
@ -82,7 +84,7 @@ class PanelController: ParentPanelController {
if DataStore.shared().timezones().isEmpty || DataStore.shared().shouldDisplay(.futureSlider) == false {
futureSliderView.isHidden = true
modernContainerView.isHidden = true
} else if let value = DataStore.shared().retrieve(key: CLDisplayFutureSliderKey) as? NSNumber {
} else if let value = DataStore.shared().retrieve(key: CLDisplayFutureSliderKey) as? NSNumber, modernContainerView != nil {
if value.intValue == 1 {
futureSliderView.isHidden = false
modernContainerView.isHidden = true
@ -95,9 +97,12 @@ class PanelController: ParentPanelController {
// Reset future slider value to zero
futureSlider.integerValue = 0
sliderDatePicker.dateValue = Date()
closestQuarterTimeRepresentation = setModernLabel()
let indexPaths: Set<IndexPath> = Set([IndexPath(item: modernSlider.numberOfItems(inSection: 0) / 2, section: 0)])
modernSlider.scrollToItems(at: indexPaths, scrollPosition: .centeredHorizontally)
closestQuarterTimeRepresentation = setModernSliderLabel()
if modernSlider != nil {
let indexPaths: Set<IndexPath> = Set([IndexPath(item: modernSlider.numberOfItems(inSection: 0) / 2, section: 0)])
modernSlider.scrollToItems(at: indexPaths, scrollPosition: .centeredHorizontally)
}
setTimezoneDatasourceSlider(sliderValue: 0)

4
Clocker/Panel/ParentPanelController+ModernSlider.swift

@ -53,7 +53,7 @@ extension ParentPanelController {
}
@discardableResult
public func setModernLabel(_ shouldUpdate: Bool = false) -> Date {
public func setModernSliderLabel(_ shouldUpdate: Bool = false) -> Date {
let defaultParameters = minuteFromCalendar()
let hourQuarterDate = Calendar.current.nextDate(after: defaultParameters.0,
matching: DateComponents(minute: defaultParameters.1),
@ -85,7 +85,7 @@ extension ParentPanelController {
modernSliderLabel.stringValue = timezoneFormattedStringRepresentation(previousDate)
return previousDate.minutes(from: Date())
} else {
setModernLabel(true)
setModernSliderLabel(true)
return 0
}
}

9
Clocker/Panel/ParentPanelController.swift

@ -207,7 +207,7 @@ class ParentPanelController: NSWindowController {
selector: #selector(collectionViewDidScroll(_:)),
name: NSView.boundsDidChangeNotification,
object: modernSlider.superview)
closestQuarterTimeRepresentation = setModernLabel()
closestQuarterTimeRepresentation = setModernSliderLabel()
let indexPaths: Set<IndexPath> = Set([IndexPath(item: modernSlider.numberOfItems(inSection: 0) / 2, section: 0)])
modernSlider.scrollToItems(at: indexPaths, scrollPosition: .centeredHorizontally)
}
@ -583,6 +583,12 @@ class ParentPanelController: NSWindowController {
let preferences = store.timezones()
if modernSlider != nil, modernSlider.isHidden == false, modernContainerView.currentlyInFocus == false {
setModernSliderLabel()
let indexPaths: Set<IndexPath> = Set([IndexPath(item: modernSlider.numberOfItems(inSection: 0) / 2, section: 0)])
modernSlider.animator().scrollToItems(at: indexPaths, scrollPosition: .centeredHorizontally)
}
stride(from: 0, to: preferences.count, by: 1).forEach {
let current = preferences[$0]
@ -612,7 +618,6 @@ class ParentPanelController: NSWindowController {
}
cellView.layout(with: model)
updateDatePicker()
setModernLabel()
}
}
}

15
Clocker/Panel/Rate Controller/UpcomingEventView.swift

@ -62,11 +62,26 @@ class ModernSliderContainerView: NSView {
}
class ThinScroller: NSScroller {
private var trackingArea: NSTrackingArea?
override class func scrollerWidth(for _: NSControl.ControlSize, scrollerStyle _: NSScroller.Style) -> CGFloat {
return 15
}
override class func awakeFromNib() {
super.awakeFromNib()
}
override func drawKnobSlot(in _: NSRect, highlight _: Bool) {
// Leaving this empty to prevent background drawing
}
override func drawKnob() {
let knobRect = rect(for: .knob)
let knobDimensions: CGFloat = 10.0
let newRect = NSMakeRect(knobRect.origin.x, knobRect.origin.y + 5, knobDimensions, knobDimensions)
let path = NSBezierPath(ovalIn: newRect)
NSColor.lightGray.set()
path.fill()
}
}

4
Clocker/Panel/UI/FloatingWindow.xib

@ -42,7 +42,7 @@
<windowCollectionBehavior key="collectionBehavior" moveToActiveSpace="YES" ignoresCycle="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="1000" y="379" width="350" height="460"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1025"/>
<value key="minSize" type="size" width="150" height="50"/>
<value key="maxSize" type="size" width="350" height="800"/>
<view key="contentView" misplaced="YES" id="qEx-SC-5Qd">
@ -281,7 +281,7 @@
</collectionView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="oU5-xB-bV5">
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="oU5-xB-bV5" customClass="ThinScroller" customModule="Clocker" customModuleProvider="target">
<rect key="frame" x="0.0" y="34" width="340" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>

Loading…
Cancel
Save