Skip to content

Commit d3abb91

Browse files
committed
Fix modal safe area handling for proper screen orientation
- HomeScreen: Use useSafeAreaInsets for detail modal to prevent content going under status bar/notch - InfoScreen: Use dynamic safe area insets for image viewer header - Add statusBarTranslucent prop to modal for proper behavior - Remove fixed paddingTop from InfoScreen imageViewerHeader style - Add bottom safe area padding for proper scrollview handling
1 parent f7d2f3a commit d3abb91

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

screens/HomeScreen.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import {
1313
RefreshControl,
1414
Linking,
1515
ScrollView,
16+
StatusBar,
17+
Platform,
1618
} from 'react-native';
19+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
1720
import { useTranslation } from 'react-i18next';
1821
import { Ionicons } from '@expo/vector-icons';
1922
import { db } from '../firebase.config';
@@ -121,6 +124,7 @@ const getDirectImageUrl = (url: string): string => {
121124

122125
export default function HomeScreen() {
123126
const { t, i18n } = useTranslation();
127+
const insets = useSafeAreaInsets();
124128
const [content, setContent] = useState<ContentItem[]>([]);
125129
const [loading, setLoading] = useState(true);
126130
const [refreshing, setRefreshing] = useState(false);
@@ -766,8 +770,10 @@ export default function HomeScreen() {
766770
transparent={false}
767771
visible={modalVisible}
768772
onRequestClose={closeModal}
773+
statusBarTranslucent={true}
769774
>
770-
<SafeAreaView style={styles.modalContainer}>
775+
<View style={[styles.modalContainer, { paddingTop: insets.top }]}>
776+
<StatusBar barStyle="dark-content" backgroundColor="#FFFFFF" />
771777
{/* Modal Header */}
772778
<View style={styles.modalHeader}>
773779
<TouchableOpacity onPress={closeModal} style={styles.closeButton}>
@@ -924,9 +930,9 @@ export default function HomeScreen() {
924930
)}
925931
</View>
926932

927-
<View style={styles.bottomSpacing} />
933+
<View style={[styles.bottomSpacing, { paddingBottom: insets.bottom }]} />
928934
</ScrollView>
929-
</SafeAreaView>
935+
</View>
930936
</Modal>
931937
);
932938
};

screens/InfoScreen.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ import {
1313
Dimensions,
1414
Image,
1515
Modal,
16+
Platform,
1617
} from 'react-native';
18+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
1719
import ImageViewer from 'react-native-image-zoom-viewer';
1820
import { Ionicons } from '@expo/vector-icons';
1921
import { useTranslation } from 'react-i18next';
@@ -91,6 +93,7 @@ interface ContentItem {
9193

9294
export default function InfoScreen() {
9395
const { t, i18n } = useTranslation();
96+
const insets = useSafeAreaInsets();
9497
const [location, setLocation] = useState<Location.LocationObject | null>(null);
9598
const [weather, setWeather] = useState<WeatherData | null>(null);
9699
const [aiResponse, setAiResponse] = useState<AIResponse>({
@@ -1395,7 +1398,7 @@ Keep the response concise, practical, and actionable for farmers. Remember to re
13951398
onCancel={() => setSelectedImage(null)}
13961399
backgroundColor="rgba(0, 0, 0, 0.9)"
13971400
renderHeader={(currentIndex) => (
1398-
<View style={styles.imageViewerHeader}>
1401+
<View style={[styles.imageViewerHeader, { paddingTop: insets.top + 10 }]}>
13991402
<TouchableOpacity
14001403
style={styles.imageViewerClose}
14011404
onPress={() => setSelectedImage(null)}
@@ -2042,7 +2045,6 @@ const styles = StyleSheet.create({
20422045
left: 0,
20432046
right: 0,
20442047
zIndex: 10,
2045-
paddingTop: 50,
20462048
paddingHorizontal: 20,
20472049
},
20482050
imageViewerTitle: {

0 commit comments

Comments
 (0)