57 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
//
 | 
						|
//  ContentMainContentThemeView.swift
 | 
						|
//  SodaLive
 | 
						|
//
 | 
						|
//  Created by klaus on 2/21/25.
 | 
						|
//
 | 
						|
 | 
						|
import SwiftUI
 | 
						|
 | 
						|
struct ContentMainContentThemeView: View {
 | 
						|
    
 | 
						|
    let themeList: [String]
 | 
						|
    let selectTheme: (String) -> Void
 | 
						|
    
 | 
						|
    @Binding var selectedTheme: String
 | 
						|
    
 | 
						|
    var body: some View {
 | 
						|
        ScrollView(.horizontal, showsIndicators: false) {
 | 
						|
            HStack(alignment: .top, spacing: 8) {
 | 
						|
                ForEach(0..<themeList.count, id: \.self) { index in
 | 
						|
                    let theme = themeList[index]
 | 
						|
                    Text(theme)
 | 
						|
                        .font(.custom(Font.medium.rawValue, size: 14.7))
 | 
						|
                        .foregroundColor(selectedTheme == theme ? Color.button : Color.gray77)
 | 
						|
                        .padding(.horizontal, 13.3)
 | 
						|
                        .padding(.vertical, 9.3)
 | 
						|
                        .border(
 | 
						|
                            selectedTheme == theme ? Color.button : Color.grayee,
 | 
						|
                            width: 1
 | 
						|
                        )
 | 
						|
                        .cornerRadius(16.7)
 | 
						|
                        .overlay(
 | 
						|
                            RoundedRectangle(cornerRadius: CGFloat(16.7))
 | 
						|
                                .stroke(lineWidth: 1)
 | 
						|
                                .foregroundColor(selectedTheme == theme ? Color.button : Color.grayee)
 | 
						|
                        )
 | 
						|
                        .onTapGesture {
 | 
						|
                            if selectedTheme != theme {
 | 
						|
                                selectedTheme = theme
 | 
						|
                                selectTheme(theme)
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                }
 | 
						|
            }
 | 
						|
            .padding(.horizontal, 13.3)
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
#Preview {
 | 
						|
    ContentMainContentThemeView(
 | 
						|
        themeList: ["전체", "test", "test2"],
 | 
						|
        selectTheme: { _ in },
 | 
						|
        selectedTheme: .constant("전체")
 | 
						|
    )
 | 
						|
}
 |