90 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			90 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
//
 | 
						|
//  ContentMainItemView.swift
 | 
						|
//  SodaLive
 | 
						|
//
 | 
						|
//  Created by klaus on 2023/08/11.
 | 
						|
//
 | 
						|
 | 
						|
import SwiftUI
 | 
						|
import Kingfisher
 | 
						|
 | 
						|
struct ContentMainItemView: View {
 | 
						|
    
 | 
						|
    let item: GetAudioContentMainItem
 | 
						|
    
 | 
						|
    var body: some View {
 | 
						|
        VStack(alignment: .leading, spacing: 8) {
 | 
						|
            ZStack(alignment: .topTrailing) {
 | 
						|
                KFImage(URL(string: item.coverImageUrl))
 | 
						|
                    .cancelOnDisappear(true)
 | 
						|
                    .downsampling(
 | 
						|
                        size: CGSize(
 | 
						|
                            width: 133.3,
 | 
						|
                            height: 133.3
 | 
						|
                        )
 | 
						|
                    )
 | 
						|
                    .resizable()
 | 
						|
                    .scaledToFill()
 | 
						|
                    .frame(width: 133.3, height: 133.3, alignment: .top)
 | 
						|
                    .cornerRadius(2.7)
 | 
						|
                
 | 
						|
                if item.isPointAvailable {
 | 
						|
                    Image("ic_point")
 | 
						|
                        .padding(.top, 2.7)
 | 
						|
                        .padding(.trailing, 2.7)
 | 
						|
                }
 | 
						|
            }
 | 
						|
            
 | 
						|
            Text(item.title)
 | 
						|
                .font(.custom(Font.medium.rawValue, size: 13.3))
 | 
						|
                .foregroundColor(.grayd2)
 | 
						|
                .frame(width: 133.3, alignment: .leading)
 | 
						|
                .multilineTextAlignment(.leading)
 | 
						|
                .fixedSize(horizontal: false, vertical: true)
 | 
						|
                .lineLimit(1)
 | 
						|
            
 | 
						|
            HStack(spacing: 5.3) {
 | 
						|
                KFImage(URL(string: item.creatorProfileImageUrl))
 | 
						|
                    .cancelOnDisappear(true)
 | 
						|
                    .downsampling(
 | 
						|
                        size: CGSize(
 | 
						|
                            width: 21.3,
 | 
						|
                            height: 21.3
 | 
						|
                        )
 | 
						|
                    )
 | 
						|
                    .resizable()
 | 
						|
                    .scaledToFill()
 | 
						|
                    .frame(width: 21.3, height: 21.3)
 | 
						|
                    .clipShape(Circle())
 | 
						|
                    .onTapGesture { AppState.shared.setAppStep(step: .creatorDetail(userId: item.creatorId)) }
 | 
						|
                
 | 
						|
                Text(item.creatorNickname)
 | 
						|
                    .font(.custom(Font.medium.rawValue, size: 12))
 | 
						|
                    .foregroundColor(.gray77)
 | 
						|
                    .lineLimit(1)
 | 
						|
            }
 | 
						|
            .padding(.bottom, 10)
 | 
						|
        }
 | 
						|
        .frame(width: 133.3, alignment: .leading)
 | 
						|
        .onTapGesture { AppState.shared.setAppStep(step: .contentDetail(contentId: item.contentId)) }
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
struct ContentMainItemView_Previews: PreviewProvider {
 | 
						|
    static var previews: some View {
 | 
						|
        ContentMainItemView(
 | 
						|
            item: GetAudioContentMainItem(
 | 
						|
                contentId: 2,
 | 
						|
                coverImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
 | 
						|
                title: "ㅓ처랴햐햫햐햐",
 | 
						|
                creatorId: 8,
 | 
						|
                creatorProfileImageUrl: "https://test-cf.sodalive.net/profile/default-profile.png",
 | 
						|
                creatorNickname: "유저2",
 | 
						|
                price: 10,
 | 
						|
                duration: "00:00:30",
 | 
						|
                isPointAvailable: true
 | 
						|
            )
 | 
						|
        )
 | 
						|
    }
 | 
						|
}
 |