2022-12-19 11:28:55 +00:00
|
|
|
import SwiftUI
|
|
|
|
import Models
|
|
|
|
import DesignSystem
|
|
|
|
import Status
|
2022-12-22 09:53:36 +00:00
|
|
|
import Env
|
2022-12-19 11:28:55 +00:00
|
|
|
|
|
|
|
struct NotificationRowView: View {
|
|
|
|
@EnvironmentObject private var routeurPath: RouterPath
|
|
|
|
@Environment(\.redactionReasons) private var reasons
|
|
|
|
|
|
|
|
let notification: Models.Notification
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
if let type = notification.supportedType {
|
|
|
|
HStack(alignment: .top, spacing: 8) {
|
|
|
|
AvatarView(url: notification.account.avatar)
|
|
|
|
.onTapGesture {
|
|
|
|
routeurPath.navigate(to: .accountDetailWithAccount(account: notification.account))
|
|
|
|
}
|
2022-12-22 18:00:23 +00:00
|
|
|
VStack(alignment: .leading, spacing: 0) {
|
2022-12-19 11:28:55 +00:00
|
|
|
HStack(spacing: 0) {
|
2022-12-23 16:50:51 +00:00
|
|
|
Text(notification.account.displayName)
|
2022-12-21 16:39:48 +00:00
|
|
|
.font(.subheadline)
|
2022-12-23 16:50:51 +00:00
|
|
|
.fontWeight(.semibold) +
|
|
|
|
Text(" ") +
|
|
|
|
Text(type.label())
|
|
|
|
.font(.subheadline) +
|
|
|
|
Text(" ⸱ ")
|
|
|
|
.font(.footnote)
|
|
|
|
.foregroundColor(.gray) +
|
|
|
|
Text(notification.createdAt.formatted)
|
|
|
|
.font(.footnote)
|
|
|
|
.foregroundColor(.gray)
|
2022-12-21 11:39:29 +00:00
|
|
|
Spacer()
|
2022-12-19 11:28:55 +00:00
|
|
|
}
|
|
|
|
if let status = notification.status {
|
2022-12-20 19:33:45 +00:00
|
|
|
StatusRowView(viewModel: .init(status: status, isEmbed: true))
|
2022-12-21 11:39:29 +00:00
|
|
|
.padding(8)
|
|
|
|
.background(Color.gray.opacity(0.10))
|
|
|
|
.overlay(
|
|
|
|
RoundedRectangle(cornerRadius: 4)
|
|
|
|
.stroke(.gray.opacity(0.35), lineWidth: 1)
|
|
|
|
)
|
|
|
|
.padding(.top, 8)
|
2022-12-19 11:28:55 +00:00
|
|
|
} else {
|
|
|
|
Text(notification.account.acct)
|
|
|
|
.font(.callout)
|
|
|
|
.foregroundColor(.gray)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
EmptyView()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension Models.Notification.NotificationType {
|
|
|
|
func label() -> String {
|
|
|
|
switch self {
|
|
|
|
case .status:
|
|
|
|
return "posted a status"
|
|
|
|
case .mention:
|
|
|
|
return "mentionned you"
|
|
|
|
case .reblog:
|
|
|
|
return "boosted"
|
|
|
|
case .follow:
|
|
|
|
return "followed you"
|
|
|
|
case .follow_request:
|
|
|
|
return "request to follow you"
|
|
|
|
case .favourite:
|
|
|
|
return "starred"
|
|
|
|
case .poll:
|
|
|
|
return "poll ended"
|
|
|
|
case .update:
|
|
|
|
return "has been edited"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct NotificationRowView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
NotificationRowView(notification: .placeholder())
|
|
|
|
}
|
|
|
|
}
|