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",
title: "This is a test",
body: "This is just a test post. ",
status: isDraft ? "draft" : "published",
status: isDraft ? "draft" : "live",
timestamp: 12_312_312,
address: "otaviocc",
location: "/2022/12/my-weblog-post",

View file

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

View file

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