From 575e2dbe67eb3d7798d06e43a493b398b3d4833b Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Sat, 28 May 2022 21:27:16 -0400 Subject: [PATCH] Fix actions buttons --- ntfy/Views/NotificationListView.swift | 23 ++++++++++++++++++----- ntfy/Views/SubscriptionListView.swift | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ntfy/Views/NotificationListView.swift b/ntfy/Views/NotificationListView.swift index 3b701e4..357bd55 100644 --- a/ntfy/Views/NotificationListView.swift +++ b/ntfy/Views/NotificationListView.swift @@ -60,7 +60,9 @@ struct NotificationListView: View { } } ToolbarItem(placement: .principal) { - Text(subscription.displayName()).font(.headline) + Text(subscription.displayName()) + .font(.headline) + .lineLimit(1) } ToolbarItem(placement: .navigationBarTrailing) { if (self.editMode == .active) { @@ -221,8 +223,9 @@ struct NotificationListView: View { notificationCenter.getDeliveredNotifications { notifications in let ids = notifications .filter { notification in - if let topic = notification.request.content.userInfo["topic"] as? String { - return topic == subscription.topic // TODO: This is not enough for selfhosted servers + let userInfo = notification.request.content.userInfo + if let baseUrl = userInfo["base_url"] as? String, let topic = userInfo["topic"] as? String { + return baseUrl == subscription.baseUrl && topic == subscription.topic } return false } @@ -291,11 +294,21 @@ struct NotificationRowView: View { Button(action.label) { ActionExecutor.execute(action) } - .buttonStyle(.bordered) + .buttonStyle(.borderedProminent) } else { - Button(action.label) { + Button(action: { ActionExecutor.execute(action) + }) { + Text(action.label) + .padding(EdgeInsets(top: 10.0, leading: 10.0, bottom: 10.0, trailing: 10.0)) + .foregroundColor(.white) + .overlay( + RoundedRectangle(cornerRadius: 10) + .stroke(Color.white, lineWidth: 2) + ) } + .background(Color.accentColor) + .cornerRadius(10) } } } diff --git a/ntfy/Views/SubscriptionListView.swift b/ntfy/Views/SubscriptionListView.swift index c0f32d9..1716737 100644 --- a/ntfy/Views/SubscriptionListView.swift +++ b/ntfy/Views/SubscriptionListView.swift @@ -174,5 +174,6 @@ struct SubscriptionsListView_Previews: PreviewProvider { SubscriptionListView() .environment(\.managedObjectContext, store.context) .environmentObject(store) + .environmentObject(AppDelegate()) } }