Browse Source

Tweaks.

pull/101/head
Abhishek 4 years ago
parent
commit
0ccbab53f3
  1. 8
      Clocker/Clocker/en.lproj/Panel.xib
  2. 4
      Clocker/ClockerUnitTests/ClockerUnitTests.swift
  3. 8
      Clocker/Panel/ParentPanelController+ModernSlider.swift
  4. 13
      Clocker/Panel/ParentPanelController.swift
  5. 27
      Clocker/Panel/Rate Controller/ReviewView.swift

8
Clocker/Clocker/en.lproj/Panel.xib

@ -262,7 +262,7 @@
</scroller> </scroller>
</scrollView> </scrollView>
<customView identifier="Review Cell" focusRingType="none" translatesAutoresizingMaskIntoConstraints="NO" id="TDn-Kk-KkV"> <customView identifier="Review Cell" focusRingType="none" translatesAutoresizingMaskIntoConstraints="NO" id="TDn-Kk-KkV">
<rect key="frame" x="0.0" y="220" width="350" height="50"/> <rect key="frame" x="0.0" y="5" width="350" height="50"/>
<subviews> <subviews>
<stackView focusRingType="none" distribution="fill" orientation="horizontal" alignment="centerY" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uys-ww-duA"> <stackView focusRingType="none" distribution="fill" orientation="horizontal" alignment="centerY" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uys-ww-duA">
<rect key="frame" x="25" y="25" width="300" height="20"/> <rect key="frame" x="25" y="25" width="300" height="20"/>
@ -336,7 +336,7 @@
<accessibility description="ReviewCell" identifier="ReviewCell"/> <accessibility description="ReviewCell" identifier="ReviewCell"/>
</customView> </customView>
<customView wantsLayer="YES" focusRingType="none" translatesAutoresizingMaskIntoConstraints="NO" id="Akn-cR-W4G" customClass="ReviewView" customModule="Clocker" customModuleProvider="target"> <customView wantsLayer="YES" focusRingType="none" translatesAutoresizingMaskIntoConstraints="NO" id="Akn-cR-W4G" customClass="ReviewView" customModule="Clocker" customModuleProvider="target">
<rect key="frame" x="0.0" y="145" width="350" height="75"/> <rect key="frame" x="0.0" y="-70" width="350" height="75"/>
<subviews> <subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="Etf-aa-udM" customClass="ClockerTextBackgroundView" customModule="Clocker" customModuleProvider="target"> <customView translatesAutoresizingMaskIntoConstraints="NO" id="Etf-aa-udM" customClass="ClockerTextBackgroundView" customModule="Clocker" customModuleProvider="target">
<rect key="frame" x="10" y="10" width="330" height="55"/> <rect key="frame" x="10" y="10" width="330" height="55"/>
@ -413,7 +413,7 @@
<accessibility identifier="UpcomingEventView"/> <accessibility identifier="UpcomingEventView"/>
</customView> </customView>
<customView wantsLayer="YES" focusRingType="none" translatesAutoresizingMaskIntoConstraints="NO" id="C7R-Dq-MFr" userLabel="Slider View"> <customView wantsLayer="YES" focusRingType="none" translatesAutoresizingMaskIntoConstraints="NO" id="C7R-Dq-MFr" userLabel="Slider View">
<rect key="frame" x="0.0" y="115" width="350" height="30"/> <rect key="frame" x="0.0" y="-100" width="350" height="30"/>
<subviews> <subviews>
<slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Vf2-uI-yf3"> <slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Vf2-uI-yf3">
<rect key="frame" x="7" y="2" width="201" height="23"/> <rect key="frame" x="7" y="2" width="201" height="23"/>
@ -461,7 +461,7 @@
<constraint firstAttribute="trailing" secondItem="I2Z-NZ-795" secondAttribute="trailing" constant="5" id="ju8-FH-nE8"/> <constraint firstAttribute="trailing" secondItem="I2Z-NZ-795" secondAttribute="trailing" constant="5" id="ju8-FH-nE8"/>
</constraints> </constraints>
</customView> </customView>
<customView wantsLayer="YES" focusRingType="none" id="8W7-rS-Uob" userLabel="Modern Slider"> <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="40" width="350" height="75"/> <rect key="frame" x="0.0" y="40" width="350" height="75"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews> <subviews>

4
Clocker/ClockerUnitTests/ClockerUnitTests.swift

