From 18c4b8643df09be4ce52a4b110ea21ac1ad053fc Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Mon, 11 Dec 2023 23:32:28 -0800 Subject: Move to new Hotline model for data observation and let client exist standalone. --- Hotline/Views/UsersView.swift | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Hotline/Views/UsersView.swift (limited to 'Hotline/Views/UsersView.swift') diff --git a/Hotline/Views/UsersView.swift b/Hotline/Views/UsersView.swift new file mode 100644 index 0000000..0397ef7 --- /dev/null +++ b/Hotline/Views/UsersView.swift @@ -0,0 +1,41 @@ +import SwiftUI + +struct UsersView: View { + @Environment(Hotline.self) private var model: Hotline + + var body: some View { + NavigationStack { + List(model.users) { u in + Text("🤖 \(u.name)") + .fontWeight(.medium) + .lineLimit(1) + .truncationMode(.tail) + .foregroundStyle(u.status.contains(.admin) ? Color(hex: 0xE10000) : Color.accentColor) + .opacity(u.status.contains(.idle) ? 0.5 : 1.0) + } +// .listStyle(.grouped) + .navigationBarTitleDisplayMode(.inline) + .toolbar { + ToolbarItem(placement: .principal) { + Text(model.server?.name ?? "") + .font(.headline) + } + ToolbarItem(placement: .navigationBarLeading) { + Button { + model.disconnect() + } label: { + Text(Image(systemName: "xmark.circle.fill")) + .symbolRenderingMode(.hierarchical) + .font(.title2) + .foregroundColor(.secondary) + } + } + } + } + } +} + +#Preview { + ChatView() + .environment(Hotline(trackerClient: HotlineTrackerClient(), client: HotlineNewClient())) +} -- cgit