Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'iphone/Maps/Classes/MWMPPView.mm')
-rw-r--r--iphone/Maps/Classes/MWMPPView.mm101
1 files changed, 101 insertions, 0 deletions
diff --git a/iphone/Maps/Classes/MWMPPView.mm b/iphone/Maps/Classes/MWMPPView.mm
new file mode 100644
index 0000000000..d6c80dd84a
--- /dev/null
+++ b/iphone/Maps/Classes/MWMPPView.mm
@@ -0,0 +1,101 @@
+#import "MWMPPView.h"
+#import "UIColor+MapsMeColor.h"
+
+namespace
+{
+void * kContext = &kContext;
+NSString * const kTableViewContentSizeKeyPath = @"contentSize";
+
+} // namespace
+
+#pragma mark - MWMPPScrollView
+
+@implementation MWMPPScrollView
+
+- (instancetype)initWithFrame:(CGRect)frame inactiveView:(UIView *)inactiveView
+{
+ self = [super initWithFrame:frame];
+ if (self)
+ _inactiveView = inactiveView;
+ return self;
+}
+
+- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
+{
+ if (point.y > [self convertRect:self.inactiveView.bounds fromView:self.inactiveView].origin.y)
+ return YES;
+ return NO;
+}
+
+@end
+
+#pragma mark - MWMPPView
+
+@implementation MWMPPView
+
+- (void)hideTableView:(BOOL)isHidden
+{
+ if (isHidden)
+ {
+ self.tableView.alpha = 0.;
+ self.spinner.hidden = NO;
+ [self.spinner startAnimating];
+ }
+ else
+ {
+ self.tableView.alpha = 1.;
+ self.spinner.hidden = YES;
+ [self.spinner stopAnimating];
+ }
+}
+
+- (void)observeValueForKeyPath:(NSString *)keyPath
+ ofObject:(id)object
+ change:(NSDictionary *)change
+ context:(void *)context
+{
+ if (context == kContext)
+ {
+ NSValue * s = change[@"new"];
+ CGFloat const height = s.CGSizeValue.height;
+ if (fabs(height - self.currentContentHeight) > 0.5)
+ {
+ self.currentContentHeight = height;
+ self.height = height + self.top.height;
+ [self setNeedsLayout];
+ [self.delegate updateWithHeight:self.height];
+ }
+ return;
+ }
+
+ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+}
+
+- (void)awakeFromNib
+{
+ [super awakeFromNib];
+ [self.tableView addObserver:self forKeyPath:kTableViewContentSizeKeyPath options:NSKeyValueObservingOptionNew context:kContext];
+
+ self.tableView.estimatedRowHeight = 44.;
+ self.tableView.rowHeight = UITableViewAutomaticDimension;
+
+ self.tableView.contentInset = {.top = -36};
+
+ NSUInteger const animationImagesCount = 12;
+ NSMutableArray * animationImages = [NSMutableArray arrayWithCapacity:animationImagesCount];
+ NSString * postfix = [UIColor isNightMode] ? @"dark" : @"light";
+ for (NSUInteger i = 0; i < animationImagesCount; ++i)
+ animationImages[i] = [UIImage imageNamed:[NSString stringWithFormat:@"Spinner_%@_%@", @(i+1), postfix]];
+
+ self.spinner.animationDuration = 0.8;
+ self.spinner.animationImages = animationImages;
+ [self.spinner startAnimating];
+}
+
+- (void)dealloc
+{
+ [self.tableView removeObserver:self forKeyPath:kTableViewContentSizeKeyPath context:kContext];
+}
+
+@end
+