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

import SwiftUI
import SwiftUIX


struct TSSettingListView: View {
    @ObservedObject var viewModel: TSSetingViewModel
    var publisher: ListEventPublisher
    var body: some View {
        ZStack {
            Color.clear
            VStack(spacing: 0) {
                Spacer().height(16)
                
                if viewModel.settingTypes.contains(.tutorialsBanner) {
                    Image(.tutorialsBanner).resizable().frame(width: k_ScreenWidth-32,height: 117*kDesignScale)
                    .onTapGesture {
                        publisher.settingPublisher.send(.tutorialsBanner)
                    }
                }
                
                CocoaList(viewModel.settingTypes.filter({$0 != .tutorialsBanner}), id: \.self) { type in
                    Spacer().height(16)
                    SettingListItemView(type: type)
                    .onTapGesture {
                        publisher.settingPublisher.send(type)
                    }
                }.listStyle(.grouped)
            }.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)
        }
        .height(64)
        .cornerRadius(.allCorners, 16)
    }
}
