[bookmarks][iOS] Bookmarks search and sort UI.

This commit is contained in:
Daria Volvenkova 2019-08-01 18:30:39 +03:00 committed by Aleksey Belousov
parent b7280631af
commit cf5325423b
10 changed files with 1065 additions and 244 deletions

View file

@ -0,0 +1,67 @@
#import "MWMTypes.h"
#include "platform/location.hpp"
#include "kml/type_utils.hpp"
@protocol TableSectionDelegate <NSObject>
- (NSInteger)numberOfRows;
- (NSString *)title;
- (BOOL)canEdit;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRow:(NSInteger)row;
- (BOOL)didSelectRow:(NSInteger)row;
- (void)deleteRow:(NSInteger)row;
@optional
-(void)updateCell:(UITableViewCell *)cell forRow:(NSInteger)row withNewLocation:(location::GpsInfo const &)gpsInfo;
@end
@class BookmarksSection;
@protocol BookmarksSectionDelegate <NSObject>
- (NSInteger)numberOfBookmarksInSection:(BookmarksSection *)bookmarkSection;
- (NSString *)titleOfBookmarksSection:(BookmarksSection *)bookmarkSection;
- (BOOL)canEditBookmarksSection:(BookmarksSection *)bookmarkSection;
- (kml::MarkId)bookmarkSection:(BookmarksSection *)bookmarkSection getBookmarkIdByRow:(NSInteger)row;
- (void)bookmarkSection:(BookmarksSection *)bookmarkSection onDeleteBookmarkInRow:(NSInteger)row;
@end
@class TracksSection;
@protocol TracksSectionDelegate <NSObject>
- (NSInteger)numberOfTracksInSection:(TracksSection *)tracksSection;
- (NSString *)titleOfTracksSection:(TracksSection *)tracksSection;
- (BOOL)canEditTracksSection:(TracksSection *)tracksSection;
- (kml::MarkId)tracksSection:(TracksSection *)tracksSection getTrackIdByRow:(NSInteger)row;
- (void)tracksSection:(TracksSection *)tracksSection onDeleteTrackInRow:(NSInteger)row;
@end
@protocol InfoSectionDelegate <NSObject>
- (UITableViewCell *)infoCellForTableView:(UITableView *)tableView;
@end
@interface BookmarksSection : NSObject <TableSectionDelegate>
@property (nullable, nonatomic) NSNumber * blockIndex;
- (instancetype)initWithDelegate:(id<BookmarksSectionDelegate>)delegate;
- (instancetype)initWithBlockIndex:(NSNumber *)blockIndex delegate:(id<BookmarksSectionDelegate>)delegate;
@end
@interface TracksSection : NSObject <TableSectionDelegate>
@property (nullable, nonatomic) NSNumber * blockIndex;
- (instancetype)initWithDelegate:(id<TracksSectionDelegate>)delegate;
- (instancetype)initWithBlockIndex:(NSNumber *)blockIndex delegate: (id<TracksSectionDelegate>)delegate;
@end
@interface InfoSection : NSObject <TableSectionDelegate>
- (instancetype)initWithDelegate:(id<InfoSectionDelegate>)delegate;
@end

View file

@ -0,0 +1,267 @@
#import "BookmarksSection.h"
#import "CircleView.h"
#import "ColorPickerView.h"
#import "MWMBookmarksManager.h"
#import "MWMCategoryInfoCell.h"
#import "MWMLocationHelpers.h"
#import "MWMSearchManager.h"
#include "Framework.h"
#include "geometry/distance_on_sphere.hpp"
namespace
{
CGFloat const kPinDiameter = 22.0f;
} // namespace
@interface BookmarksSection()
@property (weak, nonatomic) id<BookmarksSectionDelegate> delegate;
@end
@implementation BookmarksSection
- (instancetype)initWithDelegate: (id<BookmarksSectionDelegate>)delegate
{
return [self initWithBlockIndex:nil delegate:delegate];
}
- (instancetype)initWithBlockIndex:(NSNumber *)blockIndex delegate:(id<BookmarksSectionDelegate>)delegate
{
self = [super init];
if (self)
{
_blockIndex = blockIndex;
_delegate = delegate;
}
return self;
}
- (NSInteger)numberOfRows
{
return [self.delegate numberOfBookmarksInSection:self];
}
- (NSString *)title
{
return [self.delegate titleOfBookmarksSection:self];
}
- (BOOL)canEdit
{
return [self.delegate canEditBookmarksSection:self];
}
- (void)fillCell: (UITableViewCell *)cell withBookmarkDetails: (Bookmark const *)bookmark andLocation:(CLLocation *)location
{
std::vector<std::string> details;
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;
if (!types.empty())
details.push_back(kml::GetLocalizedFeatureType(types));
auto const detailText = strings::JoinStrings(details, " • ");
if (!detailText.empty())
cell.detailTextLabel.text = @(detailText.c_str());
else
cell.detailTextLabel.text = nil;
}
- (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);
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];
[self fillCell:cell withBookmarkDetails:bookmark andLocation:lastLocation];
return cell;
}
- (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);
if (!bookmark)
return;
CLLocation * location = [[CLLocation alloc] initWithLatitude:info.m_latitude longitude:info.m_longitude];
[self fillCell:cell withBookmarkDetails:bookmark andLocation:location];
}
- (BOOL)didSelectRow: (NSInteger)row
{
kml::MarkId const bmId = [self.delegate bookmarkSection:self getBookmarkIdByRow:row];
[Statistics logEvent:kStatEventName(kStatBookmarks, kStatShowOnMap)];
// Same as "Close".
[MWMSearchManager manager].state = MWMSearchManagerStateHidden;
GetFramework().ShowBookmark(bmId);
return YES;
}
- (void)deleteRow: (NSInteger)row
{
kml::MarkId const bmId = [self.delegate bookmarkSection:self getBookmarkIdByRow:row];
[[MWMBookmarksManager sharedManager] deleteBookmark:bmId];
[self.delegate bookmarkSection:self onDeleteBookmarkInRow:row];
}
@end
////////////////////////////////////////////////////////
@interface TracksSection()
@property (weak, nonatomic) id<TracksSectionDelegate> delegate;
@end
@implementation TracksSection
- (instancetype)initWithDelegate:(id<TracksSectionDelegate>)delegate
{
return [self initWithBlockIndex:nil delegate:delegate];
}
- (instancetype)initWithBlockIndex:(NSNumber *)blockIndex delegate: (id<TracksSectionDelegate>)delegate
{
self = [super init];
if (self)
{
_blockIndex = blockIndex;
_delegate = delegate;
}
return self;
}
- (NSInteger)numberOfRows
{
return [self.delegate numberOfTracksInSection:self];
}
- (NSString *)title
{
return [self.delegate titleOfTracksSection:self];
}
- (BOOL)canEdit
{
return [self.delegate canEditTracksSection:self];
}
- (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();
kml::TrackId const trackId = [self.delegate tracksSection:self getTrackIdByRow:row];
Track const * track = bm.GetTrack(trackId);
cell.textLabel.text = @(track->GetName().c_str());
string dist;
if (measurement_utils::FormatDistance(track->GetLengthMeters(), dist))
//Change Length before release!!!
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ %@", L(@"length"), @(dist.c_str())];
else
cell.detailTextLabel.text = nil;
dp::Color const c = track->GetColor(0);
cell.imageView.image = [CircleView createCircleImageWith:kPinDiameter
andColor:[UIColor colorWithRed:c.GetRed()/255.f
green:c.GetGreen()/255.f
blue:c.GetBlue()/255.f
alpha:1.f]];
return cell;
}
- (BOOL)didSelectRow: (NSInteger)row
{
kml::TrackId const trackId = [self.delegate tracksSection:self getTrackIdByRow:row];
GetFramework().ShowTrack(trackId);
return YES;
}
- (void)deleteRow: (NSInteger)row
{
// TODO(@darina): [[MWMBookmarksManager sharedManager] deleteTrack:bmId];?
kml::TrackId const trackId = [self.delegate tracksSection:self getTrackIdByRow:row];
auto & bm = GetFramework().GetBookmarkManager();
bm.GetEditSession().DeleteTrack(trackId);
[self.delegate tracksSection:self onDeleteTrackInRow:row];
}
@end
////////////////////////////////////////////////////////
@interface InfoSection()
@property (weak, nonatomic) id<InfoSectionDelegate> delegate;
@end
@implementation InfoSection
- (instancetype)initWithDelegate: (id<InfoSectionDelegate>)delegate
{
self = [super init];
if (self)
{
_delegate = delegate;
}
return self;
}
- (NSInteger)numberOfRows
{
return 1;
}
- (NSString *)title
{
return L(@"placepage_place_description");
}
- (BOOL)canEdit
{
return NO;
}
- (UITableViewCell *)tableView: (UITableView *)tableView cellForRow: (NSInteger)row
{
return [self.delegate infoCellForTableView:tableView];
}
- (BOOL)didSelectRow: (NSInteger)row
{
return NO;
}
- (void)deleteRow: (NSInteger)row
{
}
@end

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -13,9 +13,16 @@
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="BookmarksVC" customModule="maps_me" customModuleProvider="target">
<connections>
<outlet property="downloadedCategoryToolbar" destination="lox-EJ-BTW" id="q8N-7N-FxS"/>
<outlet property="hideSearchBar" destination="rHp-eh-4pP" id="OwI-2X-3vq"/>
<outlet property="moreItem" destination="SzW-hJ-oy9" id="aRd-eB-gSj"/>
<outlet property="myCategoryToolbar" destination="uNd-fM-YVD" id="dYH-H1-P8u"/>
<outlet property="sharingOptionsItem" destination="U4v-rd-kcf" id="vlw-yQ-uUA"/>
<outlet property="noResultsBottom" destination="d1b-HE-ApF" id="3vy-xW-aew"/>
<outlet property="noResultsContainer" destination="eGH-Rr-EJq" id="vaj-qX-IeS"/>
<outlet property="searchBar" destination="CQZ-YM-Mk4" id="1DX-m0-Vok"/>
<outlet property="showSearchBar" destination="GJx-FV-8CF" id="PkO-sS-pSv"/>
<outlet property="sortItem" destination="U4v-rd-kcf" id="vlw-yQ-uUA"/>
<outlet property="sortSpinnerItem" destination="bgr-Fc-kub" id="7q1-gI-Wxt"/>
<outlet property="statusBarBackground" destination="S4A-UM-s8p" id="4DY-Of-VqX"/>
<outlet property="tableView" destination="sBT-45-bnw" id="zSc-eX-NZC"/>
<outlet property="view" destination="iN0-l3-epB" id="jfu-i2-8ie"/>
<outlet property="viewOnMapItem" destination="zDI-L0-Fjj" id="O8a-cu-AsX"/>
@ -26,8 +33,16 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="eGH-Rr-EJq">
<rect key="frame" x="27.5" y="173.5" width="320" height="320"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="320" id="6G5-oW-coH"/>
<constraint firstAttribute="width" secondItem="eGH-Rr-EJq" secondAttribute="height" multiplier="1:1" priority="999" id="LzS-Q2-IYS"/>
</constraints>
</view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="sBT-45-bnw">
<rect key="frame" x="0.0" y="20" width="375" height="603"/>
<rect key="frame" x="0.0" y="76" width="375" height="547"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="pressBackground"/>
@ -37,27 +52,6 @@
<outlet property="delegate" destination="-1" id="2dq-o5-nMb"/>
</connections>
</tableView>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uNd-fM-YVD">
<rect key="frame" x="0.0" y="623" width="375" height="44"/>
<items>
<barButtonItem width="16" style="plain" systemItem="fixedSpace" id="jsx-WU-dhT"/>
<barButtonItem title="Sharing options" style="plain" id="U4v-rd-kcf">
<connections>
<action selector="onSharingOptions:" destination="-1" id="Nvj-G6-K6X"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="Hpc-In-hqh"/>
<barButtonItem title="More..." style="plain" id="SzW-hJ-oy9">
<connections>
<action selector="onMore:" destination="-1" id="lBH-EV-C9v"/>
</connections>
</barButtonItem>
<barButtonItem width="16" style="plain" systemItem="fixedSpace" id="YAt-eE-x2I"/>
</items>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="white"/>
</userDefinedRuntimeAttributes>
</toolbar>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lox-EJ-BTW">
<rect key="frame" x="0.0" y="623" width="375" height="44"/>
<items>
@ -73,19 +67,67 @@
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="white"/>
</userDefinedRuntimeAttributes>
</toolbar>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uNd-fM-YVD">
<rect key="frame" x="0.0" y="623" width="375" height="44"/>
<items>
<barButtonItem width="16" style="plain" systemItem="fixedSpace" id="jsx-WU-dhT"/>
<barButtonItem title="Sort" style="plain" id="U4v-rd-kcf">
<connections>
<action selector="onSort:" destination="-1" id="Nvj-G6-K6X"/>
</connections>
</barButtonItem>
<barButtonItem width="16" style="plain" id="bgr-Fc-kub"/>
<barButtonItem style="plain" systemItem="flexibleSpace" id="Hpc-In-hqh"/>
<barButtonItem title="More..." style="plain" id="SzW-hJ-oy9">
<connections>
<action selector="onMore:" destination="-1" id="lBH-EV-C9v"/>
</connections>
</barButtonItem>
<barButtonItem width="16" style="plain" systemItem="fixedSpace" id="YAt-eE-x2I"/>
</items>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="white"/>
</userDefinedRuntimeAttributes>
</toolbar>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="S4A-UM-s8p">
<rect key="frame" x="0.0" y="-32" width="375" height="108"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="108" id="R0d-xI-qxQ"/>
</constraints>
</view>
<searchBar contentMode="redraw" translatesAutoresizingMaskIntoConstraints="NO" id="CQZ-YM-Mk4">
<rect key="frame" x="0.0" y="20" width="375" height="56"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" priority="750" constant="44" id="GJx-FV-8CF"/>
<constraint firstAttribute="height" priority="250" id="rHp-eh-4pP"/>
</constraints>
<textInputTraits key="textInputTraits"/>
</searchBar>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="uNd-fM-YVD" secondAttribute="trailing" id="34g-uY-Sux"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="lox-EJ-BTW" secondAttribute="bottom" id="3A5-UK-ohJ"/>
<constraint firstItem="uNd-fM-YVD" firstAttribute="top" secondItem="sBT-45-bnw" secondAttribute="bottom" id="3Ki-Wg-en5"/>
<constraint firstItem="CQZ-YM-Mk4" firstAttribute="trailing" secondItem="vUN-kp-3ea" secondAttribute="trailing" id="Cci-iR-01c"/>
<constraint firstItem="uNd-fM-YVD" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="DzR-ER-jD4"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="sBT-45-bnw" secondAttribute="trailing" id="GS0-Rr-fBB"/>
<constraint firstItem="S4A-UM-s8p" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="Mmb-vi-04p"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="uNd-fM-YVD" secondAttribute="bottom" id="Oxb-Wq-fvG"/>
<constraint firstItem="CQZ-YM-Mk4" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" id="Rm6-dw-N0b"/>
<constraint firstItem="S4A-UM-s8p" firstAttribute="bottom" secondItem="CQZ-YM-Mk4" secondAttribute="bottom" id="TDJ-kZ-bcu"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="lox-EJ-BTW" secondAttribute="trailing" id="V1B-Y8-uLf"/>
<constraint firstItem="sBT-45-bnw" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" id="biK-L7-5qY"/>
<constraint firstItem="eGH-Rr-EJq" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" priority="750" id="aln-fh-XqA"/>
<constraint firstItem="sBT-45-bnw" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="cPb-Wt-26Z"/>
<constraint firstItem="S4A-UM-s8p" firstAttribute="trailing" secondItem="vUN-kp-3ea" secondAttribute="trailing" id="czZ-o2-KQr"/>
<constraint firstItem="eGH-Rr-EJq" firstAttribute="bottom" relation="lessThanOrEqual" secondItem="iN0-l3-epB" secondAttribute="bottom" id="d1b-HE-ApF"/>
<constraint firstItem="eGH-Rr-EJq" firstAttribute="top" relation="greaterThanOrEqual" secondItem="CQZ-YM-Mk4" secondAttribute="bottom" id="iES-lf-sJD"/>
<constraint firstItem="CQZ-YM-Mk4" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="n9f-0C-CPH"/>
<constraint firstItem="eGH-Rr-EJq" firstAttribute="height" relation="lessThanOrEqual" secondItem="iN0-l3-epB" secondAttribute="height" id="sMa-Xr-abe"/>
<constraint firstItem="lox-EJ-BTW" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="xFB-3S-laD"/>
<constraint firstItem="sBT-45-bnw" firstAttribute="top" secondItem="CQZ-YM-Mk4" secondAttribute="bottom" id="z9p-fb-qAp"/>
<constraint firstItem="eGH-Rr-EJq" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="zuq-4u-j3n"/>
</constraints>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<userDefinedRuntimeAttributes>

