This commit is contained in:
spaced4ndy
2024-10-30 20:25:40 +04:00
parent 2b08736932
commit 11c3a6eb30
2 changed files with 12 additions and 29 deletions
@@ -27,7 +27,16 @@ struct NetworkAndServers: View {
var body: some View {
VStack {
List {
presetServersSection()
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("Preset servers")
.foregroundColor(theme.colors.secondary)
}
Section {
NavigationLink {
@@ -79,19 +88,6 @@ struct NetworkAndServers: View {
}
}
@ViewBuilder private func presetServersSection() -> 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("Preset servers")
.foregroundColor(theme.colors.secondary)
}
}
@ViewBuilder private func serverOperatorView(
_ serverOperator: Binding<ServerOperator>,
_ smpServers: [ServerCfg],
@@ -32,9 +32,6 @@ struct OperatorView: View {
Section {
infoViewLink()
useOperatorToggle()
if serverOperatorToEdit.enabled || serverOperatorToEdit.conditionsAcceptance.conditionsAccepted {
viewConditionsButton()
}
} header: {
Text("Operator")
.foregroundColor(theme.colors.secondary)
@@ -42,9 +39,11 @@ struct OperatorView: View {
switch (serverOperatorToEdit.conditionsAcceptance) {
case let .accepted(date):
Text("Conditions accepted on: \(conditionsTimestamp(date)).")
.foregroundColor(theme.colors.secondary)
case let .reviewAvailable(deadline):
if serverOperatorToEdit.enabled {
Text("Review conditions until: \(conditionsTimestamp(deadline)).")
.foregroundColor(theme.colors.secondary)
}
case .reviewRequired:
EmptyView()
@@ -142,18 +141,6 @@ struct OperatorView: View {
}
}
private func viewConditionsButton() -> some View {
Button {
showConditionsSheet = true
} label: {
if case .accepted = serverOperatorToEdit.conditionsAcceptance {
Text("Conditions accepted")
} else {
Text("Review conditions")
}
}
}
private func usageRolesSection() -> some View {
Section(header: Text("Use operator").foregroundColor(theme.colors.secondary)) {
Toggle("For storage", isOn: $serverOperatorToEdit.roles.storage)