Skip to content

Commit e77eb95

Browse files
authored
Handle missing react-native-safe-area-context in ScreenFooter screen (#3941)
* fix: handle missing react-native-safe-area-context in ScreenFooter demo screen * fix: replace circular barrel import with direct Image import in ScreenFooter Made-with: Cursor
1 parent cd6397b commit e77eb95

2 files changed

Lines changed: 31 additions & 3 deletions

File tree

demo/src/screens/componentScreens/ScreenFooterScreen.tsx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, {useState} from 'react';
22
import {StyleSheet, ScrollView} from 'react-native';
3-
import {SafeAreaProvider} from 'react-native-safe-area-context';
43
import {
54
View,
65
Text,
@@ -21,6 +20,11 @@ import {
2120
Icon
2221
} from 'react-native-ui-lib';
2322

23+
let SafeAreaProvider: React.ComponentType<any> | undefined;
24+
try {
25+
SafeAreaProvider = require('react-native-safe-area-context').SafeAreaProvider;
26+
} catch {}
27+
2428
// eslint-disable-next-line @typescript-eslint/no-var-requires
2529
const basketIcon = require('../../assets/icons/collections.png');
2630

@@ -93,7 +97,23 @@ const KEYBOARD_BEHAVIOR_OPTIONS_SPACED = [
9397
{label: '', value: 'dummy'}
9498
];
9599

96-
const ScreenFooterScreen = () => {
100+
const MissingDependencyScreen = () => {
101+
return (
102+
<View flex center padding-s5>
103+
<Text text60 $textDangerLight center>
104+
Missing Dependency
105+
</Text>
106+
<Text text70 center marginT-s3>
107+
This screen requires react-native-safe-area-context to be installed.
108+
</Text>
109+
<Text text80 $textNeutral center marginT-s2>
110+
Run: npm/yarn install react-native-safe-area-context
111+
</Text>
112+
</View>
113+
);
114+
};
115+
116+
const ScreenFooterContent = () => {
97117
const [itemsCount, setItemsCount] = useState(2);
98118
const [layout, setLayout] = useState<ScreenFooterLayouts>(ScreenFooterLayouts.HORIZONTAL);
99119
const [background, setBackground] = useState<ScreenFooterBackgrounds>(ScreenFooterBackgrounds.SOLID);
@@ -474,6 +494,14 @@ const ScreenFooterScreen = () => {
474494
);
475495
};
476496

497+
const ScreenFooterScreen = () => {
498+
if (!SafeAreaProvider) {
499+
return <MissingDependencyScreen />;
500+
}
501+
502+
return <ScreenFooterContent />;
503+
};
504+
477505
const styles = StyleSheet.create({
478506
scrollContent: {
479507
padding: 20,

packages/react-native-ui-lib/src/components/screenFooter/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React, {useCallback, useEffect, useMemo, useState} from 'react';
22
import {LayoutChangeEvent, StyleSheet, ViewStyle} from 'react-native';
3-
import {Image} from 'react-native-ui-lib';
43
import Animated, {useAnimatedKeyboard, useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated';
54
import {Keyboard} from 'uilib-native';
65
import {SafeAreaContextPackage} from '../../optionalDependencies';
76
import View from '../view';
7+
import Image from '../image';
88
import Assets from '../../assets';
99
import {Colors, Shadows, Spacings} from '../../style';
1010
import {asBaseComponent, Constants} from '../../commons/new';

0 commit comments

Comments
 (0)