Merge branch 'server-operators' into dc/android-desktop-server-operators

This commit is contained in:
spaced4ndy
2024-11-21 21:16:10 +04:00
6 changed files with 43 additions and 13 deletions
@@ -9,6 +9,8 @@
import SwiftUI
import SimpleXChat
let conditionsURL = URL(string: "https://github.com/simplex-chat/simplex-chat/blob/stable/PRIVACY.md")!
struct OnboardingButtonStyle: ButtonStyle {
@EnvironmentObject var theme: AppTheme
var isDisabled: Bool = false
@@ -313,6 +315,7 @@ struct ChooseServerOperators: View {
reviewConditionsView()
.navigationTitle("Conditions of use")
.navigationBarTitleDisplayMode(.large)
.toolbar { ToolbarItem(placement: .navigationBarTrailing, content: conditionsLinkButton) }
.modifier(ThemedBackground(grouped: true))
}
@@ -238,11 +238,13 @@ struct UsageConditionsView: View {
var body: some View {
VStack(alignment: .leading, spacing: 20) {
Text("Conditions of use")
.font(.largeTitle)
.bold()
.padding(.top)
.padding(.top)
HStack {
Text("Conditions of use").font(.largeTitle).bold()
Spacer()
conditionsLinkButton()
}
.padding(.top)
.padding(.top)
switch ChatModel.shared.conditions.conditionsAction {
@@ -464,11 +464,13 @@ struct SingleOperatorUsageConditionsView: View {
}
private func viewHeader() -> some View {
Text("Use servers of \(userServers[operatorIndex].operator_.tradeName)")
.font(.largeTitle)
.bold()
.padding(.top)
.padding(.top)
HStack {
Text("Use \(userServers[operatorIndex].operator_.tradeName)").font(.largeTitle).bold()
Spacer()
conditionsLinkButton()
}
.padding(.top)
.padding(.top)
}
@ViewBuilder private func conditionsAppliedToOtherOperatorsText() -> some View {
@@ -545,10 +547,33 @@ struct SingleOperatorUsageConditionsView: View {
.padding(.bottom)
.navigationTitle("Conditions of use")
.navigationBarTitleDisplayMode(.large)
.toolbar { ToolbarItem(placement: .navigationBarTrailing, content: conditionsLinkButton) }
.modifier(ThemedBackground(grouped: true))
}
}
func conditionsLinkButton() -> some View {
let commit = ChatModel.shared.conditions.currentConditions.conditionsCommit
let mdUrl = URL(string: "https://github.com/simplex-chat/simplex-chat/blob/\(commit)/PRIVACY.md") ?? conditionsURL
return Menu {
Link(destination: mdUrl) {
Label("Open conditions", systemImage: "doc")
}
if let commitUrl = URL(string: "https://github.com/simplex-chat/simplex-chat/commit/\(commit)") {
Link(destination: commitUrl) {
Label("Open changes", systemImage: "ellipsis")
}
}
} label: {
Image(systemName: "arrow.up.right.circle")
.resizable()
.scaledToFit()
.frame(width: 20)
.padding(2)
.contentShape(Circle())
}
}
#Preview {
OperatorView(
currUserServers: Binding.constant([UserOperatorServers.sampleData1, UserOperatorServers.sampleDataNilOperator]),
+1 -1
View File
@@ -1722,7 +1722,7 @@ public struct NetCfg: Codable, Equatable {
public var hostMode: HostMode = .publicHost
public var requiredHostMode = true
public var sessionMode = TransportSessionMode.user
public var smpProxyMode: SMPProxyMode = .unknown
public var smpProxyMode: SMPProxyMode = .always
public var smpProxyFallback: SMPProxyFallback = .allowProtected
public var smpWebPort = false
public var tcpConnectTimeout: Int // microseconds
@@ -4113,7 +4113,7 @@ data class NetCfg(
val hostMode: HostMode = HostMode.OnionViaSocks,
val requiredHostMode: Boolean = false,
val sessionMode: TransportSessionMode = TransportSessionMode.default,
val smpProxyMode: SMPProxyMode = SMPProxyMode.Unknown,
val smpProxyMode: SMPProxyMode = SMPProxyMode.Always,
val smpProxyFallback: SMPProxyFallback = SMPProxyFallback.AllowProtected,
val smpWebPort: Boolean = false,
val tcpConnectTimeout: Long, // microseconds
+1 -1
View File
@@ -236,7 +236,7 @@ coreChatOptsP appDir defaultDbFileName = do
)
yesToUpMigrations <-
switch
( long "--yes-migrate"
( long "yes-migrate"
<> short 'y'
<> help "Automatically confirm \"up\" database migrations"
)