StikDebug/StikJIT/Utilities/TabConfiguration.swift
Stephen B 06b64192c4 Add device library and external device support (Semi WIP)
Introduces DeviceLibraryStore and DeviceConnectionContext to manage external device profiles and connections. Updates app logic to support switching between local loopback VPN and direct external device connections, including UI for device management and improved connection handling throughout the app.
2025-12-06 15:20:23 -05:00

48 lines
1.5 KiB
Swift

import Foundation
enum TabConfiguration {
static let storageKey = "enabledTabIdentifiers"
static let maxSelectableTabs = 4
private static let coreIDs: [String] = ["home", "console", "scripts", "profiles", "deviceinfo"]
static var allowedIDs: [String] {
var ids = coreIDs
if FeatureFlags.showBetaTabs {
ids.append("processes")
ids.append("devicelibrary")
if FeatureFlags.isLocationSpoofingEnabled {
ids.append("location")
}
}
return ids
}
static let defaultIDs: [String] = ["home", "console", "scripts", "profiles"]
static let defaultRawValue = serialize(defaultIDs)
static func sanitize(raw: String) -> [String] {
let ids = raw
.split(separator: ",")
.map { String($0).trimmingCharacters(in: .whitespacesAndNewlines) }
return sanitize(ids: ids)
}
static func sanitize(ids: [String]) -> [String] {
var result: [String] = []
for id in ids {
guard allowedIDs.contains(id) else { continue }
if !result.contains(id) {
result.append(id)
}
if result.count == maxSelectableTabs {
break
}
}
if result.isEmpty {
result = defaultIDs
}
return result
}
static func serialize(_ ids: [String]) -> String {
sanitize(ids: ids).joined(separator: ",")
}
}