Merge pull request #2638 from omnivore-app/feat/ios-upgrade-appreader

Add lightbox to the appreader
This commit is contained in:
Jackson Harper
2023-08-10 17:19:37 +08:00
committed by GitHub
6 changed files with 49 additions and 23 deletions

File diff suppressed because one or more lines are too long

View File

@ -110,6 +110,12 @@ struct WebReaderContainerView: View {
showBottomBar = navBarVisible
showNavBarActionID = UUID()
}
case "dismissNavBars":
withAnimation {
navBarVisible = false
showBottomBar = false
showNavBarActionID = UUID()
}
default:
break
}

File diff suppressed because one or more lines are too long

View File

@ -52,8 +52,6 @@ const mutation = async (name, input) => {
const App = () => {
applyStoredTheme(false)
console.log('rerendering: ', window.omnivoreArticle)
return (
<>
<Box

View File

@ -1,4 +1,4 @@
import { Box } from '../../elements/LayoutPrimitives'
import { Box, SpanBox } from '../../elements/LayoutPrimitives'
import {
getTopOmnivoreAnchorElement,
parseDomTree,
@ -7,7 +7,7 @@ import {
ScrollOffsetChangeset,
useScrollWatcher,
} from '../../../lib/hooks/useScrollWatcher'
import { MutableRefObject, useEffect, useRef, useState } from 'react'
import { MutableRefObject, useEffect, useMemo, useRef, useState } from 'react'
import { isDarkTheme } from '../../../lib/themeUpdater'
import { ArticleMutations } from '../../../lib/articleActions'
import { Lightbox, SlideImage } from 'yet-another-react-lightbox'
@ -15,6 +15,7 @@ import 'yet-another-react-lightbox/styles.css'
import Download from 'yet-another-react-lightbox/plugins/download'
import Fullscreen from 'yet-another-react-lightbox/plugins/fullscreen'
import Zoom from 'yet-another-react-lightbox/plugins/zoom'
import Counter from 'yet-another-react-lightbox/plugins/counter'
import loadjs from 'loadjs'
@ -26,6 +27,7 @@ export type ArticleProps = {
initialReadingProgressTop?: number
highlightHref: MutableRefObject<string | null>
articleMutations: ArticleMutations
isAppleAppEmbed: boolean
}
export function Article(props: ArticleProps): JSX.Element {
@ -244,14 +246,27 @@ export function Article(props: ArticleProps): JSX.Element {
setlightBoxIndex(idx)
setLightboxOpen(true)
event.preventDefault()
event.stopPropagation()
}
console.log('updated image: ', img)
})
console.log('set srcs: ', srcs)
console.log('setting srcs: ', srcs)
}, [props.content])
useEffect(() => {
if (lightboxOpen) {
window?.webkit?.messageHandlers.highlightAction?.postMessage({
actionID: 'dismissNavBars',
})
}
}, [lightboxOpen])
const lightboxPlugins = useMemo(() => {
if (props.isAppleAppEmbed) {
return [Fullscreen, Counter, Zoom]
} else {
return [Fullscreen, Download, Counter, Zoom]
}
}, [props])
return (
<>
<link
@ -269,20 +284,26 @@ export function Article(props: ArticleProps): JSX.Element {
__html: props.content,
}}
/>
<Lightbox
open={lightboxOpen}
index={lightboxIndex}
close={() => setLightboxOpen(false)}
slides={imageSrcs}
plugins={[Fullscreen, Download, Zoom]}
controller={{ closeOnPullDown: true }}
carousel={{
finite: true,
<SpanBox
onClick={(event) => {
event.stopPropagation()
}}
zoom={{
maxZoomPixelRatio: 3,
}}
/>
>
<Lightbox
open={lightboxOpen}
index={lightboxIndex}
close={() => setLightboxOpen(false)}
slides={imageSrcs}
plugins={lightboxPlugins}
controller={{ closeOnPullDown: true, closeOnBackdropClick: true }}
zoom={{
maxZoomPixelRatio: 3,
}}
render={{
buttonZoom: () => undefined,
}}
/>
</SpanBox>
</>
)
}

View File

@ -452,6 +452,7 @@ export function ArticleContainer(props: ArticleContainerProps): JSX.Element {
initialAnchorIndex={props.article.readingProgressAnchorIndex}
initialReadingProgressTop={props.article.readingProgressTopPercent}
articleMutations={props.articleMutations}
isAppleAppEmbed={props.isAppleAppEmbed}
/>
<Button
style="ghost"