more iOS settings and fix appearance setting
This commit is contained in:
parent
3eb92cd325
commit
4f3f6d4c08
|
@ -15,7 +15,6 @@ import SwiftUI
|
||||||
struct JellyfinPlayerApp: App {
|
struct JellyfinPlayerApp: App {
|
||||||
|
|
||||||
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
||||||
@Default(.appAppearance) var appAppearance
|
|
||||||
|
|
||||||
var body: some Scene {
|
var body: some Scene {
|
||||||
WindowGroup {
|
WindowGroup {
|
||||||
|
@ -25,21 +24,18 @@ struct JellyfinPlayerApp: App {
|
||||||
window?.rootViewController = PreferenceUIHostingController(wrappedView: MainCoordinator().view())
|
window?.rootViewController = PreferenceUIHostingController(wrappedView: MainCoordinator().view())
|
||||||
})
|
})
|
||||||
.onAppear {
|
.onAppear {
|
||||||
setupAppearance()
|
JellyfinPlayerApp.setupAppearance()
|
||||||
}
|
}
|
||||||
.onOpenURL { url in
|
.onOpenURL { url in
|
||||||
AppURLHandler.shared.processDeepLink(url: url)
|
AppURLHandler.shared.processDeepLink(url: url)
|
||||||
}
|
}
|
||||||
.onChange(of: appAppearance) { newValue in
|
|
||||||
setupAppearance()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setupAppearance() {
|
static func setupAppearance() {
|
||||||
let scenes = UIApplication.shared.connectedScenes
|
let scenes = UIApplication.shared.connectedScenes
|
||||||
let windowScene = scenes.first as? UIWindowScene
|
let windowScene = scenes.first as? UIWindowScene
|
||||||
windowScene?.windows.first?.overrideUserInterfaceStyle = appAppearance.style
|
windowScene?.windows.first?.overrideUserInterfaceStyle = Defaults[.appAppearance].style
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,9 @@ struct BasicAppSettingsView: View {
|
||||||
|
|
||||||
@EnvironmentObject var basicAppSettingsRouter: BasicAppSettingsCoordinator.Router
|
@EnvironmentObject var basicAppSettingsRouter: BasicAppSettingsCoordinator.Router
|
||||||
@ObservedObject var viewModel: BasicAppSettingsViewModel
|
@ObservedObject var viewModel: BasicAppSettingsViewModel
|
||||||
@State var resetTapped: Bool = false
|
@State var resetUserSettingsTapped: Bool = false
|
||||||
|
@State var resetAppSettingsTapped: Bool = false
|
||||||
|
@State var removeAllUsersTapped: Bool = false
|
||||||
|
|
||||||
@Default(.appAppearance) var appAppearance
|
@Default(.appAppearance) var appAppearance
|
||||||
@Default(.defaultHTTPScheme) var defaultHTTPScheme
|
@Default(.defaultHTTPScheme) var defaultHTTPScheme
|
||||||
|
@ -43,15 +45,40 @@ struct BasicAppSettingsView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
resetTapped = true
|
resetUserSettingsTapped = true
|
||||||
|
} label: {
|
||||||
|
Text("Reset User Settings")
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
resetAppSettingsTapped = true
|
||||||
|
} label: {
|
||||||
|
Text("Reset App Settings")
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
removeAllUsersTapped = true
|
||||||
|
} label: {
|
||||||
|
Text("Remove All Users")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.alert("Reset User Settings", isPresented: $resetUserSettingsTapped, actions: {
|
||||||
|
Button(role: .destructive) {
|
||||||
|
viewModel.resetUserSettings()
|
||||||
} label: {
|
} label: {
|
||||||
L10n.reset.text
|
L10n.reset.text
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
.alert(L10n.reset, isPresented: $resetTapped, actions: {
|
.alert("Reset App Settings", isPresented: $resetAppSettingsTapped, actions: {
|
||||||
Button(role: .destructive) {
|
Button(role: .destructive) {
|
||||||
viewModel.reset()
|
viewModel.resetAppSettings()
|
||||||
basicAppSettingsRouter.dismissCoordinator()
|
} label: {
|
||||||
|
L10n.reset.text
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.alert("Remove All Users", isPresented: $removeAllUsersTapped, actions: {
|
||||||
|
Button(role: .destructive) {
|
||||||
|
viewModel.removeAllUsers()
|
||||||
} label: {
|
} label: {
|
||||||
L10n.reset.text
|
L10n.reset.text
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ struct OverlaySettingsView: View {
|
||||||
@Default(.shouldShowPlayPreviousItem) var shouldShowPlayPreviousItem
|
@Default(.shouldShowPlayPreviousItem) var shouldShowPlayPreviousItem
|
||||||
@Default(.shouldShowPlayNextItem) var shouldShowPlayNextItem
|
@Default(.shouldShowPlayNextItem) var shouldShowPlayNextItem
|
||||||
@Default(.shouldShowAutoPlay) var shouldShowAutoPlay
|
@Default(.shouldShowAutoPlay) var shouldShowAutoPlay
|
||||||
|
@Default(.shouldShowJumpButtonsInOverlayMenu) var shouldShowJumpButtonsInOverlayMenu
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Form {
|
Form {
|
||||||
|
@ -29,6 +30,7 @@ struct OverlaySettingsView: View {
|
||||||
Toggle("\(Image(systemName: "chevron.left.circle")) Play Previous Item", isOn: $shouldShowPlayPreviousItem)
|
Toggle("\(Image(systemName: "chevron.left.circle")) Play Previous Item", isOn: $shouldShowPlayPreviousItem)
|
||||||
Toggle("\(Image(systemName: "chevron.right.circle")) Play Next Item", isOn: $shouldShowPlayNextItem)
|
Toggle("\(Image(systemName: "chevron.right.circle")) Play Next Item", isOn: $shouldShowPlayNextItem)
|
||||||
Toggle("\(Image(systemName: "play.circle.fill")) Auto Play", isOn: $shouldShowAutoPlay)
|
Toggle("\(Image(systemName: "play.circle.fill")) Auto Play", isOn: $shouldShowAutoPlay)
|
||||||
|
Toggle("Allow Edit Jump Lengths", isOn: $shouldShowJumpButtonsInOverlayMenu)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ struct SettingsView: View {
|
||||||
} label: {
|
} label: {
|
||||||
HStack {
|
HStack {
|
||||||
Text("Server")
|
Text("Server")
|
||||||
.foregroundColor(.white)
|
.foregroundColor(.primary)
|
||||||
Spacer()
|
Spacer()
|
||||||
Text(viewModel.server.name)
|
Text(viewModel.server.name)
|
||||||
.foregroundColor(.jellyfinPurple)
|
.foregroundColor(.jellyfinPurple)
|
||||||
|
@ -94,7 +94,7 @@ struct SettingsView: View {
|
||||||
} label: {
|
} label: {
|
||||||
HStack {
|
HStack {
|
||||||
Text("Overlay")
|
Text("Overlay")
|
||||||
.foregroundColor(.white)
|
.foregroundColor(.primary)
|
||||||
Spacer()
|
Spacer()
|
||||||
Text(overlayType.label)
|
Text(overlayType.label)
|
||||||
|
|
||||||
|
|
|
@ -190,44 +190,45 @@ struct VLCPlayerOverlayView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu {
|
if viewModel.shouldShowJumpButtonsInOverlayMenu {
|
||||||
ForEach(VideoPlayerJumpLength.allCases, id: \.self) { forwardLength in
|
Menu {
|
||||||
Button {
|
ForEach(VideoPlayerJumpLength.allCases, id: \.self) { forwardLength in
|
||||||
viewModel.jumpForwardLength = forwardLength
|
Button {
|
||||||
} label: {
|
viewModel.jumpForwardLength = forwardLength
|
||||||
if forwardLength == viewModel.jumpForwardLength {
|
} label: {
|
||||||
Label(forwardLength.shortLabel, systemImage: "checkmark")
|
if forwardLength == viewModel.jumpForwardLength {
|
||||||
} else {
|
Label(forwardLength.shortLabel, systemImage: "checkmark")
|
||||||
Text(forwardLength.shortLabel)
|
} else {
|
||||||
|
Text(forwardLength.shortLabel)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} label: {
|
||||||
} label: {
|
HStack {
|
||||||
HStack {
|
Image(systemName: "goforward")
|
||||||
Image(systemName: "goforward")
|
Text("Jump Forward Length")
|
||||||
Text("Jump Forward Length")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Menu {
|
|
||||||
ForEach(VideoPlayerJumpLength.allCases, id: \.self) { backwardLength in
|
|
||||||
Button {
|
|
||||||
viewModel.jumpBackwardLength = backwardLength
|
|
||||||
} label: {
|
|
||||||
if backwardLength == viewModel.jumpBackwardLength {
|
|
||||||
Label(backwardLength.shortLabel, systemImage: "checkmark")
|
|
||||||
} else {
|
|
||||||
Text(backwardLength.shortLabel)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} label: {
|
|
||||||
HStack {
|
Menu {
|
||||||
Image(systemName: "gobackward")
|
ForEach(VideoPlayerJumpLength.allCases, id: \.self) { backwardLength in
|
||||||
Text("Jump Backward Length")
|
Button {
|
||||||
|
viewModel.jumpBackwardLength = backwardLength
|
||||||
|
} label: {
|
||||||
|
if backwardLength == viewModel.jumpBackwardLength {
|
||||||
|
Label(backwardLength.shortLabel, systemImage: "checkmark")
|
||||||
|
} else {
|
||||||
|
Text(backwardLength.shortLabel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
HStack {
|
||||||
|
Image(systemName: "gobackward")
|
||||||
|
Text("Jump Backward Length")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} label: {
|
} label: {
|
||||||
Image(systemName: "ellipsis.circle")
|
Image(systemName: "ellipsis.circle")
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
* Copyright 2021 Aiden Vigue & Jellyfin Contributors
|
* Copyright 2021 Aiden Vigue & Jellyfin Contributors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import Combine
|
||||||
|
import Defaults
|
||||||
import Foundation
|
import Foundation
|
||||||
import Nuke
|
import Nuke
|
||||||
import Stinsen
|
import Stinsen
|
||||||
|
@ -19,6 +21,8 @@ final class MainCoordinator: NavigationCoordinatable {
|
||||||
@Root var mainTab = makeMainTab
|
@Root var mainTab = makeMainTab
|
||||||
@Root var serverList = makeServerList
|
@Root var serverList = makeServerList
|
||||||
|
|
||||||
|
private var cancellables = Set<AnyCancellable>()
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
if SessionManager.main.currentLogin != nil {
|
if SessionManager.main.currentLogin != nil {
|
||||||
self.stack = NavigationStack(initial: \MainCoordinator.mainTab)
|
self.stack = NavigationStack(initial: \MainCoordinator.mainTab)
|
||||||
|
@ -45,6 +49,12 @@ final class MainCoordinator: NavigationCoordinatable {
|
||||||
nc.addObserver(self, selector: #selector(didLogOut), name: SwiftfinNotificationCenter.Keys.didSignOut, object: nil)
|
nc.addObserver(self, selector: #selector(didLogOut), name: SwiftfinNotificationCenter.Keys.didSignOut, object: nil)
|
||||||
nc.addObserver(self, selector: #selector(processDeepLink), name: SwiftfinNotificationCenter.Keys.processDeepLink, object: nil)
|
nc.addObserver(self, selector: #selector(processDeepLink), name: SwiftfinNotificationCenter.Keys.processDeepLink, object: nil)
|
||||||
nc.addObserver(self, selector: #selector(didChangeServerCurrentURI), name: SwiftfinNotificationCenter.Keys.didChangeServerCurrentURI, object: nil)
|
nc.addObserver(self, selector: #selector(didChangeServerCurrentURI), name: SwiftfinNotificationCenter.Keys.didChangeServerCurrentURI, object: nil)
|
||||||
|
|
||||||
|
Defaults.publisher(.appAppearance)
|
||||||
|
.sink { _ in
|
||||||
|
JellyfinPlayerApp.setupAppearance()
|
||||||
|
}
|
||||||
|
.store(in: &cancellables)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func didLogIn() {
|
@objc func didLogIn() {
|
||||||
|
|
|
@ -254,9 +254,6 @@ final class SessionManager {
|
||||||
delete(server: server)
|
delete(server: server)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete general UserDefaults
|
|
||||||
SwiftfinStore.Defaults.generalSuite.removeAll()
|
|
||||||
|
|
||||||
SwiftfinNotificationCenter.main.post(name: SwiftfinNotificationCenter.Keys.didPurge, object: nil)
|
SwiftfinNotificationCenter.main.post(name: SwiftfinNotificationCenter.Keys.didPurge, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,9 @@ extension Defaults.Keys {
|
||||||
static let shouldShowPlayNextItem = Key<Bool>("shouldShowNextItem", default: true, suite: SwiftfinStore.Defaults.generalSuite)
|
static let shouldShowPlayNextItem = Key<Bool>("shouldShowNextItem", default: true, suite: SwiftfinStore.Defaults.generalSuite)
|
||||||
static let shouldShowAutoPlay = Key<Bool>("shouldShowAutoPlayNextItem", default: true, suite: SwiftfinStore.Defaults.generalSuite)
|
static let shouldShowAutoPlay = Key<Bool>("shouldShowAutoPlayNextItem", default: true, suite: SwiftfinStore.Defaults.generalSuite)
|
||||||
|
|
||||||
|
// Should show video player items in overlay menu
|
||||||
|
static let shouldShowJumpButtonsInOverlayMenu = Key<Bool>("shouldShowJumpButtonsInMenu", default: true, suite: SwiftfinStore.Defaults.generalSuite)
|
||||||
|
|
||||||
// Experimental settings
|
// Experimental settings
|
||||||
struct Experimental {
|
struct Experimental {
|
||||||
static let syncSubtitleStateWithAdjacent = Key<Bool>("experimental.syncSubtitleState", default: false, suite: SwiftfinStore.Defaults.generalSuite)
|
static let syncSubtitleStateWithAdjacent = Key<Bool>("experimental.syncSubtitleState", default: false, suite: SwiftfinStore.Defaults.generalSuite)
|
||||||
|
|
|
@ -13,7 +13,15 @@ final class BasicAppSettingsViewModel: ViewModel {
|
||||||
|
|
||||||
let appearances = AppAppearance.allCases
|
let appearances = AppAppearance.allCases
|
||||||
|
|
||||||
func reset() {
|
func resetUserSettings() {
|
||||||
|
SwiftfinStore.Defaults.generalSuite.removeAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
func resetAppSettings() {
|
||||||
|
SwiftfinStore.Defaults.universalSuite.removeAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeAllUsers() {
|
||||||
SessionManager.main.purge()
|
SessionManager.main.purge()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ final class VideoPlayerViewModel: ViewModel {
|
||||||
let shouldShowPlayPreviousItem: Bool
|
let shouldShowPlayPreviousItem: Bool
|
||||||
let shouldShowPlayNextItem: Bool
|
let shouldShowPlayNextItem: Bool
|
||||||
let shouldShowAutoPlay: Bool
|
let shouldShowAutoPlay: Bool
|
||||||
|
let shouldShowJumpButtonsInOverlayMenu: Bool
|
||||||
|
|
||||||
// MARK: General
|
// MARK: General
|
||||||
let item: BaseItemDto
|
let item: BaseItemDto
|
||||||
|
@ -134,6 +135,7 @@ final class VideoPlayerViewModel: ViewModel {
|
||||||
self.jumpBackwardLength = Defaults[.videoPlayerJumpBackward]
|
self.jumpBackwardLength = Defaults[.videoPlayerJumpBackward]
|
||||||
self.jumpForwardLength = Defaults[.videoPlayerJumpForward]
|
self.jumpForwardLength = Defaults[.videoPlayerJumpForward]
|
||||||
self.jumpGesturesEnabled = Defaults[.jumpGesturesEnabled]
|
self.jumpGesturesEnabled = Defaults[.jumpGesturesEnabled]
|
||||||
|
self.shouldShowJumpButtonsInOverlayMenu = Defaults[.shouldShowJumpButtonsInOverlayMenu]
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue