mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Configure the media preview screen based on the event and presentation. (#3604)
* Configure media previews based on the presenting screen. * Switch on TimelineKind instead of having an isPinnedEventsTimeline Bool.
This commit is contained in:
@@ -345,7 +345,7 @@ struct TimelineItemMenu_Previews: PreviewProvider, TestablePreview {
|
||||
isDM: true,
|
||||
isViewSourceEnabled: true,
|
||||
isCreateMediaCaptionsEnabled: true,
|
||||
isPinnedEventsTimeline: false,
|
||||
timelineKind: .live,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings))
|
||||
guard let actions = provider.makeActions() else { return nil }
|
||||
|
||||
|
||||
@@ -82,9 +82,9 @@ enum TimelineItemMenuAction: Identifiable, Hashable {
|
||||
var switchToDefaultComposer: Bool {
|
||||
switch self {
|
||||
case .reply, .edit, .addCaption, .editCaption, .editPoll:
|
||||
return false
|
||||
false
|
||||
default:
|
||||
return true
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,9 +92,9 @@ enum TimelineItemMenuAction: Identifiable, Hashable {
|
||||
var canAppearInFailedEcho: Bool {
|
||||
switch self {
|
||||
case .copy, .edit, .redact, .viewSource, .editPoll:
|
||||
return true
|
||||
true
|
||||
default:
|
||||
return false
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,9 +102,9 @@ enum TimelineItemMenuAction: Identifiable, Hashable {
|
||||
var canAppearInRedacted: Bool {
|
||||
switch self {
|
||||
case .viewSource, .unpin, .viewInRoomTimeline:
|
||||
return true
|
||||
true
|
||||
default:
|
||||
return false
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,18 +112,27 @@ enum TimelineItemMenuAction: Identifiable, Hashable {
|
||||
var isDestructive: Bool {
|
||||
switch self {
|
||||
case .redact, .report, .removeCaption:
|
||||
return true
|
||||
true
|
||||
default:
|
||||
return false
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
var canAppearInPinnedEventsTimeline: Bool {
|
||||
switch self {
|
||||
case .viewInRoomTimeline, .pin, .unpin, .forward:
|
||||
return true
|
||||
true
|
||||
default:
|
||||
return false
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
var canAppearInMediaDetails: Bool {
|
||||
switch self {
|
||||
case .viewInRoomTimeline, .redact:
|
||||
true
|
||||
default:
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-7
@@ -17,7 +17,7 @@ struct TimelineItemMenuActionProvider {
|
||||
let isDM: Bool
|
||||
let isViewSourceEnabled: Bool
|
||||
let isCreateMediaCaptionsEnabled: Bool
|
||||
let isPinnedEventsTimeline: Bool
|
||||
let timelineKind: TimelineKind
|
||||
let emojiProvider: EmojiProviderProtocol
|
||||
|
||||
// swiftlint:disable:next cyclomatic_complexity
|
||||
@@ -38,6 +38,10 @@ struct TimelineItemMenuActionProvider {
|
||||
|
||||
var actions: [TimelineItemMenuAction] = []
|
||||
var secondaryActions: [TimelineItemMenuAction] = []
|
||||
|
||||
if timelineKind == .pinned || timelineKind == .media(.mediaFilesScreen) {
|
||||
actions.append(.viewInRoomTimeline)
|
||||
}
|
||||
|
||||
if item.canBeRepliedTo {
|
||||
if let messageItem = item as? EventBasedMessageTimelineItemProtocol {
|
||||
@@ -99,10 +103,15 @@ struct TimelineItemMenuActionProvider {
|
||||
secondaryActions.append(.redact)
|
||||
}
|
||||
|
||||
if isPinnedEventsTimeline {
|
||||
actions.insert(.viewInRoomTimeline, at: 0)
|
||||
switch timelineKind {
|
||||
case .pinned:
|
||||
actions = actions.filter(\.canAppearInPinnedEventsTimeline)
|
||||
secondaryActions = secondaryActions.filter(\.canAppearInPinnedEventsTimeline)
|
||||
case .media:
|
||||
actions = actions.filter(\.canAppearInMediaDetails)
|
||||
secondaryActions = secondaryActions.filter(\.canAppearInMediaDetails)
|
||||
case .live, .detached:
|
||||
break // viewInRoomTimeline is the only non-room item and was added conditionally.
|
||||
}
|
||||
|
||||
if item.hasFailedToSend {
|
||||
@@ -114,11 +123,10 @@ struct TimelineItemMenuActionProvider {
|
||||
actions = actions.filter(\.canAppearInRedacted)
|
||||
secondaryActions = secondaryActions.filter(\.canAppearInRedacted)
|
||||
}
|
||||
|
||||
let isReactable = timelineKind == .live || timelineKind == .detached ? item.isReactable : false
|
||||
|
||||
return .init(isReactable: isPinnedEventsTimeline ? false : item.isReactable,
|
||||
actions: actions,
|
||||
secondaryActions: secondaryActions,
|
||||
emojiProvider: emojiProvider)
|
||||
return .init(isReactable: isReactable, actions: actions, secondaryActions: secondaryActions, emojiProvider: emojiProvider)
|
||||
}
|
||||
|
||||
private func makeEncryptedItemActions(_ encryptedItem: EncryptedRoomTimelineItem) -> TimelineItemMenuActions? {
|
||||
|
||||
Reference in New Issue
Block a user