mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-22 06:03:45 +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
|
||||
enum LeftButtonType: String, Codable, CaseIterable, Identifiable {
|
||||
case hidden = "Hidden"
|
||||
case help = "Help"
|
||||
case addPlace = "AddPlace"
|
||||
case settings = "Settings"
|
||||
case recordTrack = "RecordTrack"
|
||||
case settings = "Settings"
|
||||
case help = "Help"
|
||||
|
||||
|
||||
|
||||
@@ -20,30 +20,30 @@ extension Settings {
|
||||
switch self {
|
||||
case .hidden:
|
||||
return String(localized: "disabled")
|
||||
case .help:
|
||||
return String(localized: "help")
|
||||
case .addPlace:
|
||||
return String(localized: "placepage_add_place_button")
|
||||
case .settings:
|
||||
return String(localized: "settings")
|
||||
case .recordTrack:
|
||||
return String(localized: "start_track_recording")
|
||||
case .settings:
|
||||
return String(localized: "settings")
|
||||
case .help:
|
||||
return String(localized: "help")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// The image
|
||||
var image: UIImage {
|
||||
let configuration = UIImage.SymbolConfiguration(pointSize: 22, weight: .semibold)
|
||||
let configuration = UIImage.SymbolConfiguration(pointSize: 24, weight: .semibold)
|
||||
switch self {
|
||||
case .help:
|
||||
return UIImage(systemName: "questionmark", withConfiguration: configuration)!
|
||||
case .addPlace:
|
||||
return UIImage(systemName: "plus", withConfiguration: configuration)!
|
||||
case .settings:
|
||||
return UIImage(systemName: "gearshape.fill", withConfiguration: configuration)!
|
||||
case .recordTrack:
|
||||
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:
|
||||
return UIImage()
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ protocol BottomMenuInteractorProtocol: AnyObject {
|
||||
func addPlace()
|
||||
func downloadMaps()
|
||||
func donate()
|
||||
func openHelp()
|
||||
func openSettings()
|
||||
func shareLocation(cell: BottomMenuItemCell)
|
||||
func toggleTrackRecording()
|
||||
@@ -60,6 +61,11 @@ extension BottomMenuInteractor: BottomMenuInteractorProtocol {
|
||||
delegate?.actionDownloadMaps(.downloaded)
|
||||
}
|
||||
|
||||
func openHelp() {
|
||||
close()
|
||||
mapViewController?.openAbout()
|
||||
}
|
||||
|
||||
func openSettings() {
|
||||
close()
|
||||
mapViewController?.openSettings()
|
||||
|
||||
@@ -8,10 +8,11 @@ class BottomMenuPresenter: NSObject {
|
||||
enum CellType: Int, CaseIterable {
|
||||
case addPlace
|
||||
case recordTrack
|
||||
case downloadMaps
|
||||
case donate
|
||||
case settings
|
||||
case share
|
||||
case donate
|
||||
case downloadMaps
|
||||
case settings
|
||||
case help
|
||||
}
|
||||
|
||||
enum Sections: Int {
|
||||
@@ -22,7 +23,7 @@ class BottomMenuPresenter: NSObject {
|
||||
private weak var view: BottomMenuViewProtocol?
|
||||
private let interactor: BottomMenuInteractorProtocol
|
||||
private let sections: [Sections]
|
||||
private let menuCells: [CellType]
|
||||
private var menuCells: [CellType]
|
||||
private let trackRecorder = TrackRecordingManager.shared
|
||||
private var cellToHighlight: CellType?
|
||||
|
||||
@@ -32,8 +33,7 @@ class BottomMenuPresenter: NSObject {
|
||||
self.view = view
|
||||
self.interactor = interactor
|
||||
self.sections = sections
|
||||
let disableDonate = SettingsBridge.donateUrl() == nil
|
||||
self.menuCells = CellType.allCases.filter { disableDonate ? $0 != .donate : true }
|
||||
self.menuCells = []
|
||||
self.cellToHighlight = Self.getCellToHighlight()
|
||||
super.init()
|
||||
}
|
||||
@@ -78,6 +78,22 @@ extension BottomMenuPresenter {
|
||||
case .layers:
|
||||
return 1
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -96,7 +112,7 @@ extension BottomMenuPresenter {
|
||||
switch menuCells[indexPath.row] {
|
||||
case .addPlace:
|
||||
let enabled = MWMNavigationDashboardManager.shared().state == .hidden && FrameworkHelper.canEditMapAtViewportCenter()
|
||||
cell.configure(imageName: "ic_add_place",
|
||||
cell.configure(imageName: "plus",
|
||||
title: L("placepage_add_place_button"),
|
||||
enabled: enabled)
|
||||
case .recordTrack:
|
||||
@@ -114,11 +130,14 @@ extension BottomMenuPresenter {
|
||||
case .donate:
|
||||
cell.configure(imageName: "ic_menu_donate",
|
||||
title: L("donate"))
|
||||
case .help:
|
||||
cell.configure(imageName: "help",
|
||||
title: L("help"))
|
||||
case .settings:
|
||||
cell.configure(imageName: "ic_menu_settings",
|
||||
cell.configure(imageName: "gearshape.fill",
|
||||
title: L("settings"))
|
||||
case .share:
|
||||
cell.configure(imageName: "ic_menu_share",
|
||||
cell.configure(imageName: "square.and.arrow.up",
|
||||
title: L("share_my_location"))
|
||||
}
|
||||
return cell
|
||||
@@ -151,6 +170,8 @@ extension BottomMenuPresenter {
|
||||
interactor.downloadMaps()
|
||||
case .donate:
|
||||
interactor.donate()
|
||||
case .help:
|
||||
interactor.openHelp()
|
||||
case .settings:
|
||||
interactor.openSettings()
|
||||
case .share:
|
||||
|
||||
@@ -32,6 +32,12 @@ class BottomMenuViewController: MWMViewController {
|
||||
tableView.delegate = presenter
|
||||
tableView.registerNib(cell: BottomMenuItemCell.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) {
|
||||
|
||||
@@ -17,7 +17,17 @@ class BottomMenuItemCell: UITableViewCell {
|
||||
private(set) var isEnabled: 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
|
||||
badgeBackground.isHidden = badgeCount == 0
|
||||
badgeCountLabel.text = "\(badgeCount)"
|
||||
|
||||
Reference in New Issue
Block a user