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

MWMSearchBookmarksCell.mm « BookmarksTab « TabbedView « Search « MapViewControls « CustomViews « Classes « Maps « iphone - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 54cf32d3776d7d44e385508203d540cd6b10ad34 (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
#import "BookmarksVC.h"
#import "Common.h"
#import "MWMSearchBookmarksCell.h"
#import "UIColor+MapsMeColor.h"
#import "UIFont+MapsMeFonts.h"

#include "Framework.h"

@interface MWMSearchBookmarksCell ()

@property (nonatomic) NSInteger index;
@property (nonatomic) BOOL isVisible;
@property (nonatomic) NSUInteger count;

@property (weak, nonatomic) IBOutlet UIButton * visibilityButton;
@property (weak, nonatomic) IBOutlet UILabel * titleLabel;
@property (weak, nonatomic) IBOutlet UILabel * countLabel;
@property (weak, nonatomic) IBOutlet UIImageView * openArrow;

@end

@implementation MWMSearchBookmarksCell

- (void)awakeFromNib
{
  [super awakeFromNib];
  if (IPAD)
    self.contentView.backgroundColor = [UIColor white];
  self.layer.shouldRasterize = YES;
  self.layer.rasterizationScale = UIScreen.mainScreen.scale;
}

- (void)configForIndex:(NSInteger)index
{
  BookmarkCategory * cat = GetFramework().GetBmCategory(index);
  self.index = index;
  self.isVisible = cat->IsVisible();
  size_t userMarksCount = 0;
  {
    BookmarkCategory::Guard guard(*cat);
    userMarksCount = guard.m_controller.GetUserMarkCount();
  }
  self.count = userMarksCount + cat->GetTracksCount();
  self.titleLabel.text = @(cat->GetName().c_str());
}

- (IBAction)toggleVisibility
{
  self.isVisible = !self.isVisible;
  BookmarkCategory * cat = GetFramework().GetBmCategory(self.index);
  {
    BookmarkCategory::Guard guard(*cat);
    guard.m_controller.SetIsVisible(self.isVisible);
  }
  cat->SaveToKMLFile();
}

- (IBAction)openBookmarks
{
  BookmarksVC * bvc = [[BookmarksVC alloc] initWithCategory:self.index];
  UINavigationController * rootVC = (UINavigationController *)UIApplication.sharedApplication.delegate.window.rootViewController;
  [rootVC pushViewController:bvc animated:YES];
}

- (void)setTitle:(NSString *)title
{
  self.titleLabel.text = title;
}

+ (CGFloat)defaultCellHeight
{
  return 44.0;
}

- (CGFloat)cellHeight
{
  return ceil([self.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height);
}

#pragma mark - Properties

- (void)setIsVisible:(BOOL)isVisible
{
  _isVisible = self.visibilityButton.selected = isVisible;
}

- (void)setCount:(NSUInteger)count
{
  _count = count;
  self.countLabel.text = @(count).stringValue;
}

@end