[ios] Bug fixies

This commit is contained in:
Igor Khmurets 2014-05-29 02:02:27 +03:00 committed by Alex Zolotarev
parent 8f1bf32796
commit c9b0656867
18 changed files with 306 additions and 226 deletions

View file

@ -220,9 +220,9 @@
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
[[NSNotificationCenter defaultCenter] postNotificationName:BOOKMARK_CATEGORY_DELETED_NOTIFICATION object:@(indexPath.row)];
Framework & f = GetFramework();
f.DeleteBmCategory(indexPath.row);
[[NSNotificationCenter defaultCenter] postNotificationName:BOOKMARK_CATEGORY_DELETED_NOTIFICATION object:@(indexPath.row)];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
// Disable edit mode if no categories are left
if (!f.GetBmCategoriesCount())

View file

@ -305,10 +305,10 @@
}
else
{
cat->DeleteBookmark(indexPath.row);
BookmarkAndCategory bookmarkAndCategory = BookmarkAndCategory(m_categoryIndex, indexPath.row);
NSValue * value = [NSValue valueWithBytes:&bookmarkAndCategory objCType:@encode(BookmarkAndCategory)];
[[NSNotificationCenter defaultCenter] postNotificationName:BOOKMARK_DELETED_NOTIFICATION object:value];
cat->DeleteBookmark(indexPath.row);
}
}
cat->SaveToKMLFile();

View file

@ -22,6 +22,7 @@
+ (UIColor *)colorWithColorCode:(NSString *)colorCode;
+ (UIColor *)applicationBackgroundColor;
+ (UIColor *)applicationColor;
+ (UIColor *)navigationBarColor;
@end
@ -59,3 +60,7 @@
@end
@interface SolidTouchView : UIView
@end

View file

@ -46,9 +46,14 @@
return [UIColor colorWithColorCode:@"efeff4"];
}
+ (UIColor *)applicationColor
{
return [UIColor colorWithColorCode:@"15c783"];
}
+ (UIColor *)navigationBarColor
{
return [UIColor colorWithColorCode:@"28384b"];
return [UIColor colorWithColorCode:@"15c783"];
}
@end
@ -208,3 +213,15 @@
@end
@implementation SolidTouchView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {}
@end

View file

@ -1,6 +1,7 @@
#import "BookmarkNameVC.h"
#import "Framework.h"
#import "UIKitCategories.h"
@interface BookmarkNameVC ()
@ -20,6 +21,12 @@
Bookmark const * bookmark = category->GetBookmark(self.bookmarkAndCategory.second);
self.textField.text = bookmark->GetName().empty() ? NSLocalizedString(@"dropped_pin", nil) : [NSString stringWithUTF8String:bookmark->GetName().c_str()];
[self.textField addTarget:self action:@selector(textDidChange:) forControlEvents:UIControlEventEditingChanged];
}
- (void)textDidChange:(UITextField *)textField
{
textField.text = [textField.text capitalizedString];
}
- (void)viewDidAppear:(BOOL)animated

View file

