Merge profile to dashboard

This commit is contained in:
世界
2025-11-26 22:25:52 +08:00
parent 4f0d1098e6
commit 264c37218c
27 changed files with 1590 additions and 306 deletions
@@ -0,0 +1,38 @@
import Foundation
import Library
@MainActor
public struct ButtonVisibilityState {
public var showGroupsButton = false
public var showConnectionsButton = false
public var groupsCount = 0
public var connectionsCount = 0
public init() {}
public mutating func update(
profile: ExtensionProfile?,
commandClient: CommandClient,
requireAnyConnection: Bool = false
) {
guard let profile else {
reset()
return
}
groupsCount = commandClient.groups?.count ?? 0
connectionsCount = commandClient.connections?.count ?? 0
let isConnected = ApplicationLibrary.inPreview || profile.status.isConnectedStrict
showConnectionsButton = isConnected && (!requireAnyConnection || commandClient.hasAnyConnection)
showGroupsButton = isConnected && (commandClient.groups?.isEmpty == false)
}
private mutating func reset() {
showGroupsButton = false
showConnectionsButton = false
groupsCount = 0
connectionsCount = 0
}
}