Fix new offenses

This commit is contained in:
Arkadiusz Fal 2021-11-08 17:29:35 +01:00
parent 2701c1ccb5
commit db9f7e5f5d
29 changed files with 305 additions and 305 deletions

View File

@ -55,14 +55,14 @@ struct FavoriteItemView: View {
resource?.loadIfNeeded() resource?.loadIfNeeded()
} }
#if !os(tvOS) #if !os(tvOS)
.onDrag { .onDrag {
dragging = item dragging = item
return NSItemProvider(object: item.id as NSString) return NSItemProvider(object: item.id as NSString)
} }
.onDrop( .onDrop(
of: [UTType.text], of: [UTType.text],
delegate: DropFavorite(item: item, favorites: $favorites, current: $dragging) delegate: DropFavorite(item: item, favorites: $favorites, current: $dragging)
) )
#endif #endif
} }
} }

View File

@ -51,8 +51,8 @@ struct FavoritesView: View {
.navigationTitle("Favorites") .navigationTitle("Favorites")
#endif #endif
#if os(macOS) #if os(macOS)
.background() .background()
.frame(minWidth: 360) .frame(minWidth: 360)
#endif #endif
} }
} }

View File

@ -53,46 +53,46 @@ struct ContentView: View {
.environmentObject(navigation) .environmentObject(navigation)
} }
#if os(iOS) #if os(iOS)
.fullScreenCover(isPresented: $player.presentingPlayer) { .fullScreenCover(isPresented: $player.presentingPlayer) {
VideoPlayerView() VideoPlayerView()
.environmentObject(accounts) .environmentObject(accounts)
.environmentObject(instances) .environmentObject(instances)
.environmentObject(navigation) .environmentObject(navigation)
.environmentObject(player) .environmentObject(player)
.environmentObject(playlists) .environmentObject(playlists)
.environmentObject(subscriptions) .environmentObject(subscriptions)
.environmentObject(thumbnailsModel) .environmentObject(thumbnailsModel)
} }
#elseif os(macOS) #elseif os(macOS)
.sheet(isPresented: $player.presentingPlayer) { .sheet(isPresented: $player.presentingPlayer) {
VideoPlayerView() VideoPlayerView()
.frame(minWidth: 900, minHeight: 800) .frame(minWidth: 900, minHeight: 800)
.environmentObject(accounts) .environmentObject(accounts)
.environmentObject(instances) .environmentObject(instances)
.environmentObject(navigation) .environmentObject(navigation)
.environmentObject(player) .environmentObject(player)
.environmentObject(playlists) .environmentObject(playlists)
.environmentObject(subscriptions) .environmentObject(subscriptions)
.environmentObject(thumbnailsModel) .environmentObject(thumbnailsModel)
} }
#endif #endif
#if !os(tvOS) #if !os(tvOS)
.handlesExternalEvents(preferring: Set(["*"]), allowing: Set(["*"])) .handlesExternalEvents(preferring: Set(["*"]), allowing: Set(["*"]))
.onOpenURL(perform: handleOpenedURL) .onOpenURL(perform: handleOpenedURL)
.sheet(isPresented: $navigation.presentingAddToPlaylist) { .sheet(isPresented: $navigation.presentingAddToPlaylist) {
AddToPlaylistView(video: navigation.videoToAddToPlaylist) AddToPlaylistView(video: navigation.videoToAddToPlaylist)
.environmentObject(playlists) .environmentObject(playlists)
} }
.sheet(isPresented: $navigation.presentingPlaylistForm) { .sheet(isPresented: $navigation.presentingPlaylistForm) {
PlaylistFormView(playlist: $navigation.editedPlaylist) PlaylistFormView(playlist: $navigation.editedPlaylist)
.environmentObject(accounts) .environmentObject(accounts)
.environmentObject(playlists) .environmentObject(playlists)
} }
.sheet(isPresented: $navigation.presentingSettings, onDismiss: openWelcomeScreenIfAccountEmpty) { .sheet(isPresented: $navigation.presentingSettings, onDismiss: openWelcomeScreenIfAccountEmpty) {
SettingsView() SettingsView()
.environmentObject(accounts) .environmentObject(accounts)
.environmentObject(instances) .environmentObject(instances)
} }
#endif #endif
} }

View File

@ -22,17 +22,17 @@ struct PlayerQueueView: View {
} }
} }
#if !os(iOS) #if !os(iOS)
.padding(.vertical, 5) .padding(.vertical, 5)
.listRowInsets(EdgeInsets()) .listRowInsets(EdgeInsets())
#endif #endif
} }
#if os(macOS) #if os(macOS)
.listStyle(.inset) .listStyle(.inset)
#elseif os(iOS) #elseif os(iOS)
.listStyle(.grouped) .listStyle(.grouped)
#else #else
.listStyle(.plain) .listStyle(.plain)
#endif #endif
} }

View File

@ -14,11 +14,11 @@ struct RelatedView: View {
} }
} }
#if os(macOS) #if os(macOS)
.listStyle(.inset) .listStyle(.inset)
#elseif os(iOS) #elseif os(iOS)
.listStyle(.grouped) .listStyle(.grouped)
#else #else
.listStyle(.plain) .listStyle(.plain)
#endif #endif
} }
} }

View File

@ -50,7 +50,7 @@ struct VideoDetails: View {
toggleFullScreenDetailsButton toggleFullScreenDetailsButton
} }
#if os(macOS) #if os(macOS)
.padding(.top, 10) .padding(.top, 10)
#endif #endif
if !video.isNil { if !video.isNil {
@ -188,7 +188,7 @@ struct VideoDetails: View {
confirmationShown = true confirmationShown = true
} }
#if os(iOS) #if os(iOS)
.tint(.gray) .tint(.gray)
#endif #endif
.confirmationDialog("Are you you want to unsubscribe from \(video!.channel.name)?", isPresented: $confirmationShown) { .confirmationDialog("Are you you want to unsubscribe from \(video!.channel.name)?", isPresented: $confirmationShown) {
Button("Unsubscribe") { Button("Unsubscribe") {
@ -309,9 +309,9 @@ struct VideoDetails: View {
} }
} }
#if os(iOS) #if os(iOS)
.sheet(isPresented: $presentingShareSheet) { .sheet(isPresented: $presentingShareSheet) {
ShareSheet(activityItems: [shareURL]) ShareSheet(activityItems: [shareURL])
} }
#endif #endif
} }

View File

@ -6,7 +6,7 @@ struct VideoDetailsPaddingModifier: ViewModifier {
#if os(macOS) #if os(macOS)
30 30
#else #else
35 40
#endif #endif
} }

View File

@ -46,7 +46,7 @@ struct VideoPlayerSizeModifier: ViewModifier {
#if os(iOS) #if os(iOS)
verticalSizeClass == .regular ? .fit : .fill verticalSizeClass == .regular ? .fit : .fill
#else #else
.fit .fit
#endif #endif
} }

View File

@ -4,7 +4,7 @@ import Siesta
import SwiftUI import SwiftUI
struct VideoPlayerView: View { struct VideoPlayerView: View {
static let defaultAspectRatio: Double = 1.77777778 static let defaultAspectRatio = 16 / 9.0
static var defaultMinimumHeightLeft: Double { static var defaultMinimumHeightLeft: Double {
#if os(macOS) #if os(macOS)
300 300
@ -76,14 +76,14 @@ struct VideoPlayerView: View {
} }
} }
#if os(iOS) #if os(iOS)
.onSwipeGesture( .onSwipeGesture(
up: { up: {
withAnimation { withAnimation {
fullScreen = true fullScreen = true
} }
}, },
down: { dismiss() } down: { dismiss() }
) )
#endif #endif
.background(.black) .background(.black)
@ -104,7 +104,7 @@ struct VideoPlayerView: View {
#endif #endif
} }
#if os(macOS) #if os(macOS)
.frame(minWidth: 650) .frame(minWidth: 650)
#endif #endif
#if os(iOS) #if os(iOS)
if sidebarQueue { if sidebarQueue {

View File

@ -33,13 +33,13 @@ struct AddToPlaylistView: View {
} }
} }
#if os(macOS) #if os(macOS)
.frame(width: 500, height: 270) .frame(width: 500, height: 270)
.padding(.vertical) .padding(.vertical)
#elseif os(tvOS) #elseif os(tvOS)
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity) .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.background(.thickMaterial) .background(.thickMaterial)
#else #else
.padding(.vertical) .padding(.vertical)
#endif #endif
} }
@ -47,7 +47,7 @@ struct AddToPlaylistView: View {
#if os(tvOS) #if os(tvOS)
600 600
#else #else
.infinity .infinity
#endif #endif
} }

View File

@ -46,7 +46,7 @@ struct PlaylistFormView: View {
.pickerStyle(.segmented) .pickerStyle(.segmented)
} }
#if os(macOS) #if os(macOS)
.padding(.horizontal) .padding(.horizontal)
#endif #endif
HStack { HStack {
@ -225,7 +225,7 @@ struct PlaylistFormView: View {
) )
} }
#if os(macOS) #if os(macOS)
.foregroundColor(.red) .foregroundColor(.red)
#endif #endif
} }

View File

@ -49,73 +49,73 @@ struct PlaylistsView: View {
} }
} }
#if os(tvOS) #if os(tvOS)
.fullScreenCover(isPresented: $showingNewPlaylist, onDismiss: selectCreatedPlaylist) { .fullScreenCover(isPresented: $showingNewPlaylist, onDismiss: selectCreatedPlaylist) {
PlaylistFormView(playlist: $createdPlaylist) PlaylistFormView(playlist: $createdPlaylist)
.environmentObject(accounts) .environmentObject(accounts)
} }
.fullScreenCover(isPresented: $showingEditPlaylist, onDismiss: selectEditedPlaylist) { .fullScreenCover(isPresented: $showingEditPlaylist, onDismiss: selectEditedPlaylist) {
PlaylistFormView(playlist: $editedPlaylist) PlaylistFormView(playlist: $editedPlaylist)
.environmentObject(accounts) .environmentObject(accounts)
} }
#else #else
.sheet(isPresented: $showingNewPlaylist, onDismiss: selectCreatedPlaylist) { .sheet(isPresented: $showingNewPlaylist, onDismiss: selectCreatedPlaylist) {
PlaylistFormView(playlist: $createdPlaylist) PlaylistFormView(playlist: $createdPlaylist)
.environmentObject(accounts) .environmentObject(accounts)
} }
.sheet(isPresented: $showingEditPlaylist, onDismiss: selectEditedPlaylist) { .sheet(isPresented: $showingEditPlaylist, onDismiss: selectEditedPlaylist) {
PlaylistFormView(playlist: $editedPlaylist) PlaylistFormView(playlist: $editedPlaylist)
.environmentObject(accounts) .environmentObject(accounts)
}
#endif
.toolbar {
ToolbarItemGroup {
#if !os(iOS)
if !model.isEmpty {
selectPlaylistButton
.prefersDefaultFocus(in: focusNamespace)
}
if currentPlaylist != nil {
editPlaylistButton
}
#endif
FavoriteButton(item: FavoriteItem(section: .playlist(selectedPlaylistID)))
newPlaylistButton
}
#if os(iOS)
ToolbarItemGroup(placement: .bottomBar) {
Group {
if model.isEmpty {
Text("No Playlists")
.foregroundColor(.secondary)
} else {
Text("Current Playlist")
.foregroundColor(.secondary)
selectPlaylistButton
}
Spacer()
if currentPlaylist != nil {
editPlaylistButton
}
}
.transaction { t in t.animation = .none }
} }
#endif
}
#if os(tvOS)
.focusScope(focusNamespace)
#endif #endif
.onAppear { .toolbar {
model.load() ToolbarItemGroup {
} #if !os(iOS)
.onChange(of: accounts.current) { _ in if !model.isEmpty {
model.load(force: true) selectPlaylistButton
} .prefersDefaultFocus(in: focusNamespace)
}
if currentPlaylist != nil {
editPlaylistButton
}
#endif
FavoriteButton(item: FavoriteItem(section: .playlist(selectedPlaylistID)))
newPlaylistButton
}
#if os(iOS)
ToolbarItemGroup(placement: .bottomBar) {
Group {
if model.isEmpty {
Text("No Playlists")
.foregroundColor(.secondary)
} else {
Text("Current Playlist")
.foregroundColor(.secondary)
selectPlaylistButton
}
Spacer()
if currentPlaylist != nil {
editPlaylistButton
}
}
.transaction { t in t.animation = .none }
}
#endif
}
#if os(tvOS)
.focusScope(focusNamespace)
#endif
.onAppear {
model.load()
}
.onChange(of: accounts.current) { _ in
model.load(force: true)
}
} }
#if os(tvOS) #if os(tvOS)

