Skip to content

Commit

Permalink
Merge pull request #534 from shimastripe/feature/sponsor-ios
Browse files Browse the repository at this point in the history
  • Loading branch information
shin-usu authored Aug 17, 2024
2 parents 8e2f9c8 + 09339b4 commit 4074a08
Showing 1 changed file with 30 additions and 40 deletions.
70 changes: 30 additions & 40 deletions app-ios/Sources/SponsorFeature/SponsorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,21 @@ public struct SponsorView: View {
.foregroundStyle(AssetColors.Primary.primaryFixed.swiftUIColor)
.frame(maxWidth: .infinity, alignment: .leading)

ForEach(store.platinums, id: \.id) { platinum in
Button {
selectedSponsorData = platinum
} label: {
AsyncImage(url: platinum.logo) {
$0.image?
.resizable()
.scaledToFit()
}
.frame(height: 110)
}
}
makeSponsorGrid(columnCount: 1, items: store.platinums, imageHeight: 110)

Text("GOLD SPONSORS")
.textStyle(.headlineSmall)
.foregroundStyle(AssetColors.Primary.primaryFixed.swiftUIColor)
.frame(maxWidth: .infinity, alignment: .leading)

LazyVGrid(columns: Array(repeating: .init(.fixed(184)), count: 2)) {
ForEach(store.golds, id: \.id) { gold in
Button {
selectedSponsorData = gold
} label: {
AsyncImage(url: gold.logo) {
$0.image?
.resizable()
.scaledToFit()
}
.frame(height: 80)
}
}
}
makeSponsorGrid(columnCount: 2, items: store.golds, imageHeight: 77)

Text("SUPPORTERS")
.textStyle(.headlineSmall)
.foregroundStyle(AssetColors.Primary.primaryFixed.swiftUIColor)
.frame(maxWidth: .infinity, alignment: .leading)

LazyVGrid(columns: Array(repeating: .init(.fixed(118)), count: 3)) {
ForEach(store.supporters, id: \.id) { supporter in
Button {
selectedSponsorData = supporter
} label: {
AsyncImage(url: supporter.logo) {
$0.image?
.resizable()
.scaledToFit()
}
.frame(height: 80)
}
}
}
makeSponsorGrid(columnCount: 3, items: store.supporters, imageHeight: 77)
}
.padding(16)
}
Expand All @@ -80,6 +43,33 @@ public struct SponsorView: View {
.navigationBarTitleDisplayMode(.large)
.navigationTitle(String(localized: "Sponsor", bundle: .module))
}

@ViewBuilder
func makeSponsorGrid(columnCount: Int, items: [SponsorData], imageHeight: Double) -> some View {
let gridItems = (1...columnCount)
.map { _ in
GridItem(.flexible(), spacing: 12, alignment: .center)
}
LazyVGrid(columns: gridItems, spacing: 12) {
ForEach(items, id: \.id) { item in
Button {
selectedSponsorData = item
} label: {
ZStack {
AssetColors.Inverse.inverseSurface.swiftUIColor
.clipShape(RoundedRectangle(cornerRadius: 12))
AsyncImage(url: item.logo) {
$0.image?
.resizable()
.scaledToFit()
}
.frame(height: imageHeight)
.padding(.vertical, 6)
}
}
}
}
}
}

#Preview {
Expand Down

0 comments on commit 4074a08

Please sign in to comment.