[bookmarks][iOS] clang-format run.

This commit is contained in:
Daria Volvenkova 2019-08-12 00:49:35 +03:00 committed by Aleksey Belousov
parent 63176abb8e
commit 870fd79c4f
12 changed files with 374 additions and 522 deletions

View file

@ -16,7 +16,7 @@
@interface BookmarksSection : NSObject <TableSectionDataSource>
@property (nullable, nonatomic) NSNumber * blockIndex;
@property(nullable, nonatomic) NSNumber *blockIndex;
- (instancetype)initWithDelegate:(id<BookmarksSectionDelegate>)delegate;
- (instancetype)initWithBlockIndex:(NSNumber *)blockIndex delegate:(id<BookmarksSectionDelegate>)delegate;

View file

@ -8,66 +8,59 @@
#include "geometry/distance_on_sphere.hpp"
namespace
{
namespace {
CGFloat const kPinDiameter = 22.0f;
} // namespace
@interface BookmarksSection()
@interface BookmarksSection ()
@property (weak, nonatomic) id<BookmarksSectionDelegate> delegate;
@property(weak, nonatomic) id<BookmarksSectionDelegate> delegate;
@end
@implementation BookmarksSection
- (instancetype)initWithDelegate: (id<BookmarksSectionDelegate>)delegate
{
- (instancetype)initWithDelegate:(id<BookmarksSectionDelegate>)delegate {
return [self initWithBlockIndex:nil delegate:delegate];
}
- (instancetype)initWithBlockIndex:(NSNumber *)blockIndex delegate:(id<BookmarksSectionDelegate>)delegate
{
- (instancetype)initWithBlockIndex:(NSNumber *)blockIndex delegate:(id<BookmarksSectionDelegate>)delegate {
self = [super init];
if (self)
{
if (self) {
_blockIndex = blockIndex;
_delegate = delegate;
}
return self;
}
- (NSInteger)numberOfRows
{
- (NSInteger)numberOfRows {
return [self.delegate numberOfBookmarksInSection:self];
}
- (NSString *)title
{
- (NSString *)title {
return [self.delegate titleOfBookmarksSection:self];
}
- (BOOL)canEdit
{
- (BOOL)canEdit {
return [self.delegate canEditBookmarksSection:self];
}
- (void)fillCell: (UITableViewCell *)cell withBookmarkDetails: (Bookmark const *)bookmark andLocation:(CLLocation *)location
{
- (void)fillCell:(UITableViewCell *)cell
withBookmarkDetails:(Bookmark const *)bookmark
andLocation:(CLLocation *)location {
std::vector<std::string> details;
if (location)
{
if (location) {
m2::PointD const pos = bookmark->GetPivot();
double const meters = ms::DistanceOnEarth(location.coordinate.latitude, location.coordinate.longitude,
MercatorBounds::YToLat(pos.y), MercatorBounds::XToLon(pos.x));
details.push_back(location_helpers::formattedDistance(meters).UTF8String);
}
auto const & types = bookmark->GetData().m_featureTypes;
auto const &types = bookmark->GetData().m_featureTypes;
if (!types.empty())
details.push_back(kml::GetLocalizedFeatureType(types));
auto const detailText = strings::JoinStrings(details, " • ");
if (!detailText.empty())
cell.detailTextLabel.text = @(detailText.c_str());
@ -75,43 +68,39 @@ CGFloat const kPinDiameter = 22.0f;
cell.detailTextLabel.text = nil;
}
- (UITableViewCell *)tableView: (UITableView *)tableView cellForRow: (NSInteger)row
{
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"BookmarksVCBookmarkItemCell"];
if (!cell)
{
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRow:(NSInteger)row {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BookmarksVCBookmarkItemCell"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:@"BookmarksVCBookmarkItemCell"];
}
CHECK(cell, ("Invalid bookmark cell."));
kml::MarkId const bmId = [self.delegate bookmarkSection:self getBookmarkIdByRow:row];
auto const & bm = GetFramework().GetBookmarkManager();
Bookmark const * bookmark = bm.GetBookmark(bmId);
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())];
CLLocation * lastLocation = [MWMLocationManager lastLocation];
CLLocation *lastLocation = [MWMLocationManager lastLocation];
[self fillCell:cell withBookmarkDetails:bookmark andLocation:lastLocation];
return cell;
}
- (void)updateCell: (UITableViewCell *)cell forRow:(NSInteger)row withNewLocation: (location::GpsInfo const &)info
{
- (void)updateCell:(UITableViewCell *)cell forRow:(NSInteger)row withNewLocation:(location::GpsInfo const &)info {
kml::MarkId const bmId = [self.delegate bookmarkSection:self getBookmarkIdByRow:row];
auto const & bm = GetFramework().GetBookmarkManager();
Bookmark const * bookmark = bm.GetBookmark(bmId);
auto const &bm = GetFramework().GetBookmarkManager();
Bookmark const *bookmark = bm.GetBookmark(bmId);
if (!bookmark)
return;
CLLocation * location = [[CLLocation alloc] initWithLatitude:info.m_latitude longitude:info.m_longitude];
CLLocation *location = [[CLLocation alloc] initWithLatitude:info.m_latitude longitude:info.m_longitude];
[self fillCell:cell withBookmarkDetails:bookmark andLocation:location];
}
- (BOOL)didSelectRow: (NSInteger)row
{
- (BOOL)didSelectRow:(NSInteger)row {
kml::MarkId const bmId = [self.delegate bookmarkSection:self getBookmarkIdByRow:row];
[Statistics logEvent:kStatEventName(kStatBookmarks, kStatShowOnMap)];
// Same as "Close".
@ -120,8 +109,7 @@ CGFloat const kPinDiameter = 22.0f;
return YES;
}
- (BOOL)deleteRow: (NSInteger)row
{
- (BOOL)deleteRow:(NSInteger)row {
kml::MarkId const bmId = [self.delegate bookmarkSection:self getBookmarkIdByRow:row];
[[MWMBookmarksManager sharedManager] deleteBookmark:bmId];
return [self.delegate bookmarkSection:self onDeleteBookmarkInRow:row];

File diff suppressed because it is too large Load diff

View file

@ -11,4 +11,3 @@
- (instancetype)initWithDelegate:(id<InfoSectionDelegate>)delegate;
@end

View file

@ -1,50 +1,42 @@
#import "InfoSection.h"
@interface InfoSection()
@interface InfoSection ()
@property (weak, nonatomic) id<InfoSectionDelegate> delegate;
@property(weak, nonatomic) id<InfoSectionDelegate> delegate;
@end
@implementation InfoSection
- (instancetype)initWithDelegate: (id<InfoSectionDelegate>)delegate
{
- (instancetype)initWithDelegate:(id<InfoSectionDelegate>)delegate {
self = [super init];
if (self)
{
if (self) {
_delegate = delegate;
}
return self;
}
- (NSInteger)numberOfRows
{
- (NSInteger)numberOfRows {
return 1;
}
- (NSString *)title
{
- (NSString *)title {
return L(@"placepage_place_description");
}
- (BOOL)canEdit
{
- (BOOL)canEdit {
return NO;
}
- (UITableViewCell *)tableView: (UITableView *)tableView cellForRow: (NSInteger)row
{
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRow:(NSInteger)row {
return [self.delegate infoCellForTableView:tableView];
}
- (BOOL)didSelectRow: (NSInteger)row
{
- (BOOL)didSelectRow:(NSInteger)row {
return NO;
}
- (BOOL)deleteRow: (NSInteger)row
{
- (BOOL)deleteRow:(NSInteger)row {
return YES;
}

View file

@ -1,5 +1,5 @@
#import "MWMTableViewCell.h"
#import "InfoSection.h"
#import "MWMTableViewCell.h"
namespace kml
{

View file

@ -6,16 +6,13 @@
- (NSString *)title;
- (BOOL)canEdit;
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRow:(NSInteger)row;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRow:(NSInteger)row;
- (BOOL)didSelectRow:(NSInteger)row;
- (BOOL)deleteRow:(NSInteger)row;
@optional
-(void)updateCell:(UITableViewCell *)cell
forRow:(NSInteger)row
withNewLocation:(location::GpsInfo const &)gpsInfo;
- (void)updateCell:(UITableViewCell *)cell forRow:(NSInteger)row withNewLocation:(location::GpsInfo const &)gpsInfo;
@end

View file

@ -16,11 +16,10 @@
@interface TracksSection : NSObject <TableSectionDataSource>
@property (nullable, nonatomic) NSNumber * blockIndex;
@property(nullable, nonatomic) NSNumber *blockIndex;
- (instancetype)initWithDelegate:(id<TracksSectionDelegate>)delegate;
- (instancetype)initWithBlockIndex:(NSNumber *)blockIndex
delegate:(id<TracksSectionDelegate>)delegate;
- (instancetype)initWithBlockIndex:(NSNumber *)blockIndex delegate:(id<TracksSectionDelegate>)delegate;
@end

View file

@ -2,61 +2,53 @@
#import "CircleView.h"
#include "Framework.h"
namespace
{
CGFloat const kPinDiameter = 22.0f;
namespace {
CGFloat const kPinDiameter = 22.0f;
} // namespace
@interface TracksSection()
@interface TracksSection ()
@property (weak, nonatomic) id<TracksSectionDelegate> delegate;
@property(weak, nonatomic) id<TracksSectionDelegate> delegate;
@end
@implementation TracksSection
- (instancetype)initWithDelegate:(id<TracksSectionDelegate>)delegate
{
- (instancetype)initWithDelegate:(id<TracksSectionDelegate>)delegate {
return [self initWithBlockIndex:nil delegate:delegate];
}
- (instancetype)initWithBlockIndex:(NSNumber *)blockIndex delegate: (id<TracksSectionDelegate>)delegate
{
- (instancetype)initWithBlockIndex:(NSNumber *)blockIndex delegate:(id<TracksSectionDelegate>)delegate {
self = [super init];
if (self)
{
if (self) {
_blockIndex = blockIndex;
_delegate = delegate;
}
return self;
}
- (NSInteger)numberOfRows
{
- (NSInteger)numberOfRows {
return [self.delegate numberOfTracksInSection:self];
}
- (NSString *)title
{
- (NSString *)title {
return [self.delegate titleOfTracksSection:self];
}
- (BOOL)canEdit
{
- (BOOL)canEdit {
return [self.delegate canEditTracksSection:self];
}
- (UITableViewCell *)tableView: (UITableView *)tableView cellForRow: (NSInteger)row
{
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"TrackCell"];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRow:(NSInteger)row {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TrackCell"];
if (!cell)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"TrackCell"];
CHECK(cell, ("Invalid track cell."));
auto const & bm = GetFramework().GetBookmarkManager();
auto const &bm = GetFramework().GetBookmarkManager();
kml::TrackId const trackId = [self.delegate tracksSection:self getTrackIdByRow:row];
Track const * track = bm.GetTrack(trackId);
Track const *track = bm.GetTrack(trackId);
cell.textLabel.text = @(track->GetName().c_str());
string dist;
if (measurement_utils::FormatDistance(track->GetLengthMeters(), dist))
@ -72,17 +64,15 @@ namespace
return cell;
}
- (BOOL)didSelectRow: (NSInteger)row
{
- (BOOL)didSelectRow:(NSInteger)row {
kml::TrackId const trackId = [self.delegate tracksSection:self getTrackIdByRow:row];
GetFramework().ShowTrack(trackId);
return YES;
}
- (BOOL)deleteRow: (NSInteger)row
{
- (BOOL)deleteRow:(NSInteger)row {
kml::TrackId const trackId = [self.delegate tracksSection:self getTrackIdByRow:row];
auto & bm = GetFramework().GetBookmarkManager();
auto &bm = GetFramework().GetBookmarkManager();
bm.GetEditSession().DeleteTrack(trackId);
return [self.delegate tracksSection:self onDeleteTrackInRow:row];
}

View file

@ -4,20 +4,18 @@
@interface CircleView()
@property (nonatomic) UIColor * circleColor;
@property (nonatomic) UIImage * image;
@property(nonatomic) UIColor *circleColor;
@property(nonatomic) UIImage *image;
@end
@implementation CircleView
- (id)initWithFrame:(CGRect)frame andColor:(UIColor *)color
{
- (id)initWithFrame:(CGRect)frame andColor:(UIColor *)color {
return [self initWithFrame:frame andColor:color andImageName:nil];
}
- (id)initWithFrame:(CGRect)frame andColor:(UIColor *)color andImageName:(NSString *)imageName
{
- (id)initWithFrame:(CGRect)frame andColor:(UIColor *)color andImageName:(NSString *)imageName {
self = [super initWithFrame:frame];
if (self)
{
@ -29,53 +27,50 @@
return self;
}
- (void)drawRect:(CGRect)rect
{
- (void)drawRect:(CGRect)rect {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextAddEllipseInRect(ctx, rect);
CGContextSetFillColor(ctx, CGColorGetComponents(self.circleColor.CGColor));
CGContextFillPath(ctx);
if (self.image)
[self.image drawInRect:CGRectMake(3, 3, rect.size.width - 6, rect.size.height - 6)];
}
+ (UIView *)createViewWithCircleDiameter:(CGFloat)diameter andColor:(UIColor *)color andImageName:(NSString *)imageName
{
UIView * circleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, diameter, diameter)];
+ (UIView *)createViewWithCircleDiameter:(CGFloat)diameter
andColor:(UIColor *)color
andImageName:(NSString *)imageName {
UIView *circleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, diameter, diameter)];
circleView.backgroundColor = UIColor.clearColor;
CircleView * circle = [[self alloc] initWithFrame:CGRectMake(0.5, 0.5, diameter - 1, diameter - 1) andColor:color andImageName:imageName];
CircleView *circle = [[self alloc] initWithFrame:CGRectMake(0.5, 0.5, diameter - 1, diameter - 1)
andColor:color
andImageName:imageName];
[circleView addSubview:circle];
return circleView;
}
+ (UIImage *)createCircleImageWith:(CGFloat)diameter andColor:(UIColor *)color
{
UIView * circle = [self createViewWithCircleDiameter:diameter andColor:color andImageName:nil];
+ (UIImage *)createCircleImageWith:(CGFloat)diameter andColor:(UIColor *)color {
UIView *circle = [self createViewWithCircleDiameter:diameter andColor:color andImageName:nil];
return [self imageWithView:circle];
}
+ (UIImage *)createCircleImageWith:(CGFloat)diameter andColor:(UIColor *)color andImageName:(NSString *)imageName
{
UIView * circle = [self createViewWithCircleDiameter:diameter andColor:color andImageName:imageName];
+ (UIImage *)createCircleImageWith:(CGFloat)diameter andColor:(UIColor *)color andImageName:(NSString *)imageName {
UIView *circle = [self createViewWithCircleDiameter:diameter andColor:color andImageName:imageName];
return [self imageWithView:circle];
}
+ (UIImage *)createCircleImageWith:(CGFloat)diameter andColor:(UIColor *)color andSubview:(UIView *)view
{
UIView * circle = [self createViewWithCircleDiameter:diameter andColor:color andImageName:nil];
+ (UIImage *)createCircleImageWith:(CGFloat)diameter andColor:(UIColor *)color andSubview:(UIView *)view {
UIView *circle = [self createViewWithCircleDiameter:diameter andColor:color andImageName:nil];
[circle addSubview:view];
return [self imageWithView:circle];
}
+ (UIImage *)imageWithView:(UIView *)view
{
+ (UIImage *)imageWithView:(UIView *)view {
UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0.0);
CGContextRef context = UIGraphicsGetCurrentContext();
[view.layer renderInContext:context];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

View file

@ -17,8 +17,7 @@ struct Tcolor
float rgb[3];
};
static Tcolor const g_color [] =
{
static Tcolor const g_color[] = {
{kml::PredefinedColor::Red, {229, 27, 35}},
{kml::PredefinedColor::Yellow, {255, 200, 0}},
{kml::PredefinedColor::Blue, {0, 110, 199}},

View file

@ -19,9 +19,9 @@ typedef NS_ENUM(NSUInteger, MWMTheme) {
typedef uint64_t MWMMarkID;
typedef uint64_t MWMTrackID;
typedef uint64_t MWMMarkGroupID;
typedef NSArray<NSNumber *> * MWMMarkIDCollection;
typedef NSArray<NSNumber *> * MWMTrackIDCollection;
typedef NSArray<NSNumber *> * MWMGroupIDCollection;
typedef NSArray<NSNumber *> *MWMMarkIDCollection;
typedef NSArray<NSNumber *> *MWMTrackIDCollection;
typedef NSArray<NSNumber *> *MWMGroupIDCollection;
typedef NS_ENUM(NSUInteger, MWMBookmarksShareStatus) {
MWMBookmarksShareStatusSuccess,