View File

@ -29,12 +29,12 @@ struct AccountForm: View {
.frame(maxWidth: 1000) .frame(maxWidth: 1000)
} }
#if os(iOS) #if os(iOS)
.padding(.vertical) .padding(.vertical)
#elseif os(tvOS) #elseif os(tvOS)
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity) .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.background(.thickMaterial) .background(.thickMaterial)
#else #else
.frame(width: 400, height: 145) .frame(width: 400, height: 145)
#endif #endif
} }
@ -49,7 +49,7 @@ struct AccountForm: View {
dismiss() dismiss()
} }
#if !os(tvOS) #if !os(tvOS)
.keyboardShortcut(.cancelAction) .keyboardShortcut(.cancelAction)
#endif #endif
} }
.padding(.horizontal) .padding(.horizontal)
@ -61,7 +61,7 @@ struct AccountForm: View {
Form { Form {
formFields formFields
#if os(macOS) #if os(macOS)
.padding(.horizontal) .padding(.horizontal)
#endif #endif
} }
#else #else
@ -97,7 +97,7 @@ struct AccountForm: View {
#if os(tvOS) #if os(tvOS)
.padding(.top, 30) .padding(.top, 30)
#endif #endif
.padding(.horizontal) .padding(.horizontal)
} }
private func initializeForm() { private func initializeForm() {

View File

@ -46,7 +46,7 @@ struct AccountsSettings: View {
} }
} }
#if os(tvOS) #if os(tvOS)
.frame(maxWidth: 1000) .frame(maxWidth: 1000)
#endif #endif
.navigationTitle(instance.description) .navigationTitle(instance.description)
@ -78,7 +78,7 @@ struct AccountsSettings: View {
AccountForm(instance: instance) AccountForm(instance: instance)
} }
#if !os(tvOS) #if !os(tvOS)
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
#endif #endif
} }

View File

@ -52,7 +52,7 @@ struct InstanceForm: View {
dismiss() dismiss()
} }
#if !os(tvOS) #if !os(tvOS)
.keyboardShortcut(.cancelAction) .keyboardShortcut(.cancelAction)
#endif #endif
} }
.padding(.horizontal) .padding(.horizontal)
@ -63,7 +63,7 @@ struct InstanceForm: View {
Form { Form {
formFields formFields
#if os(macOS) #if os(macOS)
.padding(.horizontal) .padding(.horizontal)
#endif #endif
} }
#else #else
@ -105,7 +105,7 @@ struct InstanceForm: View {
#endif #endif
} }
#if os(tvOS) #if os(tvOS)
.padding(.top, 30) .padding(.top, 30)
#endif #endif
.padding(.horizontal) .padding(.horizontal)
} }

View File

@ -22,21 +22,21 @@ struct InstancesSettings: View {
} }
} }
#if os(iOS) #if os(iOS)
.swipeActions(edge: .trailing, allowsFullSwipe: false) { .swipeActions(edge: .trailing, allowsFullSwipe: false) {
removeInstanceButton(instance) removeInstanceButton(instance)
} }
.buttonStyle(.plain) .buttonStyle(.plain)
#else #else
.contextMenu { .contextMenu {
removeInstanceButton(instance) removeInstanceButton(instance)
} }
#endif #endif
} }
addInstanceButton addInstanceButton
} }
#if os(iOS) #if os(iOS)
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
#endif #endif
} }
.sheet(isPresented: $presentingInstanceForm) { .sheet(isPresented: $presentingInstanceForm) {

View File

@ -87,7 +87,7 @@ struct ServicesSettings: View {
.contentShape(Rectangle()) .contentShape(Rectangle())
} }
#if !os(tvOS) #if !os(tvOS)
.buttonStyle(.plain) .buttonStyle(.plain)
#endif #endif
} }
} }

