From d01bbda5dc42b8abeb352e933e5ec79bea7d381d Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Fri, 23 Dec 2022 17:50:51 +0100 Subject: [PATCH] Better notifications UI --- .../Sources/DesignSystem/DesignSystem.swift | 2 +- .../Notifications/NotificationRowView.swift | 27 ++++++++----------- .../Sources/Status/Row/StatusRowView.swift | 16 +++++++---- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Packages/DesignSystem/Sources/DesignSystem/DesignSystem.swift b/Packages/DesignSystem/Sources/DesignSystem/DesignSystem.swift index 886bd242..ba89ddfb 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/DesignSystem.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/DesignSystem.swift @@ -3,6 +3,6 @@ import Foundation public struct DS { public enum Constants { public static let layoutPadding: CGFloat = 20 - public static let dividerPadding: CGFloat = 8 + public static let dividerPadding: CGFloat = 4 } } diff --git a/Packages/Notifications/Sources/Notifications/NotificationRowView.swift b/Packages/Notifications/Sources/Notifications/NotificationRowView.swift index b74e655f..737ab154 100644 --- a/Packages/Notifications/Sources/Notifications/NotificationRowView.swift +++ b/Packages/Notifications/Sources/Notifications/NotificationRowView.swift @@ -19,14 +19,18 @@ struct NotificationRowView: View { } VStack(alignment: .leading, spacing: 0) { HStack(spacing: 0) { - if type.displayAccountName() { - notification.account.displayNameWithEmojis - .font(.subheadline) - .fontWeight(.semibold) - Text(" ") - } - Text(type.label()) + Text(notification.account.displayName) .font(.subheadline) + .fontWeight(.semibold) + + Text(" ") + + Text(type.label()) + .font(.subheadline) + + Text(" βΈ± ") + .font(.footnote) + .foregroundColor(.gray) + + Text(notification.createdAt.formatted) + .font(.footnote) + .foregroundColor(.gray) Spacer() } if let status = notification.status { @@ -52,15 +56,6 @@ struct NotificationRowView: View { } extension Models.Notification.NotificationType { - func displayAccountName() -> Bool { - switch self { - case .status, .mention, .reblog, .follow, .follow_request, .favourite: - return true - case .poll, .update: - return false - } - } - func label() -> String { switch self { case .status: diff --git a/Packages/Status/Sources/Status/Row/StatusRowView.swift b/Packages/Status/Sources/Status/Row/StatusRowView.swift index 9b854af2..47ac7a0e 100644 --- a/Packages/Status/Sources/Status/Row/StatusRowView.swift +++ b/Packages/Status/Sources/Status/Row/StatusRowView.swift @@ -18,8 +18,10 @@ public struct StatusRowView: View { VStack(alignment: .leading) { reblogView statusView - StatusActionsView(viewModel: viewModel) - .padding(.vertical, 8) + if !viewModel.isEmbed { + StatusActionsView(viewModel: viewModel) + .padding(.vertical, 8) + } } .onAppear { viewModel.client = client @@ -64,10 +66,14 @@ public struct StatusRowView: View { }) if !status.mediaAttachments.isEmpty { - StatusMediaPreviewView(attachements: status.mediaAttachments) - .padding(.vertical, 4) + if viewModel.isEmbed { + Image(systemName: "paperclip") + } else { + StatusMediaPreviewView(attachements: status.mediaAttachments) + .padding(.vertical, 4) + } } - if let card = status.card { + if let card = status.card, !viewModel.isEmbed { StatusCardView(card: card) } }