From 216941355425d743d225c52a60432c8e0f16973f Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Tue, 22 Feb 2022 09:17:54 -0800 Subject: [PATCH] resolve lint/xcode warnings --- .../Share/ShareExtensionScene.swift | 24 +----------- .../Binders/Scenes/HomeFeedScene.swift | 1 - .../Sources/Models/PageScrapePayload.swift | 1 + .../Queries/LibraryItemsQuery.swift | 1 - .../Sources/Utils/FeatureFlags.swift | 2 +- .../Sources/Views/Article/WebAppView.swift | 4 +- .../Colors/UIColor+SystemOverrides.swift | 6 ++- .../Sources/Views/FormSheetWrapper.swift | 20 +++++----- .../PrimaryContainerViews/HomeFeedView.swift | 2 +- .../OmnivoreKit/Sources/Views/SnackBar.swift | 24 ++++++------ .../Sources/Views/SnoozeView.swift | 37 ++++++++++--------- apple/Sources/PDFViewer.swift | 17 ++++----- 12 files changed, 61 insertions(+), 78 deletions(-) diff --git a/apple/OmnivoreKit/Sources/Binders/AppExtensions/Share/ShareExtensionScene.swift b/apple/OmnivoreKit/Sources/Binders/AppExtensions/Share/ShareExtensionScene.swift index 9f0900474..52e7326a5 100644 --- a/apple/OmnivoreKit/Sources/Binders/AppExtensions/Share/ShareExtensionScene.swift +++ b/apple/OmnivoreKit/Sources/Binders/AppExtensions/Share/ShareExtensionScene.swift @@ -32,29 +32,8 @@ extension ShareExtensionViewModel { switch action { case let .savePage(requestID): self?.savePage(extensionContext: extensionContext, requestId: requestID) - case let .dismissButtonTapped(reminderTime, hideUntilReminded): + case .dismissButtonTapped: extensionContext?.completeRequest(returningItems: [], completionHandler: nil) -// -// guard let reminderTime = reminderTime, let self = self else { -// extensionContext?.completeRequest(returningItems: [], completionHandler: nil) -// return -// } -// -// let services = Services() -// -// services.dataService.createReminderPublisher( -// hideUntilReminded: hideUntilReminded, -// reminderTime: reminderTime, -// reminderItemId: .clientRequest(id: self.requestID) -// ) -// .sink { _ in -// extensionContext?.completeRequest(returningItems: [], completionHandler: nil) -// } receiveValue: { _ in -// extensionContext?.completeRequest(returningItems: [], completionHandler: nil) -// } -// .store(in: &self.subscriptions) -// -// extensionContext?.completeRequest(returningItems: [], completionHandler: nil) case .copyLinkButtonTapped: print("copy link button tapped") case .readNowButtonTapped: @@ -65,7 +44,6 @@ extension ShareExtensionViewModel { } #endif extensionContext?.completeRequest(returningItems: [], completionHandler: nil) - // TODO: implement macos case .archiveButtonTapped: print("archive button tapped") } diff --git a/apple/OmnivoreKit/Sources/Binders/Scenes/HomeFeedScene.swift b/apple/OmnivoreKit/Sources/Binders/Scenes/HomeFeedScene.swift index fe4ffde01..eb3e53be7 100644 --- a/apple/OmnivoreKit/Sources/Binders/Scenes/HomeFeedScene.swift +++ b/apple/OmnivoreKit/Sources/Binders/Scenes/HomeFeedScene.swift @@ -177,7 +177,6 @@ extension HomeFeedViewModel { } } -// TODO: replace these deprecated calls with a progress bar or custom spinner private func startNetworkActivityIndicator() { #if os(iOS) UIApplication.shared.isNetworkActivityIndicatorVisible = true diff --git a/apple/OmnivoreKit/Sources/Models/PageScrapePayload.swift b/apple/OmnivoreKit/Sources/Models/PageScrapePayload.swift index 792b12808..d2f1955a3 100644 --- a/apple/OmnivoreKit/Sources/Models/PageScrapePayload.swift +++ b/apple/OmnivoreKit/Sources/Models/PageScrapePayload.swift @@ -71,6 +71,7 @@ public enum PageScraper { } } + // swiftlint:disable:next function_body_length private static func scrapeURLOnly( extensionContext: NSExtensionContext?, completion: @escaping (Result) -> Void diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Queries/LibraryItemsQuery.swift b/apple/OmnivoreKit/Sources/Services/DataService/Queries/LibraryItemsQuery.swift index 5e51d7af9..e8b86506c 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Queries/LibraryItemsQuery.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Queries/LibraryItemsQuery.swift @@ -107,7 +107,6 @@ public extension DataService { case let .success(payload): switch payload.data { case let .success(result: result): - // TODO: check local db to see what has a local documentpath promise(.success(result)) case .error: promise(.failure(.unknown)) diff --git a/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift b/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift index 2c36508d1..3dfabc24c 100644 --- a/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift +++ b/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift @@ -7,10 +7,10 @@ import Foundation #endif public enum FeatureFlag { - public static let exampleFlag = false // unused public static let showAccountDeletion = false public static let enableSnoozeFromShareExtension = false public static let enableReadNowFromShareExtension = false public static let enableRemindersFromShareExtension = false public static let enablePushNotifications = false + public static let enableShareButton = false } diff --git a/apple/OmnivoreKit/Sources/Views/Article/WebAppView.swift b/apple/OmnivoreKit/Sources/Views/Article/WebAppView.swift index fd5eb6870..e725392f9 100644 --- a/apple/OmnivoreKit/Sources/Views/Article/WebAppView.swift +++ b/apple/OmnivoreKit/Sources/Views/Article/WebAppView.swift @@ -35,7 +35,7 @@ import WebKit webView.configuration.userContentController = contentController webView.scrollView.delegate = context.coordinator webView.scrollView.contentInset.top = LinkItemDetailView.navBarHeight - webView.scrollView.verticalScrollIndicatorInsets = UIEdgeInsets(top: LinkItemDetailView.navBarHeight, left: 0, bottom: 0, right: 0) + webView.scrollView.verticalScrollIndicatorInsets.top = LinkItemDetailView.navBarHeight for action in WebViewAction.allCases { webView.configuration.userContentController.add(context.coordinator, name: action.rawValue) @@ -125,7 +125,7 @@ import WebKit themeId: NSApp.effectiveAppearance.name == NSAppearance.Name.darkAqua ? "Gray" : "LightGray", margin: 0, fontSize: fontSize(), - fontFamily: "inter", // TODO: allow user to change this and save to user defaults + fontFamily: "inter", rawAuthCookie: rawAuthCookie ) ) diff --git a/apple/OmnivoreKit/Sources/Views/Colors/UIColor+SystemOverrides.swift b/apple/OmnivoreKit/Sources/Views/Colors/UIColor+SystemOverrides.swift index 2bf9beff8..2cf757618 100644 --- a/apple/OmnivoreKit/Sources/Views/Colors/UIColor+SystemOverrides.swift +++ b/apple/OmnivoreKit/Sources/Views/Colors/UIColor+SystemOverrides.swift @@ -157,11 +157,13 @@ } @objc class var customSecondarySystemGroupedBackground: UIColor { - UIColor(named: "_appPrimaryBackground", in: .module, compatibleWith: .current) ?? .secondarySystemGroupedBackground + UIColor(named: "_appPrimaryBackground", in: .module, compatibleWith: .current) + ?? .secondarySystemGroupedBackground } @objc class var customSystemTertiaryGroupedBackground: UIColor { - UIColor(named: "_appPrimaryBackground", in: .module, compatibleWith: .current) ?? .customSystemTertiaryGroupedBackground + UIColor(named: "_appPrimaryBackground", in: .module, compatibleWith: .current) + ?? .customSystemTertiaryGroupedBackground } @objc class var customSeparator: UIColor { diff --git a/apple/OmnivoreKit/Sources/Views/FormSheetWrapper.swift b/apple/OmnivoreKit/Sources/Views/FormSheetWrapper.swift index 76980a744..a998cf4d3 100644 --- a/apple/OmnivoreKit/Sources/Views/FormSheetWrapper.swift +++ b/apple/OmnivoreKit/Sources/Views/FormSheetWrapper.swift @@ -70,16 +70,17 @@ import SwiftUI let content: () -> Content func makeUIViewController( - context _: UIViewControllerRepresentableContext>) -> FormSheetWrapper - { + context _: UIViewControllerRepresentableContext> + ) -> FormSheetWrapper { let controller = FormSheetWrapper(content: content, modalSize: modalSize) controller.onDismiss = { self.show = false } return controller } - func updateUIViewController(_ uiViewController: FormSheetWrapper, - context _: UIViewControllerRepresentableContext>) - { + func updateUIViewController( + _ uiViewController: FormSheetWrapper, + context _: UIViewControllerRepresentableContext> + ) { if show { uiViewController.show() } else { @@ -89,10 +90,11 @@ import SwiftUI } public extension View { - func formSheet(isPresented: Binding, - modalSize: CGSize = CGSize(width: 320, height: 320), - @ViewBuilder content: @escaping () -> Content) -> some View - { + func formSheet( + isPresented: Binding, + modalSize: CGSize = CGSize(width: 320, height: 320), + @ViewBuilder content: @escaping () -> Content + ) -> some View { background(FormSheet(show: isPresented, modalSize: modalSize, content: content)) diff --git a/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/HomeFeedView.swift b/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/HomeFeedView.swift index 5c61c17c4..86d7da6ee 100644 --- a/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/HomeFeedView.swift +++ b/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/HomeFeedView.swift @@ -38,7 +38,7 @@ public final class HomeFeedViewModel: ObservableObject { // Check if user has scrolled to the last five items in the list if itemIndex == thresholdIndex { - print("load more items triggered") // TODO: fix loading mechanism + print("load more items triggered") // performActionSubject.send(.loadItems) } } diff --git a/apple/OmnivoreKit/Sources/Views/SnackBar.swift b/apple/OmnivoreKit/Sources/Views/SnackBar.swift index 9c3caa52a..678f8d44d 100644 --- a/apple/OmnivoreKit/Sources/Views/SnackBar.swift +++ b/apple/OmnivoreKit/Sources/Views/SnackBar.swift @@ -13,12 +13,13 @@ struct Snackbar: View { @Environment(\.colorScheme) private var colorScheme: ColorScheme - init(isShowing: Binding, - presenting: Presenting, - text: Text, - actionText: Text? = nil, - action: (() -> Void)? = nil) where Presenting: View - { + init( + isShowing: Binding, + presenting: Presenting, + text: Text, + actionText: Text? = nil, + action: (() -> Void)? = nil + ) where Presenting: View { self._isShowing = isShowing self.presenting = AnyView(presenting) self.text = text @@ -73,11 +74,12 @@ struct Snackbar: View { } public extension View { - func snackBar(isShowing: Binding, - text: Text, - actionText: Text? = nil, - action: (() -> Void)? = nil) -> some View - { + func snackBar( + isShowing: Binding, + text: Text, + actionText: Text? = nil, + action: (() -> Void)? = nil + ) -> some View { Snackbar(isShowing: isShowing, presenting: self, text: text, diff --git a/apple/OmnivoreKit/Sources/Views/SnoozeView.swift b/apple/OmnivoreKit/Sources/Views/SnoozeView.swift index 63b1c91c6..7901412cf 100644 --- a/apple/OmnivoreKit/Sources/Views/SnoozeView.swift +++ b/apple/OmnivoreKit/Sources/Views/SnoozeView.swift @@ -53,25 +53,26 @@ private struct SnoozeIconButtonView: View { let action: (_ snooze: Snooze) -> Void var body: some View { - Button(action: { - action(snooze) - }) { - VStack(alignment: .center, spacing: 8) { - snooze.icon - .font(.appTitle) - .foregroundColor(.appYellow48) - Text(snooze.title) - .font(.appBody) - .foregroundColor(.appGrayText) - Text(snooze.untilStr) - .font(.appCaption) - .foregroundColor(.appGrayText) + Button( + action: { action(snooze) }, + label: { + VStack(alignment: .center, spacing: 8) { + snooze.icon + .font(.appTitle) + .foregroundColor(.appYellow48) + Text(snooze.title) + .font(.appBody) + .foregroundColor(.appGrayText) + Text(snooze.untilStr) + .font(.appCaption) + .foregroundColor(.appGrayText) + } + .frame( + maxWidth: .infinity, + maxHeight: .infinity + ) } - .frame( - maxWidth: .infinity, - maxHeight: .infinity - ) - } + ) .frame(height: 100) } } diff --git a/apple/Sources/PDFViewer.swift b/apple/Sources/PDFViewer.swift index d1cd02e64..47f71c3c2 100644 --- a/apple/Sources/PDFViewer.swift +++ b/apple/Sources/PDFViewer.swift @@ -1,6 +1,7 @@ import Binders import Combine import SwiftUI +import Utils #if os(iOS) import PDFKit @@ -103,15 +104,13 @@ import SwiftUI let highlights = annotations?.compactMap { $0 as? HighlightAnnotation } let shortId = highlights.flatMap { coordinator.shortHighlightIds($0).first } - if let shortId = shortId { - /* - let share = MenuItem(title: "Share", block: { - if let shareURL = viewModel.highlightShareURL(shortId: shortId) { - shareLink = ShareLink(id: UUID(), url: shareURL) - } - }) - result.append(share) - */ + if let shortId = shortId, FeatureFlag.enableShareButton { + let share = MenuItem(title: "Share", block: { + if let shareURL = viewModel.highlightShareURL(shortId: shortId) { + shareLink = ShareLink(id: UUID(), url: shareURL) + } + }) + result.append(share) } return result