Add link to profile from notifications.
This commit is contained in:
parent
d12f60e00a
commit
2c22651cac
|
@ -6,6 +6,7 @@
|
|||
|
||||
import SwiftUI
|
||||
import MastodonKit
|
||||
import Foundation
|
||||
|
||||
struct AccountsView: View {
|
||||
public enum ListType {
|
||||
|
@ -68,7 +69,7 @@ struct AccountsView: View {
|
|||
}
|
||||
}
|
||||
.navigationBarTitle(self.getTitle())
|
||||
.listStyle(PlainListStyle())
|
||||
.listStyle(.plain)
|
||||
.task {
|
||||
if self.accounts.isEmpty == false {
|
||||
return
|
||||
|
|
|
@ -23,38 +23,7 @@ struct NotificationsView: View {
|
|||
var body: some View {
|
||||
List {
|
||||
ForEach(notifications, id: \.id) { notification in
|
||||
switch notification.type {
|
||||
case .favourite, .reblog, .mention, .status, .poll, .update:
|
||||
if let status = notification.status, let statusViewModel = StatusViewModel(status: status) {
|
||||
NavigationLink(value: RouteurDestinations.status(
|
||||
id: statusViewModel.id,
|
||||
blurhash: statusViewModel.mediaAttachments.first?.blurhash,
|
||||
metaImageWidth: statusViewModel.getImageWidth(),
|
||||
metaImageHeight: statusViewModel.getImageHeight())
|
||||
) {
|
||||
NotificationRow(notification: notification)
|
||||
}
|
||||
.buttonStyle(EmptyButtonStyle())
|
||||
}
|
||||
case .follow, .followRequest, .adminSignUp:
|
||||
NavigationLink(value: RouteurDestinations.userProfile(
|
||||
accountId: notification.account.id,
|
||||
accountDisplayName: notification.account.displayNameWithoutEmojis,
|
||||
accountUserName: notification.account.acct)
|
||||
) {
|
||||
NotificationRow(notification: notification)
|
||||
}
|
||||
case .adminReport:
|
||||
if let targetAccount = notification.report?.targetAccount {
|
||||
NavigationLink(value: RouteurDestinations.userProfile(
|
||||
accountId: targetAccount.id,
|
||||
accountDisplayName: targetAccount.displayNameWithoutEmojis,
|
||||
accountUserName: targetAccount.acct)
|
||||
) {
|
||||
NotificationRow(notification: notification)
|
||||
}
|
||||
}
|
||||
}
|
||||
NotificationRow(notification: notification)
|
||||
}
|
||||
|
||||
if allItemsLoaded == false && firstLoadFinished == true {
|
||||
|
|
|
@ -10,6 +10,7 @@ import NukeUI
|
|||
|
||||
struct NotificationRow: View {
|
||||
@EnvironmentObject var applicationState: ApplicationState
|
||||
@EnvironmentObject var routerPath: RouterPath
|
||||
|
||||
@State public var notification: MastodonKit.Notification
|
||||
|
||||
|
@ -21,6 +22,11 @@ struct NotificationRow: View {
|
|||
HStack {
|
||||
Spacer()
|
||||
UserAvatar(accountAvatar: self.notification.account.avatar, size: .list)
|
||||
.onTapGesture {
|
||||
self.routerPath.navigate(to: .userProfile(accountId: notification.account.id,
|
||||
accountDisplayName: notification.account.displayNameWithoutEmojis,
|
||||
accountUserName: notification.account.acct))
|
||||
}
|
||||
}
|
||||
self.notificationBadge()
|
||||
}
|
||||
|
@ -80,6 +86,29 @@ struct NotificationRow: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
switch notification.type {
|
||||
case .favourite, .reblog, .mention, .status, .poll, .update:
|
||||
if let status = notification.status {
|
||||
let statusViewModel = StatusViewModel(status: status)
|
||||
self.routerPath.navigate(to: .status(id: statusViewModel.id,
|
||||
blurhash: statusViewModel.mediaAttachments.first?.blurhash,
|
||||
metaImageWidth: statusViewModel.getImageWidth(),
|
||||
metaImageHeight: statusViewModel.getImageHeight()))
|
||||
}
|
||||
case .follow, .followRequest, .adminSignUp:
|
||||
self.routerPath.navigate(to: .userProfile(accountId: notification.account.id,
|
||||
accountDisplayName: notification.account.displayNameWithoutEmojis,
|
||||
accountUserName: notification.account.acct))
|
||||
case .adminReport:
|
||||
if let targetAccount = notification.report?.targetAccount {
|
||||
self.routerPath.navigate(to: .userProfile(accountId: targetAccount.id,
|
||||
accountDisplayName: targetAccount.displayNameWithoutEmojis,
|
||||
accountUserName: targetAccount.acct))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func notificationBadge() -> some View {
|
||||
|
|
Loading…
Reference in New Issue