Minor improvements

This commit is contained in:
Arkadiusz Fal 2021-11-10 23:05:59 +01:00
parent fba85eb77b
commit 72d735e962
11 changed files with 167 additions and 95 deletions

View File

@ -23,7 +23,6 @@ struct VideoDetails: View {
@EnvironmentObject<AccountsModel> private var accounts @EnvironmentObject<AccountsModel> private var accounts
@EnvironmentObject<PlayerModel> private var player @EnvironmentObject<PlayerModel> private var player
@EnvironmentObject<PlaylistsModel> private var playlists
@EnvironmentObject<SubscriptionsModel> private var subscriptions @EnvironmentObject<SubscriptionsModel> private var subscriptions
@Default(.showKeywords) private var showKeywords @Default(.showKeywords) private var showKeywords
@ -263,7 +262,7 @@ struct VideoDetails: View {
if let video = player.currentVideo { if let video = player.currentVideo {
HStack { HStack {
ShareButton( ShareButton(
contentItem: ContentItem(video: video), contentItem: contentItem,
presentingShareSheet: $presentingShareSheet, presentingShareSheet: $presentingShareSheet,
shareURL: $shareURL shareURL: $shareURL
) )

View File

@ -126,24 +126,26 @@ struct AddToPlaylistView: View {
.padding(.horizontal) .padding(.horizontal)
} }
private var selectPlaylistButton: some View { #if os(tvOS)
Button(selectedPlaylist?.title ?? "Select playlist") { private var selectPlaylistButton: some View {
guard selectedPlaylist != nil else { Button(selectedPlaylist?.title ?? "Select playlist") {
return guard selectedPlaylist != nil else {
} return // swiftlint:disable:this implicit_return
selectedPlaylistID = model.all.next(after: selectedPlaylist!)!.id
}
.contextMenu {
ForEach(model.all) { playlist in
Button(playlist.title) {
selectedPlaylistID = playlist.id
} }
}
Button("Cancel", role: .cancel) {} selectedPlaylistID = model.all.next(after: selectedPlaylist!)!.id
}
.contextMenu {
ForEach(model.all) { playlist in
Button(playlist.title) {
selectedPlaylistID = playlist.id
}
}
Button("Cancel", role: .cancel) {}
}
} }
} #endif
private func addToPlaylist() { private func addToPlaylist() {
guard let id = selectedPlaylist?.id else { guard let id = selectedPlaylist?.id else {

View File

@ -95,59 +95,61 @@ struct PlaylistFormView: View {
#endif #endif
} }
var header: some View { #if os(tvOS)
HStack(alignment: .center) { var header: some View {
Text(editing ? "Edit Playlist" : "Create Playlist") HStack(alignment: .center) {
.font(.title2.bold()) Text(editing ? "Edit Playlist" : "Create Playlist")
.font(.title2.bold())
Spacer()
#if !os(tvOS)
Button("Cancel") {
dismiss()
}
.keyboardShortcut(.cancelAction)
#endif
}
.padding(.horizontal)
}
var form: some View {
VStack(alignment: .trailing) {
VStack {
Text("Name")
.frame(maxWidth: .infinity, alignment: .leading)
TextField("Playlist Name", text: $name, onCommit: validate)
}
HStack {
Text("Visibility")
.frame(maxWidth: .infinity, alignment: .leading)
visibilityFormItem
}
.padding(.top, 10)
HStack {
Spacer() Spacer()
Button("Save", action: submitForm).disabled(!valid) #if !os(tvOS)
Button("Cancel") {
dismiss()
}
.keyboardShortcut(.cancelAction)
#endif
} }
.padding(.top, 40) .padding(.horizontal)
}
var form: some View {
VStack(alignment: .trailing) {
VStack {
Text("Name")
.frame(maxWidth: .infinity, alignment: .leading)
TextField("Playlist Name", text: $name, onCommit: validate)
}
HStack {
Text("Visibility")
.frame(maxWidth: .infinity, alignment: .leading)
visibilityFormItem
}
.padding(.top, 10)
if editing {
Divider()
HStack { HStack {
Text("Delete playlist")
.font(.title2.bold())
Spacer() Spacer()
deletePlaylistButton
Button("Save", action: submitForm).disabled(!valid)
}
.padding(.top, 40)
if editing {
Divider()
HStack {
Text("Delete playlist")
.font(.title2.bold())
Spacer()
deletePlaylistButton
}
} }
} }
.padding(.horizontal)
} }
.padding(.horizontal) #endif
}
func initializeForm() { func initializeForm() {
focused = true focused = true

View File

@ -17,8 +17,6 @@ struct AccountForm: View {
@Environment(\.dismiss) private var dismiss @Environment(\.dismiss) private var dismiss
@EnvironmentObject<InstancesModel> private var instances
var body: some View { var body: some View {
VStack { VStack {
Group { Group {

View File

@ -124,37 +124,39 @@ struct TrendingView: View {
} }
} }
private var toolbar: some View { #if os(tvOS)
HStack { private var toolbar: some View {
if accounts.app.supportsTrendingCategories { HStack {
if accounts.app.supportsTrendingCategories {
HStack {
Text("Category")
.foregroundColor(.secondary)
categoryButton
}
}
#if os(iOS)
Spacer()
#endif
HStack { HStack {
Text("Category") Text("Country")
.foregroundColor(.secondary) .foregroundColor(.secondary)
categoryButton countryButton
} }
#if os(tvOS)
if let favoriteItem = favoriteItem {
FavoriteButton(item: favoriteItem)
.id(favoriteItem.id)
.labelStyle(.iconOnly)
}
#endif
} }
#if os(iOS)
Spacer()
#endif
HStack {
Text("Country")
.foregroundColor(.secondary)
countryButton
}
#if os(tvOS)
if let favoriteItem = favoriteItem {
FavoriteButton(item: favoriteItem)
.id(favoriteItem.id)
.labelStyle(.iconOnly)
}
#endif
} }
} #endif
private var categoryButton: some View { private var categoryButton: some View {
#if os(tvOS) #if os(tvOS)

View File

@ -4,7 +4,6 @@ import SwiftUI
struct VideoCell: View { struct VideoCell: View {
var video: Video var video: Video
@State private var mediumQualityThumbnail = false
@Environment(\.inNavigationView) private var inNavigationView @Environment(\.inNavigationView) private var inNavigationView

View File

@ -8,8 +8,9 @@ struct ChannelPlaylistView: View {
@StateObject private var store = Store<ChannelPlaylist>() @StateObject private var store = Store<ChannelPlaylist>()
@Environment(\.dismiss) private var dismiss #if os(iOS)
@Environment(\.inNavigationView) private var inNavigationView @Environment(\.inNavigationView) private var inNavigationView
#endif
@EnvironmentObject<AccountsModel> private var accounts @EnvironmentObject<AccountsModel> private var accounts

View File

@ -2,7 +2,10 @@ import SwiftUI
struct OpenSettingsButton: View { struct OpenSettingsButton: View {
@Environment(\.dismiss) private var dismiss @Environment(\.dismiss) private var dismiss
@EnvironmentObject<NavigationModel> private var navigation
#if !os(macOS)
@EnvironmentObject<NavigationModel> private var navigation
#endif
var body: some View { var body: some View {
Button { Button {

View File

@ -1612,7 +1612,7 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "periphery scan \\\n --project \"Yattee.xcodeproj\" \\\n --schemes \"Yattee (iOS)\" \\\n --targets \"Yattee (iOS)\" \\\n --retain-objc-accessible \\\n --retain-public \\\n -- -destination \"platform=iOS\\ Simulator,name=iPhone\\ 8,OS=15.0\"\n"; shellScript = "if test -d \"/opt/homebrew/bin/\"; then\n PATH=\"/opt/homebrew/bin/:${PATH}\"\nfi\n\nperiphery scan \\\n --project \"Yattee.xcodeproj\" \\\n --schemes \"Yattee (iOS)\" \\\n --targets \"Yattee (iOS)\" \\\n --retain-objc-accessible \\\n --retain-public \\\n -- -destination \"platform=iOS\\ Simulator,name=iPhone\\ 8,OS=15.0\"\n";
}; };
37CC3F48270CE89B00608308 /* ShellScript */ = { 37CC3F48270CE89B00608308 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
@ -1680,7 +1680,7 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "periphery scan \\\n --project \"Yattee.xcodeproj\" \\\n --schemes \"Yattee (macOS)\" \\\n --targets \"Yattee (macOS)\" \\\n --retain-objc-accessible \\\n --retain-public\n"; shellScript = "if test -d \"/opt/homebrew/bin/\"; then\n PATH=\"/opt/homebrew/bin/:${PATH}\"\nfi\n\nperiphery scan \\\n --project \"Yattee.xcodeproj\" \\\n --schemes \"Yattee (macOS)\" \\\n --targets \"Yattee (macOS)\" \\\n --retain-objc-accessible \\\n --retain-public\n";
}; };
37FD43EF2704A7780073EE42 /* ShellScript */ = { 37FD43EF2704A7780073EE42 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
@ -1697,7 +1697,7 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "periphery scan \\\n --project \"Yattee.xcodeproj\" \\\n --schemes \"Yattee (Apple TV)\" \\\n --targets \"Yattee (Apple TV)\" \\\n --retain-objc-accessible \\\n --retain-public\n"; shellScript = "if test -d \"/opt/homebrew/bin/\"; then\n PATH=\"/opt/homebrew/bin/:${PATH}\"\nfi\n\nperiphery scan \\\n --project \"Yattee.xcodeproj\" \\\n --schemes \"Yattee (tvOS)\" \\\n --targets \"Yattee (tvOS)\" \\\n --retain-objc-accessible \\\n --retain-public\n";
}; };
/* End PBXShellScriptBuildPhase section */ /* End PBXShellScriptBuildPhase section */

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1320"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "37FD43EB2704A7710073EE42"
BuildableName = "Periphery (tvOS)"
BlueprintName = "Periphery (tvOS)"
ReferencedContainer = "container:Yattee.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</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">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "37FD43EB2704A7710073EE42"
BuildableName = "Periphery (tvOS)"
BlueprintName = "Periphery (tvOS)"
ReferencedContainer = "container:Yattee.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -15,7 +15,6 @@ struct InstancesSettings: View {
@State private var frontendURL = "" @State private var frontendURL = ""
@EnvironmentObject<AccountsModel> private var accounts @EnvironmentObject<AccountsModel> private var accounts
@EnvironmentObject<InstancesModel> private var model
@Default(.instances) private var instances @Default(.instances) private var instances