Skip to content

Commit

Permalink
Add Apple TV platform
Browse files Browse the repository at this point in the history
  • Loading branch information
grgar committed Oct 14, 2023
1 parent bd1c246 commit 5561310
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 11 deletions.
11 changes: 11 additions & 0 deletions ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,19 @@ struct ContentView: View {
@State private var navigationCategory: NavigationCategory?

var body: some View {
#if os(tvOS)
NavigationStack {
PasswordRules()
.background {
HomeBackground()
}
}
#else
NavigationSplitView(columnVisibility: $visibility) {
HomeSidebar(selection: $navigationCategory)
#if !os(tvOS)
.listStyle(.sidebar)
#endif
} content: {
if let navigationCategory {
navigationCategory
Expand All @@ -41,6 +51,7 @@ struct ContentView: View {
#if os(macOS)
.frame(minWidth: 320 + 320 + (navigationCategory == .rules ? 320 : 0))
#endif
#endif
}
}

Expand Down
12 changes: 6 additions & 6 deletions Home/HomeBackground.swift
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import SwiftUI

struct HomeBackground: View {
let scale: Int = {
static let scale: Int = {
#if os(macOS)
return 48
#else
return 64
#endif
}()

let padding: Int = {
#if os(macOS)
return 12
static let padding: CGSize = {
#if os(tvOS)
return .init(width: 96, height: 96)
#else
return 12
return .init(width: 12, height: 24)
#endif
}()

var body: some View {
GeometryReader { geometry in
Image(systemName: "key.fill", size: .init(width: scale, height: scale), padding: .init(width: padding, height: padding * 2))
Image(systemName: "key.fill", size: .init(width: Self.scale, height: Self.scale), padding: Self.padding)
.resizable(resizingMode: .tile)
.modifier(InvertIfDark())
.opacity(0.05)
Expand Down
32 changes: 31 additions & 1 deletion Home/HomeSidebar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ struct HomeSidebar: View {
}
#else
Text("Password Rules")
#if os(tvOS)
.padding(.horizontal, 96)
#endif
#endif
} icon: {
Image(systemName: "lock.rectangle")
#if os(tvOS)
.font(.largeTitle)
.padding(.leading, 64)
#endif
}
#if os(iOS)
.padding(.vertical)
Expand All @@ -36,9 +43,16 @@ struct HomeSidebar: View {
}
#else
Text("Shared Credentials")
#if os(tvOS)
.padding(.horizontal, 96)
#endif
#endif
} icon: {
Image(systemName: "rectangle.on.rectangle.angled")
#if os(tvOS)
.font(.largeTitle)
.padding(.leading, 64)
#endif
}
#if os(iOS)
.padding(.vertical)
Expand All @@ -56,9 +70,16 @@ struct HomeSidebar: View {
}
#else
Text("Change Password URLs")
#if os(tvOS)
.padding(.horizontal, 96)
#endif
#endif
} icon: {
Image(systemName: "rectangle.and.pencil.and.ellipsis")
#if os(tvOS)
.font(.largeTitle)
.padding(.leading, 64)
#endif
}
#if os(iOS)
.padding(.vertical)
Expand All @@ -76,20 +97,29 @@ struct HomeSidebar: View {
}
#else
Text("Appended 2FA")
#if os(tvOS)
.padding(.horizontal, 96)
#endif
#endif
} icon: {
Image(systemName: "123.rectangle")
#if os(tvOS)
.font(.largeTitle)
.padding(.leading, 64)
#endif
}
#if os(iOS)
.padding(.vertical)
#endif
}
}
#if !os(tvOS)
.scrollContentBackground(.hidden)
.listStyle(.sidebar)
#endif
.background {
HomeBackground()
}
.listStyle(.sidebar)
.navigationTitle(Text("Passwords Inspector"))
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
Expand Down
10 changes: 6 additions & 4 deletions Passwords Inspector.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,11 @@
PRODUCT_BUNDLE_IDENTIFIER = com.georgegarside.passwordsinspector;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx";
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,3";
};
name = Debug;
};
Expand Down Expand Up @@ -384,10 +385,11 @@
PRODUCT_BUNDLE_IDENTIFIER = com.georgegarside.passwordsinspector;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx";
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,3";
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1717C4992ABA44EC00AD991A"
BuildableName = "Passwords Inspector.app"
BlueprintName = "Passwords Inspector"
ReferencedContainer = "container:Passwords Inspector.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1717C4992ABA44EC00AD991A"
BuildableName = "Passwords Inspector.app"
BlueprintName = "Passwords Inspector"
ReferencedContainer = "container:Passwords Inspector.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1717C4992ABA44EC00AD991A"
BuildableName = "Passwords Inspector.app"
BlueprintName = "Passwords Inspector"
ReferencedContainer = "container:Passwords Inspector.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
5 changes: 5 additions & 0 deletions Rule/PasswordRules.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ struct PasswordRules: View {
})

Group {
#if os(tvOS)
RulesList(rules: responses, showFavicon: showFavicon)
#else
if isCompact {
RulesList(rules: responses, showFavicon: showFavicon)
} else {
RulesTable(rules: responses, showFavicon: showFavicon, faviconHeight: faviconHeight, sortOrder: $sortOrder)
}
#endif
}
.toolbar {
ToolbarItemGroup(placement: .automatic) {
Expand Down Expand Up @@ -153,6 +157,7 @@ struct RulesList: View {
}
}

@available(tvOS, unavailable)
struct RulesTable: View {
let rules: [Rule]
let showFavicon: Bool
Expand Down

0 comments on commit 5561310

Please sign in to comment.