[ios] UI fixes

This commit is contained in:
Igor Khmurets 2014-08-04 19:10:53 +03:00 committed by Alex Zolotarev
parent 2f3df596d9
commit e058c46a90
10 changed files with 159 additions and 83 deletions

View file

@ -3,4 +3,10 @@
@interface CopyLabel : UILabel
@end
@interface CopyView : UIView
@property (nonatomic) NSString * textToCopy;
@end

View file

@ -28,3 +28,24 @@
}
@end
@implementation CopyView
- (BOOL)canBecomeFirstResponder
{
return YES;
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
return action == @selector(copy:);
}
- (void)copy:(id)sender
{
[UIPasteboard generalPasteboard].string = self.textToCopy;
}
@end

View file

@ -608,7 +608,14 @@ const long long LITE_IDL = 431183278L;
if (self.apiMode)
return UIStatusBarStyleLightContent;
else
return self.searchView.state != SearchViewStateHidden ? UIStatusBarStyleLightContent : UIStatusBarStyleDefault;
{
UIStatusBarStyle style = UIStatusBarStyleDefault;
if (self.searchView.state != SearchViewStateHidden)
style = UIStatusBarStyleLightContent;
if (self.containerView.placePage.state != PlacePageStateHidden)
style = UIStatusBarStyleDefault;
return style;
}
}
- (id)initWithCoder:(NSCoder *)coder

View file

@ -15,7 +15,7 @@
[self.contentView addSubview:self.titleLabel];
UIView * selectedBackgroundView = [[UIView alloc] initWithFrame:self.bounds];
selectedBackgroundView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.2];
selectedBackgroundView.backgroundColor = [UIColor colorWithColorCode:@"F0F0F0"];
self.selectedBackgroundView = selectedBackgroundView;
UIImageView * editImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"PlacePageEditButton"]];

View file

@ -15,12 +15,12 @@
@interface PlacePageInfoCell : UITableViewCell
+ (CGFloat)cellHeightWithAddress:(NSString *)address viewWidth:(CGFloat)viewWidth inMyPositionMode:(BOOL)myPositon;
+ (CGFloat)cellHeightWithViewWidth:(CGFloat)viewWidth inMyPositionMode:(BOOL)myPositon;
- (void)setAddress:(NSString *)address pinPoint:(m2::PointD)point;
- (void)updateDistance;
- (void)updateCoordinates;
@property (nonatomic) m2::PointD pinPoint;
@property (nonatomic) UIColor * color;
@property (nonatomic) BOOL myPositionMode;

View file

