@fadyshawky/react-native-magic 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/.vscode/settings.json +7 -0
  2. package/CHANGELOG.md +9 -0
  3. package/package.json +1 -1
  4. package/template/App.tsx +30 -9
  5. package/template/package-lock.json +170 -123
  6. package/template/package.json +1 -0
  7. package/template/src/common/ImageResources.g.ts +3 -5
  8. package/template/src/common/components/Background.tsx +66 -28
  9. package/template/src/common/components/Cards.tsx +116 -0
  10. package/template/src/common/components/Container.tsx +145 -0
  11. package/template/src/common/components/FlatListWrapper.tsx +1 -0
  12. package/template/src/common/components/ImageCropPickerButton.tsx +1 -1
  13. package/template/src/common/components/OTPInput.tsx +107 -0
  14. package/template/src/common/components/PhotoTakingButton.tsx +1 -4
  15. package/template/src/common/components/PrimaryButton.tsx +171 -157
  16. package/template/src/common/components/RTLAwareText.tsx +42 -0
  17. package/template/src/common/components/RTLAwareView.tsx +179 -0
  18. package/template/src/common/components/RadioButton.tsx +1 -3
  19. package/template/src/common/components/RadioIcon.tsx +1 -2
  20. package/template/src/common/components/SearchBar.tsx +179 -0
  21. package/template/src/common/components/Separator.tsx +7 -4
  22. package/template/src/common/components/TouchablePlatform.tsx +1 -3
  23. package/template/src/common/components/TryAgain.tsx +3 -3
  24. package/template/src/common/helpers/inAppReviewHelper.ts +0 -1
  25. package/template/src/common/helpers/stringsHelpers.ts +10 -0
  26. package/template/src/common/hooks/useFlatListActions.ts +1 -1
  27. package/template/src/common/localization/LocalizationProvider.tsx +152 -0
  28. package/template/src/common/localization/README.md +488 -0
  29. package/template/src/common/localization/localization.ts +12 -0
  30. package/template/src/common/localization/translations/homeLocalization.ts +1 -0
  31. package/template/src/common/localization/translations/profileLocalization.ts +24 -0
  32. package/template/src/common/validations/errorValidations.ts +1 -6
  33. package/template/src/common/validations/examples/TextInputWithValidation.tsx +229 -0
  34. package/template/src/common/validations/index.ts +28 -0
  35. package/template/src/common/validations/regex.js +83 -0
  36. package/template/src/common/validations/regexValidator.ts +240 -0
  37. package/template/src/common/validations/validationConstants.ts +2 -2
  38. package/template/src/core/api/errorHandler.ts +39 -0
  39. package/template/src/core/api/responseHandlers.ts +1 -26
  40. package/template/src/core/api/serverHeaders.ts +13 -23
  41. package/template/src/core/store/app/appSlice.ts +1 -2
  42. package/template/src/core/store/user/userSlice.ts +1 -0
  43. package/template/src/core/theme/ThemeProvider.tsx +63 -0
  44. package/template/src/core/theme/colors.ts +31 -42
  45. package/template/src/core/theme/commonConsts.ts +1 -1
  46. package/template/src/core/theme/commonStyles.ts +267 -210
  47. package/template/src/core/theme/fonts.ts +17 -1
  48. package/template/src/core/theme/scaling.ts +101 -0
  49. package/template/src/core/theme/themes.ts +214 -0
  50. package/template/src/core/theme/types.ts +51 -0
  51. package/template/src/navigation/AuthStack.tsx +25 -30
  52. package/template/src/navigation/HeaderComponents.tsx +18 -58
  53. package/template/src/navigation/MainNavigation.tsx +5 -6
  54. package/template/src/navigation/MainStack.tsx +6 -27
  55. package/template/src/navigation/RootNavigation.tsx +1 -7
  56. package/template/src/navigation/TabBar.tsx +2 -2
  57. package/template/src/navigation/TopTabBar.tsx +1 -1
  58. package/template/src/screens/Login/Login.tsx +3 -3
  59. package/template/src/screens/home/HomeScreen.tsx +107 -0
  60. package/template/src/screens/home/components/CarouselSection.tsx +79 -0
  61. package/template/src/screens/home/components/FeaturedCarousel.tsx +128 -0
  62. package/template/src/screens/home/hooks/useHomeData.ts +60 -0
  63. package/template/src/screens/home/types.ts +7 -0
  64. package/template/src/screens/registration/RegistrationScreen.tsx +2 -2
  65. package/template/src/screens/resetPassword/ForgotPasswordScreen.tsx +2 -2
  66. package/template/src/utils/stringBuilder.js +25 -0
