mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-28 05:24:44 +00:00
information map, logos
This commit is contained in:
@@ -92,7 +92,13 @@ struct OperatorView: View {
|
||||
.modifier(ThemedBackground(grouped: true))
|
||||
.navigationBarTitleDisplayMode(.large)
|
||||
} label: {
|
||||
Text(serverOperator.name)
|
||||
HStack {
|
||||
Image(serverOperator.info.logo)
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(width: 24, height: 24)
|
||||
Text(serverOperator.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ struct ProtocolServersView: View {
|
||||
// this condition is needed to prevent re-setting the servers when exiting single server view
|
||||
if justOpened {
|
||||
do {
|
||||
serverOperators = [ServerOperator.sampleData1, ServerOperator.sampleData2]
|
||||
serverOperators = [ServerOperator.sampleData1, ServerOperator.sampleData2, ServerOperator.sampleData3]
|
||||
let r = try getUserProtoServers(serverProtocol)
|
||||
currServers = r.protoServers
|
||||
presetServers = r.presetServers
|
||||
@@ -205,7 +205,13 @@ struct ProtocolServersView: View {
|
||||
.modifier(ThemedBackground(grouped: true))
|
||||
.navigationBarTitleDisplayMode(.large)
|
||||
} label: {
|
||||
Text(srvOperator.name)
|
||||
HStack {
|
||||
Image(srvOperator.info.logo)
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(width: 24, height: 24)
|
||||
Text(srvOperator.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1194,6 +1194,36 @@ public struct UserProtoServers: Decodable {
|
||||
public var presetServers: [ServerCfg]
|
||||
}
|
||||
|
||||
public enum OperatorTag: Decodable {
|
||||
case simplex
|
||||
case xyz
|
||||
case demo
|
||||
}
|
||||
|
||||
public struct ServerOperatorInfo: Decodable {
|
||||
public var description: String
|
||||
public var website: String
|
||||
public var logo: String
|
||||
}
|
||||
|
||||
public let operatorsInfo: Dictionary<OperatorTag, ServerOperatorInfo> = [
|
||||
.simplex: ServerOperatorInfo(
|
||||
description: "SimpleX Chat preset servers",
|
||||
website: "https://simplex.chat",
|
||||
logo: "icon-transparent"
|
||||
),
|
||||
.xyz: ServerOperatorInfo(
|
||||
description: "XYZ servers",
|
||||
website: "XYZ website",
|
||||
logo: "shield"
|
||||
),
|
||||
.demo: ServerOperatorInfo(
|
||||
description: "Demo operator",
|
||||
website: "Demo website",
|
||||
logo: "privacy"
|
||||
)
|
||||
]
|
||||
|
||||
public enum UsageConditionsAcceptance: Decodable, Hashable {
|
||||
case accepted(date: Date)
|
||||
case reviewAvailable(deadline: Date)
|
||||
@@ -1219,20 +1249,21 @@ public enum UsageConditionsAcceptance: Decodable, Hashable {
|
||||
public struct ServerOperator: Identifiable, Decodable {
|
||||
public var operatorId: Int64
|
||||
public var name: String
|
||||
public var info: ServerOperatorInfo
|
||||
public var tag: OperatorTag
|
||||
public var latestConditionsAcceptance: UsageConditionsAcceptance
|
||||
public var enabled: Bool
|
||||
public var roles: ServerRoles
|
||||
|
||||
public var id: Int64 { operatorId }
|
||||
|
||||
public var info: ServerOperatorInfo {
|
||||
operatorsInfo[tag] ?? ServerOperatorInfo(description: "Default", website: "Default", logo: "icon-transparent")
|
||||
}
|
||||
|
||||
public static var sampleData1 = ServerOperator(
|
||||
operatorId: 1,
|
||||
name: "SimpleX Chat",
|
||||
info: ServerOperatorInfo(
|
||||
description: "SimpleX Chat preset servers",
|
||||
website: "https://simplex.chat"
|
||||
),
|
||||
tag: .simplex,
|
||||
latestConditionsAcceptance: .reviewAvailable(deadline: Date.distantFuture),
|
||||
enabled: true,
|
||||
roles: ServerRoles(storage: true, proxy: true)
|
||||
@@ -1241,19 +1272,20 @@ public struct ServerOperator: Identifiable, Decodable {
|
||||
public static var sampleData2 = ServerOperator(
|
||||
operatorId: 2,
|
||||
name: "XYZ",
|
||||
info: ServerOperatorInfo(
|
||||
description: "XYZ servers",
|
||||
website: "https://xyz.com"
|
||||
),
|
||||
tag: .xyz,
|
||||
latestConditionsAcceptance: .reviewRequired,
|
||||
enabled: false,
|
||||
roles: ServerRoles(storage: true, proxy: true)
|
||||
)
|
||||
}
|
||||
|
||||
public struct ServerOperatorInfo: Decodable {
|
||||
public var description: String
|
||||
public var website: String
|
||||
public static var sampleData3 = ServerOperator(
|
||||
operatorId: 3,
|
||||
name: "Demo",
|
||||
tag: .demo,
|
||||
latestConditionsAcceptance: .reviewRequired,
|
||||
enabled: false,
|
||||
roles: ServerRoles(storage: true, proxy: true)
|
||||
)
|
||||
}
|
||||
|
||||
public struct ServerRoles: Decodable {
|
||||
|
||||
Reference in New Issue
Block a user