sodalive-ios/SodaLive/Sources/MyPage/ServiceCenter/ServiceCenterCategoryView.s...

49 lines
1.3 KiB
Swift

//
// ServiceCenterCategoryView.swift
// SodaLive
//
// Created by klaus on 2023/08/11.
//
import SwiftUI
struct ServiceCenterCategoryView: View {
let columns = [
GridItem(.flexible()),
GridItem(.flexible()),
GridItem(.flexible()),
GridItem(.flexible()),
]
let categories: [String]
@Binding var selectedCategory: String
var body: some View {
LazyVGrid(columns: columns, spacing: 10) {
ForEach(categories, id: \.self) { category in
ServiceCenterCategoryItemView(
category: category,
isSelected: selectedCategory == category
)
.frame(height: 46.7)
.onTapGesture {
if selectedCategory != category {
selectedCategory = category
}
}
}
}
.padding(.horizontal, 13.3)
}
}
struct ServiceCenterCategoryView_Previews: PreviewProvider {
static var previews: some View {
ServiceCenterCategoryView(
categories: ["전체", "사용방법", "수다", "결제/환불", "서비스/기타"],
selectedCategory: .constant("전체")
)
}
}