// // ContentMainRankingSortView.swift // SodaLive // // Created by klaus on 2023/11/03. // import SwiftUI struct ContentMainRankingSortView: View { let sorts: [String] let selectSort: (String) -> Void @Binding var selectedSort: String var body: some View { ScrollView(.horizontal, showsIndicators: false) { HStack(alignment: .top, spacing: 8) { ForEach(0..<sorts.count, id: \.self) { index in let sort = sorts[index] Text(sort) .font(.custom(Font.medium.rawValue, size: 14.7)) .foregroundColor(Color(hex: selectedSort == sort ? "9970ff" : "777777")) .padding(.horizontal, 13.3) .padding(.vertical, 9.3) .border( Color(hex: selectedSort == sort ? "9970ff" : "eeeeee"), width: 0.5 ) .cornerRadius(16.7) .overlay( RoundedRectangle(cornerRadius: CGFloat(16.7)) .stroke(lineWidth: 0.5) .foregroundColor(Color(hex: selectedSort == sort ? "9970ff" : "eeeeee")) ) .onTapGesture { if selectedSort != sort { selectSort(sort) } } } } } } } struct ContentMainRankingSortView_Previews: PreviewProvider { static var previews: some View { ContentMainRankingSortView( sorts: ["전체", "테마1", "테마2"], selectSort: { _ in }, selectedSort: .constant("전체") ) } }