Merge pull request #141 from jellyfin/create-pull-request/patch
[ci] SwiftLint
This commit is contained in:
commit
1e883b3c17
|
@ -10,9 +10,9 @@
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct ServerDetailView: View {
|
struct ServerDetailView: View {
|
||||||
|
|
||||||
@ObservedObject var viewModel = ServerDetailViewModel()
|
@ObservedObject var viewModel = ServerDetailViewModel()
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Form {
|
Form {
|
||||||
Section(header: Text("")) {
|
Section(header: Text("")) {
|
||||||
|
@ -22,21 +22,21 @@ struct ServerDetailView: View {
|
||||||
Text(ServerEnvironment.current.server.name ?? "")
|
Text(ServerEnvironment.current.server.name ?? "")
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
}
|
}
|
||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
Text("URI")
|
Text("URI")
|
||||||
Spacer()
|
Spacer()
|
||||||
Text(ServerEnvironment.current.server.baseURI ?? "")
|
Text(ServerEnvironment.current.server.baseURI ?? "")
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
}
|
}
|
||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
Text("Version")
|
Text("Version")
|
||||||
Spacer()
|
Spacer()
|
||||||
Text(ServerEnvironment.current.server.version ?? "")
|
Text(ServerEnvironment.current.server.version ?? "")
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
}
|
}
|
||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
Text("Operating System")
|
Text("Operating System")
|
||||||
Spacer()
|
Spacer()
|
||||||
|
@ -44,7 +44,7 @@ struct ServerDetailView: View {
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Button(action: {
|
Button(action: {
|
||||||
viewModel.refreshServerLibrary()
|
viewModel.refreshServerLibrary()
|
||||||
}, label: {
|
}, label: {
|
||||||
|
|
|
@ -34,7 +34,7 @@ struct SettingsView: View {
|
||||||
Text(SessionManager.current.user.username ?? "")
|
Text(SessionManager.current.user.username ?? "")
|
||||||
.foregroundColor(.jellyfinPurple)
|
.foregroundColor(.jellyfinPurple)
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationLink(
|
NavigationLink(
|
||||||
destination: ServerDetailView(),
|
destination: ServerDetailView(),
|
||||||
label: {
|
label: {
|
||||||
|
@ -45,7 +45,7 @@ struct SettingsView: View {
|
||||||
.foregroundColor(.jellyfinPurple)
|
.foregroundColor(.jellyfinPurple)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
close = false
|
close = false
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
||||||
|
@ -70,13 +70,13 @@ struct SettingsView: View {
|
||||||
Text(bitrate.name).tag(bitrate.value)
|
Text(bitrate.name).tag(bitrate.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Picker("Jump Forward Length", selection: $jumpForwardLength) {
|
Picker("Jump Forward Length", selection: $jumpForwardLength) {
|
||||||
ForEach(self.viewModel.videoPlayerJumpLengths, id: \.self) { length in
|
ForEach(self.viewModel.videoPlayerJumpLengths, id: \.self) { length in
|
||||||
Text(length.label).tag(length.rawValue)
|
Text(length.label).tag(length.rawValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Picker("Jump Backward Length", selection: $jumpBackwardLength) {
|
Picker("Jump Backward Length", selection: $jumpBackwardLength) {
|
||||||
ForEach(self.viewModel.videoPlayerJumpLengths, id: \.self) { length in
|
ForEach(self.viewModel.videoPlayerJumpLengths, id: \.self) { length in
|
||||||
Text(length.label).tag(length.rawValue)
|
Text(length.label).tag(length.rawValue)
|
||||||
|
|
|
@ -83,12 +83,12 @@ class PlayerViewController: UIViewController, GCKDiscoveryManagerListener, GCKRe
|
||||||
var jumpBackwardLength: VideoPlayerJumpLength {
|
var jumpBackwardLength: VideoPlayerJumpLength {
|
||||||
return Defaults[.videoPlayerJumpBackward]
|
return Defaults[.videoPlayerJumpBackward]
|
||||||
}
|
}
|
||||||
|
|
||||||
var manifest: BaseItemDto = BaseItemDto()
|
var manifest: BaseItemDto = BaseItemDto()
|
||||||
var playbackItem = PlaybackItem()
|
var playbackItem = PlaybackItem()
|
||||||
var remoteTimeUpdateTimer: Timer?
|
var remoteTimeUpdateTimer: Timer?
|
||||||
var upNextViewModel: UpNextViewModel = UpNextViewModel()
|
var upNextViewModel: UpNextViewModel = UpNextViewModel()
|
||||||
var lastOri: UIInterfaceOrientation? = nil
|
var lastOri: UIInterfaceOrientation?
|
||||||
|
|
||||||
// MARK: IBActions
|
// MARK: IBActions
|
||||||
@IBAction func seekSliderStart(_ sender: Any) {
|
@IBAction func seekSliderStart(_ sender: Any) {
|
||||||
|
@ -104,24 +104,24 @@ class PlayerViewController: UIViewController, GCKDiscoveryManagerListener, GCKRe
|
||||||
let videoDuration: Double = Double(manifest.runTimeTicks! / Int64(10_000_000))
|
let videoDuration: Double = Double(manifest.runTimeTicks! / Int64(10_000_000))
|
||||||
let secondsScrubbedTo = round(Double(seekSlider.value) * videoDuration)
|
let secondsScrubbedTo = round(Double(seekSlider.value) * videoDuration)
|
||||||
let secondsScrubbedRemaining = videoDuration - secondsScrubbedTo
|
let secondsScrubbedRemaining = videoDuration - secondsScrubbedTo
|
||||||
|
|
||||||
timeText.text = calculateTimeText(from: secondsScrubbedTo)
|
timeText.text = calculateTimeText(from: secondsScrubbedTo)
|
||||||
timeLeftText.text = calculateTimeText(from: secondsScrubbedRemaining)
|
timeLeftText.text = calculateTimeText(from: secondsScrubbedRemaining)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func calculateTimeText(from duration: Double) -> String {
|
private func calculateTimeText(from duration: Double) -> String {
|
||||||
let hours = floor(duration / 3600)
|
let hours = floor(duration / 3600)
|
||||||
let minutes = (duration.truncatingRemainder(dividingBy: 3600)) / 60
|
let minutes = (duration.truncatingRemainder(dividingBy: 3600)) / 60
|
||||||
let seconds = (duration.truncatingRemainder(dividingBy: 3600)).truncatingRemainder(dividingBy: 60)
|
let seconds = (duration.truncatingRemainder(dividingBy: 3600)).truncatingRemainder(dividingBy: 60)
|
||||||
|
|
||||||
let timeText: String
|
let timeText: String
|
||||||
|
|
||||||
if hours != 0 {
|
if hours != 0 {
|
||||||
timeText = "\(Int(hours)):\(String(Int(floor(minutes))).leftPad(toWidth: 2, withString: "0")):\(String(Int(floor(seconds))).leftPad(toWidth: 2, withString: "0"))"
|
timeText = "\(Int(hours)):\(String(Int(floor(minutes))).leftPad(toWidth: 2, withString: "0")):\(String(Int(floor(seconds))).leftPad(toWidth: 2, withString: "0"))"
|
||||||
} else {
|
} else {
|
||||||
timeText = "\(String(Int(floor(minutes))).leftPad(toWidth: 2, withString: "0")):\(String(Int(floor(seconds))).leftPad(toWidth: 2, withString: "0"))"
|
timeText = "\(String(Int(floor(minutes))).leftPad(toWidth: 2, withString: "0")):\(String(Int(floor(seconds))).leftPad(toWidth: 2, withString: "0"))"
|
||||||
}
|
}
|
||||||
|
|
||||||
return timeText
|
return timeText
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,8 +417,8 @@ class PlayerViewController: UIViewController, GCKDiscoveryManagerListener, GCKRe
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.lastOri = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation ?? nil
|
self.lastOri = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation ?? nil
|
||||||
AppDelegate.orientationLock = .landscape
|
AppDelegate.orientationLock = .landscape
|
||||||
|
|
||||||
if(self.lastOri != nil) {
|
if self.lastOri != nil {
|
||||||
if !self.lastOri!.isLandscape {
|
if !self.lastOri!.isLandscape {
|
||||||
UIDevice.current.setValue(UIInterfaceOrientation.landscapeRight.rawValue, forKey: "orientation")
|
UIDevice.current.setValue(UIInterfaceOrientation.landscapeRight.rawValue, forKey: "orientation")
|
||||||
UIViewController.attemptRotationToDeviceOrientation()
|
UIViewController.attemptRotationToDeviceOrientation()
|
||||||
|
@ -470,7 +470,7 @@ class PlayerViewController: UIViewController, GCKDiscoveryManagerListener, GCKRe
|
||||||
self.navigationController?.isNavigationBarHidden = false
|
self.navigationController?.isNavigationBarHidden = false
|
||||||
overrideUserInterfaceStyle = .unspecified
|
overrideUserInterfaceStyle = .unspecified
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if(self.lastOri != nil) {
|
if self.lastOri != nil {
|
||||||
AppDelegate.orientationLock = .all
|
AppDelegate.orientationLock = .all
|
||||||
UIDevice.current.setValue(self.lastOri!.rawValue, forKey: "orientation")
|
UIDevice.current.setValue(self.lastOri!.rawValue, forKey: "orientation")
|
||||||
UIViewController.attemptRotationToDeviceOrientation()
|
UIViewController.attemptRotationToDeviceOrientation()
|
||||||
|
@ -625,7 +625,7 @@ class PlayerViewController: UIViewController, GCKDiscoveryManagerListener, GCKRe
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setupJumpLengthButtons() {
|
private func setupJumpLengthButtons() {
|
||||||
let buttonFont = UIFont.systemFont(ofSize: 35, weight: .regular)
|
let buttonFont = UIFont.systemFont(ofSize: 35, weight: .regular)
|
||||||
jumpForwardButton.setImage(jumpForwardLength.generateForwardImage(with: buttonFont), for: .normal)
|
jumpForwardButton.setImage(jumpForwardLength.generateForwardImage(with: buttonFont), for: .normal)
|
||||||
|
@ -804,7 +804,7 @@ extension PlayerViewController: GCKGenericChannelDelegate {
|
||||||
if isSeeking == false {
|
if isSeeking == false {
|
||||||
let positiveSeconds = Double(remotePositionTicks/10_000_000)
|
let positiveSeconds = Double(remotePositionTicks/10_000_000)
|
||||||
let remainingSeconds = Double((manifest.runTimeTicks! - Int64(remotePositionTicks))/10_000_000)
|
let remainingSeconds = Double((manifest.runTimeTicks! - Int64(remotePositionTicks))/10_000_000)
|
||||||
|
|
||||||
timeText.text = calculateTimeText(from: positiveSeconds)
|
timeText.text = calculateTimeText(from: positiveSeconds)
|
||||||
timeLeftText.text = calculateTimeText(from: remainingSeconds)
|
timeLeftText.text = calculateTimeText(from: remainingSeconds)
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ class VideoPlayerSettingsView: UINavigationController {
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
self.viewControllers = [UIHostingController(rootView: VideoPlayerSettings(delegate: self.playerDelegate ?? PlayerViewController()))]
|
self.viewControllers = [UIHostingController(rootView: VideoPlayerSettings(delegate: self.playerDelegate ?? PlayerViewController()))]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
extension Color {
|
extension Color {
|
||||||
|
|
||||||
static let jellyfinPurple = Color(red: 172 / 255, green: 92 / 255, blue: 195 / 255)
|
static let jellyfinPurple = Color(red: 172 / 255, green: 92 / 255, blue: 195 / 255)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,18 +14,18 @@ enum VideoPlayerJumpLength: Int32, CaseIterable, Defaults.Serializable {
|
||||||
case thirty = 30
|
case thirty = 30
|
||||||
case fifteen = 15
|
case fifteen = 15
|
||||||
case ten = 10
|
case ten = 10
|
||||||
|
|
||||||
// TODO - Uncomment once iOS 15 released
|
// TODO - Uncomment once iOS 15 released
|
||||||
// case five = 5
|
// case five = 5
|
||||||
|
|
||||||
var label: String {
|
var label: String {
|
||||||
return "\(self.rawValue) seconds"
|
return "\(self.rawValue) seconds"
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateForwardImage(with font: UIFont) -> UIImage {
|
func generateForwardImage(with font: UIFont) -> UIImage {
|
||||||
let config = UIImage.SymbolConfiguration(font: font)
|
let config = UIImage.SymbolConfiguration(font: font)
|
||||||
let systemName: String
|
let systemName: String
|
||||||
|
|
||||||
switch self {
|
switch self {
|
||||||
case .thirty:
|
case .thirty:
|
||||||
systemName = "goforward.30"
|
systemName = "goforward.30"
|
||||||
|
@ -36,14 +36,14 @@ enum VideoPlayerJumpLength: Int32, CaseIterable, Defaults.Serializable {
|
||||||
// case .five:
|
// case .five:
|
||||||
// systemName = "goforward.5"
|
// systemName = "goforward.5"
|
||||||
}
|
}
|
||||||
|
|
||||||
return UIImage(systemName: systemName, withConfiguration: config)!
|
return UIImage(systemName: systemName, withConfiguration: config)!
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateBackwardImage(with font: UIFont) -> UIImage {
|
func generateBackwardImage(with font: UIFont) -> UIImage {
|
||||||
let config = UIImage.SymbolConfiguration(font: font)
|
let config = UIImage.SymbolConfiguration(font: font)
|
||||||
let systemName: String
|
let systemName: String
|
||||||
|
|
||||||
switch self {
|
switch self {
|
||||||
case .thirty:
|
case .thirty:
|
||||||
systemName = "gobackward.30"
|
systemName = "gobackward.30"
|
||||||
|
@ -54,7 +54,7 @@ enum VideoPlayerJumpLength: Int32, CaseIterable, Defaults.Serializable {
|
||||||
// case .five:
|
// case .five:
|
||||||
// systemName = "gobackward.5"
|
// systemName = "gobackward.5"
|
||||||
}
|
}
|
||||||
|
|
||||||
return UIImage(systemName: systemName, withConfiguration: config)!
|
return UIImage(systemName: systemName, withConfiguration: config)!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import Foundation
|
||||||
import JellyfinAPI
|
import JellyfinAPI
|
||||||
|
|
||||||
class ServerDetailViewModel: ViewModel {
|
class ServerDetailViewModel: ViewModel {
|
||||||
|
|
||||||
func refreshServerLibrary() {
|
func refreshServerLibrary() {
|
||||||
LibraryAPI.refreshLibrary()
|
LibraryAPI.refreshLibrary()
|
||||||
.trackActivity(loading)
|
.trackActivity(loading)
|
||||||
|
|
Loading…
Reference in New Issue