mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Various minor fixes
This commit is contained in:
parent
4657af2f3d
commit
61d235780d
@ -38,6 +38,10 @@ struct PlayerQueueItem: Hashable, Identifiable, Defaults.Serializable {
|
||||
return false
|
||||
}
|
||||
|
||||
if duration <= 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
return duration - seconds <= 20
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ struct DocumentsView: View {
|
||||
}
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
if model.canGoBack {
|
||||
Button {
|
||||
withAnimation {
|
||||
model.goBack()
|
||||
@ -52,8 +53,9 @@ struct DocumentsView: View {
|
||||
.disabled(!model.canGoBack)
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle(model.directoryLabel)
|
||||
.padding()
|
||||
.padding(.horizontal)
|
||||
.navigationBarTitleDisplayMode(RefreshControl.navigationBarTitleDisplayMode)
|
||||
.backport
|
||||
.refreshable {
|
||||
|
@ -141,7 +141,6 @@ struct Favorites_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
TabView {
|
||||
HomeView()
|
||||
// .overlay(VideoPlayerView().injectFixtureEnvironmentObjects())
|
||||
.injectFixtureEnvironmentObjects()
|
||||
.tabItem {
|
||||
Label("Home", systemImage: "house")
|
||||
|
@ -5,8 +5,6 @@ import SwiftUI
|
||||
#endif
|
||||
|
||||
struct AppSidebarNavigation: View {
|
||||
@Default(.showOpenActionsToolbarItem) private var showOpenActionsToolbarItem
|
||||
|
||||
@EnvironmentObject<AccountsModel> private var accounts
|
||||
@EnvironmentObject<NavigationModel> private var navigation
|
||||
|
||||
@ -23,6 +21,8 @@ struct AppSidebarNavigation: View {
|
||||
@EnvironmentObject<ThumbnailsModel> private var thumbnailsModel
|
||||
#endif
|
||||
|
||||
@Default(.showOpenActionsToolbarItem) private var showOpenActionsToolbarItem
|
||||
|
||||
var body: some View {
|
||||
#if os(iOS)
|
||||
content.introspectViewController { viewController in
|
||||
|
@ -121,16 +121,7 @@ struct ContentView: View {
|
||||
|
||||
NavigationModel.shared.presentingOpenVideos = false
|
||||
}
|
||||
.onOpenURL {
|
||||
OpenURLHandler(
|
||||
accounts: accounts,
|
||||
navigation: navigation,
|
||||
recents: recents,
|
||||
player: player,
|
||||
search: search,
|
||||
navigationStyle: navigationStyle
|
||||
).handle($0)
|
||||
}
|
||||
.onOpenURL(perform: OpenURLHandler.shared.handle)
|
||||
.background(
|
||||
EmptyView().sheet(isPresented: $navigation.presentingAddToPlaylist) {
|
||||
AddToPlaylistView(video: navigation.videoToAddToPlaylist)
|
||||
|
@ -47,7 +47,7 @@ struct Sidebar: View {
|
||||
Label("Home", systemImage: "house")
|
||||
.accessibility(label: Text("Home"))
|
||||
}
|
||||
.id("favorites")
|
||||
.id("home")
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
@ -59,7 +59,6 @@ struct Sidebar: View {
|
||||
.id("documents")
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if !accounts.isEmpty {
|
||||
if visibleSections.contains(.subscriptions),
|
||||
|
@ -3,16 +3,25 @@ import Foundation
|
||||
import Siesta
|
||||
|
||||
struct OpenURLHandler {
|
||||
static var firstHandle = true
|
||||
static var shared = OpenURLHandler()
|
||||
static let yatteeProtocol = "yattee://"
|
||||
|
||||
var accounts: AccountsModel
|
||||
var navigation: NavigationModel
|
||||
var recents: RecentsModel
|
||||
var player: PlayerModel
|
||||
var search: SearchModel
|
||||
var accounts: AccountsModel!
|
||||
var navigation: NavigationModel!
|
||||
var recents: RecentsModel!
|
||||
var player: PlayerModel!
|
||||
var search: SearchModel!
|
||||
var navigationStyle = NavigationStyle.sidebar
|
||||
|
||||
func handle(_ url: URL) {
|
||||
if Self.firstHandle {
|
||||
Self.firstHandle = false
|
||||
|
||||
Delay.by(1) { Self.shared.handle(url) }
|
||||
return
|
||||
}
|
||||
|
||||
if accounts.current.isNil {
|
||||
accounts.setCurrent(accounts.any)
|
||||
}
|
||||
@ -27,9 +36,7 @@ struct OpenURLHandler {
|
||||
}
|
||||
#endif
|
||||
|
||||
guard var url = urlByReplacingYatteeProtocol(url) else {
|
||||
return
|
||||
}
|
||||
guard let url = urlByReplacingYatteeProtocol(url) else { return }
|
||||
|
||||
let parser = URLParser(url: url)
|
||||
|
||||
|
@ -39,7 +39,6 @@ struct PlayerQueueRow: View {
|
||||
return
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if item.video.localStreamIsFile, let url = item.video.localStream?.localURL {
|
||||
URLBookmarkModel.shared.saveBookmark(url)
|
||||
|
@ -57,14 +57,14 @@ struct VideoPlayerView: View {
|
||||
@State internal var orientationObserver: Any?
|
||||
#endif
|
||||
|
||||
@EnvironmentObject<AccountsModel> internal var accounts
|
||||
@EnvironmentObject<NavigationModel> internal var navigation
|
||||
@EnvironmentObject<PlayerModel> internal var player
|
||||
@EnvironmentObject<RecentsModel> internal var recents
|
||||
#if os(macOS)
|
||||
@EnvironmentObject<NavigationModel> internal var navigation
|
||||
@EnvironmentObject<SearchModel> internal var search
|
||||
#endif
|
||||
@EnvironmentObject<ThumbnailsModel> internal var thumbnails
|
||||
#if os(tvOS)
|
||||
@EnvironmentObject<ThumbnailsModel> private var thumbnails
|
||||
#endif
|
||||
|
||||
@Default(.horizontalPlayerGestureEnabled) var horizontalPlayerGestureEnabled
|
||||
@Default(.seekGestureSpeed) var seekGestureSpeed
|
||||
@ -107,15 +107,7 @@ struct VideoPlayerView: View {
|
||||
}
|
||||
}
|
||||
.alert(isPresented: $navigation.presentingAlertInVideoPlayer) { navigation.alert }
|
||||
.onOpenURL {
|
||||
OpenURLHandler(
|
||||
accounts: accounts,
|
||||
navigation: navigation,
|
||||
recents: recents,
|
||||
player: player,
|
||||
search: search
|
||||
).handle($0)
|
||||
}
|
||||
.onOpenURL(perform: OpenURLHandler.shared.handle)
|
||||
.frame(minWidth: 950, minHeight: 700)
|
||||
#else
|
||||
return GeometryReader { geometry in
|
||||
|
@ -21,7 +21,9 @@ struct OpenVideosView: View {
|
||||
.frame(minWidth: 600, maxWidth: 800, minHeight: 350, maxHeight: 500)
|
||||
#else
|
||||
NavigationView {
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
openVideos
|
||||
}
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button(action: { presentationMode.wrappedValue.dismiss() }) {
|
||||
|
@ -226,12 +226,13 @@ struct VideoContextMenuView: View {
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
private var removeDocumentButton: some View {
|
||||
Button {
|
||||
@ViewBuilder private var removeDocumentButton: some View {
|
||||
let action = {
|
||||
if let url = video.localStream?.localURL {
|
||||
NavigationModel.shared.presentAlert(
|
||||
Alert(
|
||||
title: Text("Are you sure you want to remove this document?"),
|
||||
message: Text(String(format: "\"%@\" will be irreversibly removed from this device.", video.displayTitle)),
|
||||
primaryButton: .destructive(Text("Remove")) {
|
||||
do {
|
||||
try DocumentsModel.shared.removeDocument(url)
|
||||
@ -243,9 +244,14 @@ struct VideoContextMenuView: View {
|
||||
)
|
||||
)
|
||||
}
|
||||
} label: {
|
||||
Label("Remove...", systemImage: "trash.fill")
|
||||
}
|
||||
let label = Label("Remove...", systemImage: "trash.fill")
|
||||
.foregroundColor(Color("AppRedColor"))
|
||||
|
||||
if #available(iOS 15, macOS 12, *) {
|
||||
Button(role: .destructive, action: action) { label }
|
||||
} else {
|
||||
Button(action: action) { label }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -195,6 +195,14 @@ struct YatteeApp: App {
|
||||
PlayerModel.shared = player
|
||||
PlayerTimeModel.shared.player = player
|
||||
|
||||
#if !os(tvOS)
|
||||
OpenURLHandler.shared.accounts = accounts
|
||||
OpenURLHandler.shared.navigation = navigation
|
||||
OpenURLHandler.shared.recents = recents
|
||||
OpenURLHandler.shared.player = player
|
||||
OpenURLHandler.shared.search = search
|
||||
#endif
|
||||
|
||||
if !accounts.current.isNil {
|
||||
player.restoreQueue()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user