93 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			93 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
//
 | 
						|
//  UserProfileDonationView.swift
 | 
						|
//  SodaLive
 | 
						|
//
 | 
						|
//  Created by klaus on 2023/08/11.
 | 
						|
//
 | 
						|
 | 
						|
import SwiftUI
 | 
						|
import Kingfisher
 | 
						|
 | 
						|
struct UserProfileDonationView: View {
 | 
						|
    
 | 
						|
    let userId: Int
 | 
						|
    let donationRankingResponse: [UserDonationRankingResponse]
 | 
						|
    let rankingCrawns = ["ic_crown_1", "ic_crown_2", "ic_crown_3"]
 | 
						|
    let rankingColors = [
 | 
						|
        [Color(hex: "ffdc00"), Color(hex: "ffb600")],
 | 
						|
        [Color(hex: "ffffff"), Color(hex: "9f9f9f")],
 | 
						|
        [Color(hex: "e6a77a"), Color(hex: "c67e4a")],
 | 
						|
        [Color(hex: "ffffff").opacity(0), Color(hex: "ffffff").opacity(0)]
 | 
						|
    ]
 | 
						|
    
 | 
						|
    var body: some View {
 | 
						|
        VStack(alignment: .leading, spacing: 14) {
 | 
						|
            HStack(spacing: 0) {
 | 
						|
                Text("후원랭킹")
 | 
						|
                    .font(.custom(Font.preBold.rawValue, size: 26))
 | 
						|
                    .foregroundColor(Color.white)
 | 
						|
                
 | 
						|
                Spacer()
 | 
						|
                
 | 
						|
                Text("전체보기")
 | 
						|
                    .font(.custom(Font.preLight.rawValue, size: 14))
 | 
						|
                    .foregroundColor(Color(hex: "78909C"))
 | 
						|
                    .onTapGesture {
 | 
						|
                        AppState.shared.setAppStep(step: .userProfileDonationAll(userId: userId))
 | 
						|
                    }
 | 
						|
            }
 | 
						|
            .padding(.horizontal, 24)
 | 
						|
            
 | 
						|
            ScrollView(.horizontal, showsIndicators: false) {
 | 
						|
                HStack(spacing: 13.3) {
 | 
						|
                    ForEach(0..<donationRankingResponse.count, id: \.self) { index in
 | 
						|
                        let item = donationRankingResponse[index]
 | 
						|
                        VStack(spacing: 6.7) {
 | 
						|
                            ZStack {
 | 
						|
                                KFImage(URL(string: item.profileImage))
 | 
						|
                                    .cancelOnDisappear(true)
 | 
						|
                                    .downsampling(
 | 
						|
                                        size: CGSize(
 | 
						|
                                            width: 70,
 | 
						|
                                            height: 70
 | 
						|
                                        )
 | 
						|
                                    )
 | 
						|
                                    .resizable()
 | 
						|
                                    .scaledToFill()
 | 
						|
                                    .frame(width: 70, height: 70, alignment: .top)
 | 
						|
                                    .clipShape(Circle())
 | 
						|
                                    .overlay(
 | 
						|
                                        Circle()
 | 
						|
                                            .stroke(
 | 
						|
                                                AngularGradient(colors: rankingColors[index < 4 ? index : 3], center: .center),
 | 
						|
                                                lineWidth: 3
 | 
						|
                                            )
 | 
						|
                                    )
 | 
						|
                                
 | 
						|
                                if index < 3 {
 | 
						|
                                    VStack(alignment: .trailing, spacing: 0) {
 | 
						|
                                        Spacer()
 | 
						|
                                        
 | 
						|
                                        Image(rankingCrawns[index])
 | 
						|
                                            .resizable()
 | 
						|
                                            .frame(width: 25, height: 25)
 | 
						|
                                    }
 | 
						|
                                    .frame(width: 73, height: 73, alignment: .trailing)
 | 
						|
                                }
 | 
						|
                            }
 | 
						|
                            .frame(width: 73, height: 73)
 | 
						|
                            
 | 
						|
                            Text(item.nickname)
 | 
						|
                                .font(.custom(Font.preMedium.rawValue, size: 12))
 | 
						|
                                .foregroundColor(.grayee)
 | 
						|
                                .frame(width: 63)
 | 
						|
                                .lineLimit(1)
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                .padding(.horizontal, 24)
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |