Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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 creator: String = ""
Comment thread
Themakew marked this conversation as resolved.
Outdated
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(),
creator: String = "",
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.creator = creator
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,
creator: $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.creator = feed.creator
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 creator: 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,
creator: 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.creator = creator
self.urlToShare = urlToShare
self.artworkUrl = artworkUrl
self.favorite = favorite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private extension GlassCardView {
}

layout {
dateRow
dateAndCreatorRow
Comment thread
Themakew marked this conversation as resolved.
Outdated
Spacer(minLength: 0)
duration
}
Expand All @@ -187,7 +187,7 @@ private extension GlassCardView {

layout {
innerLayout {
dateRow
dateAndCreatorRow
statistics
}
Spacer(minLength: 4)
Expand All @@ -196,12 +196,29 @@ private extension GlassCardView {
.font(.caption2)
}

var dateRow: some View {
MetadataContent(
image: "calendar",
text: data.pubDate.toTimeAgoDisplay(showTime: false)
)
var dateAndCreatorRow: some View {
HStack(spacing: 4) {
MetadataContent(
image: "calendar",
text: data.pubDate.toTimeAgoDisplay(showTime: false)
)
if let creator = data.creator, !creator.isEmpty {
Text("•")
Comment thread
Themakew marked this conversation as resolved.
Outdated
Text(creator)
}
}
.foregroundStyle(.white.opacity(0.9))
.lineLimit(1)
Comment thread
Themakew marked this conversation as resolved.
Outdated
.truncationMode(.tail)
.accessibilityElement(children: .ignore)
.accessibilityLabel({
let dateText = data.pubDate.toTimeAgoDisplay(showTime: true)
if let creator = data.creator, !creator.isEmpty {
return "Publicado \(dateText) por \(creator)"
} else {
return "Publicado \(dateText)"
}
}())
}

@ViewBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private extension LeadingImageCard {
var metadataContent: some View {
VStack(alignment: .leading, spacing: 6) {
titleRow
dateRow
dateAndCreatorRow
Spacer(minLength: 0)
}
.frame(maxWidth: .infinity, alignment: .leading)
Expand All @@ -82,12 +82,29 @@ private extension LeadingImageCard {
}
}

var dateRow: some View {
MetadataContent(
image: "calendar",
text: data.pubDate.toTimeAgoDisplay(showTime: true)
)
var dateAndCreatorRow: some View {
Comment thread
Themakew marked this conversation as resolved.
Outdated
HStack(spacing: 4) {
MetadataContent(
image: "calendar",
text: data.pubDate.toTimeAgoDisplay(showTime: true)
)
if let creator = data.creator, !creator.isEmpty {
Text("•")
Text(creator)
}
}
.foregroundStyle(.primary.opacity(0.9))
.font(.caption2)
.lineLimit(1)
.truncationMode(.tail)
.accessibilityElement(children: .ignore)
.accessibilityLabel({
let dateText = data.pubDate.toTimeAgoDisplay(showTime: true)
if let creator = data.creator, !creator.isEmpty {
return "Publicado \(dateText) por \(creator)"
} else {
return "Publicado \(dateText)"
}
}())
}
}
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,
creator: self.creator,
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),
creator: "MacMagazine",
artworkURL: "https://picsum.photos/id/\(Int.random(in: 100...500))/800/450",
link: "https://www.macmagazine.com/",
categories: categories,
Expand Down
2 changes: 1 addition & 1 deletion MacMagazine/MacMagazine/Features/News/NewsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct NewsView: View {
.sheet(isPresented: $category) {
categories
.presentationDragIndicator(.visible)
.presentationDetents([.fraction(0.33)])
.presentationDetents([.fraction(0.33), .medium])
Comment thread
Themakew marked this conversation as resolved.
Outdated
}
.onChange(of: viewModel.news) { _, newValue in
let newCategory = newValue.toNewsCategory
Expand Down
2 changes: 2 additions & 0 deletions MacMagazine/WatchApp/Extension/FeedDB.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extension FeedDB {
title: "Apple lança atualização do watchOS",
subtitle: "Mudanças importantes para o Apple Watch",
pubDate: Date().addingTimeInterval(-3600),
creator: "MacMagazine",
artworkURL: "https://picsum.photos/400/400",
link: "https://macmagazine.com.br",
categories: ["watchos", "news", "teste1", "teste2", "teste 3"],
Expand All @@ -55,6 +56,7 @@ extension FeedDB {
title: "Notícia \(index): título de teste para o Watch",
subtitle: "Subtítulo \(index)",
pubDate: Date().addingTimeInterval(TimeInterval(-index * 900)),
creator: "MacMagazine",
artworkURL: "https://picsum.photos/seed/\(index)/600/600",
link: "https://macmagazine.com.br",
categories: ["news", "teste1", "teste2", "teste 3"],
Expand Down
Loading