View file

@ -1,4 +1,5 @@
#import "MWMTableViewCell.h"
#import "BookmarksSection.h"
namespace kml
{
@ -7,7 +8,7 @@ struct CategoryData;
@class MWMCategoryInfoCell;
@protocol MWMCategoryInfoCellDelegate
@protocol MWMCategoryInfoCellDelegate <InfoSectionDelegate>
- (void)categoryInfoCellDidPressMore:(MWMCategoryInfoCell *)cell;

View file

@ -3,7 +3,9 @@
@interface CircleView : UIView
- (id)initWithFrame:(CGRect)frame andColor:(UIColor *)color;
- (id)initWithFrame:(CGRect)frame andColor:(UIColor *)color andImageName:(NSString *)imageName;
+ (UIImage *)createCircleImageWith:(CGFloat)diameter andColor:(UIColor *)color;
+ (UIImage *)createCircleImageWith:(CGFloat)diameter andColor:(UIColor *)color andImageName:(NSString *)imageName;
+ (UIImage *)createCircleImageWith:(CGFloat)diameter andColor:(UIColor *)color andSubview:(UIView *)view;
@end

View file

@ -5,17 +5,25 @@
@interface CircleView()
@property (nonatomic) UIColor * circleColor;
@property (nonatomic) UIImage * image;
@end
@implementation CircleView
- (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
{
self = [super initWithFrame:frame];
if (self)
{
_circleColor = color;
if (imageName)
_image = [UIImage imageNamed:[NSString stringWithFormat:@"%@%@", @"ic_bm_", [imageName lowercaseString]]];
self.opaque = NO;
}
return self;
@ -27,26 +35,35 @@
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
+ (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];
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];
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];
return [self imageWithView:circle];
}
+ (UIImage *)createCircleImageWith:(CGFloat)diameter andColor:(UIColor *)color andSubview:(UIView *)view
{
UIView * circle = [self createViewWithCircleDiameter:diameter andColor:color];
UIView * circle = [self createViewWithCircleDiameter:diameter andColor:color andImageName:nil];
[circle addSubview:view];
return [self imageWithView:circle];
}

View file

@ -19,14 +19,14 @@ struct Tcolor
static Tcolor const g_color [] =
{
{kml::PredefinedColor::Red, {255, 51, 51}},
{kml::PredefinedColor::Yellow, {255, 255, 51}},
{kml::PredefinedColor::Blue, {51, 204, 255}},
{kml::PredefinedColor::Green, {102, 255, 51}},
{kml::PredefinedColor::Purple, {153, 51, 255}},
{kml::PredefinedColor::Orange, {255, 102, 0}},
{kml::PredefinedColor::Brown, {102, 51, 0}},
{kml::PredefinedColor::Pink, {255, 51, 255}},
{kml::PredefinedColor::Red, {229, 27, 35}},
{kml::PredefinedColor::Yellow, {255, 200, 0}},
{kml::PredefinedColor::Blue, {0, 110, 199}},
{kml::PredefinedColor::Green, {56, 142, 60}},
{kml::PredefinedColor::Purple, {156, 39, 176}},
{kml::PredefinedColor::Orange, {255, 160, 0}},
{kml::PredefinedColor::Brown, {121, 85, 72}},
{kml::PredefinedColor::Pink, {255, 65, 130}},
};
@implementation ColorPickerView

View file

@ -17,8 +17,10 @@ typedef NS_ENUM(NSUInteger, MWMTheme) {
};
typedef uint64_t MWMMarkID;
typedef uint64_t MWMLineID;
typedef uint64_t MWMTrackID;
typedef uint64_t MWMMarkGroupID;
typedef NSArray<NSNumber *> * MWMMarkIDCollection;
typedef NSArray<NSNumber *> * MWMTrackIDCollection;
typedef NSArray<NSNumber *> * MWMGroupIDCollection;
typedef NS_ENUM(NSUInteger, MWMBookmarksShareStatus) {

View file

@ -589,6 +589,7 @@
BB8123CF212C264700ADE512 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BB8123CD212C264700ADE512 /* Metal.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
BB8123D0212C264700ADE512 /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BB8123CE212C264700ADE512 /* MetalKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
BB8123D62130427E00ADE512 /* MetalContextFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = BB8123D52130427E00ADE512 /* MetalContextFactory.mm */; };
BBED27022292F6C000788143 /* BookmarksSection.mm in Sources */ = {isa = PBXBuildFile; fileRef = BBED27012292F6C000788143 /* BookmarksSection.mm */; };
CD08887422B7ABB400C1368D /* MWMDiscoveryCollectionView.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD08887322B7ABB400C1368D /* MWMDiscoveryCollectionView.mm */; };
CD4A1F132305872700F2A6B6 /* PromoBookingPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD4A1F122305872700F2A6B6 /* PromoBookingPresentationController.swift */; };
CD4A1F1A230EADC100F2A6B6 /* CatalogConnectionErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD4A1F19230EADC100F2A6B6 /* CatalogConnectionErrorView.swift */; };
@ -1678,6 +1679,8 @@
BB8123CE212C264700ADE512 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; };
BB8123D42130427E00ADE512 /* MetalContextFactory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MetalContextFactory.h; sourceTree = "<group>"; };
BB8123D52130427E00ADE512 /* MetalContextFactory.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MetalContextFactory.mm; sourceTree = "<group>"; };
BBED27002292F42000788143 /* BookmarksSection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BookmarksSection.h; sourceTree = "<group>"; };
BBED27012292F6C000788143 /* BookmarksSection.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = BookmarksSection.mm; sourceTree = "<group>"; };
CD08887222B7ABB400C1368D /* MWMDiscoveryCollectionView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMDiscoveryCollectionView.h; sourceTree = "<group>"; };
CD08887322B7ABB400C1368D /* MWMDiscoveryCollectionView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMDiscoveryCollectionView.mm; sourceTree = "<group>"; };
CD08888322BCF1C800C1368D /* maps.me rel.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = "maps.me rel.entitlements"; sourceTree = "<group>"; };
@ -4730,6 +4733,8 @@
FA054610155C465E001F4E37 /* SelectSetVC.h */,
FA054611155C465E001F4E37 /* SelectSetVC.mm */,
B33D21B720E130D000BAD749 /* BookmarksTabViewController.swift */,
BBED27002292F42000788143 /* BookmarksSection.h */,
BBED27012292F6C000788143 /* BookmarksSection.mm */,
);
path = Bookmarks;
sourceTree = "<group>";
@ -5318,6 +5323,7 @@
6741A9CF1BF340DE002C974C /* MWMLocationAlert.mm in Sources */,
474AC76C2139E4F2002F9BF9 /* RemoveAdsViewController.swift in Sources */,
34ABA62D1C2D57D500FE1BEC /* MWMInputPasswordValidator.mm in Sources */,
BBED27022292F6C000788143 /* BookmarksSection.mm in Sources */,
F6E2FDA11E097BA00083EBEC /* MWMEditorAdditionalNamesTableViewController.mm in Sources */,
4767CDA620AB1F6200BD8166 /* LeftAlignedIconButton.swift in Sources */,
3454D7D41E07F045004AF2AD /* UIImageView+Coloring.mm in Sources */,