-
-
Save tomersh/c5f5a3b60511d88d944b8ff940f80c41 to your computer and use it in GitHub Desktop.
continues press gesture recognizer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void) syncButtonViewDidPassedSyncTreshhold:(CPRSyncButtonView*) syncView { | |
self.didFinishSync = YES; | |
} | |
-(void) syncButtonViewDidShowSyncConfirmation:(CPRSyncButtonView*) syncView { | |
self.didFinishSync = NO; | |
self.desktopSyncView.hidden = YES; | |
self.accessoryView.hidden = NO; | |
} | |
-(void) _beginSyncProcessAnimationIfNeeded { | |
if (!self.isSyncing && self.touchStartTimestamp + (self.syncStartThreasholds*1000) >= [[NSDate date] timeIntervalSince1970]) { | |
self.isSyncing = YES; | |
self.desktopSyncView.hidden = NO; | |
self.accessoryView.hidden = YES; | |
[self.desktopSyncView animateSync:self.syncHoldThreasholds]; | |
} | |
} | |
-(void) _onLongPress:(UILongPressGestureRecognizer*) sender { | |
if (!self.canSyncWithDesktop) return; | |
switch (sender.state) { | |
case UIGestureRecognizerStateBegan: //first touch | |
self.touchStartTimestamp = [[NSDate date] timeIntervalSince1970]; | |
self.syncingStartTimer = [NSTimer scheduledTimerWithTimeInterval:self.syncStartThreasholds target:self selector:@selector(_beginSyncProcessAnimationIfNeeded) userInfo:nil repeats:NO]; | |
break; | |
case UIGestureRecognizerStateCancelled: | |
case UIGestureRecognizerStateEnded: //finger is removed | |
self.isSyncing = NO; | |
[self.syncingStartTimer invalidate]; | |
self.syncingStartTimer = nil; | |
if (!self.didFinishSync) { | |
[self.desktopSyncView stopSyncAnimation]; | |
self.desktopSyncView.hidden = YES; | |
self.accessoryView.hidden = NO; | |
} | |
case UIGestureRecognizerStateChanged: | |
break; | |
break; | |
default: | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment