mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-21 22:03:37 +00:00
[ios] Added help to menu and switched some menu icons to system symbols
Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
This commit is contained in:
committed by
Yannik Bloscheck
parent
a5bd24ccdb
commit
5ae0ef626a
@@ -2,10 +2,10 @@ extension Settings {
|
|||||||
/// The type of the left bottom bar button
|
/// The type of the left bottom bar button
|
||||||
enum LeftButtonType: String, Codable, CaseIterable, Identifiable {
|
enum LeftButtonType: String, Codable, CaseIterable, Identifiable {
|
||||||
case hidden = "Hidden"
|
case hidden = "Hidden"
|
||||||
case help = "Help"
|
|
||||||
case addPlace = "AddPlace"
|
case addPlace = "AddPlace"
|
||||||
case settings = "Settings"
|
|
||||||
case recordTrack = "RecordTrack"
|
case recordTrack = "RecordTrack"
|
||||||
|
case settings = "Settings"
|
||||||
|
case help = "Help"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -20,30 +20,30 @@ extension Settings {
|
|||||||
switch self {
|
switch self {
|
||||||
case .hidden:
|
case .hidden:
|
||||||
return String(localized: "disabled")
|
return String(localized: "disabled")
|
||||||
case .help:
|
|
||||||
return String(localized: "help")
|
|
||||||
case .addPlace:
|
case .addPlace:
|
||||||
return String(localized: "placepage_add_place_button")
|
return String(localized: "placepage_add_place_button")
|
||||||
case .settings:
|
|
||||||
return String(localized: "settings")
|
|
||||||
case .recordTrack:
|
case .recordTrack:
|
||||||
return String(localized: "start_track_recording")
|
return String(localized: "start_track_recording")
|
||||||
|
case .settings:
|
||||||
|
return String(localized: "settings")
|
||||||
|
case .help:
|
||||||
|
return String(localized: "help")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// The image
|
/// The image
|
||||||
var image: UIImage {
|
var image: UIImage {
|
||||||
let configuration = UIImage.SymbolConfiguration(pointSize: 22, weight: .semibold)
|
let configuration = UIImage.SymbolConfiguration(pointSize: 24, weight: .semibold)
|
||||||
switch self {
|
switch self {
|
||||||
case .help:
|
|
||||||
return UIImage(systemName: "questionmark", withConfiguration: configuration)!
|
|
||||||
case .addPlace:
|
case .addPlace:
|
||||||
return UIImage(systemName: "plus", withConfiguration: configuration)!
|
return UIImage(systemName: "plus", withConfiguration: configuration)!
|
||||||
case .settings:
|
|
||||||
return UIImage(systemName: "gearshape.fill", withConfiguration: configuration)!
|
|
||||||
case .recordTrack:
|
case .recordTrack:
|
||||||
return UIImage.MainButtons.LeftButton.recordTrack.withConfiguration(configuration)
|
return UIImage.MainButtons.LeftButton.recordTrack.withConfiguration(configuration)
|
||||||
|
case .settings:
|
||||||
|
return UIImage(systemName: "gearshape.fill", withConfiguration: UIImage.SymbolConfiguration(pointSize: 22, weight: .semibold))!
|
||||||
|
case .help:
|
||||||
|
return UIImage(systemName: "info.circle", withConfiguration: configuration)!
|
||||||
default:
|
default:
|
||||||
return UIImage()
|
return UIImage()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ protocol BottomMenuInteractorProtocol: AnyObject {
|
|||||||
func addPlace()
|
func addPlace()
|
||||||
func downloadMaps()
|
func downloadMaps()
|
||||||
func donate()
|
func donate()
|
||||||
|
func openHelp()
|
||||||
func openSettings()
|
func openSettings()
|
||||||
func shareLocation(cell: BottomMenuItemCell)
|
func shareLocation(cell: BottomMenuItemCell)
|
||||||
func toggleTrackRecording()
|
func toggleTrackRecording()
|
||||||
@@ -60,6 +61,11 @@ extension BottomMenuInteractor: BottomMenuInteractorProtocol {
|
|||||||
delegate?.actionDownloadMaps(.downloaded)
|
delegate?.actionDownloadMaps(.downloaded)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func openHelp() {
|
||||||
|
close()
|
||||||
|
mapViewController?.openAbout()
|
||||||
|
}
|
||||||
|
|
||||||
func openSettings() {
|
func openSettings() {
|
||||||
close()
|
close()
|
||||||
mapViewController?.openSettings()
|
mapViewController?.openSettings()
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ class BottomMenuPresenter: NSObject {
|
|||||||
enum CellType: Int, CaseIterable {
|
enum CellType: Int, CaseIterable {
|
||||||
case addPlace
|
case addPlace
|
||||||
case recordTrack
|
case recordTrack
|
||||||
case downloadMaps
|
|
||||||
case donate
|
|
||||||
case settings
|
|
||||||
case share
|
case share
|
||||||
|
case donate
|
||||||
|
case downloadMaps
|
||||||
|
case settings
|
||||||
|
case help
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Sections: Int {
|
enum Sections: Int {
|
||||||
@@ -22,7 +23,7 @@ class BottomMenuPresenter: NSObject {
|
|||||||
private weak var view: BottomMenuViewProtocol?
|
private weak var view: BottomMenuViewProtocol?
|
||||||
private let interactor: BottomMenuInteractorProtocol
|
private let interactor: BottomMenuInteractorProtocol
|
||||||
private let sections: [Sections]
|
private let sections: [Sections]
|
||||||
private let menuCells: [CellType]
|
private var menuCells: [CellType]
|
||||||
private let trackRecorder = TrackRecordingManager.shared
|
private let trackRecorder = TrackRecordingManager.shared
|
||||||
private var cellToHighlight: CellType?
|
private var cellToHighlight: CellType?
|
||||||
|
|
||||||
@@ -32,8 +33,7 @@ class BottomMenuPresenter: NSObject {
|
|||||||
self.view = view
|
self.view = view
|
||||||
self.interactor = interactor
|
self.interactor = interactor
|
||||||
self.sections = sections
|
self.sections = sections
|
||||||
let disableDonate = SettingsBridge.donateUrl() == nil
|
self.menuCells = []
|
||||||
self.menuCells = CellType.allCases.filter { disableDonate ? $0 != .donate : true }
|
|
||||||
self.cellToHighlight = Self.getCellToHighlight()
|
self.cellToHighlight = Self.getCellToHighlight()
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
@@ -78,6 +78,22 @@ extension BottomMenuPresenter {
|
|||||||
case .layers:
|
case .layers:
|
||||||
return 1
|
return 1
|
||||||
case .items:
|
case .items:
|
||||||
|
let leftButtonType = Settings.leftButtonType
|
||||||
|
menuCells = CellType.allCases.filter { cell in
|
||||||
|
if cell == .donate {
|
||||||
|
return false
|
||||||
|
} else if leftButtonType == .addPlace, cell == .addPlace {
|
||||||
|
return false
|
||||||
|
} else if leftButtonType == .recordTrack, cell == .recordTrack {
|
||||||
|
return false
|
||||||
|
} else if leftButtonType == .help, cell == .help {
|
||||||
|
return false
|
||||||
|
} else if leftButtonType == .settings, cell == .settings {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
return menuCells.count
|
return menuCells.count
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,7 +112,7 @@ extension BottomMenuPresenter {
|
|||||||
switch menuCells[indexPath.row] {
|
switch menuCells[indexPath.row] {
|
||||||
case .addPlace:
|
case .addPlace:
|
||||||
let enabled = MWMNavigationDashboardManager.shared().state == .hidden && FrameworkHelper.canEditMapAtViewportCenter()
|
let enabled = MWMNavigationDashboardManager.shared().state == .hidden && FrameworkHelper.canEditMapAtViewportCenter()
|
||||||
cell.configure(imageName: "ic_add_place",
|
cell.configure(imageName: "plus",
|
||||||
title: L("placepage_add_place_button"),
|
title: L("placepage_add_place_button"),
|
||||||
enabled: enabled)
|
enabled: enabled)
|
||||||
case .recordTrack:
|
case .recordTrack:
|
||||||
@@ -114,11 +130,14 @@ extension BottomMenuPresenter {
|
|||||||
case .donate:
|
case .donate:
|
||||||
cell.configure(imageName: "ic_menu_donate",
|
cell.configure(imageName: "ic_menu_donate",
|
||||||
title: L("donate"))
|
title: L("donate"))
|
||||||
|
case .help:
|
||||||
|
cell.configure(imageName: "help",
|
||||||
|
title: L("help"))
|
||||||
case .settings:
|
case .settings:
|
||||||
cell.configure(imageName: "ic_menu_settings",
|
cell.configure(imageName: "gearshape.fill",
|
||||||
title: L("settings"))
|
title: L("settings"))
|
||||||
case .share:
|
case .share:
|
||||||
cell.configure(imageName: "ic_menu_share",
|
cell.configure(imageName: "square.and.arrow.up",
|
||||||
title: L("share_my_location"))
|
title: L("share_my_location"))
|
||||||
}
|
}
|
||||||
return cell
|
return cell
|
||||||
@@ -151,6 +170,8 @@ extension BottomMenuPresenter {
|
|||||||
interactor.downloadMaps()
|
interactor.downloadMaps()
|
||||||
case .donate:
|
case .donate:
|
||||||
interactor.donate()
|
interactor.donate()
|
||||||
|
case .help:
|
||||||
|
interactor.openHelp()
|
||||||
case .settings:
|
case .settings:
|
||||||
interactor.openSettings()
|
interactor.openSettings()
|
||||||
case .share:
|
case .share:
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ class BottomMenuViewController: MWMViewController {
|
|||||||
tableView.delegate = presenter
|
tableView.delegate = presenter
|
||||||
tableView.registerNib(cell: BottomMenuItemCell.self)
|
tableView.registerNib(cell: BottomMenuItemCell.self)
|
||||||
tableView.registerNib(cell: BottomMenuLayersCell.self)
|
tableView.registerNib(cell: BottomMenuLayersCell.self)
|
||||||
|
|
||||||
|
NotificationCenter.default.addObserver(forName: UserDefaults.didChangeNotification, object: nil, queue: nil) { _ in
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.tableView.reloadData()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewDidAppear(_ animated: Bool) {
|
override func viewDidAppear(_ animated: Bool) {
|
||||||
|
|||||||
@@ -17,7 +17,17 @@ class BottomMenuItemCell: UITableViewCell {
|
|||||||
private(set) var isEnabled: Bool = true
|
private(set) var isEnabled: Bool = true
|
||||||
|
|
||||||
func configure(imageName: String, title: String, badgeCount: UInt = .zero, enabled: Bool = true) {
|
func configure(imageName: String, title: String, badgeCount: UInt = .zero, enabled: Bool = true) {
|
||||||
icon.image = UIImage(named: imageName)
|
if imageName == "help" {
|
||||||
|
icon.image = Settings.LeftButtonType.help.image
|
||||||
|
} else if imageName == "plus" {
|
||||||
|
icon.image = Settings.LeftButtonType.addPlace.image
|
||||||
|
} else if imageName == "track_recorder_inactive" || imageName == "track_recorder_active" || imageName == "ic_menu_download" || imageName == "ic_menu_donate" {
|
||||||
|
icon.image = UIImage(named: imageName)
|
||||||
|
} else {
|
||||||
|
let configuration = UIImage.SymbolConfiguration(pointSize: 22, weight: .semibold)
|
||||||
|
icon.image = UIImage(systemName: imageName, withConfiguration: configuration)!
|
||||||
|
}
|
||||||
|
|
||||||
label.text = title
|
label.text = title
|
||||||
badgeBackground.isHidden = badgeCount == 0
|
badgeBackground.isHidden = badgeCount == 0
|
||||||
badgeCountLabel.text = "\(badgeCount)"
|
badgeCountLabel.text = "\(badgeCount)"
|
||||||
|
|||||||
Reference in New Issue
Block a user