73 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
//
 | 
						|
//  CanUseStatusView.swift
 | 
						|
//  SodaLive
 | 
						|
//
 | 
						|
//  Created by klaus on 2023/08/11.
 | 
						|
//
 | 
						|
 | 
						|
import SwiftUI
 | 
						|
 | 
						|
struct CanUseStatusView: View {
 | 
						|
    
 | 
						|
    @StateObject var viewModel = CanStatusViewModel()
 | 
						|
    
 | 
						|
    var body: some View {
 | 
						|
        ZStack {
 | 
						|
            VStack(spacing: 13.3) {
 | 
						|
                ForEach(viewModel.useStatusItems, id: \.self) { item in
 | 
						|
                    CanUseStatusItemView(item: item)
 | 
						|
                }
 | 
						|
            }
 | 
						|
            
 | 
						|
            if viewModel.isLoading {
 | 
						|
                LoadingView()
 | 
						|
            }
 | 
						|
        }
 | 
						|
        .onAppear {
 | 
						|
            viewModel.getCanUseStatus()
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
struct CanUseStatusItemView: View {
 | 
						|
    
 | 
						|
    let item: GetCanUseStatusResponseItem
 | 
						|
    
 | 
						|
    var body: some View {
 | 
						|
        HStack(spacing: 0) {
 | 
						|
            VStack(alignment: .leading, spacing: 6.7) {
 | 
						|
                Text(item.title)
 | 
						|
                    .font(.custom(Font.medium.rawValue, size: 13.3))
 | 
						|
                    .foregroundColor(Color(hex: "eeeeee"))
 | 
						|
                
 | 
						|
                Text(item.date)
 | 
						|
                    .font(.custom(Font.medium.rawValue, size: 12))
 | 
						|
                    .foregroundColor(Color(hex: "777777"))
 | 
						|
            }
 | 
						|
            
 | 
						|
            Spacer()
 | 
						|
            
 | 
						|
            Text("\(item.can)")
 | 
						|
                .font(.custom(Font.bold.rawValue, size: 13.3))
 | 
						|
                .foregroundColor(Color(hex: "eeeeee"))
 | 
						|
            
 | 
						|
            Image("ic_can")
 | 
						|
                .resizable()
 | 
						|
                .frame(width: 26.7, height: 26.7)
 | 
						|
                .padding(.leading, 6.7)
 | 
						|
        }
 | 
						|
        .padding(.horizontal, 13.3)
 | 
						|
        .padding(.vertical, 16)
 | 
						|
        .background(Color(hex: "111111"))
 | 
						|
        .cornerRadius(16.7)
 | 
						|
        .padding(.horizontal, 13.3)
 | 
						|
        .frame(width: screenSize().width)
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
struct CanUseStatusView_Previews: PreviewProvider {
 | 
						|
    static var previews: some View {
 | 
						|
        CanUseStatusView()
 | 
						|
    }
 | 
						|
}
 |