Skip to content

Commit 2b4da8a

Browse files
committed
refactor: wrap components in SafeAreaView for improved layout consistency
1 parent 5206902 commit 2b4da8a

5 files changed

Lines changed: 42 additions & 37 deletions

File tree

example/src/components/Commerce/Commerce.tsx

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Alert, Image, Pressable, ScrollView, Text, View } from 'react-native';
2+
import { SafeAreaView } from 'react-native-safe-area-context';
23

34
import { Iterable, IterableCommerceItem } from '@iterable/react-native-sdk';
45

@@ -32,35 +33,37 @@ export const Commerce = () => {
3233
};
3334

3435
return (
35-
<ScrollView>
36-
<View style={styles.container}>
37-
<Text style={styles.title}>Commerce</Text>
38-
<Text style={styles.subtitle}>
39-
Purchase will be tracked when &quot;Buy&quot; is clicked. See logs for
40-
output.
41-
</Text>
42-
{items.map((item) => (
43-
<View key={item.id} style={styles.cardContainer}>
44-
<View style={styles.infoContainer}>
45-
<View style={styles.imageContainer}>
46-
<Image source={item.icon} style={styles.cardImage} />
47-
</View>
48-
<View style={styles.textContainer}>
49-
<Text style={styles.cardTitle}>{item.name}</Text>
50-
<Text style={styles.cardSubtitle}>{item.subtitle}</Text>
51-
<Text style={styles.price}>${item.price}</Text>
52-
<Pressable
53-
style={styles.button}
54-
onPress={() => handleClick(item)}
55-
>
56-
<Text style={styles.buttonText}>Buy</Text>
57-
</Pressable>
36+
<SafeAreaView>
37+
<ScrollView>
38+
<View style={styles.container}>
39+
<Text style={styles.title}>Commerce</Text>
40+
<Text style={styles.subtitle}>
41+
Purchase will be tracked when &quot;Buy&quot; is clicked. See logs for
42+
output.
43+
</Text>
44+
{items.map((item) => (
45+
<View key={item.id} style={styles.cardContainer}>
46+
<View style={styles.infoContainer}>
47+
<View style={styles.imageContainer}>
48+
<Image source={item.icon} style={styles.cardImage} />
49+
</View>
50+
<View style={styles.textContainer}>
51+
<Text style={styles.cardTitle}>{item.name}</Text>
52+
<Text style={styles.cardSubtitle}>{item.subtitle}</Text>
53+
<Text style={styles.price}>${item.price}</Text>
54+
<Pressable
55+
style={styles.button}
56+
onPress={() => handleClick(item)}
57+
>
58+
<Text style={styles.buttonText}>Buy</Text>
59+
</Pressable>
60+
</View>
5861
</View>
5962
</View>
60-
</View>
61-
))}
62-
</View>
63-
</ScrollView>
63+
))}
64+
</View>
65+
</ScrollView>
66+
</SafeAreaView>
6467
);
6568
};
6669

example/src/components/Embedded/Embedded.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { Text, View } from 'react-native';
21
import { Iterable } from '@iterable/react-native-sdk';
2+
import { Text } from 'react-native';
3+
import { SafeAreaView } from 'react-native-safe-area-context';
34

45
import styles from './Embedded.styles';
56

67
export const Embedded = () => {
78
return (
8-
<View style={styles.container}>
9+
<SafeAreaView style={styles.container}>
910
<Text style={styles.text}>EMBEDDED</Text>
1011
<Text style={styles.text}>
1112
Does embedded class exist? {Iterable.embeddedManager ? 'Yes' : 'No'}
@@ -14,7 +15,7 @@ export const Embedded = () => {
1415
Is embedded manager enabled?{' '}
1516
{Iterable.embeddedManager.isEnabled ? 'Yes' : 'No'}
1617
</Text>
17-
</View>
18+
</SafeAreaView>
1819
);
1920
};
2021

example/src/components/Login/Login.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import { useMemo } from 'react';
12
import {
23
ActivityIndicator,
34
Pressable,
45
Text,
56
TextInput,
67
View,
78
} from 'react-native';
8-
import { useMemo } from 'react';
9+
import { SafeAreaView } from 'react-native-safe-area-context';
910

1011
import { colors, type Route } from '../../constants';
1112
import { useIterableApp } from '../../hooks';
@@ -18,7 +19,7 @@ export const Login = ({ navigation }: RootStackScreenProps<Route.Login>) => {
1819
const loginIsEnabled = useMemo(() => apiKey && userId, [apiKey, userId]);
1920

2021
return (
21-
<View style={styles.loginScreenContainer}>
22+
<SafeAreaView style={styles.loginScreenContainer}>
2223
{loginInProgress ? (
2324
<View style={styles.loadingContainer}>
2425
<ActivityIndicator size="large" color={colors.brandPurple} />
@@ -66,7 +67,7 @@ export const Login = ({ navigation }: RootStackScreenProps<Route.Login>) => {
6667
</View>
6768
</>
6869
)}
69-
</View>
70+
</SafeAreaView>
7071
);
7172
};
7273

example/src/components/User/User.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Iterable } from '@iterable/react-native-sdk';
22
import { useEffect, useState } from 'react';
3-
import { Text, TouchableOpacity, View } from 'react-native';
3+
import { Text, TouchableOpacity } from 'react-native';
4+
import { SafeAreaView } from 'react-native-safe-area-context';
45

56
import { useIterableApp } from '../../hooks';
67
import styles from './User.styles';
@@ -18,13 +19,13 @@ export const User = () => {
1819
}, [isLoggedIn]);
1920

2021
return (
21-
<View style={styles.container}>
22+
<SafeAreaView style={styles.container}>
2223
<Text style={styles.appName}>Welcome Iterator</Text>
2324
<Text style={styles.text}>Logged in as {loggedInAs}</Text>
2425
<TouchableOpacity style={styles.button} onPress={logout}>
2526
<Text style={styles.buttonText}>Logout</Text>
2627
</TouchableOpacity>
27-
</View>
28+
</SafeAreaView>
2829
);
2930
};
3031

example/src/constants/styles/typography.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export const appName: TextStyle = {
66
fontWeight: 'bold',
77
fontSize: 14,
88
width: '100%',
9-
marginTop: 41,
109
marginBottom: 64,
1110
textTransform: 'uppercase',
1211
letterSpacing: 2,

0 commit comments

Comments
 (0)