IceCubesApp/Packages/DesignSystem/Sources/DesignSystem/AccountExt.swift
Thomas Ricouard b1f81dbe2f Fix build
2022-12-25 13:11:51 +01:00

33 lines
886 B
Swift

import Foundation
import SwiftUI
import Nuke
import NukeUI
import Models
@MainActor
extension Account {
public var displayNameWithEmojis: some View {
let splittedDisplayName = displayName.split(separator: ":")
return HStack(spacing: 0) {
ForEach(splittedDisplayName, id: \.self) { part in
if let emoji = emojis.first(where: { $0.shortcode == part }) {
LazyImage(url: emoji.url) { state in
if let image = state.image {
image
.resizingMode(.aspectFit)
} else if state.isLoading {
ProgressView()
} else {
ProgressView()
}
}
.processors([ImageProcessors.Resize(size: .init(width: 20, height: 20))])
.frame(width: 20, height: 20)
} else {
Text(part)
}
}
}
}
}