Better notifications UI

This commit is contained in:
Thomas Ricouard 2022-12-23 17:50:51 +01:00
parent 2f7653d05c
commit d01bbda5dc
3 changed files with 23 additions and 22 deletions

View file

@ -3,6 +3,6 @@ import Foundation
public struct DS { public struct DS {
public enum Constants { public enum Constants {
public static let layoutPadding: CGFloat = 20 public static let layoutPadding: CGFloat = 20
public static let dividerPadding: CGFloat = 8 public static let dividerPadding: CGFloat = 4
} }
} }

View file

@ -19,14 +19,18 @@ struct NotificationRowView: View {
} }
VStack(alignment: .leading, spacing: 0) { VStack(alignment: .leading, spacing: 0) {
HStack(spacing: 0) { HStack(spacing: 0) {
if type.displayAccountName() { Text(notification.account.displayName)
notification.account.displayNameWithEmojis
.font(.subheadline)
.fontWeight(.semibold)
Text(" ")
}
Text(type.label())
.font(.subheadline) .font(.subheadline)
.fontWeight(.semibold) +
Text(" ") +
Text(type.label())
.font(.subheadline) +
Text("")
.font(.footnote)
.foregroundColor(.gray) +
Text(notification.createdAt.formatted)
.font(.footnote)
.foregroundColor(.gray)
Spacer() Spacer()
} }
if let status = notification.status { if let status = notification.status {
@ -52,15 +56,6 @@ struct NotificationRowView: View {
} }
extension Models.Notification.NotificationType { 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 { func label() -> String {
switch self { switch self {
case .status: case .status:

View file

@ -18,8 +18,10 @@ public struct StatusRowView: View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
reblogView reblogView
statusView statusView
StatusActionsView(viewModel: viewModel) if !viewModel.isEmbed {
.padding(.vertical, 8) StatusActionsView(viewModel: viewModel)
.padding(.vertical, 8)
}
} }
.onAppear { .onAppear {
viewModel.client = client viewModel.client = client
@ -64,10 +66,14 @@ public struct StatusRowView: View {
}) })
if !status.mediaAttachments.isEmpty { if !status.mediaAttachments.isEmpty {
StatusMediaPreviewView(attachements: status.mediaAttachments) if viewModel.isEmbed {
.padding(.vertical, 4) 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) StatusCardView(card: card)
} }
} }