@ -8,7 +8,7 @@
@interface BottomMenu () <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic) UITableView * tableView;
@property (nonatomic) UIView * fadeView;
@property (nonatomic) SolidTouchView * fadeView;
@property (nonatomic) NSArray * items;
@ -64,18 +64,8 @@
cell = [[BottomMenuCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[BottomMenuCell className]];
cell.iconImageView.image = self.items[indexPath.row][@"Icon"];
NSInteger wordsCount = [[self.items[indexPath.row][@"Title"] componentsSeparatedByString:@" "] count];
if (wordsCount > 1)
{
cell.titleLabel.numberOfLines = 0;
cell.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
}
else
{
cell.titleLabel.numberOfLines = 1;
cell.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
}
cell.titleLabel.text = self.items[indexPath.row][@"Title"];
cell.titleLabel.textColor = [UIColor whiteColor];
return cell;
}
@ -86,7 +76,8 @@
cell = [[BottomMenuCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[BottomMenuCell className]];
cell.titleLabel.text = NSLocalizedString(@"become_a_pro", nil);
cell.iconImageView.image = [UIImage imageNamed:@"IconMWMPro"];
cell.iconImageView.image = [UIImage imageNamed:@"MWMProIcon"];
cell.titleLabel.textColor = [UIColor applicationColor];
return cell;
}
@ -100,14 +91,11 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (GetPlatform().IsPro() || (!GetPlatform().IsPro() && indexPath.section == 1))
{
[self.delegate bottomMenu:self didPressItemWithName:self.items[indexPath.row][@"Item"]];
[self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES];
}
else
{
[self.delegate bottomMenuDidPressBuyButton:self];
}
[self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES];
}
- (void)setMenuHidden:(BOOL)hidden animated:(BOOL)animated
@ -154,11 +142,11 @@
return _tableView;
}
- (UIView *)fadeView
- (SolidTouchView *)fadeView
{
if (!_fadeView)
{
_fadeView = [[UIView alloc] initWithFrame:self.bounds];
_fadeView = [[SolidTouchView alloc] initWithFrame:self.bounds];
_fadeView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
_fadeView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];

View file

@ -31,20 +31,20 @@
+ (CGFloat)cellHeight
{
return 55;
return 50;
}
- (void)layoutSubviews
{
self.selectedBackgroundView.height = self.height;
self.selectedBackgroundView.frame = self.bounds;
CGFloat shift = 19;
self.separator.minX = shift;
self.separator.width = self.width - 2 * shift;
self.separator.maxY = self.height;
self.titleLabel.frame = CGRectMake(53, -1.5, 246, self.height);
self.iconImageView.origin = CGPointMake(11, 6.5);
self.titleLabel.frame = CGRectMake(53, -1.5, self.width - 70, self.height);
self.iconImageView.origin = CGPointMake(11, 4.5);
}
- (UIImageView *)separator

View file

@ -4,8 +4,8 @@
@interface ContainerView ()
@property (nonatomic) UIView * fadeView;
@property (nonatomic) UIView * swipeView;
@property (nonatomic) SolidTouchView * fadeView;
@property (nonatomic) SolidTouchView * swipeView;
@end
@ -43,8 +43,7 @@
{
if (object == self.placePage && [keyPath isEqualToString:@"state"])
{
CGFloat const panViewShift = 12;
self.swipeView.frame = CGRectMake(0, self.placePage.maxY - panViewShift, self.width, self.height - self.placePage.height - panViewShift);
self.swipeView.frame = CGRectMake(0, self.placePage.maxY, self.width, self.height - self.placePage.height);
self.swipeView.userInteractionEnabled = (self.placePage.state == PlacePageStateOpened) ? YES : NO;
[UIView animateWithDuration:0.4 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.fadeView.alpha = (self.placePage.state == PlacePageStateOpened) ? 1 : 0;
@ -67,22 +66,22 @@
return _placePage;
}
- (UIView *)fadeView
- (SolidTouchView *)fadeView
{
if (!_fadeView)
{
_fadeView = [[UIView alloc] initWithFrame:self.bounds];
_fadeView = [[SolidTouchView alloc] initWithFrame:self.bounds];
_fadeView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
_fadeView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
}
return _fadeView;
}
- (UIView *)swipeView
- (SolidTouchView *)swipeView
{
if (!_swipeView)
{
_swipeView = [[UIView alloc] initWithFrame:CGRectZero];
_swipeView = [[SolidTouchView alloc] initWithFrame:CGRectZero];
_swipeView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
UISwipeGestureRecognizer * swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe:)];

View file

@ -38,8 +38,9 @@
#include "../../../map/user_mark.hpp"
#include "../../../platform/settings.hpp"
#define FACEBOOK_ALERT_VIEW 1
#define APPSTORE_ALERT_VIEW 2
#define ALERT_VIEW_FACEBOOK 1
#define ALERT_VIEW_APPSTORE 2
#define ALERT_VIEW_BOOKMARKS 4
#define ITUNES_URL @"itms-apps://itunes.apple.com/app/id%lld"
#define FACEBOOK_URL @"http://www.facebook.com/MapsWithMe"
#define FACEBOOK_SCHEME @"fb://profile/111923085594432"
@ -539,14 +540,24 @@ const long long LITE_IDL = 431183278L;
self.view.clipsToBounds = YES;
[self.view addSubview:self.toolbarView];
self.toolbarView.maxY = self.toolbarView.superview.height;
[self.view addSubview:self.searchView];
[self.view addSubview:self.containerView];
[self.view addSubview:self.bottomMenu];
#ifdef OMIM_LITE
AppInfo * info = [AppInfo sharedInfo];
if ([info featureAvailable:AppFeatureProButtonOnMap])
{
[self.view addSubview:self.buyButton];
[self.view insertSubview:self.buyButton belowSubview:self.toolbarView];
self.buyButton.midX = self.view.width / 2;
self.buyButton.maxY = self.toolbarView.minY - 5;
self.buyButton.maxY = self.toolbarView.minY - 14;
NSDictionary * texts = [info featureValue:AppFeatureProButtonOnMap forKey:@"Texts"];
NSString * proText = texts[[[NSLocale preferredLanguages] firstObject]];
if (!proText)
@ -558,15 +569,6 @@ const long long LITE_IDL = 431183278L;
}
#endif
[self.view addSubview:self.toolbarView];
self.toolbarView.maxY = self.toolbarView.superview.height;
[self.view addSubview:self.searchView];
[self.view addSubview:self.containerView];
[self.view addSubview:self.bottomMenu];
[self setApiMode:NO animated:NO];
}
@ -787,8 +789,9 @@ const long long LITE_IDL = 431183278L;
}
else
{
[[Statistics instance] logProposalReason:@"Bookmark Screen" withAnswer:@"YES"];
[[UIApplication sharedApplication] openProVersionFrom:@"ios_toolabar_bookmarks"];
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"bookmarks_in_pro_version", nil) message:nil delegate:self cancelButtonTitle:NSLocalizedString(@"cancel", nil) otherButtonTitles:NSLocalizedString(@"get_it_now", nil), nil];
alert.tag = ALERT_VIEW_BOOKMARKS;
[alert show];
}
}
else if ([itemName isEqualToString:@"Menu"])
@ -921,7 +924,7 @@ const long long LITE_IDL = 431183278L;
{
switch (alertView.tag)
{
case APPSTORE_ALERT_VIEW:
case ALERT_VIEW_APPSTORE:
{
NSString * url = nil;
if (GetPlatform().IsPro())
@ -931,7 +934,7 @@ const long long LITE_IDL = 431183278L;
[self manageAlert:buttonIndex andUrl:[NSURL URLWithString:url] andDlgSetting:dlg_settings::AppStore];
return;
}
case FACEBOOK_ALERT_VIEW:
case ALERT_VIEW_FACEBOOK:
{
NSString * url = [NSString stringWithFormat:FACEBOOK_SCHEME];
if (![[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:url]])
@ -939,6 +942,18 @@ const long long LITE_IDL = 431183278L;
[self manageAlert:buttonIndex andUrl:[NSURL URLWithString:url] andDlgSetting:dlg_settings::FacebookDlg];
return;
}
case ALERT_VIEW_BOOKMARKS:
{
if (buttonIndex != alertView.cancelButtonIndex)
{
[[Statistics instance] logProposalReason:@"Bookmark Screen" withAnswer:@"YES"];
[[UIApplication sharedApplication] openProVersionFrom:@"ios_toolabar_bookmarks"];
}
else
{
[[Statistics instance] logProposalReason:@"Bookmark Screen" withAnswer:@"NO"];
}
}
default:
break;
}
@ -950,33 +965,56 @@ const long long LITE_IDL = 431183278L;
{
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)])
[self setNeedsStatusBarAppearanceUpdate];
[UIView animateWithDuration:0.5 delay:0 damping:0.8 initialVelocity:0 options:(UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction) animations:^{
switch (self.containerView.placePage.state)
switch (self.containerView.placePage.state)
{
case PlacePageStateHidden:
{
case PlacePageStateHidden:
{
if (self.searchView.state == SearchViewStateAlpha)
[self.searchView setState:SearchViewStateResults animated:YES withCallback:NO];
GetFramework().GetBalloonManager().RemovePin();
break;
}
case PlacePageStatePreview:
{
if (self.searchView.state == SearchViewStateResults)
[self.searchView setState:SearchViewStateAlpha animated:YES withCallback:NO];
if ([change[@"old"] integerValue] == PlacePageStatePreview || [change[@"old"] integerValue] == PlacePageStateHidden)
{
Framework & framework = GetFramework();
CGFloat const x = self.view.width / 2;
CGFloat const y = self.view.height / 2;
CGPoint const center = [(EAGLView *)self.view viewPoint2GlobalPoint:CGPointMake(x, y)];
m2::PointD const offset = [self.containerView.placePage pinPoint] - m2::PointD(center.x, center.y);
framework.SetViewportCenterAnimated(framework.GetViewportCenter() + offset);
}
break;
}
if (self.searchView.state == SearchViewStateAlpha)
[self.searchView setState:SearchViewStateResults animated:YES withCallback:NO];
GetFramework().GetBalloonManager().RemovePin();
[UIView animateWithDuration:0.3 animations:^{
self.toolbarView.maxY = self.view.height;
}];
break;
}
} completion:nil];
case PlacePageStatePreview:
{
if (self.searchView.state == SearchViewStateResults)
[self.searchView setState:SearchViewStateAlpha animated:YES withCallback:NO];
if ([change[@"old"] integerValue] == PlacePageStatePreview || [change[@"old"] integerValue] == PlacePageStateHidden)
{
m2::PointD const pinPoint = [self.containerView.placePage pinPoint];
CGPoint viewPinPoint = [(EAGLView *)self.view globalPoint2ViewPoint:CGPointMake(pinPoint.x, pinPoint.y)];
CGFloat const minOffset = 40;
viewPinPoint.x = MIN(self.view.width - minOffset, viewPinPoint.x);
viewPinPoint.x = MAX(minOffset, viewPinPoint.x);
viewPinPoint.y = MIN(self.view.height - minOffset - self.toolbarView.height, viewPinPoint.y);
viewPinPoint.y = MAX(minOffset + self.containerView.placePage.maxY, viewPinPoint.y);
CGPoint const center = [(EAGLView *)self.view viewPoint2GlobalPoint:viewPinPoint];
m2::PointD const offset = [self.containerView.placePage pinPoint] - m2::PointD(center.x, center.y);
Framework & framework = GetFramework();
framework.SetViewportCenterAnimated(framework.GetViewportCenter() + offset);
}
[UIView animateWithDuration:0.3 animations:^{
self.toolbarView.maxY = self.view.height;
}];
break;
}
case PlacePageStateOpened:
{
[UIView animateWithDuration:0.3 animations:^{
self.toolbarView.minY = self.view.height;
}];
}
break;
}
}
else if (object == self.searchView && [keyPath isEqualToString:@"state"])
{
@ -1084,7 +1122,7 @@ NSInteger compareAddress(id l, id r, void * context)
delegate:self
cancelButtonTitle:NSLocalizedString(@"no_thanks", nil)
otherButtonTitles:NSLocalizedString(@"ok", nil), NSLocalizedString(@"remind_me_later", nil), nil];
alertView.tag = APPSTORE_ALERT_VIEW;
alertView.tag = ALERT_VIEW_APPSTORE;
[alertView show];
}
@ -1095,7 +1133,7 @@ NSInteger compareAddress(id l, id r, void * context)
delegate:self
cancelButtonTitle:NSLocalizedString(@"no_thanks", nil)
otherButtonTitles:NSLocalizedString(@"ok", nil), NSLocalizedString(@"remind_me_later", nil), nil];
alertView.tag = FACEBOOK_ALERT_VIEW;
alertView.tag = ALERT_VIEW_FACEBOOK;
[alertView show];
}

View file

@ -13,7 +13,7 @@
@property (nonatomic, weak) id <PlacePageShareCellDelegate> delegate;
- (void)setApiAppTitle:(NSString *)appTitle;
@property (nonatomic) NSString * apiAppTitle;
+ (CGFloat)cellHeight;

View file

@ -23,18 +23,18 @@
return self;
}
- (void)setApiAppTitle:(NSString *)appTitle
- (void)layoutSubviews
{
CGFloat const xOffset = 20;
CGFloat const yOffset = 14;
CGFloat const height = [self.shareButton backgroundImageForState:UIControlStateNormal].size.height;
if (appTitle)
if (self.apiAppTitle)
{
CGFloat const betweenOffset = 10;
self.shareButton.frame = CGRectMake(xOffset, yOffset, (self.width - 2 * xOffset - betweenOffset) / 2, height);
self.apiButton.frame = CGRectMake(self.shareButton.maxX + betweenOffset, yOffset, (self.width - 2 * xOffset - betweenOffset) / 2, height);
self.apiButton.hidden = NO;
[self.apiButton setTitle:appTitle forState:UIControlStateNormal];
[self.apiButton setTitle:self.apiAppTitle forState:UIControlStateNormal];
}
else
{

View file

@ -2,6 +2,7 @@
#import <UIKit/UIKit.h>
#include "../../map/bookmark.hpp"
#include "../../geometry/point2d.hpp"
#import "UIKitCategories.h"
typedef NS_ENUM(NSUInteger, PlacePageState) {
PlacePageStateHidden,
@ -19,7 +20,7 @@ typedef NS_ENUM(NSUInteger, PlacePageState) {
@end
@interface PlacePageView : UIView
@interface PlacePageView : SolidTouchView
- (void)showUserMark:(UserMark const *)mark;

View file

@ -1,7 +1,5 @@
#import "PlacePageView.h"
#import "UIKitCategories.h"
#import "MapsAppDelegate.h"
#import "MapViewController.h"
#import "BookmarksRootVC.h"
@ -12,6 +10,7 @@
#import "PlacePageShareCell.h"
#include "../../search/result.hpp"
#import "ColorPickerView.h"
#import "Statistics.h"
typedef NS_ENUM(NSUInteger, CellRow)
{
@ -21,10 +20,9 @@ typedef NS_ENUM(NSUInteger, CellRow)
CellRowShare,
};
@interface PlacePageView () <UIGestureRecognizerDelegate, UITableViewDataSource, UITableViewDelegate, LocationObserver, PlacePageShareCellDelegate, PlacePageInfoCellDelegate>
@interface PlacePageView () <UIGestureRecognizerDelegate, UITableViewDataSource, UITableViewDelegate, LocationObserver, PlacePageShareCellDelegate, PlacePageInfoCellDelegate, ColorPickerDelegate, UIAlertViewDelegate>
@property (nonatomic) UIView * backgroundView;
@property (nonatomic) UIView * wrapView;
@property (nonatomic) UIView * headerView;
@property (nonatomic) UIView * headerSeparator;
@property (nonatomic) UITableView * tableView;
@ -32,8 +30,6 @@ typedef NS_ENUM(NSUInteger, CellRow)
@property (nonatomic) UIButton * bookmarkButton;
@property (nonatomic) UILabel * typeLabel;
@property (nonatomic) UIButton * shareButton;
@property (nonatomic) CALayer * maskLayer1;
@property (nonatomic) CALayer * maskLayer2;
@property (nonatomic) UIImageView * editImageView;
@property (nonatomic) UIImageView * arrowImageView;
@property (nonatomic) UIView * pickerView;
@ -51,9 +47,10 @@ typedef NS_ENUM(NSUInteger, CellRow)
@implementation PlacePageView
{
UserMark const * m_mark;
UserMark const * m_cached_mark;
UserMark const * m_cachedMark;
BookmarkData * m_bookmarkData;
size_t m_categoryIndex;
BOOL updatingTable;
}
- (id)initWithFrame:(CGRect)frame
@ -61,16 +58,11 @@ typedef NS_ENUM(NSUInteger, CellRow)
self = [super initWithFrame:frame];
self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.clipsToBounds = YES;
m_mark = NULL;
m_cached_mark = NULL;
m_bookmarkData = NULL;
self.statusBarIncluded = !SYSTEM_VERSION_IS_LESS_THAN(@"7");
[self addSubview:self.backgroundView];
[self addSubview:self.arrowImageView];
m_mark = NULL;
m_cachedMark = NULL;
m_bookmarkData = NULL;
UISwipeGestureRecognizer * swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe:)];
swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
@ -80,10 +72,10 @@ typedef NS_ENUM(NSUInteger, CellRow)
swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
[self addGestureRecognizer:swipeDown];
[self addSubview:self.wrapView];
[self.wrapView addSubview:self.tableView];
[self addSubview:self.backgroundView];
[self addSubview:self.tableView];
[self addSubview:self.headerView];
[self addSubview:self.arrowImageView];
NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(bookmarkDeletedNotification:) name:BOOKMARK_DELETED_NOTIFICATION object:nil];
@ -96,6 +88,11 @@ typedef NS_ENUM(NSUInteger, CellRow)
[[MapsAppDelegate theApp].m_locationManager start:self];
CGFloat const defaultHeight = 93;
[self updateHeight:defaultHeight];
updatingTable = NO;
return self;
}
@ -148,7 +145,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
if (row == CellRowCommon)
{
PlacePageInfoCell * cell = [tableView dequeueReusableCellWithIdentifier:[PlacePageInfoCell className]];
[cell setAddress:[self address] pinPoint:[self pinPoint]];
[cell setAddress:self.address pinPoint:[self pinPoint]];
[cell setColor:[ColorPickerView colorForName:[self colorName]]];
cell.selectedColorView.alpha = [self isBookmark] ? 1 : 0;
cell.delegate = self;
@ -157,13 +154,13 @@ typedef NS_ENUM(NSUInteger, CellRow)
else if (row == CellRowSet)
{
PlacePageEditCell * cell = [tableView dequeueReusableCellWithIdentifier:[PlacePageEditCell className]];
cell.titleLabel.text = [self setName];
cell.titleLabel.text = self.setName;
return cell;
}
else if (row == CellRowInfo)
{
PlacePageEditCell * cell = [tableView dequeueReusableCellWithIdentifier:[PlacePageEditCell className]];
cell.titleLabel.text = [self info];
cell.titleLabel.text = self.info;
return cell;
}
else if (row == CellRowShare)
@ -171,9 +168,9 @@ typedef NS_ENUM(NSUInteger, CellRow)
PlacePageShareCell * cell = [tableView dequeueReusableCellWithIdentifier:[PlacePageShareCell className]];
cell.delegate = self;
if ([self isMarkOfType:UserMark::API])
[cell setApiAppTitle:[NSString stringWithUTF8String:GetFramework().GetApiDataHolder().GetAppTitle().c_str()]];
cell.apiAppTitle = [NSString stringWithUTF8String:GetFramework().GetApiDataHolder().GetAppTitle().c_str()];
else
[cell setApiAppTitle:nil];
cell.apiAppTitle = nil;
return cell;
}
return nil;
@ -183,11 +180,11 @@ typedef NS_ENUM(NSUInteger, CellRow)
{
CellRow row = [self cellRowForIndexPath:indexPath];
if (row == CellRowCommon)
return [PlacePageInfoCell cellHeightWithAddress:[self address] viewWidth:tableView.width];
return [PlacePageInfoCell cellHeightWithAddress:self.address viewWidth:tableView.width];
else if (row == CellRowSet)
return [PlacePageEditCell cellHeightWithTextValue:[self setName] viewWidth:tableView.width];
return [PlacePageEditCell cellHeightWithTextValue:self.setName viewWidth:tableView.width];
else if (row == CellRowInfo)
return [PlacePageEditCell cellHeightWithTextValue:[self info] viewWidth:tableView.width];
return [PlacePageEditCell cellHeightWithTextValue:self.info viewWidth:tableView.width];
else if (row == CellRowShare)
return [PlacePageShareCell cellHeight];
return 0;
@ -205,12 +202,12 @@ typedef NS_ENUM(NSUInteger, CellRow)
- (void)reloadHeader
{
self.titleLabel.text = [self title];
self.titleLabel.text = self.title;
self.titleLabel.width = [self titleWidth];
[self.titleLabel sizeToFit];
self.titleLabel.origin = CGPointMake(23, 29);
self.typeLabel.text = [self types];
self.typeLabel.text = self.types;
self.typeLabel.width = [self typesWidth];
[self.typeLabel sizeToFit];
self.typeLabel.origin = CGPointMake(self.titleLabel.minX + 1, self.titleLabel.maxY + 1);
@ -230,8 +227,8 @@ typedef NS_ENUM(NSUInteger, CellRow)
- (CGFloat)headerHeight
{
CGFloat titleHeight = [[self title] sizeWithDrawSize:CGSizeMake([self titleWidth], 100) font:self.titleLabel.font].height;
CGFloat typesHeight = [[self types] sizeWithDrawSize:CGSizeMake([self typesWidth], 30) font:self.typeLabel.font].height;
CGFloat titleHeight = [self.title sizeWithDrawSize:CGSizeMake([self titleWidth], 100) font:self.titleLabel.font].height;
CGFloat typesHeight = [self.types sizeWithDrawSize:CGSizeMake([self typesWidth], 30) font:self.typeLabel.font].height;
return MAX(74, titleHeight + typesHeight + 50);
}
@ -259,8 +256,11 @@ typedef NS_ENUM(NSUInteger, CellRow)
- (void)layoutSubviews
{
[self alignAnimated:YES];
// self.tableView.frame = CGRectMake(0, 0, self.superview.width, self.backgroundView.height);
if (!updatingTable)
{
[self alignAnimated:YES];
self.tableView.frame = CGRectMake(0, 0, self.superview.width, self.backgroundView.height);
}
}
- (void)updateHeight:(CGFloat)height
@ -271,9 +271,6 @@ typedef NS_ENUM(NSUInteger, CellRow)
CALayer * layer = [self.backgroundView.layer.sublayers firstObject];
layer.frame = self.backgroundView.bounds;
self.maskLayer1.frame = CGRectMake(0, 0, self.superview.frame.size.width, [self headerHeight]);
self.maskLayer2.frame = CGRectMake(0, [self headerHeight], self.superview.frame.size.width, self.maskLayer2.superlayer.frame.size.height - [self headerHeight]);
}
- (void)alignAnimated:(BOOL)animated
@ -300,8 +297,8 @@ typedef NS_ENUM(NSUInteger, CellRow)
CGFloat fullHeight = [self headerHeight] + [PlacePageInfoCell cellHeightWithAddress:self.address viewWidth:self.tableView.width] + [PlacePageShareCell cellHeight];
if (self.isBookmark)
{
fullHeight += [PlacePageEditCell cellHeightWithTextValue:[self setName] viewWidth:self.tableView.width];
fullHeight += [PlacePageEditCell cellHeightWithTextValue:[self info] viewWidth:self.tableView.width];
fullHeight += [PlacePageEditCell cellHeightWithTextValue:self.setName viewWidth:self.tableView.width];
fullHeight += [PlacePageEditCell cellHeightWithTextValue:self.info viewWidth:self.tableView.width];
}
fullHeight = MIN(fullHeight, [self maxHeight]);
self.headerSeparator.maxY = [self headerHeight];
@ -320,25 +317,44 @@ typedef NS_ENUM(NSUInteger, CellRow)
} completion:nil];
}
[self updateEditImageViewAnimated:animated];
[self updateBookmarkViewsAlpha:animated];
}
- (void)updateEditImageViewAnimated:(BOOL)animated
- (void)updateBookmarkViewsAlpha:(BOOL)animated
{
self.editImageView.center = CGPointMake(self.titleLabel.maxX + 14, self.titleLabel.minY + 10.5);
[UIView animateWithDuration:(animated ? 0.3 : 0) delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.editImageView.alpha = self.isBookmark ? (self.state == PlacePageStateOpened ? 1 : 0) : 0;
self.editImageView.alpha = [self isBookmark] ? (self.state == PlacePageStateOpened ? 1 : 0) : 0;
PlacePageInfoCell * cell = (PlacePageInfoCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:ROW_COMMON inSection:0]];
cell.separator.alpha = self.isBookmark ? 1 : 0;
} completion:^(BOOL finished) {}];
cell.separator.alpha = [self isBookmark] ? 1 : 0;
cell.selectedColorView.alpha = [self isBookmark] ? 1 : 0;
} completion:nil];
}
- (void)updateBookmarkStateAnimated:(BOOL)animated
{
NSIndexPath * indexPath1 = [NSIndexPath indexPathForRow:ROW_SET inSection:0];
NSIndexPath * indexPath2 = [NSIndexPath indexPathForRow:ROW_INFO inSection:0];
if ([self isBookmark])
{
CGFloat newHeight = self.backgroundView.height + [PlacePageEditCell cellHeightWithTextValue:self.info viewWidth:self.tableView.width] + [PlacePageEditCell cellHeightWithTextValue:self.setName viewWidth:self.tableView.width];
self.tableView.frame = CGRectMake(0, 0, self.superview.width, newHeight);
}
// [self performAfterDelay:0 block:^{
[self resizeTableAnimated:animated];
// }];
[self updateBookmarkViewsAlpha:animated];
}
- (void)resizeTableAnimated:(BOOL)animated
{
if (self.bookmarkButton.selected != [self isBookmark])
{
updatingTable = YES;
NSIndexPath * indexPath1 = [NSIndexPath indexPathForRow:ROW_SET inSection:0];
NSIndexPath * indexPath2 = [NSIndexPath indexPathForRow:ROW_INFO inSection:0];
NSTimeInterval delay = 0;
if ([self isBookmark] && !self.bookmarkButton.selected)
{
@ -354,15 +370,17 @@ typedef NS_ENUM(NSUInteger, CellRow)
[self willChangeValueForKey:@"state"];
[self alignAnimated:YES];
[self didChangeValueForKey:@"state"];
[self performAfterDelay:0 block:^{
updatingTable = NO;
}];
}];
}
self.bookmarkButton.selected = [self isBookmark];
[self updateEditImageViewAnimated:animated];
}
- (CGFloat)maxHeight
{
return IPAD ? 600 : (self.superview.width > self.superview.height ? 250 : 430);
return IPAD ? 600 : (self.superview.width > self.superview.height ? 270 : 470);
}
- (void)didMoveToSuperview
@ -377,8 +395,8 @@ typedef NS_ENUM(NSUInteger, CellRow)
- (void)bookmarkCategoryDeletedNotification:(NSNotification *)notification
{
if (GetFramework().FindBookmark(m_mark).first == [[notification object] integerValue])
[self deleteBookmark];
if (m_categoryIndex == [[notification object] integerValue])
[self abortBookmarkState];
}
- (void)bookmarkDeletedNotification:(NSNotification *)notification
@ -386,16 +404,19 @@ typedef NS_ENUM(NSUInteger, CellRow)
BookmarkAndCategory bookmarkAndCategory;
[[notification object] getValue:&bookmarkAndCategory];
if (bookmarkAndCategory == GetFramework().FindBookmark(m_mark))
[self deleteBookmark];
[self abortBookmarkState];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)abortBookmarkState
{
Framework & framework = GetFramework();
m_mark = m_cachedMark != NULL ? m_cachedMark : framework.GetAddressMark([self pinPoint]);
framework.ActivateUserMark(m_mark);
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {}
[self clearCachedProperties];
[self reloadHeader];
[self updateBookmarkStateAnimated:YES];
}
- (void)swipe:(UISwipeGestureRecognizer *)sender
{
@ -509,7 +530,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
- (void)bookmarkButtonPressed:(UIButton *)sender
{
if (self.isBookmark)
if ([self isBookmark])
[self deleteBookmark];
else
[self addBookmark];
@ -521,16 +542,21 @@ typedef NS_ENUM(NSUInteger, CellRow)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
}
- (void)showUserMark:(UserMark const *)mark
- (void)clearCachedProperties
{
_title = nil;
_types = nil;
_address = nil;
_setName = nil;
_info = nil;
}
- (void)showUserMark:(UserMark const *)mark
{
[self clearCachedProperties];
m_mark = mark;
m_cached_mark = mark;
m_cachedMark = mark;
if ([self isBookmark])
[self bookmarkActivated:static_cast<Bookmark const *>(mark)];
@ -544,7 +570,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
m_categoryIndex = GetFramework().FindBookmark(bookmark).first;
delete m_bookmarkData;
m_bookmarkData = new BookmarkData(bookmark->GetName(), bookmark->GetType(), bookmark->GetDescription(), bookmark->GetScale(), bookmark->GetTimeStamp());
m_cached_mark = NULL;
m_cachedMark = NULL;
}
- (void)userMarkActivated:(UserMark const *)mark
@ -717,7 +743,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
Framework & framework = GetFramework();
BookmarkAndCategory const & bookmarkAndCategory = framework.FindBookmark(m_mark);
BookmarkCategory * category = framework.GetBmCategory(bookmarkAndCategory.first);
m_mark = m_cached_mark != NULL ? m_cached_mark : framework.GetAddressMark([self pinPoint]);
m_mark = m_cachedMark != NULL ? m_cachedMark : framework.GetAddressMark([self pinPoint]);
framework.ActivateUserMark(m_mark);
if (category)
{
@ -732,29 +758,37 @@ typedef NS_ENUM(NSUInteger, CellRow)
- (void)addBookmark
{
Framework & framework = GetFramework();
if (m_bookmarkData)
if (GetPlatform().IsPro())
{
BookmarkCategory const * category = framework.GetBmCategory(m_categoryIndex);
if (!category)
m_categoryIndex = framework.LastEditedBMCategory();
Framework & framework = GetFramework();
if (m_bookmarkData)
{
BookmarkCategory const * category = framework.GetBmCategory(m_categoryIndex);
if (!category)
m_categoryIndex = framework.LastEditedBMCategory();
size_t const bookmarkIndex = framework.GetBookmarkManager().AddBookmark(m_categoryIndex, [self pinPoint], *m_bookmarkData);
m_mark = category->GetBookmark(bookmarkIndex);
size_t const bookmarkIndex = framework.GetBookmarkManager().AddBookmark(m_categoryIndex, [self pinPoint], *m_bookmarkData);
m_mark = category->GetBookmark(bookmarkIndex);
}
else
{
size_t const categoryIndex = framework.LastEditedBMCategory();
BookmarkData data = BookmarkData([self.title UTF8String], "placemark-red");
size_t const bookmarkIndex = framework.AddBookmark(categoryIndex, [self pinPoint], data);
BookmarkCategory const * category = framework.GetBmCategory(categoryIndex);
m_mark = category->GetBookmark(bookmarkIndex);
}
framework.ActivateUserMark(m_mark);
framework.Invalidate();
[self reloadHeader];
[self updateBookmarkStateAnimated:YES];
}
else
{
size_t const categoryIndex = framework.LastEditedBMCategory();
BookmarkData data = BookmarkData([[self title] UTF8String], "placemark-red");
size_t const bookmarkIndex = framework.AddBookmark(categoryIndex, [self pinPoint], data);
BookmarkCategory const * category = framework.GetBmCategory(categoryIndex);
m_mark = category->GetBookmark(bookmarkIndex);
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"bookmarks_in_pro_version", nil) message:nil delegate:self cancelButtonTitle:NSLocalizedString(@"cancel", nil) otherButtonTitles:NSLocalizedString(@"get_it_now", nil), nil];
[alert show];
}
framework.ActivateUserMark(m_mark);
framework.Invalidate();
[self reloadHeader];
[self updateBookmarkStateAnimated:YES];
}
- (void)shareCellDidPressApiButton:(PlacePageShareCell *)cell
@ -764,38 +798,30 @@ typedef NS_ENUM(NSUInteger, CellRow)
- (void)shareCellDidPressShareButton:(PlacePageShareCell *)cell
{
[self.delegate placePageView:self willShareText:[self title] point:self.pinPoint];
[self.delegate placePageView:self willShareText:self.title point:self.pinPoint];
}
- (UIView *)wrapView
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (!_wrapView)
UIScrollView * sv = scrollView;
if ((sv.contentOffset.y + sv.height > sv.contentSize.height + 60) && !sv.dragging && sv.decelerating)
{
_wrapView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
_wrapView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
CALayer * mask = [CALayer layer];
mask.frame = _wrapView.bounds;
CGFloat height1 = [self headerHeight];
CGFloat height2 = _wrapView.height - height1;
CALayer * submask1 = [CALayer layer];
submask1.frame = CGRectMake(0, 0, _wrapView.width, height1);
submask1.backgroundColor = [[UIColor clearColor] CGColor];
[mask addSublayer:submask1];
self.maskLayer1 = submask1;
CALayer * submask2 = [CALayer layer];
submask2.frame = CGRectMake(0, height1, _wrapView.width, height2);
submask2.backgroundColor = [[UIColor blackColor] CGColor];
[mask addSublayer:submask2];
self.maskLayer2 = submask2;
[_wrapView.layer addSublayer:mask];
_wrapView.layer.mask = mask;
if (self.state == PlacePageStateOpened)
[self setState:PlacePageStatePreview animated:YES withCallback:YES];
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex != alertView.cancelButtonIndex)
{
[[Statistics instance] logProposalReason:@"Add Bookmark" withAnswer:@"YES"];
[[UIApplication sharedApplication] openProVersionFrom:@"ios_pp_bookmark"];
}
else
{
[[Statistics instance] logProposalReason:@"Add Bookmark" withAnswer:@"NO"];
}
return _wrapView;
}
- (CopyLabel *)titleLabel
@ -849,6 +875,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
if (!_headerView)
{
_headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.width, [self headerHeight])];
_headerView.backgroundColor = [UIColor applicationColor];
_headerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
[_headerView addSubview:self.titleLabel];

View file

@ -23,7 +23,7 @@
[self.fieldBackgroundView addSubview:self.clearButton];
self.clearButton.midY = self.fieldBackgroundView.height / 2;
self.clearButton.maxX = self.fieldBackgroundView.width + 2;
self.clearButton.midX = self.fieldBackgroundView.width - 14;
self.cancelButton.midY = self.height / 2 - 5;
self.cancelButton.maxX = self.width - 3;
@ -32,8 +32,8 @@
self.textField.midY = self.height / 2 - 3;
[self addSubview:self.textField];
if ([UITextField instancesRespondToSelector:@selector(setTintColor:)])
[[UITextField appearance] setTintColor:[UIColor whiteColor]];
if ([self.textField respondsToSelector:@selector(setTintColor:)])
self.textField.tintColor = [UIColor whiteColor];
return self;
}
@ -50,25 +50,7 @@
- (void)clearButtonPressed:(id)sender
{
// Framework & framework = GetFramework();
// GetFramework().ClearMapApiPoints();
// if (self.active)
// {
// self.textField.text = nil;
// self.resultText = nil;
// [self.textField becomeFirstResponder];
// }
// else
// {
// [self hideSearchedText];
// }
[self.delegate searchBarDidPressClearButton:self];
//
// framework.GetBookmarkManager().AdditionalPoiLayerClear();
// framework.GetBalloonManager().RemovePin();
// framework.GetBalloonManager().Dismiss();
// framework.Invalidate();
}
- (void)hideSearchedText
@ -85,6 +67,8 @@
_cancelButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 64, 44)];
_cancelButton.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:15];
_cancelButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin;
[_cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_cancelButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted];
[_cancelButton setTitle:@"cancel" forState:UIControlStateNormal];
[_cancelButton addTarget:self action:@selector(cancelButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
}
@ -95,7 +79,7 @@
{
if (!_clearButton)
{
_clearButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 32, 44)];
_clearButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
_clearButton.contentMode = UIViewContentModeCenter;
_clearButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
[_clearButton setImage:[UIImage imageNamed:@"SearchBarClearButton"] forState:UIControlStateNormal];

View file

@ -31,7 +31,7 @@
CGFloat const shift = 15;
self.separatorView.width = self.width - 2 * shift;
self.separatorView.minX = shift;
self.selectedBackgroundView.height = self.height;
self.selectedBackgroundView.frame = self.bounds;
}
- (UIView *)separatorView

