@core_super_app/ui 0.0.1

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 (64) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +37 -0
  3. package/Ui.podspec +20 -0
  4. package/android/build.gradle +67 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/com/core/ui/UiModule.kt +15 -0
  7. package/android/src/main/java/com/core/ui/UiPackage.kt +31 -0
  8. package/ios/Ui.h +5 -0
  9. package/ios/Ui.mm +21 -0
  10. package/lib/module/assets/images/icons/remove.png +0 -0
  11. package/lib/module/components/BaseView.js +45 -0
  12. package/lib/module/components/BaseView.js.map +1 -0
  13. package/lib/module/components/BasicButton.js +57 -0
  14. package/lib/module/components/BasicButton.js.map +1 -0
  15. package/lib/module/components/Header.js +140 -0
  16. package/lib/module/components/Header.js.map +1 -0
  17. package/lib/module/components/LoadingOverlay.js +32 -0
  18. package/lib/module/components/LoadingOverlay.js.map +1 -0
  19. package/lib/module/components/TextWrapper.js +34 -0
  20. package/lib/module/components/TextWrapper.js.map +1 -0
  21. package/lib/module/components/index.js +9 -0
  22. package/lib/module/components/index.js.map +1 -0
  23. package/lib/module/components/input/BasicInput.js +237 -0
  24. package/lib/module/components/input/BasicInput.js.map +1 -0
  25. package/lib/module/components/input/index.js +4 -0
  26. package/lib/module/components/input/index.js.map +1 -0
  27. package/lib/module/constants/image.js +6 -0
  28. package/lib/module/constants/image.js.map +1 -0
  29. package/lib/module/index.js +5 -0
  30. package/lib/module/index.js.map +1 -0
  31. package/lib/module/package.json +1 -0
  32. package/lib/typescript/package.json +1 -0
  33. package/lib/typescript/src/components/BaseView.d.ts +11 -0
  34. package/lib/typescript/src/components/BaseView.d.ts.map +1 -0
  35. package/lib/typescript/src/components/BasicButton.d.ts +16 -0
  36. package/lib/typescript/src/components/BasicButton.d.ts.map +1 -0
  37. package/lib/typescript/src/components/Header.d.ts +18 -0
  38. package/lib/typescript/src/components/Header.d.ts.map +1 -0
  39. package/lib/typescript/src/components/LoadingOverlay.d.ts +7 -0
  40. package/lib/typescript/src/components/LoadingOverlay.d.ts.map +1 -0
  41. package/lib/typescript/src/components/TextWrapper.d.ts +14 -0
  42. package/lib/typescript/src/components/TextWrapper.d.ts.map +1 -0
  43. package/lib/typescript/src/components/index.d.ts +7 -0
  44. package/lib/typescript/src/components/index.d.ts.map +1 -0
  45. package/lib/typescript/src/components/input/BasicInput.d.ts +49 -0
  46. package/lib/typescript/src/components/input/BasicInput.d.ts.map +1 -0
  47. package/lib/typescript/src/components/input/index.d.ts +2 -0
  48. package/lib/typescript/src/components/input/index.d.ts.map +1 -0
  49. package/lib/typescript/src/constants/image.d.ts +3 -0
  50. package/lib/typescript/src/constants/image.d.ts.map +1 -0
  51. package/lib/typescript/src/index.d.ts +3 -0
  52. package/lib/typescript/src/index.d.ts.map +1 -0
  53. package/package.json +170 -0
  54. package/src/assets/images/icons/remove.png +0 -0
  55. package/src/components/BaseView.tsx +56 -0
  56. package/src/components/BasicButton.tsx +70 -0
  57. package/src/components/Header.tsx +171 -0
  58. package/src/components/LoadingOverlay.tsx +32 -0
  59. package/src/components/TextWrapper.tsx +49 -0
  60. package/src/components/index.ts +6 -0
  61. package/src/components/input/BasicInput.tsx +360 -0
  62. package/src/components/input/index.ts +1 -0
  63. package/src/constants/image.ts +5 -0
  64. package/src/index.tsx +2 -0
