mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-07 13:03:54 +00:00
[ios] Added setting for map language
Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
This commit is contained in:
committed by
Konstantin Pastbin
parent
1fe8f1f0e6
commit
1cf4ff21ec
31
iphone/Maps/Model/Settings Types/Language.swift
Normal file
31
iphone/Maps/Model/Settings Types/Language.swift
Normal file
@@ -0,0 +1,31 @@
|
||||
extension Settings {
|
||||
/// A language
|
||||
protocol Language: Codable, Identifiable, Equatable, Comparable {
|
||||
// MARK: Properties
|
||||
|
||||
/// The id
|
||||
var id: String { get }
|
||||
|
||||
|
||||
/// The localized name
|
||||
var localizedName: String { get }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MARK: - Comparable
|
||||
extension Settings.Language {
|
||||
static func == (lhs: Self, rhs: Self) -> Bool {
|
||||
return lhs.id == rhs.id
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MARK: - Comparable
|
||||
extension Settings.Language {
|
||||
static func < (lhs: Self, rhs: Self) -> Bool {
|
||||
return lhs.localizedName.localizedCaseInsensitiveCompare(rhs.localizedName) == .orderedAscending
|
||||
}
|
||||
}
|
||||
13
iphone/Maps/Model/Settings Types/MapLanguage.swift
Normal file
13
iphone/Maps/Model/Settings Types/MapLanguage.swift
Normal file
@@ -0,0 +1,13 @@
|
||||
extension Settings {
|
||||
/// A language used for the map
|
||||
struct MapLanguage: Language {
|
||||
// MARK: Properties
|
||||
|
||||
/// The id
|
||||
let id: String
|
||||
|
||||
|
||||
/// The localized name
|
||||
let localizedName: String
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,13 @@
|
||||
extension Settings {
|
||||
/// A language used for voice guidance during routing
|
||||
struct VoiceRoutingLanguage: Codable, Identifiable {
|
||||
struct VoiceRoutingLanguage: Language {
|
||||
// MARK: Properties
|
||||
|
||||
/// The id
|
||||
var id: String
|
||||
let id: String
|
||||
|
||||
|
||||
/// The localized name
|
||||
var localizedName: String
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MARK: - Comparable
|
||||
extension Settings.VoiceRoutingLanguage: Equatable {
|
||||
static func == (lhs: Settings.VoiceRoutingLanguage, rhs: Settings.VoiceRoutingLanguage) -> Bool {
|
||||
return lhs.id == rhs.id
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MARK: - Comparable
|
||||
extension Settings.VoiceRoutingLanguage: Comparable {
|
||||
static func < (lhs: Settings.VoiceRoutingLanguage, rhs: Settings.VoiceRoutingLanguage) -> Bool {
|
||||
return lhs.localizedName.localizedCaseInsensitiveCompare(rhs.localizedName) == .orderedAscending
|
||||
let localizedName: String
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,6 +140,28 @@ import Combine
|
||||
}
|
||||
|
||||
|
||||
/// The available languages for the map
|
||||
static var availableLanguagesForMap: [MapLanguage] {
|
||||
var languages = SettingsBridge.availableMapLanguages().map { language in
|
||||
return MapLanguage(id: language.key, localizedName: language.value)
|
||||
}.sorted()
|
||||
languages.insert(MapLanguage(id: "default", localizedName: String(localized: "pref_maplanguage_local")), at: 0)
|
||||
languages.insert(MapLanguage(id: "auto", localizedName: String(localized: "auto")), at: 0)
|
||||
return languages
|
||||
}
|
||||
|
||||
|
||||
/// The current language for the map
|
||||
static var languageForMap: MapLanguage.ID {
|
||||
get {
|
||||
return SettingsBridge.mapLanguageCode()
|
||||
}
|
||||
set {
|
||||
SettingsBridge.setMapLanguageCode(newValue)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// If the compass should be calibrated
|
||||
@objc static var shouldCalibrateCompass: Bool {
|
||||
get {
|
||||
|
||||
Reference in New Issue
Block a user