@ -14,14 +14,13 @@
@interface PlacePageInfoCell () <SelectedColorViewDelegate>
@property (nonatomic) UILabel * distanceLabel;
@property (nonatomic) CopyLabel * addressLabel;
@property (nonatomic) CopyLabel * coordinatesLabel;
@property (nonatomic) CopyView * coordinatesView;
@property (nonatomic) UILabel * latitudeLabel;
@property (nonatomic) UILabel * longitudeLabel;
@property (nonatomic) SmallCompassView * compassView;
@property (nonatomic) UIImageView * separatorView;
@property (nonatomic) SelectedColorView * selectedColorView;
@property (nonatomic) m2::PointD pinPoint;
@end
@implementation PlacePageInfoCell
@ -34,8 +33,9 @@
[self addSubview:self.compassView];
[self addSubview:self.distanceLabel];
[self addSubview:self.addressLabel];
[self addSubview:self.coordinatesLabel];
[self addSubview:self.coordinatesView];
[self.coordinatesView addSubview:self.latitudeLabel];
[self.coordinatesView addSubview:self.longitudeLabel];
[self addSubview:self.selectedColorView];
[self addSubview:self.separatorView];
@ -80,71 +80,84 @@
{
point = self.pinPoint;
}
string const coords = useDMS ? MeasurementUtils::FormatMercatorAsDMS(point, 2)
: MeasurementUtils::FormatMercator(point, 6);
self.coordinatesLabel.text = [NSString stringWithUTF8String:coords.c_str()];
int const dmcDac = 2;
int const dac = 6;
string const coords = useDMS ? MeasurementUtils::FormatMercatorAsDMS(point, dmcDac)
: MeasurementUtils::FormatMercator(point, dac);
self.coordinatesView.textToCopy = [NSString stringWithUTF8String:coords.c_str()];
string lat;
string lon;
if (useDMS)
MeasurementUtils::FormatMercatorAsDMS(point, lat, lon, dmcDac);
else
MeasurementUtils::FormatMercator(point, lat, lon, dac);
self.longitudeLabel.text = [NSString stringWithUTF8String:lon.c_str()];
self.latitudeLabel.text = [NSString stringWithUTF8String:lat.c_str()];
}
- (void)setAddress:(NSString *)address pinPoint:(m2::PointD)point
- (void)setPinPoint:(m2::PointD)pinPoint
{
self.pinPoint = point;
self.addressLabel.text = address;
_pinPoint = pinPoint;
self.distanceLabel.text = [self distance];
[self updateCoordinates];
}
#define ADDRESS_LEFT_SHIFT 19
#define COORDINATES_RIGHT_SHIFT 42
#define RIGHT_SHIFT 55
#define DISTANCE_LEFT_SHIFT 55
#define ADDRESS_FONT [UIFont fontWithName:@"HelveticaNeue-Light" size:17.5]
#define LEFT_SHIFT 20
- (void)layoutSubviews
{
[self.latitudeLabel sizeToFit];
[self.longitudeLabel sizeToFit];
BOOL const shouldShowLocationViews = [[MapsAppDelegate theApp].m_locationManager enabledOnMap] && !self.myPositionMode;
CGFloat addressY;
if (shouldShowLocationViews)
{
self.compassView.origin = CGPointMake(19, 17);
self.compassView.origin = CGPointMake(15, 12.5);
self.compassView.hidden = NO;
self.distanceLabel.frame = CGRectMake(DISTANCE_LEFT_SHIFT, 18, self.width - DISTANCE_LEFT_SHIFT - RIGHT_SHIFT, 24);
CGFloat const width = 134;
self.distanceLabel.text = @"12345";
self.distanceLabel.frame = CGRectMake(self.compassView.maxX + 15, 13, width, 20);
self.distanceLabel.hidden = NO;
addressY = 55;
self.coordinatesView.frame = CGRectMake(self.distanceLabel.minX, self.distanceLabel.maxY + 6, width, 44);
self.latitudeLabel.origin = CGPointMake(0, 0);
self.longitudeLabel.origin = CGPointMake(0, self.latitudeLabel.maxY);
}
else
{
self.compassView.hidden = YES;
self.distanceLabel.hidden = YES;
addressY = 15;
self.coordinatesView.frame = CGRectMake(LEFT_SHIFT, 5, 250, 44);
self.latitudeLabel.minX = 0;
self.latitudeLabel.midY = self.latitudeLabel.superview.height / 2;
self.longitudeLabel.minX = self.latitudeLabel.maxX + 8;
self.longitudeLabel.midY = self.longitudeLabel.superview.height / 2;
}
self.addressLabel.width = self.width - ADDRESS_LEFT_SHIFT - RIGHT_SHIFT;
[self.addressLabel sizeToFit];
self.addressLabel.origin = CGPointMake(ADDRESS_LEFT_SHIFT, addressY);
// coordinates label is wider than address label, to fit long DMS coordinates
CGFloat coordinatesShift = self.addressLabel.height ? 10 : 0;
self.coordinatesLabel.frame = CGRectMake(ADDRESS_LEFT_SHIFT, self.addressLabel.maxY + coordinatesShift, self.width - ADDRESS_LEFT_SHIFT - COORDINATES_RIGHT_SHIFT, 24);
self.selectedColorView.center = CGPointMake(self.width - 30, 27);
[self.selectedColorView setColor:self.color];
self.separatorView.maxY = self.height;
CGFloat const shift = 12.5;
self.separatorView.width = self.width - 2 * shift;
self.separatorView.minX = shift;
[self.selectedColorView setColor:self.color];
self.backgroundColor = [UIColor clearColor];
}
+ (CGFloat)cellHeightWithAddress:(NSString *)address viewWidth:(CGFloat)viewWidth inMyPositionMode:(BOOL)myPositon
+ (CGFloat)cellHeightWithViewWidth:(CGFloat)viewWidth inMyPositionMode:(BOOL)myPositon
{
NSString * addressCopy = [address copy];
if ([addressCopy isEqualToString:@""])
addressCopy = nil;
CGFloat addressHeight = [addressCopy sizeWithDrawSize:CGSizeMake(viewWidth - ADDRESS_LEFT_SHIFT - RIGHT_SHIFT, 200) font:ADDRESS_FONT].height;
BOOL const shouldShowLocationViews = [[MapsAppDelegate theApp].m_locationManager enabledOnMap] && !myPositon;
return addressHeight + (shouldShowLocationViews ? 100 : 56) + (addressHeight ? 10 : 0);
return shouldShowLocationViews ? 95 : 55;
}
- (void)addressPress:(id)sender
@ -196,40 +209,45 @@
return _distanceLabel;
}
- (CopyLabel *)addressLabel
- (CopyView *)coordinatesView
{
if (!_addressLabel)
if (!_coordinatesView)
{
_addressLabel = [[CopyLabel alloc] initWithFrame:CGRectZero];
_addressLabel.backgroundColor = [UIColor clearColor];
_addressLabel.font = ADDRESS_FONT;
_addressLabel.numberOfLines = 0;
_addressLabel.lineBreakMode = NSLineBreakByWordWrapping;
_addressLabel.textAlignment = NSTextAlignmentLeft;
_addressLabel.textColor = [UIColor blackColor];
_addressLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
UILongPressGestureRecognizer * press = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(addressPress:)];
[_addressLabel addGestureRecognizer:press];
_coordinatesView = [[CopyView alloc] initWithFrame:CGRectZero];
_coordinatesView.backgroundColor = [UIColor clearColor];
_coordinatesView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
UILongPressGestureRecognizer * press = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(coordinatesPress:)];
[_coordinatesView addGestureRecognizer:press];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(coordinatesTap:)];
[_coordinatesView addGestureRecognizer:tap];
}
return _addressLabel;
return _coordinatesView;
}
- (CopyLabel *)coordinatesLabel
- (UILabel *)latitudeLabel
{
if (!_coordinatesLabel)
if (!_latitudeLabel)
{
_coordinatesLabel = [[CopyLabel alloc] initWithFrame:CGRectZero];
_coordinatesLabel.backgroundColor = [UIColor clearColor];
_coordinatesLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:17.5];
_coordinatesLabel.textAlignment = NSTextAlignmentLeft;
_coordinatesLabel.textColor = [UIColor blackColor];
_coordinatesLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
UILongPressGestureRecognizer * press = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(coordinatesPress:)];
[_coordinatesLabel addGestureRecognizer:press];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(coordinatesTap:)];
[_coordinatesLabel addGestureRecognizer:tap];
_latitudeLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_latitudeLabel.backgroundColor = [UIColor clearColor];
_latitudeLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:18];
_latitudeLabel.textAlignment = NSTextAlignmentLeft;
_latitudeLabel.textColor = [UIColor blackColor];
}
return _coordinatesLabel;
return _latitudeLabel;
}
- (UILabel *)longitudeLabel
{
if (!_longitudeLabel)
{
_longitudeLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_longitudeLabel.backgroundColor = [UIColor clearColor];
_longitudeLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:18];
_longitudeLabel.textAlignment = NSTextAlignmentLeft;
_longitudeLabel.textColor = [UIColor blackColor];
}
return _longitudeLabel;
}
- (SelectedColorView *)selectedColorView

View file

@ -199,7 +199,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
if (!cell) // only for iOS 5
cell = [[PlacePageInfoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[PlacePageInfoCell className]];
[cell setAddress:self.address pinPoint:[self pinPoint]];
cell.pinPoint = [self pinPoint];
cell.color = [ColorPickerView colorForName:[self colorName]];
cell.selectedColorView.alpha = [self isBookmark] ? 1 : 0;
cell.delegate = self;
@ -253,7 +253,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
{
CellRow row = [self cellRowForIndexPath:indexPath];
if (row == CellRowCommon)
return [PlacePageInfoCell cellHeightWithAddress:self.address viewWidth:tableView.width inMyPositionMode:[self isMyPosition]];
return [PlacePageInfoCell cellHeightWithViewWidth:tableView.width inMyPositionMode:[self isMyPosition]];
else if (row == CellRowSet)
return [PlacePageEditCell cellHeightWithTextValue:self.setName viewWidth:tableView.width];
else if (row == CellRowInfo)
@ -275,7 +275,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
[self.delegate placePageView:self willEditProperty:@"Description" inBookmarkAndCategory:GetFramework().FindBookmark([self userMark])];
}
#define TITLE_LABEL_LANDSCAPE_LEFT_OFFSET 20
#define TITLE_LABEL_LEFT_OFFSET 20
#define TYPES_LABEL_LANDSCAPE_RIGHT_OFFSET 80
- (void)reloadHeader
@ -291,20 +291,22 @@ typedef NS_ENUM(NSUInteger, CellRow)
self.typeLabel.width = [self typesWidth];
[self.typeLabel sizeToFit];
self.bookmarkButton.midX = self.headerView.width - 29.5;
self.titleLabel.minX = TITLE_LABEL_LEFT_OFFSET;
if ([self iPhoneInLandscape] && !IPAD)
{
self.titleLabel.origin = CGPointMake(12.5, 24);
self.titleLabel.minY = 25;
self.typeLabel.textAlignment = NSTextAlignmentRight;
self.typeLabel.maxY = self.titleLabel.maxY;
self.typeLabel.maxX = self.width - TYPES_LABEL_LANDSCAPE_RIGHT_OFFSET;
self.bookmarkButton.center = CGPointMake(self.headerView.width - 24, 36);
self.bookmarkButton.midY = 37;
}
else
{
self.titleLabel.origin = CGPointMake(15, 27);
self.titleLabel.minY = 24;
self.typeLabel.textAlignment = NSTextAlignmentLeft;
self.typeLabel.origin = CGPointMake(self.titleLabel.minX, self.titleLabel.maxY + 2);
self.bookmarkButton.center = CGPointMake(self.headerView.width - 25, 39);
self.bookmarkButton.midY = 39;
}
}
@ -315,7 +317,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
- (CGFloat)typesWidth
{
CGFloat const landscapeWidth = self.width - TITLE_LABEL_LANDSCAPE_LEFT_OFFSET - [self titleWidth] - TYPES_LABEL_LANDSCAPE_RIGHT_OFFSET - 8;
CGFloat const landscapeWidth = self.width - TITLE_LABEL_LEFT_OFFSET - [self titleWidth] - TYPES_LABEL_LANDSCAPE_RIGHT_OFFSET - 8;
return [self iPhoneInLandscape] ? landscapeWidth : self.width - 90;
}
@ -324,9 +326,9 @@ typedef NS_ENUM(NSUInteger, CellRow)
CGFloat titleHeight = [self.title sizeWithDrawSize:CGSizeMake([self titleWidth], 200) font:self.titleLabel.font].height;
CGFloat typesHeight = [self.types sizeWithDrawSize:CGSizeMake([self typesWidth], 200) font:self.typeLabel.font].height;
if ([self iPhoneInLandscape] && !IPAD)
return MAX(titleHeight, typesHeight) + 52;
return MAX(titleHeight, typesHeight) + 34;
else
return titleHeight + typesHeight + 57;
return titleHeight + typesHeight + 39;
}
- (BOOL)iPhoneInLandscape
@ -365,7 +367,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
}
}
#define BOTTOM_SHADOW_OFFSET 20
#define BOTTOM_SHADOW_OFFSET 18
- (void)layoutSubviews
{
@ -398,19 +400,21 @@ typedef NS_ENUM(NSUInteger, CellRow)
if (self.state == PlacePageStatePreview)
{
self.tableView.alpha = 0;
self.titleLabel.userInteractionEnabled = NO;
self.arrowImageView.center = CGPointMake(self.width / 2, [self headerHeight] - 10);
self.arrowImageView.center = CGPointMake(self.width / 2, [self headerHeight] + BOTTOM_SHADOW_OFFSET - 10);
[UIView animateWithDuration:(animated ? 0.4 : 0) delay:0 damping:damping initialVelocity:0 options:options animations:^{
self.arrowImageView.alpha = 1;
[self updateHeight:[self headerHeight]];
[self updateHeight:([self headerHeight] + BOTTOM_SHADOW_OFFSET)];
self.minY = [self viewMinY];
self.headerSeparator.alpha = 0;
} completion:nil];
}
else if (self.state == PlacePageStateOpened)
{
self.tableView.alpha = 1;
self.titleLabel.userInteractionEnabled = YES;
CGFloat const infoCellHeight = [PlacePageInfoCell cellHeightWithAddress:self.address viewWidth:self.tableView.width inMyPositionMode:[self isMyPosition]];
CGFloat const infoCellHeight = [PlacePageInfoCell cellHeightWithViewWidth:self.tableView.width inMyPositionMode:[self isMyPosition]];
CGFloat fullHeight = [self headerHeight] + infoCellHeight + [PlacePageShareCell cellHeight] + (GetFramework().IsRoutingEnabled() ? [PlacePageRoutingCell cellHeight] : 0);
if ([self isBookmark])
{
@ -430,6 +434,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
{
[UIView animateWithDuration:(animated ? 0.4 : 0) delay:0 damping:damping initialVelocity:0 options:options animations:^{
self.maxY = 0;
self.tableView.alpha = 0;
} completion:nil];
}
@ -461,6 +466,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
if ([self isBookmark])
{
CGFloat newHeight = self.backgroundView.height + [PlacePageEditCell cellHeightWithTextValue:self.info viewWidth:self.tableView.width] + [PlacePageEditCell cellHeightWithTextValue:self.setName viewWidth:self.tableView.width];
newHeight = MIN(newHeight, [self maxHeight]);
CGFloat const headerHeight = [self headerHeight];
self.tableView.frame = CGRectMake(0, headerHeight, self.superview.width, newHeight - headerHeight - BOTTOM_SHADOW_OFFSET);
}
@ -1127,8 +1133,12 @@ typedef NS_ENUM(NSUInteger, CellRow)
{
if (!_arrowImageView)
{
_arrowImageView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
_arrowImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"PlacePageArrow"]];
_arrowImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];
_arrowImageView.image = [UIImage imageNamed:@"PlacePageArrow"];
_arrowImageView.contentMode = UIViewContentModeCenter;
_arrowImageView.userInteractionEnabled = YES;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
[_arrowImageView addGestureRecognizer:tap];
}
return _arrowImageView;
}

