diff --git a/Packages/Models/Sources/Models/Status.swift b/Packages/Models/Sources/Models/Status.swift index 79ee59ab..e09818e7 100644 --- a/Packages/Models/Sources/Models/Status.swift +++ b/Packages/Models/Sources/Models/Status.swift @@ -5,6 +5,14 @@ public struct Application: Codable, Identifiable { name } public let name: String + public let website: URL? +} + +public enum Visibility: String, Codable { + case pub = "public" + case unlisted + case priv = "private" + case direct } public protocol AnyStatus { @@ -27,6 +35,7 @@ public protocol AnyStatus { var url: URL? { get } var application: Application? { get } var inReplyToAccountId: String? { get } + var visibility: Visibility { get } } @@ -54,6 +63,7 @@ public struct Status: AnyStatus, Codable, Identifiable { public let url: URL? public let application: Application? public let inReplyToAccountId: String? + public let visibility: Visibility public static func placeholder() -> Status { .init(id: UUID().uuidString, @@ -74,7 +84,8 @@ public struct Status: AnyStatus, Codable, Identifiable { emojis: [], url: nil, application: nil, - inReplyToAccountId: nil) + inReplyToAccountId: nil, + visibility: .pub) } public static func placeholders() -> [Status] { @@ -105,4 +116,5 @@ public struct ReblogStatus: AnyStatus, Codable, Identifiable { public let url: URL? public var application: Application? public let inReplyToAccountId: String? + public let visibility: Visibility } diff --git a/Packages/Status/Sources/Status/Ext/Visibility.swift b/Packages/Status/Sources/Status/Ext/Visibility.swift new file mode 100644 index 00000000..b3bcc22c --- /dev/null +++ b/Packages/Status/Sources/Status/Ext/Visibility.swift @@ -0,0 +1,16 @@ +import Models + +extension Visibility { + public var iconName: String { + switch self { + case .pub: + return "globe.americas" + case .unlisted: + return "lock.open" + case .priv: + return "lock" + case .direct: + return "at.circle" + } + } +} diff --git a/Packages/Status/Sources/Status/Row/StatusActionsView.swift b/Packages/Status/Sources/Status/Row/StatusActionsView.swift index f88a6cad..101e8bec 100644 --- a/Packages/Status/Sources/Status/Row/StatusActionsView.swift +++ b/Packages/Status/Sources/Status/Row/StatusActionsView.swift @@ -5,6 +5,7 @@ import Network import DesignSystem struct StatusActionsView: View { + @Environment(\.openURL) private var openURL @EnvironmentObject private var routeurPath: RouterPath @ObservedObject var viewModel: StatusRowViewModel @@ -91,10 +92,19 @@ struct StatusActionsView: View { HStack { Text(viewModel.status.createdAt.asDate, style: .date) Text(viewModel.status.createdAt.asDate, style: .time) + Text("·") + Image(systemName: viewModel.status.visibility.iconName) Spacer() Text(viewModel.status.application?.name ?? "") + .underline() + .onTapGesture { + if let url = viewModel.status.application?.website { + openURL(url) + } + } } .font(.caption) + .foregroundColor(.gray) if viewModel.favouritesCount > 0 { Divider() Button { diff --git a/Packages/Status/Sources/Status/Row/StatusRowView.swift b/Packages/Status/Sources/Status/Row/StatusRowView.swift index 37f653ff..d67c363d 100644 --- a/Packages/Status/Sources/Status/Row/StatusRowView.swift +++ b/Packages/Status/Sources/Status/Row/StatusRowView.swift @@ -141,7 +141,9 @@ public struct StatusRowView: View { Group { Text("@\(status.account.acct)") + Text(" ⸱ ") + - Text(status.createdAt.formatted) + Text(status.createdAt.formatted) + + Text(" ⸱ ") + + Text(Image(systemName: viewModel.status.visibility.iconName)) } .font(.footnote) .foregroundColor(.gray)