@@ -0,0 +1,107 @@
1
+ import React from 'react';
2
+ import {
3
+ View,
4
+ StyleSheet,
5
+ ScrollView,
6
+ RefreshControl,
7
+ Dimensions,
8
+ Text,
9
+ } from 'react-native';
10
+ import {Colors} from '../../core/theme/colors';
11
+ import {CommonSizes} from '../../core/theme/commonSizes';
12
+ import {CommonStyles} from '../../core/theme/commonStyles';
13
+ import {CarouselSection} from './components/CarouselSection';
14
+ import {FeaturedCarousel} from './components/FeaturedCarousel';
15
+ import {useHomeData} from './hooks/useHomeData';
16
+
17
+ const {width} = Dimensions.get('window');
18
+
19
+ export function HomeScreen(): JSX.Element {
20
+ const {
21
+ featuredItems,
22
+ trendingItems,
23
+ newItems,
24
+ recommendedItems,
25
+ isLoading,
26
+ refreshData,
27
+ } = useHomeData();
28
+
29
+ return (
30
+ <ScrollView
31
+ style={styles.container}
32
+ refreshControl={
33
+ <RefreshControl refreshing={isLoading} onRefresh={refreshData} />
34
+ }>
35
+ <View style={styles.content}>
36
+ {/* Featured Section */}
37
+ <View style={styles.featuredSection}>
38
+ <Text style={styles.sectionTitle}>Featured</Text>
39
+ <FeaturedCarousel items={featuredItems} />
40
+ </View>
41
+
42
+ {/* Trending Section */}
43
+ <View style={styles.carouselSection}>
44
+ <Text style={styles.sectionTitle}>Trending Now</Text>
45
+ <CarouselSection
46
+ items={trendingItems}
47
+ imageStyle={styles.trendingImage}
48
+ />
49
+ </View>
50
+
51
+ {/* New Arrivals Section */}
52
+ <View style={styles.carouselSection}>
53
+ <Text style={styles.sectionTitle}>New Arrivals</Text>
54
+ <CarouselSection
55
+ items={newItems}
56
+ imageStyle={styles.newArrivalsImage}
57
+ />
58
+ </View>
59
+
60
+ {/* Recommended Section */}
61
+ <View style={styles.carouselSection}>
62
+ <Text style={styles.sectionTitle}>Recommended for You</Text>
63
+ <CarouselSection
64
+ items={recommendedItems}
65
+ imageStyle={styles.recommendedImage}
66
+ />
67
+ </View>
68
+ </View>
69
+ </ScrollView>
70
+ );
71
+ }
72
+
73
+ const styles = StyleSheet.create({
74
+ container: {
75
+ flex: 1,
76
+ backgroundColor: Colors.background,
77
+ },
78
+ content: {
79
+ paddingVertical: CommonSizes.spacing.medium,
80
+ },
81
+ featuredSection: {
82
+ marginBottom: CommonSizes.spacing.large,
83
+ },
84
+ carouselSection: {
85
+ marginBottom: CommonSizes.spacing.large,
86
+ },
87
+ sectionTitle: {
88
+ ...CommonStyles.h2_semiBold,
89
+ marginHorizontal: CommonSizes.spacing.large,
90
+ marginBottom: CommonSizes.spacing.medium,
91
+ },
92
+ trendingImage: {
93
+ width: width * 0.7,
94
+ height: 200,
95
+ borderRadius: CommonSizes.borderRadius.medium,
96
+ },
97
+ newArrivalsImage: {
98
+ width: width * 0.5,
99
+ height: 180,
100
+ borderRadius: CommonSizes.borderRadius.medium,
101
+ },
102
+ recommendedImage: {
103
+ width: width * 0.6,
104
+ height: 160,
105
+ borderRadius: CommonSizes.borderRadius.medium,
106
+ },
107
+ });
@@ -0,0 +1,79 @@
1
+ import React from 'react';
2
+ import {
3
+ Image,
4
+ ImageStyle,
5
+ ScrollView,
6
+ StyleSheet,
7
+ Text,
8
+ TouchableOpacity,
9
+ View,
10
+ } from 'react-native';
11
+ import {Colors} from '../../../core/theme/colors';
12
+ import {CommonSizes} from '../../../core/theme/commonSizes';
13
+ import {CarouselItem} from '../types';
14
+
15
+ interface CarouselSectionProps {
16
+ items: CarouselItem[];
17
+ imageStyle?: ImageStyle;
18
+ }
19
+
20
+ export function CarouselSection({
21
+ items,
22
+ imageStyle,
23
+ }: CarouselSectionProps): JSX.Element {
24
+ return (
25
+ <ScrollView
26
+ horizontal
27
+ showsHorizontalScrollIndicator={false}
28
+ contentContainerStyle={styles.container}>
29
+ {items.map((item, index) => (
30
+ <TouchableOpacity
31
+ key={item.id}
32
+ style={styles.itemContainer}
33
+ onPress={() => item.onPress?.(item)}>
34
+ <Image
35
+ source={{uri: item.imageUrl}}
36
+ style={[styles.image, imageStyle]}
37
+ />
38
+ <View style={styles.textContainer}>
39
+ <Text style={styles.title} numberOfLines={1}>
40
+ {item.title}
41
+ </Text>
42
+ {item.subtitle && (
43
+ <Text style={styles.subtitle} numberOfLines={1}>
44
+ {item.subtitle}
45
+ </Text>
46
+ )}
47
+ </View>
48
+ </TouchableOpacity>
49
+ ))}
50
+ </ScrollView>
51
+ );
52
+ }
53
+
54
+ const styles = StyleSheet.create({
55
+ container: {
56
+ paddingHorizontal: CommonSizes.spacing.large,
57
+ },
58
+ itemContainer: {
59
+ marginRight: CommonSizes.spacing.medium,
60
+ },
61
+ image: {
62
+ width: 200,
63
+ height: 150,
64
+ borderRadius: CommonSizes.borderRadius.medium,
65
+ },
66
+ textContainer: {
67
+ marginTop: CommonSizes.spacing.small,
68
+ },
69
+ title: {
70
+ fontSize: 16,
71
+ fontWeight: '600',
72
+ color: Colors.blueDarker,
73
+ },
74
+ subtitle: {
75
+ fontSize: 14,
76
+ color: Colors.blueDarker,
77
+ marginTop: 2,
78
+ },
79
+ });
@@ -0,0 +1,128 @@
1
+ import React, {useRef, useState} from 'react';
2
+ import {
3
+ Dimensions,
4
+ FlatList,
5
+ Image,
6
+ StyleSheet,
7
+ Text,
8
+ TouchableOpacity,
9
+ View,
10
+ } from 'react-native';
11
+ import {Colors} from '../../../core/theme/colors';
12
+ import {CommonSizes} from '../../../core/theme/commonSizes';
13
+ import {CarouselItem} from '../types';
14
+
15
+ const {width} = Dimensions.get('window');
16
+ const ITEM_WIDTH = width * 0.85;
17
+
18
+ interface FeaturedCarouselProps {
19
+ items: CarouselItem[];
20
+ }
21
+
22
+ export function FeaturedCarousel({items}: FeaturedCarouselProps): JSX.Element {
23
+ const [activeIndex, setActiveIndex] = useState(0);
24
+ const flatListRef = useRef<FlatList>(null);
25
+
26
+ const renderItem = ({item}: {item: CarouselItem}) => (
27
+ <TouchableOpacity
28
+ style={styles.itemContainer}
29
+ onPress={() => item.onPress?.(item)}>
30
+ <Image source={{uri: item.imageUrl}} style={styles.image} />
31
+ <View style={styles.overlay}>
32
+ <Text style={styles.title}>{item.title}</Text>
33
+ {item.subtitle && <Text style={styles.subtitle}>{item.subtitle}</Text>}
34
+ </View>
35
+ </TouchableOpacity>
36
+ );
37
+
38
+ const renderDot = (index: number) => (
39
+ <View
40
+ key={index}
41
+ style={[styles.dot, index === activeIndex && styles.activeDot]}
42
+ />
43
+ );
44
+
45
+ const handleScroll = (event: any) => {
46
+ const slideSize = event.nativeEvent.layoutMeasurement.width;
47
+ const index = event.nativeEvent.contentOffset.x / slideSize;
48
+ const roundIndex = Math.round(index);
49
+ setActiveIndex(roundIndex);
50
+ };
51
+
52
+ return (
53
+ <View>
54
+ <FlatList
55
+ ref={flatListRef}
56
+ data={items}
57
+ renderItem={renderItem}
58
+ horizontal
59
+ pagingEnabled
60
+ showsHorizontalScrollIndicator={false}
61
+ onScroll={handleScroll}
62
+ snapToAlignment="center"
63
+ decelerationRate="fast"
64
+ snapToInterval={ITEM_WIDTH}
65
+ contentContainerStyle={styles.listContainer}
66
+ getItemLayout={(_, index) => ({
67
+ length: ITEM_WIDTH,
68
+ offset: ITEM_WIDTH * index,
69
+ index,
70
+ })}
71
+ />
72
+ <View style={styles.pagination}>
73
+ {items.map((_, index) => renderDot(index))}
74
+ </View>
75
+ </View>
76
+ );
77
+ }
78
+
79
+ const styles = StyleSheet.create({
80
+ listContainer: {
81
+ paddingHorizontal: (width - ITEM_WIDTH) / 2,
82
+ },
83
+ itemContainer: {
84
+ width: ITEM_WIDTH,
85
+ height: 250,
86
+ },
87
+ image: {
88
+ width: '100%',
89
+ height: '100%',
90
+ borderRadius: CommonSizes.borderRadius.large,
91
+ },
92
+ overlay: {
93
+ ...StyleSheet.absoluteFillObject,
94
+ backgroundColor: 'rgba(0, 0, 0, 0.3)',
95
+ borderRadius: CommonSizes.borderRadius.large,
96
+ padding: CommonSizes.spacing.large,
97
+ justifyContent: 'flex-end',
98
+ },
99
+ title: {
100
+ fontSize: 20,
101
+ fontWeight: '600',
102
+ color: Colors.white,
103
+ },
104
+ subtitle: {
105
+ fontSize: 16,
106
+ color: Colors.white,
107
+ marginTop: CommonSizes.spacing.small,
108
+ },
109
+ pagination: {
110
+ flexDirection: 'row',
111
+ justifyContent: 'center',
112
+ alignItems: 'center',
113
+ marginTop: CommonSizes.spacing.medium,
114
+ },
115
+ dot: {
116
+ width: 8,
117
+ height: 8,
118
+ borderRadius: 4,
119
+ backgroundColor: Colors.gray,
120
+ marginHorizontal: 4,
121
+ },
122
+ activeDot: {
123
+ backgroundColor: Colors.blueDarker,
124
+ width: 12,
125
+ height: 12,
126
+ borderRadius: 6,
127
+ },
128
+ });
@@ -0,0 +1,60 @@
1
+ import {useState, useEffect} from 'react';
2
+ import {CarouselItem} from '../types';
3
+
4
+ export function useHomeData() {
5
+ const [isLoading, setIsLoading] = useState(false);
6
+ const [featuredItems, setFeaturedItems] = useState<CarouselItem[]>([]);
7
+ const [trendingItems, setTrendingItems] = useState<CarouselItem[]>([]);
8
+ const [newItems, setNewItems] = useState<CarouselItem[]>([]);
9
+ const [recommendedItems, setRecommendedItems] = useState<CarouselItem[]>([]);
10
+
11
+ const fetchData = async () => {
12
+ setIsLoading(true);
13
+ try {
14
+ // Simulate API calls
15
+ // Replace with actual API calls in production
16
+ setFeaturedItems([
17
+ {
18
+ id: '1',
19
+ title: 'Featured Item 1',
20
+ subtitle: 'Discover amazing features',
21
+ imageUrl: 'https://picsum.photos/800/400',
22
+ },
23
+ // Add more items...
24
+ ]);
25
+
26
+ setTrendingItems([
27
+ {
28
+ id: '1',
29
+ title: 'Trending Item 1',
30
+ subtitle: 'Hot right now',
31
+ imageUrl: 'https://picsum.photos/700/400',
32
+ },
33
+ // Add more items...
34
+ ]);
35
+
36
+ // Similar for newItems and recommendedItems...
37
+ } catch (error) {
38
+ console.error('Error fetching home data:', error);
39
+ } finally {
40
+ setIsLoading(false);
41
+ }
42
+ };
43
+
44
+ const refreshData = () => {
45
+ fetchData();
46
+ };
47
+
48
+ useEffect(() => {
49
+ fetchData();
50
+ }, []);
51
+
52
+ return {
53
+ isLoading,
54
+ featuredItems,
55
+ trendingItems,
56
+ newItems,
57
+ recommendedItems,
58
+ refreshData,
59
+ };
60
+ }
@@ -0,0 +1,7 @@
1
+ export interface CarouselItem {
2
+ id: string;
3
+ title: string;
4
+ subtitle?: string;
5
+ imageUrl: string;
6
+ onPress?: (item: CarouselItem) => void;
7
+ }
@@ -21,7 +21,7 @@ import {
21
21
  } from '../../common/validations/profileValidations';
