Show status of weblog entry in list of posts

This commit is contained in:
Otavio Cordeiro 2025-12-19 21:10:33 +01:00 committed by Otávio
parent e6d378dfef
commit 958d410ddc
3 changed files with 18 additions and 3 deletions

View file

@ -12,7 +12,7 @@
id: "blogpostID", id: "blogpostID",
title: "This is a test", title: "This is a test",
body: "This is just a test post. ", body: "This is just a test post. ",
status: isDraft ? "draft" : "published", status: isDraft ? "draft" : "live",
timestamp: 12_312_312, timestamp: 12_312_312,
address: "otaviocc", address: "otaviocc",
location: "/2022/12/my-weblog-post", location: "/2022/12/my-weblog-post",

View file

@ -26,6 +26,10 @@ struct WeblogEntryView: View {
VStack(alignment: .leading, spacing: 4) { VStack(alignment: .leading, spacing: 4) {
makeHeaderView() makeHeaderView()
makeContentView() makeContentView()
if viewModel.showStatus {
makeStatusView()
}
} }
.frame( .frame(
maxWidth: .infinity, maxWidth: .infinity,
@ -65,6 +69,17 @@ struct WeblogEntryView: View {
.foregroundColor(.primary) .foregroundColor(.primary)
} }
@ViewBuilder
private func makeStatusView() -> some View {
HStack {
Spacer()
Text(viewModel.status)
.textCase(.uppercase)
.font(.caption)
.foregroundColor(.accentColor)
}
}
@ViewBuilder @ViewBuilder
private func makeContextualMenu() -> some View { private func makeContextualMenu() -> some View {
makeEditEntryMenuItem() makeEditEntryMenuItem()

View file

@ -34,8 +34,8 @@ final class WeblogEntryViewModel: Identifiable {
) )
} }
var isLive: Bool { var showStatus: Bool {
status == "live" status.lowercased() != "live"
} }
private let repository: any WeblogRepositoryProtocol private let repository: any WeblogRepositoryProtocol