aboutsummaryrefslogtreecommitdiff
path: root/Hotline/macOS
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2025-11-14 08:38:32 -0800
committerDustin Mierau <dustin@mierau.me>2025-11-14 08:38:32 -0800
commit46384d99b78cca150aa720eb915d161b5be8c08d (patch)
tree33b56420adae4f3158e7a07530c12b73e9f5d312 /Hotline/macOS
parent7ca2ece66a5d40964f5d640255d1b137433511a9 (diff)
Cleanup user client info sheet. Hide button if you don't have persmission to do so.
Diffstat (limited to 'Hotline/macOS')
-rw-r--r--Hotline/macOS/MessageView.swift50
-rw-r--r--Hotline/macOS/UserInfo.swift25
2 files changed, 35 insertions, 40 deletions
diff --git a/Hotline/macOS/MessageView.swift b/Hotline/macOS/MessageView.swift
index 861a14a..6690a88 100644
--- a/Hotline/macOS/MessageView.swift
+++ b/Hotline/macOS/MessageView.swift
@@ -1,37 +1,5 @@
import SwiftUI
-struct UserInfo: Identifiable {
- let username: String
- let data: String
-
- var id: String {
- self.username
- }
-}
-
-struct UserInfoView: View {
- @Environment(\.dismiss) private var dismiss
-
- let info: UserInfo
-
- var body: some View {
- ScrollView(.vertical) {
- Text(self.info.data)
- .fontDesign(.monospaced)
- .textSelection(.enabled)
- .padding()
- }
- .frame(width: 300, height: 400)
- .toolbar {
- if #available(macOS 26.0, *) {
- Button(role: .close) {
- self.dismiss()
- }
- }
- }
- }
-}
-
struct MessageView: View {
@Environment(HotlineState.self) private var model: HotlineState
@Environment(\.colorScheme) private var colorScheme
@@ -39,7 +7,7 @@ struct MessageView: View {
@State private var input: String = ""
@State private var scrollPos: Int?
@State private var contentHeight: CGFloat = 0
- @State private var userInfo: UserInfo?
+ @State private var userInfo: HotlineUserClientInfo?
@Namespace private var bottomID
@FocusState private var focusedField: FocusedField?
@@ -60,11 +28,13 @@ struct MessageView: View {
}
.background(Color(nsColor: .textBackgroundColor))
.toolbar {
- ToolbarItem {
- Button {
- self.getUserInfo()
- } label: {
- Image(systemName: "info.circle")
+ if self.model.access?.contains(.canGetClientInfo) == true {
+ ToolbarItem {
+ Button {
+ self.getUserInfo()
+ } label: {
+ Image(systemName: "info.circle")
+ }
}
}
}
@@ -75,8 +45,8 @@ struct MessageView: View {
private func getUserInfo() {
Task {
- if let (username, info) = try await self.model.getClientInfoText(id: self.userID) {
- self.userInfo = UserInfo(username: username, data: info)
+ if let info = try await self.model.getClientInfoText(id: self.userID) {
+ self.userInfo = info
}
}
}
diff --git a/Hotline/macOS/UserInfo.swift b/Hotline/macOS/UserInfo.swift
new file mode 100644
index 0000000..328fc02
--- /dev/null
+++ b/Hotline/macOS/UserInfo.swift
@@ -0,0 +1,25 @@
+import SwiftUI
+
+struct UserInfoView: View {
+ @Environment(\.dismiss) private var dismiss
+
+ let info: HotlineUserClientInfo
+
+ var body: some View {
+ ScrollView(.vertical) {
+ Text(self.info.details)
+ .fontDesign(.monospaced)
+ .textSelection(.enabled)
+ .frame(maxWidth: .infinity, alignment: .topLeading)
+ .padding()
+ }
+ .frame(width: 350, height: 400)
+ .toolbar {
+ ToolbarItem(placement: .confirmationAction) {
+ Button("OK") {
+ self.dismiss()
+ }
+ }
+ }
+ }
+}