@ -130,10 +130,10 @@ class ClockerUnitTests: XCTestCase {
// The below test might fail outside California or if DST is active! // The below test might fail outside California or if DST is active!
// CI is calibrated to be on LA timezone! // CI is calibrated to be on LA timezone!
func testTimeDifference() { func testTimeDifference() {
XCTAssertTrue(operations.timeDifference() == ", 11h 30m ahead", "Difference was unexpectedly: \(operations.timeDifference())") XCTAssertTrue(operations.timeDifference() == ", 10h 30m ahead", "Difference was unexpectedly: \(operations.timeDifference())")
XCTAssertTrue(californiaOperations.timeDifference() == ", 2h behind", "Difference was unexpectedly: \(californiaOperations.timeDifference())") XCTAssertTrue(californiaOperations.timeDifference() == ", 2h behind", "Difference was unexpectedly: \(californiaOperations.timeDifference())")
XCTAssertTrue(floridaOperations.timeDifference() == ", an hour ahead", "Difference was unexpectedly: \(floridaOperations.timeDifference())") XCTAssertTrue(floridaOperations.timeDifference() == ", an hour ahead", "Difference was unexpectedly: \(floridaOperations.timeDifference())")
XCTAssertTrue(aucklandOperations.timeDifference() == ", 19h ahead", "Difference was unexpectedly: \(aucklandOperations.timeDifference())") XCTAssertTrue(aucklandOperations.timeDifference() == ", 17h ahead", "Difference was unexpectedly: \(aucklandOperations.timeDifference())")
XCTAssertTrue(omahaOperations.timeDifference() == "", "Difference was unexpectedly: \(omahaOperations.timeDifference())") XCTAssertTrue(omahaOperations.timeDifference() == "", "Difference was unexpectedly: \(omahaOperations.timeDifference())")
} }

8
Clocker/Panel/ParentPanelController+ModernSlider.swift

@ -29,14 +29,6 @@ extension ParentPanelController {
} }
} }
@objc func scrollViewWillStartLiveScroll(_: NSNotification) {
modernSliderIsScrolling = true
}
@objc func scrollViewDidEndLiveScroll(_: NSNotification) {
modernSliderIsScrolling = false
}
@discardableResult @discardableResult
public func setModernLabel(_ shouldUpdate: Bool = false) -> Date { public func setModernLabel(_ shouldUpdate: Bool = false) -> Date {
let defaultParameters = minuteFromCalendar() let defaultParameters = minuteFromCalendar()

13
Clocker/Panel/ParentPanelController.swift

@ -89,10 +89,9 @@ class ParentPanelController: NSWindowController {
// Modern Slider // Modern Slider
public var currentCenterIndexPath: Int = -1 public var currentCenterIndexPath: Int = -1
public var closestQuarterTimeRepresentation: Date? public var closestQuarterTimeRepresentation: Date?
public var modernSliderIsScrolling: Bool = false
@IBOutlet var modernSlider: NSCollectionView! @IBOutlet var modernSlider: NSCollectionView!
@IBOutlet var modernSliderLabel: NSTextField! @IBOutlet var modernSliderLabel: NSTextField!
@IBOutlet var modernContainerView: NSView! @IBOutlet var modernContainerView: ModernSliderContainerView!
var defaultPreferences: [Data] { var defaultPreferences: [Data] {
return DataStore.shared().timezones() return DataStore.shared().timezones()
@ -204,14 +203,6 @@ class ParentPanelController: NSWindowController {
modernSlider.enclosingScrollView?.scrollerInsets = NSEdgeInsets(top: 0, left: 0, bottom: 100, right: 0) modernSlider.enclosingScrollView?.scrollerInsets = NSEdgeInsets(top: 0, left: 0, bottom: 100, right: 0)
modernSlider.delegate = self modernSlider.delegate = self
modernSlider.postsBoundsChangedNotifications = true modernSlider.postsBoundsChangedNotifications = true
NotificationCenter.default.addObserver(self,
selector: #selector(scrollViewWillStartLiveScroll(_:)),
name: NSScrollView.willStartLiveScrollNotification,
object: modernSlider.enclosingScrollView)
NotificationCenter.default.addObserver(self,
selector: #selector(scrollViewDidEndLiveScroll(_:)),
name: NSScrollView.didEndLiveScrollNotification,
object: modernSlider.enclosingScrollView)
NotificationCenter.default.addObserver(self, NotificationCenter.default.addObserver(self,
selector: #selector(collectionViewDidScroll(_:)), selector: #selector(collectionViewDidScroll(_:)),
name: NSView.boundsDidChangeNotification, name: NSView.boundsDidChangeNotification,
@ -601,7 +592,7 @@ class ParentPanelController: NSWindowController {
if let futureSliderCell = futureSlider.cell as? CustomSliderCell, futureSliderCell.tracking == true { if let futureSliderCell = futureSlider.cell as? CustomSliderCell, futureSliderCell.tracking == true {
return return
} }
if modernSlider.isHidden == false, modernSliderIsScrolling { if modernSlider.isHidden == false, modernContainerView.currentlyInFocus {
return return
} }
let dataOperation = TimezoneDataOperations(with: model) let dataOperation = TimezoneDataOperations(with: model)

27
Clocker/Panel/Rate Controller/ReviewView.swift

@ -33,3 +33,30 @@ class ReviewView: NSView {
addTrackingArea(trackingArea) addTrackingArea(trackingArea)
} }
} }
class ModernSliderContainerView: NSView {
private var trackingArea: NSTrackingArea?
public var currentlyInFocus = false
override func mouseEntered(with event: NSEvent) {
super.mouseEntered(with: event)
currentlyInFocus = true
}
override func mouseExited(with event: NSEvent) {
super.mouseExited(with: event)
currentlyInFocus = false
}
override func updateTrackingAreas() {
super.updateTrackingAreas()
if let trackingArea = self.trackingArea {
removeTrackingArea(trackingArea)
}
let options: NSTrackingArea.Options = [.mouseEnteredAndExited, .activeAlways]
let trackingArea = NSTrackingArea(rect: bounds, options: options, owner: self, userInfo: nil)
addTrackingArea(trackingArea)
}
}

Loading…
Cancel
Save