Layout fixes

This commit is contained in:
Arkadiusz Fal 2022-11-12 02:39:44 +01:00
parent eb1e440ed2
commit eb9924bd4a
8 changed files with 117 additions and 102 deletions

View File

@ -26,14 +26,21 @@ struct HomeView: View {
var body: some View { var body: some View {
BrowserPlayerControls { BrowserPlayerControls {
ScrollView(.vertical, showsIndicators: false) { ScrollView(.vertical, showsIndicators: false) {
if showOpenActionsInHome { HStack {
HStack { #if os(tvOS)
#if os(tvOS) Group {
OpenVideosButton(text: "Open Video", imageSystemName: "globe") { if showOpenActionsInHome {
NavigationModel.shared.presentingOpenVideos = true OpenVideosButton(text: "Open Video", imageSystemName: "globe") {
NavigationModel.shared.presentingOpenVideos = true
}
} }
.frame(maxWidth: 600) OpenVideosButton(text: "Settings", imageSystemName: "gear") {
#else NavigationModel.shared.presentingSettings = true
}
}
#else
if showOpenActionsInHome {
OpenVideosButton(text: "Files", imageSystemName: "folder") { OpenVideosButton(text: "Files", imageSystemName: "folder") {
NavigationModel.shared.presentingFileImporter = true NavigationModel.shared.presentingFileImporter = true
} }
@ -44,19 +51,19 @@ struct HomeView: View {
NavigationModel.shared.presentingOpenVideos = true NavigationModel.shared.presentingOpenVideos = true
} }
.frame(maxWidth: 40) .frame(maxWidth: 40)
#endif }
}
#if os(iOS)
.padding(.top, RefreshControl.navigationBarTitleDisplayMode == .inline ? 15 : 0)
#else
.padding(.top, 15)
#endif
#if os(tvOS)
.padding(.horizontal, 40)
#else
.padding(.horizontal, 15)
#endif #endif
} }
#if os(iOS)
.padding(.top, RefreshControl.navigationBarTitleDisplayMode == .inline ? 15 : 0)
#else
.padding(.top, 15)
#endif
#if os(tvOS)
.padding(.horizontal, 40)
#else
.padding(.horizontal, 15)
#endif
if !accounts.current.isNil, showFavoritesInHome { if !accounts.current.isNil, showFavoritesInHome {
#if os(tvOS) #if os(tvOS)
@ -112,7 +119,6 @@ struct HomeView: View {
#if os(tvOS) #if os(tvOS)
.edgesIgnoringSafeArea(.horizontal) .edgesIgnoringSafeArea(.horizontal)
#else #else
.onDrop(of: [UTType.text], delegate: DropFavoriteOutside(current: $dragging))
.navigationTitle("Home") .navigationTitle("Home")
#endif #endif
#if os(macOS) #if os(macOS)

View File

@ -84,6 +84,16 @@ struct ContentView: View {
.environmentObject(navigation) .environmentObject(navigation)
} }
) )
.background(
EmptyView().sheet(isPresented: $navigation.presentingSettings) {
SettingsView()
.environmentObject(accounts)
.environmentObject(instances)
.environmentObject(settings)
.environmentObject(navigation)
.environmentObject(player)
}
)
#if !os(tvOS) #if !os(tvOS)
.fileImporter( .fileImporter(
isPresented: $navigation.presentingFileImporter, isPresented: $navigation.presentingFileImporter,
@ -134,16 +144,6 @@ struct ContentView: View {
.environmentObject(playlists) .environmentObject(playlists)
} }
) )
.background(
EmptyView().sheet(isPresented: $navigation.presentingSettings) {
SettingsView()
.environmentObject(accounts)
.environmentObject(instances)
.environmentObject(settings)
.environmentObject(navigation)
.environmentObject(player)
}
)
#endif #endif
.background( .background(
EmptyView().sheet(isPresented: $navigation.presentingOpenVideos) { EmptyView().sheet(isPresented: $navigation.presentingOpenVideos) {

View File

@ -120,7 +120,9 @@ struct BrowsingSettings: View {
private var interfaceSettings: some View { private var interfaceSettings: some View {
Section(header: SettingsHeader(text: "Interface".localized())) { Section(header: SettingsHeader(text: "Interface".localized())) {
Toggle("Show Open Videos toolbar button", isOn: $showOpenActionsToolbarItem) #if !os(tvOS)
Toggle("Show Open Videos toolbar button", isOn: $showOpenActionsToolbarItem)
#endif
#if os(iOS) #if os(iOS)
Toggle("Lock portrait mode", isOn: $lockPortraitWhenBrowsing) Toggle("Lock portrait mode", isOn: $lockPortraitWhenBrowsing)
.onChange(of: lockPortraitWhenBrowsing) { lock in .onChange(of: lockPortraitWhenBrowsing) { lock in

View File

@ -10,51 +10,69 @@ struct EditFavorites: View {
var body: some View { var body: some View {
Group { Group {
List { #if os(tvOS)
Section(header: Text("Favorites")) { ScrollView {
if favorites.isEmpty { VStack {
Text("Favorites is empty") editor
.foregroundColor(.secondary)
}
ForEach(favorites) { item in
HStack {
Text(label(item))
Spacer()
HStack(spacing: 30) {
Button {
model.moveUp(item)
} label: {
Label("Move Up", systemImage: "arrow.up")
}
Button {
model.moveDown(item)
} label: {
Label("Move Down", systemImage: "arrow.down")
}
Button {
model.remove(item)
} label: {
Label("Remove", systemImage: "trash")
}
}
#if !os(tvOS)
.buttonStyle(.borderless)
#endif
}
} }
} }
#if os(tvOS) .frame(width: 1000)
.padding(.trailing, 40) #else
#endif List {
editor
}
#endif
}
.navigationTitle("Favorites")
}
#if os(tvOS) var editor: some View {
Divider() Group {
.padding(20) Section(header: Text("Favorites")) {
#endif if favorites.isEmpty {
Text("Favorites is empty")
.foregroundColor(.secondary)
}
ForEach(favorites) { item in
HStack {
Text(label(item))
Spacer()
HStack(spacing: 30) {
Button {
model.moveUp(item)
} label: {
Label("Move Up", systemImage: "arrow.up")
}
Button {
model.moveDown(item)
} label: {
Label("Move Down", systemImage: "arrow.down")
}
Button {
model.remove(item)
} label: {
Label("Remove", systemImage: "trash")
}
}
#if !os(tvOS)
.buttonStyle(.borderless)
#endif
}
}
}
#if os(tvOS)
.padding(.trailing, 40)
#endif
#if os(tvOS)
Divider()
.padding(20)
#endif
if !model.addableItems().isEmpty {
Section(header: Text("Available")) { Section(header: Text("Available")) {
ForEach(model.addableItems()) { item in ForEach(model.addableItems()) { item in
HStack { HStack {
@ -70,6 +88,9 @@ struct EditFavorites: View {
.font(.system(size: 30)) .font(.system(size: 30))
#endif #endif
} }
#if !os(tvOS)
.buttonStyle(.borderless)
#endif
} }
} }
} }
@ -77,13 +98,8 @@ struct EditFavorites: View {
.padding(.trailing, 40) .padding(.trailing, 40)
#endif #endif
} }
.labelStyle(.iconOnly)
.frame(alignment: .leading)
#if os(tvOS)
.frame(width: 1000)
#endif
} }
.navigationTitle("Favorites") .labelStyle(.iconOnly)
} }
func label(_ item: FavoriteItem) -> String { func label(_ item: FavoriteItem) -> String {
@ -97,9 +113,9 @@ struct EditFavorites: View {
struct EditFavorites_Previews: PreviewProvider { struct EditFavorites_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
NavigationView { // NavigationView {
EditFavorites() EditFavorites()
} // }
.injectFixtureEnvironmentObjects() .injectFixtureEnvironmentObjects()
} }
} }

View File

@ -97,9 +97,7 @@ struct SettingsView: View {
#else #else
NavigationView { NavigationView {
settingsList settingsList
#if os(tvOS) .navigationTitle("Settings")
.navigationBarHidden(true)
#endif
} }
#endif #endif
} }
@ -115,14 +113,6 @@ struct SettingsView: View {
#endif #endif
Section { Section {
#if os(tvOS)
NavigationLink {
EditFavorites()
} label: {
Label("Favorites", systemImage: "heart.fill")
}
#endif
NavigationLink { NavigationLink {
BrowsingSettings() BrowsingSettings()
} label: { } label: {
@ -195,7 +185,6 @@ struct SettingsView: View {
} }
#endif #endif
} }
.navigationTitle("Settings")
.toolbar { .toolbar {
ToolbarItem(placement: .navigationBarLeading) { ToolbarItem(placement: .navigationBarLeading) {
#if !os(tvOS) #if !os(tvOS)
@ -217,9 +206,9 @@ struct SettingsView: View {
private var windowHeight: Double { private var windowHeight: Double {
switch selection { switch selection {
case nil: case nil:
return accounts.isEmpty ? 680 : 520 return accounts.isEmpty ? 680 : 580
case .browsing: case .browsing:
return 520 return 580
case .player: case .player:
return 680 return 680
case .quality: case .quality:

View File

@ -4,6 +4,12 @@ import SDWebImageSwiftUI
import SwiftUI import SwiftUI
struct VideoBanner: View { struct VideoBanner: View {
#if os(tvOS)
static let titleAppend = ""
#else
static let titleAppend = "\n"
#endif
let video: Video? let video: Video?
var playbackTime: CMTime? var playbackTime: CMTime?
var videoDuration: TimeInterval? var videoDuration: TimeInterval?
@ -27,7 +33,7 @@ struct VideoBanner: View {
Group { Group {
if let video { if let video {
HStack(alignment: .top) { HStack(alignment: .top) {
Text(video.displayTitle + "\n") Text(video.displayTitle + Self.titleAppend)
if video.isLocal, let fileExtension = video.localStreamFileExtension { if video.isLocal, let fileExtension = video.localStreamFileExtension {
Spacer() Spacer()
Text(fileExtension) Text(fileExtension)

View File

@ -7,12 +7,12 @@ struct OpenVideosButton: View {
var body: some View { var body: some View {
Button(action: action) { Button(action: action) {
HStack { HStack(spacing: 8) {
if let imageSystemName { if let imageSystemName {
Image(systemName: imageSystemName) Image(systemName: imageSystemName)
} }
if let text { if let text {
Text(text ?? "") Text(text)
.fontWeight(.bold) .fontWeight(.bold)
} }
} }

View File

@ -50,10 +50,6 @@ struct TVNavigationView: View {
.tabItem { Image(systemName: "magnifyingglass") } .tabItem { Image(systemName: "magnifyingglass") }
.tag(TabSelection.search) .tag(TabSelection.search)
} }
LazyView(SettingsView())
.tabItem { Image(systemName: "gear") }
.tag(TabSelection.settings)
} }
} }
.fullScreenCover(isPresented: $navigation.presentingAddToPlaylist) { .fullScreenCover(isPresented: $navigation.presentingAddToPlaylist) {