diff options
author | siqi <me@siqi.fr> | 2013-07-12 11:31:34 +0200 |
---|---|---|
committer | siqi <me@siqi.fr> | 2013-07-12 11:31:48 +0200 |
commit | 544fd39ed3abe5d5a1699ae009c6ff797a3dfba6 (patch) | |
tree | 19c6ec6011c2313c38e84540a06e31415397f50c /ios | |
parent | d3c31b6fccd605ced0c7657916c38cda02206b11 (diff) |
swipe in sidebar improvement
Change-Id: I7834d5ae8013004d080d433e4625a0a60bd5877a
Diffstat (limited to 'ios')
-rw-r--r-- | ios/iosremote/iosremote.xcodeproj/project.pbxproj | 26 | ||||
-rw-r--r-- | ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate | bin | 68048 -> 70600 bytes | |||
-rw-r--r-- | ios/iosremote/iosremote/Communication/Client.h | 3 | ||||
-rw-r--r-- | ios/iosremote/iosremote/Communication/Client.m | 16 | ||||
-rw-r--r-- | ios/iosremote/iosremote/Communication/CommandInterpreter.m | 4 | ||||
-rw-r--r-- | ios/iosremote/iosremote/Communication/CommunicationManager.h | 1 | ||||
-rw-r--r-- | ios/iosremote/iosremote/Communication/CommunicationManager.m | 5 | ||||
-rw-r--r-- | ios/iosremote/iosremote/en.lproj/iPhone_autolayout.storyboard | 18 | ||||
-rw-r--r-- | ios/iosremote/iosremote/serverList_vc.m | 4 | ||||
-rw-r--r-- | ios/iosremote/iosremote/slideShowSwipeInList.h | 3 | ||||
-rw-r--r-- | ios/iosremote/iosremote/slideShowSwipeInList.m | 69 |
11 files changed, 103 insertions, 46 deletions
diff --git a/ios/iosremote/iosremote.xcodeproj/project.pbxproj b/ios/iosremote/iosremote.xcodeproj/project.pbxproj index 89b16eaef7a7..7b8bddecffe7 100644 --- a/ios/iosremote/iosremote.xcodeproj/project.pbxproj +++ b/ios/iosremote/iosremote.xcodeproj/project.pbxproj @@ -49,6 +49,7 @@ 57DC7007178D84490050FC58 /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57DC7006178D84490050FC58 /* CoreMotion.framework */; }; 57DC700F178E03330050FC58 /* touchPointer_vc.m in Sources */ = {isa = PBXBuildFile; fileRef = 57DC700E178E03330050FC58 /* touchPointer_vc.m */; }; 57DC7012178E16A40050FC58 /* setRecursiveUserInteraction.m in Sources */ = {isa = PBXBuildFile; fileRef = 57DC7011178E16A40050FC58 /* setRecursiveUserInteraction.m */; }; + 57DF0A85178FFFAB008B2D3D /* iPhone_spring&strut.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 57DF0A83178FFFAB008B2D3D /* iPhone_spring&strut.storyboard */; }; 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 */; }; 57FE71E917861A9000B50125 /* slideShowPreviewTable_vc.m in Sources */ = {isa = PBXBuildFile; fileRef = 57FE71E817861A9000B50125 /* slideShowPreviewTable_vc.m */; }; @@ -118,6 +119,7 @@ 57DC700E178E03330050FC58 /* touchPointer_vc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = touchPointer_vc.m; sourceTree = "<group>"; }; 57DC7010178E16A40050FC58 /* setRecursiveUserInteraction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = setRecursiveUserInteraction.h; sourceTree = "<group>"; }; 57DC7011178E16A40050FC58 /* setRecursiveUserInteraction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = setRecursiveUserInteraction.m; sourceTree = "<group>"; }; + 57DF0A84178FFFAB008B2D3D /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = "en.lproj/iPhone_spring&strut.storyboard"; 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>"; }; 57FE71E21785C61400B50125 /* pinValidation_vc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = pinValidation_vc.m; path = Communication/pinValidation_vc.m; sourceTree = "<group>"; }; 57FE71E41785D7FE00B50125 /* slideShowPreview_vc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = slideShowPreview_vc.h; sourceTree = "<group>"; }; @@ -237,12 +239,10 @@ isa = PBXGroup; children = ( 57C6E3F9175E06E800E8BC5F /* Supporting Files */, - 57C6E40A175E06E800E8BC5F /* iPhone_autolayout.storyboard */, + 57DF0A78178FFF8C008B2D3D /* StoryBoards */, 57FE71E11785C61300B50125 /* pinValidation_vc.h */, 57FE71E21785C61400B50125 /* pinValidation_vc.m */, 57AEEDAB1789443D007F4F97 /* slideShowPreview */, - 57C6E401175E06E800E8BC5F /* AppDelegate.h */, - 57C6E402175E06E800E8BC5F /* AppDelegate.m */, 571BFAD2178AB7BA00EF1BDB /* slideShow */, 5753DD9717834D7100DB71BB /* newServer_vc.h */, 5753DD9817834D7100DB71BB /* newServer_vc.m */, @@ -258,6 +258,8 @@ 57701736178AC83E00B99793 /* SWRevealViewController */, 57B152971764703500EECC67 /* Base64.h */, 57B152981764703500EECC67 /* Base64.m */, + 57C6E401175E06E800E8BC5F /* AppDelegate.h */, + 57C6E402175E06E800E8BC5F /* AppDelegate.m */, 57CFED9717838FDC00E82E05 /* EditableTableViewCell.h */, 57CFED9817838FDC00E82E05 /* EditableTableViewCell.m */, 57C6E3FA175E06E800E8BC5F /* iosremote-Info.plist */, @@ -291,6 +293,15 @@ path = iosremote/Communication; sourceTree = "<group>"; }; + 57DF0A78178FFF8C008B2D3D /* StoryBoards */ = { + isa = PBXGroup; + children = ( + 57DF0A83178FFFAB008B2D3D /* iPhone_spring&strut.storyboard */, + 57C6E40A175E06E800E8BC5F /* iPhone_autolayout.storyboard */, + ); + name = StoryBoards; + sourceTree = "<group>"; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -363,6 +374,7 @@ 57CC48C7178B42A400075DE4 /* timer_resume_btn.png in Resources */, 57DC7003178D82610050FC58 /* ic_launcher.png in Resources */, 57DC7005178D82940050FC58 /* ic_launcher@2x.png in Resources */, + 57DF0A85178FFFAB008B2D3D /* iPhone_spring&strut.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -416,6 +428,14 @@ name = iPhone_autolayout.storyboard; sourceTree = "<group>"; }; + 57DF0A83178FFFAB008B2D3D /* iPhone_spring&strut.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 57DF0A84178FFFAB008B2D3D /* en */, + ); + name = "iPhone_spring&strut.storyboard"; + sourceTree = "<group>"; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 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 78e830a65245..931853b20a8f 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/Communication/Client.h b/ios/iosremote/iosremote/Communication/Client.h index 51674fd6b3d7..50f1d4019a3d 100644 --- a/ios/iosremote/iosremote/Communication/Client.h +++ b/ios/iosremote/iosremote/Communication/Client.h @@ -28,6 +28,9 @@ - (void) sendCommand:(NSString *)aCommand; +- (void)startConnectionTimeoutTimerwithInterval:(double) interval; +- (void)stopConnectionTimeoutTimer; + -(void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode; @end
\ No newline at end of file diff --git a/ios/iosremote/iosremote/Communication/Client.m b/ios/iosremote/iosremote/Communication/Client.m index 09fdf6a259ea..1320de1a2d27 100644 --- a/ios/iosremote/iosremote/Communication/Client.m +++ b/ios/iosremote/iosremote/Communication/Client.m @@ -11,6 +11,7 @@ #import "Server.h" #import "CommandInterpreter.h" #import "CommunicationManager.h" +#import "serverList_vc.h" #define CHARSET @"UTF-8" @@ -60,12 +61,11 @@ dispatch_queue_t backgroundQueue; return self; } -- (void)startConnectionTimeoutTimer +#pragma mark - Connection timeout handling +- (void)startConnectionTimeoutTimerwithInterval:(double) interval { [self stopConnectionTimeoutTimer]; // Or make sure any existing timer is stopped before this method is called - NSTimeInterval interval = 3.0; // Measured in seconds, is a double - self.connectionTimeoutTimer = [NSTimer scheduledTimerWithTimeInterval:interval target:self selector:@selector(handleConnectionTimeout) @@ -75,9 +75,11 @@ dispatch_queue_t backgroundQueue; - (void)handleConnectionTimeout { - NSLog(@"handleConnectionTimeout"); - [self disconnect]; - [[NSNotificationCenter defaultCenter]postNotificationName:@"connection.status.disconnected" object:nil]; + if (self.comManager.state == CONNECTING){ + NSLog(@"handleConnectionTimeout"); + [self disconnect]; + [[NSNotificationCenter defaultCenter]postNotificationName:@"connection.status.disconnected" object:nil]; + } } - (void)dealloc @@ -224,7 +226,7 @@ int count = 0; - (void) connect { - [self startConnectionTimeoutTimer]; + [self startConnectionTimeoutTimerwithInterval:3.0]; backgroundQueue = dispatch_queue_create("com.libreoffice.iosremote", NULL); dispatch_async(backgroundQueue, ^(void) { [self streamOpenWithIp:self.server.serverAddress withPortNumber:self.mPort]; diff --git a/ios/iosremote/iosremote/Communication/CommandInterpreter.m b/ios/iosremote/iosremote/Communication/CommandInterpreter.m index c3455ca71334..4c1b2f5a198a 100644 --- a/ios/iosremote/iosremote/Communication/CommandInterpreter.m +++ b/ios/iosremote/iosremote/Communication/CommandInterpreter.m @@ -78,7 +78,7 @@ dispatch_queue_t backgroundQueue; [[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_CHANGED object:nil]; marker = 3; } else if ([instruction isEqualToString:@"slide_preview"]){ - NSLog(@"Interpreter: slide_preview"); +// NSLog(@"Interpreter: slide_preview"); backgroundQueue = dispatch_queue_create("com.libreoffice.iosremote", NULL); dispatch_async(backgroundQueue, ^(void) { uint slideNumber = [[command objectAtIndex:1] integerValue]; @@ -88,7 +88,7 @@ dispatch_queue_t backgroundQueue; }); marker = 4; } else if ([instruction isEqualToString:@"slide_notes"]){ - NSLog(@"Interpreter: slide_notes"); +// NSLog(@"Interpreter: slide_notes"); backgroundQueue = dispatch_queue_create("com.libreoffice.iosremote", NULL); uint slideNumber = [[command objectAtIndex:1] integerValue]; NSMutableString *notes = [[NSMutableString alloc] init]; diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.h b/ios/iosremote/iosremote/Communication/CommunicationManager.h index 2c57dc02b1c6..d4a1f75dd05d 100644 --- a/ios/iosremote/iosremote/Communication/CommunicationManager.h +++ b/ios/iosremote/iosremote/Communication/CommunicationManager.h @@ -72,6 +72,7 @@ enum ConnectionState : NSInteger { @property ConnectionState state; @property (nonatomic, strong) id delegate; @property (atomic, strong) NSMutableArray* servers; +@property (nonatomic, strong) Client* client; @property (nonatomic, strong) CommandInterpreter* interpreter; @property (nonatomic, strong) CommandTransmitter* transmitter; diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.m b/ios/iosremote/iosremote/Communication/CommunicationManager.m index 52a826616955..683f1f7f3e5b 100644 --- a/ios/iosremote/iosremote/Communication/CommunicationManager.m +++ b/ios/iosremote/iosremote/Communication/CommunicationManager.m @@ -19,9 +19,6 @@ #define ExistingServersKey @"CommunicationManager.ExistingServers" @interface CommunicationManager() - -@property (nonatomic, strong) Client* client; - @end // Singlton Pattern @@ -52,6 +49,8 @@ if([[note name] isEqualToString:@"connection.status.connected"]){ if (self.state!=CONNECTED){ NSLog(@"Connected, waiting for pairing response"); + // A 5 seconds timer waiting for pairing response. + [self.client startConnectionTimeoutTimerwithInterval:5.0]; self.transmitter = [[CommandTransmitter alloc] initWithClient:self.client]; } } else if ([[note name] isEqualToString:@"connection.status.disconnected"]){ diff --git a/ios/iosremote/iosremote/en.lproj/iPhone_autolayout.storyboard b/ios/iosremote/iosremote/en.lproj/iPhone_autolayout.storyboard index c900f65aeeec..850d83faab3c 100644 --- a/ios/iosremote/iosremote/en.lproj/iPhone_autolayout.storyboard +++ b/ios/iosremote/iosremote/en.lproj/iPhone_autolayout.storyboard @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="3084" systemVersion="13A497d" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="qoG-TN-hN0"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="3084" systemVersion="13A510d" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="qoG-TN-hN0"> <dependencies> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="2083"/> </dependencies> @@ -330,14 +330,17 @@ <constraint firstAttribute="height" constant="122" id="idF-T1-zdQ"/> </constraints> </imageView> - <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="2" contentMode="left" text="1" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" minimumScaleFactor="1" preferredMaxLayoutWidth="29" translatesAutoresizingMaskIntoConstraints="NO" id="yWM-Nx-KmF"> + <label clipsSubviews="YES" userInteractionEnabled="NO" tag="2" contentMode="left" text="1" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="1" highlighted="YES" translatesAutoresizingMaskIntoConstraints="NO" id="yWM-Nx-KmF"> <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/> + <accessibility key="accessibilityConfiguration"> + <accessibilityTraits key="traits" none="YES" selected="YES" staticText="YES"/> + </accessibility> <constraints> <constraint firstAttribute="width" constant="29" id="d7p-Jx-M0G"/> </constraints> <fontDescription key="fontDescription" type="system" pointSize="17"/> <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/> - <color key="highlightedColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + <nil key="highlightedColor"/> </label> </subviews> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> @@ -358,9 +361,6 @@ <outlet property="delegate" destination="5d0-J5-Cal" id="QXg-wT-RSm"/> </connections> </tableView> - <connections> - <outlet property="slidesTable" destination="Ke1-ze-r00" id="Jvb-7c-oza"/> - </connections> </tableViewController> <placeholder placeholderIdentifier="IBFirstResponder" id="Fb5-Zn-HeE" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> @@ -721,9 +721,8 @@ <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2Zo-K8-3NM"> <subviews> - <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Title of the presentation" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="5" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="178" translatesAutoresizingMaskIntoConstraints="NO" id="nJf-ed-YfY"> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Title of the presentation(TODO)" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="5" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="178" translatesAutoresizingMaskIntoConstraints="NO" id="nJf-ed-YfY"> <constraints> - <constraint firstAttribute="height" constant="56" type="user" id="VUf-zJ-vPG"/> <constraint firstAttribute="width" constant="178" id="wto-RF-nap"/> </constraints> <fontDescription key="fontDescription" type="boldSystem" pointSize="25"/> @@ -773,7 +772,6 @@ <constraint firstItem="g5m-gQ-o0u" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="2Zo-K8-3NM" secondAttribute="leading" constant="32" type="user" id="VP2-HW-0K1"/> <constraint firstItem="Dds-oJ-Uhh" firstAttribute="leading" secondItem="mrB-Wd-OcP" secondAttribute="leading" type="user" id="WW4-GU-mSH"/> <constraint firstItem="Dds-oJ-Uhh" firstAttribute="top" secondItem="g5m-gQ-o0u" secondAttribute="bottom" constant="8" symbolic="YES" type="user" id="gtQ-av-tu7"/> - <constraint firstAttribute="bottom" secondItem="mrB-Wd-OcP" secondAttribute="bottom" constant="20" symbolic="YES" type="user" id="imp-d1-gQ3"/> <constraint firstAttribute="height" constant="169" type="user" id="kbX-jk-qBX"/> <constraint firstItem="nJf-ed-YfY" firstAttribute="centerX" secondItem="2Zo-K8-3NM" secondAttribute="centerX" type="default" id="qYz-zW-Lfz"/> <constraint firstItem="nJf-ed-YfY" firstAttribute="top" secondItem="2Zo-K8-3NM" secondAttribute="top" constant="20" symbolic="YES" type="user" id="qcW-Ip-dGx"/> @@ -840,7 +838,6 @@ <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> @@ -849,7 +846,6 @@ <relationships> <relationship kind="action" name="stopWatchClear:"/> <relationship kind="action" name="stopWatchStart:"/> - <relationship kind="outlet" name="slidesTable" candidateClass="UITableView"/> </relationships> </class> <class className="slideShow_vc" superclassName="UIViewController"> diff --git a/ios/iosremote/iosremote/serverList_vc.m b/ios/iosremote/iosremote/serverList_vc.m index 8493ff5a3571..5d26463a9d49 100644 --- a/ios/iosremote/iosremote/serverList_vc.m +++ b/ios/iosremote/iosremote/serverList_vc.m @@ -10,6 +10,7 @@ #import "CommunicationManager.h" #import "newServer_vc.h" #import "Server.h" +#import "Client.h" @interface server_list_vc () @@ -61,6 +62,7 @@ object:nil queue:mainQueue usingBlock:^(NSNotification *note) { + [self.comManager.client stopConnectionTimeoutTimer]; self.comManager.state = CONNECTED; [self disableSpinner]; [self performSegueWithIdentifier:@"pinValidation" sender:self ]; @@ -69,6 +71,7 @@ object:nil queue:mainQueue usingBlock:^(NSNotification *note) { + [self.comManager.client stopConnectionTimeoutTimer]; self.comManager.state = CONNECTED; [self disableSpinner]; [self performSegueWithIdentifier:@"SlideShowPreview" sender:self ]; @@ -128,7 +131,6 @@ } NSLog(@"Connecting to %@:%@", [[self.comManager.servers objectAtIndex:indexPath.row] serverName], [[self.comManager.servers objectAtIndex:indexPath.row] serverAddress]); - self.comManager.delegate = self; [self.comManager connectToServer:[self.comManager.servers objectAtIndex:indexPath.row]]; [tableView deselectRowAtIndexPath:indexPath animated:YES]; } diff --git a/ios/iosremote/iosremote/slideShowSwipeInList.h b/ios/iosremote/iosremote/slideShowSwipeInList.h index 8b106040f72e..d95ba94b809c 100644 --- a/ios/iosremote/iosremote/slideShowSwipeInList.h +++ b/ios/iosremote/iosremote/slideShowSwipeInList.h @@ -14,7 +14,4 @@ @property (strong, nonatomic) NSTimer *stopWatchTimer; @property (strong, nonatomic) NSDate *startDate; - -@property (strong, nonatomic) IBOutlet UITableView *slidesTable; - @end diff --git a/ios/iosremote/iosremote/slideShowSwipeInList.m b/ios/iosremote/iosremote/slideShowSwipeInList.m index 26288002bff7..011fccc6b23d 100644 --- a/ios/iosremote/iosremote/slideShowSwipeInList.m +++ b/ios/iosremote/iosremote/slideShowSwipeInList.m @@ -43,11 +43,20 @@ dispatch_queue_t backgroundQueue; self.slideshow = self.comManager.interpreter.slideShow; self.slideshow.secondaryDelegate = self; self.state = TIMER_STATE_CLEARED; - if ([[NSUserDefaults standardUserDefaults] boolForKey:KEY_TIMER]) { - UIButton *l = (UIButton *)[[self.slidesTable cellForRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]] viewWithTag:2]; - [self stopWatchStart:l]; + [self stopWatchStart:nil]; } + self.clearsSelectionOnViewWillAppear = NO; +} + +- (void) viewDidAppear:(BOOL)animated +{ + [self changeStartButtonIconForButton:nil]; + NSIndexPath *indexPath = [NSIndexPath indexPathForItem:self.slideshow.currentSlide + inSection:1]; + [self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; + [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO]; + [[[self.tableView cellForRowAtIndexPath:indexPath] viewWithTag:2] setBackgroundColor:[UIColor lightGrayColor]]; } - (void) prepareForSegue: (UIStoryboardSegue *) segue sender: (id) sender @@ -77,15 +86,37 @@ dispatch_queue_t backgroundQueue; #pragma mark - Table view data source +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 2; +} + - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - // +1 for stopwatch - return [self.slideshow size]+1; + // Section one used for stopwatch + if (section == 0) + return 1; + else + return [self.slideshow size]; +} + +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section +{ + switch (section) { + case 0: + return @"Stop Watch"; + break; + case 1: + return @"Slides"; + default: + break; + } + return nil; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - if (indexPath.row == 0) { + if (indexPath.section == 0) { static NSString *CellIdentifier = @"stopWatch"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier]; @@ -98,26 +129,25 @@ dispatch_queue_t backgroundQueue; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier]; UILabel * slideNumber = (UILabel *)[cell viewWithTag:2]; + // Starting 20, all tags are used for thumbnails in this sidebar [cell setTag:20+indexPath.row]; - [self.slideshow getContentAtIndex:indexPath.row-1 forView:cell]; - [slideNumber setText:[NSString stringWithFormat:@"%u", indexPath.row]]; + [self.slideshow getContentAtIndex:indexPath.row forView:cell]; + [slideNumber setText:[NSString stringWithFormat:@"%u", indexPath.row+1]]; return cell; } } - - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - if (indexPath.row == 0) + if (indexPath.section == 0) return; - [self.comManager.transmitter gotoSlide:indexPath.row - 1]; + [self.comManager.transmitter gotoSlide:indexPath.row]; + [[[self.tableView cellForRowAtIndexPath:indexPath] viewWithTag:2] setBackgroundColor:[UIColor lightGrayColor]]; [self.revealViewController revealToggle: self]; - [tableView deselectRowAtIndexPath:indexPath animated:YES]; } - (void)viewDidUnload { - [self setSlidesTable:nil]; [super viewDidUnload]; } @@ -135,7 +165,7 @@ dispatch_queue_t backgroundQueue; // 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]; + UILabel *l = (UILabel *)[[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]] viewWithTag:1]; l.text = timeString; } @@ -170,8 +200,15 @@ dispatch_queue_t backgroundQueue; break; } - UIButton * btn = (UIButton *)sender; + [self changeStartButtonIconForButton:sender]; +} +- (void) changeStartButtonIconForButton:(UIButton *)sender +{ + UIButton * btn = sender; + if (!btn) { + btn = (UIButton *)[[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]] viewWithTag:2]; + } switch (self.state) { case TIMER_STATE_RUNNING: [btn setImage:[UIImage imageNamed:@"timer_pause_btn"] forState:UIControlStateNormal]; @@ -194,7 +231,7 @@ dispatch_queue_t backgroundQueue; self.lastInterval = 0; self.state = TIMER_STATE_CLEARED; - UIButton *l = (UIButton *)[[self.slidesTable cellForRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]] viewWithTag:2]; + UIButton *l = (UIButton *)[[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]] viewWithTag:2]; [l setImage:[UIImage imageNamed:@"timer_start_btn"] forState:UIControlStateNormal]; [self updateTimer]; } |