Browse Source

Merge branch 'master' of https://github.com/n0shake/Clocker

pull/101/head
Abhishek 4 years ago
parent
commit
7a8f0527b5
  1. 4
      Clocker/Clocker/en.lproj/Panel.xib
  2. 13
      Clocker/Panel/PanelController.swift
  3. 8
      Clocker/Panel/ParentPanelController+ModernSlider.swift
  4. 7
      Clocker/Panel/ParentPanelController.swift
  5. 25
      Clocker/Panel/Rate Controller/UpcomingEventView.swift
  6. 4
      Clocker/Panel/UI/FloatingWindow.xib

4
Clocker/Clocker/en.lproj/Panel.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"/>
<view key="contentView" focusRingType="none" misplaced="YES" id="6" customClass="BackgroundPanelView" customModule="Clocker" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="350" height="460"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@ -334,7 +334,7 @@
</subviews>
<color key="backgroundColor" name="systemIndigoColor" catalog="System" colorSpace="catalog"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="8II-oP-xbd">
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="8II-oP-xbd" customClass="ThinScroller" customModule="Clocker" customModuleProvider="target">
<rect key="frame" x="-100" y="-100" width="340" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>

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)

8
Clocker/Panel/ParentPanelController+ModernSlider.swift

@ -40,7 +40,9 @@ extension ParentPanelController {
}
private func navigateModernSliderToSpecificIndex(_ index: Int) {
let contentView = modernSlider.superview as! NSClipView
guard let contentView = modernSlider.superview as? NSClipView else {
return
}
let changedOrigin = contentView.documentVisibleRect.origin
let newPoint = NSPoint(x: changedOrigin.x + contentView.frame.width / 2, y: changedOrigin.y)
if let indexPath = modernSlider.indexPathForItem(at: newPoint) {
@ -66,7 +68,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),
@ -98,7 +100,7 @@ extension ParentPanelController {
modernSliderLabel.stringValue = timezoneFormattedStringRepresentation(previousDate)
return previousDate.minutes(from: Date())
} else {
setModernLabel(true)
setModernSliderLabel(true)
return 0
}
}

7
Clocker/Panel/ParentPanelController.swift

@ -572,6 +572,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]
@ -601,7 +607,6 @@ class ParentPanelController: NSWindowController {
}
cellView.layout(with: model)
updateDatePicker()
setModernLabel()
}
}
}

25
Clocker/Panel/Rate Controller/UpcomingEventView.swift

@ -60,3 +60,28 @@ class ModernSliderContainerView: NSView {
addTrackingArea(trackingArea)
}
}
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