View File

@ -84,7 +84,7 @@ struct SettingsView: View {
#endif #endif
} }
#if os(tvOS) #if os(tvOS)
.background(.black) .background(.black)
#endif #endif
#endif #endif
} }

View File

@ -48,7 +48,7 @@ struct TrendingCountry: View {
.searchable(text: $query, placement: searchPlacement, prompt: Text(TrendingCountry.prompt)) .searchable(text: $query, placement: searchPlacement, prompt: Text(TrendingCountry.prompt))
#endif #endif
#if os(tvOS) #if os(tvOS)
.background(.thinMaterial) .background(.thinMaterial)
#endif #endif
} }
@ -72,8 +72,8 @@ struct TrendingCountry: View {
} }
#if os(macOS) #if os(macOS)
.listStyle(.inset(alternatesRowBackgrounds: true)) .listStyle(.inset(alternatesRowBackgrounds: true))
.padding(.bottom, 5) .padding(.bottom, 5)
#endif #endif
} }

View File

@ -49,79 +49,79 @@ struct TrendingView: View {
} }
} }
#if os(tvOS) #if os(tvOS)
.fullScreenCover(isPresented: $presentingCountrySelection) { .fullScreenCover(isPresented: $presentingCountrySelection) {
TrendingCountry(selectedCountry: $country) TrendingCountry(selectedCountry: $country)
} }
#else #else
.sheet(isPresented: $presentingCountrySelection) { .sheet(isPresented: $presentingCountrySelection) {
TrendingCountry(selectedCountry: $country) TrendingCountry(selectedCountry: $country)
#if os(macOS) #if os(macOS)
.frame(minWidth: 400, minHeight: 400) .frame(minWidth: 400, minHeight: 400)
#endif #endif
}
.navigationTitle("Trending")
#endif
.toolbar {
#if os(macOS)
ToolbarItemGroup {
if let favoriteItem = favoriteItem {
FavoriteButton(item: favoriteItem)
.id(favoriteItem.id)
}
if accounts.app.supportsTrendingCategories {
categoryButton
}
countryButton
} }
#elseif os(iOS) .navigationTitle("Trending")
ToolbarItemGroup(placement: .bottomBar) { #endif
Group { .toolbar {
HStack { #if os(macOS)
if accounts.app.supportsTrendingCategories { ToolbarItemGroup {
Text("Category") if let favoriteItem = favoriteItem {
.foregroundColor(.secondary) FavoriteButton(item: favoriteItem)
.id(favoriteItem.id)
categoryButton
// only way to disable Menu animation is to
// force redraw of the view when it changes
.id(UUID())
} }
}
Spacer()
if let favoriteItem = favoriteItem {
FavoriteButton(item: favoriteItem)
.id(favoriteItem.id)
Spacer()
}
HStack {
Text("Country")
.foregroundColor(.secondary)
if accounts.app.supportsTrendingCategories {
categoryButton
}
countryButton countryButton
} }
} #elseif os(iOS)
} ToolbarItemGroup(placement: .bottomBar) {
#endif Group {
} HStack {
.onChange(of: resource) { _ in if accounts.app.supportsTrendingCategories {
resource.load() Text("Category")
updateFavoriteItem() .foregroundColor(.secondary)
}
.onAppear {
if videos.isEmpty {
resource.addObserver(store)
resource.loadIfNeeded()
} else {
store.replace(videos)
}
updateFavoriteItem() categoryButton
} // only way to disable Menu animation is to
// force redraw of the view when it changes
.id(UUID())
}
}
Spacer()
if let favoriteItem = favoriteItem {
FavoriteButton(item: favoriteItem)
.id(favoriteItem.id)
Spacer()
}
HStack {
Text("Country")
.foregroundColor(.secondary)
countryButton
}
}
}
#endif
}
.onChange(of: resource) { _ in
resource.load()
updateFavoriteItem()
}
.onAppear {
if videos.isEmpty {
resource.addObserver(store)
resource.loadIfNeeded()
} else {
store.replace(videos)
}
updateFavoriteItem()
}
} }
private var toolbar: some View { private var toolbar: some View {

View File

@ -22,11 +22,11 @@ struct HorizontalCells: View {
} }
} }
#if os(tvOS) #if os(tvOS)
.padding(.horizontal, 40) .padding(.horizontal, 40)
.padding(.vertical, 30) .padding(.vertical, 30)
#else #else
.padding(.horizontal, 15) .padding(.horizontal, 15)
.padding(.vertical, 10) .padding(.vertical, 10)
#endif #endif
} }
.frame(height: cellHeight) .frame(height: cellHeight)

