Merge pull request #69 from jellyfin/create-pull-request/patch
[ci] SwiftLint
This commit is contained in:
commit
f3cc44f39f
|
@ -10,8 +10,8 @@
|
|||
import SwiftUI
|
||||
import JellyfinAPI
|
||||
|
||||
fileprivate struct CutOffShadow: Shape {
|
||||
let radius = 6.0;
|
||||
private struct CutOffShadow: Shape {
|
||||
let radius = 6.0
|
||||
|
||||
func path(in rect: CGRect) -> Path {
|
||||
var path = Path()
|
||||
|
@ -38,22 +38,22 @@ fileprivate struct CutOffShadow: Shape {
|
|||
|
||||
struct LandscapeItemElement: View {
|
||||
@Environment(\.isFocused) var envFocused: Bool
|
||||
@State var focused: Bool = false;
|
||||
@State var backgroundURL: URL?;
|
||||
@State var focused: Bool = false
|
||||
@State var backgroundURL: URL?
|
||||
|
||||
var item: BaseItemDto;
|
||||
var item: BaseItemDto
|
||||
|
||||
var body: some View {
|
||||
VStack() {
|
||||
VStack {
|
||||
ImageView(src: (item.type == "Episode" ? item.getSeriesBackdropImage(maxWidth: 445) : item.getBackdropImage(maxWidth: 445)), bh: item.type == "Episode" ? item.getSeriesBackdropImageBlurHash() : item.getBackdropImageBlurHash())
|
||||
.frame(width: 445, height: 250)
|
||||
.cornerRadius(10)
|
||||
.overlay(
|
||||
Group {
|
||||
if(focused && item.userData?.playedPercentage != nil) {
|
||||
if focused && item.userData?.playedPercentage != nil {
|
||||
ZStack(alignment: .leading) {
|
||||
Rectangle()
|
||||
.fill(LinearGradient(colors: [.black,.clear], startPoint: .bottom, endPoint: .top))
|
||||
.fill(LinearGradient(colors: [.black, .clear], startPoint: .bottom, endPoint: .top))
|
||||
.frame(width: 445, height: 90)
|
||||
.mask(CutOffShadow())
|
||||
VStack(alignment: .leading) {
|
||||
|
@ -79,7 +79,7 @@ struct LandscapeItemElement: View {
|
|||
)
|
||||
.shadow(radius: focused ? 10.0 : 0, y: focused ? 10.0 : 0)
|
||||
.shadow(radius: focused ? 10.0 : 0, y: focused ? 10.0 : 0)
|
||||
if(focused) {
|
||||
if focused {
|
||||
Text(item.type == "Episode" ? "\(item.seriesName ?? "") • S\(String(item.parentIndexNumber ?? 0)):E\(String(item.indexNumber ?? 0))" : item.name ?? "")
|
||||
.font(.callout)
|
||||
.fontWeight(.semibold)
|
||||
|
@ -94,10 +94,10 @@ struct LandscapeItemElement: View {
|
|||
self.focused = envFocus
|
||||
}
|
||||
|
||||
if(envFocus == true) {
|
||||
if envFocus == true {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
// your code here
|
||||
if(self.focused == true) {
|
||||
if self.focused == true {
|
||||
backgroundURL = item.getBackdropImage(maxWidth: 1080)
|
||||
BackgroundManager.current.setBackground(to: backgroundURL!, hash: item.getBackdropImageBlurHash())
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
import SwiftUI
|
||||
import JellyfinAPI
|
||||
|
||||
fileprivate struct CutOffShadow: Shape {
|
||||
let radius = 6.0;
|
||||
private struct CutOffShadow: Shape {
|
||||
let radius = 6.0
|
||||
|
||||
func path(in rect: CGRect) -> Path {
|
||||
var path = Path()
|
||||
|
@ -38,13 +38,13 @@ fileprivate struct CutOffShadow: Shape {
|
|||
|
||||
struct PortraitItemElement: View {
|
||||
@Environment(\.isFocused) var envFocused: Bool
|
||||
@State var focused: Bool = false;
|
||||
@State var backgroundURL: URL?;
|
||||
@State var focused: Bool = false
|
||||
@State var backgroundURL: URL?
|
||||
|
||||
var item: BaseItemDto;
|
||||
var item: BaseItemDto
|
||||
|
||||
var body: some View {
|
||||
VStack() {
|
||||
VStack {
|
||||
ImageView(src: item.type == "Episode" ? item.getSeriesPrimaryImage(maxWidth: 200) : item.getPrimaryImage(maxWidth: 200), bh: item.type == "Episode" ? item.getSeriesPrimaryImageBlurHash() : item.getPrimaryImageBlurHash())
|
||||
.frame(width: 200, height: 300)
|
||||
.cornerRadius(10)
|
||||
|
@ -56,10 +56,10 @@ struct PortraitItemElement: View {
|
|||
self.focused = envFocus
|
||||
}
|
||||
|
||||
if(envFocus == true) {
|
||||
if envFocus == true {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
// your code here
|
||||
if(self.focused == true) {
|
||||
if self.focused == true {
|
||||
backgroundURL = item.getBackdropImage(maxWidth: 1080)
|
||||
BackgroundManager.current.setBackground(to: backgroundURL!, hash: item.getBackdropImageBlurHash())
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import CoreMedia
|
|||
|
||||
struct PublicUserButton: View {
|
||||
@Environment(\.isFocused) var envFocused: Bool
|
||||
@State var focused: Bool = false;
|
||||
@State var focused: Bool = false
|
||||
var publicUser: UserDto
|
||||
|
||||
var body: some View {
|
||||
|
@ -31,7 +31,7 @@ struct PublicUserButton: View {
|
|||
.cornerRadius(125.0)
|
||||
.shadow(radius: 6)
|
||||
}
|
||||
if(focused) {
|
||||
if focused {
|
||||
Text(publicUser.name ?? "").font(.headline).fontWeight(.semibold)
|
||||
} else {
|
||||
Spacer().frame(height: 60)
|
||||
|
|
|
@ -16,12 +16,12 @@ struct ConnectToServerView: View {
|
|||
if viewModel.isConnectedServer {
|
||||
if viewModel.publicUsers.isEmpty {
|
||||
Section(header: Text(viewModel.lastPublicUsers.isEmpty || viewModel.username == "" ? "Login to \(ServerEnvironment.current.server.name ?? "")": "")) {
|
||||
if(viewModel.lastPublicUsers.isEmpty || viewModel.username == "") {
|
||||
if viewModel.lastPublicUsers.isEmpty || viewModel.username == "" {
|
||||
TextField("Username", text: $viewModel.username)
|
||||
.disableAutocorrection(true)
|
||||
.autocapitalization(.none)
|
||||
} else {
|
||||
HStack() {
|
||||
HStack {
|
||||
Spacer()
|
||||
ImageView(src: URL(string: "\(ServerEnvironment.current.server.baseURI ?? "")/Users/\(viewModel.selectedPublicUser.id ?? "")/Images/Primary?width=500&quality=80&tag=\(viewModel.selectedPublicUser.primaryImageTag ?? "")")!)
|
||||
.frame(width: 250, height: 250)
|
||||
|
@ -36,9 +36,9 @@ struct ConnectToServerView: View {
|
|||
}
|
||||
|
||||
Section {
|
||||
HStack() {
|
||||
HStack {
|
||||
Button {
|
||||
if(!viewModel.lastPublicUsers.isEmpty) {
|
||||
if !viewModel.lastPublicUsers.isEmpty {
|
||||
viewModel.username = ""
|
||||
viewModel.showPublicUsers()
|
||||
} else {
|
||||
|
@ -66,11 +66,11 @@ struct ConnectToServerView: View {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
VStack() {
|
||||
HStack() {
|
||||
VStack {
|
||||
HStack {
|
||||
ForEach(viewModel.publicUsers, id: \.id) { publicUser in
|
||||
Button(action: {
|
||||
if(SessionManager.current.doesUserHaveSavedSession(userID: publicUser.id!)) {
|
||||
if SessionManager.current.doesUserHaveSavedSession(userID: publicUser.id!) {
|
||||
let user = SessionManager.current.getSavedSession(userID: publicUser.id!)
|
||||
SessionManager.current.loginWithSavedSession(user: user)
|
||||
} else {
|
||||
|
@ -87,7 +87,7 @@ struct ConnectToServerView: View {
|
|||
}.buttonStyle(PlainNavigationLinkButtonStyle())
|
||||
}
|
||||
}.padding(.bottom, 20)
|
||||
HStack() {
|
||||
HStack {
|
||||
Spacer()
|
||||
Button {
|
||||
viewModel.hidePublicUsers()
|
||||
|
|
|
@ -34,7 +34,7 @@ struct HomeView: View {
|
|||
let library = viewModel.libraries.first(where: { $0.id == libraryID })
|
||||
|
||||
NavigationLink(destination: Text("library_latest")) {
|
||||
HStack() {
|
||||
HStack {
|
||||
Text("Latest \(library?.name ?? "")")
|
||||
.font(.headline)
|
||||
.fontWeight(.semibold)
|
||||
|
|
|
@ -17,14 +17,14 @@ struct MainTabView: View {
|
|||
@State private var lastBackdropAnim: Bool = false
|
||||
|
||||
var body: some View {
|
||||
ZStack() {
|
||||
//please do not touch my magical crossfading. i will wave my magical github wand and cry
|
||||
if(viewModel.lastBackgroundURL != nil) {
|
||||
ZStack {
|
||||
// please do not touch my magical crossfading. i will wave my magical github wand and cry
|
||||
if viewModel.lastBackgroundURL != nil {
|
||||
ImageView(src: viewModel.lastBackgroundURL!, bh: viewModel.backgroundBlurHash)
|
||||
.frame(minWidth: 100, maxWidth: .infinity, minHeight: 100, maxHeight: .infinity)
|
||||
.opacity(lastBackdropAnim ? 0.4 : 0)
|
||||
}
|
||||
if(viewModel.backgroundURL != nil) {
|
||||
if viewModel.backgroundURL != nil {
|
||||
ImageView(src: viewModel.backgroundURL!, bh: viewModel.backgroundBlurHash)
|
||||
.frame(minWidth: 100, maxWidth: .infinity, minHeight: 100, maxHeight: .infinity)
|
||||
.opacity(backdropAnim ? 0.4 : 0)
|
||||
|
|
|
@ -15,7 +15,7 @@ struct SplashView: View {
|
|||
var body: some View {
|
||||
Group {
|
||||
if viewModel.isLoggedIn {
|
||||
NavigationView() {
|
||||
NavigationView {
|
||||
MainTabView()
|
||||
}.padding(.all, -1)
|
||||
} else {
|
||||
|
|
|
@ -19,7 +19,6 @@ struct SeasonItemView: View {
|
|||
var item: BaseItemDto = BaseItemDto()
|
||||
@State private var episodes: [BaseItemDto] = []
|
||||
|
||||
|
||||
@State private var isLoading: Bool = true
|
||||
@State private var viewDidLoad: Bool = false
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ struct SeriesItemView: View {
|
|||
|
||||
isLoading = true
|
||||
|
||||
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
TvShowsAPI.getSeasons(seriesId: item.id ?? "", fields: [.primaryImageAspectRatio, .seriesPrimaryImage, .seasonUserData, .overview, .genres, .people])
|
||||
.sink(receiveCompletion: { completion in
|
||||
|
|
|
@ -300,7 +300,7 @@ class PlayerViewController: UIViewController, VLCMediaDelegate, VLCMediaPlayerDe
|
|||
}, receiveValue: { [self] response in
|
||||
playSessionId = response.playSessionId ?? ""
|
||||
|
||||
if(response.mediaSources == nil) {
|
||||
if response.mediaSources == nil {
|
||||
delegate?.exitPlayer(self)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -34,4 +34,3 @@ final class BackgroundManager {
|
|||
nc.post(name: Notification.Name("backgroundDidChange"), object: nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ final class ServerEnvironment {
|
|||
let serverRequest = Server.fetchRequest()
|
||||
let servers = try? PersistenceController.shared.container.viewContext.fetch(serverRequest)
|
||||
|
||||
if(servers?.count != 0) {
|
||||
if servers?.count != 0 {
|
||||
server = servers?.first
|
||||
JellyfinAPI.basePath = server.baseURI!
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ final class ServerEnvironment {
|
|||
let serverRequest: NSFetchRequest<NSFetchRequestResult> = Server.fetchRequest()
|
||||
let deleteRequest = NSBatchDeleteRequest(fetchRequest: serverRequest)
|
||||
|
||||
//coredata will theoretically never throw
|
||||
// coredata will theoretically never throw
|
||||
_ = try? PersistenceController.shared.container.viewContext.execute(deleteRequest)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ final class SessionManager {
|
|||
let savedUsers = try? PersistenceController.shared.container.viewContext.fetch(savedUserRequest)
|
||||
|
||||
#if os(tvOS)
|
||||
savedUsers?.forEach() { savedUser in
|
||||
if(savedUser.appletv_id == tvUserManager.currentUserIdentifier ?? "") {
|
||||
savedUsers?.forEach { savedUser in
|
||||
if savedUser.appletv_id == tvUserManager.currentUserIdentifier ?? "" {
|
||||
self.user = savedUser
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ final class SessionManager {
|
|||
user = savedUsers?.first
|
||||
#endif
|
||||
|
||||
if(user != nil) {
|
||||
if user != nil {
|
||||
let authToken = getAuthToken(userID: user.user_id!)
|
||||
generateAuthHeader(with: authToken)
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ final class SessionManager {
|
|||
#endif
|
||||
header.append("Version=\"\(appVersion ?? "0.0.1")\", ")
|
||||
|
||||
if(authToken != nil) {
|
||||
if authToken != nil {
|
||||
header.append("Token=\"\(authToken!)\"")
|
||||
accessToken = authToken!
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ final class SessionManager {
|
|||
savedUserRequest.predicate = NSPredicate(format: "user_id == %@", userID)
|
||||
let savedUsers = try? PersistenceController.shared.container.viewContext.fetch(savedUserRequest)
|
||||
|
||||
if(savedUsers!.isEmpty) {
|
||||
if savedUsers!.isEmpty {
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ final class SessionManager {
|
|||
user.user_id = response.user?.id
|
||||
|
||||
#if os(tvOS)
|
||||
//user.appletv_id = tvUserManager.currentUserIdentifier ?? ""
|
||||
// user.appletv_id = tvUserManager.currentUserIdentifier ?? ""
|
||||
#endif
|
||||
|
||||
return (user, response.accessToken)
|
||||
|
|
|
@ -47,13 +47,13 @@ final class ConnectToServerViewModel: ViewModel {
|
|||
}
|
||||
|
||||
func hidePublicUsers() {
|
||||
self.lastPublicUsers = publicUsers;
|
||||
publicUsers = [];
|
||||
self.lastPublicUsers = publicUsers
|
||||
publicUsers = []
|
||||
}
|
||||
|
||||
func showPublicUsers() {
|
||||
self.publicUsers = lastPublicUsers;
|
||||
lastPublicUsers = [];
|
||||
self.publicUsers = lastPublicUsers
|
||||
lastPublicUsers = []
|
||||
}
|
||||
|
||||
func connectToServer() {
|
||||
|
@ -65,7 +65,7 @@ final class ConnectToServerViewModel: ViewModel {
|
|||
default:
|
||||
break
|
||||
}
|
||||
}, receiveValue: { response in
|
||||
}, receiveValue: { _ in
|
||||
self.getPublicUsers()
|
||||
})
|
||||
.store(in: &cancellables)
|
||||
|
|
|
@ -39,7 +39,7 @@ final class HomeViewModel: ViewModel {
|
|||
self.HandleAPIRequestCompletion(completion: completion)
|
||||
}, receiveValue: { response in
|
||||
response.items!.forEach { item in
|
||||
if(item.collectionType == "movies" || item.collectionType == "tvshows") {
|
||||
if item.collectionType == "movies" || item.collectionType == "tvshows" {
|
||||
self.libraries.append(item)
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ final class HomeViewModel: ViewModel {
|
|||
self.HandleAPIRequestCompletion(completion: completion)
|
||||
}, receiveValue: { response in
|
||||
self.libraries.forEach { library in
|
||||
if(!(response.configuration?.latestItemsExcludes?.contains(library.id!))!) {
|
||||
if !(response.configuration?.latestItemsExcludes?.contains(library.id!))! {
|
||||
self.librariesShowRecentlyAddedIDs.append(library.id!)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue