mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 11:58:32 +00:00
pr suggestions
This commit is contained in:
+2
-2
@@ -8,7 +8,7 @@
|
||||
import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct Highlight: ViewModifier {
|
||||
struct HorizontalHighlightGradient: ViewModifier {
|
||||
let borderColor: Color
|
||||
let primaryColor: Color
|
||||
let secondaryColor: Color
|
||||
@@ -30,6 +30,6 @@ struct Highlight: ViewModifier {
|
||||
|
||||
extension View {
|
||||
func highlight(borderColor: Color, primaryColor: Color, secondaryColor: Color) -> some View {
|
||||
modifier(Highlight(borderColor: borderColor, primaryColor: primaryColor, secondaryColor: secondaryColor))
|
||||
modifier(HorizontalHighlightGradient(borderColor: borderColor, primaryColor: primaryColor, secondaryColor: secondaryColor))
|
||||
}
|
||||
}
|
||||
@@ -199,6 +199,14 @@ struct HomeScreenRoom: Identifiable, Equatable {
|
||||
|
||||
let isTombstoned: Bool
|
||||
|
||||
var displayedLastMessage: AttributedString? {
|
||||
// If the room is tombstoned, show a specific message, regardless of any last message.
|
||||
guard !isTombstoned else {
|
||||
return AttributedString(L10n.screenRoomlistTombstonedRoomDescription)
|
||||
}
|
||||
return lastMessage
|
||||
}
|
||||
|
||||
static func placeholder() -> HomeScreenRoom {
|
||||
HomeScreenRoom(id: UUID().uuidString,
|
||||
roomID: nil,
|
||||
|
||||
@@ -135,12 +135,8 @@ struct HomeScreenRoomCell: View {
|
||||
|
||||
@ViewBuilder
|
||||
private var lastMessage: some View {
|
||||
// If the room is tombstoned, show a specific message, regardless of any last message.
|
||||
if room.isTombstoned {
|
||||
Text(L10n.screenRoomlistTombstonedRoomDescription)
|
||||
.lastMessageFormatting()
|
||||
} else if let lastMessage = room.lastMessage {
|
||||
Text(lastMessage)
|
||||
if let displayedLastMessage = room.displayedLastMessage {
|
||||
Text(displayedLastMessage)
|
||||
.lastMessageFormatting()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,6 +331,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
|
||||
private func handleRoomInfoUpdate(_ roomInfo: RoomInfoProxy) async {
|
||||
state.hasSuccessor = roomInfo.successor != nil
|
||||
|
||||
let pinnedEventIDs = roomInfo.pinnedEventIDs
|
||||
// Only update the loading state of the banner
|
||||
if state.pinnedEventsBannerState.isLoading {
|
||||
|
||||
@@ -79,7 +79,7 @@ enum TimelineViewAction {
|
||||
case hasScrolled(direction: ScrollDirection)
|
||||
case setOpenURLAction(OpenURLAction)
|
||||
|
||||
case seePredecessorTapped
|
||||
case displayPredecessorRoom
|
||||
}
|
||||
|
||||
enum TimelineComposerAction {
|
||||
|
||||
@@ -212,8 +212,10 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
||||
actionsSubject.send(.hasScrolled(direction: direction))
|
||||
case .setOpenURLAction(let action):
|
||||
state.openURL = action
|
||||
case .seePredecessorTapped:
|
||||
guard let predecessorID = roomProxy.predecessorRoom?.roomId else { return }
|
||||
case .displayPredecessorRoom:
|
||||
guard let predecessorID = roomProxy.predecessorRoom?.roomId else {
|
||||
fatalError("Predecessor room should exist if this action is triggered.")
|
||||
}
|
||||
actionsSubject.send(.displayRoom(roomID: predecessorID))
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -15,8 +15,9 @@ struct TimelineStartRoomTimelineView: View {
|
||||
var body: some View {
|
||||
VStack(spacing: 14) {
|
||||
if context?.viewState.hasPredecessor == true {
|
||||
upgrade
|
||||
upgradeDialogue
|
||||
}
|
||||
// We don't display the title for tombstoned DMs
|
||||
if context?.viewState.isDirectOneToOneRoom != true {
|
||||
Text(title)
|
||||
.font(.compound.bodySM)
|
||||
@@ -28,13 +29,13 @@ struct TimelineStartRoomTimelineView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var upgrade: some View {
|
||||
private var upgradeDialogue: some View {
|
||||
VStack(spacing: 16) {
|
||||
Text(L10n.screenRoomTimelineUpgradedRoomMessage)
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
Button {
|
||||
context?.send(viewAction: .seePredecessorTapped)
|
||||
context?.send(viewAction: .displayPredecessorRoom)
|
||||
} label: {
|
||||
Text(L10n.screenRoomTimelineUpgradedRoomAction)
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
@@ -34,7 +34,14 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
|
||||
|
||||
var ownUserID: String { room.ownUserId() }
|
||||
|
||||
lazy var predecessorRoom: PredecessorRoom? = room.predecessorRoom()
|
||||
// The predecessor is set on room creation and never changes, so we lazily store it.
|
||||
lazy var predecessorRoom = room.predecessorRoom()
|
||||
|
||||
// The successor may change over time, so we access it dynamically.
|
||||
// It's suggested to observe it through the `infoPublisher`
|
||||
var successorRoom: SuccessorRoom? {
|
||||
room.successorRoom()
|
||||
}
|
||||
|
||||
let timeline: TimelineProxyProtocol
|
||||
|
||||
|
||||
@@ -78,6 +78,8 @@ protocol JoinedRoomProxyProtocol: RoomProxyProtocol {
|
||||
|
||||
var predecessorRoom: PredecessorRoom? { get }
|
||||
|
||||
var successorRoom: SuccessorRoom? { get }
|
||||
|
||||
func subscribeForUpdates() async
|
||||
|
||||
func subscribeToRoomInfoUpdates()
|
||||
|
||||
@@ -55,7 +55,6 @@ struct RoomSummary {
|
||||
|
||||
let isMarkedUnread: Bool
|
||||
let isFavourite: Bool
|
||||
|
||||
let isTombstoned: Bool
|
||||
|
||||
var hasUnreadMessages: Bool { unreadMessagesCount > 0 }
|
||||
|
||||
@@ -480,11 +480,12 @@ class TimelineController: TimelineControllerProtocol {
|
||||
case .readMarker:
|
||||
return ReadMarkerRoomTimelineItem(id: .virtual(uniqueID: uniqueID))
|
||||
case .timelineStart:
|
||||
if hasPredecessor {
|
||||
// We always display the timeline start item, if there is a predecessor room.
|
||||
guard !hasPredecessor else {
|
||||
return TimelineStartRoomTimelineItem(name: roomDisplayName)
|
||||
} else {
|
||||
return isDM ? nil : TimelineStartRoomTimelineItem(name: roomDisplayName)
|
||||
}
|
||||
// If not we only display the timeline start item if this is not a DM.
|
||||
return isDM ? nil : TimelineStartRoomTimelineItem(name: roomDisplayName)
|
||||
}
|
||||
case .unknown:
|
||||
return nil
|
||||
|
||||
+1
@@ -8,6 +8,7 @@
|
||||
import Foundation
|
||||
|
||||
struct TimelineStartRoomTimelineItem: DecorationTimelineItemProtocol, Equatable {
|
||||
// Using a static identifier makes the animations consistent in SwiftUI
|
||||
let id: TimelineItemIdentifier = .virtual(uniqueID: .init("TimelineStart"))
|
||||
let name: String?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user