diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index e08e43362..a3e3d1aba 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -372,23 +372,17 @@ struct AnimatingCellHeight: AnimatableModifier { VStack(alignment: .leading, spacing: 20) { Menu(content: { Button(action: { - withoutAnimation { - viewModel.updateFeatureFilter(.continueReading) - } + viewModel.updateFeatureFilter(.continueReading) }, label: { Text("Continue Reading") }) -// Button(action: { -// withoutAnimation { -// viewModel.updateFeatureFilter(.recommended) -// } -// }, label: { -// Text("Recommended") -// }) Button(action: { - withoutAnimation { - viewModel.updateFeatureFilter(.newsletters) - } + viewModel.updateFeatureFilter(.pinned) + }, label: { + Text("Pinned") + }) + Button(action: { + viewModel.updateFeatureFilter(.newsletters) }, label: { Text("Newsletters") }) @@ -402,31 +396,34 @@ struct AnimatingCellHeight: AnimatableModifier { Text(viewModel.featureFilter.title.uppercased()) .font(Font.system(size: 14, weight: .regular)) Image(systemName: "chevron.down") - } + }.frame(maxWidth: .infinity, alignment: .leading) }) .padding(.top, 20) .padding(.bottom, 0) - ScrollView(.horizontal, showsIndicators: false) { - if viewModel.featureItems.count > 0 { - LazyHStack(alignment: .top, spacing: 20) { - ForEach(viewModel.featureItems) { item in - LibraryFeatureCardNavigationLink(item: item, viewModel: viewModel) - .background( - RoundedRectangle(cornerRadius: 12) // << tune as needed - .fill(Color(UIColor.systemBackground)) // << fill with system color - ) + GeometryReader { geo in + + ScrollView(.horizontal, showsIndicators: false) { + if viewModel.featureItems.count > 0 { + LazyHStack(alignment: .top, spacing: 20) { + ForEach(viewModel.featureItems) { item in + LibraryFeatureCardNavigationLink(item: item, viewModel: viewModel) + .background( + RoundedRectangle(cornerRadius: 12) // << tune as needed + .fill(Color(UIColor.systemBackground)) // << fill with system color + ) + } } - }.padding(0) - } else { - Text(viewModel.featureFilter.emptyMessage) - .font(Font.system(size: 14, weight: .regular)) - .foregroundColor(Color(hex: "#898989")) - .frame(height: 60, alignment: .topLeading) + } else { + Text(viewModel.featureFilter.emptyMessage) + .font(Font.system(size: 14, weight: .regular)) + .foregroundColor(Color(hex: "#898989")) + .frame(maxWidth: geo.size.width) + .frame(height: 60, alignment: .topLeading) + .fixedSize(horizontal: false, vertical: true) + } } } - // .frame(height: viewModel.featureItems.count > 0 ? 160 : 60, alignment: .topLeading) - .padding(.top, 0) Text((LinkedItemFilter(rawValue: viewModel.appliedFilter)?.displayName ?? "Inbox").uppercased()) .font(Font.system(size: 14, weight: .regular)) @@ -457,7 +454,7 @@ struct AnimatingCellHeight: AnimatableModifier { if !viewModel.hideFeatureSection, viewModel.items.count > 0 { featureCard .listRowInsets(.init(top: 0, leading: 10, bottom: 10, trailing: 10)) - .modifier(AnimatingCellHeight(height: viewModel.featureItems.count > 0 ? 260 : 80)) + .modifier(AnimatingCellHeight(height: viewModel.featureItems.count > 0 ? 260 : 130)) } ForEach(viewModel.items) { item in diff --git a/apple/OmnivoreKit/Sources/Models/LinkedItemFilter.swift b/apple/OmnivoreKit/Sources/Models/LinkedItemFilter.swift index 7ae47cd22..7a21295e2 100644 --- a/apple/OmnivoreKit/Sources/Models/LinkedItemFilter.swift +++ b/apple/OmnivoreKit/Sources/Models/LinkedItemFilter.swift @@ -94,6 +94,7 @@ public enum FeaturedItemFilter: String, CaseIterable { case continueReading case recommended case newsletters + case pinned } public extension FeaturedItemFilter { @@ -110,6 +111,8 @@ public extension FeaturedItemFilter { switch self { case .continueReading: return "Your recently read items will appear here." + case .pinned: + return "Create a label named Pinned and add it to items you'd like to appear here" case .recommended: return "Reads recommended in your Clubs will appear here." case .newsletters: @@ -131,19 +134,32 @@ public extension FeaturedItemFilter { let continueReadingPredicate = NSPredicate( format: "readingProgress > 1 AND readingProgress < 100 AND readAt != nil" ) - return NSCompoundPredicate(andPredicateWithSubpredicates: [continueReadingPredicate, undeletedPredicate, notInArchivePredicate]) + return NSCompoundPredicate(andPredicateWithSubpredicates: [ + continueReadingPredicate, undeletedPredicate, notInArchivePredicate + ]) + case .pinned: + let newsletterLabelPredicate = NSPredicate( + format: "SUBQUERY(labels, $label, $label.name == \"Pinned\").@count > 0" + ) + return NSCompoundPredicate(andPredicateWithSubpredicates: [ + notInArchivePredicate, undeletedPredicate, newsletterLabelPredicate + ]) case .newsletters: // non-archived or deleted items with the Newsletter label let newsletterLabelPredicate = NSPredicate( format: "SUBQUERY(labels, $label, $label.name == \"Newsletter\").@count > 0" ) - return NSCompoundPredicate(andPredicateWithSubpredicates: [notInArchivePredicate, undeletedPredicate, newsletterLabelPredicate]) + return NSCompoundPredicate(andPredicateWithSubpredicates: [ + notInArchivePredicate, undeletedPredicate, newsletterLabelPredicate + ]) case .recommended: // non-archived or deleted items with the Newsletter label let recommendedPredicate = NSPredicate( format: "recommendations.@count > 0" ) - return NSCompoundPredicate(andPredicateWithSubpredicates: [notInArchivePredicate, undeletedPredicate, recommendedPredicate]) + return NSCompoundPredicate(andPredicateWithSubpredicates: [ + notInArchivePredicate, undeletedPredicate, recommendedPredicate + ]) } }