Skip to content

Instantly share code, notes, and snippets.

@tomersh
Created July 24, 2016 23:18
Show Gist options
  • Save tomersh/c5f5a3b60511d88d944b8ff940f80c41 to your computer and use it in GitHub Desktop.
Save tomersh/c5f5a3b60511d88d944b8ff940f80c41 to your computer and use it in GitHub Desktop.
continues press gesture recognizer
-(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