Byline in grid cards, improve safe area handling
This commit is contained in:
@ -35,15 +35,6 @@ enum PrimaryContentCategory: Identifiable, Hashable, Equatable {
|
||||
Label { Text(title) } icon: { image.renderingMode(.template) }
|
||||
}
|
||||
|
||||
@MainActor @ViewBuilder var destinationView: some View {
|
||||
switch self {
|
||||
case .feed:
|
||||
LibraryListView()
|
||||
case .profile:
|
||||
ProfileView()
|
||||
}
|
||||
}
|
||||
|
||||
func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(id)
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ public struct LibrarySplitView: View {
|
||||
|
||||
HomeFeedContainerView(viewModel: inboxViewModel)
|
||||
.navigationViewStyle(.stack)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.tag("following")
|
||||
}
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
|
||||
@ -55,11 +55,13 @@ struct LibraryTabView: View {
|
||||
TabView(selection: $selectedTab) {
|
||||
NavigationView {
|
||||
HomeFeedContainerView(viewModel: followingViewModel)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.navigationViewStyle(.stack)
|
||||
}.tag("following")
|
||||
|
||||
NavigationView {
|
||||
HomeFeedContainerView(viewModel: libraryViewModel)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.navigationViewStyle(.stack)
|
||||
}.tag("inbox")
|
||||
|
||||
@ -84,7 +86,6 @@ struct LibraryTabView: View {
|
||||
.fullScreenCover(isPresented: $showExpandedAudioPlayer) {
|
||||
ExpandedAudioPlayer()
|
||||
}
|
||||
.ignoresSafeArea()
|
||||
.navigationBarHidden(true)
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ struct CustomTabBar: View {
|
||||
TabBarButton(key: "profile", image: Image.tabProfile, selectedTab: $selectedTab)
|
||||
}
|
||||
.padding(.top, 10)
|
||||
.padding(.bottom, 40)
|
||||
.padding(.bottom, 10)
|
||||
.background(Color.themeTabBarColor)
|
||||
}
|
||||
}
|
||||
|
||||
27
apple/OmnivoreKit/Sources/Views/FeedItem/CardUtils.swift
Normal file
27
apple/OmnivoreKit/Sources/Views/FeedItem/CardUtils.swift
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
func cardShouldHideUrl(_ url: String?) -> Bool {
|
||||
if let url = url, let origin = URL(string: url)?.host {
|
||||
let hideHosts = ["storage.googleapis.com", "omnivore.app"]
|
||||
if hideHosts.contains(origin) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func cardSiteName(_ originalArticleUrl: String?) -> String? {
|
||||
if cardShouldHideUrl(originalArticleUrl) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if let url = originalArticleUrl,
|
||||
let originalHost = URL(string: url)?.host?.replacingOccurrences(of: "^www\\.", with: "", options: .regularExpression)
|
||||
{
|
||||
return originalHost
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -123,6 +123,34 @@ public struct GridCard: View {
|
||||
}
|
||||
}
|
||||
|
||||
var bylineStr: String {
|
||||
// It seems like it could be cleaner just having author, instead of
|
||||
// concating, maybe we fall back
|
||||
if let author = item.author {
|
||||
return author
|
||||
} else if let publisherDisplayName = item.publisherDisplayName {
|
||||
return publisherDisplayName
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
var byLine: some View {
|
||||
if let origin = cardSiteName(item.pageURLString) {
|
||||
Text(bylineStr + " | " + origin)
|
||||
.font(.caption2)
|
||||
.foregroundColor(Color.themeLibraryItemSubtle)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
} else {
|
||||
Text(bylineStr)
|
||||
.font(.caption2)
|
||||
.foregroundColor(Color.themeLibraryItemSubtle)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
GeometryReader { geo in
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
@ -138,23 +166,7 @@ public struct GridCard: View {
|
||||
.lineLimit(1)
|
||||
}
|
||||
|
||||
HStack {
|
||||
if let author = item.author {
|
||||
Text("by \(author)")
|
||||
.font(.appCaptionTwo)
|
||||
.foregroundColor(.appGrayText)
|
||||
.lineLimit(1)
|
||||
}
|
||||
|
||||
if let publisherDisplayName = item.publisherDisplayName {
|
||||
Text(publisherDisplayName)
|
||||
.font(.appCaptionTwo)
|
||||
.foregroundColor(.appGrayText)
|
||||
.lineLimit(1)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
byLine
|
||||
}
|
||||
.frame(height: 30)
|
||||
.padding(.horizontal, 10)
|
||||
|
||||
@ -289,33 +289,8 @@ public struct LibraryItemCard: View {
|
||||
return ""
|
||||
}
|
||||
|
||||
func shouldHideUrl(_ url: String?) -> Bool {
|
||||
if let url = url, let origin = URL(string: url)?.host {
|
||||
let hideHosts = ["storage.googleapis.com", "omnivore.app"]
|
||||
if hideHosts.contains(origin) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func siteName(_ originalArticleUrl: String?) -> String? {
|
||||
if shouldHideUrl(originalArticleUrl) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if let url = originalArticleUrl,
|
||||
let originalHost = URL(string: url)?.host?.replacingOccurrences(of: "^www\\.", with: "", options: .regularExpression)
|
||||
{
|
||||
return originalHost
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var byLine: some View {
|
||||
if let origin = siteName(item.pageURLString) {
|
||||
if let origin = cardSiteName(item.pageURLString) {
|
||||
Text(bylineStr + " | " + origin)
|
||||
.font(.caption2)
|
||||
.foregroundColor(Color.themeLibraryItemSubtle)
|
||||
|
||||
Reference in New Issue
Block a user