Files
sing-box-for-apple/ApplicationLibrary/Views/Dashboard/ClashModeView.swift
T
2025-11-26 22:25:48 +08:00

37 lines
1.1 KiB
Swift

import Libbox
import Library
import SwiftUI
@MainActor
public struct ClashModeView: View {
@EnvironmentObject private var environments: ExtensionEnvironments
@StateObject private var viewModel = ClashModeViewModel()
public init() {}
public var body: some View {
VStack {
if viewModel.shouldShowPicker {
Picker("", selection: Binding(get: {
viewModel.clashMode
}, set: { newMode in
viewModel.clashMode = newMode
Task {
await viewModel.setClashMode(newMode)
}
}), content: {
ForEach(viewModel.clashModeList, id: \.self) { mode in
Text(mode)
}
})
.pickerStyle(.segmented)
.padding([.top], 8)
}
}
.padding([.leading, .trailing])
.onAppear {
viewModel.setCommandClient(environments.commandClient)
}
.alertBinding($viewModel.alert)
}
}