Skip to content

Commit 86babf5

Browse files
committed
fix(intro-screen-native): fix inconsistent layout between android-ios
1 parent 9361768 commit 86babf5

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

packages/pluggableWidgets/intro-screen-native/src/SwipeableContainer.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const refreshActiveSlideAttribute = (slides: SlidesType[], activeSlide?: Editabl
6868

6969
export const SwipeableContainer = (props: SwipeableContainerProps): ReactElement => {
7070
const [width, setWidth] = useState(0);
71+
const [height, setHeight] = useState(0);
7172
const [activeIndex, setActiveIndex] = useState(0);
7273
const flashList = useRef<FlashListRef<any>>(null);
7374
const isInitializing = useRef(true);
@@ -124,9 +125,9 @@ export const SwipeableContainer = (props: SwipeableContainerProps): ReactElement
124125

125126
const renderItem = useCallback(
126127
({ item }: any): ReactElement => {
127-
return <View style={[{ width }]}>{item.content}</View>;
128+
return <View style={[{ width }, { height }]}>{item.content}</View>;
128129
},
129-
[width]
130+
[width, height]
130131
);
131132

132133
const renderButton = (
@@ -327,12 +328,17 @@ export const SwipeableContainer = (props: SwipeableContainerProps): ReactElement
327328
*/
328329
const onLayout = useCallback(
329330
(event: LayoutChangeEvent) => {
330-
const newWidth = event.nativeEvent.layout.width;
331+
const layout = event.nativeEvent.layout;
332+
const newWidth = layout.width;
331333
if (newWidth !== width) {
332334
setWidth(newWidth);
333335
}
336+
const newHeight = layout.height;
337+
if (newHeight !== height) {
338+
setHeight(newHeight);
339+
}
334340
},
335-
[width]
341+
[width, height]
336342
);
337343

338344
return (

0 commit comments

Comments
 (0)