22
22
  import {useAppDispatch} from '../../core/store/reduxHelpers';
23
23
  import {userRegister} from '../../core/store/user/userActions';
24
- import {Colors, NewColors} from '../../core/theme/colors';
24
+ import {Colors} from '../../core/theme/colors';
25
25
  import {CommonSizes} from '../../core/theme/commonSizes';
26
26
  import {CommonStyles} from '../../core/theme/commonStyles';
27
27
  import type {RootStackParamList} from '../../navigation/types';
@@ -191,7 +191,7 @@ const styles = StyleSheet.create({
191
191
  },
192
192
  loginLink: {
193
193
  ...CommonStyles.normalText,
194
- color: NewColors.blueNormalActive,
194
+ color: Colors.blueNormalActive,
195
195
  textAlign: 'center',
196
196
  marginTop: 16,
197
197
  },
@@ -17,7 +17,7 @@ import {useInputError} from '../../common/validations/hooks/useInputError';
17
17
  import {emailValidations} from '../../common/validations/profileValidations';
18
18
  import {useAppDispatch} from '../../core/store/reduxHelpers';
19
19
  import {resetPassword} from '../../core/store/user/userActions';
20
- import {Colors, NewColors} from '../../core/theme/colors';
20
+ import {Colors} from '../../core/theme/colors';
21
21
  import {CommonSizes} from '../../core/theme/commonSizes';
22
22
  import {CommonStyles} from '../../core/theme/commonStyles';
23
23
  import type {RootStackParamList} from '../../navigation/types';
@@ -122,7 +122,7 @@ const styles = StyleSheet.create({
122
122
  },
123
123
  loginLink: {
124
124
  ...CommonStyles.normalText,
125
- color: NewColors.blueNormalActive,
125
+ color: Colors.blueNormalActive,
126
126
  textAlign: 'center',
127
127
  marginTop: 16,
128
128
  },
@@ -0,0 +1,25 @@
1
+ // Initializes a new instance of the StringBuilder class
2
+ // and appends the given value if supplied
3
+ function StringBuilder(value) {
4
+ this.strings = new Array('');
5
+ this.append(value);
6
+ }
7
+
8
+ // Appends the given value to the end of this instance.
9
+ StringBuilder.prototype.append = function (value) {
10
+ if (value) {
11
+ this.strings.push(value);
12
+ }
13
+ };
14
+
15
+ // Clears the string buffer
16
+ StringBuilder.prototype.clear = function () {
17
+ this.strings.length = 1;
18
+ };
19
+
20
+ // Converts this instance to a String.
21
+ StringBuilder.prototype.toString = function () {
22
+ return this.strings.join('');
23
+ };
24
+
25
+ export default StringBuilder;