* refactored the static location screen to the location sharing screen # Conflicts: # UnitTests/Sources/LocationSharingScreenViewModelTests.swift # Conflicts: # ElementX.xcodeproj/project.pbxproj * implemented a custom pin with an overlayable view * implemented the render of the user when the location is sender instead of the pin type * removed description and body they are not used at all. * reimplemented single button for sharing this or user location + implemented an experimental way to update annotations * removed unnecessary @Suite description * implemented a way to display the alert on top of the sheet and added a spinner to the center user location button * fixed alerts strings * fixed a failing test * improved preview tests
75 lines
2.1 KiB
Swift
75 lines
2.1 KiB
Swift
//
|
|
// Copyright 2025 Element Creations Ltd.
|
|
// Copyright 2023-2025 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import Foundation
|
|
import MatrixRustSDK
|
|
|
|
struct UserProfileProxy: Equatable, Hashable {
|
|
let userID: String
|
|
let displayName: String?
|
|
let avatarURL: URL?
|
|
|
|
init(userID: String, displayName: String? = nil, avatarURL: URL? = nil) {
|
|
self.userID = userID
|
|
self.displayName = displayName
|
|
self.avatarURL = avatarURL
|
|
}
|
|
|
|
init(member: RoomMemberDetails) {
|
|
userID = member.id
|
|
displayName = member.isBanned ? nil : member.name
|
|
avatarURL = member.isBanned ? nil : member.avatarURL
|
|
}
|
|
|
|
init(sender: TimelineItemSender) {
|
|
userID = sender.id
|
|
displayName = sender.displayName
|
|
avatarURL = sender.avatarURL
|
|
}
|
|
|
|
init(sdkUserProfile: MatrixRustSDK.UserProfile) {
|
|
userID = sdkUserProfile.userId
|
|
displayName = sdkUserProfile.displayName
|
|
avatarURL = sdkUserProfile.avatarUrl.flatMap(URL.init(string:))
|
|
}
|
|
|
|
init(sdkRoomHero: MatrixRustSDK.RoomHero) {
|
|
userID = sdkRoomHero.userId
|
|
displayName = sdkRoomHero.displayName
|
|
avatarURL = sdkRoomHero.avatarUrl.flatMap(URL.init(string:))
|
|
}
|
|
|
|
init(member: RoomMemberProxyProtocol) {
|
|
self.init(member: RoomMemberDetails(withProxy: member))
|
|
}
|
|
|
|
/// A user is meant to be "verified" when the GET profile returns back either the display name or the avatar
|
|
/// If isn't we aren't sure that the related matrix id really exists.
|
|
var isVerified: Bool {
|
|
displayName != nil || avatarURL != nil
|
|
}
|
|
}
|
|
|
|
struct SearchUsersResultsProxy {
|
|
let results: [UserProfileProxy]
|
|
let limited: Bool
|
|
}
|
|
|
|
extension SearchUsersResultsProxy {
|
|
init(sdkResults: MatrixRustSDK.SearchUsersResults) {
|
|
results = sdkResults.results.map(UserProfileProxy.init)
|
|
limited = sdkResults.limited
|
|
}
|
|
}
|
|
|
|
extension UserProfileProxy: Identifiable {
|
|
var id: String {
|
|
userID
|
|
}
|
|
}
|