forked from organicmaps/organicmaps
[ios] review fixed
This commit is contained in:
parent
07888673da
commit
d63f26ec5f
31 changed files with 141 additions and 146 deletions
|
@ -1,5 +1,5 @@
|
|||
@objc(MWMBookmarksTabViewController)
|
||||
class BookmarksTabViewController: TabViewController {
|
||||
final class BookmarksTabViewController: TabViewController {
|
||||
private static let selectedIndexKey = "BookmarksTabViewController_selectedIndexKey"
|
||||
private var selectedIndex: Int {
|
||||
get {
|
||||
|
|
|
@ -104,15 +104,9 @@
|
|||
if (indexPath.section == m_infoSection)
|
||||
{
|
||||
cell = [tableView dequeueReusableCellWithCellClass:MWMCategoryInfoCell.class indexPath:indexPath];
|
||||
MWMCategoryInfoCell * infoCell = (MWMCategoryInfoCell *)cell;
|
||||
NSString * title = @(bmManager.GetCategoryName(m_categoryId).c_str());
|
||||
auto categoryData = bmManager.GetCategoryData(m_categoryId);
|
||||
NSString * author = [NSString stringWithCoreFormat:L(@"author_name_by_prefix")
|
||||
arguments:@[@(categoryData.m_authorName.c_str())]];
|
||||
NSString * info = @(kml::GetDefaultStr(categoryData.m_description).c_str());
|
||||
NSString * shortInfo = @(kml::GetDefaultStr(categoryData.m_annotation).c_str());
|
||||
[infoCell updateWithTitle:title author:author info:info shortInfo:shortInfo];
|
||||
infoCell.delegate = self;
|
||||
auto infoCell = (MWMCategoryInfoCell *)cell;
|
||||
auto const & categoryData = bmManager.GetCategoryData(m_categoryId);
|
||||
[infoCell updateWithCategoryData:categoryData delegate:self];
|
||||
}
|
||||
else if (indexPath.section == m_trackSection)
|
||||
{
|
||||
|
@ -259,19 +253,11 @@
|
|||
|
||||
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
|
||||
{
|
||||
UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
|
||||
|
||||
UITableViewHeaderFooterView * header = (UITableViewHeaderFooterView *)view;
|
||||
header.textLabel.textColor = [UIColor blackSecondaryText];
|
||||
header.textLabel.font = [UIFont medium14];
|
||||
}
|
||||
|
||||
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (indexPath.section == m_infoSection)
|
||||
return nil;
|
||||
return indexPath;
|
||||
}
|
||||
|
||||
#pragma mark - MWMCategoryInfoCellDelegate
|
||||
|
||||
- (void)categoryInfoCellDidPressMore:(MWMCategoryInfoCell *)cell
|
||||
|
@ -315,7 +301,6 @@
|
|||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self.tableView registerWithCellClass:MWMCategoryInfoCell.class];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
protocol CatalogCategoryCellDelegate {
|
||||
protocol CatalogCategoryCellDelegate : AnyObject {
|
||||
func cell(_ cell: CatalogCategoryCell, didCheck visible: Bool)
|
||||
func cell(_ cell: CatalogCategoryCell, didPress moreButton: UIButton)
|
||||
}
|
||||
|
||||
class CatalogCategoryCell: MWMTableViewCell {
|
||||
final class CatalogCategoryCell: MWMTableViewCell {
|
||||
|
||||
var delegate: CatalogCategoryCellDelegate?
|
||||
weak var delegate: CatalogCategoryCellDelegate?
|
||||
|
||||
@IBOutlet weak var visibleCheckmark: Checkmark! {
|
||||
didSet {
|
||||
|
@ -38,7 +38,7 @@ class CatalogCategoryCell: MWMTableViewCell {
|
|||
func update(with category: MWMCatalogCategory, delegate: CatalogCategoryCellDelegate?) {
|
||||
titleLabel.text = category.title
|
||||
subtitleLabel.text = "\(category.bookmarksCount) places • by \(category.author ?? "")"
|
||||
visibleCheckmark.isChecked = category.isVisible
|
||||
visibleCheckmark.isChecked = category.visible
|
||||
self.delegate = delegate
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class CatalogWebViewController: WebViewController {
|
||||
final class CatalogWebViewController: WebViewController {
|
||||
|
||||
let progressView = UIVisualEffectView(effect: UIBlurEffect(style: .dark))
|
||||
let progressImageView = UIImageView(image: #imageLiteral(resourceName: "ic_24px_spinner"))
|
||||
|
@ -63,28 +63,27 @@ class CatalogWebViewController: WebViewController {
|
|||
override func webView(_ webView: WKWebView,
|
||||
decidePolicyFor navigationAction: WKNavigationAction,
|
||||
decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
||||
if let url = navigationAction.request.url {
|
||||
if url.scheme == "mapsme" {
|
||||
processDeeplink(url)
|
||||
decisionHandler(.cancel)
|
||||
return
|
||||
}
|
||||
guard let url = navigationAction.request.url, url.scheme == "mapsme" else {
|
||||
super.webView(webView, decidePolicyFor: navigationAction, decisionHandler: decisionHandler)
|
||||
return
|
||||
}
|
||||
super.webView(webView, decidePolicyFor: navigationAction, decisionHandler: decisionHandler)
|
||||
|
||||
processDeeplink(url)
|
||||
decisionHandler(.cancel);
|
||||
}
|
||||
|
||||
func processDeeplink(_ url: URL) {
|
||||
let components = URLComponents(url: url, resolvingAgainstBaseURL: false)
|
||||
var id = ""
|
||||
var name = ""
|
||||
components?.queryItems?.forEach({ (item) in
|
||||
if (item.name == "name") {
|
||||
name = item.value ?? ""
|
||||
components?.queryItems?.forEach {
|
||||
if $0.name == "name" {
|
||||
name = $0.value ?? ""
|
||||
}
|
||||
if (item.name == "id") {
|
||||
id = item.value ?? ""
|
||||
if $0.name == "id" {
|
||||
id = $0.value ?? ""
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if MWMBookmarksManager.isCategoryDownloading(id) {
|
||||
//TODO: add alert
|
||||
|
@ -96,33 +95,39 @@ class CatalogWebViewController: WebViewController {
|
|||
return
|
||||
}
|
||||
|
||||
MWMBookmarksManager.downloadItem(withId: id, name: name, progress: { (progress) in
|
||||
self.updateProgress()
|
||||
}) { (error) in
|
||||
MWMBookmarksManager.downloadItem(withId: id, name: name, progress: { [weak self] (progress) in
|
||||
self?.updateProgress()
|
||||
}) { [weak self] (error) in
|
||||
if let error = error as NSError? {
|
||||
if error.code == kCategoryDownloadFailedCode {
|
||||
guard let statusCode = error.userInfo[kCategoryDownloadStatusKey] as? NSNumber else { return }
|
||||
guard let status = MWMCategoryDownloadStatus(rawValue: statusCode.intValue) else { return }
|
||||
guard let statusCode = error.userInfo[kCategoryDownloadStatusKey] as? NSNumber else {
|
||||
assertionFailure()
|
||||
return
|
||||
}
|
||||
guard let status = MWMCategoryDownloadStatus(rawValue: statusCode.intValue) else {
|
||||
assertionFailure()
|
||||
return
|
||||
}
|
||||
switch (status) {
|
||||
case .forbidden:
|
||||
fallthrough
|
||||
case .notFound:
|
||||
self.showServerError(url)
|
||||
self?.showServerError(url)
|
||||
break
|
||||
case .networkError:
|
||||
self.showNetworkError()
|
||||
self?.showNetworkError()
|
||||
break
|
||||
case .diskError:
|
||||
self.showDiskError()
|
||||
self?.showDiskError()
|
||||
break
|
||||
}
|
||||
} else if error.code == kCategoryImportFailedCode {
|
||||
self.showImportError()
|
||||
self?.showImportError()
|
||||
}
|
||||
} else {
|
||||
Toast.toast(withText: L("bookmarks_webview_success_toast")).show()
|
||||
}
|
||||
self.updateProgress()
|
||||
self?.updateProgress()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,40 +7,40 @@ class DownloadedBookmarksDataSource {
|
|||
}
|
||||
}
|
||||
|
||||
var allCategoriesVisible: Bool {
|
||||
var allCategoriesHidden: Bool {
|
||||
get {
|
||||
var result = true
|
||||
categories.forEach { if !$0.isVisible { result = false } }
|
||||
categories.forEach { if $0.visible { result = false } }
|
||||
return result
|
||||
}
|
||||
set {
|
||||
categories.forEach {
|
||||
$0.isVisible = newValue
|
||||
$0.visible = !newValue
|
||||
}
|
||||
MWMBookmarksManager.setCatalogCategoriesVisible(newValue)
|
||||
MWMBookmarksManager.setCatalogCategoriesVisible(!newValue)
|
||||
}
|
||||
}
|
||||
|
||||
init() {
|
||||
reload()
|
||||
reloadData()
|
||||
}
|
||||
|
||||
func category(at index: Int) -> MWMCatalogCategory {
|
||||
return categories[index]
|
||||
}
|
||||
|
||||
func reload() {
|
||||
func reloadData() {
|
||||
categories = MWMBookmarksManager.categoriesFromCatalog()
|
||||
}
|
||||
|
||||
func setCategory(visible: Bool, at index: Int) {
|
||||
let category = categories[index]
|
||||
category.isVisible = visible
|
||||
category.visible = visible
|
||||
MWMBookmarksManager.setCategory(category.categoryId, isVisible: visible)
|
||||
}
|
||||
|
||||
func deleteCategory(at index: Int) {
|
||||
MWMBookmarksManager.deleteCategory(category(at: index).categoryId)
|
||||
reload()
|
||||
reloadData()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ class DownloadedBookmarksViewController: MWMViewController {
|
|||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
tableView.tableFooterView = bottomView
|
||||
tableView.registerNib(cell: CatalogCategoryCell.self)
|
||||
tableView.registerNibForHeaderFooterView(BMCCategoriesHeader.self)
|
||||
|
@ -16,8 +15,7 @@ class DownloadedBookmarksViewController: MWMViewController {
|
|||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
dataSource.reload()
|
||||
dataSource.reloadData()
|
||||
noDataView.isHidden = dataSource.categoriesCount > 0
|
||||
tableView.reloadData()
|
||||
}
|
||||
|
@ -27,29 +25,38 @@ class DownloadedBookmarksViewController: MWMViewController {
|
|||
MWMAlertViewController.activeAlert().presentNoConnectionAlert();
|
||||
return
|
||||
}
|
||||
if let url = MWMBookmarksManager.catalogFrontendUrl(),
|
||||
let webViewController = CatalogWebViewController(url: url, andTitleOrNil: L("routes_and_bookmarks")) {
|
||||
MapViewController.topViewController().navigationController?.pushViewController(webViewController,
|
||||
animated: true)
|
||||
guard let url = MWMBookmarksManager.catalogFrontendUrl(),
|
||||
let webViewController = CatalogWebViewController(url: url,
|
||||
andTitleOrNil: L("routes_and_bookmarks")) else {
|
||||
assertionFailure()
|
||||
return
|
||||
}
|
||||
MapViewController.topViewController().navigationController?.pushViewController(webViewController,
|
||||
animated: true)
|
||||
}
|
||||
|
||||
private func setCategoryVisible(_ visible: Bool, at index: Int) {
|
||||
dataSource.setCategory(visible: visible, at: index)
|
||||
let categoriesHeader = tableView.headerView(forSection: 0) as! BMCCategoriesHeader
|
||||
categoriesHeader.isShowAll = !dataSource.allCategoriesVisible
|
||||
categoriesHeader.isShowAll = dataSource.allCategoriesHidden
|
||||
}
|
||||
|
||||
private func shareCategory(at index: Int) {
|
||||
let category = dataSource.category(at: index)
|
||||
if let url = MWMBookmarksManager.sharingUrl(forCategoryId: category.categoryId) {
|
||||
let message = L("share_bookmarks_email_body")
|
||||
let shareController = MWMActivityViewController.share(for: url, message: message)
|
||||
shareController?.present(inParentViewController: self, anchorView: nil)
|
||||
guard let url = MWMBookmarksManager.sharingUrl(forCategoryId: category.categoryId) else {
|
||||
assertionFailure()
|
||||
return
|
||||
}
|
||||
let message = L("share_bookmarks_email_body")
|
||||
let shareController = MWMActivityViewController.share(for: url, message: message)
|
||||
shareController?.present(inParentViewController: self, anchorView: nil)
|
||||
}
|
||||
|
||||
private func deleteCategory(at index: Int) {
|
||||
guard index >= 0 && index < dataSource.categoriesCount else {
|
||||
assertionFailure()
|
||||
return
|
||||
}
|
||||
dataSource.deleteCategory(at: index)
|
||||
if dataSource.categoriesCount > 0 {
|
||||
tableView.deleteRows(at: [IndexPath(row: index, section: 0)], with: .automatic)
|
||||
|
@ -61,10 +68,6 @@ class DownloadedBookmarksViewController: MWMViewController {
|
|||
}
|
||||
|
||||
extension DownloadedBookmarksViewController: UITableViewDataSource {
|
||||
func numberOfSections(in tableView: UITableView) -> Int {
|
||||
return dataSource.categoriesCount > 0 ? 1 : 0
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return dataSource.categoriesCount
|
||||
}
|
||||
|
@ -84,7 +87,7 @@ extension DownloadedBookmarksViewController: UITableViewDelegate {
|
|||
|
||||
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
||||
let headerView = tableView.dequeueReusableHeaderFooterView(BMCCategoriesHeader.self)
|
||||
headerView.isShowAll = !dataSource.allCategoriesVisible
|
||||
headerView.isShowAll = dataSource.allCategoriesHidden
|
||||
headerView.delegate = self
|
||||
return headerView
|
||||
}
|
||||
|
@ -115,9 +118,9 @@ extension DownloadedBookmarksViewController: CatalogCategoryCellDelegate {
|
|||
ppc.sourceRect = moreButton.bounds
|
||||
}
|
||||
|
||||
let showHide = L(category.isVisible ? "hide" : "show").capitalized
|
||||
let showHide = L(category.visible ? "hide" : "show").capitalized
|
||||
actionSheet.addAction(UIAlertAction(title: showHide, style: .default, handler: { _ in
|
||||
self.setCategoryVisible(!category.isVisible, at: indexPath.row)
|
||||
self.setCategoryVisible(!category.visible, at: indexPath.row)
|
||||
self.tableView.reloadRows(at: [indexPath], with: .none)
|
||||
}))
|
||||
|
||||
|
@ -141,8 +144,7 @@ extension DownloadedBookmarksViewController: CatalogCategoryCellDelegate {
|
|||
|
||||
extension DownloadedBookmarksViewController: BMCCategoriesHeaderDelegate {
|
||||
func visibilityAction(_ categoriesHeader: BMCCategoriesHeader) {
|
||||
let showAll = categoriesHeader.isShowAll
|
||||
dataSource.allCategoriesVisible = showAll
|
||||
dataSource.allCategoriesHidden = !dataSource.allCategoriesHidden
|
||||
tableView.reloadData()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
|
||||
@interface MWMCatalogCategory (Convenience)
|
||||
|
||||
- (instancetype)initWithCategoryData:(kml::CategoryData &)categoryData bookmarksCount:(UInt64)count;
|
||||
- (instancetype)initWithCategoryData:(kml::CategoryData const &)categoryData bookmarksCount:(uint64_t)count;
|
||||
|
||||
@end
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
|
||||
@implementation MWMCatalogCategory (Convenience)
|
||||
|
||||
- (instancetype)initWithCategoryData:(kml::CategoryData &)categoryData bookmarksCount:(UInt64)count
|
||||
- (instancetype)initWithCategoryData:(kml::CategoryData const &)categoryData bookmarksCount:(uint64_t)count
|
||||
{
|
||||
self = [self init];
|
||||
|
||||
if (self)
|
||||
{
|
||||
self.categoryId = categoryData.m_id;
|
||||
|
@ -16,6 +15,7 @@
|
|||
self.annotation = @(kml::GetDefaultStr(categoryData.m_annotation).c_str());
|
||||
self.detailedAnnotation = @(kml::GetDefaultStr(categoryData.m_description).c_str());
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface MWMCatalogCategory : NSObject
|
||||
|
||||
@property (nonatomic) MWMMarkGroupID categoryId;
|
||||
|
@ -8,6 +6,6 @@
|
|||
@property (copy, nonatomic) NSString * annotation;
|
||||
@property (copy, nonatomic) NSString * detailedAnnotation;
|
||||
@property (nonatomic) NSInteger bookmarksCount;
|
||||
@property (nonatomic, getter=isVisible) BOOL visible;
|
||||
@property (nonatomic) BOOL visible;
|
||||
|
||||
@end
|
||||
|
|
|
@ -245,7 +245,7 @@ extension BMCViewController: UITableViewDelegate {
|
|||
case .permissions: return permissionsHeader
|
||||
case .categories:
|
||||
let categoriesHeader = tableView.dequeueReusableHeaderFooterView(BMCCategoriesHeader.self)
|
||||
categoriesHeader.isShowAll = !viewModel.areAllCategoriesVisible()
|
||||
categoriesHeader.isShowAll = viewModel.areAllCategoriesHidden()
|
||||
categoriesHeader.delegate = self
|
||||
return categoriesHeader
|
||||
case .actions: return actionsHeader
|
||||
|
@ -290,7 +290,7 @@ extension BMCViewController: BMCCategoryCellDelegate {
|
|||
func visibilityAction(category: BMCCategory) {
|
||||
viewModel.updateCategoryVisibility(category: category)
|
||||
let categoriesHeader = tableView.headerView(forSection: viewModel.sectionIndex(section: .categories)) as! BMCCategoriesHeader
|
||||
categoriesHeader.isShowAll = !viewModel.areAllCategoriesVisible()
|
||||
categoriesHeader.isShowAll = viewModel.areAllCategoriesHidden()
|
||||
}
|
||||
|
||||
func moreAction(category: BMCCategory, anchor: UIView) {
|
||||
|
@ -318,6 +318,6 @@ extension BMCViewController: BMCPermissionsHeaderDelegate {
|
|||
extension BMCViewController: BMCCategoriesHeaderDelegate {
|
||||
func visibilityAction(_ categoriesHeader: BMCCategoriesHeader) {
|
||||
viewModel.updateAllCategoriesVisibility(isShowAll: categoriesHeader.isShowAll)
|
||||
categoriesHeader.isShowAll = !viewModel.areAllCategoriesVisible()
|
||||
categoriesHeader.isShowAll = viewModel.areAllCategoriesHidden()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,9 +117,9 @@ extension BMCDefaultViewModel: BMCViewModel {
|
|||
}
|
||||
}
|
||||
|
||||
func areAllCategoriesVisible() -> Bool {
|
||||
func areAllCategoriesHidden() -> Bool {
|
||||
var result = true;
|
||||
categories.forEach { if !$0.isVisible { result = false } }
|
||||
categories.forEach { if $0.isVisible { result = false } }
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ protocol BMCViewModel: AnyObject {
|
|||
|
||||
func item(indexPath: IndexPath) -> BMCModel
|
||||
|
||||
func areAllCategoriesVisible() -> Bool
|
||||
func areAllCategoriesHidden() -> Bool
|
||||
|
||||
func updateAllCategoriesVisibility(isShowAll: Bool)
|
||||
func updateCategoryVisibility(category: BMCCategory)
|
||||
|
|
|
@ -27,9 +27,9 @@ final class BMCCategoriesHeader: UITableViewHeaderFooterView {
|
|||
}
|
||||
}
|
||||
|
||||
var delegate: BMCCategoriesHeaderDelegate?
|
||||
var delegate: BMCCategoriesHeaderDelegate!
|
||||
|
||||
@IBAction private func buttonAction() {
|
||||
delegate?.visibilityAction(self)
|
||||
delegate.visibilityAction(self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,20 +36,20 @@ final class BMCCategoryCell: MWMTableViewCell {
|
|||
}
|
||||
}
|
||||
|
||||
private var delegate: BMCCategoryCellDelegate?
|
||||
private var delegate: BMCCategoryCellDelegate!
|
||||
|
||||
func config(category: BMCCategory, delegate: BMCCategoryCellDelegate?) -> UITableViewCell {
|
||||
func config(category: BMCCategory, delegate: BMCCategoryCellDelegate) -> UITableViewCell {
|
||||
self.category = category
|
||||
self.delegate = delegate
|
||||
return self
|
||||
}
|
||||
|
||||
@IBAction private func visibilityAction() {
|
||||
delegate?.visibilityAction(category: category)
|
||||
delegate.visibilityAction(category: category)
|
||||
}
|
||||
|
||||
@IBAction private func moreAction() {
|
||||
delegate?.moreAction(category: category, anchor: more)
|
||||
delegate.moreAction(category: category, anchor: more)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
#import "MWMTableViewCell.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
@class MWMCategoryInfoCell;
|
||||
|
||||
@protocol MWMCategoryInfoCellDelegate
|
||||
|
||||
- (void)categoryInfoCellDidPressMore:(MWMCategoryInfoCell *)cell;
|
||||
|
||||
@end
|
||||
|
||||
@interface MWMCategoryInfoCell : MWMTableViewCell
|
||||
|
||||
@property (nonatomic) BOOL expanded;
|
||||
@property (weak, nonatomic) id<MWMCategoryInfoCellDelegate> delegate;
|
||||
|
||||
- (void)updateWithTitle:(NSString *)title
|
||||
author:(NSString *)author
|
||||
info:(NSString *)info
|
||||
shortInfo:(NSString *)shortInfo;
|
||||
- (void)updateWithCategoryData:(kml::CategoryData const &)data
|
||||
delegate:(id<MWMCategoryInfoCellDelegate>)delegate;
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#import "MWMCategoryInfoCell.h"
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
@interface MWMCategoryInfoCell()
|
||||
|
||||
|
@ -18,7 +19,6 @@
|
|||
- (void)awakeFromNib
|
||||
{
|
||||
[super awakeFromNib];
|
||||
|
||||
self.titleLabel.text = nil;
|
||||
self.authorLabel.text = nil;
|
||||
self.infoLabel.text = nil;
|
||||
|
@ -36,13 +36,15 @@
|
|||
self.moreButton.hidden = expanded;
|
||||
}
|
||||
|
||||
- (void)updateWithTitle:(NSString *)title
|
||||
author:(NSString *)author
|
||||
info:(NSString *)info
|
||||
shortInfo:(NSString *)shortInfo
|
||||
- (void)updateWithCategoryData:(const kml::CategoryData &)data
|
||||
delegate:(id<MWMCategoryInfoCellDelegate>)delegate
|
||||
{
|
||||
self.titleLabel.text = title;
|
||||
self.authorLabel.text = author;
|
||||
self.delegate = delegate;
|
||||
self.titleLabel.text = @(kml::GetDefaultStr(data.m_name).c_str());
|
||||
self.authorLabel.text = [NSString stringWithCoreFormat:L(@"author_name_by_prefix")
|
||||
arguments:@[@(data.m_authorName.c_str())]];
|
||||
NSString * info = @(kml::GetDefaultStr(data.m_description).c_str());
|
||||
NSString * shortInfo = @(kml::GetDefaultStr(data.m_annotation).c_str());
|
||||
if (info.length > 0 && shortInfo.length > 0)
|
||||
{
|
||||
self.info = info;
|
||||
|
@ -63,7 +65,6 @@
|
|||
- (void)prepareForReuse
|
||||
{
|
||||
[super prepareForReuse];
|
||||
|
||||
self.titleLabel.text = nil;
|
||||
self.authorLabel.text = nil;
|
||||
self.infoLabel.text = nil;
|
|
@ -38,7 +38,6 @@
|
|||
NSAssert(self.delegate, @"Delegate can't be nil!");
|
||||
self.title = L(@"bookmark_sets");
|
||||
[self reloadData];
|
||||
|
||||
}
|
||||
|
||||
- (void)reloadData
|
||||
|
@ -72,8 +71,8 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
auto & bmManager = GetFramework().GetBookmarkManager();
|
||||
auto categoryId = [self.groupIds[indexPath.row] unsignedLongLongValue];
|
||||
auto const & bmManager = GetFramework().GetBookmarkManager();
|
||||
auto const categoryId = [self.groupIds[indexPath.row] unsignedLongLongValue];
|
||||
if (bmManager.HasBmCategory(categoryId))
|
||||
cell.textLabel.text = @(bmManager.GetCategoryName(categoryId).c_str());
|
||||
|
||||
|
@ -113,7 +112,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
auto categoryId = [self.groupIds[indexPath.row] unsignedLongLongValue];;
|
||||
auto const categoryId = [self.groupIds[indexPath.row] unsignedLongLongValue];;
|
||||
[self moveBookmarkToSetWithCategoryId:categoryId];
|
||||
[self.delegate didSelectCategory:self.category withCategoryId:categoryId];
|
||||
[self backTap];
|
||||
|
|
|
@ -116,13 +116,9 @@ namespace
|
|||
{
|
||||
[super setEnabled:enabled];
|
||||
if (!enabled)
|
||||
{
|
||||
self.tintColor = [UIColor lightGrayColor];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setDefaultTintColor];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setDefaultTintColor
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
@objc(MWMToast)
|
||||
class Toast: NSObject {
|
||||
@objcMembers
|
||||
final class Toast: NSObject {
|
||||
|
||||
private var blurView = UIVisualEffectView(effect: UIBlurEffect(style: .dark))
|
||||
|
||||
|
@ -32,11 +33,11 @@ class Toast: NSObject {
|
|||
views: views))
|
||||
}
|
||||
|
||||
@objc func show() {
|
||||
func show() {
|
||||
show(in: UIApplication.shared.keyWindow)
|
||||
}
|
||||
|
||||
@objc func show(in view: UIView?) {
|
||||
func show(in view: UIView?) {
|
||||
guard let v = view else { return }
|
||||
blurView.translatesAutoresizingMaskIntoConstraints = false
|
||||
v.addSubview(blurView)
|
||||
|
|
|
@ -58,8 +58,7 @@
|
|||
UIView * view = self.view;
|
||||
view.backgroundColor = UIColor.whiteColor;
|
||||
|
||||
WKWebViewConfiguration * configuration = [[WKWebViewConfiguration alloc] init];
|
||||
WKWebView * webView = [[WKWebView alloc] initWithFrame:{} configuration:configuration];
|
||||
WKWebView * webView = [[WKWebView alloc] initWithFrame:{}];
|
||||
webView.navigationDelegate = self;
|
||||
[view addSubview:webView];
|
||||
|
||||
|
@ -135,7 +134,6 @@
|
|||
}
|
||||
|
||||
decisionHandler(WKNavigationActionPolicyAllow);
|
||||
return;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
|
|
|
@ -50,8 +50,8 @@
|
|||
+ (NSURL * _Nullable)sharingUrlForCategoryId:(MWMMarkGroupID)groupId;
|
||||
+ (void)downloadItemWithId:(NSString * _Nonnull)itemId
|
||||
name:(NSString * _Nonnull)name
|
||||
progress:(void (^ _Nullable)(MWMCategoryProgress progress))progress
|
||||
completion:(void (^ _Nullable)(NSError * _Nullable error))completion;
|
||||
progress:(_Nullable ProgressBlock)progress
|
||||
completion:(_Nullable CompletionBlock)completion;
|
||||
+ (BOOL)isCategoryFromCatalog:(MWMMarkGroupID)groupId;
|
||||
+ (NSArray<MWMCatalogCategory *> * _Nonnull)categoriesFromCatalog;
|
||||
+ (NSInteger)getCatalogDownloadsCount;
|
||||
|
|
|
@ -447,22 +447,22 @@ NSString * const CloudErrorToString(Cloud::SynchronizationResult result)
|
|||
return GetFramework().GetBookmarkManager().AreNotificationsEnabled();
|
||||
}
|
||||
|
||||
+ (NSURL * _Nullable )catalogFrontendUrl
|
||||
+ (NSURL *)catalogFrontendUrl
|
||||
{
|
||||
NSString *urlString = @(GetFramework().GetBookmarkManager().GetCatalog().GetFrontendUrl().c_str());
|
||||
NSString * urlString = @(GetFramework().GetBookmarkManager().GetCatalog().GetFrontendUrl().c_str());
|
||||
return urlString ? [NSURL URLWithString:urlString] : nil;
|
||||
}
|
||||
|
||||
+ (NSURL * _Nullable)sharingUrlForCategoryId:(MWMMarkGroupID)groupId
|
||||
+ (NSURL *)sharingUrlForCategoryId:(MWMMarkGroupID)groupId
|
||||
{
|
||||
NSString *urlString = @(GetFramework().GetBookmarkManager().GetCategoryCatalogDeeplink(groupId).c_str());
|
||||
NSString * urlString = @(GetFramework().GetBookmarkManager().GetCategoryCatalogDeeplink(groupId).c_str());
|
||||
return urlString ? [NSURL URLWithString:urlString] : nil;
|
||||
}
|
||||
|
||||
+ (void)downloadItemWithId:(NSString *)itemId
|
||||
name:(NSString *)name
|
||||
progress:(void (^)(MWMCategoryProgress progress))progress
|
||||
completion:(void (^)(NSError * error))completion
|
||||
progress:(ProgressBlock)progress
|
||||
completion:(CompletionBlock)completion
|
||||
{
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
|
@ -504,7 +504,7 @@ NSString * const CloudErrorToString(Cloud::SynchronizationResult result)
|
|||
std::move(onImportStarted),
|
||||
std::move(onImportFinished));
|
||||
});
|
||||
auto *observer = [[MWMCatalogObserver alloc] init];
|
||||
auto observer = [[MWMCatalogObserver alloc] init];
|
||||
observer.categoryId = itemId;
|
||||
observer.progressBlock = progress;
|
||||
observer.completionBlock = completion;
|
||||
|
@ -526,7 +526,7 @@ NSString * const CloudErrorToString(Cloud::SynchronizationResult result)
|
|||
if ([self isCategoryFromCatalog:groupId])
|
||||
{
|
||||
kml::CategoryData categoryData = GetFramework().GetBookmarkManager().GetCategoryData(groupId);
|
||||
UInt64 bookmarksCount = [self getCategoryMarksCount:groupId] + [self getCategoryTracksCount:groupId];
|
||||
uint64_t bookmarksCount = [self getCategoryMarksCount:groupId] + [self getCategoryTracksCount:groupId];
|
||||
MWMCatalogCategory * category = [[MWMCatalogCategory alloc] initWithCategoryData:categoryData
|
||||
bookmarksCount:bookmarksCount];
|
||||
[result addObject:category];
|
||||
|
|
|
@ -20,3 +20,7 @@ static NSInteger const kCategoryDownloadFailedCode = -10;
|
|||
static NSInteger const kCategoryImportFailedCode = -11;
|
||||
|
||||
static NSString * const kCategoryDownloadStatusKey = @"kCategoryDownloadStatusKey";
|
||||
|
||||
typedef void (^ProgressBlock)(MWMCategoryProgress progress);
|
||||
typedef void (^CompletionBlock)(NSError * error);
|
||||
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "MWMCatalogCommon.h"
|
||||
|
||||
#include "platform/remote_file.hpp"
|
||||
|
||||
@interface MWMCatalogObserver : NSObject
|
||||
|
||||
@property (copy, nonatomic) NSString * categoryId;
|
||||
@property (copy, nonatomic) void(^progressBlock)(MWMCategoryProgress progress);
|
||||
@property (copy, nonatomic) void(^completionBlock)(NSError * error);
|
||||
@property (copy, nonatomic) ProgressBlock progressBlock;
|
||||
@property (copy, nonatomic) CompletionBlock completionBlock;
|
||||
|
||||
- (void)onDownloadStart;
|
||||
- (void)onDownloadComplete:(platform::RemoteFile::Status)status;
|
||||
- (void)onImportStart;
|
||||
- (void)onImportCompleteSuccessful:(BOOL)success;
|
||||
|
||||
@end
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
- (void)onDownloadComplete:(platform::RemoteFile::Status)status
|
||||
{
|
||||
MWMCategoryDownloadStatus downloadStatus;
|
||||
switch (status) {
|
||||
switch (status)
|
||||
{
|
||||
case platform::RemoteFile::Status::Ok:
|
||||
if (self.progressBlock)
|
||||
self.progressBlock(MWMCategoryProgressDownloadFinished);
|
||||
return;
|
||||
break;
|
||||
case platform::RemoteFile::Status::Forbidden:
|
||||
downloadStatus = MWMCategoryDownloadStatusForbidden;
|
||||
break;
|
||||
|
|
|
@ -466,7 +466,7 @@
|
|||
B32FE74020D2844600EF7446 /* DownloadedBookmarksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B32FE73E20D2844600EF7446 /* DownloadedBookmarksViewController.swift */; };
|
||||
B32FE74120D2844600EF7446 /* DownloadedBookmarksViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B32FE73F20D2844600EF7446 /* DownloadedBookmarksViewController.xib */; };
|
||||
B32FE74320D2B09600EF7446 /* CatalogWebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B32FE74220D2B09600EF7446 /* CatalogWebViewController.swift */; };
|
||||
B33D21AC20DA515800BAD749 /* MWMCategoryInfoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B33D21AA20DA515800BAD749 /* MWMCategoryInfoCell.m */; };
|
||||
B33D21AC20DA515800BAD749 /* MWMCategoryInfoCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = B33D21AA20DA515800BAD749 /* MWMCategoryInfoCell.mm */; };
|
||||
B33D21AD20DA515800BAD749 /* MWMCategoryInfoCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = B33D21AB20DA515800BAD749 /* MWMCategoryInfoCell.xib */; };
|
||||
B33D21AF20DAF9F000BAD749 /* Toast.swift in Sources */ = {isa = PBXBuildFile; fileRef = B33D21AE20DAF9F000BAD749 /* Toast.swift */; };
|
||||
B33D21B220DBCC5E00BAD749 /* MWMCatalogObserver.mm in Sources */ = {isa = PBXBuildFile; fileRef = B33D21B120DBCC5D00BAD749 /* MWMCatalogObserver.mm */; };
|
||||
|
@ -1394,7 +1394,7 @@
|
|||
B32FE73F20D2844600EF7446 /* DownloadedBookmarksViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DownloadedBookmarksViewController.xib; sourceTree = "<group>"; };
|
||||
B32FE74220D2B09600EF7446 /* CatalogWebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CatalogWebViewController.swift; sourceTree = "<group>"; };
|
||||
B33D21A920DA515800BAD749 /* MWMCategoryInfoCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMCategoryInfoCell.h; sourceTree = "<group>"; };
|
||||
B33D21AA20DA515800BAD749 /* MWMCategoryInfoCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MWMCategoryInfoCell.m; sourceTree = "<group>"; };
|
||||
B33D21AA20DA515800BAD749 /* MWMCategoryInfoCell.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMCategoryInfoCell.mm; sourceTree = "<group>"; };
|
||||
B33D21AB20DA515800BAD749 /* MWMCategoryInfoCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MWMCategoryInfoCell.xib; sourceTree = "<group>"; };
|
||||
B33D21AE20DAF9F000BAD749 /* Toast.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toast.swift; sourceTree = "<group>"; };
|
||||
B33D21B020DBCC5D00BAD749 /* MWMCatalogObserver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMCatalogObserver.h; sourceTree = "<group>"; };
|
||||
|
@ -4111,7 +4111,7 @@
|
|||
FA36B80515403A4F004560CC /* BookmarksVC.h */,
|
||||
FA36B80615403A4F004560CC /* BookmarksVC.mm */,
|
||||
B33D21A920DA515800BAD749 /* MWMCategoryInfoCell.h */,
|
||||
B33D21AA20DA515800BAD749 /* MWMCategoryInfoCell.m */,
|
||||
B33D21AA20DA515800BAD749 /* MWMCategoryInfoCell.mm */,
|
||||
B33D21AB20DA515800BAD749 /* MWMCategoryInfoCell.xib */,
|
||||
3404F4A02028A6C00090E401 /* Categories */,
|
||||
FA054610155C465E001F4E37 /* SelectSetVC.h */,
|
||||
|
@ -4616,7 +4616,7 @@
|
|||
F6E2FF631E097BA00083EBEC /* MWMTTSLanguageViewController.mm in Sources */,
|
||||
342EE4121C43DAA7009F6A49 /* MWMAuthorizationWebViewLoginViewController.mm in Sources */,
|
||||
34AB667D1FC5AA330078E451 /* MWMRoutePreview.mm in Sources */,
|
||||
B33D21AC20DA515800BAD749 /* MWMCategoryInfoCell.m in Sources */,
|
||||
B33D21AC20DA515800BAD749 /* MWMCategoryInfoCell.mm in Sources */,
|
||||
34845DAF1E1649F6003D55B9 /* DownloaderNoResultsEmbedViewController.swift in Sources */,
|
||||
F6791B141C43DF0B007A8A6E /* MWMStartButton.mm in Sources */,
|
||||
F6E2FEDF1E097BA00083EBEC /* MWMSearchManager+Layout.mm in Sources */,
|
||||
|
|
|
@ -223,7 +223,7 @@ using NewSectionsAreReady = void (^)(NSRange const & range, MWMPlacePageData * d
|
|||
- (NSString *)bookmarkCategory;
|
||||
- (kml::MarkId)bookmarkId;
|
||||
- (kml::MarkGroupId)bookmarkCategoryId;
|
||||
- (BOOL)isFromCatalog;
|
||||
- (BOOL)isBookmarkFromCatalog;
|
||||
|
||||
// Local Ads
|
||||
- (NSString *)localAdsURL;
|
||||
|
|
|
@ -736,7 +736,7 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
|
|||
return m_info.GetBookmarkCategoryId();
|
||||
}
|
||||
|
||||
- (BOOL)isFromCatalog
|
||||
- (BOOL)isBookmarkFromCatalog
|
||||
{
|
||||
return self.isBookmark && [MWMBookmarksManager isCategoryFromCatalog:self.bookmarkCategoryId];
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
@protocol MWMActionBarSharedData<NSObject>
|
||||
|
||||
- (BOOL)isBookmark;
|
||||
- (BOOL)isFromCatalog;
|
||||
- (BOOL)isBookmarkFromCatalog;
|
||||
- (BOOL)isOpentable;
|
||||
- (BOOL)isPartner;
|
||||
- (BOOL)isBooking;
|
||||
|
|
|
@ -130,7 +130,7 @@
|
|||
for (auto const buttonType : m_visibleButtons)
|
||||
{
|
||||
auto const isSelected = (buttonType == EButton::Bookmark ? [data isBookmark] : NO);
|
||||
auto const isDisabled = (buttonType == EButton::Bookmark && data.isFromCatalog);
|
||||
auto const isDisabled = (buttonType == EButton::Bookmark && data.isBookmarkFromCatalog);
|
||||
auto button = [MWMActionBarButton buttonWithDelegate:self
|
||||
buttonType:buttonType
|
||||
partnerIndex:partnerIndex
|
||||
|
|
|
@ -284,7 +284,7 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
|
|||
return 0;
|
||||
switch (data.sections[section])
|
||||
{
|
||||
case Sections::Bookmark: return data.isFromCatalog ? 0 : 1;
|
||||
case Sections::Bookmark: return data.isBookmarkFromCatalog ? 0 : 1;
|
||||
case Sections::Preview: return data.previewRows.size();
|
||||
case Sections::SpecialProjects: return data.specialProjectRows.size();
|
||||
case Sections::Metainfo: return data.metainfoRows.size();
|
||||
|
|
Loading…
Add table
Reference in a new issue