generated from element-hq/.github
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read Receipts sheet + enabled RR by default (#2123)
- Loading branch information
Showing
21 changed files
with
286 additions
and
29 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
ElementX/Sources/Screens/RoomScreen/View/ReadReceipts/ReadReceiptCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// | ||
// Copyright 2023 New Vector Ltd | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ReadReceiptCell: View { | ||
let readReceipt: ReadReceipt | ||
let memberState: RoomMemberState? | ||
let imageProvider: ImageProviderProtocol? | ||
|
||
private var title: String { | ||
memberState?.displayName ?? readReceipt.userID | ||
} | ||
|
||
private var subtitle: String { | ||
guard title != readReceipt.userID else { | ||
return "" | ||
} | ||
return readReceipt.userID | ||
} | ||
|
||
var body: some View { | ||
HStack(spacing: 12) { | ||
LoadableAvatarImage(url: memberState?.avatarURL, | ||
name: memberState?.displayName, | ||
contentID: readReceipt.userID, | ||
avatarSize: .user(on: .readReceiptSheet), | ||
imageProvider: imageProvider) | ||
VStack(alignment: .leading, spacing: 0) { | ||
HStack(spacing: 12) { | ||
Text(title) | ||
.font(.compound.bodyMDSemibold) | ||
.foregroundColor(.compound.textPrimary) | ||
.lineLimit(1) | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
if let formattedTimestamp = readReceipt.formattedTimestamp { | ||
Text(formattedTimestamp) | ||
.font(.compound.bodyXS) | ||
.foregroundColor(.compound.textSecondary) | ||
.lineLimit(1) | ||
} | ||
} | ||
Text(subtitle) | ||
.font(.compound.bodySM) | ||
.foregroundColor(.compound.textSecondary) | ||
.lineLimit(1) | ||
} | ||
} | ||
.padding(.vertical, 8) | ||
.padding(.horizontal, 16) | ||
} | ||
} | ||
|
||
struct ReadReceiptCell_Previews: PreviewProvider, TestablePreview { | ||
static var previews: some View { | ||
ReadReceiptCell(readReceipt: .init(userID: "@test:matrix.org", | ||
formattedTimestamp: "10:00"), | ||
memberState: .init(displayName: "Test", | ||
avatarURL: nil), | ||
imageProvider: MockMediaProvider()) | ||
.previewDisplayName("No Image") | ||
ReadReceiptCell(readReceipt: .init(userID: "@test:matrix.org", | ||
formattedTimestamp: "10:00"), | ||
memberState: .init(displayName: "Test", | ||
avatarURL: URL.documentsDirectory), | ||
imageProvider: MockMediaProvider()) | ||
.previewDisplayName("With Image") | ||
ReadReceiptCell(readReceipt: .init(userID: "@test:matrix.org", | ||
formattedTimestamp: "10:00"), | ||
memberState: nil, | ||
imageProvider: MockMediaProvider()) | ||
.previewDisplayName("Loading Member") | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
ElementX/Sources/Screens/RoomScreen/View/ReadReceipts/ReadReceiptsSummaryView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// | ||
// Copyright 2023 New Vector Ltd | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ReadReceiptsSummaryView: View { | ||
let orderedReadReceipts: [ReadReceipt] | ||
@EnvironmentObject private var context: RoomScreenViewModel.Context | ||
|
||
var body: some View { | ||
VStack(alignment: .leading, spacing: 16) { | ||
Text(L10n.commonSeenBy) | ||
.font(.compound.bodyLGSemibold) | ||
.foregroundColor(.compound.textPrimary) | ||
.padding(.horizontal, 16) | ||
ScrollView { | ||
LazyVStack(spacing: 0) { | ||
ForEach(orderedReadReceipts) { receipt in | ||
ReadReceiptCell(readReceipt: receipt, | ||
memberState: context.viewState.members[receipt.userID], | ||
imageProvider: context.imageProvider) | ||
} | ||
} | ||
} | ||
} | ||
.padding(.top, 24) | ||
.presentationDetents([.medium, .large]) | ||
.presentationBackground(Color.compound.bgCanvasDefault) | ||
.presentationDragIndicator(.visible) | ||
} | ||
} | ||
|
||
struct ReadReceiptsSummaryView_Previews: PreviewProvider, TestablePreview { | ||
static let viewModel = { | ||
let members: [RoomMemberProxyMock] = [ | ||
.mockAlice, | ||
.mockBob, | ||
.mockCharlie, | ||
.mockDan | ||
] | ||
let roomProxyMock = RoomProxyMock(with: .init(displayName: "Room", members: members)) | ||
let mock = RoomScreenViewModel(roomProxy: roomProxyMock, | ||
timelineController: MockRoomTimelineController(), | ||
mediaProvider: MockMediaProvider(), | ||
mediaPlayerProvider: MediaPlayerProviderMock(), | ||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(), | ||
userIndicatorController: UserIndicatorControllerMock(), | ||
application: ApplicationMock(), | ||
appSettings: ServiceLocator.shared.settings, | ||
analyticsService: ServiceLocator.shared.analytics, | ||
notificationCenter: NotificationCenterMock()) | ||
return mock | ||
}() | ||
|
||
static let orderedReadReceipts: [ReadReceipt] = [ | ||
.init(userID: "@alice:matrix.org", formattedTimestamp: "10:00"), | ||
.init(userID: "@bob:matrix.org", formattedTimestamp: "9:30"), | ||
.init(userID: "@charlie:matrix.org", formattedTimestamp: "9:00"), | ||
.init(userID: "@dan:matrix.org", formattedTimestamp: "8:30"), | ||
.init(userID: "@loading:matrix.org", formattedTimestamp: "Long time ago") | ||
] | ||
|
||
static var previews: some View { | ||
ReadReceiptsSummaryView(orderedReadReceipts: orderedReadReceipts) | ||
.environmentObject(viewModel.context) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
UnitTests/__Snapshots__/PreviewTests/test_readReceiptCell.Loading-Member.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
UnitTests/__Snapshots__/PreviewTests/test_readReceiptCell.No-Image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
UnitTests/__Snapshots__/PreviewTests/test_readReceiptCell.With-Image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
UnitTests/__Snapshots__/PreviewTests/test_readReceiptsSummaryView.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
UnitTests/__Snapshots__/PreviewTests/test_uITimelineView.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Tapping on read receipts will open a detailed sheet of all the receipts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Read Receipts are enabled by default. |