Move feature mapping to a single file (#726)

Do not scatter sensitive data.
This commit is contained in:
Davide 2024-10-11 04:17:17 +02:00 committed by GitHub
parent 8f6192c2b6
commit 1aa393ee02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 47 additions and 47 deletions

View File

@ -60,7 +60,3 @@ extension AppFeature: Identifiable {
rawValue
}
}
protocol AppFeatureProviding {
var features: [AppFeature] { get }
}

View File

@ -1,8 +1,8 @@
//
// AppUserLevel+Features.swift
// AppFeatureProviding.swift
// Passepartout
//
// Created by Davide De Rosa on 9/10/24.
// Created by Davide De Rosa on 10/11/24.
// Copyright (c) 2024 Davide De Rosa. All rights reserved.
//
// https://github.com/passepartoutvpn
@ -25,6 +25,10 @@
import Foundation
protocol AppFeatureProviding {
var features: [AppFeature] { get }
}
extension AppUserLevel: AppFeatureProviding {
var features: [AppFeature] {
switch self {
@ -41,3 +45,44 @@ extension AppUserLevel: AppFeatureProviding {
}
}
}
extension AppProduct: AppFeatureProviding {
var features: [AppFeature] {
switch self {
case .Features.allProviders:
return [.providers]
case .Features.appleTV:
return [.appleTV]
case .Features.networkSettings:
return [.dns, .httpProxy, .routing]
case .Features.siriShortcuts:
return [.siri]
case .Features.trustedNetworks:
return [.onDemand]
case .Full.allPlatforms:
return AppFeature.fullVersionFeaturesV2
case .Full.iOS:
#if os(iOS)
return AppFeature.fullVersionFeaturesV2
#else
return []
#endif
case .Full.macOS:
#if os(macOS)
return AppFeature.fullVersionFeaturesV2
#else
return []
#endif
default:
return []
}
}
}

View File

@ -70,44 +70,3 @@ extension AppProduct {
rawValue.hasPrefix(Self.featurePrefix)
}
}
extension AppProduct: AppFeatureProviding {
var features: [AppFeature] {
switch self {
case .Features.allProviders:
return [.providers]
case .Features.appleTV:
return [.appleTV]
case .Features.networkSettings:
return [.dns, .httpProxy, .routing]
case .Features.siriShortcuts:
return [.siri]
case .Features.trustedNetworks:
return [.onDemand]
case .Full.allPlatforms:
return AppFeature.fullVersionFeaturesV2
case .Full.iOS:
#if os(iOS)
return AppFeature.fullVersionFeaturesV2
#else
return []
#endif
case .Full.macOS:
#if os(macOS)
return AppFeature.fullVersionFeaturesV2
#else
return []
#endif
default:
return []
}
}
}