Browse Source

New version changes!

v1.2.1
Abhishek Banthia 9 years ago
parent
commit
006023a3bc
  1. 6
      Clocker.xcodeproj/project.pbxproj
  2. BIN
      Clocker.xcodeproj/project.xcworkspace/xcuserdata/abhishekbanthia.xcuserdatad/UserInterfaceState.xcuserstate
  3. 16
      Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  4. 13
      Clocker/Custom Slider/CLCustomSliderCell.h
  5. 43
      Clocker/Custom Slider/CLCustomSliderCell.m
  6. BIN
      Clocker/Images/PowerIcon 2.png
  7. BIN
      Clocker/Images/index.png
  8. 2
      Clocker/Panel.m
  9. 42
      Clocker/Panel.xib
  10. 15
      Clocker/PanelController.h
  11. 151
      Clocker/PanelController.m
  12. 236
      Clocker/Preferences/CLPreferencesView.xib
  13. 6
      Clocker/Preferences/CLPreferencesViewController.h
  14. 55
      Clocker/Preferences/CLPreferencesViewController.m
  15. 2
      Clocker/Reachability/Reachability.m
  16. 1
      Clocker/Utilities/CommonStrings.h
  17. 1
      Clocker/Utilities/CommonStrings.m
  18. 2
      Media.xcassets/PowerIcon-White.imageset/Contents.json
  19. BIN
      Media.xcassets/PowerIcon-White.imageset/PowerIcon 2.png
  20. BIN
      Media.xcassets/PowerIcon-White.imageset/PowerIcon-Whitw2.png
  21. BIN
      Media.xcassets/Settings-White.imageset/Settings-White.png

6
Clocker.xcodeproj/project.pbxproj

@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
9A25F7471C1A5E17007D369B /* iRate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A25F7441C1A5E17007D369B /* iRate.m */; };
9A3247321C25FD3A00CF6B6E /* CLCustomSliderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A3247311C25FD3A00CF6B6E /* CLCustomSliderCell.m */; };
9A392EE81C1CDD530072C10A /* CLAboutUsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A392EE61C1CDD530072C10A /* CLAboutUsViewController.m */; };
9A392EE91C1CDD530072C10A /* CLAboutUsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9A392EE71C1CDD530072C10A /* CLAboutUsView.xib */; };
9A392EED1C1CE9950072C10A /* CLPreferencesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A392EEB1C1CE9950072C10A /* CLPreferencesViewController.m */; };
@ -65,6 +66,8 @@
/* Begin PBXFileReference section */
9A25F7411C1A5E17007D369B /* iRate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = iRate.h; path = "Clocker/Rate App/iRate.h"; sourceTree = "<group>"; };
9A25F7441C1A5E17007D369B /* iRate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = iRate.m; path = "Clocker/Rate App/iRate.m"; sourceTree = "<group>"; };
9A3247301C25FD3A00CF6B6E /* CLCustomSliderCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CLCustomSliderCell.h; path = "Clocker/Custom Slider/CLCustomSliderCell.h"; sourceTree = "<group>"; };
9A3247311C25FD3A00CF6B6E /* CLCustomSliderCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CLCustomSliderCell.m; path = "Clocker/Custom Slider/CLCustomSliderCell.m"; sourceTree = "<group>"; };
9A392EE51C1CDD530072C10A /* CLAboutUsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CLAboutUsViewController.h; path = Clocker/AboutUsWindow/CLAboutUsViewController.h; sourceTree = "<group>"; };
9A392EE61C1CDD530072C10A /* CLAboutUsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CLAboutUsViewController.m; path = Clocker/AboutUsWindow/CLAboutUsViewController.m; sourceTree = "<group>"; };
9A392EE71C1CDD530072C10A /* CLAboutUsView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = CLAboutUsView.xib; path = Clocker/AboutUsWindow/CLAboutUsView.xib; sourceTree = "<group>"; };
@ -217,6 +220,8 @@
9A8605BD1BEC14F600A810A4 /* Panel.m */,
9A8605CB1BEC155B00A810A4 /* ColoredButton.h */,
9A8605B21BEC14A600A810A4 /* ColoredButton.m */,
9A3247301C25FD3A00CF6B6E /* CLCustomSliderCell.h */,
9A3247311C25FD3A00CF6B6E /* CLCustomSliderCell.m */,
);
name = Superclass;
sourceTree = "<group>";
@ -428,6 +433,7 @@
files = (
9A8605BF1BEC14F600A810A4 /* BackgroundView.m in Sources */,
9AB9357B1C1AD8F7001285A0 /* CLRatingCellView.m in Sources */,
9A3247321C25FD3A00CF6B6E /* CLCustomSliderCell.m in Sources */,
9A392EED1C1CE9950072C10A /* CLPreferencesViewController.m in Sources */,
9A5951BD1C1D0A8D009C17AA /* CommonStrings.m in Sources */,
9A5951FA1C1D5214009C17AA /* iVersion.m in Sources */,

BIN
Clocker.xcodeproj/project.xcworkspace/xcuserdata/abhishekbanthia.xcuserdatad/UserInterfaceState.xcuserstate generated

Binary file not shown.

16
Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@ -13,21 +13,5 @@
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Clocker/Preferences/CLPreferencesViewController.m"
timestampString = "472193139.144987"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "625"
endingLineNumber = "625"
landmarkName = "-getTimeZoneForLatitude:andLongitude:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

13
Clocker/Custom Slider/CLCustomSliderCell.h

@ -0,0 +1,13 @@
//
// CLCustomSliderCell.h
// Clocker
//
// Created by Abhishek Banthia on 12/19/15.
//
//
#import <Cocoa/Cocoa.h>
@interface CLCustomSliderCell : NSSliderCell
@end

43
Clocker/Custom Slider/CLCustomSliderCell.m

@ -0,0 +1,43 @@
//
// CLCustomSliderCell.m
// Clocker
//
// Created by Abhishek Banthia on 12/19/15.
//
//
#import "CLCustomSliderCell.h"
@implementation CLCustomSliderCell
- (void)drawBarInside:(NSRect)rect flipped:(BOOL)flipped
{
rect.size.height = 5.0;
// Bar radius
CGFloat barRadius = 2.5;
// Knob position depending on control min/max value and current control value.
CGFloat value = ([self doubleValue] - [self minValue]) / ([self maxValue] - [self minValue]);
// Final Left Part Width
CGFloat finalWidth = value * ([[self controlView] frame].size.width - 8);
// Left Part Rect
NSRect leftRect = rect;
leftRect.size.width = finalWidth;
NSBezierPath* bg = [NSBezierPath bezierPathWithRoundedRect: rect xRadius: barRadius yRadius: barRadius];
NSString *theme = [[NSUserDefaults standardUserDefaults] objectForKey:@"defaultTheme"];
[theme isEqualToString:@"Black"] ? [NSColor.whiteColor setFill] : [[NSColor colorWithCalibratedRed:67.0/255.0 green:138.0/255.0 blue:250.0/255.0 alpha:1.0] setFill];
[bg fill];
// Draw Right Part
NSBezierPath* active = [NSBezierPath bezierPathWithRoundedRect: leftRect xRadius: barRadius yRadius: barRadius];
[[NSColor colorWithCalibratedRed:67.0/255.0 green:138.0/255.0 blue:250.0/255.0 alpha:1.0] setFill];
[theme isEqualToString:@"Black"] ? [[NSColor colorWithCalibratedRed:67.0/255.0 green:138.0/255.0 blue:250.0/255.0 alpha:1.0] setFill] : [NSColor.blackColor setFill];
[active fill];
}
@end

BIN
Clocker/Images/PowerIcon 2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
Clocker/Images/index.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

2
Clocker/Panel.m

@ -55,4 +55,6 @@
}
@end

42
Clocker/Panel.xib

@ -7,11 +7,12 @@
<customObject id="-2" userLabel="File's Owner" customClass="PanelController">
<connections>
<outlet property="backgroundView" destination="6" id="20"/>
<outlet property="futureSlider" destination="T7e-RS-eTE" id="xDZ-rl-pux"/>
<outlet property="mainTableview" destination="dFw-ts-8OZ" id="wwJ-jA-lCy"/>
<outlet property="preferencesButton" destination="OFy-u1-TnH" id="SId-Ih-ssT"/>
<outlet property="scrollViewHeight" destination="QcT-N0-G4s" id="EHr-Co-L0Z"/>
<outlet property="shutdownButton" destination="nTt-pf-Hw2" id="gCK-0D-gnK"/>
<outlet property="titleField" destination="HR1-ZK-Ey0" id="L0G-91-jZx"/>
<outlet property="sliderLabel" destination="rGL-w7-iSa" id="70y-sh-dyl"/>
<outlet property="window" destination="5" id="7"/>
</connections>
</customObject>
@ -38,7 +39,6 @@
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="1"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<tableViewGridLines key="gridStyleMask" dashed="YES"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="279" minWidth="40" maxWidth="1000" id="LTt-db-Dwv">
@ -200,17 +200,29 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="HR1-ZK-Ey0">
<rect key="frame" x="0.0" y="2" width="280" height="22"/>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rGL-w7-iSa">
<rect key="frame" x="100" y="26" width="79" height="20"/>
<constraints>
<constraint firstAttribute="height" constant="22" id="IxM-FF-J1F"/>
<constraint firstAttribute="width" constant="75" id="XLu-0I-ACL"/>
<constraint firstAttribute="height" constant="20" id="j4s-Vf-pQQ"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" state="on" alignment="center" placeholderString="Clocker" drawsBackground="YES" id="KVB-OA-XfT">
<font key="font" size="17" name="Palatino-Bold"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" placeholderString="Future Slider" id="KPS-ge-xQM">
<font key="font" size="13" name="HelveticaNeue-Light"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="T7e-RS-eTE">
<rect key="frame" x="29" y="11" width="217" height="16"/>
<constraints>
<constraint firstAttribute="height" constant="12" id="tQw-lm-Ify"/>
</constraints>
<sliderCell key="cell" state="on" alignment="left" maxValue="24" tickMarkPosition="above" sliderType="linear" id="V8R-sf-5hO" customClass="CLCustomSliderCell"/>
<connections>
<action selector="sliderMoved:" target="-2" id="TMW-de-NVq"/>
<binding destination="-2" name="value" keyPath="self.futureSliderValue" id="Fbv-WN-01b"/>
</connections>
</slider>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="OFy-u1-TnH">
<rect key="frame" x="246" y="1" width="29" height="19"/>
<constraints>
@ -218,7 +230,7 @@
<constraint firstAttribute="height" constant="18" id="X7D-ep-wB4"/>
</constraints>
<buttonCell key="cell" type="recessed" bezelStyle="recessed" image="NSActionTemplate" imagePosition="only" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="vYm-fs-Zjd">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<behavior key="behavior" lightByContents="YES"/>
<font key="font" metaFont="systemBold" size="12"/>
</buttonCell>
<connections>
@ -232,7 +244,7 @@
<constraint firstAttribute="height" constant="18" id="sVG-VE-3q4"/>
</constraints>
<buttonCell key="cell" type="recessed" bezelStyle="recessed" image="PowerIcon" imagePosition="only" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="sUh-16-Fhk">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES" changeBackground="YES" changeGray="YES"/>
<behavior key="behavior" lightByContents="YES"/>
<font key="font" metaFont="systemBold" size="12"/>
</buttonCell>
<connections>
@ -242,15 +254,17 @@
</subviews>
<constraints>
<constraint firstItem="4Gd-Nv-fXr" firstAttribute="top" secondItem="6" secondAttribute="top" constant="8" id="1g0-Hm-7Gh"/>
<constraint firstAttribute="trailing" secondItem="HR1-ZK-Ey0" secondAttribute="trailing" id="1ol-mo-aQU"/>
<constraint firstAttribute="bottom" secondItem="HR1-ZK-Ey0" secondAttribute="bottom" constant="2" id="Jtb-Nx-FYR"/>
<constraint firstItem="T7e-RS-eTE" firstAttribute="top" secondItem="dFw-ts-8OZ" secondAttribute="bottom" constant="-25" id="96B-lf-iFV"/>
<constraint firstItem="T7e-RS-eTE" firstAttribute="leading" secondItem="nTt-pf-Hw2" secondAttribute="trailing" constant="2" id="GgQ-58-tbc"/>
<constraint firstAttribute="bottom" secondItem="nTt-pf-Hw2" secondAttribute="bottom" constant="2" id="QoV-TI-KVJ"/>
<constraint firstAttribute="bottom" secondItem="OFy-u1-TnH" secondAttribute="bottom" constant="2" id="Ubf-Mv-WMp"/>
<constraint firstAttribute="trailing" secondItem="4Gd-Nv-fXr" secondAttribute="trailing" constant="-1" id="XP6-W0-2XT"/>
<constraint firstItem="HR1-ZK-Ey0" firstAttribute="leading" secondItem="6" secondAttribute="leading" id="XQ8-hU-ayC"/>
<constraint firstItem="T7e-RS-eTE" firstAttribute="top" secondItem="rGL-w7-iSa" secondAttribute="bottom" constant="1" id="cuU-JZ-uRn"/>
<constraint firstItem="4Gd-Nv-fXr" firstAttribute="leading" secondItem="6" secondAttribute="leading" constant="-1" id="fHc-VQ-mJ3"/>
<constraint firstItem="rGL-w7-iSa" firstAttribute="centerX" secondItem="dFw-ts-8OZ" secondAttribute="centerX" id="jY7-tr-VZ1"/>
<constraint firstAttribute="trailing" secondItem="OFy-u1-TnH" secondAttribute="trailing" constant="5" id="p2a-qj-LHE"/>
<constraint firstItem="nTt-pf-Hw2" firstAttribute="leading" secondItem="6" secondAttribute="leading" id="pKl-Ay-0cB"/>
<constraint firstItem="OFy-u1-TnH" firstAttribute="leading" secondItem="T7e-RS-eTE" secondAttribute="trailing" constant="2" id="vVD-Or-EZX"/>
</constraints>
</view>
<connections>

15
Clocker/PanelController.h

@ -51,24 +51,23 @@
__unsafe_unretained NSTextField *_textField;
}
@property (nonatomic, unsafe_unretained) IBOutlet BackgroundView *backgroundView;
@property (nonatomic, strong) CLOneWindowController *oneWindow;
@property (nonatomic, strong) NSMutableArray *defaultPreferences;
@property (nonatomic, strong) NSDateFormatter *dateFormatter;
@property (nonatomic, assign) NSInteger futureSliderValue;
@property (nonatomic) BOOL hasActivePanel;
@property (nonatomic) BOOL showReviewCell;
@property (nonatomic, unsafe_unretained, readonly) id<PanelControllerDelegate> delegate;
@property (nonatomic, unsafe_unretained) IBOutlet BackgroundView *backgroundView;
@property (weak) IBOutlet NSTableView *mainTableview;
@property (weak) IBOutlet NSLayoutConstraint *scrollViewHeight;
@property (weak) IBOutlet NSButton *shutdownButton;
@property (weak) IBOutlet NSButton *preferencesButton;
@property (assign) BOOL showReviewCell;
@property (weak) IBOutlet NSTextField *titleField;
@property (weak) IBOutlet NSSlider *futureSlider;
@property (weak) IBOutlet NSTextField *sliderLabel;
- (id)initWithDelegate:(id<PanelControllerDelegate>)delegate;
- (void)openPanel;
- (void)closePanel;
- (void)updateDefaultPreferences;

151
Clocker/PanelController.m

@ -59,8 +59,6 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
@implementation PanelController
#pragma mark -
- (id)initWithDelegate:(id<PanelControllerDelegate>)delegate
@ -80,6 +78,11 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
{
[super awakeFromNib];
if (!self.dateFormatter)
{
self.dateFormatter = [[NSDateFormatter alloc] init];
}
[self updateDefaultPreferences];
if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"defaultTheme"] isEqualToString:@"Black"]) {
@ -113,12 +116,21 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
- (void) updateDefaultPreferences
{
NSArray *defaultZones = [[NSUserDefaults standardUserDefaults] objectForKey:CLDefaultPreferenceKey];
self.defaultPreferences = self.defaultPreferences == nil ? [[NSMutableArray alloc] initWithArray:defaultZones] : [NSMutableArray arrayWithArray:defaultZones];
self.scrollViewHeight.constant = self.showReviewCell ? (self.defaultPreferences.count+1)*55+40 : self.defaultPreferences.count*55 + 30;
if (self.defaultPreferences.count == 0) {
self.futureSlider.hidden = YES;
self.sliderLabel.hidden = YES;
}
else
{
self.futureSlider.hidden = NO;
self.sliderLabel.hidden = NO;
}
}
@ -203,6 +215,8 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
- (void)openPanel
{
self.futureSliderValue = 0;
NSWindow *panel = [self window];
NSRect screenRect = [[[NSScreen screens] objectAtIndex:0] frame];
@ -301,39 +315,13 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
{
[cell updateTextColorWithColor:[NSColor whiteColor] andCell:cell];
[self.mainTableview setBackgroundColor:[NSColor blackColor]];
[self.titleField setBackgroundColor:[NSColor blackColor]];
NSMutableParagraphStyle *paragraphStyle = NSMutableParagraphStyle.new;
paragraphStyle.alignment = NSTextAlignmentCenter;
NSDictionary *whiteDict = [NSDictionary dictionaryWithObjectsAndKeys:[NSColor whiteColor], NSForegroundColorAttributeName, [NSFont fontWithName:@"Palatino" size:17] ,NSFontAttributeName,paragraphStyle,NSParagraphStyleAttributeName, nil];
NSAttributedString *whiteTitle = [[NSAttributedString alloc]
initWithString: @"Clocker"
attributes: whiteDict] ;
[self.titleField setPlaceholderAttributedString:whiteTitle];
self.window.alphaValue = 0.90;
}
else
{
[cell updateTextColorWithColor:[NSColor blackColor] andCell:cell];
[self.mainTableview setBackgroundColor:[NSColor whiteColor]];
[self.titleField setBackgroundColor:[NSColor whiteColor]];
NSMutableParagraphStyle *paragraphStyle = NSMutableParagraphStyle.new;
paragraphStyle.alignment = NSTextAlignmentCenter;
NSDictionary *whiteDict = [NSDictionary dictionaryWithObjectsAndKeys:[NSColor blackColor], NSForegroundColorAttributeName, [NSFont fontWithName:@"Palatino" size:17] ,NSFontAttributeName,paragraphStyle,NSParagraphStyleAttributeName, nil];
NSAttributedString *whiteTitle = [[NSAttributedString alloc]
initWithString: @"Clocker"
attributes: whiteDict] ;
[self.titleField setPlaceholderAttributedString:whiteTitle];
self.window.alphaValue = 1;
}
cell.relativeDate.stringValue = [self getDateForTimeZone:self.defaultPreferences[row][CLTimezoneID]];
@ -385,7 +373,11 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
- (NSString *)getTimeForTimeZone:(NSString *)timezoneID
{
NSDate *currentDate = [NSDate date];
NSCalendar *currentCalendar = [NSCalendar autoupdatingCurrentCalendar];
NSDate *newDate = [currentCalendar dateByAddingUnit:NSCalendarUnitHour
value:self.futureSliderValue
toDate:[NSDate date]
options:kNilOptions];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateStyle = kCFDateFormatterNoStyle;
@ -396,19 +388,19 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
dateFormatter.timeZone = [NSTimeZone timeZoneWithName:timezoneID];
//In the format 22:10
return [dateFormatter stringFromDate:currentDate];
return [dateFormatter stringFromDate:newDate];
}
- (NSString *)getLocalCurrentDate
{
NSDate *currentDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateStyle = kCFDateFormatterShortStyle;
dateFormatter.timeStyle = kCFDateFormatterNoStyle;
dateFormatter.timeZone = [NSTimeZone systemTimeZone];
return [NSDateFormatter localizedStringFromDate:currentDate dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterNoStyle];
// return [dateFormatter stringFromDate:currentDate];
return [NSDateFormatter localizedStringFromDate:[NSDate date]
dateStyle:NSDateFormatterShortStyle
timeStyle:NSDateFormatterNoStyle];
}
@ -428,9 +420,10 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
// Specify which units we would like to use
unsigned units = NSCalendarUnitDay;
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
NSInteger systemDay = [calendar component:units fromDate:localDate];
NSInteger timezoneDay = [calendar component:units fromDate:timezoneDate];
NSInteger weekday = [calendar component:NSCalendarUnitWeekday fromDate:localDate];
if (systemDay == timezoneDay) {
return @"Today";
@ -439,23 +432,30 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
{
return @"Yesterday";
}
else
else if (systemDay + 1 == timezoneDay)
{
return @"Tomorrow";
}
else
{
return [self getWeekdayFromInteger:weekday+2];
}
}
- (NSString *)getDateForTimeZone:(NSString *)timezoneID
{
NSDate *currentDate = [NSDate date];
NSCalendar *currentCalendar = [NSCalendar autoupdatingCurrentCalendar];
NSDate *newDate = [currentCalendar dateByAddingUnit:NSCalendarUnitHour
value:self.futureSliderValue
toDate:[NSDate date]
options:kNilOptions];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateStyle = kCFDateFormatterShortStyle;
dateFormatter.timeStyle = kCFDateFormatterNoStyle;
dateFormatter.timeZone = [NSTimeZone timeZoneWithName:timezoneID];
//In the format 22:10
return [self compareSystemDate:[self getLocalCurrentDate] toTimezoneDate:[dateFormatter stringFromDate:currentDate]];;
return [self compareSystemDate:[self getLocalCurrentDate] toTimezoneDate:[dateFormatter stringFromDate:newDate]];;
}
#pragma mark -
@ -465,11 +465,8 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
- (BOOL)tableView:(NSTableView *)tableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard
{
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
[pboard declareTypes:[NSArray arrayWithObject:CLDragSessionKey] owner:self];
[pboard setData:data forType:CLDragSessionKey];
return YES;
}
@ -483,7 +480,6 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
[mutableTimeZoneDict setValue:object forKey:CLCustomLabel];
[self.defaultPreferences replaceObjectAtIndex:row withObject:mutableTimeZoneDict];
[[NSUserDefaults standardUserDefaults] setObject:self.defaultPreferences forKey:CLDefaultPreferenceKey];
[self.mainTableview reloadData];
}
}
@ -536,7 +532,76 @@ NSString *const CLTimezoneCellViewIdentifier = @"timeZoneCell";
self.shutdownButton.hidden = !value;
self.preferencesButton.hidden = !value;
}
- (IBAction)sliderMoved:(id)sender
{
NSCalendar *currentCalendar = [NSCalendar autoupdatingCurrentCalendar];
NSDate *newDate = [currentCalendar dateByAddingUnit:NSCalendarUnitHour
value:self.futureSliderValue
toDate:[NSDate date]
options:kNilOptions];
self.dateFormatter.dateStyle = kCFDateFormatterNoStyle;
self.dateFormatter.timeStyle = kCFDateFormatterShortStyle;
NSString *relativeDate = [currentCalendar isDateInToday:newDate] ? @"Today" : @"Tomorrow";
NSString *helper = [self.dateFormatter stringFromDate:newDate];
NSHelpManager *helpManager = [NSHelpManager sharedHelpManager];
NSPoint pointInScreen = [NSEvent mouseLocation];
pointInScreen.y -= 5;
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@", relativeDate, helper]];
[NSHelpManager setContextHelpModeActive:YES];
[helpManager setContextHelp:attributedString forObject:self.futureSlider];
[helpManager showContextHelpForObject:self.futureSlider locationHint:pointInScreen];
[self.mainTableview reloadData];
}
- (NSString *)getWeekdayFromInteger:(NSInteger)weekdayInteger
{
if (weekdayInteger > 7) {
weekdayInteger = weekdayInteger - 7;
}
switch (weekdayInteger) {
case 1:
return @"Sunday";
break;
case 2:
return @"Monday";
break;
case 3:
return @"Tuesday";
break;
case 4:
return @"Wednesday";
break;
case 5:
return @"Thursday";
break;
case 6:
return @"Friday";
break;
case 7:
return @"Saturday";
break;
default:
return @"Error";
break;
}
}
@end

236
Clocker/Preferences/CLPreferencesView.xib

@ -8,11 +8,11 @@
<connections>
<outlet property="availableTimezoneTableView" destination="Q0t-hQ-orw" id="vQv-rd-Wkv"/>
<outlet property="fontPopUp" destination="adA-dB-5Ok" id="FK1-Pq-eXW"/>
<outlet property="is24HourFormatSelected" destination="msw-L5-agF" id="Orm-wH-Yr8"/>
<outlet property="messageLabel" destination="KFC-NV-5A3" id="NKB-JY-Udb"/>
<outlet property="placeholderLabel" destination="Wb6-yr-Pw4" id="ilx-y4-XEw"/>
<outlet property="searchField" destination="biT-6m-ElR" id="Di3-QU-LGY"/>
<outlet property="themePopUp" destination="sfL-D2-aUX" id="G3Z-Nv-eVe"/>
<outlet property="theme" destination="ri6-fd-h3Z" id="9Sm-u7-G9o"/>
<outlet property="timeFormat" destination="qCn-Gz-vsB" id="0ZW-hJ-wgI"/>
<outlet property="timezonePanel" destination="6FL-fp-Ke1" id="SDq-Q4-hMb"/>
<outlet property="timezoneTableView" destination="LbJ-dW-ITm" id="tRO-Ch-Was"/>
<outlet property="view" destination="Uu9-io-frR" id="bYk-D1-SUF"/>
@ -21,11 +21,11 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<view id="Uu9-io-frR">
<rect key="frame" x="0.0" y="0.0" width="439" height="407"/>
<rect key="frame" x="0.0" y="0.0" width="439" height="479"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button toolTip="Add a timezone" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="4yB-vZ-tNX">
<rect key="frame" x="11" y="102" width="21" height="22"/>
<rect key="frame" x="11" y="163" width="21" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="GNz-C9-Ay8"/>
<constraint firstAttribute="width" constant="21" id="OkY-Uq-PwX"/>
@ -39,7 +39,7 @@
</connections>
</button>
<button toolTip="Remove a timezone" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iOG-Ey-lmD">
<rect key="frame" x="32" y="102" width="21" height="22"/>
<rect key="frame" x="32" y="163" width="21" height="22"/>
<buttonCell key="cell" type="smallSquare" bezelStyle="smallSquare" image="NSRemoveTemplate" imagePosition="overlaps" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="gLH-wy-bCE">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@ -52,13 +52,13 @@ CA
</connections>
</button>
<scrollView focusRingType="none" borderType="none" autohidesScrollers="YES" horizontalLineScroll="22" horizontalPageScroll="10" verticalLineScroll="22" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zBR-OH-6QQ">
<rect key="frame" x="10" y="129" width="419" height="270"/>
<rect key="frame" x="10" y="190" width="419" height="281"/>
<clipView key="contentView" id="UZ2-JA-TZe">
<rect key="frame" x="0.0" y="0.0" width="419" height="270"/>
<rect key="frame" x="0.0" y="0.0" width="419" height="281"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnSelection="YES" autosaveColumns="NO" rowHeight="20" headerView="igm-uc-1wh" id="LbJ-dW-ITm">
<rect key="frame" x="0.0" y="0.0" width="419" height="247"/>
<rect key="frame" x="0.0" y="0.0" width="419" height="258"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@ -112,27 +112,73 @@ CA
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
<button toolTip="Show time using a 24-hour format" translatesAutoresizingMaskIntoConstraints="NO" id="msw-L5-agF" customClass="ColoredButton">
<rect key="frame" x="167" y="75" width="343" height="22"/>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wtb-He-7BA">
<rect key="frame" x="186" y="45" width="67" height="19"/>
<constraints>
<constraint firstAttribute="width" constant="339" id="KXG-qX-V3N"/>
<constraint firstAttribute="height" constant="18" id="d60-FM-DPd"/>
<constraint firstAttribute="width" constant="63" id="Whm-eI-Qun"/>
</constraints>
<buttonCell key="cell" type="check" title="Use a 24-hour clock" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="ki6-rf-utU">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" size="12" name="Helvetica-Light"/>
</buttonCell>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Font Family" id="fIc-YC-zol">
<font key="font" size="12" name="HelveticaNeue-Light"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="RVw-E8-jnc">
<rect key="frame" x="200" y="93" width="40" height="19"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Theme" id="Fxt-Z4-w4Z">
<font key="font" size="12" name="HelveticaNeue-Light"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="EdZ-8X-JQg">
<rect key="frame" x="184" y="141" width="70" height="19"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Time Format" id="KxG-3S-ZCz">
<font key="font" size="12" name="HelveticaNeue-Light"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ri6-fd-h3Z">
<rect key="frame" x="157" y="66" width="124" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="120" id="uei-YD-v1R"/>
</constraints>
<segmentedCell key="cell" borderStyle="border" alignment="left" style="rounded" trackingMode="selectOne" id="Z4q-lw-PxF">
<font key="font" size="12" name="HelveticaNeue-Light"/>
<segments>
<segment label="Default"/>
<segment label="Black" toolTip="Customize the timezone panel by selecting a theme!" selected="YES" tag="1"/>
</segments>
</segmentedCell>
<connections>
<action selector="timeFormatSelectionChanged:" target="-2" id="5mG-yB-Vzd"/>
<binding destination="1Gq-ZQ-IML" name="value" keyPath="values.is24HourFormatSelected" id="KjZ-gp-ipG"/>
<action selector="changeTheme:" target="-2" id="IeG-lF-AYU"/>
<binding destination="1Gq-ZQ-IML" name="selectedLabel" keyPath="values.defaultTheme" id="ODp-CX-fqY"/>
</connections>
</button>
</segmentedControl>
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="qCn-Gz-vsB">
<rect key="frame" x="101" y="114" width="236" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="232" id="Gma-Mm-ceK"/>
</constraints>
<segmentedCell key="cell" borderStyle="border" alignment="left" style="rounded" trackingMode="selectOne" id="rc6-Qv-gWj">
<font key="font" size="13" name="HelveticaNeue-Light"/>
<segments>
<segment label="12-hour clock" width="115"/>
<segment label="24-hour clock" toolTip="Set the time format you want to see in the timezone panel!" width="114" tag="1"/>
</segments>
</segmentedCell>
<connections>
<action selector="timeFormatSelectionChanged:" target="-2" id="tdk-w1-ZdT"/>
<binding destination="1Gq-ZQ-IML" name="selectedIndex" keyPath="values.is24HourFormatSelected" id="f6L-5I-EVP"/>
</connections>
</segmentedControl>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="adA-dB-5Ok">
<rect key="frame" x="167" y="17" width="179" height="26"/>
<rect key="frame" x="131" y="17" width="179" height="26"/>
<constraints>
<constraint firstAttribute="width" constant="174" id="Iav-7m-gZ5"/>
</constraints>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" imagePosition="overlaps" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="fI5-8y-GjM" id="3QE-QI-x3u">
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" arrowPosition="noArrow" selectedItem="fI5-8y-GjM" id="3QE-QI-x3u">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" size="12" name="HelveticaNeue-Thin"/>
<menu key="menu" id="cF5-QZ-Ydw">
@ -149,85 +195,36 @@ CA
<binding destination="1Gq-ZQ-IML" name="selectedValue" keyPath="values.defaultFontFamily" previousBinding="JZm-hy-Yzo" id="olU-xe-W4j"/>
</connections>
</popUpButton>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="sfL-D2-aUX">
<rect key="frame" x="167" y="45" width="179" height="26"/>
<constraints>
<constraint firstAttribute="width" constant="174" id="AQn-7i-cfu"/>
</constraints>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" imagePosition="overlaps" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="tDC-SX-9j7">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" size="12" name="HelveticaNeue-Thin"/>
<menu key="menu" id="A5x-kq-ASo">
<items>
<menuItem title="Default" id="wIH-hb-kKL"/>
<menuItem title="Item 2" id="z5C-7z-5Lv"/>
<menuItem title="Item 3" id="1qC-i0-ODT"/>
</items>
</menu>
</popUpButtonCell>
<connections>
<action selector="changeTheme:" target="-2" id="EJf-VX-AVu"/>
<binding destination="-2" name="content" keyPath="self.themes" id="sq9-TC-zmI"/>
<binding destination="1Gq-ZQ-IML" name="selectedValue" keyPath="values.defaultTheme" previousBinding="sq9-TC-zmI" id="YII-d7-sWH"/>
</connections>
</popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wtb-He-7BA">
<rect key="frame" x="95" y="21" width="67" height="19"/>
<constraints>
<constraint firstAttribute="width" constant="63" id="Whm-eI-Qun"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Font Family:" id="fIc-YC-zol">
<font key="font" size="12" name="HelveticaNeue-Light"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="RVw-E8-jnc">
<rect key="frame" x="119" y="49" width="43" height="19"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Theme:" id="Fxt-Z4-w4Z">
<font key="font" size="12" name="HelveticaNeue-Light"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="EdZ-8X-JQg">
<rect key="frame" x="86" y="77" width="73" height="19"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Time Format:" id="KxG-3S-ZCz">
<font key="font" size="12" name="HelveticaNeue-Light"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<constraints>
<constraint firstItem="adA-dB-5Ok" firstAttribute="top" secondItem="sfL-D2-aUX" secondAttribute="bottom" constant="7" id="8lc-ds-Esz"/>
<constraint firstAttribute="bottom" secondItem="wtb-He-7BA" secondAttribute="bottom" constant="21" id="ABT-bI-1fr"/>
<constraint firstItem="msw-L5-agF" firstAttribute="top" secondItem="4yB-vZ-tNX" secondAttribute="bottom" constant="8" id="CnR-dg-KfG"/>
<constraint firstItem="adA-dB-5Ok" firstAttribute="centerX" secondItem="Uu9-io-frR" secondAttribute="centerX" id="1cp-Qu-tUG"/>
<constraint firstItem="EdZ-8X-JQg" firstAttribute="top" secondItem="4yB-vZ-tNX" secondAttribute="bottom" constant="4" id="7j3-qP-hQS"/>
<constraint firstItem="qCn-Gz-vsB" firstAttribute="centerX" secondItem="Uu9-io-frR" secondAttribute="centerX" id="Ddq-aH-J08"/>
<constraint firstItem="wtb-He-7BA" firstAttribute="centerX" secondItem="Uu9-io-frR" secondAttribute="centerX" id="FYU-zT-Kh2"/>
<constraint firstItem="iOG-Ey-lmD" firstAttribute="height" secondItem="4yB-vZ-tNX" secondAttribute="height" id="HKt-is-5y3"/>
<constraint firstItem="zBR-OH-6QQ" firstAttribute="top" secondItem="Uu9-io-frR" secondAttribute="top" constant="8" id="JKn-gF-8oI"/>
<constraint firstItem="msw-L5-agF" firstAttribute="top" secondItem="iOG-Ey-lmD" secondAttribute="bottom" constant="8" id="Umd-Jo-VZj"/>
<constraint firstItem="RVw-E8-jnc" firstAttribute="top" secondItem="EdZ-8X-JQg" secondAttribute="bottom" constant="9" id="YL7-ik-B6o"/>
<constraint firstItem="ri6-fd-h3Z" firstAttribute="top" secondItem="RVw-E8-jnc" secondAttribute="bottom" constant="4" id="K6f-Vr-qVl"/>
<constraint firstItem="RVw-E8-jnc" firstAttribute="centerX" secondItem="Uu9-io-frR" secondAttribute="centerX" id="Lbm-Wb-QhA"/>
<constraint firstItem="EdZ-8X-JQg" firstAttribute="top" secondItem="iOG-Ey-lmD" secondAttribute="bottom" constant="4" id="VH4-rQ-sQ3"/>
<constraint firstItem="4yB-vZ-tNX" firstAttribute="top" secondItem="zBR-OH-6QQ" secondAttribute="bottom" constant="6" id="Zsk-85-aI8"/>
<constraint firstItem="RVw-E8-jnc" firstAttribute="leading" secondItem="Uu9-io-frR" secondAttribute="leading" constant="121" id="dyX-Sd-50z"/>
<constraint firstItem="adA-dB-5Ok" firstAttribute="top" secondItem="wtb-He-7BA" secondAttribute="bottom" constant="4" id="alc-Vc-hTT"/>
<constraint firstItem="qCn-Gz-vsB" firstAttribute="top" secondItem="EdZ-8X-JQg" secondAttribute="bottom" constant="4" id="btm-if-1Jq"/>
<constraint firstAttribute="bottom" secondItem="adA-dB-5Ok" secondAttribute="bottom" constant="20" id="fZs-aV-AJw"/>
<constraint firstItem="sfL-D2-aUX" firstAttribute="leading" secondItem="RVw-E8-jnc" secondAttribute="trailing" constant="9" id="fzk-AD-jKY"/>
<constraint firstItem="wtb-He-7BA" firstAttribute="leading" secondItem="Uu9-io-frR" secondAttribute="leading" constant="97" id="im6-yj-x5a"/>
<constraint firstItem="adA-dB-5Ok" firstAttribute="leading" secondItem="wtb-He-7BA" secondAttribute="trailing" constant="9" id="l3q-0l-VaZ"/>
<constraint firstItem="wtb-He-7BA" firstAttribute="top" secondItem="ri6-fd-h3Z" secondAttribute="bottom" constant="4" id="kOu-TZ-9f8"/>
<constraint firstAttribute="trailing" secondItem="zBR-OH-6QQ" secondAttribute="trailing" constant="10" id="p1P-Ev-oBI"/>
<constraint firstItem="msw-L5-agF" firstAttribute="leading" secondItem="Uu9-io-frR" secondAttribute="leading" constant="169" id="uwf-y2-ZwE"/>
<constraint firstItem="wtb-He-7BA" firstAttribute="top" secondItem="RVw-E8-jnc" secondAttribute="bottom" constant="9" id="w2l-AG-0Y2"/>
<constraint firstItem="RVw-E8-jnc" firstAttribute="top" secondItem="qCn-Gz-vsB" secondAttribute="bottom" constant="4" id="pkQ-fr-Y1p"/>
<constraint firstItem="ri6-fd-h3Z" firstAttribute="centerX" secondItem="Uu9-io-frR" secondAttribute="centerX" id="slW-cb-BAu"/>
<constraint firstItem="iOG-Ey-lmD" firstAttribute="width" secondItem="4yB-vZ-tNX" secondAttribute="width" id="wLJ-lQ-GhP"/>
<constraint firstItem="EdZ-8X-JQg" firstAttribute="leading" secondItem="Uu9-io-frR" secondAttribute="leading" constant="88" id="wmd-IT-K12"/>
<constraint firstItem="EdZ-8X-JQg" firstAttribute="centerX" secondItem="Uu9-io-frR" secondAttribute="centerX" id="xh9-kQ-AAh"/>
<constraint firstItem="iOG-Ey-lmD" firstAttribute="leading" secondItem="4yB-vZ-tNX" secondAttribute="trailing" id="xu0-0C-2pe"/>
<constraint firstItem="sfL-D2-aUX" firstAttribute="top" secondItem="msw-L5-agF" secondAttribute="bottom" constant="8" id="zSV-jH-6pp"/>
<constraint firstItem="4yB-vZ-tNX" firstAttribute="leading" secondItem="Uu9-io-frR" secondAttribute="leading" constant="11" id="zgB-PO-97r"/>
<constraint firstItem="zBR-OH-6QQ" firstAttribute="leading" secondItem="Uu9-io-frR" secondAttribute="leading" constant="10" id="zoH-62-nam"/>
</constraints>
<point key="canvasLocation" x="295.5" y="209.5"/>
<point key="canvasLocation" x="295.5" y="245.5"/>
</view>
<userDefaultsController representsSharedInstance="YES" id="1Gq-ZQ-IML"/>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hasShadow="NO" hidesOnDeactivate="YES" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="alertPanel" appearanceType="aqua" frameAutosaveName="" id="6FL-fp-Ke1" customClass="Panel">
<windowStyleMask key="styleMask" closable="YES" miniaturizable="YES" resizable="YES" documentModal="YES" nonactivatingPanel="YES" texturedBackground="YES"/>
<windowStyleMask key="styleMask" closable="YES" miniaturizable="YES" nonactivatingPanel="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="120" y="64" width="345" height="320"/>
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
@ -266,14 +263,14 @@ CA
</tableColumn>
</tableColumns>
<connections>
<binding destination="-2" name="enabled" keyPath="self.activityInProgress" id="Xk8-FS-aWk">
<binding destination="-2" name="doubleClickTarget" keyPath="self" id="nBJ-qr-qEf">
<dictionary key="options">
<string key="NSValueTransformerName">NSNegateBoolean</string>
<string key="NSSelectorName">addToFavorites:</string>
</dictionary>
</binding>
<binding destination="-2" name="doubleClickTarget" keyPath="self" id="nBJ-qr-qEf">
<binding destination="-2" name="enabled" keyPath="self.activityInProgress" id="Xk8-FS-aWk">
<dictionary key="options">
<string key="NSSelectorName">addToFavorites:</string>
<string key="NSValueTransformerName">NSNegateBoolean</string>
</dictionary>
</binding>
<outlet property="dataSource" destination="-2" id="86g-xx-hg5"/>
@ -299,26 +296,6 @@ CA
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
<button toolTip="Add a timezone" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hp6-CH-WJs">
<rect key="frame" x="8" y="4" width="60" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="r2L-5O-GZy"/>
<constraint firstAttribute="width" constant="60" id="yuH-LM-RAy"/>
</constraints>
<buttonCell key="cell" type="roundRect" title="Add" bezelStyle="roundedRect" imagePosition="left" alignment="center" borderStyle="border" inset="2" id="x6l-8x-qnu">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="cellTitle"/>
</buttonCell>
<connections>
<action selector="addToFavorites:" target="-2" id="Mdg-7P-kDy"/>
<binding destination="-2" name="enabled" keyPath="self.activityInProgress" id="aBp-GA-vQ3">
<dictionary key="options">
<string key="NSValueTransformerName">NSNegateBoolean</string>
</dictionary>
</binding>
<binding destination="-2" name="title" keyPath="self.buttonTitle" id="W5O-nY-Q3i"/>
</connections>
</button>
<searchField toolTip="Search a timezone" wantsLayer="YES" focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="biT-6m-ElR">
<rect key="frame" x="8" y="287" width="329" height="25"/>
<searchFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" borderStyle="bezel" focusRingType="none" placeholderString="Enter a city, state, country name" drawsBackground="YES" usesSingleLineMode="YES" id="ijc-z6-99E">
@ -336,7 +313,7 @@ CA
</connections>
</searchField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KFC-NV-5A3">
<rect key="frame" x="76" y="7" width="256" height="20"/>
<rect key="frame" x="102" y="7" width="230" height="20"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="rr3-gU-VUn"/>
</constraints>
@ -361,25 +338,60 @@ CA
<progressIndicator wantsLayer="YES" horizontalHuggingPriority="750" verticalHuggingPriority="750" maxValue="100" bezeled="NO" indeterminate="YES" controlSize="small" style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="ifx-PO-gfq">
<rect key="frame" x="75" y="134" width="16" height="16"/>
<connections>
<binding destination="-2" name="animate" keyPath="self.activityInProgress" id="S3o-gJ-W9p"/>
<binding destination="-2" name="hidden" keyPath="self.activityInProgress" id="9pA-XX-dhd">
<dictionary key="options">
<string key="NSValueTransformerName">NSNegateBoolean</string>
</dictionary>
</binding>
<binding destination="-2" name="animate" keyPath="self.activityInProgress" id="S3o-gJ-W9p"/>
</connections>
</progressIndicator>
<button toolTip="Add a timezone" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="cyZ-cL-S7a">
<rect key="frame" x="50" y="4" width="50" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="lku-Qx-nX5"/>
<constraint firstAttribute="width" constant="50" id="vqo-37-082"/>
</constraints>
<buttonCell key="cell" type="roundRect" title="Close" bezelStyle="roundedRect" imagePosition="left" alignment="center" borderStyle="border" inset="2" id="YjP-c4-vTl">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="cellTitle"/>
</buttonCell>
<connections>
<action selector="closePanel:" target="-2" id="YRs-VA-eFr"/>
</connections>
</button>
<button toolTip="Add a timezone" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hp6-CH-WJs">
<rect key="frame" x="8" y="4" width="40" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="r2L-5O-GZy"/>
<constraint firstAttribute="width" constant="40" id="yuH-LM-RAy"/>
</constraints>
<buttonCell key="cell" type="roundRect" title="Add" bezelStyle="roundedRect" imagePosition="left" alignment="center" borderStyle="border" inset="2" id="x6l-8x-qnu">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="cellTitle"/>
</buttonCell>
<connections>
<action selector="addToFavorites:" target="-2" id="Mdg-7P-kDy"/>
<binding destination="-2" name="enabled" keyPath="self.activityInProgress" id="aBp-GA-vQ3">
<dictionary key="options">
<string key="NSValueTransformerName">NSNegateBoolean</string>
</dictionary>
</binding>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="KFC-NV-5A3" firstAttribute="leading" secondItem="cyZ-cL-S7a" secondAttribute="trailing" constant="4" id="1i8-FW-qYz"/>
<constraint firstAttribute="trailing" secondItem="biT-6m-ElR" secondAttribute="trailing" constant="8" id="23X-dw-hpU"/>
<constraint firstItem="Wb6-yr-Pw4" firstAttribute="leading" secondItem="ifx-PO-gfq" secondAttribute="trailing" constant="9" id="9cg-iz-7Dq"/>
<constraint firstAttribute="trailing" secondItem="KFC-NV-5A3" secondAttribute="trailing" constant="15" id="B6V-vn-THO"/>
<constraint firstItem="LM9-75-vkc" firstAttribute="top" secondItem="biT-6m-ElR" secondAttribute="bottom" constant="3" id="DZR-XO-6sm"/>
<constraint firstAttribute="bottom" secondItem="KFC-NV-5A3" secondAttribute="bottom" constant="7" id="FWx-F1-VK8"/>
<constraint firstItem="KFC-NV-5A3" firstAttribute="leading" secondItem="hp6-CH-WJs" secondAttribute="trailing" constant="10" id="GYa-Tw-JN4"/>
<constraint firstItem="hp6-CH-WJs" firstAttribute="leading" secondItem="kXo-nl-oxR" secondAttribute="leading" constant="8" id="Oir-hL-Og8"/>
<constraint firstAttribute="bottom" secondItem="cyZ-cL-S7a" secondAttribute="bottom" constant="5" id="QQ1-JS-knf"/>
<constraint firstItem="biT-6m-ElR" firstAttribute="top" secondItem="kXo-nl-oxR" secondAttribute="top" constant="8" id="Y7N-oR-3KY"/>
<constraint firstItem="LM9-75-vkc" firstAttribute="leading" secondItem="kXo-nl-oxR" secondAttribute="leading" constant="8" id="ZJc-ws-AZR"/>
<constraint firstItem="cyZ-cL-S7a" firstAttribute="leading" secondItem="hp6-CH-WJs" secondAttribute="trailing" constant="2" id="g8m-TW-fLo"/>
<constraint firstAttribute="bottom" secondItem="hp6-CH-WJs" secondAttribute="bottom" constant="5" id="hEn-h1-my5"/>
<constraint firstItem="biT-6m-ElR" firstAttribute="leading" secondItem="kXo-nl-oxR" secondAttribute="leading" constant="8" id="nhU-xR-AW2"/>
<constraint firstAttribute="trailing" secondItem="LM9-75-vkc" secondAttribute="trailing" constant="8" id="pMs-Ol-hsh"/>

