mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-01-03 04:48: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
|
import Foundation
|
||||||
|
|
||||||
|
public struct Application: Codable, Identifiable {
|
||||||
|
public var id: String {
|
||||||
|
name
|
||||||
|
}
|
||||||
|
public let name: String
|
||||||
|
}
|
||||||
|
|
||||||
public protocol AnyStatus {
|
public protocol AnyStatus {
|
||||||
var id: String { get }
|
var id: String { get }
|
||||||
var content: HTMLString { get }
|
var content: HTMLString { get }
|
||||||
|
@ -16,6 +23,8 @@ public protocol AnyStatus {
|
||||||
var pinned: Bool? { get }
|
var pinned: Bool? { get }
|
||||||
var emojis: [Emoji] { get }
|
var emojis: [Emoji] { get }
|
||||||
var url: URL? { get }
|
var url: URL? { get }
|
||||||
|
var application: Application? { get }
|
||||||
|
var inReplyToAccountId: String? { get }
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct Status: AnyStatus, Codable, Identifiable {
|
public struct Status: AnyStatus, Codable, Identifiable {
|
||||||
|
@ -35,6 +44,8 @@ public struct Status: AnyStatus, Codable, Identifiable {
|
||||||
public let pinned: Bool?
|
public let pinned: Bool?
|
||||||
public let emojis: [Emoji]
|
public let emojis: [Emoji]
|
||||||
public let url: URL?
|
public let url: URL?
|
||||||
|
public let application: Application?
|
||||||
|
public let inReplyToAccountId: String?
|
||||||
|
|
||||||
public static func placeholder() -> Status {
|
public static func placeholder() -> Status {
|
||||||
.init(id: UUID().uuidString,
|
.init(id: UUID().uuidString,
|
||||||
|
@ -52,7 +63,9 @@ public struct Status: AnyStatus, Codable, Identifiable {
|
||||||
reblogged: false,
|
reblogged: false,
|
||||||
pinned: false,
|
pinned: false,
|
||||||
emojis: [],
|
emojis: [],
|
||||||
url: nil)
|
url: nil,
|
||||||
|
application: nil,
|
||||||
|
inReplyToAccountId: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func placeholders() -> [Status] {
|
public static func placeholders() -> [Status] {
|
||||||
|
@ -76,4 +89,6 @@ public struct ReblogStatus: AnyStatus, Codable, Identifiable {
|
||||||
public let pinned: Bool?
|
public let pinned: Bool?
|
||||||
public let emojis: [Emoji]
|
public let emojis: [Emoji]
|
||||||
public let url: URL?
|
public let url: URL?
|
||||||
|
public var application: Application?
|
||||||
|
public let inReplyToAccountId: String?
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ struct StatusActionsView: View {
|
||||||
func iconName(viewModel: StatusRowViewModel) -> String {
|
func iconName(viewModel: StatusRowViewModel) -> String {
|
||||||
switch self {
|
switch self {
|
||||||
case .respond:
|
case .respond:
|
||||||
return "bubble.right"
|
return "arrowshape.turn.up.left"
|
||||||
case .boost:
|
case .boost:
|
||||||
return viewModel.isReblogged ? "arrow.left.arrow.right.circle.fill" : "arrow.left.arrow.right.circle"
|
return viewModel.isReblogged ? "arrow.left.arrow.right.circle.fill" : "arrow.left.arrow.right.circle"
|
||||||
case .favourite:
|
case .favourite:
|
||||||
|
@ -59,6 +59,7 @@ struct StatusActionsView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.buttonStyle(.borderless)
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ public struct StatusRowView: View {
|
||||||
public var body: some View {
|
public var body: some View {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
reblogView
|
reblogView
|
||||||
|
replyView
|
||||||
statusView
|
statusView
|
||||||
if !viewModel.isEmbed {
|
if !viewModel.isEmbed {
|
||||||
StatusActionsView(viewModel: viewModel)
|
StatusActionsView(viewModel: viewModel)
|
||||||
|
@ -32,7 +33,7 @@ public struct StatusRowView: View {
|
||||||
private var reblogView: some View {
|
private var reblogView: some View {
|
||||||
if viewModel.status.reblog != nil {
|
if viewModel.status.reblog != nil {
|
||||||
HStack(spacing: 2) {
|
HStack(spacing: 2) {
|
||||||
Image(systemName:"arrow.left.arrow.right.circle")
|
Image(systemName:"arrow.left.arrow.right.circle.fill")
|
||||||
viewModel.status.account.displayNameWithEmojis
|
viewModel.status.account.displayNameWithEmojis
|
||||||
Text("boosted")
|
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 {
|
private var statusView: some View {
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
if let status: AnyStatus = viewModel.status.reblog ?? viewModel.status {
|
if let status: AnyStatus = viewModel.status.reblog ?? viewModel.status {
|
||||||
|
|
Loading…
Reference in a new issue