mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-25 09:41:02 +00:00
Status actions count
This commit is contained in:
parent
3850dab340
commit
103db56ea4
2 changed files with 59 additions and 24 deletions
|
@ -7,6 +7,9 @@ public protocol AnyStatus {
|
|||
var createdAt: String { get }
|
||||
var mediaAttachments: [MediaAttachement] { get }
|
||||
var mentions: [Mention] { get }
|
||||
var repliesCount: Int { get }
|
||||
var reblogsCount: Int { get }
|
||||
var favouritesCount: Int { get }
|
||||
}
|
||||
|
||||
public struct Status: AnyStatus, Codable, Identifiable {
|
||||
|
@ -17,6 +20,9 @@ public struct Status: AnyStatus, Codable, Identifiable {
|
|||
public let reblog: ReblogStatus?
|
||||
public let mediaAttachments: [MediaAttachement]
|
||||
public let mentions: [Mention]
|
||||
public let repliesCount: Int
|
||||
public let reblogsCount: Int
|
||||
public let favouritesCount: Int
|
||||
|
||||
public static func placeholder() -> Status {
|
||||
.init(id: UUID().uuidString,
|
||||
|
@ -25,7 +31,10 @@ public struct Status: AnyStatus, Codable, Identifiable {
|
|||
createdAt: "2022-12-16T10:20:54.000Z",
|
||||
reblog: nil,
|
||||
mediaAttachments: [],
|
||||
mentions: [])
|
||||
mentions: [],
|
||||
repliesCount: 0,
|
||||
reblogsCount: 0,
|
||||
favouritesCount: 0)
|
||||
}
|
||||
|
||||
public static func placeholders() -> [Status] {
|
||||
|
@ -40,4 +49,7 @@ public struct ReblogStatus: AnyStatus, Codable, Identifiable {
|
|||
public let createdAt: String
|
||||
public let mediaAttachments: [MediaAttachement]
|
||||
public let mentions: [Mention]
|
||||
public let repliesCount: Int
|
||||
public let reblogsCount: Int
|
||||
public let favouritesCount: Int
|
||||
}
|
||||
|
|
|
@ -5,31 +5,54 @@ import Routeur
|
|||
struct StatusActionsView: View {
|
||||
let status: Status
|
||||
|
||||
enum Actions: CaseIterable {
|
||||
case respond, boost, favourite, share
|
||||
|
||||
var iconName: String {
|
||||
switch self {
|
||||
case .respond:
|
||||
return "bubble.right"
|
||||
case .boost:
|
||||
return "arrow.left.arrow.right.circle"
|
||||
case .favourite:
|
||||
return "star"
|
||||
case .share:
|
||||
return "square.and.arrow.up"
|
||||
}
|
||||
}
|
||||
|
||||
func count(status: Status) -> Int? {
|
||||
switch self {
|
||||
case .respond:
|
||||
return status.repliesCount
|
||||
case .favourite:
|
||||
return status.favouritesCount
|
||||
case .boost:
|
||||
return status.reblogsCount
|
||||
case .share:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
Button {
|
||||
|
||||
} label: {
|
||||
Image(systemName: "bubble.right")
|
||||
ForEach(Actions.allCases, id: \.self) { action in
|
||||
Button {
|
||||
|
||||
} label: {
|
||||
HStack(spacing: 2) {
|
||||
Image(systemName: action.iconName)
|
||||
if let count = action.count(status: status) {
|
||||
Text("\(count)")
|
||||
.font(.footnote)
|
||||
}
|
||||
}
|
||||
}
|
||||
if action != .share {
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
Button {
|
||||
|
||||
} label: {
|
||||
Image(systemName: "arrow.left.arrow.right.circle")
|
||||
}
|
||||
Spacer()
|
||||
Button {
|
||||
|
||||
} label: {
|
||||
Image(systemName: "star")
|
||||
}
|
||||
Spacer()
|
||||
Button {
|
||||
|
||||
} label: {
|
||||
Image(systemName: "square.and.arrow.up")
|
||||
}
|
||||
}.tint(.black)
|
||||
}.tint(.gray)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue