Byline in grid cards, improve safe area handling

This commit is contained in:
Jackson Harper
2023-12-06 18:12:13 +08:00
parent 73341ad578
commit 0c8eecf3fb
7 changed files with 61 additions and 54 deletions

View File

@ -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)
}

View File

@ -39,6 +39,7 @@ public struct LibrarySplitView: View {
HomeFeedContainerView(viewModel: inboxViewModel)
.navigationViewStyle(.stack)
.navigationBarTitleDisplayMode(.inline)
.tag("following")
}
.navigationBarTitleDisplayMode(.inline)

View File

@ -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)
}
}

View File

@ -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)
}
}

View 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
}

View File

@ -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)

View File

@ -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)