View File

@ -58,7 +58,7 @@ struct VideoBanner: View {
#if os(macOS) #if os(macOS)
playbackTime.isNil ? .center : .top playbackTime.isNil ? .center : .top
#else #else
.center .center
#endif #endif
} }

View File

@ -56,7 +56,7 @@ struct VideoCell: View {
#endif #endif
} }
#if os(macOS) #if os(macOS)
.background() .background()
#endif #endif
} }
@ -171,11 +171,11 @@ struct VideoCell: View {
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading) .frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
} }
#if os(tvOS) #if os(tvOS)
.frame(minHeight: channelOnThumbnail ? 80 : 120, alignment: .top) .frame(minHeight: channelOnThumbnail ? 80 : 120, alignment: .top)
#elseif os(macOS) #elseif os(macOS)
.frame(minHeight: 35, alignment: .top) .frame(minHeight: 35, alignment: .top)
#else #else
.frame(minHeight: 50, alignment: .top) .frame(minHeight: 50, alignment: .top)
#endif #endif
.padding(.bottom, 4) .padding(.bottom, 4)
@ -316,9 +316,9 @@ struct VideoCell_Preview: PreviewProvider {
VideoCell(video: Video.fixture) VideoCell(video: Video.fixture)
} }
#if os(macOS) #if os(macOS)
.frame(maxWidth: 300, maxHeight: 250) .frame(maxWidth: 300, maxHeight: 250)
#elseif os(iOS) #elseif os(iOS)
.frame(maxWidth: 300, maxHeight: 200) .frame(maxWidth: 300, maxHeight: 200)
#endif #endif
.injectFixtureEnvironmentObjects() .injectFixtureEnvironmentObjects()
} }

View File

@ -54,33 +54,33 @@ struct ChannelPlaylistView: View {
VerticalCells(items: items) VerticalCells(items: items)
} }
#if os(iOS) #if os(iOS)
.sheet(isPresented: $presentingShareSheet) { .sheet(isPresented: $presentingShareSheet) {
if let url = accounts.api.shareURL(contentItem) { if let url = accounts.api.shareURL(contentItem) {
ShareSheet(activityItems: [url]) ShareSheet(activityItems: [url])
}
} }
}
#endif #endif
.onAppear { .onAppear {
resource?.addObserver(store) resource?.addObserver(store)
resource?.loadIfNeeded() resource?.loadIfNeeded()
} }
#if !os(tvOS) #if !os(tvOS)
.toolbar { .toolbar {
ToolbarItem(placement: .navigation) { ToolbarItem(placement: .navigation) {
ShareButton( ShareButton(
contentItem: contentItem, contentItem: contentItem,
presentingShareSheet: $presentingShareSheet presentingShareSheet: $presentingShareSheet
) )
}
ToolbarItem {
FavoriteButton(item: FavoriteItem(section: .channelPlaylist(playlist.id, playlist.title)))
}
} }
.navigationTitle(playlist.title)
ToolbarItem {
FavoriteButton(item: FavoriteItem(section: .channelPlaylist(playlist.id, playlist.title)))
}
}
.navigationTitle(playlist.title)
#else #else
.background(.thickMaterial) .background(.thickMaterial)
#endif #endif
} }

View File

