rollback toolbar
GlobalData conform Equatable Change the conditions for some screens onAppear
This commit is contained in:
parent
039d2aef0f
commit
e1dba314df
|
@ -19,6 +19,16 @@ class GlobalData: ObservableObject {
|
||||||
@Published var isInNetwork: Bool = true;
|
@Published var isInNetwork: Bool = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension GlobalData: Equatable {
|
||||||
|
|
||||||
|
static func == (lhs: GlobalData, rhs: GlobalData) -> Bool {
|
||||||
|
lhs.user == rhs.user
|
||||||
|
&& lhs.authToken == rhs.authToken
|
||||||
|
&& lhs.server == rhs.server
|
||||||
|
&& lhs.authHeader == rhs.authHeader
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension UIDevice {
|
extension UIDevice {
|
||||||
var hasNotch: Bool {
|
var hasNotch: Bool {
|
||||||
let bottom = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.safeAreaInsets.bottom ?? 0
|
let bottom = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.safeAreaInsets.bottom ?? 0
|
||||||
|
|
|
@ -147,13 +147,17 @@ struct LibraryFilterView: View {
|
||||||
}
|
}
|
||||||
}.onAppear(perform: onAppear)
|
}.onAppear(perform: onAppear)
|
||||||
.navigationBarTitle("Filters", displayMode: .inline)
|
.navigationBarTitle("Filters", displayMode: .inline)
|
||||||
.navigationBarItems(leading: Button {
|
.toolbar {
|
||||||
|
ToolbarItemGroup(placement: .navigationBarLeading) {
|
||||||
|
Button {
|
||||||
presentationMode.wrappedValue.dismiss()
|
presentationMode.wrappedValue.dismiss()
|
||||||
} label: {
|
} label: {
|
||||||
HStack {
|
HStack {
|
||||||
Text("Back").font(.callout)
|
Text("Back").font(.callout)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,12 @@ struct LibraryListView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.navigationTitle("All Media")
|
.navigationTitle("All Media")
|
||||||
.navigationBarItems(trailing:
|
.toolbar {
|
||||||
|
ToolbarItemGroup(placement: .navigationBarTrailing) {
|
||||||
NavigationLink(destination: LazyView { LibrarySearchView(viewModel: .init(filter: .init())) }) {
|
NavigationLink(destination: LazyView { LibrarySearchView(viewModel: .init(filter: .init())) }) {
|
||||||
Image(systemName: "magnifyingglass")
|
Image(systemName: "magnifyingglass")
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ struct LibrarySearchView: View {
|
||||||
var horizontalSizeClass: UserInterfaceSizeClass?
|
var horizontalSizeClass: UserInterfaceSizeClass?
|
||||||
|
|
||||||
func onAppear() {
|
func onAppear() {
|
||||||
|
guard viewModel.globalData != globalData else { return }
|
||||||
recalcTracks()
|
recalcTracks()
|
||||||
viewModel.globalData = globalData
|
viewModel.globalData = globalData
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ struct LibraryView: View {
|
||||||
@State
|
@State
|
||||||
private var showFiltersPopover: Bool = false
|
private var showFiltersPopover: Bool = false
|
||||||
@State
|
@State
|
||||||
private var showSearchPopover: Bool = false
|
private var showingSearchView: Bool = false
|
||||||
|
|
||||||
private var title: String
|
private var title: String
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ struct LibraryView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
func onAppear() {
|
func onAppear() {
|
||||||
|
guard viewModel.globalData != globalData else { return }
|
||||||
recalcTracks()
|
recalcTracks()
|
||||||
viewModel.globalData = globalData
|
viewModel.globalData = globalData
|
||||||
}
|
}
|
||||||
|
@ -78,10 +79,11 @@ struct LibraryView: View {
|
||||||
Text("Empty Response")
|
Text("Empty Response")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.overrideViewPreference(.unspecified)
|
// .overrideViewPreference(.unspecified)
|
||||||
.onAppear(perform: onAppear)
|
.onAppear(perform: onAppear)
|
||||||
.navigationTitle(title)
|
.navigationTitle(title)
|
||||||
.navigationBarItems(trailing: HStack {
|
.toolbar {
|
||||||
|
ToolbarItemGroup(placement: .navigationBarTrailing) {
|
||||||
if !viewModel.isHiddenPreviousButton {
|
if !viewModel.isHiddenPreviousButton {
|
||||||
Button {
|
Button {
|
||||||
viewModel.requestPreviousPage()
|
viewModel.requestPreviousPage()
|
||||||
|
@ -104,7 +106,8 @@ struct LibraryView: View {
|
||||||
} label: {
|
} label: {
|
||||||
Image(systemName: "line.horizontal.3.decrease")
|
Image(systemName: "line.horizontal.3.decrease")
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
}
|
||||||
.sheet(isPresented: self.$showFiltersPopover) {
|
.sheet(isPresented: self.$showFiltersPopover) {
|
||||||
LibraryFilterView(library: viewModel.filter.parentID ?? "", filter: $viewModel.filter)
|
LibraryFilterView(library: viewModel.filter.parentID ?? "", filter: $viewModel.filter)
|
||||||
.environmentObject(self.globalData)
|
.environmentObject(self.globalData)
|
||||||
|
|
|
@ -5,34 +5,44 @@
|
||||||
// Created by Aiden Vigue on 4/29/21.
|
// Created by Aiden Vigue on 4/29/21.
|
||||||
//
|
//
|
||||||
|
|
||||||
import SwiftUI
|
|
||||||
import CoreData
|
import CoreData
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
struct SettingsView: View {
|
struct SettingsView: View {
|
||||||
@ObservedObject var viewModel: SettingsViewModel
|
@ObservedObject
|
||||||
|
var viewModel: SettingsViewModel
|
||||||
|
|
||||||
@Binding var close: Bool;
|
@Binding
|
||||||
@Environment(\.managedObjectContext) private var viewContext
|
var close: Bool
|
||||||
@EnvironmentObject var globalData: GlobalData
|
@Environment(\.managedObjectContext)
|
||||||
@EnvironmentObject var jsi: justSignedIn
|
private var viewContext
|
||||||
@State private var username: String = "";
|
@EnvironmentObject
|
||||||
@State private var inNetworkStreamBitrate: Int = 40000000;
|
var globalData: GlobalData
|
||||||
@State private var outOfNetworkStreamBitrate: Int = 40000000;
|
@EnvironmentObject
|
||||||
@State private var autoSelectSubtitles: Bool = false;
|
var jsi: justSignedIn
|
||||||
@State private var autoSelectSubtitlesLangcode: String = "none";
|
@State
|
||||||
|
private var username: String = ""
|
||||||
|
@State
|
||||||
|
private var inNetworkStreamBitrate: Int = 40_000_000
|
||||||
|
@State
|
||||||
|
private var outOfNetworkStreamBitrate: Int = 40_000_000
|
||||||
|
@State
|
||||||
|
private var autoSelectSubtitles: Bool = false
|
||||||
|
@State
|
||||||
|
private var autoSelectSubtitlesLangcode: String = "none"
|
||||||
|
|
||||||
func onAppear() {
|
func onAppear() {
|
||||||
_username.wrappedValue = globalData.user?.username ?? "";
|
_username.wrappedValue = globalData.user?.username ?? ""
|
||||||
let defaults = UserDefaults.standard
|
let defaults = UserDefaults.standard
|
||||||
_inNetworkStreamBitrate.wrappedValue = defaults.integer(forKey: "InNetworkBandwidth");
|
_inNetworkStreamBitrate.wrappedValue = defaults.integer(forKey: "InNetworkBandwidth")
|
||||||
_outOfNetworkStreamBitrate.wrappedValue = defaults.integer(forKey: "OutOfNetworkBandwidth");
|
_outOfNetworkStreamBitrate.wrappedValue = defaults.integer(forKey: "OutOfNetworkBandwidth")
|
||||||
_autoSelectSubtitles.wrappedValue = defaults.bool(forKey: "AutoSelectSubtitles");
|
_autoSelectSubtitles.wrappedValue = defaults.bool(forKey: "AutoSelectSubtitles")
|
||||||
_autoSelectSubtitlesLangcode.wrappedValue = defaults.string(forKey: "AutoSelectSubtitlesLangcode") ?? "";
|
_autoSelectSubtitlesLangcode.wrappedValue = defaults.string(forKey: "AutoSelectSubtitlesLangcode") ?? ""
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationView() {
|
NavigationView {
|
||||||
Form() {
|
Form {
|
||||||
Section(header: Text("Playback settings")) {
|
Section(header: Text("Playback settings")) {
|
||||||
Picker("Default local quality", selection: $inNetworkStreamBitrate) {
|
Picker("Default local quality", selection: $inNetworkStreamBitrate) {
|
||||||
ForEach(self.viewModel.bitrates, id: \.self) { bitrate in
|
ForEach(self.viewModel.bitrates, id: \.self) { bitrate in
|
||||||
|
@ -58,13 +68,11 @@ struct SettingsView: View {
|
||||||
let defaults = UserDefaults.standard
|
let defaults = UserDefaults.standard
|
||||||
defaults.setValue(autoSelectSubtitles, forKey: "AutoSelectSubtitles")
|
defaults.setValue(autoSelectSubtitles, forKey: "AutoSelectSubtitles")
|
||||||
})
|
})
|
||||||
Picker("Language preferences", selection: $autoSelectSubtitlesLangcode) {
|
Picker("Language preferences", selection: $autoSelectSubtitlesLangcode) {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Section() {
|
Section {
|
||||||
HStack() {
|
HStack {
|
||||||
Text("Signed in as \(username)").foregroundColor(.primary)
|
Text("Signed in as \(username)").foregroundColor(.primary)
|
||||||
Spacer()
|
Spacer()
|
||||||
Button {
|
Button {
|
||||||
|
@ -101,14 +109,15 @@ struct SettingsView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
.navigationBarTitle("Settings", displayMode: .inline)
|
.navigationBarTitle("Settings", displayMode: .inline)
|
||||||
.navigationBarItems(leading:
|
.toolbar {
|
||||||
|
ToolbarItemGroup(placement: .navigationBarLeading) {
|
||||||
Button {
|
Button {
|
||||||
close = false
|
close = false
|
||||||
} label: {
|
} label: {
|
||||||
HStack() {
|
|
||||||
Text("Back").font(.callout)
|
Text("Back").font(.callout)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
}
|
||||||
}.onAppear(perform: onAppear)
|
}.onAppear(perform: onAppear)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue