Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update staff media list toggle to menu #26

Merged
merged 4 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,15 @@ class StaffDetailsViewModel: ObservableObject {
})
}

@Published var mediaOnMyList = false
@Published var mediaOnMyList: Bool?
@Published var staffMedia = [StaffMediaGrouped]()
var pageMedia = 1
var hasNextPageMedia = true

func getStaffMedia(staffId: Int) {
var mediaOnListValue = GraphQLNullable<Bool>.none
if mediaOnMyList { mediaOnListValue = .some(true) }
Network.shared.apollo.fetch(query: StaffMediaQuery(
staffId: .some(staffId),
onList: mediaOnListValue,
onList: someIfNotNil(mediaOnMyList),
page: .some(pageMedia),
perPage: .some(25)
)) { [weak self] result in
Expand Down
13 changes: 9 additions & 4 deletions AniHyou/Screens/StaffDetails/Views/StaffDetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,15 @@ struct StaffDetailsView: View {
@ViewBuilder
var staffMedia: some View {
LazyVStack(alignment: .leading) {
Toggle("On my list", isOn: $viewModel.mediaOnMyList)
HStack {
Text("On my list")
Spacer()
TriPicker("On my list", selection: $viewModel.mediaOnMyList)
.onChange(of: viewModel.mediaOnMyList) { _ in
viewModel.resetStaffMedia()
}
}

ForEach(viewModel.staffMedia, id: \.value.id) { item in
if let media = item.value.node {
NavigationLink(destination: MediaDetailsView(mediaId: media.id)) {
Expand All @@ -136,9 +144,6 @@ struct StaffDetailsView: View {
}
}//:LazyVStack
.padding(.horizontal)
.onChange(of: viewModel.mediaOnMyList) { _ in
viewModel.resetStaffMedia()
}
}

@ViewBuilder
Expand Down