@jescon-technologies/react-native-ui-kit 0.0.14 → 0.0.15

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.
@@ -15,69 +15,60 @@ import AntDesignI from 'react-native-vector-icons/AntDesign';
15
15
 
16
16
  import type { IconProps } from 'react-native-vector-icons/Icon';
17
17
 
18
- /**
19
- * Shared icon props type
20
- */
21
18
  type Props = IconProps;
22
19
 
23
- /**
24
- * Wrapper components (typed)
25
- */
26
- export const MaterialCommunityIcons: React.FC<Props> = (props) => (
27
- <MaterialCommunityIconsI {...props} />
28
- );
29
-
30
- export const SimpleLineIcons: React.FC<Props> = (props) => (
31
- <SimpleLineIconsI {...props} />
32
- );
33
-
34
- export const MaterialIcons: React.FC<Props> = (props) => (
35
- <MaterialIconsI {...props} />
36
- );
37
-
38
- export const FontAwesome: React.FC<Props> = (props) => (
39
- <FontAwesomeI {...props} />
40
- );
41
-
42
- export const Foundation: React.FC<Props> = (props) => (
43
- <FoundationI {...props} />
44
- );
45
-
46
- export const EvilIcons: React.FC<Props> = (props) => (
47
- <EvilIconsI {...props} />
48
- );
49
-
50
- export const Ionicons: React.FC<Props> = (props) => (
51
- <IoniconsI {...props} />
52
- );
53
-
54
- export const Octicons: React.FC<Props> = (props) => (
55
- <OcticonsI {...props} />
56
- );
57
-
58
- export const Feather: React.FC<Props> = (props) => (
59
- <FeatherI {...props} />
60
- );
20
+ export interface IconsProps extends Props {
21
+ icongroup?: number | null;
22
+ }
23
+
24
+ // Wrappers (kept, but note: declare BEFORE the map)
25
+ export const MaterialCommunityIcons: React.FC<Props> = (p) => <MaterialCommunityIconsI {...p} />;
26
+ export const SimpleLineIcons: React.FC<Props> = (p) => <SimpleLineIconsI {...p} />;
27
+ export const MaterialIcons: React.FC<Props> = (p) => <MaterialIconsI {...p} />;
28
+ export const FontAwesome: React.FC<Props> = (p) => <FontAwesomeI {...p} />;
29
+ export const Foundation: React.FC<Props> = (p) => <FoundationI {...p} />;
30
+ export const EvilIcons: React.FC<Props> = (p) => <EvilIconsI {...p} />;
31
+ export const Ionicons: React.FC<Props> = (p) => <IoniconsI {...p} />;
32
+ export const Octicons: React.FC<Props> = (p) => <OcticonsI {...p} />;
33
+ export const Feather: React.FC<Props> = (p) => <FeatherI {...p} />;
34
+ export const Entypo: React.FC<Props> = (p) => <EntypoI {...p} />;
35
+ export const Zocial: React.FC<Props> = (p) => <ZocialI {...p} />;
36
+ export const FontAwesome5: React.FC<Props> = (p) => <FontAwesome5I {...p} />;
37
+ export const AntDesign: React.FC<Props> = (p) => <AntDesignI {...p} />;
38
+
39
+ // If you actually need Fontisto, add:
40
+ // import FontistoI from 'react-native-vector-icons/Fontisto';
41
+ // export const Fontisto: React.FC<Props> = (p) => <FontistoI {...p} />;
42
+
43
+ const components: Record<number, React.ComponentType<Props>> = {
44
+ 1: AntDesign,
45
+ 2: MaterialIcons,
46
+ 3: MaterialCommunityIcons,
47
+ 4: FontAwesome,
48
+ 5: FontAwesome5,
49
+ 6: Foundation,
50
+ 7: EvilIcons,
51
+ 8: Ionicons,
52
+ 9: Octicons,
53
+ 10: Feather,
54
+ 11: Entypo,
55
+ 12: Zocial,
56
+ 14: SimpleLineIcons,
57
+ };
61
58
 
62
- export const Entypo: React.FC<Props> = (props) => (
63
- <EntypoI {...props} />
64
- );
59
+ const DEFAULT_ICON_GROUP = 5;
65
60
 
66
- export const Zocial: React.FC<Props> = (props) => (
67
- <ZocialI {...props} />
68
- );
61
+ function Icons({ icongroup, ...rest }: IconsProps): React.ReactElement {
62
+ const group =
63
+ typeof icongroup === 'number' && Number.isInteger(icongroup) && icongroup >= 1 && icongroup in components
64
+ ? icongroup
65
+ : DEFAULT_ICON_GROUP;
69
66
 
70
- export const FontAwesome5: React.FC<Props> = (props) => (
71
- <FontAwesome5I {...props} />
72
- );
67
+ const IconComponent = components[group] ?? components[DEFAULT_ICON_GROUP];
73
68
 
74
- export const AntDesign: React.FC<Props> = (props) => (
75
- <AntDesignI {...props} />
76
- );
69
+ return <IconComponent {...rest} />;
70
+ }
77
71
 
78
- /**
79
- * Default export object (same usage style as your JS version)
80
- */
81
72
  const HIcons = {
82
73
  MaterialCommunityIcons,
83
74
  SimpleLineIcons,
@@ -92,6 +83,7 @@ const HIcons = {
92
83
  Zocial,
93
84
  FontAwesome5,
94
85
  AntDesign,
86
+ Icons,
95
87
  };
96
88
 
97
89
  export default HIcons;
@@ -0,0 +1,101 @@
1
+ import { StyleProp, Text, TextStyle, TouchableOpacity, ViewStyle } from 'react-native';
2
+ import { isBNU, isNU, isNUQ, normalize } from '../CommonStyle/ComponentFunctions';
3
+ import HIcons from './HIcons';
4
+ import { Global } from '../Common/Global';
5
+ import React from 'react';
6
+
7
+ // ---------------------------------------------------------------------------
8
+ // Types
9
+ // ---------------------------------------------------------------------------
10
+
11
+ export interface HShadowButtonProps {
12
+ /** Disables the button when true. */
13
+ disabled?: boolean;
14
+ /** Invoked on press. Receives `true` when pressed. */
15
+ buttonCallback?: (pressed: boolean) => void;
16
+ /** Outer button (TouchableOpacity) style. */
17
+ buttonstyle?: StyleProp<ViewStyle>;
18
+
19
+ /** Render the leading icon when true. */
20
+ useicon?: boolean;
21
+ /** Icon group index (e.g. FontAwesome vs MaterialIcons). Defaults to 5. */
22
+ icongroup?: number;
23
+ /** Icon name string. Defaults to 'file-alt'. */
24
+ iconname?: string;
25
+ /** Icon color. Defaults to `Global.AppTheme.primary_color`. */
26
+ iconcolor?: string;
27
+ /** Icon size. Defaults to `normalize(15)`. */
28
+ iconsize?: number;
29
+ /** Extra icon container style. */
30
+ iconstyle?: StyleProp<ViewStyle>;
31
+
32
+ /** Render the label when true. */
33
+ usetext?: boolean;
34
+ /** Label text. */
35
+ displaytext?: string;
36
+ /** Text style. Defaults provided in component. */
37
+ textstyle?: StyleProp<TextStyle>;
38
+ /** Max lines for the label. Defaults to 1. */
39
+ numberOfLines?: number;
40
+ }
41
+
42
+ // ---------------------------------------------------------------------------
43
+ // Component
44
+ // ---------------------------------------------------------------------------
45
+
46
+ export default function HShadowButton(props: HShadowButtonProps): React.ReactElement {
47
+ const {
48
+ disabled,
49
+ buttonCallback,
50
+ buttonstyle,
51
+ useicon,
52
+ icongroup,
53
+ iconname,
54
+ iconcolor,
55
+ iconsize,
56
+ iconstyle,
57
+ usetext,
58
+ displaytext,
59
+ textstyle,
60
+ numberOfLines,
61
+ } = props;
62
+
63
+ return (
64
+ <TouchableOpacity
65
+ disabled={!!disabled}
66
+ onPress={() => {
67
+ if (isNU(buttonCallback)) {
68
+ buttonCallback!(true);
69
+ }
70
+ }}
71
+ style={isNU(buttonstyle) ? buttonstyle : {}}
72
+ >
73
+ {useicon ? (
74
+ <HIcons.Icons
75
+ icongroup={isNU(icongroup) ? icongroup : 5}
76
+ name={isBNU(iconname) ? iconname : 'file-alt'}
77
+ color={isNU(iconcolor) ? iconcolor : Global.AppTheme.primary_color}
78
+ size={isNU(iconsize) ? iconsize : normalize(15)}
79
+ style={iconstyle ? iconstyle : {}}
80
+ />
81
+ ) : null}
82
+ {usetext ? (
83
+ <Text
84
+ numberOfLines={numberOfLines || 1}
85
+ adjustsFontSizeToFit={true}
86
+ style={
87
+ textstyle
88
+ ? textstyle
89
+ : {
90
+ color: Global.AppTheme.primary_color,
91
+ fontSize: normalize(6),
92
+ textAlign: 'center',
93
+ }
94
+ }
95
+ >
96
+ {isNUQ(displaytext) ? displaytext : null}
97
+ </Text>
98
+ ) : null}
99
+ </TouchableOpacity>
100
+ );
101
+ }