diff options
author | siqi <me@siqi.fr> | 2013-07-08 21:06:07 +0200 |
---|---|---|
committer | siqi <me@siqi.fr> | 2013-07-08 21:06:07 +0200 |
commit | 4374e5c80525cd1a9d9ab04714ccbf2543a912ce (patch) | |
tree | e0adce41cc75d42f1b2e97890e638a1715f2492c /ios | |
parent | click on a slideshow in the nav bar will take users to the slide directly (diff) | |
download | core-4374e5c80525cd1a9d9ab04714ccbf2543a912ce.tar.gz core-4374e5c80525cd1a9d9ab04714ccbf2543a912ce.zip |
first functional version
Change-Id: Ia6ed1d8a29d7f5b09db5c815daabf4495e650d4d
Diffstat (limited to 'ios')
-rw-r--r-- | ios/iosremote/iosremote.xcodeproj/project.pbxproj | 12 | ||||
-rw-r--r-- | ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate | bin | 45861 -> 48996 bytes | |||
-rw-r--r-- | ios/iosremote/iosremote/en.lproj/MainStoryboard_iPhone.storyboard | 57 | ||||
-rw-r--r-- | ios/iosremote/iosremote/slideShowSwipeInList.h | 6 | ||||
-rw-r--r-- | ios/iosremote/iosremote/slideShowSwipeInList.m | 108 | ||||
-rw-r--r-- | ios/iosremote/iosremote/timer_pause_btn.png | bin | 0 -> 4756 bytes | |||
-rw-r--r-- | ios/iosremote/iosremote/timer_resume_btn.png | bin | 0 -> 4937 bytes |
7 files changed, 160 insertions, 23 deletions
diff --git a/ios/iosremote/iosremote.xcodeproj/project.pbxproj b/ios/iosremote/iosremote.xcodeproj/project.pbxproj index 558d3440693e..bd13696ae597 100644 --- a/ios/iosremote/iosremote.xcodeproj/project.pbxproj +++ b/ios/iosremote/iosremote.xcodeproj/project.pbxproj @@ -41,6 +41,8 @@ 57C6E42F175E076900E8BC5F /* CommunicationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 57C6E429175E076900E8BC5F /* CommunicationManager.m */; }; 57C6E430175E076900E8BC5F /* CommandInterpreter.m in Sources */ = {isa = PBXBuildFile; fileRef = 57C6E42B175E076900E8BC5F /* CommandInterpreter.m */; }; 57C6E431175E076900E8BC5F /* Server.m in Sources */ = {isa = PBXBuildFile; fileRef = 57C6E42D175E076900E8BC5F /* Server.m */; }; + 57CC48C6178B42A400075DE4 /* timer_pause_btn.png in Resources */ = {isa = PBXBuildFile; fileRef = 57CC48C4178B42A400075DE4 /* timer_pause_btn.png */; }; + 57CC48C7178B42A400075DE4 /* timer_resume_btn.png in Resources */ = {isa = PBXBuildFile; fileRef = 57CC48C5178B42A400075DE4 /* timer_resume_btn.png */; }; 57CFED9917838FDC00E82E05 /* EditableTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 57CFED9817838FDC00E82E05 /* EditableTableViewCell.m */; }; 57FE71E31785C61400B50125 /* pinValidation_vc.m in Sources */ = {isa = PBXBuildFile; fileRef = 57FE71E21785C61400B50125 /* pinValidation_vc.m */; }; 57FE71E61785D7FE00B50125 /* slideShowPreview_vc.m in Sources */ = {isa = PBXBuildFile; fileRef = 57FE71E51785D7FE00B50125 /* slideShowPreview_vc.m */; }; @@ -94,12 +96,14 @@ 57C6E40B175E06E800E8BC5F /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPhone.storyboard; sourceTree = "<group>"; }; 57C6E426175E076900E8BC5F /* Client.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Client.h; sourceTree = "<group>"; }; 57C6E427175E076900E8BC5F /* Client.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Client.m; sourceTree = "<group>"; }; - 57C6E428175E076900E8BC5F /* CommunicationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommunicationManager.h; sourceTree = "<group>"; }; - 57C6E429175E076900E8BC5F /* CommunicationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommunicationManager.m; sourceTree = "<group>"; }; + 57C6E428175E076900E8BC5F /* CommunicationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = CommunicationManager.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 57C6E429175E076900E8BC5F /* CommunicationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CommunicationManager.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 57C6E42A175E076900E8BC5F /* CommandInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandInterpreter.h; sourceTree = "<group>"; }; 57C6E42B175E076900E8BC5F /* CommandInterpreter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommandInterpreter.m; sourceTree = "<group>"; }; 57C6E42C175E076900E8BC5F /* Server.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Server.h; sourceTree = "<group>"; }; 57C6E42D175E076900E8BC5F /* Server.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Server.m; sourceTree = "<group>"; }; + 57CC48C4178B42A400075DE4 /* timer_pause_btn.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = timer_pause_btn.png; path = iosremote/timer_pause_btn.png; sourceTree = "<group>"; }; + 57CC48C5178B42A400075DE4 /* timer_resume_btn.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = timer_resume_btn.png; path = iosremote/timer_resume_btn.png; sourceTree = "<group>"; }; 57CFED9717838FDC00E82E05 /* EditableTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditableTableViewCell.h; sourceTree = "<group>"; }; 57CFED9817838FDC00E82E05 /* EditableTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EditableTableViewCell.m; sourceTree = "<group>"; }; 57FE71E11785C61300B50125 /* pinValidation_vc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pinValidation_vc.h; path = Communication/pinValidation_vc.h; sourceTree = "<group>"; }; @@ -151,6 +155,8 @@ 57AEEDAA1788D7B2007F4F97 /* Assets */ = { isa = PBXGroup; children = ( + 57CC48C4178B42A400075DE4 /* timer_pause_btn.png */, + 57CC48C5178B42A400075DE4 /* timer_resume_btn.png */, 571BFAD0178AADA200EF1BDB /* more_icon.png */, 57AEEDB417899BB4007F4F97 /* slide_finished.png */, 57AEEDB017895BF5007F4F97 /* pointer_pushed.png */, @@ -333,6 +339,8 @@ 571BFAD1178AADA200EF1BDB /* more_icon.png in Resources */, 571D4807178B2F080063D93B /* timer_clear_btn.png in Resources */, 571D4808178B2F080063D93B /* timer_start_btn.png in Resources */, + 57CC48C6178B42A400075DE4 /* timer_pause_btn.png in Resources */, + 57CC48C7178B42A400075DE4 /* timer_resume_btn.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate b/ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate Binary files differindex f9706f214a64..13fb9f55ebeb 100644 --- a/ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate +++ b/ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate diff --git a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPhone.storyboard b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPhone.storyboard index d5a629025b35..b64e5f59b175 100644 --- a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPhone.storyboard +++ b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPhone.storyboard @@ -235,16 +235,16 @@ <rect key="frame" x="0.0" y="0.0" width="320" height="131"/> <autoresizingMask key="autoresizingMask"/> <subviews> - <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="00:00:00" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JsJ-ic-uyC"> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="1" contentMode="left" text="00:00:00" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JsJ-ic-uyC"> <constraints> - <constraint firstAttribute="height" constant="56" id="7o1-Sm-4pn"/> - <constraint firstAttribute="width" constant="213" id="Yak-Oz-mwe"/> + <constraint firstAttribute="width" constant="220" type="user" id="8Gg-8f-cT7"/> + <constraint firstAttribute="height" constant="60" type="user" id="M2t-hC-QqV"/> </constraints> - <fontDescription key="fontDescription" type="system" pointSize="45"/> + <fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="39"/> <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <color key="highlightedColor" white="1" alpha="1" colorSpace="calibratedWhite"/> </label> - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Fmn-lt-vBn"> + <button opaque="NO" tag="2" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Fmn-lt-vBn"> <constraints> <constraint firstAttribute="width" constant="44" id="7ff-i8-MnF"/> <constraint firstAttribute="height" constant="44" id="Pef-te-m1Y"/> @@ -257,6 +257,9 @@ <state key="highlighted"> <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/> </state> + <connections> + <action selector="stopWatchStart:" destination="5d0-J5-Cal" eventType="touchUpInside" id="887-jd-VmR"/> + </connections> </button> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="EVu-he-FS4"> <constraints> @@ -270,19 +273,48 @@ <state key="highlighted"> <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/> </state> + <connections> + <action selector="stopWatchClear:" destination="5d0-J5-Cal" eventType="touchUpInside" id="uua-50-63G"/> + </connections> </button> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Hours" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3UQ-XJ-SDP"> + <constraints> + <constraint firstAttribute="height" constant="21" id="LwO-US-j6S"/> + </constraints> + <fontDescription key="fontDescription" type="system" pointSize="12"/> + <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> + <color key="highlightedColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + </label> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Minutes" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="TqG-sM-lAC"> + <fontDescription key="fontDescription" type="system" pointSize="12"/> + <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> + <color key="highlightedColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + </label> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Seconds" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6jG-LW-J7Q"> + <fontDescription key="fontDescription" type="system" pointSize="12"/> + <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> + <color key="highlightedColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + </label> </subviews> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> </view> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <constraints> - <constraint firstItem="JsJ-ic-uyC" firstAttribute="leading" secondItem="hig-YG-1Lg" secondAttribute="leading" constant="20" type="default" id="0YN-U0-8Pa"/> - <constraint firstItem="Fmn-lt-vBn" firstAttribute="leading" secondItem="hig-YG-1Lg" secondAttribute="leading" constant="70" id="DKO-d3-AHl"/> - <constraint firstAttribute="bottom" secondItem="Fmn-lt-vBn" secondAttribute="bottom" constant="14" id="LPb-LS-NNv"/> - <constraint firstItem="JsJ-ic-uyC" firstAttribute="top" secondItem="hig-YG-1Lg" secondAttribute="top" constant="14" id="MIv-bn-BMI"/> + <constraint firstItem="TqG-sM-lAC" firstAttribute="top" secondItem="6jG-LW-J7Q" secondAttribute="top" type="default" id="0fA-Dm-47U"/> + <constraint firstItem="EVu-he-FS4" firstAttribute="top" secondItem="Fmn-lt-vBn" secondAttribute="top" type="default" id="99Y-4S-1aN"/> + <constraint firstItem="3UQ-XJ-SDP" firstAttribute="top" secondItem="TqG-sM-lAC" secondAttribute="top" type="default" id="AtJ-JE-Pqz"/> + <constraint firstItem="Fmn-lt-vBn" firstAttribute="leading" secondItem="hig-YG-1Lg" secondAttribute="leading" constant="61" id="GVV-6L-l4W"/> + <constraint firstItem="EVu-he-FS4" firstAttribute="leading" secondItem="hig-YG-1Lg" secondAttribute="leading" constant="130" id="JEc-bR-rF8"/> + <constraint firstItem="TqG-sM-lAC" firstAttribute="baseline" secondItem="3UQ-XJ-SDP" secondAttribute="baseline" type="default" id="O8m-Cg-3ma"/> + <constraint firstItem="6jG-LW-J7Q" firstAttribute="leading" secondItem="JsJ-ic-uyC" secondAttribute="trailing" constant="-75" type="user" id="V4J-LN-DQ5"/> + <constraint firstItem="TqG-sM-lAC" firstAttribute="leading" secondItem="hig-YG-1Lg" secondAttribute="leading" constant="101" id="a80-Ly-6HQ"/> + <constraint firstItem="3UQ-XJ-SDP" firstAttribute="top" secondItem="hig-YG-1Lg" secondAttribute="top" constant="47" id="e4B-LI-KYX"/> <constraint firstItem="Fmn-lt-vBn" firstAttribute="bottom" secondItem="EVu-he-FS4" secondAttribute="bottom" type="default" id="fMf-BD-LAf"/> - <constraint firstItem="EVu-he-FS4" firstAttribute="top" secondItem="Fmn-lt-vBn" secondAttribute="top" type="default" id="nrz-wB-UvB"/> - <constraint firstItem="EVu-he-FS4" firstAttribute="leading" secondItem="hig-YG-1Lg" secondAttribute="leading" constant="139" id="o5t-v1-DIw"/> + <constraint firstItem="JsJ-ic-uyC" firstAttribute="leading" secondItem="hig-YG-1Lg" secondAttribute="leading" constant="11" id="g9d-KM-GbM"/> + <constraint firstAttribute="bottom" secondItem="Fmn-lt-vBn" secondAttribute="bottom" constant="11" id="hBN-Is-hCr"/> + <constraint firstItem="6jG-LW-J7Q" firstAttribute="baseline" secondItem="TqG-sM-lAC" secondAttribute="baseline" type="default" id="hcq-ha-5YG"/> + <constraint firstItem="JsJ-ic-uyC" firstAttribute="top" secondItem="hig-YG-1Lg" secondAttribute="top" type="default" id="hgW-2z-759"/> + <constraint firstItem="3UQ-XJ-SDP" firstAttribute="leading" secondItem="hig-YG-1Lg" secondAttribute="leading" constant="48" id="zV7-CU-RWk"/> </constraints> </tableViewCell> <tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="slide" rowHeight="132" id="dDp-H3-HyL"> @@ -713,13 +745,14 @@ <class className="slideShowPreviewTable_vc" superclassName="UITableViewController"> <source key="sourceIdentifier" type="project" relativePath="./Classes/slideShowPreviewTable_vc.h"/> <relationships> - <relationship kind="action" name="startPresentationAction:"/> <relationship kind="outlet" name="optionsTable" candidateClass="UITableView"/> </relationships> </class> <class className="slideShowSwipeInList" superclassName="UITableViewController"> <source key="sourceIdentifier" type="project" relativePath="./Classes/slideShowSwipeInList.h"/> <relationships> + <relationship kind="action" name="stopWatchClear:"/> + <relationship kind="action" name="stopWatchStart:"/> <relationship kind="outlet" name="slidesTable" candidateClass="UITableView"/> </relationships> </class> diff --git a/ios/iosremote/iosremote/slideShowSwipeInList.h b/ios/iosremote/iosremote/slideShowSwipeInList.h index 0cb9c52094fb..b614c703b7b2 100644 --- a/ios/iosremote/iosremote/slideShowSwipeInList.h +++ b/ios/iosremote/iosremote/slideShowSwipeInList.h @@ -9,6 +9,12 @@ #import <UIKit/UIKit.h> @interface slideShowSwipeInList : UITableViewController <UITableViewDataSource, UITableViewDelegate> +// StopWatch +- (IBAction)stopWatchStart:(id)sender; +- (IBAction)stopWatchClear:(id)sender; +@property (strong, nonatomic) NSTimer *stopWatchTimer; +@property (strong, nonatomic) NSDate *startDate; + @property (strong, nonatomic) IBOutlet UITableView *slidesTable; diff --git a/ios/iosremote/iosremote/slideShowSwipeInList.m b/ios/iosremote/iosremote/slideShowSwipeInList.m index c477c64a55cb..7291b26fc071 100644 --- a/ios/iosremote/iosremote/slideShowSwipeInList.m +++ b/ios/iosremote/iosremote/slideShowSwipeInList.m @@ -13,24 +13,34 @@ #import "CommandTransmitter.h" #import "SWRevealViewController.h" +#define TIMER_STATE_RUNNING 0 +#define TIMER_STATE_PAUSED 1 +#define TIMER_STATE_CLEARED 2 + @interface slideShowSwipeInList () @property (nonatomic, strong) CommunicationManager *comManager; @property (nonatomic, strong) SlideShow *slideshow; +@property NSTimeInterval lastInterval; +@property int state; @end @implementation slideShowSwipeInList @synthesize comManager = _comManager; @synthesize slideshow = _slideshow; +@synthesize lastInterval = _lastInterval; + +dispatch_queue_t backgroundQueue; - (void) viewDidLoad { [super viewDidLoad]; - + self.comManager = [CommunicationManager sharedComManager]; self.slideshow = self.comManager.interpreter.slideShow; self.slideshow.secondaryDelegate = self; + self.state = TIMER_STATE_CLEARED; } - (void) prepareForSegue: (UIStoryboardSegue *) segue sender: (id) sender @@ -41,17 +51,17 @@ if ( [segue isKindOfClass: [SWRevealViewControllerSegue class]] ) { SWRevealViewControllerSegue* rvcs = (SWRevealViewControllerSegue*) segue; - + SWRevealViewController* rvc = self.revealViewController; NSAssert( rvc != nil, @"oops! must have a revealViewController" ); - + NSAssert( [rvc.frontViewController isKindOfClass: [UINavigationController class]], @"oops! for this segue we want a permanent navigation controller in the front!" ); - + rvcs.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc) { - + UINavigationController* nc = (UINavigationController*)rvc.frontViewController; [nc setViewControllers: @[ dvc ] animated: YES ]; - + [rvc setFrontViewPosition: FrontViewPositionLeft animated: YES]; }; } @@ -69,17 +79,17 @@ { if (indexPath.row == 0) { static NSString *CellIdentifier = @"stopWatch"; - + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier]; [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; cell.contentView.backgroundColor = [UIColor whiteColor]; return cell; } else { static NSString *CellIdentifier = @"slide"; - + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier]; UILabel * slideNumber = (UILabel *)[cell viewWithTag:2]; - + [cell setTag:20+indexPath.row]; [self.slideshow getContentAtIndex:indexPath.row-1 forView:cell]; [slideNumber setText:[NSString stringWithFormat:@"%u", indexPath.row]]; @@ -90,6 +100,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + if (indexPath.row == 0) + return; [self.comManager.transmitter gotoSlide:indexPath.row - 1]; [self.revealViewController revealToggle: self]; [tableView deselectRowAtIndexPath:indexPath animated:YES]; @@ -100,4 +112,82 @@ [self setSlidesTable:nil]; [super viewDidUnload]; } + +- (void)updateTimer +{ + // Create date from the elapsed time + NSDate *currentDate = [NSDate date]; + NSTimeInterval timeInterval = [currentDate timeIntervalSinceDate:self.startDate] + self.lastInterval; + NSDate *timerDate = [NSDate dateWithTimeIntervalSince1970:timeInterval]; + + // Create a date formatter + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + [dateFormatter setDateFormat:@"HH:mm:ss"]; + [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0.0]]; + + // Format the elapsed time and set it to the label + NSString *timeString = [dateFormatter stringFromDate:timerDate]; + UILabel *l = (UILabel *)[[self.slidesTable cellForRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]] viewWithTag:1]; + l.text = timeString; +} + + +- (IBAction)stopWatchStart:(id)sender { + switch (self.state) { + case TIMER_STATE_RUNNING: + self.state = TIMER_STATE_PAUSED; + [self.stopWatchTimer invalidate]; + self.lastInterval += [[NSDate date] timeIntervalSinceDate:self.startDate]; + break; + case TIMER_STATE_PAUSED: + self.state = TIMER_STATE_RUNNING; + self.startDate = [NSDate date]; + self.stopWatchTimer = [NSTimer scheduledTimerWithTimeInterval:1.0/10.0 + target:self + selector:@selector(updateTimer) + userInfo:nil + repeats:YES]; + break; + case TIMER_STATE_CLEARED: + self.state = TIMER_STATE_RUNNING; + self.startDate = [NSDate date]; + // Create the stop watch timer that fires every 100 ms + self.stopWatchTimer = [NSTimer scheduledTimerWithTimeInterval:1.0/10.0 + target:self + selector:@selector(updateTimer) + userInfo:nil + repeats:YES]; + break; + default: + break; + } + + UIButton * btn = (UIButton *)sender; + + switch (self.state) { + case TIMER_STATE_RUNNING: + [btn setImage:[UIImage imageNamed:@"timer_pause_btn"] forState:UIControlStateNormal]; + break; + case TIMER_STATE_PAUSED: + [btn setImage:[UIImage imageNamed:@"timer_resume_btn"] forState:UIControlStateNormal]; + break; + case TIMER_STATE_CLEARED: + [btn setImage:[UIImage imageNamed:@"timer_start_btn"] forState:UIControlStateNormal]; + break; + default: + break; + } +} + +- (IBAction)stopWatchClear:(id)sender { + [self.stopWatchTimer invalidate]; + self.stopWatchTimer = nil; + self.startDate = [NSDate date]; + self.lastInterval = 0; + self.state = TIMER_STATE_CLEARED; + + UIButton *l = (UIButton *)[[self.slidesTable cellForRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]] viewWithTag:2]; + [l setImage:[UIImage imageNamed:@"timer_start_btn"] forState:UIControlStateNormal]; + [self updateTimer]; +} @end diff --git a/ios/iosremote/iosremote/timer_pause_btn.png b/ios/iosremote/iosremote/timer_pause_btn.png Binary files differnew file mode 100644 index 000000000000..c2829d5f06a5 --- /dev/null +++ b/ios/iosremote/iosremote/timer_pause_btn.png diff --git a/ios/iosremote/iosremote/timer_resume_btn.png b/ios/iosremote/iosremote/timer_resume_btn.png Binary files differnew file mode 100644 index 000000000000..fc980b11b71f --- /dev/null +++ b/ios/iosremote/iosremote/timer_resume_btn.png |