mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-21 20:06:05 +00:00
restructure
This commit is contained in:
@@ -22,19 +22,42 @@ private enum NetworkAlert: Identifiable {
|
||||
struct NetworkAndServers: View {
|
||||
@EnvironmentObject var m: ChatModel
|
||||
@EnvironmentObject var theme: AppTheme
|
||||
@State private var serverOperators: [ServerOperator] = []
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
List {
|
||||
operatorsSection()
|
||||
|
||||
Section {
|
||||
NavigationLink {
|
||||
AllServersView()
|
||||
.navigationTitle("Servers")
|
||||
ProtocolServersView(serverProtocol: .smp)
|
||||
.navigationTitle("SMP servers")
|
||||
.modifier(ThemedBackground(grouped: true))
|
||||
} label: {
|
||||
Text("Servers")
|
||||
Text("Message servers")
|
||||
}
|
||||
|
||||
NavigationLink {
|
||||
ProtocolServersView(serverProtocol: .xftp)
|
||||
.navigationTitle("XFTP servers")
|
||||
.modifier(ThemedBackground(grouped: true))
|
||||
} label: {
|
||||
Text("Media & file servers")
|
||||
}
|
||||
} header: {
|
||||
Text("Other servers")
|
||||
.foregroundColor(theme.colors.secondary)
|
||||
}
|
||||
|
||||
Section {
|
||||
Button("Reset") {}
|
||||
.disabled(true)
|
||||
Button("Save") {}
|
||||
.disabled(true)
|
||||
}
|
||||
|
||||
Section {
|
||||
NavigationLink {
|
||||
AdvancedNetworkSettings()
|
||||
.navigationTitle("Advanced settings")
|
||||
@@ -66,6 +89,50 @@ struct NetworkAndServers: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
serverOperators = ChatModel.shared.serverOperators
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder private func operatorsSection() -> some View {
|
||||
let smpServers = [ServerCfg.sampleData.preset, ServerCfg.sampleData.preset]
|
||||
let xftpServers = [ServerCfg.sampleData.xftpPreset, ServerCfg.sampleData.xftpPreset]
|
||||
Section {
|
||||
ForEach($serverOperators) { srvOperator in
|
||||
serverOperatorView(srvOperator, smpServers, xftpServers)
|
||||
}
|
||||
} header: {
|
||||
Text("Operators")
|
||||
.foregroundColor(theme.colors.secondary)
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder private func serverOperatorView(
|
||||
_ serverOperator: Binding<ServerOperator>,
|
||||
_ smpServers: [ServerCfg],
|
||||
_ xftpServers: [ServerCfg]
|
||||
) -> some View {
|
||||
let srvOperator = serverOperator.wrappedValue
|
||||
NavigationLink() {
|
||||
OperatorView(
|
||||
serverOperator: serverOperator,
|
||||
serverOperatorToEdit: srvOperator,
|
||||
useOperator: srvOperator.enabled,
|
||||
currSMPServers: smpServers,
|
||||
currXFTPServers: xftpServers
|
||||
)
|
||||
.navigationBarTitle("\(srvOperator.name) servers")
|
||||
.modifier(ThemedBackground(grouped: true))
|
||||
.navigationBarTitleDisplayMode(.large)
|
||||
} label: {
|
||||
HStack {
|
||||
Image(srvOperator.info.logo)
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(width: 24, height: 24)
|
||||
Text(srvOperator.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user