View file

@ -84,7 +84,7 @@
@end
@interface SearchView () <UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource, SearchBarDelegate, LocationObserver>
@interface SearchView () <UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource, SearchBarDelegate, LocationObserver, UIAlertViewDelegate>
@property (nonatomic) UITableView * tableView;
@property (nonatomic) UIImageView * topBackgroundView;
@ -341,6 +341,7 @@ static void OnSearchResultCallback(search::Results const & results)
self.searchBar.textField.text = nil;
[self.searchBar setSearching:NO];
[self.tableView reloadData];
self.emptyResultLabel.alpha = 0;
[self setState:SearchViewStateHidden animated:YES withCallback:YES];
}
@ -514,9 +515,17 @@ static void OnSearchResultCallback(search::Results const & results)
}
else
{
GetFramework().ShowSearchResult(result);
needToScroll = YES;
[self setState:SearchViewStateHidden animated:YES withCallback:YES];
if (GetPlatform().IsPro())
{
GetFramework().ShowSearchResult(result);
needToScroll = YES;
[self setState:SearchViewStateHidden animated:YES withCallback:YES];
}
else
{
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"search_available_in_pro_version", nil) message:nil delegate:self cancelButtonTitle:NSLocalizedString(@"cancel", nil) otherButtonTitles:NSLocalizedString(@"get_it_now", nil), nil];
[alert show];
}
}
}
else
@ -527,6 +536,19 @@ static void OnSearchResultCallback(search::Results const & results)
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex != alertView.cancelButtonIndex)
{
[[UIApplication sharedApplication] openProVersionFrom:@"ios_search_alert"];
[[Statistics instance] logProposalReason:@"Search Screen" withAnswer:@"YES"];
}
else
{
[[Statistics instance] logProposalReason:@"Search Screen" withAnswer:@"NO"];
}
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (!scrollView.decelerating && scrollView.dragging)

View file

@ -1,6 +1,7 @@
#import <UIKit/UIKit.h>
#import "LocationButton.h"
#import "UIKitCategories.h"
@class ToolbarView;
@protocol ToolbarViewDelegate <NSObject>
@ -9,7 +10,7 @@
@end
@interface ToolbarView : UIView
@interface ToolbarView : SolidTouchView
@property (nonatomic, weak) id <ToolbarViewDelegate> delegate;
@property (nonatomic) LocationButton * locationButton;

View file

@ -1,6 +1,5 @@
#import "ToolbarView.h"
#import "UIKitCategories.h"
@interface ToolbarView ()
@ -55,14 +54,6 @@
[self.delegate toolbar:self didPressItemWithName:@"Menu"];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)layoutButtons
{
CGFloat const xOffsetPercent = 1.0 / 8;