mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-01-03 12:58:50 +00:00
Display reply to in status
This commit is contained in:
parent
e4e2b2ab8b
commit
840461caeb
3 changed files with 38 additions and 3 deletions
|
@ -1,5 +1,12 @@
|
|||
import Foundation
|
||||
|
||||
public struct Application: Codable, Identifiable {
|
||||
public var id: String {
|
||||
name
|
||||
}
|
||||
public let name: String
|
||||
}
|
||||
|
||||
public protocol AnyStatus {
|
||||
var id: String { get }
|
||||
var content: HTMLString { get }
|
||||
|
@ -16,6 +23,8 @@ public protocol AnyStatus {
|
|||
var pinned: Bool? { get }
|
||||
var emojis: [Emoji] { get }
|
||||
var url: URL? { get }
|
||||
var application: Application? { get }
|
||||
var inReplyToAccountId: String? { get }
|
||||
}
|
||||
|
||||
public struct Status: AnyStatus, Codable, Identifiable {
|
||||
|
@ -35,6 +44,8 @@ public struct Status: AnyStatus, Codable, Identifiable {
|
|||
public let pinned: Bool?
|
||||
public let emojis: [Emoji]
|
||||
public let url: URL?
|
||||
public let application: Application?
|
||||
public let inReplyToAccountId: String?
|
||||
|
||||
public static func placeholder() -> Status {
|
||||
.init(id: UUID().uuidString,
|
||||
|
@ -52,7 +63,9 @@ public struct Status: AnyStatus, Codable, Identifiable {
|
|||
reblogged: false,
|
||||
pinned: false,
|
||||
emojis: [],
|
||||
url: nil)
|
||||
url: nil,
|
||||
application: nil,
|
||||
inReplyToAccountId: nil)
|
||||
}
|
||||
|
||||
public static func placeholders() -> [Status] {
|
||||
|
@ -76,4 +89,6 @@ public struct ReblogStatus: AnyStatus, Codable, Identifiable {
|
|||
public let pinned: Bool?
|
||||
public let emojis: [Emoji]
|
||||
public let url: URL?
|
||||
public var application: Application?
|
||||
public let inReplyToAccountId: String?
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ struct StatusActionsView: View {
|
|||
func iconName(viewModel: StatusRowViewModel) -> String {
|
||||
switch self {
|
||||
case .respond:
|
||||
return "bubble.right"
|
||||
return "arrowshape.turn.up.left"
|
||||
case .boost:
|
||||
return viewModel.isReblogged ? "arrow.left.arrow.right.circle.fill" : "arrow.left.arrow.right.circle"
|
||||
case .favourite:
|
||||
|
@ -59,6 +59,7 @@ struct StatusActionsView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.buttonStyle(.borderless)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ public struct StatusRowView: View {
|
|||
public var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
reblogView
|
||||
replyView
|
||||
statusView
|
||||
if !viewModel.isEmbed {
|
||||
StatusActionsView(viewModel: viewModel)
|
||||
|
@ -32,7 +33,7 @@ public struct StatusRowView: View {
|
|||
private var reblogView: some View {
|
||||
if viewModel.status.reblog != nil {
|
||||
HStack(spacing: 2) {
|
||||
Image(systemName:"arrow.left.arrow.right.circle")
|
||||
Image(systemName:"arrow.left.arrow.right.circle.fill")
|
||||
viewModel.status.account.displayNameWithEmojis
|
||||
Text("boosted")
|
||||
}
|
||||
|
@ -45,6 +46,24 @@ public struct StatusRowView: View {
|
|||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
var replyView: some View {
|
||||
if let accountId = viewModel.status.inReplyToAccountId,
|
||||
let mention = viewModel.status.mentions.first(where: { $0.id == accountId}) {
|
||||
HStack(spacing: 2) {
|
||||
Image(systemName:"arrowshape.turn.up.left.fill")
|
||||
Text("Replied to")
|
||||
Text(mention.username)
|
||||
}
|
||||
.font(.footnote)
|
||||
.foregroundColor(.gray)
|
||||
.fontWeight(.semibold)
|
||||
.onTapGesture {
|
||||
routeurPath.navigate(to: .accountDetail(id: mention.id))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var statusView: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
if let status: AnyStatus = viewModel.status.reblog ?? viewModel.status {
|
||||
|
|
Loading…
Reference in a new issue