mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
45 lines
1.0 KiB
Swift
45 lines
1.0 KiB
Swift
//
|
|
// Copyright 2023, 2024 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 UIKit
|
|
|
|
enum PillType: Codable, Equatable {
|
|
enum EventRoom: Codable, Equatable {
|
|
case roomAlias(String)
|
|
case roomID(String)
|
|
}
|
|
|
|
case event(room: EventRoom)
|
|
case roomAlias(String)
|
|
case roomID(String)
|
|
/// A pill that mentions a user
|
|
case user(userID: String)
|
|
/// A pill that mentions all users in a room
|
|
case allUsers
|
|
}
|
|
|
|
struct PillTextAttachmentData: Codable, Equatable {
|
|
struct Font: Codable, Equatable {
|
|
let descender: CGFloat
|
|
let lineHeight: CGFloat
|
|
}
|
|
|
|
/// Pill type
|
|
let type: PillType
|
|
|
|
/// Font for the display name
|
|
let fontData: Font
|
|
}
|
|
|
|
extension PillTextAttachmentData {
|
|
init(type: PillType, font: UIFont) {
|
|
self.type = type
|
|
fontData = Font(descender: font.descender, lineHeight: font.lineHeight)
|
|
}
|
|
}
|