@ -75,44 +75,44 @@ struct ChannelVideosView: View {
.focusScope(focusNamespace) .focusScope(focusNamespace)
#endif #endif
#if !os(tvOS) #if !os(tvOS)
.toolbar { .toolbar {
ToolbarItem(placement: .navigation) { ToolbarItem(placement: .navigation) {
ShareButton( ShareButton(
contentItem: contentItem, contentItem: contentItem,
presentingShareSheet: $presentingShareSheet presentingShareSheet: $presentingShareSheet
) )
} }
ToolbarItem { ToolbarItem {
HStack { HStack {
Text("**\(store.item?.subscriptionsString ?? "loading")** subscribers") Text("**\(store.item?.subscriptionsString ?? "loading")** subscribers")
.foregroundColor(.secondary) .foregroundColor(.secondary)
.opacity(store.item?.subscriptionsString != nil ? 1 : 0) .opacity(store.item?.subscriptionsString != nil ? 1 : 0)
subscriptionToggleButton subscriptionToggleButton
FavoriteButton(item: FavoriteItem(section: .channel(channel.id, channel.name))) FavoriteButton(item: FavoriteItem(section: .channel(channel.id, channel.name)))
}
} }
} }
}
#else #else
.background(.thickMaterial) .background(.thickMaterial)
#endif #endif
#if os(iOS) #if os(iOS)
.sheet(isPresented: $presentingShareSheet) { .sheet(isPresented: $presentingShareSheet) {
if let url = accounts.api.shareURL(contentItem) { if let url = accounts.api.shareURL(contentItem) {
ShareSheet(activityItems: [url]) ShareSheet(activityItems: [url])
}
} }
}
#endif #endif
.modifier(UnsubscribeAlertModifier()) .modifier(UnsubscribeAlertModifier())
.onAppear { .onAppear {
if store.item.isNil { if store.item.isNil {
resource.addObserver(store) resource.addObserver(store)
resource.load() resource.load()
}
} }
.navigationTitle(navigationTitle) }
.navigationTitle(navigationTitle)
} }
private var resource: Resource { private var resource: Resource {

View File

@ -14,8 +14,8 @@ struct PlayerControlsView<Content: View>: View {
ZStack(alignment: .bottomLeading) { ZStack(alignment: .bottomLeading) {
content content
#if !os(tvOS) #if !os(tvOS)
.frame(minHeight: 0, maxHeight: .infinity) .frame(minHeight: 0, maxHeight: .infinity)
.padding(.bottom, 50) .padding(.bottom, 50)
#endif #endif
#if !os(tvOS) #if !os(tvOS)

View File

@ -142,7 +142,7 @@ struct SearchView: View {
state.changeQuery { query in query.duration = duration } state.changeQuery { query in query.duration = duration }
} }
#if !os(tvOS) #if !os(tvOS)
.navigationTitle("Search") .navigationTitle("Search")
#endif #endif
} }
@ -194,13 +194,13 @@ struct SearchView: View {
state.changeQuery { query in query.query = item.title } state.changeQuery { query in query.query = item.title }
} }
#if os(iOS) #if os(iOS)
.swipeActions(edge: .trailing) { .swipeActions(edge: .trailing) {
deleteButton(item) deleteButton(item)
} }
#elseif os(tvOS) #elseif os(tvOS)
.contextMenu { .contextMenu {
deleteButton(item) deleteButton(item)
} }
#endif #endif
} }
} }
@ -212,7 +212,7 @@ struct SearchView: View {
} }
} }
#if os(iOS) #if os(iOS)
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
#endif #endif
} }

View File

@ -23,7 +23,7 @@ struct SignInRequiredView<Content: View>: View {
} }
} }
#if !os(tvOS) #if !os(tvOS)
.navigationTitle(title) .navigationTitle(title)
#endif #endif
} }

View File

@ -12,11 +12,11 @@ struct YatteeApp: App {
ContentView() ContentView()
} }
#if !os(tvOS) #if !os(tvOS)
.handlesExternalEvents(matching: Set(["*"])) .handlesExternalEvents(matching: Set(["*"]))
.commands { .commands {
SidebarCommands() SidebarCommands()
CommandGroup(replacing: .newItem, addition: {}) CommandGroup(replacing: .newItem, addition: {})
} }
#endif #endif
#if os(macOS) #if os(macOS)