Skip to content

Commit

Permalink
Add light purple background to notifications about statuses with priv…
Browse files Browse the repository at this point in the history
…ate visibility, as on the web

Contributes to #399 [BUG] Multiple interactions do not collapse into a single notification
  • Loading branch information
whattherestimefor committed Feb 18, 2025
1 parent 523ff0a commit 619bb27
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright © 2025 Mastodon gGmbH. All rights reserved.

import Combine
import MastodonAsset
import MastodonCore
import MastodonLocalization
import MastodonSDK
Expand Down Expand Up @@ -166,6 +167,12 @@ struct NotificationListView: View {
case .groupedNotification(let viewModel):
// TODO: implement unread using Mastodon.Entity.Marker
NotificationRowView(viewModel: viewModel)
.padding(.vertical, 4)
.listRowBackground(
Rectangle()
.fill(viewModel.usePrivateBackground ? Asset.Colors.accent.swiftUIColor : .clear)
.opacity(0.1)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class NotificationRowViewModel: ObservableObject {
let presentError: (Error) -> Void
let defaultNavigation: (() -> Void)?
let iconStyle: GroupedNotificationType.MainIconStyle?
let usePrivateBackground: Bool
let actionSuperheader: (iconName: String, text: String, color: Color)?

@Published public var headerComponents: [NotificationViewComponent] = []
Expand Down Expand Up @@ -58,6 +59,8 @@ class NotificationRowViewModel: ObservableObject {
self.navigateToScene = navigateToScene
self.presentError = presentError
self.defaultNavigation = notificationInfo.defaultNavigation

var needsPrivateBackground = false

switch notificationInfo.groupedNotificationType {

Expand Down Expand Up @@ -99,6 +102,7 @@ class NotificationRowViewModel: ObservableObject {
?? "")
]
contentComponents = [.status(statusViewModel)]
needsPrivateBackground = statusViewModel.visibility == .direct
} else {
actionSuperheader = nil
headerTextComponents = [._other("POST BY UNKNOWN ACCOUNT")]
Expand All @@ -116,6 +120,7 @@ class NotificationRowViewModel: ObservableObject {
?? "")
]
contentComponents = [.status(statusViewModel)]
needsPrivateBackground = statusViewModel.visibility == .direct
} else {
headerTextComponents = [
._other("REBLOGGED/FAVOURITED BY UNKNOWN ACCOUNT")
Expand All @@ -133,6 +138,7 @@ class NotificationRowViewModel: ObservableObject {
?? "")
]
contentComponents = [.status(statusViewModel)]
needsPrivateBackground = statusViewModel.visibility == .direct
} else {
headerTextComponents = [
._other("POLL/UPDATE FROM UNKNOWN ACCOUNT")
Expand Down Expand Up @@ -208,6 +214,9 @@ class NotificationRowViewModel: ObservableObject {
._other("UNEXPECTED NOTIFICATION TYPE: \(text)")
]
}

usePrivateBackground = needsPrivateBackground

resetHeaderComponents()
}

Expand Down

0 comments on commit 619bb27

Please sign in to comment.