codingpixel-expo-app 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +112 -0
- package/bin/cli.js +9 -0
- package/dist/babel.js +198 -0
- package/dist/bootstrap.js +54 -0
- package/dist/fonts.js +98 -0
- package/dist/index.js +120 -0
- package/dist/install.js +243 -0
- package/dist/overlay.js +141 -0
- package/dist/patch.js +212 -0
- package/dist/prompts.js +115 -0
- package/dist/scaffold.js +43 -0
- package/dist/sdkNotes.js +19 -0
- package/dist/util.js +48 -0
- package/package.json +56 -0
- package/templates/base/assets/fonts/.gitkeep +0 -0
- package/templates/base/assets/images/.gitkeep +0 -0
- package/templates/base/assets/index.ts +8 -0
- package/templates/base/src/app/_layout.tsx +39 -0
- package/templates/base/src/app/index.tsx +13 -0
- package/templates/base/src/app/routes.tsx +9 -0
- package/templates/base/src/core/hooks/.gitkeep +0 -0
- package/templates/base/src/core/redux/hooks.ts +6 -0
- package/templates/base/src/core/redux/mmkvStorage.ts +18 -0
- package/templates/base/src/core/redux/reducers.ts +20 -0
- package/templates/base/src/core/redux/slices/userSlice.ts +31 -0
- package/templates/base/src/core/redux/store.ts +28 -0
- package/templates/base/src/core/services/.gitkeep +0 -0
- package/templates/base/src/core/tanstack/index.tsx +93 -0
- package/templates/base/src/core/tanstack/tanstack-keys.ts +42 -0
- package/templates/base/src/core/utils/config.ts +50 -0
- package/templates/base/src/core/utils/constants.ts +11 -0
- package/templates/base/src/core/utils/endpoints.ts +29 -0
- package/templates/base/src/core/utils/types.ts +47 -0
- package/templates/base/src/core/utils/validation.ts +10 -0
- package/templates/base/src/features/.gitkeep +0 -0
- package/templates/base/src/ui/appComponents/AppRefreshControl/index.tsx +39 -0
- package/templates/base/src/ui/appComponents/appButton/index.tsx +122 -0
- package/templates/base/src/ui/appComponents/appColumnView/index.tsx +320 -0
- package/templates/base/src/ui/appComponents/appFlashList/index.tsx +191 -0
- package/templates/base/src/ui/appComponents/appFlatList/index.tsx +172 -0
- package/templates/base/src/ui/appComponents/appIcon/index.tsx +105 -0
- package/templates/base/src/ui/appComponents/appInput/index.tsx +226 -0
- package/templates/base/src/ui/appComponents/appKeyboardAvoidingView/index.tsx +168 -0
- package/templates/base/src/ui/appComponents/appKeyboardAwareScrollView/index.tsx +188 -0
- package/templates/base/src/ui/appComponents/appLogger/index.tsx +22 -0
- package/templates/base/src/ui/appComponents/appPressable/index.tsx +220 -0
- package/templates/base/src/ui/appComponents/appRowView/index.tsx +320 -0
- package/templates/base/src/ui/appComponents/appSafeAreaInsets/index.tsx +24 -0
- package/templates/base/src/ui/appComponents/appScrollView/index.tsx +166 -0
- package/templates/base/src/ui/appComponents/appSkeleton/index.tsx +22 -0
- package/templates/base/src/ui/appComponents/appStatusBar/index.tsx +8 -0
- package/templates/base/src/ui/appComponents/appTabHeader/index.tsx +111 -0
- package/templates/base/src/ui/appComponents/appText/index.tsx +258 -0
- package/templates/base/src/ui/appComponents/appTextWrapper/index.tsx +84 -0
- package/templates/base/src/ui/appComponents/appWrapper/index.tsx +56 -0
- package/templates/base/src/ui/appComponents/customActivityIndicator/index.tsx +34 -0
- package/templates/base/src/ui/appComponents/customGetPermissionModal/index.tsx +62 -0
- package/templates/base/src/ui/appComponents/customModal/index.tsx +26 -0
- package/templates/base/src/ui/appComponents/customTextInput/index.tsx +143 -0
- package/templates/base/src/ui/components/.gitkeep +0 -0
- package/templates/base/src/ui/components/avatarBlock/index.tsx +42 -0
- package/templates/base/src/ui/components/backgroundGradient/index.tsx +24 -0
- package/templates/base/src/ui/components/errorFallback/index.tsx +40 -0
- package/templates/base/src/ui/iconComponents/IconFontAwesome6/index.tsx +22 -0
- package/templates/base/src/ui/iconComponents/IoniconsIcons/index.tsx +33 -0
- package/templates/base/src/ui/iconComponents/antDesignicons/index.tsx +22 -0
- package/templates/base/src/ui/iconComponents/featherIcons/index.tsx +22 -0
- package/templates/base/src/ui/iconComponents/materialCommunityIcons/index.tsx +24 -0
- package/templates/base/src/ui/iconComponents/materialIcons/index.tsx +23 -0
- package/templates/base/src/ui/iconComponents/octiconsIcons/index.tsx +23 -0
- package/templates/base/src/ui/theme/allFileStyles.ts +39 -0
- package/templates/base/src/ui/theme/colors.ts +54 -0
- package/templates/base/src/ui/theme/fonts.ts +3 -0
- package/templates/base/src/ui/theme/responsive.ts +27 -0
- package/templates/bottom-sheet/src/ui/appComponents/BottomSheetKeyboardAwareScrollView/index.tsx +111 -0
- package/templates/bottom-sheet/src/ui/appComponents/appBottomSheetBackdrop/index.tsx +27 -0
- package/templates/bottom-sheet/src/ui/appComponents/appBottomSheetScrollView/index.tsx +99 -0
- package/templates/bottom-sheet/src/ui/appComponents/appBottomSheetView/index.tsx +173 -0
- package/templates/bottom-sheet/src/ui/appComponents/customBottomSheetModal/index.tsx +17 -0
- package/templates/claude-command/init-app.md +41 -0
- package/templates/image-picker/media-constants.snippet.ts +18 -0
- package/templates/image-picker/src/core/services/PermissionService.ts +48 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import AppColumnView from "@appComponents/appColumnView";
|
|
2
|
+
import {
|
|
3
|
+
FlashListProps,
|
|
4
|
+
FlashListRef,
|
|
5
|
+
FlashList as ShopifyFlashList,
|
|
6
|
+
} from "@shopify/flash-list";
|
|
7
|
+
import { RF } from "@theme/responsive";
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { DimensionValue, StyleProp, ViewStyle } from "react-native";
|
|
10
|
+
|
|
11
|
+
type NumericOrDim = number | DimensionValue;
|
|
12
|
+
|
|
13
|
+
export interface AppFlashListProps<T> extends Omit<
|
|
14
|
+
FlashListProps<T>,
|
|
15
|
+
"style" | "contentContainerStyle"
|
|
16
|
+
> {
|
|
17
|
+
ref?: React.RefObject<FlashListRef<T>>;
|
|
18
|
+
flex?: number;
|
|
19
|
+
flexGrow?: number;
|
|
20
|
+
flexShrink?: number;
|
|
21
|
+
flexBasis?: NumericOrDim;
|
|
22
|
+
|
|
23
|
+
flexWrap?: ViewStyle["flexWrap"];
|
|
24
|
+
flexDirection?: ViewStyle["flexDirection"];
|
|
25
|
+
alignItems?: ViewStyle["alignItems"];
|
|
26
|
+
justifyContent?: ViewStyle["justifyContent"];
|
|
27
|
+
alignSelf?: ViewStyle["alignSelf"];
|
|
28
|
+
|
|
29
|
+
width?: NumericOrDim;
|
|
30
|
+
height?: NumericOrDim;
|
|
31
|
+
minWidth?: NumericOrDim;
|
|
32
|
+
maxWidth?: NumericOrDim;
|
|
33
|
+
minHeight?: NumericOrDim;
|
|
34
|
+
maxHeight?: NumericOrDim;
|
|
35
|
+
|
|
36
|
+
padding?: number;
|
|
37
|
+
paddingHorizontal?: number;
|
|
38
|
+
paddingVertical?: number;
|
|
39
|
+
paddingTop?: number;
|
|
40
|
+
paddingBottom?: number;
|
|
41
|
+
paddingLeft?: number;
|
|
42
|
+
paddingRight?: number;
|
|
43
|
+
gap?: number;
|
|
44
|
+
|
|
45
|
+
margin?: number;
|
|
46
|
+
marginHorizontal?: number;
|
|
47
|
+
marginVertical?: number;
|
|
48
|
+
marginTop?: number;
|
|
49
|
+
marginBottom?: number;
|
|
50
|
+
marginLeft?: number;
|
|
51
|
+
marginRight?: number;
|
|
52
|
+
|
|
53
|
+
borderRadius?: number;
|
|
54
|
+
borderWidth?: number;
|
|
55
|
+
borderColor?: string;
|
|
56
|
+
backgroundColor?: string;
|
|
57
|
+
|
|
58
|
+
position?: ViewStyle["position"];
|
|
59
|
+
top?: NumericOrDim;
|
|
60
|
+
right?: NumericOrDim;
|
|
61
|
+
bottom?: NumericOrDim;
|
|
62
|
+
left?: NumericOrDim;
|
|
63
|
+
|
|
64
|
+
style?: StyleProp<ViewStyle>;
|
|
65
|
+
contentContainerStyle?: StyleProp<ViewStyle>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const toDim = (v?: number | DimensionValue) =>
|
|
69
|
+
v === undefined
|
|
70
|
+
? undefined
|
|
71
|
+
: typeof v === "number"
|
|
72
|
+
? (RF(v) as unknown as DimensionValue)
|
|
73
|
+
: v;
|
|
74
|
+
|
|
75
|
+
function buildContainerStyle<T>(props: AppFlashListProps<T>): ViewStyle {
|
|
76
|
+
const {
|
|
77
|
+
flex,
|
|
78
|
+
flexGrow,
|
|
79
|
+
flexShrink,
|
|
80
|
+
flexBasis,
|
|
81
|
+
flexWrap,
|
|
82
|
+
flexDirection,
|
|
83
|
+
alignItems,
|
|
84
|
+
justifyContent,
|
|
85
|
+
alignSelf,
|
|
86
|
+
width,
|
|
87
|
+
height,
|
|
88
|
+
minWidth,
|
|
89
|
+
maxWidth,
|
|
90
|
+
minHeight,
|
|
91
|
+
maxHeight,
|
|
92
|
+
padding,
|
|
93
|
+
paddingHorizontal,
|
|
94
|
+
paddingVertical,
|
|
95
|
+
paddingTop,
|
|
96
|
+
paddingBottom,
|
|
97
|
+
paddingLeft,
|
|
98
|
+
paddingRight,
|
|
99
|
+
gap,
|
|
100
|
+
margin,
|
|
101
|
+
marginHorizontal,
|
|
102
|
+
marginVertical,
|
|
103
|
+
marginTop,
|
|
104
|
+
marginBottom,
|
|
105
|
+
marginLeft,
|
|
106
|
+
marginRight,
|
|
107
|
+
borderRadius,
|
|
108
|
+
borderWidth,
|
|
109
|
+
borderColor,
|
|
110
|
+
backgroundColor,
|
|
111
|
+
position,
|
|
112
|
+
top,
|
|
113
|
+
right,
|
|
114
|
+
bottom,
|
|
115
|
+
left,
|
|
116
|
+
} = props;
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
flex,
|
|
120
|
+
flexGrow,
|
|
121
|
+
flexShrink,
|
|
122
|
+
flexBasis: toDim(flexBasis),
|
|
123
|
+
flexWrap,
|
|
124
|
+
flexDirection,
|
|
125
|
+
alignItems,
|
|
126
|
+
justifyContent,
|
|
127
|
+
alignSelf,
|
|
128
|
+
|
|
129
|
+
width: toDim(width),
|
|
130
|
+
height: toDim(height),
|
|
131
|
+
minWidth: toDim(minWidth),
|
|
132
|
+
maxWidth: toDim(maxWidth),
|
|
133
|
+
minHeight: toDim(minHeight),
|
|
134
|
+
maxHeight: toDim(maxHeight),
|
|
135
|
+
|
|
136
|
+
padding: padding !== undefined ? RF(padding) : undefined,
|
|
137
|
+
paddingHorizontal:
|
|
138
|
+
paddingHorizontal !== undefined ? RF(paddingHorizontal) : undefined,
|
|
139
|
+
paddingVertical:
|
|
140
|
+
paddingVertical !== undefined ? RF(paddingVertical) : undefined,
|
|
141
|
+
paddingTop: paddingTop !== undefined ? RF(paddingTop) : undefined,
|
|
142
|
+
paddingBottom: paddingBottom !== undefined ? RF(paddingBottom) : undefined,
|
|
143
|
+
paddingLeft: paddingLeft !== undefined ? RF(paddingLeft) : undefined,
|
|
144
|
+
paddingRight: paddingRight !== undefined ? RF(paddingRight) : undefined,
|
|
145
|
+
|
|
146
|
+
gap: gap !== undefined ? RF(gap) : undefined,
|
|
147
|
+
|
|
148
|
+
margin: margin !== undefined ? RF(margin) : undefined,
|
|
149
|
+
marginHorizontal:
|
|
150
|
+
marginHorizontal !== undefined ? RF(marginHorizontal) : undefined,
|
|
151
|
+
marginVertical:
|
|
152
|
+
marginVertical !== undefined ? RF(marginVertical) : undefined,
|
|
153
|
+
marginTop: marginTop !== undefined ? RF(marginTop) : undefined,
|
|
154
|
+
marginBottom: marginBottom !== undefined ? RF(marginBottom) : undefined,
|
|
155
|
+
marginLeft: marginLeft !== undefined ? RF(marginLeft) : undefined,
|
|
156
|
+
marginRight: marginRight !== undefined ? RF(marginRight) : undefined,
|
|
157
|
+
|
|
158
|
+
borderRadius: borderRadius !== undefined ? RF(borderRadius) : undefined,
|
|
159
|
+
borderWidth: borderWidth !== undefined ? RF(borderWidth) : undefined,
|
|
160
|
+
borderColor,
|
|
161
|
+
backgroundColor,
|
|
162
|
+
|
|
163
|
+
position,
|
|
164
|
+
top: toDim(top),
|
|
165
|
+
right: toDim(right),
|
|
166
|
+
bottom: toDim(bottom),
|
|
167
|
+
left: toDim(left),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export default function AppFlashList<T>(props: AppFlashListProps<T>) {
|
|
172
|
+
const { ref, style, contentContainerStyle, gap, children, ...rest } = props;
|
|
173
|
+
|
|
174
|
+
const containerStyle = buildContainerStyle(props);
|
|
175
|
+
|
|
176
|
+
const separator =
|
|
177
|
+
gap !== undefined
|
|
178
|
+
? () => <AppColumnView height={gap} />
|
|
179
|
+
: undefined;
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<ShopifyFlashList
|
|
183
|
+
ref={ref}
|
|
184
|
+
{...(rest as FlashListProps<T>)}
|
|
185
|
+
ItemSeparatorComponent={rest.ItemSeparatorComponent ?? separator}
|
|
186
|
+
contentContainerStyle={[containerStyle, contentContainerStyle]}
|
|
187
|
+
>
|
|
188
|
+
{children}
|
|
189
|
+
</ShopifyFlashList>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { RF } from "@theme/responsive";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import {
|
|
4
|
+
DimensionValue,
|
|
5
|
+
FlatList,
|
|
6
|
+
FlatListProps,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
ViewStyle,
|
|
9
|
+
} from "react-native";
|
|
10
|
+
|
|
11
|
+
const toDim = (v?: number | DimensionValue) =>
|
|
12
|
+
v === undefined
|
|
13
|
+
? undefined
|
|
14
|
+
: typeof v === "number"
|
|
15
|
+
? (RF(v) as DimensionValue)
|
|
16
|
+
: v;
|
|
17
|
+
|
|
18
|
+
interface AppFlatListProps<ItemT> extends FlatListProps<ItemT> {
|
|
19
|
+
margin?: number;
|
|
20
|
+
marginTop?: number;
|
|
21
|
+
marginBottom?: number;
|
|
22
|
+
marginLeft?: number;
|
|
23
|
+
marginRight?: number;
|
|
24
|
+
marginHorizontal?: number;
|
|
25
|
+
marginVertical?: number;
|
|
26
|
+
padding?: number;
|
|
27
|
+
paddingTop?: number;
|
|
28
|
+
paddingBottom?: number;
|
|
29
|
+
paddingLeft?: number;
|
|
30
|
+
paddingRight?: number;
|
|
31
|
+
paddingHorizontal?: number;
|
|
32
|
+
paddingVertical?: number;
|
|
33
|
+
|
|
34
|
+
gap?: number;
|
|
35
|
+
|
|
36
|
+
flex?: number;
|
|
37
|
+
flexGrow?: number;
|
|
38
|
+
flexShrink?: number;
|
|
39
|
+
flexBasis?: number | DimensionValue;
|
|
40
|
+
flexWrap?: ViewStyle["flexWrap"];
|
|
41
|
+
alignItems?: ViewStyle["alignItems"];
|
|
42
|
+
alignSelf?: ViewStyle["alignSelf"];
|
|
43
|
+
justifyContent?: ViewStyle["justifyContent"];
|
|
44
|
+
alignContent?: ViewStyle["alignContent"];
|
|
45
|
+
flexDirection?: ViewStyle["flexDirection"];
|
|
46
|
+
|
|
47
|
+
width?: number | DimensionValue;
|
|
48
|
+
height?: number | DimensionValue;
|
|
49
|
+
minWidth?: number | DimensionValue;
|
|
50
|
+
maxWidth?: number | DimensionValue;
|
|
51
|
+
minHeight?: number | DimensionValue;
|
|
52
|
+
maxHeight?: number | DimensionValue;
|
|
53
|
+
|
|
54
|
+
borderRadius?: number;
|
|
55
|
+
borderWidth?: number;
|
|
56
|
+
borderColor?: string;
|
|
57
|
+
|
|
58
|
+
position?: ViewStyle["position"];
|
|
59
|
+
top?: number | DimensionValue;
|
|
60
|
+
bottom?: number | DimensionValue;
|
|
61
|
+
left?: number | DimensionValue;
|
|
62
|
+
right?: number | DimensionValue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function AppFlatList<ItemT = any>(props: AppFlatListProps<ItemT>) {
|
|
66
|
+
const {
|
|
67
|
+
style,
|
|
68
|
+
contentContainerStyle,
|
|
69
|
+
horizontal,
|
|
70
|
+
margin,
|
|
71
|
+
marginTop,
|
|
72
|
+
marginBottom,
|
|
73
|
+
marginLeft,
|
|
74
|
+
marginRight,
|
|
75
|
+
marginHorizontal,
|
|
76
|
+
marginVertical,
|
|
77
|
+
padding,
|
|
78
|
+
paddingTop,
|
|
79
|
+
paddingBottom,
|
|
80
|
+
paddingLeft,
|
|
81
|
+
paddingRight,
|
|
82
|
+
paddingHorizontal,
|
|
83
|
+
paddingVertical,
|
|
84
|
+
gap,
|
|
85
|
+
flex,
|
|
86
|
+
flexGrow,
|
|
87
|
+
flexShrink,
|
|
88
|
+
flexBasis,
|
|
89
|
+
flexWrap,
|
|
90
|
+
alignItems,
|
|
91
|
+
alignSelf,
|
|
92
|
+
justifyContent,
|
|
93
|
+
alignContent,
|
|
94
|
+
flexDirection,
|
|
95
|
+
width,
|
|
96
|
+
height,
|
|
97
|
+
minWidth,
|
|
98
|
+
maxWidth,
|
|
99
|
+
minHeight,
|
|
100
|
+
maxHeight,
|
|
101
|
+
borderRadius,
|
|
102
|
+
borderWidth,
|
|
103
|
+
borderColor,
|
|
104
|
+
position,
|
|
105
|
+
top,
|
|
106
|
+
bottom,
|
|
107
|
+
left,
|
|
108
|
+
right,
|
|
109
|
+
...rest
|
|
110
|
+
} = props;
|
|
111
|
+
|
|
112
|
+
const resolvedContentStyle: ViewStyle = {
|
|
113
|
+
margin: margin ? RF(margin) : undefined,
|
|
114
|
+
marginTop: marginTop ? RF(marginTop) : undefined,
|
|
115
|
+
marginBottom: marginBottom ? RF(marginBottom) : undefined,
|
|
116
|
+
marginLeft: marginLeft ? RF(marginLeft) : undefined,
|
|
117
|
+
marginRight: marginRight ? RF(marginRight) : undefined,
|
|
118
|
+
marginHorizontal: marginHorizontal ? RF(marginHorizontal) : undefined,
|
|
119
|
+
marginVertical: marginVertical ? RF(marginVertical) : undefined,
|
|
120
|
+
|
|
121
|
+
padding: padding ? RF(padding) : undefined,
|
|
122
|
+
paddingTop: paddingTop ? RF(paddingTop) : undefined,
|
|
123
|
+
paddingBottom: paddingBottom ? RF(paddingBottom) : undefined,
|
|
124
|
+
paddingLeft: paddingLeft ? RF(paddingLeft) : undefined,
|
|
125
|
+
paddingRight: paddingRight ? RF(paddingRight) : undefined,
|
|
126
|
+
paddingHorizontal: paddingHorizontal ? RF(paddingHorizontal) : undefined,
|
|
127
|
+
paddingVertical: paddingVertical ? RF(paddingVertical) : undefined,
|
|
128
|
+
gap: gap ? RF(gap) : undefined,
|
|
129
|
+
|
|
130
|
+
flex,
|
|
131
|
+
flexGrow,
|
|
132
|
+
flexShrink,
|
|
133
|
+
flexBasis: toDim(flexBasis),
|
|
134
|
+
flexWrap,
|
|
135
|
+
alignItems,
|
|
136
|
+
alignSelf,
|
|
137
|
+
justifyContent,
|
|
138
|
+
alignContent,
|
|
139
|
+
flexDirection: flexDirection || (horizontal ? "row" : "column"),
|
|
140
|
+
|
|
141
|
+
width: toDim(width),
|
|
142
|
+
height: toDim(height),
|
|
143
|
+
minWidth: toDim(minWidth),
|
|
144
|
+
maxWidth: toDim(maxWidth),
|
|
145
|
+
minHeight: toDim(minHeight),
|
|
146
|
+
maxHeight: toDim(maxHeight),
|
|
147
|
+
|
|
148
|
+
borderRadius: borderRadius ? RF(borderRadius) : undefined,
|
|
149
|
+
borderWidth: borderWidth ? RF(borderWidth) : undefined,
|
|
150
|
+
borderColor,
|
|
151
|
+
|
|
152
|
+
position,
|
|
153
|
+
top: toDim(top),
|
|
154
|
+
bottom: toDim(bottom),
|
|
155
|
+
left: toDim(left),
|
|
156
|
+
right: toDim(right),
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<FlatList
|
|
161
|
+
{...rest}
|
|
162
|
+
horizontal={horizontal}
|
|
163
|
+
style={style}
|
|
164
|
+
contentContainerStyle={StyleSheet.flatten([
|
|
165
|
+
resolvedContentStyle,
|
|
166
|
+
contentContainerStyle,
|
|
167
|
+
])}
|
|
168
|
+
/>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export default AppFlatList;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { RF } from "@theme/responsive";
|
|
2
|
+
import { Image, ImageContentFit, ImageLoadEventData } from "expo-image";
|
|
3
|
+
import React, { useState } from "react";
|
|
4
|
+
import {
|
|
5
|
+
ActivityIndicator,
|
|
6
|
+
DimensionValue,
|
|
7
|
+
ImageStyle,
|
|
8
|
+
StyleProp,
|
|
9
|
+
ViewStyle,
|
|
10
|
+
} from "react-native";
|
|
11
|
+
import AppColumnView from "../appColumnView";
|
|
12
|
+
import AppPressable from "../appPressable";
|
|
13
|
+
|
|
14
|
+
const IMAGE_FILL_STYLE = { width: "100%" as const, height: "100%" as const };
|
|
15
|
+
|
|
16
|
+
interface AppIconProps extends Omit<
|
|
17
|
+
Partial<React.ComponentProps<typeof AppPressable>>,
|
|
18
|
+
"path"
|
|
19
|
+
> {
|
|
20
|
+
path?: string | number;
|
|
21
|
+
uri?: string;
|
|
22
|
+
resizeMode?: ImageContentFit;
|
|
23
|
+
customStyle?: StyleProp<ImageStyle>;
|
|
24
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
25
|
+
tintColor?: string;
|
|
26
|
+
loader?: React.ReactNode;
|
|
27
|
+
activityIndicatorColor?: string;
|
|
28
|
+
width?: number | DimensionValue;
|
|
29
|
+
height?: number | DimensionValue;
|
|
30
|
+
size?: number;
|
|
31
|
+
borderRadius?: number;
|
|
32
|
+
onLoad?: (e: ImageLoadEventData) => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const AppIcon: React.FC<AppIconProps> = ({
|
|
36
|
+
path,
|
|
37
|
+
uri,
|
|
38
|
+
resizeMode = "cover",
|
|
39
|
+
customStyle,
|
|
40
|
+
containerStyle,
|
|
41
|
+
tintColor,
|
|
42
|
+
loader,
|
|
43
|
+
activityIndicatorColor = "#999",
|
|
44
|
+
width = 24,
|
|
45
|
+
height = 24,
|
|
46
|
+
size,
|
|
47
|
+
borderRadius,
|
|
48
|
+
onPress,
|
|
49
|
+
onLoad,
|
|
50
|
+
...pressableProps
|
|
51
|
+
}) => {
|
|
52
|
+
const toDim = (v?: number | DimensionValue) =>
|
|
53
|
+
v === undefined
|
|
54
|
+
? undefined
|
|
55
|
+
: typeof v === "number"
|
|
56
|
+
? (RF(v) as unknown as DimensionValue)
|
|
57
|
+
: v;
|
|
58
|
+
const [loading, setLoading] = useState<boolean>(false);
|
|
59
|
+
const source = uri ? { uri } : path;
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<AppPressable
|
|
63
|
+
disabled={!onPress}
|
|
64
|
+
onPress={onPress}
|
|
65
|
+
width={size ? RF(size) : toDim(width)}
|
|
66
|
+
height={size ? RF(size) : toDim(height)}
|
|
67
|
+
borderRadius={
|
|
68
|
+
size ? RF(size / 2) : borderRadius ? RF(borderRadius) : undefined
|
|
69
|
+
}
|
|
70
|
+
style={containerStyle}
|
|
71
|
+
overflow="hidden"
|
|
72
|
+
{...pressableProps}
|
|
73
|
+
>
|
|
74
|
+
<Image
|
|
75
|
+
source={source}
|
|
76
|
+
contentFit={resizeMode}
|
|
77
|
+
style={[IMAGE_FILL_STYLE, customStyle]}
|
|
78
|
+
tintColor={tintColor}
|
|
79
|
+
onLoadStart={() => setLoading(true)}
|
|
80
|
+
onLoadEnd={() => setLoading(false)}
|
|
81
|
+
onLoad={onLoad}
|
|
82
|
+
/>
|
|
83
|
+
|
|
84
|
+
{loading && (
|
|
85
|
+
<AppColumnView
|
|
86
|
+
position="absolute"
|
|
87
|
+
top={0}
|
|
88
|
+
left={0}
|
|
89
|
+
width="100%"
|
|
90
|
+
height="100%"
|
|
91
|
+
justifyContent="center"
|
|
92
|
+
alignItems="center"
|
|
93
|
+
>
|
|
94
|
+
{loader ? (
|
|
95
|
+
loader
|
|
96
|
+
) : (
|
|
97
|
+
<ActivityIndicator size="small" color={activityIndicatorColor} />
|
|
98
|
+
)}
|
|
99
|
+
</AppColumnView>
|
|
100
|
+
)}
|
|
101
|
+
</AppPressable>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export default AppIcon;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { Colors } from "@theme/colors";
|
|
2
|
+
import { Fonts } from "@theme/fonts";
|
|
3
|
+
import { RF } from "@theme/responsive";
|
|
4
|
+
|
|
5
|
+
import { ANDROID } from "@utils/constants";
|
|
6
|
+
import React, { forwardRef, useState } from "react";
|
|
7
|
+
import { Platform, StyleSheet, TextInputProps, ViewStyle } from "react-native";
|
|
8
|
+
import AppColumnView from "../appColumnView";
|
|
9
|
+
import AppPressable from "../appPressable";
|
|
10
|
+
import AppRowView from "../appRowView";
|
|
11
|
+
import AppText from "../appText";
|
|
12
|
+
import CustomTextInput from "../customTextInput";
|
|
13
|
+
|
|
14
|
+
interface InputProp extends TextInputProps {
|
|
15
|
+
title: any;
|
|
16
|
+
visible?: any;
|
|
17
|
+
titleColor: string;
|
|
18
|
+
containerStyle: ViewStyle;
|
|
19
|
+
HeadingTitle: string;
|
|
20
|
+
titleSize: number;
|
|
21
|
+
leftIcon?: React.ReactNode;
|
|
22
|
+
rightIcon?: React.ReactNode;
|
|
23
|
+
inputProps: TextInputProps;
|
|
24
|
+
error: any;
|
|
25
|
+
errorStyle: any;
|
|
26
|
+
showPassword: boolean;
|
|
27
|
+
toggleShowPassword: () => void;
|
|
28
|
+
key: any;
|
|
29
|
+
iconColor: string;
|
|
30
|
+
required: boolean;
|
|
31
|
+
onRightPress: () => void;
|
|
32
|
+
setKeyPress: (key: string) => void;
|
|
33
|
+
disableContainerPress: boolean;
|
|
34
|
+
mainContainerStyle: any;
|
|
35
|
+
inputStyle: any;
|
|
36
|
+
tintColor: any;
|
|
37
|
+
charLimit: number;
|
|
38
|
+
value: any;
|
|
39
|
+
displayError: boolean;
|
|
40
|
+
placeHolderColor?: string;
|
|
41
|
+
inputType?: string;
|
|
42
|
+
keyboardNumberic?: boolean;
|
|
43
|
+
isFocused?: boolean;
|
|
44
|
+
setValue?: any;
|
|
45
|
+
cancelIcon?: any;
|
|
46
|
+
scrollEnabled?: boolean;
|
|
47
|
+
titleConStyle?: ViewStyle | any;
|
|
48
|
+
titleFontFamily?: string;
|
|
49
|
+
backgroundColor?: string;
|
|
50
|
+
borderColor?: string;
|
|
51
|
+
borderWidth?: number;
|
|
52
|
+
inputColor?: string;
|
|
53
|
+
borderRadius?: number;
|
|
54
|
+
disabled?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const AppInput = forwardRef((props: Partial<InputProp>, ref: any) => {
|
|
58
|
+
const {
|
|
59
|
+
titleSize = 15,
|
|
60
|
+
title,
|
|
61
|
+
titleColor = Colors.BLACK,
|
|
62
|
+
leftIcon,
|
|
63
|
+
rightIcon,
|
|
64
|
+
error,
|
|
65
|
+
containerStyle,
|
|
66
|
+
errorStyle,
|
|
67
|
+
showPassword,
|
|
68
|
+
value,
|
|
69
|
+
toggleShowPassword,
|
|
70
|
+
iconColor,
|
|
71
|
+
key,
|
|
72
|
+
required,
|
|
73
|
+
onRightPress,
|
|
74
|
+
inputType,
|
|
75
|
+
multiline,
|
|
76
|
+
setKeyPress,
|
|
77
|
+
editable = true,
|
|
78
|
+
disableContainerPress,
|
|
79
|
+
mainContainerStyle,
|
|
80
|
+
inputStyle,
|
|
81
|
+
tintColor,
|
|
82
|
+
visible = true,
|
|
83
|
+
charLimit,
|
|
84
|
+
displayError = true,
|
|
85
|
+
placeHolderColor = Colors.GRAY_4,
|
|
86
|
+
keyboardNumberic = false,
|
|
87
|
+
setValue = () => {},
|
|
88
|
+
cancelIcon,
|
|
89
|
+
scrollEnabled = false,
|
|
90
|
+
titleConStyle,
|
|
91
|
+
titleFontFamily = Fonts.MEDIUM,
|
|
92
|
+
backgroundColor,
|
|
93
|
+
borderColor,
|
|
94
|
+
borderWidth,
|
|
95
|
+
inputColor,
|
|
96
|
+
borderRadius,
|
|
97
|
+
disabled,
|
|
98
|
+
...restProps
|
|
99
|
+
} = props;
|
|
100
|
+
const labelSize = 15;
|
|
101
|
+
const [isFocus, setIsFocus] = useState(false);
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
visible && (
|
|
105
|
+
<AppColumnView marginBottom={12} style={mainContainerStyle}>
|
|
106
|
+
<AppRowView justifyContent="space-between" style={titleConStyle}>
|
|
107
|
+
{!!title && (
|
|
108
|
+
<AppText
|
|
109
|
+
fontFamily={titleFontFamily}
|
|
110
|
+
size={titleSize}
|
|
111
|
+
color={!editable ? Colors.GRAY_5 : titleColor}
|
|
112
|
+
marginBottom={8}
|
|
113
|
+
>
|
|
114
|
+
{title}
|
|
115
|
+
<AppText
|
|
116
|
+
size={titleSize}
|
|
117
|
+
color={required && !editable ? Colors.ERROR : Colors.ERROR}
|
|
118
|
+
fontFamily={titleFontFamily}
|
|
119
|
+
>
|
|
120
|
+
{required ? " *" : ""}
|
|
121
|
+
</AppText>
|
|
122
|
+
</AppText>
|
|
123
|
+
)}
|
|
124
|
+
{!!charLimit && (
|
|
125
|
+
<AppText size={labelSize}>
|
|
126
|
+
{value?.length > 0 && value.length}
|
|
127
|
+
<AppText size={labelSize} color={Colors.GRAY_3} marginBottom={8}>
|
|
128
|
+
{value?.length > 0 && "/"}
|
|
129
|
+
{charLimit}
|
|
130
|
+
</AppText>
|
|
131
|
+
</AppText>
|
|
132
|
+
)}
|
|
133
|
+
</AppRowView>
|
|
134
|
+
<AppPressable
|
|
135
|
+
flexDirection="row"
|
|
136
|
+
alignItems="center"
|
|
137
|
+
paddingHorizontal={ANDROID ? 16 : 18}
|
|
138
|
+
padding={ANDROID ? 6 : 12}
|
|
139
|
+
backgroundColor={
|
|
140
|
+
disabled ? Colors.GRAY_1 : (backgroundColor ?? Colors.WHITE)
|
|
141
|
+
}
|
|
142
|
+
borderRadius={borderRadius ?? 8}
|
|
143
|
+
borderWidth={borderWidth ?? 1}
|
|
144
|
+
borderColor={
|
|
145
|
+
borderColor ? borderColor : isFocus ? Colors.PRIMARY : Colors.GRAY_2
|
|
146
|
+
}
|
|
147
|
+
style={[containerStyle, multiline && styles.flexStart]}
|
|
148
|
+
disabled={disableContainerPress}
|
|
149
|
+
onPress={onRightPress}
|
|
150
|
+
>
|
|
151
|
+
{leftIcon && (
|
|
152
|
+
<AppColumnView marginRight={12}>{leftIcon}</AppColumnView>
|
|
153
|
+
)}
|
|
154
|
+
<CustomTextInput
|
|
155
|
+
ref={ref}
|
|
156
|
+
value={value}
|
|
157
|
+
maxLength={charLimit || props.maxLength}
|
|
158
|
+
pointerEvents={editable ? "auto" : "none"}
|
|
159
|
+
textContentType="oneTimeCode"
|
|
160
|
+
keyboardType={keyboardNumberic ? "number-pad" : "default"}
|
|
161
|
+
flex={1}
|
|
162
|
+
paddingRight={14}
|
|
163
|
+
fontFamily={Fonts.MEDIUM}
|
|
164
|
+
color={inputColor ?? Colors.GRAY_10}
|
|
165
|
+
fontSize={14}
|
|
166
|
+
paddingVertical={ANDROID ? 0 : 4}
|
|
167
|
+
style={[
|
|
168
|
+
multiline && styles.multiline,
|
|
169
|
+
multiline && {
|
|
170
|
+
textAlignVertical: "top",
|
|
171
|
+
paddingTop: Platform.OS === "ios" ? 0 : 0,
|
|
172
|
+
},
|
|
173
|
+
inputStyle,
|
|
174
|
+
]}
|
|
175
|
+
placeholderTextColor={placeHolderColor}
|
|
176
|
+
onKeyPress={(e) => setKeyPress && setKeyPress(e.nativeEvent.key)}
|
|
177
|
+
autoCorrect={false}
|
|
178
|
+
scrollEnabled={!multiline || scrollEnabled}
|
|
179
|
+
onFocus={() => setIsFocus(true)}
|
|
180
|
+
onBlur={() => setIsFocus(false)}
|
|
181
|
+
multiline={multiline}
|
|
182
|
+
{...restProps}
|
|
183
|
+
/>
|
|
184
|
+
|
|
185
|
+
{!!rightIcon && (
|
|
186
|
+
<AppColumnView marginLeft={12}>{rightIcon}</AppColumnView>
|
|
187
|
+
)}
|
|
188
|
+
</AppPressable>
|
|
189
|
+
{!!error && displayError && (
|
|
190
|
+
<AppText
|
|
191
|
+
italic
|
|
192
|
+
color={Colors.ERROR}
|
|
193
|
+
size={12}
|
|
194
|
+
marginTop={8}
|
|
195
|
+
fontFamily={Fonts.MEDIUM}
|
|
196
|
+
style={errorStyle}
|
|
197
|
+
>
|
|
198
|
+
{error}
|
|
199
|
+
</AppText>
|
|
200
|
+
)}
|
|
201
|
+
</AppColumnView>
|
|
202
|
+
)
|
|
203
|
+
);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
const styles = StyleSheet.create({
|
|
207
|
+
multiline: {
|
|
208
|
+
textAlignVertical: "top",
|
|
209
|
+
height: RF(80),
|
|
210
|
+
lineHeight: RF(19),
|
|
211
|
+
...(Platform.OS === "ios" && {
|
|
212
|
+
paddingTop: 0,
|
|
213
|
+
paddingBottom: 0,
|
|
214
|
+
}),
|
|
215
|
+
},
|
|
216
|
+
flexStart: {
|
|
217
|
+
alignItems: "flex-start",
|
|
218
|
+
borderRadius: RF(12),
|
|
219
|
+
...(Platform.OS === "ios" && {
|
|
220
|
+
paddingTop: 12,
|
|
221
|
+
paddingBottom: 12,
|
|
222
|
+
}),
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
export default AppInput;
|