//
//  SettingsNetworkView.swift
//  punchnet
//
//  Created by 安礼成 on 2026/1/19.
//

import SwiftUI

struct SettingsNetworkView: View {
    @State var state: SettingsState = SettingsState()
    
    var body: some View {
        VStack(alignment: .leading) {
            Text("网络")
            
            HStack(alignment: .top) {
                Text("默认网络")
                
                VStack(alignment: .leading) {
                    Menu {
                        ForEach(state.networks, id: \.id) { network in
                            Button(network.name) {
                                self.state.selectedNetwork = network
                            }
                        }
                    } label: {
                        Text(state.selectedNetwork.name)
                            .padding()
                            .background(Color.gray.opacity(0.2))
                            .cornerRadius(5)
                    }
                    
                    Button {
                        
                    } label: {
                        Text("进入管理平台")
                    }
                }
                
                Button {
                    
                } label: {
                    Text("详情")
                }
                
            }
            
            
            HStack {
                Text("出口节点")
                
                Menu {
                    ForEach(state.exitNodes, id: \.id) { node in
                        Button(node.name) {
                            self.state.selectedExitNode = node
                        }
                    }
                    
                } label: {
                    Text(state.selectedExitNode.name)
                }
            }
            
            HStack {
                Text("授权状态")
                Text("有效")
            }
            
            HStack {
                Text("授权有效期")
                Text("临时（至断开连接）")
            }
            
        }
        
    }
    
}

#Preview {
    SettingsNetworkView()
}
