mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Show user statuses in mention suggestions.
This commit is contained in:
+60
-9
@@ -6,6 +6,7 @@
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct MentionSuggestionItemView: View {
|
||||
@@ -13,19 +14,29 @@ struct MentionSuggestionItemView: View {
|
||||
let item: SuggestionItem
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .center, spacing: 16) {
|
||||
HStack(alignment: .center, spacing: 12) {
|
||||
avatar
|
||||
.accessibilityHidden(true)
|
||||
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
Text(item.displayName)
|
||||
.font(.compound.bodyLG)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
.lineLimit(1)
|
||||
HStack(spacing: 2) {
|
||||
Text(item.displayName)
|
||||
.lineLimit(1)
|
||||
.padding(.vertical, 1) // Compensation for Figma line height.
|
||||
|
||||
if let statusEmoji = item.statusEmoji {
|
||||
Text(String(statusEmoji))
|
||||
}
|
||||
}
|
||||
.font(.compound.bodyLG)
|
||||
.foregroundStyle(.compound.textPrimary)
|
||||
|
||||
if let subtitle = item.subtitle {
|
||||
Text(subtitle)
|
||||
.font(.compound.bodySM)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
.foregroundStyle(.compound.textSecondary)
|
||||
.lineLimit(1)
|
||||
.padding(.vertical, 1) // Compensation for Figma line height.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,12 +60,52 @@ struct MentionSuggestionItemView_Previews: PreviewProvider, TestablePreview {
|
||||
static let mockMediaProvider = MediaProviderMock(.init())
|
||||
|
||||
static var previews: some View {
|
||||
MentionSuggestionItemView(mediaProvider: mockMediaProvider, item: .init(suggestionType: .user(.init(id: "test", displayName: "Test", avatarURL: .mockMXCUserAvatar)), range: .init(), rawSuggestionText: ""))
|
||||
MentionSuggestionItemView(mediaProvider: mockMediaProvider,
|
||||
item: .init(suggestionType: .user(.init(id: "test", displayName: "Test", avatarURL: .mockMXCUserAvatar)),
|
||||
range: .init(),
|
||||
rawSuggestionText: ""))
|
||||
.previewDisplayName("User")
|
||||
MentionSuggestionItemView(mediaProvider: mockMediaProvider, item: .init(suggestionType: .user(.init(id: "test2", displayName: nil, avatarURL: nil)), range: .init(), rawSuggestionText: ""))
|
||||
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
MentionSuggestionItemView(mediaProvider: mockMediaProvider,
|
||||
item: .init(suggestionType: .user(.init(id: "@john.smith:example.com",
|
||||
displayName: "John Smith",
|
||||
avatarURL: nil,
|
||||
status: .mockHoliday)),
|
||||
range: .init(),
|
||||
rawSuggestionText: ""))
|
||||
|
||||
MentionSuggestionItemView(mediaProvider: mockMediaProvider,
|
||||
item: .init(suggestionType: .user(.init(id: "@alice.liddel:example.com",
|
||||
displayName: "Alice Liddell",
|
||||
avatarURL: nil,
|
||||
status: .mockCall)),
|
||||
range: .init(),
|
||||
rawSuggestionText: ""))
|
||||
|
||||
MentionSuggestionItemView(mediaProvider: mockMediaProvider,
|
||||
item: .init(suggestionType: .user(.init(id: "@long.name:example.com",
|
||||
displayName: "I have a long name that doesn't fit on one line",
|
||||
avatarURL: nil,
|
||||
status: .mock(text: "Travelling", emoji: "🚆"))),
|
||||
range: .init(),
|
||||
rawSuggestionText: ""))
|
||||
}
|
||||
.padding(16)
|
||||
.previewDisplayName("User with status")
|
||||
|
||||
MentionSuggestionItemView(mediaProvider: mockMediaProvider,
|
||||
item: .init(suggestionType: .user(.init(id: "test2", displayName: nil, avatarURL: nil)),
|
||||
range: .init(),
|
||||
rawSuggestionText: ""))
|
||||
.previewDisplayName("User no display name")
|
||||
MentionSuggestionItemView(mediaProvider: mockMediaProvider, item: .init(suggestionType: .allUsers(.room(id: "room", name: "Room", avatarURL: .mockMXCAvatar)), range: .init(), rawSuggestionText: ""))
|
||||
|
||||
MentionSuggestionItemView(mediaProvider: mockMediaProvider,
|
||||
item: .init(suggestionType: .allUsers(.room(id: "room", name: "Room", avatarURL: .mockMXCAvatar)),
|
||||
range: .init(),
|
||||
rawSuggestionText: ""))
|
||||
.previewDisplayName("All users")
|
||||
|
||||
MentionSuggestionItemView(mediaProvider: mockMediaProvider,
|
||||
item: .init(suggestionType: .room(.init(id: "room",
|
||||
canonicalAlias: "#room:matrix.org",
|
||||
|
||||
Reference in New Issue
Block a user