Files
sing-box-for-apple/ApplicationLibrary/Views/Groups/GroupListView.swift
T
2025-11-27 16:10:55 +08:00

33 lines
914 B
Swift

import Library
import SwiftUI
public struct GroupListView: View {
@EnvironmentObject private var environments: ExtensionEnvironments
@StateObject private var viewModel = GroupListViewModel()
public init() {}
public var body: some View {
VStack {
if viewModel.isLoading {
Text("Loading...")
} else if !viewModel.groups.isEmpty {
ScrollView {
VStack {
ForEach(viewModel.groups, id: \.hashValue) { it in
GroupView(it)
}
}.padding()
}
} else {
Text("Empty groups")
}
}
.onAppear {
viewModel.connect()
}
.onReceive(environments.commandClient.$groups) { groups in
viewModel.setGroups(groups)
}
}
}