mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Improve byline display, centralize the code a bit
This commit is contained in:
parent
9598a3c686
commit
09bea6d8c1
3 changed files with 20 additions and 21 deletions
|
|
@ -223,28 +223,14 @@ public struct MiniPlayer: View {
|
|||
|
||||
HStack {
|
||||
Spacer()
|
||||
if let author = itemAudioProperties.author {
|
||||
Text(author)
|
||||
if let byline = itemAudioProperties.byline {
|
||||
Text(byline)
|
||||
.lineLimit(1)
|
||||
.font(.appCallout)
|
||||
.lineSpacing(1.25)
|
||||
.foregroundColor(.appGrayText)
|
||||
.frame(alignment: .trailing)
|
||||
}
|
||||
if itemAudioProperties.author != nil, itemAudioProperties.siteName != nil {
|
||||
Text(" • ")
|
||||
.font(.appCallout)
|
||||
.lineSpacing(1.25)
|
||||
.foregroundColor(.appGrayText)
|
||||
}
|
||||
if let siteName = itemAudioProperties.siteName {
|
||||
Text(siteName)
|
||||
.lineLimit(1)
|
||||
.font(.appCallout)
|
||||
.lineSpacing(1.25)
|
||||
.foregroundColor(.appGrayText)
|
||||
.frame(alignment: .leading)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ public struct LinkedItemAudioProperties {
|
|||
public let itemID: String
|
||||
public let objectID: NSManagedObjectID
|
||||
public let title: String
|
||||
public let author: String?
|
||||
public let siteName: String?
|
||||
public let byline: String?
|
||||
public let imageURL: URL?
|
||||
public let language: String?
|
||||
}
|
||||
|
|
@ -95,13 +94,27 @@ public extension LinkedItem {
|
|||
return String(data: JSON, encoding: .utf8) ?? "[]"
|
||||
}
|
||||
|
||||
var formattedByline: String {
|
||||
var byline = ""
|
||||
|
||||
if let author = author {
|
||||
byline += author
|
||||
}
|
||||
if author != nil, publisherDisplayName != nil {
|
||||
byline += " • "
|
||||
}
|
||||
if let publisherDisplayName = publisherDisplayName {
|
||||
byline += publisherDisplayName
|
||||
}
|
||||
return byline
|
||||
}
|
||||
|
||||
var audioProperties: LinkedItemAudioProperties {
|
||||
LinkedItemAudioProperties(
|
||||
itemID: unwrappedID,
|
||||
objectID: objectID,
|
||||
title: unwrappedTitle,
|
||||
author: author,
|
||||
siteName: siteName,
|
||||
byline: formattedByline,
|
||||
imageURL: imageURL,
|
||||
language: language
|
||||
)
|
||||
|
|
|
|||
|
|
@ -800,7 +800,7 @@ public class AudioController: NSObject, ObservableObject, AVAudioPlayerDelegate
|
|||
if let itemAudioProperties = itemAudioProperties {
|
||||
MPNowPlayingInfoCenter.default().nowPlayingInfo = [
|
||||
MPMediaItemPropertyTitle: NSString(string: itemAudioProperties.title),
|
||||
MPMediaItemPropertyArtist: NSString(string: itemAudioProperties.author ?? "Omnivore"),
|
||||
MPMediaItemPropertyArtist: NSString(string: itemAudioProperties.byline ?? "Omnivore"),
|
||||
MPMediaItemPropertyPlaybackDuration: NSNumber(value: duration),
|
||||
MPNowPlayingInfoPropertyElapsedPlaybackTime: NSNumber(value: timeElapsed)
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue