Skip to content

Commit

Permalink
[bookmarks][iOS] Review fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
darina authored and beloal committed Aug 26, 2019
1 parent 4f822bc commit 4f99193
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 157 deletions.
43 changes: 20 additions & 23 deletions iphone/Maps/Bookmarks/BookmarksSection.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@
#import "MWMBookmarksManager.h"
#import "MWMLocationHelpers.h"
#import "MWMSearchManager.h"

#include "Framework.h"

#include "geometry/distance_on_sphere.hpp"

NS_ASSUME_NONNULL_BEGIN

namespace {
CGFloat const kPinDiameter = 22.0f;
} // namespace

@interface BookmarksSection () {
NSString *m_title;
NSMutableArray<NSNumber *> *m_markIds;
BOOL m_isEditable;
}
@interface BookmarksSection ()

@property(copy, nonatomic, nullable) NSString *sectionTitle;
@property(strong, nonatomic) NSMutableArray<NSNumber *> *markIds;
@property(nonatomic) BOOL isEditable;

@end

Expand All @@ -29,27 +28,27 @@ - (instancetype)initWithTitle:(nullable NSString *)title
isEditable:(BOOL)isEditable {
self = [super init];
if (self) {
m_title = title;
m_markIds = markIds.mutableCopy;
m_isEditable = isEditable;
_sectionTitle = [title copy];
_markIds = [markIds mutableCopy];
_isEditable = isEditable;
}
return self;
}

- (kml::MarkId)getMarkIdForRow:(NSInteger)row {
return static_cast<kml::MarkId>(m_markIds[row].unsignedLongLongValue);
- (kml::MarkId)markIdForRow:(NSInteger)row {
return static_cast<kml::MarkId>(self.markIds[row].unsignedLongLongValue);
}

- (NSInteger)numberOfRows {
return [m_markIds count];
return [self.markIds count];
}

- (nullable NSString *)title {
return m_title;
return self.sectionTitle;
}

- (BOOL)canEdit {
return m_isEditable;
return self.isEditable;
}

- (void)fillCell:(UITableViewCell *)cell
Expand Down Expand Up @@ -82,13 +81,13 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRow:(NSInteger)ro
reuseIdentifier:@"BookmarksVCBookmarkItemCell"];
}

auto const bmId = [self getMarkIdForRow:row];
auto const bmId = [self markIdForRow:row];
auto const &bm = GetFramework().GetBookmarkManager();
Bookmark const *bookmark = bm.GetBookmark(bmId);
cell.textLabel.text = @(bookmark->GetPreferredName().c_str());
cell.imageView.image = [CircleView createCircleImageWith:kPinDiameter
andColor:[ColorPickerView getUIColor:bookmark->GetColor()]
andImageName:@(DebugPrint(bookmark->GetData().m_icon).c_str())];
andImageName:@(ToString(bookmark->GetData().m_icon).c_str())];

CLLocation *lastLocation = [MWMLocationManager lastLocation];

Expand All @@ -97,7 +96,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRow:(NSInteger)ro
}

- (void)updateCell:(UITableViewCell *)cell forRow:(NSInteger)row withNewLocation:(CLLocation *)location {
auto const bmId = [self getMarkIdForRow:row];
auto const bmId = [self markIdForRow:row];
auto const &bm = GetFramework().GetBookmarkManager();
Bookmark const *bookmark = bm.GetBookmark(bmId);
if (!bookmark)
Expand All @@ -106,7 +105,7 @@ - (void)updateCell:(UITableViewCell *)cell forRow:(NSInteger)row withNewLocation
}

- (BOOL)didSelectRow:(NSInteger)row {
auto const bmId = [self getMarkIdForRow:row];
auto const bmId = [self markIdForRow:row];
[Statistics logEvent:kStatEventName(kStatBookmarks, kStatShowOnMap)];
// Same as "Close".
[MWMSearchManager manager].state = MWMSearchManagerStateHidden;
Expand All @@ -115,11 +114,9 @@ - (BOOL)didSelectRow:(NSInteger)row {
}

- (void)deleteRow:(NSInteger)row {
auto const bmId = [self getMarkIdForRow:row];
auto const bmId = [self markIdForRow:row];
[[MWMBookmarksManager sharedManager] deleteBookmark:bmId];
[m_markIds removeObjectAtIndex:row];
[self.markIds removeObjectAtIndex:row];
}

@end

NS_ASSUME_NONNULL_END
4 changes: 1 addition & 3 deletions iphone/Maps/Bookmarks/BookmarksVC.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ NS_ASSUME_NONNULL_BEGIN
@end

@interface BookmarksVC : MWMViewController <UITextFieldDelegate>
{
MWMMarkGroupID m_categoryId;
}

@property (nonatomic) MWMMarkGroupID categoryId;
@property (weak, nonatomic) id<BookmarksVCDelegate> delegate;

- (instancetype)initWithCategory:(MWMMarkGroupID)categoryId;
Expand Down
Loading

0 comments on commit 4f99193

Please sign in to comment.