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) .font(.subheadline)
.fontWeight(.semibold) .fontWeight(.semibold) +
Text(" ") Text(" ") +
}
Text(type.label()) Text(type.label())
.font(.subheadline) .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,9 +18,11 @@ public struct StatusRowView: View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
reblogView reblogView
statusView statusView
if !viewModel.isEmbed {
StatusActionsView(viewModel: viewModel) StatusActionsView(viewModel: viewModel)
.padding(.vertical, 8) .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 {
if viewModel.isEmbed {
Image(systemName: "paperclip")
} else {
StatusMediaPreviewView(attachements: status.mediaAttachments) StatusMediaPreviewView(attachements: status.mediaAttachments)
.padding(.vertical, 4) .padding(.vertical, 4)
} }
if let card = status.card { }
if let card = status.card, !viewModel.isEmbed {
StatusCardView(card: card) StatusCardView(card: card)
} }
} }