mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-09 13:54:37 +00:00
[ios] Make left button configurable
Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
This commit is contained in:
52
iphone/Maps/Model/Settings Types/LeftButtonType.swift
Normal file
52
iphone/Maps/Model/Settings Types/LeftButtonType.swift
Normal file
@@ -0,0 +1,52 @@
|
||||
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"
|
||||
|
||||
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// The id
|
||||
var id: Self { self }
|
||||
|
||||
|
||||
/// The description text
|
||||
var description: String {
|
||||
switch self {
|
||||
case .hidden:
|
||||
return L("disabled")
|
||||
case .help:
|
||||
return L("help")
|
||||
case .addPlace:
|
||||
return L("placepage_add_place_button")
|
||||
case .settings:
|
||||
return L("settings")
|
||||
case .recordTrack:
|
||||
return L("start_track_recording")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// The image
|
||||
var image: UIImage {
|
||||
let configuration = UIImage.SymbolConfiguration(pointSize: 22, 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)
|
||||
default:
|
||||
return UIImage()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,10 @@ import Combine
|
||||
static private let userDefaultsKeyHasShownSyncBetaAlert = "kUDDidShowICloudSynchronizationEnablingAlert"
|
||||
|
||||
|
||||
/// Key for storing the type of action used for the bottom left main interface button in the user defaults
|
||||
static private let userDefaultsKeyLeftButtonType = "LeftButtonType"
|
||||
|
||||
|
||||
/// The current distance unit
|
||||
static var distanceUnit: DistanceUnit {
|
||||
get {
|
||||
@@ -38,6 +42,21 @@ import Combine
|
||||
}
|
||||
|
||||
|
||||
/// The type of action used for the bottom left main interface button
|
||||
static var leftButtonType: LeftButtonType {
|
||||
get {
|
||||
if let leftButtonTypeRawValue = UserDefaults.standard.string(forKey: userDefaultsKeyLeftButtonType), let leftButtonType = LeftButtonType(rawValue: leftButtonTypeRawValue) {
|
||||
return leftButtonType
|
||||
}
|
||||
|
||||
return .help
|
||||
}
|
||||
set {
|
||||
UserDefaults.standard.set(newValue.rawValue, forKey: userDefaultsKeyLeftButtonType)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// If 3D buildings should be displayed
|
||||
@objc static var has3dBuildings: Bool {
|
||||
get {
|
||||
@@ -287,7 +306,7 @@ import Combine
|
||||
return RoutingOptions().avoidToll
|
||||
}
|
||||
set {
|
||||
var routingOptions = RoutingOptions()
|
||||
let routingOptions = RoutingOptions()
|
||||
routingOptions.avoidToll = newValue
|
||||
routingOptions.save()
|
||||
}
|
||||
@@ -300,7 +319,7 @@ import Combine
|
||||
return RoutingOptions().avoidDirty
|
||||
}
|
||||
set {
|
||||
var routingOptions = RoutingOptions()
|
||||
let routingOptions = RoutingOptions()
|
||||
routingOptions.avoidDirty = newValue
|
||||
routingOptions.save()
|
||||
}
|
||||
@@ -313,7 +332,7 @@ import Combine
|
||||
return RoutingOptions().avoidFerry
|
||||
}
|
||||
set {
|
||||
var routingOptions = RoutingOptions()
|
||||
let routingOptions = RoutingOptions()
|
||||
routingOptions.avoidFerry = newValue
|
||||
routingOptions.save()
|
||||
}
|
||||
@@ -326,7 +345,7 @@ import Combine
|
||||
return RoutingOptions().avoidMotorway
|
||||
}
|
||||
set {
|
||||
var routingOptions = RoutingOptions()
|
||||
let routingOptions = RoutingOptions()
|
||||
routingOptions.avoidMotorway = newValue
|
||||
routingOptions.save()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user