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

MWMSearchDownloadMapRequest.m « SearchDownloadMapRequest « CustomViews « Classes « Maps « iphone - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c1855fb2ea6ef5824c5687c55cc65a13cde9ee48 (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//
//  MWMSearchDownloadMapRequest.m
//  Maps
//
//  Created by Ilya Grechuhin on 10.07.15.
//  Copyright (c) 2015 MapsWithMe. All rights reserved.
//

#import "MWMSearchDownloadMapRequest.h"
#import "MWMSearchDownloadMapRequestView.h"

@interface MWMSearchDownloadMapRequest ()

@property (nonatomic) IBOutlet MWMSearchDownloadMapRequestView * rootView;
@property (nonatomic) IBOutlet UIView * downloadRequestHolder;

@property (nonatomic) MWMDownloadMapRequest * downloadRequest;
@property (strong, nonatomic) IBOutlet UIButton * dimButton;

@end

@implementation MWMSearchDownloadMapRequest

- (nonnull instancetype)initWithParentView:(nonnull UIView *)parentView delegate:(nonnull id <MWMCircularProgressDelegate>)delegate
{
  self = [super init];
  if (self)
  {
    [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self.class) owner:self options:nil];
    [parentView addSubview:self.rootView];
    self.downloadRequest = [[MWMDownloadMapRequest alloc] initWithParentView:self.downloadRequestHolder delegate:delegate];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillhide:) name:UIKeyboardWillHideNotification object:nil];
  }
  return self;
}

- (void)showForLocationWithName:(nonnull NSString *)locationName mapSize:(nonnull NSString *)mapSize mapAndRouteSize:(nonnull NSString *)mapAndRouteSize download:(nonnull MWMDownloadMapRequestDownloadCallback)download select:(nonnull MWMDownloadMapRequestSelectCallback)select;
{
  [self.downloadRequest showForLocationWithName:locationName mapSize:mapSize mapAndRouteSize:mapAndRouteSize download:download select:select];
}

- (void)showForUnknownLocation:(nonnull MWMDownloadMapRequestSelectCallback)select
{
  [self.downloadRequest showForUnknownLocation:select];
}

- (void)dealloc
{
  [[NSNotificationCenter defaultCenter] removeObserver:self];
  [self.rootView removeFromSuperview];
}

- (void)keyboardWillShow:(nonnull NSNotification *)aNotification
{
  UIButton * dim = self.dimButton;
  dim.hidden = NO;
  dim.alpha = 0.0;
  NSNumber * duration = aNotification.userInfo[UIKeyboardAnimationDurationUserInfoKey];
  [UIView animateWithDuration:duration.floatValue animations:^
  {
    dim.alpha = 1.0;
  }];
}

- (void)keyboardWillhide:(nonnull NSNotification *)aNotification
{
  UIButton * dim = self.dimButton;
  dim.alpha = 1.0;
  NSNumber * duration = aNotification.userInfo[UIKeyboardAnimationDurationUserInfoKey];
  [UIView animateWithDuration:duration.floatValue animations:^
  {
    dim.alpha = 0.0;
  }
  completion:^(BOOL finished)
  {
    dim.hidden = YES;
  }];
}

#pragma mark - Process control

- (void)startDownload
{
  self.rootView.hintHidden = YES;
  [self.downloadRequest startDownload];
}

- (void)stopDownload
{
  self.rootView.hintHidden = NO;
  [self.downloadRequest stopDownload];
}

- (void)downloadProgress:(CGFloat)progress countryName:(nonnull NSString *)countryName
{
  [self.downloadRequest downloadProgress:progress countryName:countryName];
}

- (void)setDownloadFailed
{
  [self.downloadRequest setDownloadFailed];
}

#pragma mark - Actions

- (IBAction)dimTouchUpInside:(nonnull UIButton *)sender
{
  [[UIApplication sharedApplication].keyWindow endEditing:YES];
}

@end