Status visibility
This commit is contained in:
parent
ee39840713
commit
afbdd45e48
@ -5,6 +5,14 @@ public struct Application: Codable, Identifiable {
|
|||||||
name
|
name
|
||||||
}
|
}
|
||||||
public let name: String
|
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 {
|
public protocol AnyStatus {
|
||||||
@ -27,6 +35,7 @@ public protocol AnyStatus {
|
|||||||
var url: URL? { get }
|
var url: URL? { get }
|
||||||
var application: Application? { get }
|
var application: Application? { get }
|
||||||
var inReplyToAccountId: String? { 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 url: URL?
|
||||||
public let application: Application?
|
public let application: Application?
|
||||||
public let inReplyToAccountId: String?
|
public let inReplyToAccountId: String?
|
||||||
|
public let visibility: Visibility
|
||||||
|
|
||||||
public static func placeholder() -> Status {
|
public static func placeholder() -> Status {
|
||||||
.init(id: UUID().uuidString,
|
.init(id: UUID().uuidString,
|
||||||
@ -74,7 +84,8 @@ public struct Status: AnyStatus, Codable, Identifiable {
|
|||||||
emojis: [],
|
emojis: [],
|
||||||
url: nil,
|
url: nil,
|
||||||
application: nil,
|
application: nil,
|
||||||
inReplyToAccountId: nil)
|
inReplyToAccountId: nil,
|
||||||
|
visibility: .pub)
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func placeholders() -> [Status] {
|
public static func placeholders() -> [Status] {
|
||||||
@ -105,4 +116,5 @@ public struct ReblogStatus: AnyStatus, Codable, Identifiable {
|
|||||||
public let url: URL?
|
public let url: URL?
|
||||||
public var application: Application?
|
public var application: Application?
|
||||||
public let inReplyToAccountId: String?
|
public let inReplyToAccountId: String?
|
||||||
|
public let visibility: Visibility
|
||||||
}
|
}
|
||||||
|
16
Packages/Status/Sources/Status/Ext/Visibility.swift
Normal file
16
Packages/Status/Sources/Status/Ext/Visibility.swift
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ import Network
|
|||||||
import DesignSystem
|
import DesignSystem
|
||||||
|
|
||||||
struct StatusActionsView: View {
|
struct StatusActionsView: View {
|
||||||
|
@Environment(\.openURL) private var openURL
|
||||||
@EnvironmentObject private var routeurPath: RouterPath
|
@EnvironmentObject private var routeurPath: RouterPath
|
||||||
@ObservedObject var viewModel: StatusRowViewModel
|
@ObservedObject var viewModel: StatusRowViewModel
|
||||||
|
|
||||||
@ -91,10 +92,19 @@ struct StatusActionsView: View {
|
|||||||
HStack {
|
HStack {
|
||||||
Text(viewModel.status.createdAt.asDate, style: .date)
|
Text(viewModel.status.createdAt.asDate, style: .date)
|
||||||
Text(viewModel.status.createdAt.asDate, style: .time)
|
Text(viewModel.status.createdAt.asDate, style: .time)
|
||||||
|
Text("·")
|
||||||
|
Image(systemName: viewModel.status.visibility.iconName)
|
||||||
Spacer()
|
Spacer()
|
||||||
Text(viewModel.status.application?.name ?? "")
|
Text(viewModel.status.application?.name ?? "")
|
||||||
|
.underline()
|
||||||
|
.onTapGesture {
|
||||||
|
if let url = viewModel.status.application?.website {
|
||||||
|
openURL(url)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
|
.foregroundColor(.gray)
|
||||||
if viewModel.favouritesCount > 0 {
|
if viewModel.favouritesCount > 0 {
|
||||||
Divider()
|
Divider()
|
||||||
Button {
|
Button {
|
||||||
|
@ -141,7 +141,9 @@ public struct StatusRowView: View {
|
|||||||
Group {
|
Group {
|
||||||
Text("@\(status.account.acct)") +
|
Text("@\(status.account.acct)") +
|
||||||
Text(" ⸱ ") +
|
Text(" ⸱ ") +
|
||||||
Text(status.createdAt.formatted)
|
Text(status.createdAt.formatted) +
|
||||||
|
Text(" ⸱ ") +
|
||||||
|
Text(Image(systemName: viewModel.status.visibility.iconName))
|
||||||
}
|
}
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
.foregroundColor(.gray)
|
.foregroundColor(.gray)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user