Tusker/Packages/Pachyderm/Sources/Pachyderm/Model/Visibility.swift

83 lines
1.8 KiB
Swift

//
// Visibility.swift
// Pachyderm
//
// Created by Shadowfacts on 3/7/23.
//
import Foundation
public enum Visibility: String, Sendable, Codable, CaseIterable, Comparable {
case `public`
case unlisted
case `private`
case direct
public static func < (lhs: Visibility, rhs: Visibility) -> Bool {
switch (lhs, rhs) {
case (.direct, .public), (.private, .public), (.unlisted, .public):
return true
case (.direct, .unlisted), (.private, .unlisted):
return true
case (.direct, .private):
return true
default:
return false
}
}
}
public extension Visibility {
var displayName: String {
switch self {
case .public:
return "Public"
case .unlisted:
return "Unlisted"
case .private:
return "Private"
case .direct:
return "Direct"
}
}
var subtitle: String {
switch self {
case .public:
return "Everyone"
case .unlisted:
return "Hidden from public timelines"
case .private:
return "Followers only"
case .direct:
return "Mentioned users only"
}
}
var imageName: String {
switch self {
case .public:
return "globe"
case .unlisted:
return "lock.open.fill"
case .private:
return "lock.fill"
case .direct:
return "envelope.fill"
}
}
var unfilledImageName: String {
switch self {
case .public:
return "globe"
case .unlisted:
return "lock.open"
case .private:
return "lock"
case .direct:
return "envelope"
}
}
}