blob: f88de663f35c6e147a2beb6b114acd22bb8a8547 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#import "MWMCommon.h"
#import "MWMAddPlaceNavigationBar.h"
#include "Framework.h"
@interface MWMAddPlaceNavigationBar ()
@property(copy, nonatomic) MWMVoidBlock doneBlock;
@property(copy, nonatomic) MWMVoidBlock cancelBlock;
@end
@implementation MWMAddPlaceNavigationBar
+ (void)showInSuperview:(UIView *)superview
isBusiness:(BOOL)isBusiness
applyPosition:(BOOL)applyPosition
position:(m2::PointD const &)position
doneBlock:(MWMVoidBlock)done
cancelBlock:(MWMVoidBlock)cancel
{
MWMAddPlaceNavigationBar * navBar = [[[NSBundle mainBundle] loadNibNamed:self.className owner:nil options:nil] firstObject];
navBar.width = superview.width;
navBar.doneBlock = done;
navBar.cancelBlock = cancel;
navBar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[navBar setNeedsLayout];
navBar.origin = {0., -navBar.height};
[superview addSubview:navBar];
[navBar show:isBusiness applyPosition:applyPosition position:position];
}
- (void)show:(BOOL)enableBounds applyPosition:(BOOL)applyPosition position:(m2::PointD const &)position
{
auto & f = GetFramework();
f.EnableChoosePositionMode(true /* enable */, enableBounds, applyPosition, position);
f.BlockTapEvents(true);
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
{
self.transform = CGAffineTransformMakeTranslation(0., self.height);
}];
}
- (void)dismissWithBlock:(MWMVoidBlock)block
{
auto & f = GetFramework();
f.EnableChoosePositionMode(false /* enable */, false /* enableBounds */, false /* applyPosition */, m2::PointD());
f.BlockTapEvents(false);
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
{
self.transform = CGAffineTransformMakeTranslation(0., -self.height);
}
completion:^(BOOL finished)
{
[self removeFromSuperview];
block();
}];
}
- (IBAction)doneTap
{
[self dismissWithBlock:self.doneBlock];
}
- (IBAction)cancelTap
{
[self dismissWithBlock:self.cancelBlock];
}
- (void)layoutSubviews
{
if (self.superview)
self.width = self.superview.width;
[super layoutSubviews];
}
@end
|