Skip to content

Commit 842fcea

Browse files
authored
Merge pull request #291 from Crossbell-Box/develop
Develop
2 parents daeede8 + a1d8a4f commit 842fcea

8 files changed

Lines changed: 64 additions & 32 deletions

File tree

.changeset/curvy-glasses-try.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"xlog": patch
3+
---
4+
5+
Fixed styles problem.

.changeset/weak-flowers-lick.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"xlog": patch
3+
---
4+
5+
Display the long content normaly.

src/components/BlockchainInfoIcon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const BlockchainInfoIcon: FC<Props> = (props) => {
7272
return (
7373
<>
7474
<TouchableWithoutFeedback onPress={openModal}>
75-
<ShieldCheck color="$green10" width={size}/>
75+
<ShieldCheck color="$green10" size={size}/>
7676
</TouchableWithoutFeedback>
7777
<ModalWithFadeAnimation
7878
isVisible={isModalVisible}

src/components/CommentItem.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export const CommentItem: React.FC<CommentItemProps> = (props) => {
196196
<Paragraph size={"$4"}>
197197
{comment?.metadata?.content?.content}
198198
</Paragraph>
199-
<XStack alignItems="center">
199+
<XStack alignItems="center" marginTop={"$1"}>
200200
<Text color={"$colorSubtitle"}>
201201
{commonI18n.t("ago", {
202202
time: date.dayjs
@@ -208,9 +208,7 @@ export const CommentItem: React.FC<CommentItemProps> = (props) => {
208208
})}
209209
{" · "}
210210
</Text>
211-
<Stack height={22} alignItems="center">
212-
<BlockchainInfoIcon size={16} character={comment?.character} page={comment?.toNote}/>
213-
</Stack>
211+
<BlockchainInfoIcon size={16} character={comment?.character} page={comment?.toNote}/>
214212
</XStack>
215213
</YStack>
216214

src/components/HomeTabBar.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,10 @@ export const HomeTabBar: FC<BottomTabBarProps> = (props) => {
9696
width={"95%"}
9797
height={height}
9898
position="absolute"
99+
borderRadius={100}
100+
overflow="hidden"
99101
>
100-
<Stack
101-
overflow="hidden"
102-
backgroundColor={"rgba(50, 50, 50, 0.4)"}
103-
borderRadius={100}
104-
style={StyleSheet.absoluteFill}
105-
width={"100%"}
106-
height={"100%"}
107-
position="absolute"
108-
>
109-
<BlurView tint="dark" intensity={30} style={StyleSheet.absoluteFillObject}/>
110-
</Stack>
102+
<BlurView tint="dark" intensity={30} experimentalBlurMethod="dimezisBlurView" style={StyleSheet.absoluteFillObject}/>
111103

112104
<XStack zIndex={2} flex={1} alignItems="center">
113105
{[

src/pages/PostDetails/Content.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ import useGAWithPageStayTime from "@/hooks/ga/use-ga-with-page-stay-time";
1717
import { useCharacterId } from "@/hooks/use-character-id";
1818
import { useGlobalLoading } from "@/hooks/use-global-loading";
1919
import type { useScrollVisibilityHandler } from "@/hooks/use-scroll-visibility-handler";
20-
import type { RootStackParamList } from "@/navigation/types";
2120
import { useGetPage } from "@/queries/page";
22-
import type { ExpandedNote } from "@/types/crossbell";
2321
import { GA } from "@/utils/GA";
2422
import { getNoteSlug } from "@/utils/get-slug";
2523
import { isShortNotes } from "@/utils/is-short-notes";
2624

2725
import { ShortsContentRenderer } from "./ShortsContentRenderer";
26+
import type { WebViewRendererInstance } from "./WebViewRenderer";
2827
import { WebViewRenderer } from "./WebViewRenderer";
2928

3029
export interface Props {
@@ -77,6 +76,7 @@ export const Content = React.forwardRef<PostDetailsContentInstance, Props>((prop
7776
const globalLoading = useGlobalLoading();
7877
const toast = useToastController();
7978
const gaReadEventLogged = useRef(false);
79+
const webviewRendererRef = useRef<WebViewRendererInstance>(null);
8080
const noteTitle = note?.metadata?.content?.title;
8181
const isShort = isShortNotes(note);
8282
const scrollIndicatorInsets = useMemo(() => ({
@@ -180,6 +180,7 @@ export const Content = React.forwardRef<PostDetailsContentInstance, Props>((prop
180180
{...scrollVisibilityHandler}
181181
scrollEventThrottle={16}
182182
style={styles.scrollView}
183+
onScroll={e => webviewRendererRef.current?.handleScroll(e)}
183184
onMomentumScrollEnd={onMomentumScrollEnd}
184185
scrollIndicatorInsets={scrollIndicatorInsets}
185186
contentContainerStyle={{ paddingBottom: bottomBarHeight }}
@@ -196,6 +197,7 @@ export const Content = React.forwardRef<PostDetailsContentInstance, Props>((prop
196197
)
197198
: (
198199
<WebViewRenderer
200+
ref={webviewRendererRef}
199201
postUri={postUri}
200202
headerContainerHeight={headerContainerHeight}
201203
bottomBarHeight={bottomBarHeight}

src/pages/PostDetails/WebViewRenderer.tsx

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import type { FC } from "react";
2-
import React, { useCallback, useEffect, useState } from "react";
2+
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useState } from "react";
3+
import type { NativeScrollEvent, NativeSyntheticEvent } from "react-native";
34
import { StyleSheet, useWindowDimensions } from "react-native";
45
import DeviceInfo from "react-native-device-info";
5-
import Animated, { useSharedValue } from "react-native-reanimated";
6+
import Animated, { runOnUI, useAnimatedStyle, useSharedValue } from "react-native-reanimated";
67
import { useSafeAreaInsets } from "react-native-safe-area-context";
78

9+
import { Image } from "expo-image";
810
import { Stack } from "tamagui";
911

1012
import { ImageGallery } from "@/components/ImageGallery";
@@ -18,18 +20,23 @@ import { javaScriptBeforeContentLoaded } from "./javascript-before-content";
1820
import { javaScriptContentLoaded } from "./javascript-content";
1921
import { Skeleton } from "./Skeleton";
2022

21-
export const WebViewRenderer: FC<{
23+
interface Props {
2224
headerContainerHeight: number
2325
postUri?: string
2426
bottomBarHeight: number
25-
}> = ({ headerContainerHeight, postUri, bottomBarHeight }) => {
26-
const { top } = useSafeAreaInsets();
27+
}
28+
29+
export interface WebViewRendererInstance {
30+
handleScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => void
31+
}
32+
33+
export const WebViewRenderer = forwardRef<WebViewRendererInstance, Props>(({ headerContainerHeight, postUri, bottomBarHeight }, ref) => {
34+
const { top, bottom } = useSafeAreaInsets();
2735
const { width, height } = useWindowDimensions();
2836
const { isDarkMode, mode } = useThemeStore();
2937
const navigation = useRootNavigation();
3038
const headerHeight = top + headerContainerHeight;
3139
const contentLoaderDimensions = { width, height: height - headerHeight };
32-
const [webviewHeight, setWebviewHeight] = useState(contentLoaderDimensions.height);
3340
const [userAgent, setUserAgent] = React.useState<string>(null);
3441
const [displayImageUris, setDisplayImageUris] = React.useState<string[]>([]);
3542
const webviewLoadingAnimValue = useSharedValue<number>(0);
@@ -70,7 +77,7 @@ export const WebViewRenderer: FC<{
7077
}
7178

7279
if (height) {
73-
setWebviewHeight(Math.max(height, contentLoaderDimensions.height));
80+
setMaxContentHeight(Math.max(height, contentLoaderDimensions.height));
7481
}
7582

7683
if (imageUrlArray) {
@@ -88,14 +95,31 @@ export const WebViewRenderer: FC<{
8895
});
8996
}, []);
9097

98+
const { height: screenHeight } = useWindowDimensions();
99+
const [maxContentHeight, setMaxContentHeight] = useState<number>(screenHeight);
100+
const animHeight = useSharedValue<number>(screenHeight);
101+
const animatedStyle = useAnimatedStyle(() => ({ height: animHeight.value }), []);
102+
103+
const updateHeight = React.useCallback((offsetY) => {
104+
"worklet";
105+
const tolerance = 100;
106+
const isReachBottom = (offsetY + bottomBarHeight + headerContainerHeight) > (animHeight.value / 2);
107+
if (isReachBottom && animHeight.value < maxContentHeight) {
108+
animHeight.value += tolerance;
109+
}
110+
}, [maxContentHeight, bottomBarHeight, headerContainerHeight]);
111+
112+
useImperativeHandle(ref, () => ({
113+
handleScroll: (e) => {
114+
runOnUI(updateHeight)(e.nativeEvent.contentOffset.y);
115+
},
116+
}), [updateHeight]);
117+
91118
const closeModal = React.useCallback(() => setDisplayImageUris([]), []);
92119

93120
return (
94121
<>
95-
<Animated.ScrollView
96-
contentContainerStyle={{ height: webviewHeight }}
97-
scrollEventThrottle={16}
98-
>
122+
<Animated.View style={animatedStyle}>
99123
{postUri && userAgent && (
100124
<WebView
101125
progressBarShown={false}
@@ -118,7 +142,7 @@ export const WebViewRenderer: FC<{
118142
injectedJavaScriptBeforeContentLoaded={javaScriptBeforeContentLoaded(mode)}
119143
/>
120144
)}
121-
</Animated.ScrollView>
145+
</Animated.View>
122146
{
123147
displayImageUris.length > 0 && (
124148
<ImageGallery
@@ -130,7 +154,7 @@ export const WebViewRenderer: FC<{
130154
}
131155
</>
132156
);
133-
};
157+
});
134158

135159
const styles = StyleSheet.create({
136160
container: {

src/pages/PostDetails/javascript-content.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,14 @@ export const javaScriptContentLoaded = (
3939
return false;
4040
}
4141
42+
const isDataUrl = src => src.startsWith('data:image');
4243
const clickedImageUrl = event.target.src || event.target.dataset.src;
43-
const images = Array.from(document.getElementsByTagName('img')).filter(img => !isAvatar(img));
44+
45+
if (isDataUrl(clickedImageUrl)) {
46+
return false;
47+
}
48+
49+
const images = Array.from(document.getElementsByTagName('img')).filter(img => !isAvatar(img) && !isDataUrl(img.src));
4450
const allImageUrls = Array.from(images).map(img => img.src || img.dataset.src);
4551
const imageUrlSet = new Set([clickedImageUrl, ...allImageUrls]);
4652
const imageUrlArray = Array.from(imageUrlSet);

0 commit comments

Comments
 (0)