Skip to content

Commit

Permalink
Add indicator view for PDF
Browse files Browse the repository at this point in the history
  • Loading branch information
livid committed Feb 14, 2024
1 parent 07dbb20 commit e418f0b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Planet/Entities/ArticleModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class ArticleModel: ObservableObject, Identifiable, Equatable, Hashable {
audioFilename != nil
}

var hasPDF: Bool {
return attachments?.contains { $0.hasSuffix(".pdf") } ?? false
}

init(
id: UUID,
title: String,
Expand Down
22 changes: 22 additions & 0 deletions Planet/Views/Components/GIFIndicatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,25 @@ struct VideoIndicatorView: View {
}
}
}


struct PDFIndicatorView: View {
var body: some View {
VStack {
Spacer()
HStack {
Text("PDF")
.font(.system(size: 10, weight: .semibold, design: .monospaced))
.foregroundColor(.white.opacity(0.85))
.padding(.horizontal, 4)
.padding(.vertical, 2)
.background(Color.secondary.opacity(0.75))
.cornerRadius(4)
.multilineTextAlignment(.center)
Spacer()
}
.padding(.leading, 4)
.padding(.bottom, 4)
}
}
}
3 changes: 3 additions & 0 deletions Planet/Views/My/MyArticleGridView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ struct MyArticleGridView: View {
}
else if article.hasVideo {
VideoIndicatorView()
}
else if article.hasPDF {
PDFIndicatorView()
} else {

}
Expand Down
2 changes: 1 addition & 1 deletion Planet/versioning.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 1865
CURRENT_PROJECT_VERSION = 1866

0 comments on commit e418f0b

Please sign in to comment.