diff options
Diffstat (limited to 'platform/macos/app/DroppedPinAnnotation.m')
-rw-r--r-- | platform/macos/app/DroppedPinAnnotation.m | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/platform/macos/app/DroppedPinAnnotation.m b/platform/macos/app/DroppedPinAnnotation.m deleted file mode 100644 index b601405095..0000000000 --- a/platform/macos/app/DroppedPinAnnotation.m +++ /dev/null @@ -1,73 +0,0 @@ -#import "DroppedPinAnnotation.h" - -#import "LocationCoordinate2DTransformer.h" -#import "TimeIntervalTransformer.h" - -#import <Mapbox/Mapbox.h> - -static MGLCoordinateFormatter *DroppedPinCoordinateFormatter; - -@implementation DroppedPinAnnotation { - NSTimer *_timer; - NSTimeInterval _priorShownTimeInterval; - NSDate *_dateShown; - - NSValueTransformer *_timeIntervalTransformer; -} - -+ (void)initialize { - if (self == [DroppedPinAnnotation class]) { - DroppedPinCoordinateFormatter = [[MGLCoordinateFormatter alloc] init]; - } -} - -- (instancetype)init { - if (self = [super init]) { - _timeIntervalTransformer = [NSValueTransformer valueTransformerForName: - NSStringFromClass([TimeIntervalTransformer class])]; - [self update:nil]; - } - return self; -} - -- (void)dealloc { - [self pause]; -} - -- (void)setCoordinate:(CLLocationCoordinate2D)coordinate { - super.coordinate = coordinate; - [self update:nil]; -} - -- (NSTimeInterval)elapsedShownTime { - return _priorShownTimeInterval - _dateShown.timeIntervalSinceNow; -} - -- (void)resume { - _dateShown = [NSDate date]; - _timer = [NSTimer scheduledTimerWithTimeInterval:1 - target:self - selector:@selector(update:) - userInfo:nil - repeats:YES]; -} - -- (void)pause { - [_timer invalidate]; - _timer = nil; - _priorShownTimeInterval -= _dateShown.timeIntervalSinceNow; - _dateShown = nil; -} - -- (void)update:(NSTimer *)timer { - NSString *coordinate = [DroppedPinCoordinateFormatter stringFromCoordinate:self.coordinate]; - if (self.note) { - self.subtitle = [@[self.note, coordinate] componentsJoinedByString:@"\n"]; - } else { - NSString *elapsedTime = [_timeIntervalTransformer transformedValue:@(self.elapsedShownTime)]; - NSString *elapsedString = [NSString stringWithFormat:@"Selected for %@", elapsedTime]; - self.subtitle = [@[coordinate, elapsedString] componentsJoinedByString:@"\n"]; - } -} - -@end |