Skip to content

Commit

Permalink
feat: update staff media list toggle to menu
Browse files Browse the repository at this point in the history
  • Loading branch information
BitForger (Noah) committed Feb 6, 2024
1 parent 5a29f14 commit ed192d1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
4 changes: 4 additions & 0 deletions AniHyou.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
48FC947F2868C0BD00C87F56 /* ExploreViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48FC947E2868C0BD00C87F56 /* ExploreViewModel.swift */; };
48FC94812868C0F400C87F56 /* MediaChartListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48FC94802868C0F400C87F56 /* MediaChartListView.swift */; };
48FC94832868C6DB00C87F56 /* ChartListItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48FC94822868C6DB00C87F56 /* ChartListItemView.swift */; };
842A0ECD2B71BC0F00FC635D /* Enums.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842A0ECC2B71BC0F00FC635D /* Enums.swift */; };
84734AE62A7DF658000BD9E6 /* MediaListRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84734AE52A7DF658000BD9E6 /* MediaListRepository.swift */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -585,6 +586,7 @@
48FC947E2868C0BD00C87F56 /* ExploreViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExploreViewModel.swift; sourceTree = "<group>"; };
48FC94802868C0F400C87F56 /* MediaChartListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaChartListView.swift; sourceTree = "<group>"; };
48FC94822868C6DB00C87F56 /* ChartListItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChartListItemView.swift; sourceTree = "<group>"; };
842A0ECC2B71BC0F00FC635D /* Enums.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Enums.swift; sourceTree = "<group>"; };
84734AE52A7DF658000BD9E6 /* MediaListRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaListRepository.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -651,6 +653,7 @@
isa = PBXGroup;
children = (
480300D2291BC56E00E3047B /* StaffDetailsViewModel.swift */,
842A0ECC2B71BC0F00FC635D /* Enums.swift */,
);
path = ViewModels;
sourceTree = "<group>";
Expand Down Expand Up @@ -1973,6 +1976,7 @@
48AB01F8286B724A004DC7FF /* SearchViewModel.swift in Sources */,
484E88402A77E88B007E59E1 /* HorizontalProgressView.swift in Sources */,
484A6D64287480FB0044C34A /* ReviewItemView.swift in Sources */,
842A0ECD2B71BC0F00FC635D /* Enums.swift in Sources */,
4832B029285F27E000E79D27 /* MediaDetailsViewModel.swift in Sources */,
481AD4F82851D927001779EE /* DiscoverViewModel.swift in Sources */,
48CA07AD28703BE60048854E /* MediaGeneralInfoView.swift in Sources */,
Expand Down
27 changes: 27 additions & 0 deletions AniHyou/Screens/StaffDetails/ViewModels/Enums.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Enums.swift
// AniHyou
//
// Created by Noah Kovacs on 2/5/24.
//

import Foundation
import SwiftUI

public enum StaffOnList: String, Equatable, CaseIterable {
case yes
case no

Check failure on line 13 in AniHyou/Screens/StaffDetails/ViewModels/Enums.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Identifier Name Violation: Enum element name 'no' should be between 3 and 40 characters long (identifier_name)

Check warning on line 13 in AniHyou/Screens/StaffDetails/ViewModels/Enums.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Identifier Name Violation: Enum element name 'no' should be between 3 and 40 characters long (identifier_name)
case none

var localizedName: LocalizedStringKey {
switch self {
case .yes:
return "Yes"
case .no:
return "No"
case .none:
return "None"
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,21 @@ class StaffDetailsViewModel: ObservableObject {
})
}

@Published var mediaOnMyList = false
@Published var mediaOnMyList = StaffOnList.none
@Published var staffMedia = [StaffMediaGrouped]()
var pageMedia = 1
var hasNextPageMedia = true

func getStaffMedia(staffId: Int) {
var mediaOnListValue = GraphQLNullable<Bool>.none
if mediaOnMyList { mediaOnListValue = .some(true) }
var mediaOnListValue: GraphQLNullable<Bool>
switch mediaOnMyList {
case .yes:
mediaOnListValue = true
case .no:
mediaOnListValue = false
case .none:
mediaOnListValue = GraphQLNullable<Bool>.none
}
Network.shared.apollo.fetch(query: StaffMediaQuery(
staffId: .some(staffId),
onList: mediaOnListValue,
Expand Down
10 changes: 9 additions & 1 deletion 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")
Picker("On my list", selection: $viewModel.mediaOnMyList) {
ForEach(StaffOnList.allCases, id: \.self) { onListSelection in
Text(onListSelection.localizedName).tag(onListSelection)
}
}
}

ForEach(viewModel.staffMedia, id: \.value.id) { item in
if let media = item.value.node {
NavigationLink(destination: MediaDetailsView(mediaId: media.id)) {
Expand Down

0 comments on commit ed192d1

Please sign in to comment.