From 1e3c748119c6e9eec27f02146f17ea0302ff648a Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Thu, 19 Mar 2026 01:53:46 -0500 Subject: feat: add inbox threads and move builds under more --- Hutch/Views/Inbox/InboxView.swift | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'Hutch/Views/Inbox/InboxView.swift') diff --git a/Hutch/Views/Inbox/InboxView.swift b/Hutch/Views/Inbox/InboxView.swift index e5f3619..602f8d9 100644 --- a/Hutch/Views/Inbox/InboxView.swift +++ b/Hutch/Views/Inbox/InboxView.swift @@ -31,6 +31,12 @@ struct InboxView: View { NavigationLink(value: thread) { InboxThreadRow(thread: thread) } + .swipeActions(edge: .leading, allowsFullSwipe: true) { + readStateAction(for: thread, in: viewModel) + } + .swipeActions(edge: .trailing, allowsFullSwipe: true) { + readStateAction(for: thread, in: viewModel) + } } } .listStyle(.plain) @@ -39,7 +45,7 @@ struct InboxView: View { SRHTLoadingStateView(message: "Loading inbox…") } else if let error = viewModel.error, viewModel.threads.isEmpty { SRHTErrorStateView( - title: "Couldn't Load Threads", + title: "Failed to load inbox", message: error, retryAction: { await viewModel.loadThreads() } ) @@ -64,6 +70,21 @@ struct InboxView: View { } } } + + @ViewBuilder + private func readStateAction(for thread: InboxThreadSummary, in viewModel: InboxViewModel) -> some View { + Button { + withAnimation(.easeInOut(duration: 0.2)) { + viewModel.toggleThreadReadState(thread) + } + } label: { + Label( + thread.isUnread ? "Mark as Read" : "Mark as Unread", + systemImage: thread.isUnread ? "envelope.open" : "envelope.badge" + ) + } + .tint(thread.isUnread ? .blue : .gray) + } } private struct InboxThreadRow: View { -- cgit v1.2.3