Merge pull request #84 from PangMo5/PangMo5/#81-fix

Fix #81
This commit is contained in:
aiden vigue 2021-06-21 23:48:33 -04:00 committed by GitHub
commit 0786988d96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 112 additions and 110 deletions

View File

@ -35,7 +35,6 @@ struct ContinueWatchingView: View {
var body: some View { var body: some View {
ScrollView(.horizontal, showsIndicators: false) { ScrollView(.horizontal, showsIndicators: false) {
if items.count > 0 {
LazyHStack { LazyHStack {
Spacer().frame(width: 14) Spacer().frame(width: 14)
ForEach(items, id: \.id) { item in ForEach(items, id: \.id) { item in
@ -82,4 +81,3 @@ struct ContinueWatchingView: View {
} }
} }
} }
}

View File

@ -16,15 +16,16 @@ struct HomeView: View {
@Environment(\.verticalSizeClass) var vSizeClass @Environment(\.verticalSizeClass) var vSizeClass
@State var showingSettings = false @State var showingSettings = false
var body: some View { @ViewBuilder
var innerBody: some View {
if(viewModel.isLoading) { if(viewModel.isLoading) {
ProgressView() ProgressView()
} else { } else {
ScrollView { ScrollView {
LazyVStack(alignment: .leading) { LazyVStack(alignment: .leading) {
Spacer().frame(height: hSizeClass == .compact && vSizeClass == .regular ? 0 : 16)
if !viewModel.resumeItems.isEmpty { if !viewModel.resumeItems.isEmpty {
ContinueWatchingView(items: viewModel.resumeItems) ContinueWatchingView(items: viewModel.resumeItems)
.padding(.top, hSizeClass == .compact && vSizeClass == .regular ? 0 : 16)
} }
if !viewModel.nextUpItems.isEmpty { if !viewModel.nextUpItems.isEmpty {
NextUpView(items: viewModel.nextUpItems) NextUpView(items: viewModel.nextUpItems)
@ -52,10 +53,15 @@ struct HomeView: View {
}.padding(EdgeInsets(top: 4, leading: 0, bottom: 0, trailing: 0)) }.padding(EdgeInsets(top: 4, leading: 0, bottom: 0, trailing: 0))
} }
} }
}
.padding(.top, hSizeClass == .compact && vSizeClass == .regular ? 0 : 16)
.padding(.bottom, UIDevice.current.userInterfaceIdiom == .phone ? 20 : 30)
}
}
}
Spacer().frame(height: UIDevice.current.userInterfaceIdiom == .phone ? 20 : 30) var body: some View {
} innerBody
}
.navigationTitle(MainTabView.Tab.home.localized) .navigationTitle(MainTabView.Tab.home.localized)
.toolbar { .toolbar {
ToolbarItemGroup(placement: .navigationBarTrailing) { ToolbarItemGroup(placement: .navigationBarTrailing) {
@ -71,4 +77,3 @@ struct HomeView: View {
} }
} }
} }
}

View File

@ -8,11 +8,10 @@
import SwiftUI import SwiftUI
struct LatestMediaView: View { struct LatestMediaView: View {
@StateObject var viewModel: LatestMediaViewModel @ObservedObject var viewModel: LatestMediaViewModel
var body: some View { var body: some View {
ScrollView(.horizontal, showsIndicators: false) { ScrollView(.horizontal, showsIndicators: false) {
ZStack {
LazyHStack { LazyHStack {
Spacer().frame(width: 16) Spacer().frame(width: 16)
ForEach(viewModel.items, id: \.id) { item in ForEach(viewModel.items, id: \.id) { item in
@ -43,7 +42,6 @@ struct LatestMediaView: View {
} }
} }
} }
}
.frame(height: 190) .frame(height: 190)
} }
.padding(EdgeInsets(top: -2, leading: 0, bottom: 0, trailing: 0)).frame(height: 190) .padding(EdgeInsets(top: -2, leading: 0, bottom: 0, trailing: 0)).frame(height: 190)

View File

@ -15,7 +15,6 @@ struct NextUpView: View {
var body: some View { var body: some View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
if items.count != 0 {
Text("Next Up") Text("Next Up")
.font(.title2) .font(.title2)
.fontWeight(.bold) .fontWeight(.bold)
@ -48,7 +47,6 @@ struct NextUpView: View {
} }
.frame(height: 200) .frame(height: 200)
} }
}
.padding(EdgeInsets(top: 4, leading: 0, bottom: 0, trailing: 0)) .padding(EdgeInsets(top: 4, leading: 0, bottom: 0, trailing: 0))
} }
} }

View File

@ -34,6 +34,7 @@ final class ConnectToServerViewModel: ViewModel {
func getPublicUsers() { func getPublicUsers() {
if ServerEnvironment.current.server != nil { if ServerEnvironment.current.server != nil {
UserAPI.getPublicUsers() UserAPI.getPublicUsers()
.trackActivity(loading)
.sink(receiveCompletion: { completion in .sink(receiveCompletion: { completion in
self.handleAPIRequestCompletion(completion: completion) self.handleAPIRequestCompletion(completion: completion)
}, receiveValue: { response in }, receiveValue: { response in
@ -56,6 +57,7 @@ final class ConnectToServerViewModel: ViewModel {
func connectToServer() { func connectToServer() {
ServerEnvironment.current.create(with: uriSubject.value) ServerEnvironment.current.create(with: uriSubject.value)
.trackActivity(loading)
.sink(receiveCompletion: { result in .sink(receiveCompletion: { result in
switch result { switch result {
case let .failure(error): case let .failure(error):
@ -71,6 +73,7 @@ final class ConnectToServerViewModel: ViewModel {
func login() { func login() {
SessionManager.current.login(username: usernameSubject.value, password: passwordSubject.value) SessionManager.current.login(username: usernameSubject.value, password: passwordSubject.value)
.trackActivity(loading)
.sink(receiveCompletion: { completion in .sink(receiveCompletion: { completion in
switch completion { switch completion {
case .finished: case .finished: