forked from organicmaps/organicmaps
[iOS] handle catalog deeplink, disable share for catalog items
This commit is contained in:
parent
c179611c1f
commit
09278308a3
4 changed files with 56 additions and 20 deletions
|
@ -1,12 +1,16 @@
|
|||
@objc(MWMBookmarksTabViewController)
|
||||
final class BookmarksTabViewController: TabViewController {
|
||||
@objc enum ActiveTab: Int {
|
||||
case user = 0
|
||||
case catalog
|
||||
}
|
||||
|
||||
private static let selectedIndexKey = "BookmarksTabViewController_selectedIndexKey"
|
||||
private var selectedIndex: Int {
|
||||
get {
|
||||
return UserDefaults.standard.integer(forKey: BookmarksTabViewController.selectedIndexKey)
|
||||
}
|
||||
set {
|
||||
UserDefaults.standard.set(newValue, forKey: BookmarksTabViewController.selectedIndexKey)
|
||||
|
||||
@objc public var activeTab: ActiveTab = ActiveTab.init(rawValue:
|
||||
UserDefaults.standard.integer(forKey: BookmarksTabViewController.selectedIndexKey)) ?? .user {
|
||||
didSet {
|
||||
UserDefaults.standard.set(activeTab.rawValue, forKey: BookmarksTabViewController.selectedIndexKey)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,11 +28,11 @@ final class BookmarksTabViewController: TabViewController {
|
|||
tabView.tintColor = .white()
|
||||
tabView.headerTextAttributes = [.foregroundColor: UIColor.whitePrimaryText(),
|
||||
.font: UIFont.medium14()]
|
||||
tabView.selectedIndex = selectedIndex
|
||||
tabView.selectedIndex = activeTab.rawValue
|
||||
}
|
||||
|
||||
override func viewDidDisappear(_ animated: Bool) {
|
||||
super.viewDidDisappear(animated)
|
||||
selectedIndex = tabView.selectedIndex
|
||||
activeTab = ActiveTab.init(rawValue: tabView.selectedIndex) ?? .user
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,24 @@
|
|||
@objc(MWMCatalogWebViewController)
|
||||
final class CatalogWebViewController: WebViewController {
|
||||
|
||||
let progressView = UIVisualEffectView(effect: UIBlurEffect(style: .dark))
|
||||
let progressImageView = UIImageView(image: #imageLiteral(resourceName: "ic_24px_spinner"))
|
||||
let numberOfTasksLabel = UILabel()
|
||||
|
||||
var deeplink: URL?
|
||||
|
||||
@objc init() {
|
||||
super.init(url: MWMBookmarksManager.catalogFrontendUrl(), andTitleOrNil: L("routes_and_bookmarks"))
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
@objc convenience init(_ deeplinkURL: URL) {
|
||||
self.init()
|
||||
deeplink = deeplinkURL
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
|
@ -60,6 +75,13 @@ final class CatalogWebViewController: WebViewController {
|
|||
updateProgress()
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
if let deeplink = deeplink {
|
||||
processDeeplink(deeplink)
|
||||
}
|
||||
}
|
||||
|
||||
override func webView(_ webView: WKWebView,
|
||||
decidePolicyFor navigationAction: WKNavigationAction,
|
||||
decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
||||
|
|
|
@ -25,12 +25,7 @@ class DownloadedBookmarksViewController: MWMViewController {
|
|||
MWMAlertViewController.activeAlert().presentNoConnectionAlert();
|
||||
return
|
||||
}
|
||||
guard let url = MWMBookmarksManager.catalogFrontendUrl(),
|
||||
let webViewController = CatalogWebViewController(url: url,
|
||||
andTitleOrNil: L("routes_and_bookmarks")) else {
|
||||
assertionFailure()
|
||||
return
|
||||
}
|
||||
let webViewController = CatalogWebViewController()
|
||||
MapViewController.topViewController().navigationController?.pushViewController(webViewController,
|
||||
animated: true)
|
||||
}
|
||||
|
@ -124,10 +119,11 @@ extension DownloadedBookmarksViewController: CatalogCategoryCellDelegate {
|
|||
self.tableView.reloadRows(at: [indexPath], with: .none)
|
||||
}))
|
||||
|
||||
let share = L("share").capitalized
|
||||
actionSheet.addAction(UIAlertAction(title: share, style: .default, handler: { _ in
|
||||
self.shareCategory(at: indexPath.row)
|
||||
}))
|
||||
// TODO: uncomment once the correct deeplink generation is implemented
|
||||
// let share = L("share").capitalized
|
||||
// actionSheet.addAction(UIAlertAction(title: share, style: .default, handler: { _ in
|
||||
// self.shareCategory(at: indexPath.row)
|
||||
// }))
|
||||
|
||||
let delete = L("delete").capitalized
|
||||
let deleteAction = UIAlertAction(title: delete, style: .destructive, handler: { _ in
|
||||
|
|
|
@ -210,7 +210,21 @@ using namespace osm_auth_ios;
|
|||
switch (parsingType)
|
||||
{
|
||||
case ParsedMapApi::ParsingResult::Incorrect:
|
||||
LOG(LWARNING, ("Incorrect parsing result for url:", url));
|
||||
if ([m_mwmURL rangeOfString:@"catalog"].location != NSNotFound)
|
||||
{
|
||||
auto navController = self.mapViewController.navigationController;
|
||||
[navController popToRootViewControllerAnimated:NO];
|
||||
auto bookmarks = [[MWMBookmarksTabViewController alloc] init];
|
||||
bookmarks.activeTab = ActiveTabCatalog;
|
||||
auto url = [[NSURL alloc] initWithString:m_mwmURL];
|
||||
auto catalog = [[MWMCatalogWebViewController alloc] init:url];
|
||||
[navController pushViewController:bookmarks animated:NO];
|
||||
[navController pushViewController:catalog animated:NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(LWARNING, ("Incorrect parsing result for url:", url));
|
||||
}
|
||||
break;
|
||||
case ParsedMapApi::ParsingResult::Route:
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue