forked from organicmaps/organicmaps
[iOS] Added 'Add map' button in Downloader
https://jira.mail.ru/browse/MAPSME-12359
This commit is contained in:
parent
fc98524cf1
commit
7c0f3edab9
4 changed files with 27 additions and 10 deletions
|
@ -40,6 +40,7 @@
|
|||
#import "MWMLocationManager.h"
|
||||
#import "MWMMapWidgetsHelper.h"
|
||||
#import "MWMMapDownloaderTableViewCell.h"
|
||||
#import "MWMMapDownloaderButtonTableViewCell.h"
|
||||
#import "MWMMapDownloaderPlaceTableViewCell.h"
|
||||
#import "MWMMapDownloaderLargeCountryTableViewCell.h"
|
||||
#import "MWMMapDownloaderSubplaceTableViewCell.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
@protocol MWMMapDownloaderButtonTableViewCellProtocol <NSObject>
|
||||
|
||||
- (void)openAvailableMaps;
|
||||
- (void)onAddMaps;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
- (IBAction)buttonPressed
|
||||
{
|
||||
[self.delegate openAvailableMaps];
|
||||
[self.delegate onAddMaps];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -33,6 +33,7 @@ class DownloadMapsViewController: MWMViewController {
|
|||
var dataSource: IDownloaderDataSource!
|
||||
@objc var mode: MWMMapDownloaderMode = .downloaded
|
||||
private var skipCountryEvent = false
|
||||
private var hasAddMapSection: Bool { dataSource.isRoot && mode == .downloaded }
|
||||
|
||||
lazy var noSerchResultViewController: SearchNoResultsViewController = {
|
||||
let vc = storyboard!.instantiateViewController(ofType: SearchNoResultsViewController.self)
|
||||
|
@ -62,6 +63,7 @@ class DownloadMapsViewController: MWMViewController {
|
|||
tableView.registerNib(cell: MWMMapDownloaderPlaceTableViewCell.self)
|
||||
tableView.registerNib(cell: MWMMapDownloaderLargeCountryTableViewCell.self)
|
||||
tableView.registerNib(cell: MWMMapDownloaderSubplaceTableViewCell.self)
|
||||
tableView.registerNib(cell: MWMMapDownloaderButtonTableViewCell.self)
|
||||
title = dataSource.title
|
||||
if mode == .downloaded {
|
||||
let addMapsButton = button(with: UIImage(named: "ic_nav_bar_add"), action: #selector(onAddMaps))
|
||||
|
@ -192,12 +194,6 @@ class DownloadMapsViewController: MWMViewController {
|
|||
}
|
||||
}
|
||||
|
||||
@objc func onAddMaps() {
|
||||
let vc = storyboard!.instantiateViewController(ofType: DownloadMapsViewController.self)
|
||||
vc.mode = .available
|
||||
navigationController?.pushViewController(vc, animated: true)
|
||||
}
|
||||
|
||||
@IBAction func onAllMaps(_ sender: UIButton) {
|
||||
skipCountryEvent = true
|
||||
if mode == .downloaded {
|
||||
|
@ -222,14 +218,24 @@ class DownloadMapsViewController: MWMViewController {
|
|||
|
||||
extension DownloadMapsViewController: UITableViewDataSource {
|
||||
func numberOfSections(in tableView: UITableView) -> Int {
|
||||
dataSource.numberOfSections()
|
||||
dataSource.numberOfSections() + (hasAddMapSection ? 1 : 0)
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
dataSource.numberOfItems(in: section)
|
||||
if hasAddMapSection && section == dataSource.numberOfSections() {
|
||||
return 1
|
||||
}
|
||||
return dataSource.numberOfItems(in: section)
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
if hasAddMapSection && indexPath.section == dataSource.numberOfSections() {
|
||||
let cellType = MWMMapDownloaderButtonTableViewCell.self
|
||||
let buttonCell = tableView.dequeueReusableCell(cell: cellType, indexPath: indexPath)
|
||||
buttonCell.delegate = self
|
||||
return buttonCell
|
||||
}
|
||||
|
||||
let nodeAttrs = dataSource.item(at: indexPath)
|
||||
let cell: MWMMapDownloaderTableViewCell
|
||||
if dataSource.item(at: indexPath).hasChildren {
|
||||
|
@ -437,3 +443,13 @@ extension DownloadMapsViewController: UIBarPositioningDelegate {
|
|||
.topAttached
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - MWMMapDownloaderButtonTableViewCellProtocol
|
||||
|
||||
extension DownloadMapsViewController: MWMMapDownloaderButtonTableViewCellProtocol {
|
||||
@objc func onAddMaps() {
|
||||
let vc = storyboard!.instantiateViewController(ofType: DownloadMapsViewController.self)
|
||||
vc.mode = .available
|
||||
navigationController?.pushViewController(vc, animated: true)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue