Skip to content

Commit

Permalink
fix media staff grid scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
axiel7 committed Feb 5, 2024
1 parent 40b3f14 commit 5a29f14
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions AniHyou/Queries/MediaCharactersAndStaff.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ query MediaCharactersAndStaff($mediaId: Int) {
}

fragment MediaCharacter on CharacterEdge {
id
role
node {
id
Expand All @@ -36,6 +37,7 @@ fragment MediaCharacter on CharacterEdge {
}

fragment MediaStaff on StaffEdge {
id
role
node {
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct MediaCharactersAndStaffView: View {
let mediaId: Int
@StateObject private var viewModel = CharacterStaffViewModel()
private let gridRows = [
GridItem(.fixed(StaffView.imageSize), alignment: .leading),
GridItem(.fixed(StaffView.imageSize), spacing: 16, alignment: .leading),
GridItem(.fixed(StaffView.imageSize), alignment: .leading)
]

Expand Down Expand Up @@ -47,7 +47,7 @@ struct MediaCharactersAndStaffView: View {
var staffHScrollView: some View {
ScrollView(.horizontal, showsIndicators: false) {
LazyHGrid(rows: gridRows, spacing: 16) {
ForEach(viewModel.mediaCharactersAndStaff?.staff?.edges ?? [], id: \.?.node?.id) {
ForEach(viewModel.mediaCharactersAndStaff?.staff?.edges ?? [], id: \.?.id) {
if let staff = $0 {
StaffView(staff: staff.fragments.mediaStaff)
}
Expand Down
5 changes: 4 additions & 1 deletion AniListAPI/Sources/Fragments/MediaCharacter.graphql.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public struct MediaCharacter: AniListAPI.SelectionSet, Fragment {
public static var fragmentDefinition: StaticString {
#"fragment MediaCharacter on CharacterEdge { __typename role node { __typename id name { __typename userPreferred } image { __typename medium } } voiceActors(language: JAPANESE) { __typename id name { __typename userPreferred } image { __typename medium } } }"#
#"fragment MediaCharacter on CharacterEdge { __typename id role node { __typename id name { __typename userPreferred } image { __typename medium } } voiceActors(language: JAPANESE) { __typename id name { __typename userPreferred } image { __typename medium } } }"#
}

public let __data: DataDict
Expand All @@ -14,11 +14,14 @@ public struct MediaCharacter: AniListAPI.SelectionSet, Fragment {
public static var __parentType: ApolloAPI.ParentType { AniListAPI.Objects.CharacterEdge }
public static var __selections: [ApolloAPI.Selection] { [
.field("__typename", String.self),
.field("id", Int?.self),
.field("role", GraphQLEnum<AniListAPI.CharacterRole>?.self),
.field("node", Node?.self),
.field("voiceActors", [VoiceActor?]?.self, arguments: ["language": "JAPANESE"]),
] }

/// The id of the connection
public var id: Int? { __data["id"] }
/// The characters role in the media
public var role: GraphQLEnum<AniListAPI.CharacterRole>? { __data["role"] }
public var node: Node? { __data["node"] }
Expand Down
5 changes: 4 additions & 1 deletion AniListAPI/Sources/Fragments/MediaStaff.graphql.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public struct MediaStaff: AniListAPI.SelectionSet, Fragment {
public static var fragmentDefinition: StaticString {
#"fragment MediaStaff on StaffEdge { __typename role node { __typename id name { __typename userPreferred } image { __typename medium } } }"#
#"fragment MediaStaff on StaffEdge { __typename id role node { __typename id name { __typename userPreferred } image { __typename medium } } }"#
}

public let __data: DataDict
Expand All @@ -14,10 +14,13 @@ public struct MediaStaff: AniListAPI.SelectionSet, Fragment {
public static var __parentType: ApolloAPI.ParentType { AniListAPI.Objects.StaffEdge }
public static var __selections: [ApolloAPI.Selection] { [
.field("__typename", String.self),
.field("id", Int?.self),
.field("role", String?.self),
.field("node", Node?.self),
] }

/// The id of the connection
public var id: Int? { __data["id"] }
/// The role of the staff member in the production of the media
public var role: String? { __data["role"] }
public var node: Node? { __data["node"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public class MediaCharactersAndStaffQuery: GraphQLQuery {
.fragment(MediaCharacter.self),
] }

/// The id of the connection
public var id: Int? { __data["id"] }
/// The characters role in the media
public var role: GraphQLEnum<AniListAPI.CharacterRole>? { __data["role"] }
public var node: Node? { __data["node"] }
Expand Down Expand Up @@ -133,6 +135,8 @@ public class MediaCharactersAndStaffQuery: GraphQLQuery {
.fragment(MediaStaff.self),
] }

/// The id of the connection
public var id: Int? { __data["id"] }
/// The role of the staff member in the production of the media
public var role: String? { __data["role"] }
public var node: Node? { __data["node"] }
Expand Down

0 comments on commit 5a29f14

Please sign in to comment.