Skip to content

Commit

Permalink
tvOS 1.0.1 (8) source (#30)
Browse files Browse the repository at this point in the history
* tvOS 1.0.1 (8) source

* upvpn-assets for tvOS
  • Loading branch information
64bit committed Sep 20, 2024
1 parent 19fec3c commit f3df529
Show file tree
Hide file tree
Showing 71 changed files with 1,959 additions and 7 deletions.
4 changes: 4 additions & 0 deletions upvpn-apple/UpVPN/App/Views/Color+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ extension Color {
static var uSystemGroupedBackground: Color {
#if os(iOS)
return Color(uiColor: .systemGroupedBackground)
#elseif os(tvOS)
return Color(uiColor: .clear)
#elseif os(macOS)
return Color.clear
#endif
Expand All @@ -20,6 +22,8 @@ extension Color {
static var uSecondarySystemGroupedBackground: Color {
#if os(iOS)
return Color(uiColor: .secondarySystemGroupedBackground)
#elseif os(tvOS)
return Color(uiColor: .clear)
#elseif os(macOS)
return Color(nsColor: .controlBackgroundColor)
#endif
Expand Down
5 changes: 5 additions & 0 deletions upvpn-apple/UpVPN/App/Views/FlagImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ struct FlagImage: View {
var body: some View {
#if os(iOS)
Image(uiImage: Flag(countryCode: countryCode)!.image(style: .roundedRect))
#elseif os(tvOS)
Image(uiImage: Flag(countryCode: countryCode)!.image(style: .roundedRect))
.resizable()
.aspectRatio(contentMode: .fit)
.frame(minWidth: 50, maxWidth: 50)
#elseif os(macOS)
Image(nsImage: Flag(countryCode: countryCode)!.originalImage)
.clipShape(RoundedRectangle(cornerRadius: 3))
Expand Down
2 changes: 2 additions & 0 deletions upvpn-apple/UpVPN/App/Views/KeyValueView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ struct KeyValueView: View {
Text(value)
.lineLimit(1)
.opacity(0.5)
#if !os(tvOS)
.textSelection(.enabled)
#endif
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions upvpn-apple/UpVPN/App/Views/LocationsMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ struct LocationsMapView: View {
if let coordinate = getCoordinate(location) {
Annotation("", coordinate: coordinate) {
LocationView(location: location)
.id(locationViewModel.locationsLastUpdated)
#if os(tvOS)
.background(.ultraThinMaterial)
#else
.background(Color.uSecondarySystemGroupedBackground)
#endif
.clipShape(RoundedRectangle(cornerRadius: 10))
.environmentObject(locationViewModel)
}
Expand Down
4 changes: 4 additions & 0 deletions upvpn-apple/UpVPN/App/Views/Plan/PrepaidPlansView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ struct PrepaidPlansView: View {
var selectedProduct: Product? = nil
var setSelectedProduct: (Product) -> Void

#if os(tvOS)
private let columns: [GridItem] = Array(repeating: .init(.flexible(), spacing: 40), count: 4)
#else
private let columns = [
GridItem(.fixed(120)),
GridItem(.fixed(120))
]
#endif

var body: some View {
Group {
Expand Down
6 changes: 6 additions & 0 deletions upvpn-apple/UpVPN/App/Views/RuntimeConfigurationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ struct RuntimeConfigurationView: View {
.localizedString(for: lastHandshakeTime, relativeTo: Date()))
}
}
#if os(tvOS)
// so that list can scroll on tvOS
.focusable()
#endif
// otherwise list does not update
.onReceive(tunnelViewModel.tunnelObserver.$runtimeConfig) { _ in }
}
}
#if os(iOS)
Expand Down
13 changes: 12 additions & 1 deletion upvpn-apple/UpVPN/Common/FileManager+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ extension FileManager {
static var appGroupId: String? {
#if os(iOS)
let appGroupIdInfoDictionaryKey = "app.upvpn.apple.ios.app_group_id"
#elseif os(tvOS)
let appGroupIdInfoDictionaryKey = "app.upvpn.apple.tvos.app_group_id"
#elseif os(macOS)
let appGroupIdInfoDictionaryKey = "app.upvpn.apple.macos.app_group_id"
#else
Expand All @@ -28,10 +30,19 @@ extension FileManager {
os_log("Cannot obtain app group ID from bundle", log: OSLog.default, type: .error)
return nil
}
guard let sharedFolderURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupId) else {
guard let appGroupSharedFolderURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupId) else {
os_log(.error, "Cannot obtain shared folder URL")
return nil
}

var sharedFolderURL = appGroupSharedFolderURL

#if os(tvOS)
// cannot write file in the folder, hence write in directory thats created by default inside app group container
// https://developer.apple.com/documentation/foundation/filemanager/1412643-containerurl#2851195
sharedFolderURL = sharedFolderURL.appendingPathComponent("Library/Caches")
#endif

return sharedFolderURL
}

Expand Down
2 changes: 1 addition & 1 deletion upvpn-apple/UpVPN/Common/Keychain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Keychain {
/// More info: https://developer.apple.com/forums/thread/133677?answerId=422887022#422887022
/// Hence on macOS we use keychain access group instead of app group
static var keychainGroupId: String? {
#if os(iOS)
#if os(iOS) || os(tvOS)
return FileManager.appGroupId
#elseif os(macOS)
let keychainGroupIdInfoDictionaryKey = "app.upvpn.apple.macos.keychain_group_id"
Expand Down
4 changes: 2 additions & 2 deletions upvpn-apple/UpVPN/Config/Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION_NAME = 1.0.0
VERSION_ID = 5
VERSION_NAME = 1.0.1
VERSION_ID = 8
Loading

0 comments on commit f3df529

Please sign in to comment.