diff --git a/apple/Omnivore.xcworkspace/xcshareddata/swiftpm/Package.resolved b/apple/Omnivore.xcworkspace/xcshareddata/swiftpm/Package.resolved index b740628b5..d5a6b0de1 100644 --- a/apple/Omnivore.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/apple/Omnivore.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/nathantannar4/Engine", "state" : { - "revision" : "31949c114698e4fd43fd76290913bca415fa87bc", - "version" : "1.1.0" + "revision" : "e9867eb6df013abc65c3437d295e594077469a13", + "version" : "1.5.1" } }, { @@ -180,24 +180,6 @@ "version" : "1.0.2" } }, - { - "identity" : "swift-async-algorithms", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-async-algorithms", - "state" : { - "revision" : "da4e36f86544cdf733a40d59b3a2267e3a7bbf36", - "version" : "1.0.0" - } - }, - { - "identity" : "swift-collections", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-collections.git", - "state" : { - "revision" : "d029d9d39c87bed85b1c50adee7c41795261a192", - "version" : "1.0.6" - } - }, { "identity" : "swift-graphql", "kind" : "remoteSourceControl", @@ -257,8 +239,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/nathantannar4/Transmission", "state" : { - "revision" : "9517912f8f528c777f86f7896b5c35d7e43fa916", - "version" : "1.0.1" + "revision" : "3dac53ae4bddc7ab99e6374622a9c5eefbe50eed", + "version" : "1.1.4" } }, { @@ -266,8 +248,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/nathantannar4/Turbocharger", "state" : { - "revision" : "b4201ba0bc094facf6cabe3b36fd3763b51ccfc8", - "version" : "1.0.1" + "revision" : "095344c0cac57873e1552f30d3561ab1bec5ae35", + "version" : "1.1.4" } }, { diff --git a/apple/OmnivoreKit/Package.swift b/apple/OmnivoreKit/Package.swift index 4347f0f6a..93c47d10a 100644 --- a/apple/OmnivoreKit/Package.swift +++ b/apple/OmnivoreKit/Package.swift @@ -71,8 +71,9 @@ var dependencies: [Package.Dependency] { .package(url: "https://github.com/google/GoogleSignIn-iOS", from: "6.2.2"), .package(url: "https://github.com/gonzalezreal/swift-markdown-ui", from: "2.0.0"), .package(url: "https://github.com/PostHog/posthog-ios.git", from: "2.0.0"), - .package(url: "https://github.com/nathantannar4/Transmission", from: "1.0.1"), - .package(url: "https://github.com/apple/swift-async-algorithms", from: "1.0.0") + .package(url: "https://github.com/nathantannar4/Engine", exact: "1.5.1"), + .package(url: "https://github.com/nathantannar4/Turbocharger", exact: "1.1.4"), + .package(url: "https://github.com/nathantannar4/Transmission", from: "1.1.4") ] // Comment out following line for macOS build deps.append(.package(url: "https://github.com/PSPDFKit/PSPDFKit-SP", from: "13.1.0")) diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/Components/LibraryItemListNavigationLink.swift b/apple/OmnivoreKit/Sources/App/Views/Home/Components/LibraryItemListNavigationLink.swift index cb3b384df..63db31397 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/Components/LibraryItemListNavigationLink.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/Components/LibraryItemListNavigationLink.swift @@ -14,7 +14,7 @@ struct MacFeedCardNavigationLink: View { var body: some View { ZStack { - LibraryItemCard(item: LibraryItemData.make(from: item), viewer: dataService.currentViewer) + LibraryItemCard(item: item, viewer: dataService.currentViewer) NavigationLink(destination: LinkItemDetailView( linkedItemObjectID: item.objectID, isPDF: item.isPDF @@ -36,7 +36,7 @@ struct LibraryItemListNavigationLink: View { Button(action: { viewModel.presentItem(item: item) }, label: { - LibraryItemCard(item: LibraryItemData.make(from: item), viewer: dataService.currentViewer) + LibraryItemCard(item: item, viewer: dataService.currentViewer) }) } } @@ -54,7 +54,7 @@ struct LibraryItemGridCardNavigationLink: View { Button(action: { viewModel.presentItem(item: item) }, label: { - GridCard(item: LibraryItemData.make(from: item)) + GridCard(item: item) }) .buttonStyle(.plain) .aspectRatio(1.0, contentMode: .fill) diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index 92438d1ac..2fa9ec946 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -715,15 +715,6 @@ struct AnimatingCellHeight: AnimatableModifier { } } - var redactedItems: some View { - ForEach(Array(fakeLibraryItems(dataService: dataService).enumerated()), id: \.1.id) { _, item in - let horizontalInset = CGFloat(UIDevice.isIPad ? 20 : 10) - LibraryItemCard(item: item, viewer: dataService.currentViewer) - .listRowSeparatorTint(Color.thBorderColor) - .listRowInsets(.init(top: 0, leading: horizontalInset, bottom: 10, trailing: horizontalInset)) - }.redacted(reason: .placeholder) - } - var listItems: some View { ForEach(Array(viewModel.fetcher.items.enumerated()), id: \.1.unwrappedID) { idx, item in let horizontalInset = CGFloat(UIDevice.isIPad ? 20 : 10) @@ -814,9 +805,7 @@ struct AnimatingCellHeight: AnimatableModifier { } } - if viewModel.showLoadingBar == .redacted { - redactedItems - } else if viewModel.showLoadingBar == .simple { + if viewModel.showLoadingBar == .redacted || viewModel.showLoadingBar == .simple { VStack { ProgressView() } @@ -1001,14 +990,7 @@ struct AnimatingCellHeight: AnimatableModifier { ScrollView { LazyVGrid(columns: [GridItem(.adaptive(minimum: 325, maximum: 400), spacing: 16)], alignment: .center, spacing: 30) { - if viewModel.showLoadingBar == .redacted { - ForEach(fakeLibraryItems(dataService: dataService), id: \.id) { item in - GridCard(item: item) - .aspectRatio(1.0, contentMode: .fill) - .background(Color.systemBackground) - .cornerRadius(6) - }.redacted(reason: .placeholder) - } else if viewModel.showLoadingBar == .simple { + if viewModel.showLoadingBar == .redacted || viewModel.showLoadingBar == .simple { VStack { ProgressView() } @@ -1125,31 +1107,6 @@ struct LinkDestination: View { } } -func fakeLibraryItems(dataService _: DataService) -> [LibraryItemData] { - Array( - repeatElement(0, count: 20) - .map { _ in - LibraryItemData( - id: UUID().uuidString, - title: "fake title that is kind of long so it looks better", - pageURLString: "", - isArchived: false, - author: "fake author", - deepLink: nil, - hasLabels: false, - noteText: nil, - readingProgress: 10, - wordsCount: 10, - isPDF: false, - highlights: nil, - sortedLabels: [], - imageURL: nil, - publisherDisplayName: "fake publisher", - descriptionText: "This is a fake description" - ) - }) -} - struct BottomView: View { @ObservedObject var viewModel: HomeFeedViewModel @EnvironmentObject var dataService: DataService diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift index 69631117c..4229cc18d 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift @@ -11,10 +11,10 @@ public enum GridCardAction { } public struct GridCard: View { - let item: LibraryItemData + let item: Models.LibraryItem public init( - item: LibraryItemData + item: Models.LibraryItem ) { self.item = item } @@ -67,7 +67,7 @@ public struct GridCard: View { var fallbackImage: some View { GeometryReader { geo in HStack { - Text(item.title) + Text(item.title ?? "") .font(fallbackFont) .frame(alignment: .center) .multilineTextAlignment(.leading) @@ -232,7 +232,7 @@ public struct GridCard: View { .dynamicTypeSize(.xSmall ... .medium) .padding(.horizontal, 15) - Text(item.title) + Text(item.title ?? "") .lineLimit(2) .font(.appHeadline) .foregroundColor(.appGrayTextContrast) @@ -246,7 +246,7 @@ public struct GridCard: View { // Link description and image HStack(alignment: .top) { - Text(item.descriptionText ?? item.title) + Text(item.descriptionText ?? item.title ?? "") .font(.appSubheadline) .foregroundColor(.appGrayTextContrast) .lineLimit(2) diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/LibraryItemCard.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/LibraryItemCard.swift index 0a963f7da..261e45dc5 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/LibraryItemCard.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/LibraryItemCard.swift @@ -32,11 +32,11 @@ enum FlairLabels: String { } public extension View { - func draggableItem(item: LibraryItemData) -> some View { + func draggableItem(item: Models.LibraryItem) -> some View { #if os(iOS) if #available(iOS 16.0, *), let url = item.deepLink { return AnyView(self.draggable(url) { - Label(item.title, systemImage: "link") + Label(item.title ?? "", systemImage: "link") }) } #endif @@ -44,75 +44,12 @@ public extension View { } } -public struct LibraryItemData { - public var id: String - public let title: String - public let pageURLString: String - public var isArchived: Bool - public let author: String? - public let deepLink: URL? - public let hasLabels: Bool - public let noteText: String? - public let readingProgress: Double - public let wordsCount: Int64 - public let isPDF: Bool - public let highlights: NSSet? - public let sortedLabels: [LinkedItemLabel] - public let imageURL: URL? - public let publisherDisplayName: String? - public let descriptionText: String? - - public init(id: String, title: String, pageURLString: String, isArchived: Bool, author: String?, - deepLink: URL?, hasLabels: Bool, noteText: String?, - readingProgress: Double, wordsCount: Int64, isPDF: Bool, highlights: NSSet?, - sortedLabels: [LinkedItemLabel], imageURL: URL?, publisherDisplayName: String?, descriptionText: String?) - { - self.id = id - self.title = title - self.pageURLString = pageURLString - self.isArchived = isArchived - self.author = author - self.deepLink = deepLink - self.hasLabels = hasLabels - self.noteText = noteText - self.readingProgress = readingProgress - self.wordsCount = wordsCount - self.isPDF = isPDF - self.highlights = highlights - self.sortedLabels = sortedLabels - self.imageURL = imageURL - self.publisherDisplayName = publisherDisplayName - self.descriptionText = descriptionText - } - - public static func make(from item: Models.LibraryItem) -> LibraryItemData { - LibraryItemData( - id: item.unwrappedID, - title: item.unwrappedTitle, - pageURLString: item.unwrappedPageURLString, - isArchived: item.isArchived, - author: item.author, - deepLink: item.deepLink, - hasLabels: item.hasLabels, - noteText: item.noteText, - readingProgress: item.readingProgress, - wordsCount: item.wordsCount, - isPDF: item.isPDF, - highlights: item.highlights, - sortedLabels: item.sortedLabels, - imageURL: item.imageURL, - publisherDisplayName: item.publisherDisplayName, - descriptionText: item.descriptionText - ) - } -} - public struct LibraryItemCard: View { let viewer: Viewer? - var item: LibraryItemData + @ObservedObject var item: Models.LibraryItem @State var noteLineLimit: Int? = 3 - public init(item: LibraryItemData, viewer: Viewer?) { + public init(item: Models.LibraryItem, viewer: Viewer?) { self.item = item self.viewer = viewer } @@ -362,7 +299,7 @@ public struct LibraryItemCard: View { readInfo .dynamicTypeSize(.xSmall ... .medium) - Text(item.title) + Text(item.title ?? "") .font(.body).fontWeight(.semibold) .lineSpacing(1.25) .foregroundColor(.appGrayTextContrast)