24 lines
556 B
Swift
24 lines
556 B
Swift
//
|
|
// WinnerEnvelope.swift
|
|
// iris
|
|
//
|
|
// Created by Codex.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
enum TextConstraints {
|
|
static let titleMax = 26
|
|
static let subtitleMax = 30
|
|
static let ellipsis = "..."
|
|
}
|
|
|
|
extension String {
|
|
func truncated(maxLength: Int) -> String {
|
|
guard count > maxLength else { return self }
|
|
let ellipsisCount = TextConstraints.ellipsis.count
|
|
guard maxLength > ellipsisCount else { return String(prefix(maxLength)) }
|
|
return String(prefix(maxLength - ellipsisCount)) + TextConstraints.ellipsis
|
|
}
|
|
}
|