mirror of
https://github.com/hanzoai/bot.git
synced 2026-10-30 17:24:26 +00:00
Automated rebrand of all openclaw references to hanzo bot: - Package: openclaw -> @hanzo/bot - Binary: openclaw -> hanzo-bot - Config: ~/.openclaw -> ~/.hanzo/bot - Docker: ghcr.io/hanzoai/bot - Env vars: OPENCLAW_* -> BOT_* - Bundle IDs: ai.hanzo.bot.* - Product name: Hanzo Bot
86 lines
2.9 KiB
Swift
86 lines
2.9 KiB
Swift
import ActivityKit
|
|
import SwiftUI
|
|
import WidgetKit
|
|
|
|
struct Hanzo BotLiveActivity: Widget {
|
|
var body: some WidgetConfiguration {
|
|
ActivityConfiguration(for: Hanzo BotActivityAttributes.self) { context in
|
|
lockScreenView(context: context)
|
|
} dynamicIsland: { context in
|
|
DynamicIsland {
|
|
DynamicIslandExpandedRegion(.leading) {
|
|
statusDot(state: context.state)
|
|
}
|
|
DynamicIslandExpandedRegion(.center) {
|
|
Text(context.state.statusText)
|
|
.font(.subheadline)
|
|
.lineLimit(1)
|
|
}
|
|
DynamicIslandExpandedRegion(.trailing) {
|
|
trailingView(state: context.state)
|
|
}
|
|
} compactLeading: {
|
|
statusDot(state: context.state)
|
|
} compactTrailing: {
|
|
Text(context.state.statusText)
|
|
.font(.caption2)
|
|
.lineLimit(1)
|
|
.frame(maxWidth: 64)
|
|
} minimal: {
|
|
statusDot(state: context.state)
|
|
}
|
|
}
|
|
}
|
|
|
|
@ViewBuilder
|
|
private func lockScreenView(context: ActivityViewContext<Hanzo BotActivityAttributes>) -> some View {
|
|
HStack(spacing: 8) {
|
|
statusDot(state: context.state)
|
|
.frame(width: 10, height: 10)
|
|
VStack(alignment: .leading, spacing: 2) {
|
|
Text("Hanzo Bot")
|
|
.font(.subheadline.bold())
|
|
Text(context.state.statusText)
|
|
.font(.caption)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
Spacer()
|
|
trailingView(state: context.state)
|
|
}
|
|
.padding(.horizontal, 12)
|
|
.padding(.vertical, 4)
|
|
}
|
|
|
|
@ViewBuilder
|
|
private func trailingView(state: Hanzo BotActivityAttributes.ContentState) -> some View {
|
|
if state.isConnecting {
|
|
ProgressView().controlSize(.small)
|
|
} else if state.isDisconnected {
|
|
Image(systemName: "wifi.slash")
|
|
.foregroundStyle(.red)
|
|
} else if state.isIdle {
|
|
Image(systemName: "antenna.radiowaves.left.and.right")
|
|
.foregroundStyle(.green)
|
|
} else {
|
|
Text(state.startedAt, style: .timer)
|
|
.font(.caption)
|
|
.monospacedDigit()
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
}
|
|
|
|
@ViewBuilder
|
|
private func statusDot(state: Hanzo BotActivityAttributes.ContentState) -> some View {
|
|
Circle()
|
|
.fill(dotColor(state: state))
|
|
.frame(width: 6, height: 6)
|
|
}
|
|
|
|
private func dotColor(state: Hanzo BotActivityAttributes.ContentState) -> Color {
|
|
if state.isDisconnected { return .red }
|
|
if state.isConnecting { return .gray }
|
|
if state.isIdle { return .green }
|
|
return .blue
|
|
}
|
|
}
|