View file

@ -739,7 +739,7 @@ static void onSearchResultCallback(search::Results const & results)
_tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.backgroundColor = [UIColor colorWithColorCode:@"414451"];
_tableView.backgroundColor = [UIColor colorWithColorCode:@"1D1F29"];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}
return _tableView;

View file

@ -108,6 +108,12 @@ string FormatLatLonAsDMS(double lat, double lon, int dac)
FormatLatLonAsDMSImpl(lon, 'E', 'W', dac));
}
void FormatMercatorAsDMS(m2::PointD const & mercator, string & lat, string & lon, int dac)
{
lat = FormatLatLonAsDMSImpl(MercatorBounds::YToLat(mercator.y), 'N', 'S', dac);
lon = FormatLatLonAsDMSImpl(MercatorBounds::XToLon(mercator.x), 'E', 'W', dac);
}
string FormatMercatorAsDMS(m2::PointD const & mercator, int dac)
{
return FormatLatLonAsDMS(MercatorBounds::YToLat(mercator.y), MercatorBounds::XToLon(mercator.x), dac);
@ -124,6 +130,12 @@ string FormatMercator(m2::PointD const & mercator, int dac)
return FormatLatLon(MercatorBounds::YToLat(mercator.y), MercatorBounds::XToLon(mercator.x), dac);
}
void FormatMercator(m2::PointD const & mercator, string & lat, string & lon, int dac)
{
lat = FormatLatLon(MercatorBounds::YToLat(mercator.y), dac);
lon = FormatLatLon(MercatorBounds::XToLon(mercator.x), dac);
}
string FormatAltitude(double altitudeInMeters)
{
using namespace Settings;

View file

@ -31,8 +31,10 @@ string FormatSpeed(double metersPerSecond);
/// Use dac == 3 for our common conversions.
string FormatLatLonAsDMS(double lat, double lon, int dac = 3);
string FormatMercatorAsDMS(m2::PointD const & mercator, int dac = 3);
void FormatMercatorAsDMS(m2::PointD const & mercator, string & lat, string & lon, int dac = 3);
/// Simple decimal degrees formating
string FormatLatLon(double lat, double lon, int dac = 6);
string FormatMercator(m2::PointD const & mercator, int dac = 6);
void FormatMercator(m2::PointD const & mercator, string & lat, string & lon, int dac = 6);
}