@@ -0,0 +1,56 @@
1
+ import {
2
+ ImageBackground,
3
+ KeyboardAvoidingView,
4
+ StyleSheet,
5
+ View,
6
+ } from 'react-native';
7
+ import LoadingOverlay from './LoadingOverlay';
8
+ import Header from './Header';
9
+ import type { HeaderProps } from './Header';
10
+ import type { LoadingOverlayProps } from './LoadingOverlay';
11
+ import type { ImageSourcePropType } from 'react-native';
12
+ import type { ReactNode } from 'react';
13
+
14
+ type BaseViewProps = {
15
+ background?: ImageSourcePropType;
16
+ children: ReactNode;
17
+ } & HeaderProps &
18
+ LoadingOverlayProps;
19
+
20
+ const BaseView = (props: BaseViewProps) => {
21
+ const { background, children } = props;
22
+
23
+ if (background) {
24
+ return (
25
+ <ImageBackground
26
+ style={styles.container}
27
+ source={background}
28
+ resizeMode="cover"
29
+ >
30
+ <LoadingOverlay {...props} />
31
+ <Header {...props} />
32
+ <KeyboardAvoidingView style={styles.container}>
33
+ {children}
34
+ </KeyboardAvoidingView>
35
+ </ImageBackground>
36
+ );
37
+ }
38
+
39
+ return (
40
+ <View style={styles.container}>
41
+ <LoadingOverlay {...props} />
42
+ <Header {...props} />
43
+ <KeyboardAvoidingView style={styles.container}>
44
+ {children}
45
+ </KeyboardAvoidingView>
46
+ </View>
47
+ );
48
+ };
49
+
50
+ export default BaseView;
51
+
52
+ const styles = StyleSheet.create({
53
+ container: {
54
+ flex: 1,
55
+ },
56
+ });
@@ -0,0 +1,70 @@
1
+ import {
2
+ TouchableOpacity,
3
+ StyleSheet,
4
+ type ViewStyle,
5
+ type TextStyle,
6
+ } from 'react-native';
7
+ import LinearGradient from 'react-native-linear-gradient';
8
+ import TextWrapper, { type TextWrapperProps } from './TextWrapper';
9
+ import type { ReactNode } from 'react';
10
+ import type { StyleProp } from 'react-native'
11
+ import { scaleFont } from '@core_super_app/utils/dimension';
12
+
13
+ type Props = {
14
+ children?: ReactNode;
15
+ onPress: () => void;
16
+ disabled?: boolean;
17
+ loading?: boolean;
18
+ colors?: string[];
19
+ style?: StyleProp<ViewStyle>;
20
+ textStyle?: StyleProp<TextStyle>;
21
+ } & TextWrapperProps;
22
+
23
+ const BasicButton = ({
24
+ children,
25
+ onPress,
26
+ disabled = false,
27
+ colors = ['#A18CD1', '#7B5CFF', '#5A3DFF'],
28
+ style,
29
+ textStyle,
30
+ }: Props) => {
31
+ return (
32
+ <TouchableOpacity
33
+ activeOpacity={0.6}
34
+ onPress={onPress}
35
+ disabled={disabled}
36
+ style={[styles.container, style]}
37
+ >
38
+ <LinearGradient
39
+ colors={disabled ? ['#ccc', '#ccc'] : colors}
40
+ start={{ x: 0, y: 0 }}
41
+ end={{ x: 1, y: 1 }}
42
+ style={styles.gradient}
43
+ >
44
+ <TextWrapper style={[styles.text, textStyle]}>
45
+ {children}
46
+ </TextWrapper>
47
+ </LinearGradient>
48
+ </TouchableOpacity>
49
+ );
50
+ };
51
+
52
+ export default BasicButton;
53
+
54
+ const styles = StyleSheet.create({
55
+ container: {
56
+ width: '100%',
57
+ borderRadius: 12,
58
+ overflow: 'hidden',
59
+ },
60
+ gradient: {
61
+ paddingVertical: 14,
62
+ alignItems: 'center',
63
+ justifyContent: 'center',
64
+ },
65
+ text: {
66
+ color: '#fff',
67
+ fontWeight: '600',
68
+ fontSize: scaleFont(16),
69
+ },
70
+ });
@@ -0,0 +1,171 @@
1
+ import { useNavigation } from '@react-navigation/native';
2
+ import { useEffect } from 'react';
3
+ import {
4
+ BackHandler,
5
+ Image,
6
+ Keyboard,
7
+ StyleSheet,
8
+ TouchableOpacity,
9
+ View,
10
+ } from 'react-native';
11
+ import { getStatusBarHeight } from '@core_super_app/utils/status-bar';
12
+ import TextWrapper from './TextWrapper';
13
+ import type { ColorValue, ImageSourcePropType, TextStyle } from 'react-native';
14
+ import type { ReactNode } from 'react';
15
+ import { Icon } from '../constants/image';
16
+ import { scaleFont, scaleHeight, scaleWidth } from '@core_super_app/utils/dimension';
17
+
18
+ export type HeaderProps = {
19
+ disabledBackHandler?: boolean;
20
+ leftIcon?: ImageSourcePropType;
21
+ back?: boolean;
22
+ onPressLeftIcon?: () => void;
23
+ title?: string;
24
+ rightView?: ReactNode;
25
+ isNotBackAfterPressLeft?: boolean;
26
+ subTitle?: string;
27
+ titleMaxLines?: number;
28
+ titleStyle?: TextStyle;
29
+ backColor?: ColorValue;
30
+ };
31
+
32
+ export const Header = (props: HeaderProps) => {
33
+ const {
34
+ disabledBackHandler,
35
+ leftIcon,
36
+ back,
37
+ onPressLeftIcon,
38
+ title,
39
+ rightView,
40
+ isNotBackAfterPressLeft,
41
+ subTitle,
42
+ titleMaxLines,
43
+ titleStyle,
44
+ backColor
45
+ } = props;
46
+
47
+ const navigation = useNavigation();
48
+
49
+ useEffect(() => {
50
+ let subscription = null;
51
+ if (!disabledBackHandler) {
52
+ subscription = BackHandler.addEventListener('hardwareBackPress', () => {
53
+ handleLeftIconPress();
54
+ return true;
55
+ });
56
+ }
57
+
58
+ return () => {
59
+ if (!disabledBackHandler && subscription) {
60
+ subscription.remove();
61
+ }
62
+ };
63
+ // eslint-disable-next-line react-hooks/exhaustive-deps
64
+ }, [disabledBackHandler]);
65
+
66
+ const handleLeftIconPress = () => {
67
+ Keyboard.dismiss();
68
+ if (onPressLeftIcon) {
69
+ onPressLeftIcon();
70
+ }
71
+ if (back) {
72
+ if (!isNotBackAfterPressLeft) {
73
+ navigation.goBack();
74
+ }
75
+ }
76
+ };
77
+
78
+ return (
79
+ <View
80
+ style={{
81
+ ...styles.headerView,
82
+ minHeight: subTitle ? scaleHeight(8.8) : scaleHeight(6.2),
83
+ }}
84
+ >
85
+ {back && (
86
+ <View style={styles.leftView}>
87
+ <TouchableOpacity
88
+ style={styles.leftView}
89
+ onPress={handleLeftIconPress}
90
+ >
91
+ <Image
92
+ source={leftIcon || Icon.back}
93
+ style={{...styles.icon}}
94
+ tintColor={backColor}
95
+ />
96
+ </TouchableOpacity>
97
+ </View>
98
+ )}
99
+ {title && (
100
+ <View style={styles.titleContainer}>
101
+ <TextWrapper
102
+ numberOfLines={titleMaxLines}
103
+ style={{ ...styles.title, ...titleStyle }}
104
+ >
105
+ {title}
106
+ </TextWrapper>
107
+ {subTitle && (
108
+ <TextWrapper
109
+ style={{ ...styles.subTitle }}
110
+ >
111
+ {subTitle}
112
+ </TextWrapper>
113
+ )}
114
+ </View>
115
+ )}
116
+ {rightView && (
117
+ <View style={styles.rightViewContainer}>
118
+ {rightView}
119
+ </View>
120
+ )}
121
+ </View>
122
+ );
123
+ };
124
+
125
+ export default Header
126
+
127
+ const styles = StyleSheet.create({
128
+ headerView: {
129
+ flexDirection: 'row',
130
+ width: scaleWidth(100),
131
+ paddingHorizontal: scaleWidth(4),
132
+ marginTop: getStatusBarHeight(),
133
+ backgroundColor: 'transparent',
134
+ position: 'relative',
135
+ alignItems: 'center',
136
+ },
137
+ leftView: {
138
+ flexDirection: 'row',
139
+ flex: 0.24,
140
+ width: scaleWidth(12),
141
+ justifyContent: 'flex-start',
142
+ alignItems: 'center',
143
+ },
144
+ rightIconView: {
145
+ justifyContent: 'center',
146
+ alignItems: 'center',
147
+ },
148
+ icon: {
149
+ width: scaleFont(24),
150
+ height: scaleFont(24),
151
+ },
152
+ titleContainer: {
153
+ position: 'absolute',
154
+ top: 0,
155
+ left: scaleWidth(22),
156
+ width: scaleWidth(56),
157
+ height: '100%',
158
+ justifyContent: 'center',
159
+ alignItems: 'center',
160
+ },
161
+ rightViewContainer: { flexDirection: 'row', justifyContent: 'flex-end' },
162
+ subTitle: {
163
+ fontSize: scaleFont(11),
164
+ textAlign: 'center',
165
+ marginTop: scaleFont(3),
166
+ },
167
+ title: {
168
+ textAlign: 'center',
169
+ fontSize: scaleFont(16),
170
+ }
171
+ });
@@ -0,0 +1,32 @@
1
+ import { StyleSheet, ActivityIndicator, View } from "react-native";
2
+
3
+ export type LoadingOverlayProps = {
4
+ indicatorColor?: string;
5
+ isLoading?: boolean;
6
+ }
7
+
8
+ const LoadingOverlay = ({ indicatorColor, isLoading = false }: LoadingOverlayProps) => {
9
+ if (!isLoading) return null;
10
+
11
+ return (
12
+ <View style={styles.viewLoading}>
13
+ <ActivityIndicator size="large" color={indicatorColor || "#FFF"} />
14
+ </View>
15
+ );
16
+ };
17
+
18
+ export default LoadingOverlay
19
+
20
+ const styles = StyleSheet.create({
21
+ viewLoading: {
22
+ position: "absolute",
23
+ top: 0,
24
+ left: 0,
25
+ right: 0,
26
+ bottom: 0,
27
+ backgroundColor: "rgba(0,0,0,0.3)",
28
+ justifyContent: "center",
29
+ alignItems: "center",
30
+ zIndex: 999,
31
+ },
32
+ });
@@ -0,0 +1,49 @@
1
+ import { StyleSheet, Text } from 'react-native';
2
+ import type { GestureResponderEvent, StyleProp, TextStyle } from 'react-native';
3
+ import type { ReactNode } from 'react';
4
+
5
+ export type TextWrapperProps = {
6
+ testID?: string;
7
+ accessibilityLabel?: string;
8
+ onPress?: (e: GestureResponderEvent) => void;
9
+ numberOfLines?: number;
10
+ ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip';
11
+ style?: StyleProp<TextStyle>;
12
+ children: ReactNode;
13
+ };
14
+
15
+ const TextWrapper = (props: TextWrapperProps) => {
16
+ const {
17
+ testID,
18
+ accessibilityLabel,
19
+ onPress,
20
+ numberOfLines,
21
+ ellipsizeMode,
22
+ style,
23
+ children,
24
+ } = props;
25
+
26
+ return (
27
+ <Text
28
+ accessible
29
+ testID={testID}
30
+ accessibilityLabel={accessibilityLabel}
31
+ onPress={onPress}
32
+ numberOfLines={numberOfLines}
33
+ ellipsizeMode={ellipsizeMode}
34
+ allowFontScaling={false}
35
+ style={[styles.defaultStyle, style]}
36
+ >
37
+ {children}
38
+ </Text>
39
+ );
40
+ };
41
+
42
+ export default TextWrapper;
43
+
44
+ const styles = StyleSheet.create({
45
+ defaultStyle: {
46
+ color: '#212B36',
47
+ includeFontPadding: false,
48
+ },
49
+ });
@@ -0,0 +1,6 @@
1
+ export * from "./BaseView";
2
+ export * from "./Header";
3
+ export * from "./LoadingOverlay";
4
+ export * from "./TextWrapper";
5
+ export * from "./input";
6
+ export * from "./BasicButton";