//
//  SettingListView.swift
//  AIEmoji
//
//  Created by 100Years on 2025/1/16.
//

import SwiftUI

struct TSSettingListView: View {
    @ObservedObject var viewModel: TSSetingViewModel
    var publisher: ListEventPublisher
    var body: some View {
        ZStack {
            Color.clear
            VStack(spacing: 0) {
                Spacer().frame(height: 16)
                
                SettingPurchaseTopView(eventPublisher: publisher, isViper: $viewModel.isViper)
                    .frame(height: 117*kDesignScale)
                    .onTapGesture {
                        if PurchaseManager.default.isVip {
                            return
                        }
                        publisher.enterPurchasePublisher.send(true)
                    }
                
                ForEach(viewModel.settingTypes, id:\.self) { type in
                    Spacer().frame(height: 16)
                    SettingListItemView(type: type)
                    .onTapGesture {
                        publisher.settingPublisher.send(type)
                    }
                }
                
                Spacer()

            }
            .padding(.horizontal)
            
        }
    }
}


struct SettingListItemView: View {
    var type : SettingType
    var body: some View {
        
        ZStack {
            Color.white.opacity(0.1)
            HStack {
                Text(type.rawValue).font(.font(size: 16.0)).foregroundColor(.white)
                Spacer()
                if type != .about {
                    Image(.whiteRightArrow)
                }else{
                    Text(appVersion()).foregroundColor(.hex("#FFFFFF").opacity(0.4)).font(.font(size: 16))
                }
            }.padding(.horizontal)
        }
        .frame(height: 64)
        .cornerRadius(16)
//        .cornerRadius(.allCorners, 16)
    }
}
