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

MWMMapDownloaderPlaceTableViewCell.mm « Cells « Downloader « UI « Maps « iphone - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 943f10190b683c94829d0594065c63bcaeac473c (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
#import "MWMMapDownloaderPlaceTableViewCell.h"

#include "Framework.h"

@interface MWMMapDownloaderTableViewCell ()

- (NSAttributedString *)matchedString:(NSString *)str
                        selectedAttrs:(NSDictionary *)selectedAttrs
                      unselectedAttrs:(NSDictionary *)unselectedAttrs;

@end

@interface MWMMapDownloaderPlaceTableViewCell ()

@property(weak, nonatomic) IBOutlet UILabel * descriptionLabel;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * titleBottomOffset;

@end

@implementation MWMMapDownloaderPlaceTableViewCell

+ (CGFloat)estimatedHeight { return 62.0; }

#pragma mark - Config

- (void)config:(storage::NodeAttrs const &)nodeAttrs
{
  [super config:nodeAttrs];
  BOOL isDescriptionVisible = NO;
  NSDictionary * const selectedAreaAttrs = @{NSFontAttributeName : [UIFont bold12]};
  NSDictionary * const unselectedAreaAttrs = @{NSFontAttributeName : [UIFont regular12]};
  if (self.needDisplayArea && nodeAttrs.m_topmostParentInfo.size() == 1)
  {
    string const & areaName = nodeAttrs.m_topmostParentInfo[0].m_localName;
    isDescriptionVisible = (areaName != GetFramework().GetStorage().GetRootId());
    if (isDescriptionVisible)
      self.descriptionLabel.attributedText = [self matchedString:@(areaName.c_str())
                                                   selectedAttrs:selectedAreaAttrs
                                                 unselectedAttrs:unselectedAreaAttrs];
  }
  else if (!nodeAttrs.m_nodeLocalDescription.empty())
  {
    isDescriptionVisible = YES;
    self.descriptionLabel.attributedText =
        [self matchedString:@(nodeAttrs.m_nodeLocalDescription.c_str())
              selectedAttrs:selectedAreaAttrs
            unselectedAttrs:unselectedAreaAttrs];
  }
  self.descriptionLabel.hidden = !isDescriptionVisible;
  self.titleBottomOffset.priority =
      isDescriptionVisible ? UILayoutPriorityDefaultLow : UILayoutPriorityDefaultHigh;
}

@end