~ knotless Search/
↑↓ move↵ open⇧↵ all results

geesawra.industries/old-fella

Old people's social media app

0
1
main
43 lines · 1.3 KB Raw History
import Foundation

struct PadColumn: Identifiable, Codable, Equatable {
    enum Detail: Codable, Equatable {
        case post(String)
        case profile(String)
        case profileConnections(String, ProfileConnectionKind)

        var title: String {
            switch self {
            case .post: return "Post"
            case .profile: return "Profile"
            case .profileConnections(_, let kind): return kind.title
            }
        }
    }

    let id: String
    let title: String
    let feed: CustomFeed?
    let isNotifications: Bool
    let detail: Detail?

    static let following = PadColumn(id: "following", title: "Following", feed: nil, isNotifications: false)
    static let notifications = PadColumn(id: "notifications", title: "Notifications", feed: nil, isNotifications: true)

    init(id: String, title: String, feed: CustomFeed?, isNotifications: Bool, detail: Detail? = nil) {
        self.id = id
        self.title = title
        self.feed = feed
        self.isNotifications = isNotifications
        self.detail = detail
    }

    init(feed: CustomFeed) {
        self.init(id: feed.id, title: feed.name, feed: feed, isNotifications: false)
    }

    init(detail: Detail) {
        self.init(
            id: "detail-\(UUID().uuidString)", title: detail.title, feed: nil, isNotifications: false, detail: detail)
    }
}