From 5547a7bb6e82c9abb94a7cec8fe66f31bf39ecbc Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 2 Jun 2022 16:17:27 -0700 Subject: [PATCH] Improve preview images from content --- .../Sources/Views/ShareExtensionView.swift | 18 ++++++++---------- apple/Sources/ShareExtension/ShareExtension.js | 3 +++ .../ShareExtensionViewController.swift | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/apple/OmnivoreKit/Sources/Views/ShareExtensionView.swift b/apple/OmnivoreKit/Sources/Views/ShareExtensionView.swift index 21b318978..011862f6c 100644 --- a/apple/OmnivoreKit/Sources/Views/ShareExtensionView.swift +++ b/apple/OmnivoreKit/Sources/Views/ShareExtensionView.swift @@ -196,12 +196,14 @@ public struct ShareExtensionChildView: View { .resizable() .aspectRatio(contentMode: .fill) .frame(width: 61, height: 61) + .clipped() } else if case AsyncImageStatus.loading = imageStatus { Color.appButtonBackground .aspectRatio(contentMode: .fill) .frame(width: 61, height: 61) } else { EmptyView() + .frame(width: 61, height: 61) } } } else { @@ -257,16 +259,12 @@ public struct ShareExtensionChildView: View { Spacer() HStack { - // if case ShareExtensionStatus.saved = status || case ShareExtensionStatus.synced = status { - Button( - action: { readNowButtonAction() }, - label: { Text("Read Now").frame(maxWidth: .infinity) } - ) - .buttonStyle(RoundedRectButtonStyle()) - // } - if case ShareExtensionStatus.processing = viewModel.status, FeatureFlag.enableReadNow { - Button(action: {}, label: { ProgressView().frame(maxWidth: .infinity) }) - .buttonStyle(RoundedRectButtonStyle()) + if FeatureFlag.enableReadNow { + Button( + action: { readNowButtonAction() }, + label: { Text("Read Now").frame(maxWidth: .infinity) } + ) + .buttonStyle(RoundedRectButtonStyle()) } Button( action: { diff --git a/apple/Sources/ShareExtension/ShareExtension.js b/apple/Sources/ShareExtension/ShareExtension.js index 24de12ff9..1b2f22b4d 100644 --- a/apple/Sources/ShareExtension/ShareExtension.js +++ b/apple/Sources/ShareExtension/ShareExtension.js @@ -2,6 +2,9 @@ var ShareExtension = function() {}; function iconURL() { try { + const previewImage = document.querySelector("meta[property='og:image'], meta[name='twitter:image']").content + if (previewImage) { return previewImage } + return document.querySelector("link[rel='apple-touch-icon'], link[rel='shortcut icon'], link[rel='icon']").href } catch {} return null diff --git a/apple/Sources/ShareExtension/ShareExtensionViewController.swift b/apple/Sources/ShareExtension/ShareExtensionViewController.swift index 9b118b175..96a9c88ce 100644 --- a/apple/Sources/ShareExtension/ShareExtensionViewController.swift +++ b/apple/Sources/ShareExtension/ShareExtensionViewController.swift @@ -12,7 +12,7 @@ import Utils embed( childViewController: UIViewController.makeShareExtensionController(extensionContext: extensionContext), - heightRatio: 0.5 + heightRatio: 0.55 ) } }