diff --git a/Packages/Models/Sources/Models/Status.swift b/Packages/Models/Sources/Models/Status.swift index f121a2c3..08d873eb 100644 --- a/Packages/Models/Sources/Models/Status.swift +++ b/Packages/Models/Sources/Models/Status.swift @@ -55,7 +55,7 @@ public protocol AnyStatus { } protocol StatusUI { - var uiShouldHighlight: Bool? { get set } + var userMentioned: Bool? { get set } } public struct Status: AnyStatus, Codable, Identifiable, Equatable, Hashable, StatusUI { @@ -63,7 +63,7 @@ public struct Status: AnyStatus, Codable, Identifiable, Equatable, Hashable, Sta id + createdAt + (editedAt ?? "") } - public var uiShouldHighlight: Bool? + public var userMentioned: Bool? public static func == (lhs: Status, rhs: Status) -> Bool { lhs.id == rhs.id diff --git a/Packages/Status/Sources/Status/Row/StatusRowView.swift b/Packages/Status/Sources/Status/Row/StatusRowView.swift index fc1c72e7..3379034a 100644 --- a/Packages/Status/Sources/Status/Row/StatusRowView.swift +++ b/Packages/Status/Sources/Status/Row/StatusRowView.swift @@ -83,7 +83,7 @@ public struct StatusRowView: View { .contextMenu { contextMenu } - .listRowBackground(viewModel.shouldHighlightRow ? theme.secondaryBackgroundColor : theme.primaryBackgroundColor) + .listRowBackground(viewModel.highlightRowColor) .swipeActions(edge: .trailing) { if !viewModel.isCompact { trailinSwipeActions diff --git a/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift b/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift index 58aa5257..4a22dc3b 100644 --- a/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift +++ b/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift @@ -3,6 +3,8 @@ import Models import Network import SwiftUI +import DesignSystem + @MainActor public class StatusRowViewModel: ObservableObject { let status: Status @@ -30,6 +32,8 @@ public class StatusRowViewModel: ObservableObject { @Published var favoriters: [Account] = [] @Published var rebloggers: [Account] = [] + + private let theme = Theme.shared var seen = false @@ -37,8 +41,15 @@ public class StatusRowViewModel: ObservableObject { status.reblog?.filtered?.first ?? status.filtered?.first } - var shouldHighlightRow: Bool { - status.uiShouldHighlight != nil + var highlightRowColor: Color { + + if status.visibility == .direct { + return theme.tintColor.opacity(0.15) + } else if status.userMentioned != nil { + return theme.secondaryBackgroundColor + } else { + return theme.primaryBackgroundColor + } } var client: Client? diff --git a/Packages/Timeline/Sources/Timeline/TimelineViewModel.swift b/Packages/Timeline/Sources/Timeline/TimelineViewModel.swift index 806ab973..9f31a6ef 100644 --- a/Packages/Timeline/Sources/Timeline/TimelineViewModel.swift +++ b/Packages/Timeline/Sources/Timeline/TimelineViewModel.swift @@ -102,7 +102,7 @@ class TimelineViewModel: ObservableObject { var newStatus = event.status if let accountId { if newStatus.mentions.first(where: { $0.id == accountId }) != nil { - newStatus.uiShouldHighlight = true + newStatus.userMentioned = true } } statuses.insert(newStatus, at: 0) @@ -344,7 +344,7 @@ extension TimelineViewModel: StatusesFetcher { if !statuses.isEmpty, let accountId { for i in statuses.indices { if statuses[i].mentions.first(where: { $0.id == accountId }) != nil { - statuses[i].uiShouldHighlight = true + statuses[i].userMentioned = true } } }