Something went wrong. Try again.
A slopfork of Sam Henri Gold's Twitter client, reskinned like Tweetie 2 / Twitter for iPhone circa 2012. Personal use.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748import Foundationimport PostTextimport Routing
struct EntityTarget: Equatable { /// Its segment, which tells apart two mentions of the same account. let index: Int let entity: PostEntity let rects: [CGRect]
/// Where a tap goes. var url: URL? { entity.destination }
/// The account it previews: a mention, or a link to a profile. var screenName: String? { switch entity { case .mention(let screenName): return screenName case .url(let url): if case .profileHandle(let screenName) = Route(url: url) { return screenName } return nil case .hashtag, .cashtag: return nil } }
/// Its page on Twitter, to copy or share. var webURL: URL? { switch entity { case .mention(let screenName): return URL(string: "https://x.com/\(screenName)") case .hashtag(let tag): var components = URLComponents(string: "https://x.com/hashtag") components?.path += "/\(tag.trimmingPrefix("#"))" return components?.url case .cashtag(let tag): var components = URLComponents(string: "https://x.com/search") components?.queryItems = [URLQueryItem(name: "q", value: tag)] return components?.url case .url(let url): return url } }
/// In-app destinations open in a window of their own; web links open in a web panel window. var route: Route? { url.flatMap(Route.forLink) }}