Merge pull request #2349 from omnivore-app/fix/ios-pinned-items
Remember feature filter, dont display features during search
This commit is contained in:
File diff suppressed because one or more lines are too long
@ -398,7 +398,7 @@ struct AnimatingCellHeight: AnimatableModifier {
|
|||||||
})
|
})
|
||||||
}, label: {
|
}, label: {
|
||||||
HStack(alignment: .center) {
|
HStack(alignment: .center) {
|
||||||
Text(viewModel.featureFilter.title.uppercased())
|
Text((FeaturedItemFilter(rawValue: viewModel.featureFilter) ?? .continueReading).title.uppercased())
|
||||||
.font(Font.system(size: 14, weight: .regular))
|
.font(Font.system(size: 14, weight: .regular))
|
||||||
Image(systemName: "chevron.down")
|
Image(systemName: "chevron.down")
|
||||||
}.frame(maxWidth: .infinity, alignment: .leading)
|
}.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
@ -410,17 +410,13 @@ struct AnimatingCellHeight: AnimatableModifier {
|
|||||||
|
|
||||||
ScrollView(.horizontal, showsIndicators: false) {
|
ScrollView(.horizontal, showsIndicators: false) {
|
||||||
if viewModel.featureItems.count > 0 {
|
if viewModel.featureItems.count > 0 {
|
||||||
LazyHStack(alignment: .top, spacing: 20) {
|
LazyHStack(alignment: .top, spacing: 10) {
|
||||||
ForEach(viewModel.featureItems) { item in
|
ForEach(viewModel.featureItems) { item in
|
||||||
LibraryFeatureCardNavigationLink(item: item, viewModel: viewModel)
|
LibraryFeatureCardNavigationLink(item: item, viewModel: viewModel)
|
||||||
.background(
|
|
||||||
RoundedRectangle(cornerRadius: 12) // << tune as needed
|
|
||||||
.fill(Color(UIColor.systemBackground)) // << fill with system color
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Text(viewModel.featureFilter.emptyMessage)
|
Text((FeaturedItemFilter(rawValue: viewModel.featureFilter) ?? .continueReading).emptyMessage)
|
||||||
.font(Font.system(size: 14, weight: .regular))
|
.font(Font.system(size: 14, weight: .regular))
|
||||||
.foregroundColor(Color(hex: "#898989"))
|
.foregroundColor(Color(hex: "#898989"))
|
||||||
.frame(maxWidth: geo.size.width)
|
.frame(maxWidth: geo.size.width)
|
||||||
@ -432,7 +428,6 @@ struct AnimatingCellHeight: AnimatableModifier {
|
|||||||
|
|
||||||
Text((LinkedItemFilter(rawValue: viewModel.appliedFilter)?.displayName ?? "Inbox").uppercased())
|
Text((LinkedItemFilter(rawValue: viewModel.appliedFilter)?.displayName ?? "Inbox").uppercased())
|
||||||
.font(Font.system(size: 14, weight: .regular))
|
.font(Font.system(size: 14, weight: .regular))
|
||||||
.padding(.bottom, 5)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,8 +450,7 @@ struct AnimatingCellHeight: AnimatableModifier {
|
|||||||
filtersHeader
|
filtersHeader
|
||||||
.listRowInsets(.init(top: 0, leading: 10, bottom: 10, trailing: 10))
|
.listRowInsets(.init(top: 0, leading: 10, bottom: 10, trailing: 10))
|
||||||
|
|
||||||
// Only show the feature card section if we have items loaded
|
if !viewModel.hideFeatureSection, viewModel.items.count > 0, viewModel.searchTerm.isEmpty, viewModel.selectedLabels.isEmpty, viewModel.negatedLabels.isEmpty {
|
||||||
if !viewModel.hideFeatureSection, viewModel.items.count > 0 {
|
|
||||||
featureCard
|
featureCard
|
||||||
.listRowInsets(.init(top: 0, leading: 10, bottom: 10, trailing: 10))
|
.listRowInsets(.init(top: 0, leading: 10, bottom: 10, trailing: 10))
|
||||||
.modifier(AnimatingCellHeight(height: viewModel.featureItems.count > 0 ? 260 : 130))
|
.modifier(AnimatingCellHeight(height: viewModel.featureItems.count > 0 ? 260 : 130))
|
||||||
|
|||||||
@ -32,8 +32,6 @@ import Views
|
|||||||
|
|
||||||
@Published var showLabelsSheet = false
|
@Published var showLabelsSheet = false
|
||||||
@Published var showCommunityModal = false
|
@Published var showCommunityModal = false
|
||||||
|
|
||||||
@Published var featureFilter = FeaturedItemFilter.continueReading
|
|
||||||
@Published var featureItems = [LinkedItem]()
|
@Published var featureItems = [LinkedItem]()
|
||||||
|
|
||||||
var cursor: String?
|
var cursor: String?
|
||||||
@ -47,20 +45,25 @@ import Views
|
|||||||
|
|
||||||
@AppStorage(UserDefaultKey.hideFeatureSection.rawValue) var hideFeatureSection = false
|
@AppStorage(UserDefaultKey.hideFeatureSection.rawValue) var hideFeatureSection = false
|
||||||
@AppStorage(UserDefaultKey.lastSelectedLinkedItemFilter.rawValue) var appliedFilter = LinkedItemFilter.inbox.rawValue
|
@AppStorage(UserDefaultKey.lastSelectedLinkedItemFilter.rawValue) var appliedFilter = LinkedItemFilter.inbox.rawValue
|
||||||
|
@AppStorage(UserDefaultKey.lastSelectedFeaturedItemFilter.rawValue) var featureFilter = FeaturedItemFilter.continueReading.rawValue
|
||||||
|
|
||||||
func setItems(_ items: [LinkedItem]) {
|
func setItems(_ items: [LinkedItem]) {
|
||||||
self.items = items
|
self.items = items
|
||||||
updateFeatureFilter(featureFilter)
|
updateFeatureFilter(FeaturedItemFilter(rawValue: featureFilter))
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateFeatureFilter(_ filter: FeaturedItemFilter) {
|
func updateFeatureFilter(_ filter: FeaturedItemFilter?) {
|
||||||
// now try to update the continue reading items:
|
if let filter = filter {
|
||||||
featureItems = (items.filter { item in
|
// now try to update the continue reading items:
|
||||||
filter.predicate.evaluate(with: item)
|
featureItems = (items.filter { item in
|
||||||
} as NSArray)
|
filter.predicate.evaluate(with: item)
|
||||||
.sortedArray(using: [filter.sortDescriptor])
|
} as NSArray)
|
||||||
.compactMap { $0 as? LinkedItem }
|
.sortedArray(using: [filter.sortDescriptor])
|
||||||
featureFilter = filter
|
.compactMap { $0 as? LinkedItem }
|
||||||
|
featureFilter = filter.rawValue
|
||||||
|
} else {
|
||||||
|
featureItems = []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleReaderItemNotification(objectID: NSManagedObjectID, dataService: DataService) {
|
func handleReaderItemNotification(objectID: NSManagedObjectID, dataService: DataService) {
|
||||||
|
|||||||
@ -12,6 +12,7 @@ public enum UserDefaultKey: String {
|
|||||||
case firebasePushToken
|
case firebasePushToken
|
||||||
case homeFeedlayoutPreference
|
case homeFeedlayoutPreference
|
||||||
case lastSelectedLinkedItemFilter
|
case lastSelectedLinkedItemFilter
|
||||||
|
case lastSelectedFeaturedItemFilter
|
||||||
case lastUsedAppVersion
|
case lastUsedAppVersion
|
||||||
case lastUsedAppBuildNumber
|
case lastUsedAppBuildNumber
|
||||||
case lastItemSyncTime
|
case lastItemSyncTime
|
||||||
|
|||||||
@ -76,19 +76,19 @@ public struct LibraryFeatureCard: View {
|
|||||||
switch phase {
|
switch phase {
|
||||||
case .empty:
|
case .empty:
|
||||||
Color.systemBackground
|
Color.systemBackground
|
||||||
.frame(width: 150, height: 90)
|
.frame(width: 146, height: 90)
|
||||||
.cornerRadius(8)
|
.cornerRadius(5)
|
||||||
case let .success(image):
|
case let .success(image):
|
||||||
image.resizable()
|
image.resizable()
|
||||||
.aspectRatio(contentMode: .fill)
|
.aspectRatio(contentMode: .fill)
|
||||||
.frame(width: 150, height: 90)
|
.frame(width: 146, height: 90)
|
||||||
.cornerRadius(8)
|
.cornerRadius(5)
|
||||||
case .failure:
|
case .failure:
|
||||||
Image(systemName: "photo")
|
Image(systemName: "photo")
|
||||||
.frame(width: 150, height: 90)
|
.frame(width: 146, height: 90)
|
||||||
.foregroundColor(Color(hex: "#6A6968"))
|
.foregroundColor(Color(hex: "#6A6968"))
|
||||||
.background(Color(hex: "#EBEBEB"))
|
.background(Color(hex: "#EBEBEB"))
|
||||||
.cornerRadius(8)
|
.cornerRadius(5)
|
||||||
@unknown default:
|
@unknown default:
|
||||||
// Since the AsyncImagePhase enum isn't frozen,
|
// Since the AsyncImagePhase enum isn't frozen,
|
||||||
// we need to add this currently unused fallback
|
// we need to add this currently unused fallback
|
||||||
@ -99,10 +99,10 @@ public struct LibraryFeatureCard: View {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Image(systemName: "photo")
|
Image(systemName: "photo")
|
||||||
.frame(width: 150, height: 90)
|
.frame(width: 146, height: 90)
|
||||||
.foregroundColor(Color(hex: "#6A6968"))
|
.foregroundColor(Color(hex: "#6A6968"))
|
||||||
.background(Color(hex: "#EBEBEB"))
|
.background(Color(hex: "#EBEBEB"))
|
||||||
.cornerRadius(8)
|
.cornerRadius(5)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user