Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public final class FeedDB {
public var title: String = ""
public var subtitle: String = ""
public var pubDate: Date = Date()
public var author: String?
public var artworkURL: String = ""
public var link: String = ""
public var categories: [String] = []
Expand All @@ -21,6 +22,7 @@ public final class FeedDB {
title: String = "",
subtitle: String = "",
pubDate: Date = Date(),
author: String? = nil,
artworkURL: String = "",
link: String = "",
categories: [String] = [],
Expand All @@ -33,6 +35,7 @@ public final class FeedDB {
self.title = title
self.subtitle = subtitle
self.pubDate = pubDate
self.author = author
self.artworkURL = artworkURL
self.link = link
self.categories = categories
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extension Array where Element == XMLPost {
title: $0.title,
subtitle: "",
pubDate: $0.pubDate,
author: $0.creator,
artworkURL: $0.artworkURL,
link: $0.link,
categories: $0.categories,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extension Database {
existing.title = feed.title
existing.subtitle = feed.subtitle
existing.pubDate = feed.pubDate
existing.author = feed.author
existing.artworkURL = feed.artworkURL
existing.link = feed.link
existing.categories = Array(Set(existing.categories + feed.categories))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public struct CardContent {
public let analytics: AnalyticsManager?
public let title: String
public let pubDate: Date
public let author: String?
public let artworkUrl: String
public let urlToShare: String
public let favorite: Bool
Expand All @@ -81,6 +82,7 @@ public struct CardContent {
analytics: AnalyticsManager? = nil,
title: String,
pubDate: Date,
author: String? = nil,
artworkUrl: String,
urlToShare: String,
favorite: Bool,
Expand All @@ -91,6 +93,7 @@ public struct CardContent {
self.title = title
self.analytics = analytics
self.pubDate = pubDate
self.author = author
self.urlToShare = urlToShare
self.artworkUrl = artworkUrl
self.favorite = favorite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ private extension GlassCardView {
layout {
innerLayout {
dateRow
authorRow
statistics
}
Spacer(minLength: 4)
Expand All @@ -199,11 +200,24 @@ private extension GlassCardView {
var dateRow: some View {
MetadataContent(
image: "calendar",
text: data.pubDate.toTimeAgoDisplay(showTime: false)
text: data.pubDate.toTimeAgoDisplay(showTime: true)
)
.foregroundStyle(.white.opacity(0.9))
}

@ViewBuilder
var authorRow: some View {
if let authorName = data.author, !authorName.isEmpty {
MetadataContent(
image: "person.fill",
text: authorName
)
.foregroundStyle(.white.opacity(0.9))
} else {
EmptyView()
}
}

@ViewBuilder
var duration: some View {
if !data.type.duration.isEmpty {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ private extension LeadingImageCard {
VStack(alignment: .leading, spacing: 6) {
titleRow
dateRow
authorRow
Spacer(minLength: 0)
}
.frame(maxWidth: .infinity, alignment: .leading)
Expand Down Expand Up @@ -90,4 +91,18 @@ private extension LeadingImageCard {
.foregroundStyle(.primary.opacity(0.9))
.font(.caption2)
}

@ViewBuilder
var authorRow: some View {
if let authorName = data.author, !authorName.isEmpty {
MetadataContent(
image: "person.fill",
text: authorName
)
.foregroundStyle(.primary.opacity(0.9))
.font(.caption2)
} else {
EmptyView()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extension FeedDB {
analytics: analytics,
title: self.title,
pubDate: self.pubDate,
author: self.author,
artworkUrl: self.artworkURL,
urlToShare: self.link,
favorite: self.favorite,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ enum PreviewData {
title: title,
subtitle: "Subtítulo da notícia",
pubDate: Date().addingTimeInterval(-3600),
author: "MacMagazine",
artworkURL: "https://picsum.photos/id/\(Int.random(in: 100...500))/800/450",
link: "https://www.macmagazine.com/",
categories: categories,
Expand Down
1 change: 0 additions & 1 deletion MacMagazine/MacMagazine/Features/News/NewsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ struct NewsView: View {
.toolbar(type: toolbarType,
menu: favoriteButton,
options: categoriesButton)

.onChange(of: viewModel.news) { _, newValue in
let newCategory = newValue.toNewsCategory
guard newsCategory != newCategory else { return }
Expand Down