6
Clocker/Preferences/CLPreferencesViewController.h

@ -8,6 +8,11 @@
#import <Cocoa/Cocoa.h>
typedef enum : NSUInteger {
CLDefaultTheme,
CLBlackTheme
} CLTheme;
@interface CLPreferencesViewController : NSViewController
@property (strong, nonatomic) NSMutableArray *selectedTimeZones;
@ -16,6 +21,5 @@
@property (atomic, strong) NSArray *fontFamilies;
@property (atomic, strong) NSArray *themes;
@property (nonatomic, strong) NSURLSessionDataTask *dataTask;
@property (nonatomic, strong) NSString *buttonTitle;
@end

55
Clocker/Preferences/CLPreferencesViewController.m

@ -28,11 +28,11 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
@property (weak) IBOutlet NSTableView *timezoneTableView;
@property (strong) IBOutlet Panel *timezonePanel;
@property (weak) IBOutlet NSPopUpButton *themePopUp;
@property (weak) IBOutlet NSSegmentedControl *theme;
@property (weak) IBOutlet NSPopUpButton *fontPopUp;
@property (weak) IBOutlet NSTableView *availableTimezoneTableView;
@property (weak) IBOutlet NSSearchField *searchField;
@property (weak) IBOutlet NSButton *is24HourFormatSelected;
@property (weak) IBOutlet NSSegmentedControl *timeFormat;
@property (weak) IBOutlet NSTextField *messageLabel;
@end
@ -47,8 +47,6 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
[self.view setWantsLayer:YES];
[self.view setLayer:viewLayer];
self.buttonTitle = @"Close";
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(refereshTimezoneTableView) name:CLCustomLabelChangedNotification object:nil];
self.placeholderLabel.hidden = YES;
@ -181,18 +179,7 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
- (IBAction)addToFavorites:(id)sender
{
self.activityInProgress = YES;
if ([self.buttonTitle isEqualToString:@"Close"])
{
self.filteredArray = [NSMutableArray array];
self.placeholderLabel.placeholderString = CLEmptyString;
[self.availableTimezoneTableView reloadData];
self.searchField.stringValue = CLEmptyString;
[self.timezonePanel close];
self.activityInProgress = NO;
return;
}
if (self.availableTimezoneTableView.selectedRow == -1)
{
self.messageLabel.stringValue = @"Please select a timezone!";
@ -207,7 +194,6 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
{
self.messageLabel.stringValue = @"Maximum 10 timezones allowed!";
[NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(clearLabel) userInfo:nil repeats:NO];
NSLog(@"Maximum me ghusa");
self.activityInProgress = NO;
return;
}
@ -236,6 +222,18 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
[self getTimeZoneForLatitude:[self.filteredArray[self.availableTimezoneTableView.selectedRow] objectForKey:@"latitude"] andLongitude:[self.filteredArray[self.availableTimezoneTableView.selectedRow] objectForKey:@"longitude"]];
}
- (IBAction)closePanel:(id)sender {
self.filteredArray = [NSMutableArray array];
self.placeholderLabel.placeholderString = CLEmptyString;
[self.availableTimezoneTableView reloadData];
self.searchField.stringValue = CLEmptyString;
[self.timezonePanel close];
self.activityInProgress = NO;
}
- (void)clearLabel
{
self.messageLabel.stringValue = CLEmptyString;
@ -298,7 +296,6 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
}
self.placeholderLabel.placeholderString = CLEmptyString;
self.buttonTitle = @"Close";
}
[self.availableTimezoneTableView reloadData];
@ -306,9 +303,9 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
- (IBAction)timeFormatSelectionChanged:(id)sender {
NSButton *is24HourFormatSelected = (NSButton *)sender;
NSSegmentedControl *timeFormat = (NSSegmentedControl *)sender;
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInteger:is24HourFormatSelected.state] forKey:CL24hourFormatSelectedKey];
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInteger:timeFormat.selectedSegment] forKey:CL24hourFormatSelectedKey];
[self refreshMainTableview];
}
@ -391,12 +388,12 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
- (IBAction)changeTheme:(id)sender
{
NSPopUpButton *popUpButtonTitle = (NSPopUpButton *)sender;
NSSegmentedControl *themeSegment = (NSSegmentedControl *)sender;
ApplicationDelegate *appDelegate = [[NSApplication sharedApplication] delegate];
PanelController *panelController = appDelegate.panelController;
[panelController.backgroundView setNeedsDisplay:YES];
if ([[popUpButtonTitle titleOfSelectedItem] isEqualToString:@"Black"]) {
if (themeSegment.selectedSegment == CLBlackTheme) {
panelController.shutdownButton.image = [NSImage imageNamed:@"PowerIcon-White"];
panelController.preferencesButton.image = [NSImage imageNamed:@"Settings-White"];
}
@ -423,7 +420,6 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
if (networkStatus == NotReachable)
{
self.placeholderLabel.placeholderString = @"You're offline, maybe?";
self.buttonTitle = @"Close";
return;
}
@ -454,7 +450,7 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
self.dataTask= [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (!error) {
NSHTTPURLResponse *httpResp = (NSHTTPURLResponse*) response;
NSLog(@"Status Code:%zd", httpResp.statusCode);
if (httpResp.statusCode == 200) {
dispatch_async(dispatch_get_main_queue(), ^{
@ -467,7 +463,7 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
error:nil];
if ([json[@"status"] isEqualToString:@"ZERO_RESULTS"]) {
self.placeholderLabel.placeholderString = @"No results found!";
self.placeholderLabel.placeholderString = @"No results found! 😔";
self.activityInProgress = NO;
return;
}
@ -484,15 +480,13 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
CLTimezoneName:formattedAddress,
@"customLabel" : @"",
@"timezoneID" : @"",
@"placeID" : dictionary[@"place_id"]};
CLPlaceIdentifier : dictionary[@"place_id"]};
[self.filteredArray addObject:totalPackage];
}
self.activityInProgress = NO;
[self.availableTimezoneTableView reloadData];
self.buttonTitle = @"Add";
});
@ -524,7 +518,6 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
dispatch_async(dispatch_get_main_queue(), ^{
self.placeholderLabel.placeholderString = @"You're offline, maybe?";
self.activityInProgress = NO;
self.buttonTitle = @"Close";
self.filteredArray = [NSMutableArray array];
[self.availableTimezoneTableView reloadData];
});
@ -584,7 +577,8 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
@"sunriseTime" : json[@"sunrise"],
@"sunsetTime": json[@"sunset"],
CLCustomLabel : @"",
CLTimezoneName : filteredAddress};
CLTimezoneName : filteredAddress,
CLPlaceIdentifier : self.filteredArray[self.availableTimezoneTableView.selectedRow][CLPlaceIdentifier]};
NSArray *defaultPreference = [[NSUserDefaults standardUserDefaults] objectForKey:CLDefaultPreferenceKey];
@ -621,7 +615,6 @@ NSString *const CLPreferencesAvailableTimezoneIdentifier = @"availableTimezones"
}
else
{
self.placeholderLabel.placeholderString = [error.localizedDescription isEqualToString:@"The Internet connection appears to be offline."] ?
@"You're offline, maybe?" : @"Try again, maybe?";

2
Clocker/Reachability/Reachability.m

@ -21,7 +21,7 @@ NSString *kReachabilityChangedNotification = @"kNetworkReachabilityChangedNotifi
#pragma mark - Supporting functions
#define kShouldPrintReachabilityFlags 1
#define kShouldPrintReachabilityFlags 0
static void PrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment)
{

1
Clocker/Utilities/CommonStrings.h

@ -18,5 +18,6 @@ extern NSString *const CL24hourFormatSelectedKey;
extern NSString *const CLDragSessionKey;
extern NSString *const CLCustomLabelChangedNotification;
extern NSString *const CLTimezoneID;
extern NSString *const CLPlaceIdentifier;
@end

1
Clocker/Utilities/CommonStrings.m

@ -13,6 +13,7 @@
NSString *const CLEmptyString = @"";
NSString *const CLDefaultPreferenceKey = @"defaultPreferences";
NSString *const CLTimezoneName = @"formattedAddress";
NSString *const CLPlaceIdentifier = @"place_id";
NSString *const CLTimezoneID = @"timezoneID";
NSString *const CLCustomLabel = @"customLabel";
NSString *const CL24hourFormatSelectedKey = @"is24HourFormatSelected";

2
Media.xcassets/PowerIcon-White.imageset/Contents.json vendored

@ -2,7 +2,7 @@
"images" : [
{
"idiom" : "universal",
"filename" : "PowerIcon-Whitw2.png",
"filename" : "PowerIcon 2.png",
"scale" : "1x"
},
{

BIN
Media.xcassets/PowerIcon-White.imageset/PowerIcon 2.png vendored

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
Media.xcassets/PowerIcon-White.imageset/PowerIcon-Whitw2.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

BIN
Media.xcassets/Settings-White.imageset/Settings-White.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Loading…
Cancel
Save