ui-rn 2.0.1 → 2.0.3
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/dist/Icon/PropsStyle.d.ts +15 -0
- package/dist/Icon/PropsStyle.js +1 -0
- package/dist/Icon/index.d.ts +33 -0
- package/dist/Icon/index.js +72 -0
- package/dist/Icon/makeProps.d.ts +37 -0
- package/dist/Icon/makeProps.js +64 -0
- package/dist/Layout.d.ts +13 -0
- package/dist/Layout.js +21 -0
- package/dist/Text/Props.d.ts +29 -0
- package/dist/Text/Props.js +1 -0
- package/dist/Text/Style.d.ts +1 -0
- package/dist/Text/Style.js +17 -0
- package/dist/Text/index.d.ts +4 -0
- package/dist/Text/index.js +44 -0
- package/dist/Text/makeStyle.d.ts +63 -0
- package/dist/Text/makeStyle.js +91 -0
- package/dist/Touch/Block.d.ts +5 -0
- package/dist/Touch/Block.js +11 -0
- package/dist/Touch/Props.d.ts +128 -0
- package/dist/Touch/Props.js +1 -0
- package/dist/Touch/Style.d.ts +31 -0
- package/dist/Touch/Style.js +118 -0
- package/dist/Touch/Touch.d.ts +28 -0
- package/dist/Touch/Touch.js +35 -0
- package/dist/Touch/TouchScale.d.ts +10 -0
- package/dist/Touch/TouchScale.js +30 -0
- package/dist/Touch/makeStyle.d.ts +64 -0
- package/dist/Touch/makeStyle.js +94 -0
- package/dist/Touch/utils.d.ts +5 -0
- package/dist/Touch/utils.js +23 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/package.json +6 -4
- package/src/Text/makeStyle.ts +1 -1
- package/src/global.d.ts +1 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RNVectorIcon } from "./index";
|
|
2
|
+
import { FlexStyle, StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
3
|
+
import { MakeProp } from "./makeProps";
|
|
4
|
+
export interface Props extends MakeProp {
|
|
5
|
+
name: string;
|
|
6
|
+
size?: number;
|
|
7
|
+
type?: keyof typeof RNVectorIcon;
|
|
8
|
+
onPress?: () => void;
|
|
9
|
+
styleContainer?: StyleProp<ViewStyle>;
|
|
10
|
+
style?: StyleProp<TextStyle>;
|
|
11
|
+
alignSelf?: FlexStyle['alignSelf'];
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
activeOpacity?: number;
|
|
14
|
+
color?: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Ionicons from "react-native-vector-icons/Ionicons";
|
|
3
|
+
import FontAwesome5 from "react-native-vector-icons/FontAwesome5";
|
|
4
|
+
/**
|
|
5
|
+
* Collection of React Native Vector Icons
|
|
6
|
+
* Provides access to various icon sets from react-native-vector-icons
|
|
7
|
+
*/
|
|
8
|
+
export declare const RNVectorIcon: {
|
|
9
|
+
Ionicons: typeof Ionicons;
|
|
10
|
+
AntDesign: typeof Ionicons;
|
|
11
|
+
Entypo: typeof Ionicons;
|
|
12
|
+
EvilIcons: typeof Ionicons;
|
|
13
|
+
MaterialIcons: typeof Ionicons;
|
|
14
|
+
MaterialCommunityIcons: typeof Ionicons;
|
|
15
|
+
FontAwesome: typeof Ionicons;
|
|
16
|
+
FontAwesome5: typeof FontAwesome5;
|
|
17
|
+
SimpleLineIcons: typeof Ionicons;
|
|
18
|
+
Feather: typeof Ionicons;
|
|
19
|
+
Octicons: typeof Ionicons;
|
|
20
|
+
Fontisto: typeof Ionicons;
|
|
21
|
+
};
|
|
22
|
+
export type IconType = keyof typeof RNVectorIcon;
|
|
23
|
+
import { Props } from "./PropsStyle";
|
|
24
|
+
export default class IconApp extends React.PureComponent<Props> {
|
|
25
|
+
static defaultProps: Props;
|
|
26
|
+
res: {
|
|
27
|
+
color: string;
|
|
28
|
+
style: any;
|
|
29
|
+
size: number;
|
|
30
|
+
};
|
|
31
|
+
constructor(props: Props);
|
|
32
|
+
render(): React.JSX.Element | null;
|
|
33
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleSheet, TouchableOpacity } from "react-native";
|
|
3
|
+
import Ionicons from "react-native-vector-icons/Ionicons";
|
|
4
|
+
import EvilIcons from "react-native-vector-icons/EvilIcons";
|
|
5
|
+
import FontAwesome from "react-native-vector-icons/FontAwesome";
|
|
6
|
+
import FontAwesome5 from "react-native-vector-icons/FontAwesome5";
|
|
7
|
+
import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons";
|
|
8
|
+
import MaterialIcons from "react-native-vector-icons/MaterialIcons";
|
|
9
|
+
import Entypo from "react-native-vector-icons/Entypo";
|
|
10
|
+
import AntDesign from "react-native-vector-icons/AntDesign";
|
|
11
|
+
import SimpleLineIcons from "react-native-vector-icons/SimpleLineIcons";
|
|
12
|
+
import Feather from "react-native-vector-icons/Feather";
|
|
13
|
+
import Octicons from "react-native-vector-icons/Octicons";
|
|
14
|
+
import Fontisto from "react-native-vector-icons/Fontisto";
|
|
15
|
+
/**
|
|
16
|
+
* Collection of React Native Vector Icons
|
|
17
|
+
* Provides access to various icon sets from react-native-vector-icons
|
|
18
|
+
*/
|
|
19
|
+
export const RNVectorIcon = {
|
|
20
|
+
Ionicons,
|
|
21
|
+
AntDesign,
|
|
22
|
+
Entypo,
|
|
23
|
+
EvilIcons,
|
|
24
|
+
MaterialIcons,
|
|
25
|
+
MaterialCommunityIcons,
|
|
26
|
+
FontAwesome,
|
|
27
|
+
FontAwesome5,
|
|
28
|
+
SimpleLineIcons,
|
|
29
|
+
Feather,
|
|
30
|
+
Octicons,
|
|
31
|
+
Fontisto,
|
|
32
|
+
};
|
|
33
|
+
import { makeProps } from "./makeProps";
|
|
34
|
+
export default class IconApp extends React.PureComponent {
|
|
35
|
+
static defaultProps = {
|
|
36
|
+
size: 23,
|
|
37
|
+
color: "gray",
|
|
38
|
+
name: "home",
|
|
39
|
+
};
|
|
40
|
+
res;
|
|
41
|
+
constructor(props) {
|
|
42
|
+
super(props);
|
|
43
|
+
this.res = makeProps(props);
|
|
44
|
+
}
|
|
45
|
+
render() {
|
|
46
|
+
const { size, color, style } = this.res;
|
|
47
|
+
if (this.props.name === "none")
|
|
48
|
+
return null;
|
|
49
|
+
const IconView = RNVectorIcon[this.props.type || "Ionicons"];
|
|
50
|
+
if (typeof this.props.onPress != "function") {
|
|
51
|
+
return (<IconView size={size} color={color} style={style} name={this.props.name} onPress={this.props.onPress}/>);
|
|
52
|
+
}
|
|
53
|
+
return (<TouchableOpacity activeOpacity={this.props.activeOpacity || 0.5} disabled={typeof this.props.onPress == "function" ? this.props.disabled : true} style={[
|
|
54
|
+
styles.container,
|
|
55
|
+
{ ...(this.props.alignSelf && { alignSelf: this.props.alignSelf }) },
|
|
56
|
+
this.props.style,
|
|
57
|
+
this.props.styleContainer,
|
|
58
|
+
]}>
|
|
59
|
+
<IconView size={size} color={color} style={style} name={this.props.name} onPress={this.props.onPress}/>
|
|
60
|
+
</TouchableOpacity>);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Default styles for the IconApp component
|
|
65
|
+
*/
|
|
66
|
+
const styles = StyleSheet.create({
|
|
67
|
+
container: {
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
justifyContent: "center",
|
|
70
|
+
alignSelf: "flex-start",
|
|
71
|
+
},
|
|
72
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ViewStyle } from "react-native";
|
|
2
|
+
declare enum COLORS {
|
|
3
|
+
white = 1,
|
|
4
|
+
red = 2,
|
|
5
|
+
blue = 3,
|
|
6
|
+
black = 4,
|
|
7
|
+
green = 5,
|
|
8
|
+
yellow = 6,
|
|
9
|
+
pink = 7,
|
|
10
|
+
gray = 8,
|
|
11
|
+
primary = 9
|
|
12
|
+
}
|
|
13
|
+
type ColorKey = keyof typeof COLORS;
|
|
14
|
+
type ColorModifiers = Partial<Record<ColorKey, boolean>>;
|
|
15
|
+
declare const PROPS: {
|
|
16
|
+
readonly mar: "margin";
|
|
17
|
+
readonly marH: "marginHorizontal";
|
|
18
|
+
readonly marV: "marginVertical";
|
|
19
|
+
readonly marL: "marginLeft";
|
|
20
|
+
readonly marT: "marginTop";
|
|
21
|
+
readonly marR: "marginRight";
|
|
22
|
+
readonly marB: "marginBottom";
|
|
23
|
+
readonly zIndex: "zIndex";
|
|
24
|
+
readonly opacity: "opacity";
|
|
25
|
+
readonly size: "size";
|
|
26
|
+
};
|
|
27
|
+
export type ShortKey = keyof typeof PROPS;
|
|
28
|
+
export type Convert<T extends string> = Partial<Record<T, boolean | number | string>>;
|
|
29
|
+
export type MakeProp = Convert<ShortKey> & ColorModifiers;
|
|
30
|
+
type Result = {
|
|
31
|
+
size: number;
|
|
32
|
+
color: string;
|
|
33
|
+
name: string;
|
|
34
|
+
style: ViewStyle;
|
|
35
|
+
};
|
|
36
|
+
export declare const makeProps: (props: Record<string, any>) => Result;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
var COLORS;
|
|
3
|
+
(function (COLORS) {
|
|
4
|
+
COLORS[COLORS["white"] = 1] = "white";
|
|
5
|
+
COLORS[COLORS["red"] = 2] = "red";
|
|
6
|
+
COLORS[COLORS["blue"] = 3] = "blue";
|
|
7
|
+
COLORS[COLORS["black"] = 4] = "black";
|
|
8
|
+
COLORS[COLORS["green"] = 5] = "green";
|
|
9
|
+
COLORS[COLORS["yellow"] = 6] = "yellow";
|
|
10
|
+
COLORS[COLORS["pink"] = 7] = "pink";
|
|
11
|
+
COLORS[COLORS["gray"] = 8] = "gray";
|
|
12
|
+
COLORS[COLORS["primary"] = 9] = "primary";
|
|
13
|
+
})(COLORS || (COLORS = {}));
|
|
14
|
+
const PROPS = {
|
|
15
|
+
mar: "margin",
|
|
16
|
+
marH: "marginHorizontal",
|
|
17
|
+
marV: "marginVertical",
|
|
18
|
+
marL: "marginLeft",
|
|
19
|
+
marT: "marginTop",
|
|
20
|
+
marR: "marginRight",
|
|
21
|
+
marB: "marginBottom",
|
|
22
|
+
zIndex: "zIndex",
|
|
23
|
+
opacity: "opacity",
|
|
24
|
+
size: "size",
|
|
25
|
+
};
|
|
26
|
+
/** type guards */
|
|
27
|
+
const isColorKey = (key) => key in COLORS;
|
|
28
|
+
const isShortKey = (key) => key in PROPS;
|
|
29
|
+
export const makeProps = (props) => {
|
|
30
|
+
const style = {};
|
|
31
|
+
const res = {
|
|
32
|
+
size: props.size ?? 23,
|
|
33
|
+
color: props.color ?? "gray",
|
|
34
|
+
name: props.name ?? "home",
|
|
35
|
+
};
|
|
36
|
+
Object.keys(props).forEach((key) => {
|
|
37
|
+
const match = key.match(/^(\w+)-(\w+)$/);
|
|
38
|
+
// color modifier
|
|
39
|
+
if (isColorKey(key)) {
|
|
40
|
+
res.color = key;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (match) {
|
|
44
|
+
const rawKey = match[1];
|
|
45
|
+
const rawValue = match[2];
|
|
46
|
+
const value = isNaN(Number(rawValue))
|
|
47
|
+
? rawValue
|
|
48
|
+
: Number(rawValue);
|
|
49
|
+
if (rawKey === "size") {
|
|
50
|
+
res.size = Number(rawValue);
|
|
51
|
+
}
|
|
52
|
+
else if (rawKey === "color") {
|
|
53
|
+
res.color = rawValue;
|
|
54
|
+
}
|
|
55
|
+
else if (isShortKey(rawKey)) {
|
|
56
|
+
style[PROPS[rawKey]] = value;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
...res,
|
|
62
|
+
style: StyleSheet.create({ style }).style,
|
|
63
|
+
};
|
|
64
|
+
};
|
package/dist/Layout.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ForceInsetProp } from "react-native-safe-area-view";
|
|
3
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
4
|
+
export interface LayoutAppProps {
|
|
5
|
+
children?: any;
|
|
6
|
+
forceInset?: ForceInsetProp;
|
|
7
|
+
forceInsetBot?: ForceInsetProp;
|
|
8
|
+
styleBot?: StyleProp<ViewStyle> | undefined;
|
|
9
|
+
style?: StyleProp<ViewStyle> | undefined;
|
|
10
|
+
isBack?: boolean;
|
|
11
|
+
disable?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export default function Layout({ children, forceInset, forceInsetBot, styleBot, style, disable, }: LayoutAppProps): React.JSX.Element;
|
package/dist/Layout.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import SafeAreaView from "react-native-safe-area-view";
|
|
3
|
+
export default function Layout({ children, forceInset = { top: "always", horizontal: "never", bottom: "never" }, forceInsetBot = { vertical: "never" }, styleBot, style, disable, }) {
|
|
4
|
+
if (disable)
|
|
5
|
+
return <>{children}</>;
|
|
6
|
+
return (<SafeAreaView style={[
|
|
7
|
+
{
|
|
8
|
+
flex: 1,
|
|
9
|
+
},
|
|
10
|
+
style,
|
|
11
|
+
]} forceInset={forceInset}>
|
|
12
|
+
<SafeAreaView style={[
|
|
13
|
+
{
|
|
14
|
+
flex: 1,
|
|
15
|
+
},
|
|
16
|
+
styleBot,
|
|
17
|
+
]} forceInset={forceInsetBot}>
|
|
18
|
+
{children}
|
|
19
|
+
</SafeAreaView>
|
|
20
|
+
</SafeAreaView>);
|
|
21
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextProps, TextStyle } from 'react-native';
|
|
3
|
+
import { MakeProp } from './makeStyle';
|
|
4
|
+
interface PropsParent {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
bold?: boolean | TextStyle['fontWeight'];
|
|
7
|
+
center?: boolean;
|
|
8
|
+
italic?: boolean;
|
|
9
|
+
underline?: boolean;
|
|
10
|
+
color?: string;
|
|
11
|
+
toUpperCase?: boolean;
|
|
12
|
+
toLowerCase?: boolean;
|
|
13
|
+
background?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface Props extends TextProps, PropsParent, MakeProp {
|
|
16
|
+
backgroundColor?: string;
|
|
17
|
+
primary?: boolean;
|
|
18
|
+
white?: boolean;
|
|
19
|
+
red?: boolean;
|
|
20
|
+
blue?: boolean;
|
|
21
|
+
green?: boolean;
|
|
22
|
+
yellow?: boolean;
|
|
23
|
+
pink?: boolean;
|
|
24
|
+
gray?: boolean;
|
|
25
|
+
black?: boolean;
|
|
26
|
+
lang?: string;
|
|
27
|
+
content?: string;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Style: any;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { makeStyle } from "./makeStyle";
|
|
3
|
+
export const Style = (props) => {
|
|
4
|
+
const PropsConvert = StyleSheet.flatten([
|
|
5
|
+
props.color && { color: props.color },
|
|
6
|
+
props.center && { textAlign: 'center' },
|
|
7
|
+
props.italic && { fontStyle: 'italic' },
|
|
8
|
+
props.bold && { fontWeight: typeof props.bold == "boolean" ? '500' : props.bold },
|
|
9
|
+
props.underline && { textDecorationLine: 'underline' },
|
|
10
|
+
props.toUpperCase && { textTransform: 'uppercase' },
|
|
11
|
+
props.toLowerCase && { textTransform: 'lowercase' },
|
|
12
|
+
]);
|
|
13
|
+
return [
|
|
14
|
+
makeStyle(props),
|
|
15
|
+
PropsConvert,
|
|
16
|
+
];
|
|
17
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { isValidElement } from "react";
|
|
2
|
+
import { StyleSheet, Text } from "react-native";
|
|
3
|
+
import { Style } from "./Style";
|
|
4
|
+
import { isArray, isObject } from "underscore";
|
|
5
|
+
const TextApp = ({ style, children, ...props }) => {
|
|
6
|
+
const Children = () => {
|
|
7
|
+
const content = props?.lang ?? undefined;
|
|
8
|
+
if (typeof content !== "undefined") {
|
|
9
|
+
if (typeof content == "string" ||
|
|
10
|
+
typeof content == "number" ||
|
|
11
|
+
isArray(children))
|
|
12
|
+
return content;
|
|
13
|
+
if (typeof content == "function")
|
|
14
|
+
return "Error content == 'function'";
|
|
15
|
+
if (isObject(children))
|
|
16
|
+
return JSON.stringify(children);
|
|
17
|
+
if (isValidElement(content))
|
|
18
|
+
return content;
|
|
19
|
+
return React.createElement(Text, {});
|
|
20
|
+
}
|
|
21
|
+
if (typeof children !== "undefined") {
|
|
22
|
+
if (typeof children == "string" ||
|
|
23
|
+
typeof children == "number" ||
|
|
24
|
+
isArray(children))
|
|
25
|
+
return children;
|
|
26
|
+
if (isObject(children))
|
|
27
|
+
return JSON.stringify(children);
|
|
28
|
+
if (typeof children == "function")
|
|
29
|
+
return "Error children == 'function'";
|
|
30
|
+
if (isValidElement(children))
|
|
31
|
+
return children;
|
|
32
|
+
return React.createElement(Text, {}, children);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return (<Text style={[styles.default, Style(props), style]} {...props}>
|
|
36
|
+
{Children()}
|
|
37
|
+
</Text>);
|
|
38
|
+
};
|
|
39
|
+
export default TextApp;
|
|
40
|
+
const styles = StyleSheet.create({
|
|
41
|
+
default: {
|
|
42
|
+
fontSize: 14,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { TextStyle } from "react-native";
|
|
2
|
+
declare enum COLORS {
|
|
3
|
+
"white" = 1,
|
|
4
|
+
"red" = 2,
|
|
5
|
+
"blue" = 3,
|
|
6
|
+
"black" = 4,
|
|
7
|
+
"green" = 5,
|
|
8
|
+
"yellow" = 6,
|
|
9
|
+
"pink" = 7,
|
|
10
|
+
"gray" = 8,
|
|
11
|
+
"primary" = 9
|
|
12
|
+
}
|
|
13
|
+
declare const PROPS: {
|
|
14
|
+
readonly bg: "backgroundColor";
|
|
15
|
+
readonly background: "backgroundColor";
|
|
16
|
+
readonly color: "color";
|
|
17
|
+
readonly w: "width";
|
|
18
|
+
readonly width: "width";
|
|
19
|
+
readonly minW: "minWidth";
|
|
20
|
+
readonly maxW: "maxWidth";
|
|
21
|
+
readonly h: "height";
|
|
22
|
+
readonly height: "height";
|
|
23
|
+
readonly minH: "minHeight";
|
|
24
|
+
readonly maxH: "maxHeight";
|
|
25
|
+
readonly pad: "padding";
|
|
26
|
+
readonly padH: "paddingHorizontal";
|
|
27
|
+
readonly padV: "paddingVertical";
|
|
28
|
+
readonly padL: "paddingLeft";
|
|
29
|
+
readonly padT: "paddingTop";
|
|
30
|
+
readonly padR: "paddingRight";
|
|
31
|
+
readonly padB: "paddingBottom";
|
|
32
|
+
readonly mar: "margin";
|
|
33
|
+
readonly marH: "marginHorizontal";
|
|
34
|
+
readonly marV: "marginVertical";
|
|
35
|
+
readonly marL: "marginLeft";
|
|
36
|
+
readonly marT: "marginTop";
|
|
37
|
+
readonly marR: "marginRight";
|
|
38
|
+
readonly marB: "marginBottom";
|
|
39
|
+
readonly border: "borderWidth";
|
|
40
|
+
readonly borderW: "borderWidth";
|
|
41
|
+
readonly borderR: "borderRadius";
|
|
42
|
+
readonly borderC: "borderColor";
|
|
43
|
+
readonly borderLW: "borderLeftWidth";
|
|
44
|
+
readonly borderTW: "borderTopWidth";
|
|
45
|
+
readonly borderRW: "borderRightWidth";
|
|
46
|
+
readonly borderBW: "borderBottomWidth";
|
|
47
|
+
readonly flex: "flex";
|
|
48
|
+
readonly zIndex: "zIndex";
|
|
49
|
+
readonly left: "left";
|
|
50
|
+
readonly top: "top";
|
|
51
|
+
readonly bottom: "bottom";
|
|
52
|
+
readonly right: "right";
|
|
53
|
+
readonly opacity: "opacity";
|
|
54
|
+
readonly size: "fontSize";
|
|
55
|
+
};
|
|
56
|
+
export type ColorKey = keyof typeof COLORS;
|
|
57
|
+
export type ShortKey = keyof typeof PROPS;
|
|
58
|
+
export type Convert<T extends string> = Partial<Record<T, boolean | number | string>>;
|
|
59
|
+
export type MakeProp = Partial<Record<ShortKey, number | string>> & Partial<Record<ColorKey, boolean>> & Record<string, any>;
|
|
60
|
+
export declare const makeStyle: (props: {
|
|
61
|
+
[key: string]: any;
|
|
62
|
+
}) => TextStyle;
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { isNaN } from "underscore";
|
|
3
|
+
var COLORS;
|
|
4
|
+
(function (COLORS) {
|
|
5
|
+
COLORS[COLORS["white"] = 1] = "white";
|
|
6
|
+
COLORS[COLORS["red"] = 2] = "red";
|
|
7
|
+
COLORS[COLORS["blue"] = 3] = "blue";
|
|
8
|
+
COLORS[COLORS["black"] = 4] = "black";
|
|
9
|
+
COLORS[COLORS["green"] = 5] = "green";
|
|
10
|
+
COLORS[COLORS["yellow"] = 6] = "yellow";
|
|
11
|
+
COLORS[COLORS["pink"] = 7] = "pink";
|
|
12
|
+
COLORS[COLORS["gray"] = 8] = "gray";
|
|
13
|
+
COLORS[COLORS["primary"] = 9] = "primary";
|
|
14
|
+
})(COLORS || (COLORS = {}));
|
|
15
|
+
const PROPS = {
|
|
16
|
+
bg: "backgroundColor",
|
|
17
|
+
background: "backgroundColor",
|
|
18
|
+
color: "color",
|
|
19
|
+
w: "width",
|
|
20
|
+
width: "width",
|
|
21
|
+
minW: "minWidth",
|
|
22
|
+
maxW: "maxWidth",
|
|
23
|
+
h: "height",
|
|
24
|
+
height: "height",
|
|
25
|
+
minH: "minHeight",
|
|
26
|
+
maxH: "maxHeight",
|
|
27
|
+
pad: "padding",
|
|
28
|
+
padH: "paddingHorizontal",
|
|
29
|
+
padV: "paddingVertical",
|
|
30
|
+
padL: "paddingLeft",
|
|
31
|
+
padT: "paddingTop",
|
|
32
|
+
padR: "paddingRight",
|
|
33
|
+
padB: "paddingBottom",
|
|
34
|
+
mar: "margin",
|
|
35
|
+
marH: "marginHorizontal",
|
|
36
|
+
marV: "marginVertical",
|
|
37
|
+
marL: "marginLeft",
|
|
38
|
+
marT: "marginTop",
|
|
39
|
+
marR: "marginRight",
|
|
40
|
+
marB: "marginBottom",
|
|
41
|
+
border: 'borderWidth',
|
|
42
|
+
borderW: 'borderWidth',
|
|
43
|
+
borderR: "borderRadius",
|
|
44
|
+
borderC: "borderColor",
|
|
45
|
+
borderLW: "borderLeftWidth",
|
|
46
|
+
borderTW: "borderTopWidth",
|
|
47
|
+
borderRW: "borderRightWidth",
|
|
48
|
+
borderBW: "borderBottomWidth",
|
|
49
|
+
flex: 'flex',
|
|
50
|
+
zIndex: 'zIndex',
|
|
51
|
+
left: 'left',
|
|
52
|
+
top: 'top',
|
|
53
|
+
bottom: 'bottom',
|
|
54
|
+
right: 'right',
|
|
55
|
+
opacity: 'opacity',
|
|
56
|
+
size: 'fontSize'
|
|
57
|
+
};
|
|
58
|
+
const isColorKey = (key) => {
|
|
59
|
+
return key in COLORS;
|
|
60
|
+
};
|
|
61
|
+
const isShortKey = (key) => {
|
|
62
|
+
return key in PROPS;
|
|
63
|
+
};
|
|
64
|
+
export const makeStyle = (props) => {
|
|
65
|
+
const style = {};
|
|
66
|
+
Object.keys(props).forEach((key) => {
|
|
67
|
+
const match = key.match(/^(\w+)-(\w+)$/);
|
|
68
|
+
if (isColorKey(key)) {
|
|
69
|
+
style.color = key;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (match) {
|
|
73
|
+
const [, rawKey, rawValue] = match;
|
|
74
|
+
const value = isNaN(Number(rawValue))
|
|
75
|
+
? rawValue
|
|
76
|
+
: Number(rawValue);
|
|
77
|
+
if (isShortKey(rawKey)) {
|
|
78
|
+
style[PROPS[rawKey]] = value;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
style[rawKey] = value;
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// 🔹 Normal props
|
|
86
|
+
if (isShortKey(key)) {
|
|
87
|
+
style[PROPS[key]] = props[key];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return StyleSheet.create({ style }).style;
|
|
91
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { Style } from "./Style";
|
|
4
|
+
const Block = React.forwardRef(({ style, ...props }, ref) => {
|
|
5
|
+
if (props?.hidden)
|
|
6
|
+
return <></>;
|
|
7
|
+
return (<View ref={ref} style={[Style(props), style]} {...props}>
|
|
8
|
+
{props.children}
|
|
9
|
+
</View>);
|
|
10
|
+
});
|
|
11
|
+
export default Block;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { FlexStyle, TouchableWithoutFeedbackProps, ViewStyle } from "react-native";
|
|
2
|
+
import { MakeProp } from "./makeStyle";
|
|
3
|
+
/**
|
|
4
|
+
* Interface for application-specific props that extend React Native's style properties
|
|
5
|
+
* @interface PropsApp
|
|
6
|
+
*/
|
|
7
|
+
export interface PropsApp {
|
|
8
|
+
/** Border radius for top corners */
|
|
9
|
+
borderUpRadius?: number;
|
|
10
|
+
/** Border radius for bottom corners */
|
|
11
|
+
borderDownRadius?: number;
|
|
12
|
+
/** Flexbox alignment along cross axis */
|
|
13
|
+
alignItems?: FlexStyle['alignItems'];
|
|
14
|
+
/** Flexbox alignment for self */
|
|
15
|
+
alignSelf?: FlexStyle['alignSelf'];
|
|
16
|
+
/** Flexbox alignment along main axis */
|
|
17
|
+
justifyContent?: FlexStyle['justifyContent'];
|
|
18
|
+
/** Border style (solid, dashed, dotted) */
|
|
19
|
+
borderStyle?: ViewStyle['borderStyle'];
|
|
20
|
+
/** Opacity of the view */
|
|
21
|
+
opacity?: ViewStyle['opacity'];
|
|
22
|
+
/** Overflow behavior */
|
|
23
|
+
overflow?: ViewStyle['overflow'];
|
|
24
|
+
/** Set width to 100% */
|
|
25
|
+
w100?: boolean;
|
|
26
|
+
/** Set height to 100% */
|
|
27
|
+
h100?: boolean;
|
|
28
|
+
/** Center content both horizontally and vertically */
|
|
29
|
+
mid?: boolean;
|
|
30
|
+
middle?: boolean;
|
|
31
|
+
/** Set flex direction to row */
|
|
32
|
+
row?: boolean;
|
|
33
|
+
/** Center content horizontally */
|
|
34
|
+
alignCenter?: boolean;
|
|
35
|
+
/** Center content vertically */
|
|
36
|
+
justifyCenter?: boolean;
|
|
37
|
+
/** Make border radius circular */
|
|
38
|
+
borderCircle?: boolean;
|
|
39
|
+
/** Center content horizontally and space between vertically */
|
|
40
|
+
centerBetween?: boolean;
|
|
41
|
+
/** Space content evenly along main axis */
|
|
42
|
+
justifyBetween?: boolean;
|
|
43
|
+
/** Hide overflow content */
|
|
44
|
+
overHidden?: boolean;
|
|
45
|
+
/** Set width and height to same value */
|
|
46
|
+
square?: number;
|
|
47
|
+
/** Set width to 100% */
|
|
48
|
+
width100?: boolean;
|
|
49
|
+
/** Set height to 100% */
|
|
50
|
+
height100?: boolean;
|
|
51
|
+
/** Background color or gradient colors */
|
|
52
|
+
background?: string;
|
|
53
|
+
/** Gradient direction */
|
|
54
|
+
gradient?: 'vertical' | 'horizontal';
|
|
55
|
+
/** Set flex to 1 */
|
|
56
|
+
flexOne?: boolean;
|
|
57
|
+
flex1?: boolean;
|
|
58
|
+
/** Shadow color or boolean to enable default shadow */
|
|
59
|
+
shadowColor?: string | boolean;
|
|
60
|
+
/** Border options for each side */
|
|
61
|
+
borderOption?: {
|
|
62
|
+
top?: number;
|
|
63
|
+
left?: number;
|
|
64
|
+
right?: number;
|
|
65
|
+
bottom?: number;
|
|
66
|
+
color?: string;
|
|
67
|
+
};
|
|
68
|
+
/** Position options for absolute positioning */
|
|
69
|
+
positionOption?: {
|
|
70
|
+
top?: number;
|
|
71
|
+
left?: number;
|
|
72
|
+
right?: number;
|
|
73
|
+
bottom?: number;
|
|
74
|
+
};
|
|
75
|
+
/** Padding options for each side */
|
|
76
|
+
paddingOption?: {
|
|
77
|
+
all?: number;
|
|
78
|
+
top?: number;
|
|
79
|
+
left?: number;
|
|
80
|
+
right?: number;
|
|
81
|
+
bottom?: number;
|
|
82
|
+
};
|
|
83
|
+
/** Padding options for vertical and horizontal */
|
|
84
|
+
paddingFlex?: {
|
|
85
|
+
vertical?: number;
|
|
86
|
+
horizontal?: number;
|
|
87
|
+
};
|
|
88
|
+
/** Margin options for vertical and horizontal */
|
|
89
|
+
marginFlex?: {
|
|
90
|
+
vertical?: number;
|
|
91
|
+
horizontal?: number;
|
|
92
|
+
};
|
|
93
|
+
/** Margin options for each side */
|
|
94
|
+
marginOption?: {
|
|
95
|
+
all?: number;
|
|
96
|
+
top?: number;
|
|
97
|
+
left?: number;
|
|
98
|
+
right?: number;
|
|
99
|
+
bottom?: number;
|
|
100
|
+
};
|
|
101
|
+
/** Shadow configuration options */
|
|
102
|
+
shadowOption?: {
|
|
103
|
+
color?: string;
|
|
104
|
+
width?: number;
|
|
105
|
+
height?: number;
|
|
106
|
+
opacity?: number;
|
|
107
|
+
radius?: number;
|
|
108
|
+
elevation?: number;
|
|
109
|
+
};
|
|
110
|
+
/** Custom style character */
|
|
111
|
+
styleChar?: string;
|
|
112
|
+
/** Set width to screen width */
|
|
113
|
+
widthScreen?: boolean;
|
|
114
|
+
/** Set height to screen height */
|
|
115
|
+
heightScreen?: boolean;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Main Props interface that combines TouchableWithoutFeedbackProps, PropsApp, and MakeProp
|
|
119
|
+
* @interface Props
|
|
120
|
+
*/
|
|
121
|
+
export interface Props extends TouchableWithoutFeedbackProps, PropsApp, MakeProp {
|
|
122
|
+
/** Child components */
|
|
123
|
+
children?: React.ReactNode;
|
|
124
|
+
/** Hide the component */
|
|
125
|
+
hidden?: boolean;
|
|
126
|
+
/** Opacity when pressed */
|
|
127
|
+
activeOpacity?: number;
|
|
128
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Style utility function that generates React Native styles based on provided props
|
|
3
|
+
* This function combines various style properties into a single style object
|
|
4
|
+
*
|
|
5
|
+
* @param props - Style properties object containing various style configurations
|
|
6
|
+
* @returns Array containing base styles and computed styles
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* // Basic usage
|
|
11
|
+
* <View style={Style({ mid: true, row: true })}>
|
|
12
|
+
*
|
|
13
|
+
* // With position options
|
|
14
|
+
* <View style={Style({
|
|
15
|
+
* positionOption: { top: 10, left: 20 },
|
|
16
|
+
* paddingOption: { all: 10 }
|
|
17
|
+
* })}>
|
|
18
|
+
*
|
|
19
|
+
* // With shadow
|
|
20
|
+
* <View style={Style({
|
|
21
|
+
* shadowOption: {
|
|
22
|
+
* color: '#000',
|
|
23
|
+
* width: 2,
|
|
24
|
+
* height: 2,
|
|
25
|
+
* opacity: 0.5,
|
|
26
|
+
* radius: 5
|
|
27
|
+
* }
|
|
28
|
+
* })}>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const Style: any;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { StyleSheet, Dimensions } from "react-native";
|
|
2
|
+
import { isEmpty, isString } from "underscore";
|
|
3
|
+
import { makeStyle } from "./makeStyle";
|
|
4
|
+
/**
|
|
5
|
+
* Style utility function that generates React Native styles based on provided props
|
|
6
|
+
* This function combines various style properties into a single style object
|
|
7
|
+
*
|
|
8
|
+
* @param props - Style properties object containing various style configurations
|
|
9
|
+
* @returns Array containing base styles and computed styles
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // Basic usage
|
|
14
|
+
* <View style={Style({ mid: true, row: true })}>
|
|
15
|
+
*
|
|
16
|
+
* // With position options
|
|
17
|
+
* <View style={Style({
|
|
18
|
+
* positionOption: { top: 10, left: 20 },
|
|
19
|
+
* paddingOption: { all: 10 }
|
|
20
|
+
* })}>
|
|
21
|
+
*
|
|
22
|
+
* // With shadow
|
|
23
|
+
* <View style={Style({
|
|
24
|
+
* shadowOption: {
|
|
25
|
+
* color: '#000',
|
|
26
|
+
* width: 2,
|
|
27
|
+
* height: 2,
|
|
28
|
+
* opacity: 0.5,
|
|
29
|
+
* radius: 5
|
|
30
|
+
* }
|
|
31
|
+
* })}>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export const Style = (props) => {
|
|
35
|
+
const PropsApp = StyleSheet.flatten([
|
|
36
|
+
// Layout properties
|
|
37
|
+
props.alignItems && { alignItems: props.alignItems },
|
|
38
|
+
props.justifyContent && { justifyContent: props.justifyContent },
|
|
39
|
+
props.borderStyle && { borderStyle: props.borderStyle },
|
|
40
|
+
props.overflow && { overflow: props.overflow },
|
|
41
|
+
// Border radius properties
|
|
42
|
+
props.borderUpRadius && { borderTopLeftRadius: (props.borderUpRadius), borderTopRightRadius: (props.borderUpRadius) },
|
|
43
|
+
props.borderDownRadius && { borderBottomLeftRadius: (props.borderUpRadius), borderBottomRightRadius: (props.borderUpRadius) },
|
|
44
|
+
// Layout shortcuts
|
|
45
|
+
props.mid && { alignItems: 'center', justifyContent: 'center' },
|
|
46
|
+
props.row && { flexDirection: 'row' },
|
|
47
|
+
props.width100 && { width: '100%' },
|
|
48
|
+
props.height100 && { height: '100%' },
|
|
49
|
+
props.square && { width: props.square, height: props.square },
|
|
50
|
+
props.borderCircle && { borderRadius: 1000 },
|
|
51
|
+
props.alignCenter && { alignItems: 'center' },
|
|
52
|
+
props.justifyCenter && { justifyContent: 'center' },
|
|
53
|
+
props.justifyBetween && { justifyContent: 'space-between' },
|
|
54
|
+
props.overHidden && { overflow: 'hidden' },
|
|
55
|
+
props.centerBetween && { alignItems: 'center', justifyContent: 'space-between', },
|
|
56
|
+
// Position options
|
|
57
|
+
props.positionOption && {
|
|
58
|
+
position: 'absolute',
|
|
59
|
+
top: props.positionOption?.top,
|
|
60
|
+
bottom: props.positionOption?.bottom,
|
|
61
|
+
left: props.positionOption?.left,
|
|
62
|
+
right: props.positionOption?.right,
|
|
63
|
+
},
|
|
64
|
+
// Padding options
|
|
65
|
+
props.paddingOption && {
|
|
66
|
+
paddingLeft: props.paddingOption?.all || props.paddingOption?.left,
|
|
67
|
+
paddingTop: props.paddingOption?.all || props.paddingOption?.top,
|
|
68
|
+
paddingRight: props.paddingOption?.all || props.paddingOption?.right,
|
|
69
|
+
paddingBottom: props.paddingOption?.all || props.paddingOption?.bottom,
|
|
70
|
+
},
|
|
71
|
+
// Margin options
|
|
72
|
+
props.marginOption && {
|
|
73
|
+
marginLeft: props.marginOption?.all || props.marginOption?.left,
|
|
74
|
+
marginTop: props.marginOption?.all || props.marginOption?.top,
|
|
75
|
+
marginRight: props.marginOption?.all || props.marginOption?.right,
|
|
76
|
+
marginBottom: props.marginOption?.all || props.marginOption?.bottom,
|
|
77
|
+
},
|
|
78
|
+
// Border options
|
|
79
|
+
props.borderOption && {
|
|
80
|
+
borderLeftWidth: props.borderOption.left,
|
|
81
|
+
borderTopWidth: props.borderOption.top,
|
|
82
|
+
borderBottomWidth: props.borderOption.bottom,
|
|
83
|
+
borderRightWidth: props.borderOption.right,
|
|
84
|
+
borderColor: props.borderOption.color,
|
|
85
|
+
},
|
|
86
|
+
// Shadow options
|
|
87
|
+
!isEmpty(props.shadowOption) && {
|
|
88
|
+
shadowColor: props.shadowOption?.color,
|
|
89
|
+
shadowOffset: {
|
|
90
|
+
width: props.shadowOption?.width,
|
|
91
|
+
height: props.shadowOption?.height,
|
|
92
|
+
},
|
|
93
|
+
shadowOpacity: props.shadowOption?.opacity,
|
|
94
|
+
shadowRadius: props.shadowOption?.radius,
|
|
95
|
+
elevation: props.shadowOption?.elevation,
|
|
96
|
+
},
|
|
97
|
+
// Default shadow
|
|
98
|
+
props.shadowColor && {
|
|
99
|
+
shadowColor: isString(props.shadowColor) ? props.shadowColor : '#000',
|
|
100
|
+
shadowOffset: { width: 2, height: 2, },
|
|
101
|
+
shadowOpacity: 1,
|
|
102
|
+
shadowRadius: 10,
|
|
103
|
+
elevation: 2,
|
|
104
|
+
},
|
|
105
|
+
// Width and height shortcuts
|
|
106
|
+
props.w100 && { width: '100%' },
|
|
107
|
+
props.h100 && { height: '100%' },
|
|
108
|
+
props.flex1 && { flex: 1 },
|
|
109
|
+
props.flexOne && { flex: 1 },
|
|
110
|
+
// Screen dimensions
|
|
111
|
+
props.widthScreen && { width: Dimensions.get('screen').width },
|
|
112
|
+
props.heightScreen && { height: Dimensions.get('screen').height },
|
|
113
|
+
]);
|
|
114
|
+
return [
|
|
115
|
+
makeStyle(props),
|
|
116
|
+
PropsApp,
|
|
117
|
+
];
|
|
118
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Props } from "./Props";
|
|
3
|
+
/**
|
|
4
|
+
* Touch component that extends TouchableOpacity with additional styling capabilities
|
|
5
|
+
* Supports gradient backgrounds and custom styling options
|
|
6
|
+
*
|
|
7
|
+
* @component
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* // Basic usage
|
|
11
|
+
* <Touch onPress={() => console.log('pressed')}>
|
|
12
|
+
* <Text>Press me</Text>
|
|
13
|
+
* </Touch>
|
|
14
|
+
*
|
|
15
|
+
*
|
|
16
|
+
* // With custom styling
|
|
17
|
+
* <Touch
|
|
18
|
+
* mid={true}
|
|
19
|
+
* row={true}
|
|
20
|
+
* paddingOption={{ all: 10 }}
|
|
21
|
+
* onPress={() => console.log('pressed')}
|
|
22
|
+
* >
|
|
23
|
+
* <Text>Styled Button</Text>
|
|
24
|
+
* </Touch>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare const Touch: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<import("react-native").View>>;
|
|
28
|
+
export default Touch;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TouchableOpacity } from "react-native";
|
|
3
|
+
import { Style } from "./Style";
|
|
4
|
+
/**
|
|
5
|
+
* Touch component that extends TouchableOpacity with additional styling capabilities
|
|
6
|
+
* Supports gradient backgrounds and custom styling options
|
|
7
|
+
*
|
|
8
|
+
* @component
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* // Basic usage
|
|
12
|
+
* <Touch onPress={() => console.log('pressed')}>
|
|
13
|
+
* <Text>Press me</Text>
|
|
14
|
+
* </Touch>
|
|
15
|
+
*
|
|
16
|
+
*
|
|
17
|
+
* // With custom styling
|
|
18
|
+
* <Touch
|
|
19
|
+
* mid={true}
|
|
20
|
+
* row={true}
|
|
21
|
+
* paddingOption={{ all: 10 }}
|
|
22
|
+
* onPress={() => console.log('pressed')}
|
|
23
|
+
* >
|
|
24
|
+
* <Text>Styled Button</Text>
|
|
25
|
+
* </Touch>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
const Touch = React.forwardRef(({ style, ...props }, ref) => {
|
|
29
|
+
if (props?.hidden)
|
|
30
|
+
return <></>;
|
|
31
|
+
return (<TouchableOpacity ref={ref} activeOpacity={props.activeOpacity || 0.5} style={[Style(props), style]} {...props}>
|
|
32
|
+
{props.children}
|
|
33
|
+
</TouchableOpacity>);
|
|
34
|
+
});
|
|
35
|
+
export default Touch;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ViewProps } from "react-native";
|
|
3
|
+
import { Props } from "./Props";
|
|
4
|
+
interface ButtonScaleProps extends Props {
|
|
5
|
+
scaleValue?: number;
|
|
6
|
+
scale?: boolean;
|
|
7
|
+
containerStyle?: ViewProps["style"];
|
|
8
|
+
}
|
|
9
|
+
declare const Touch: React.ForwardRefExoticComponent<Omit<ButtonScaleProps, "ref"> & React.RefAttributes<import("react-native").View>>;
|
|
10
|
+
export default Touch;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import { Animated, TouchableOpacity } from "react-native";
|
|
3
|
+
import { Style } from "./Style";
|
|
4
|
+
const Touch = React.forwardRef(({ scaleValue = 1.1, style, background, containerStyle, ...props }, ref) => {
|
|
5
|
+
if (props?.hidden)
|
|
6
|
+
return <></>;
|
|
7
|
+
const animatedButtonScale = React.useRef(new Animated.Value(1)).current;
|
|
8
|
+
const onPressIn = useCallback(() => {
|
|
9
|
+
Animated.spring(animatedButtonScale, {
|
|
10
|
+
toValue: scaleValue,
|
|
11
|
+
useNativeDriver: true,
|
|
12
|
+
}).start();
|
|
13
|
+
}, [scaleValue]);
|
|
14
|
+
const onPressOut = useCallback(() => {
|
|
15
|
+
Animated.spring(animatedButtonScale, {
|
|
16
|
+
toValue: 1,
|
|
17
|
+
useNativeDriver: true,
|
|
18
|
+
}).start();
|
|
19
|
+
}, []);
|
|
20
|
+
return (<TouchableOpacity ref={ref} onPressIn={onPressIn} onPressOut={onPressOut} activeOpacity={props.activeOpacity || 1} style={containerStyle} {...props}>
|
|
21
|
+
<Animated.View style={[
|
|
22
|
+
{ transform: [{ scale: animatedButtonScale }] },
|
|
23
|
+
Style(props),
|
|
24
|
+
style,
|
|
25
|
+
]}>
|
|
26
|
+
{props.children}
|
|
27
|
+
</Animated.View>
|
|
28
|
+
</TouchableOpacity>);
|
|
29
|
+
});
|
|
30
|
+
export default Touch;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ViewStyle } from "react-native";
|
|
2
|
+
declare enum COLORS {
|
|
3
|
+
"white" = 1,
|
|
4
|
+
"red" = 2,
|
|
5
|
+
"blue" = 3,
|
|
6
|
+
"black" = 4,
|
|
7
|
+
"green" = 5,
|
|
8
|
+
"yellow" = 6,
|
|
9
|
+
"pink" = 7,
|
|
10
|
+
"gray" = 8,
|
|
11
|
+
"primary" = 9
|
|
12
|
+
}
|
|
13
|
+
declare const PROPS: {
|
|
14
|
+
readonly bg: "backgroundColor";
|
|
15
|
+
readonly background: "backgroundColor";
|
|
16
|
+
readonly w: "width";
|
|
17
|
+
readonly width: "width";
|
|
18
|
+
readonly minW: "minWidth";
|
|
19
|
+
readonly maxW: "maxWidth";
|
|
20
|
+
readonly h: "height";
|
|
21
|
+
readonly height: "height";
|
|
22
|
+
readonly minH: "minHeight";
|
|
23
|
+
readonly maxH: "maxHeight";
|
|
24
|
+
readonly pad: "padding";
|
|
25
|
+
readonly padH: "paddingHorizontal";
|
|
26
|
+
readonly horizontal: "paddingHorizontal";
|
|
27
|
+
readonly padV: "paddingVertical";
|
|
28
|
+
readonly vertical: "paddingVertical";
|
|
29
|
+
readonly padL: "paddingLeft";
|
|
30
|
+
readonly padT: "paddingTop";
|
|
31
|
+
readonly padR: "paddingRight";
|
|
32
|
+
readonly padB: "paddingBottom";
|
|
33
|
+
readonly mar: "margin";
|
|
34
|
+
readonly marH: "marginHorizontal";
|
|
35
|
+
readonly marV: "marginVertical";
|
|
36
|
+
readonly marL: "marginLeft";
|
|
37
|
+
readonly marT: "marginTop";
|
|
38
|
+
readonly marR: "marginRight";
|
|
39
|
+
readonly marB: "marginBottom";
|
|
40
|
+
readonly border: "borderWidth";
|
|
41
|
+
readonly borderW: "borderWidth";
|
|
42
|
+
readonly borderR: "borderRadius";
|
|
43
|
+
readonly radius: "borderRadius";
|
|
44
|
+
readonly borderC: "borderColor";
|
|
45
|
+
readonly borderLW: "borderLeftWidth";
|
|
46
|
+
readonly borderTW: "borderTopWidth";
|
|
47
|
+
readonly borderRW: "borderRightWidth";
|
|
48
|
+
readonly borderBW: "borderBottomWidth";
|
|
49
|
+
readonly flex: "flex";
|
|
50
|
+
readonly zIndex: "zIndex";
|
|
51
|
+
readonly left: "left";
|
|
52
|
+
readonly top: "top";
|
|
53
|
+
readonly bottom: "bottom";
|
|
54
|
+
readonly right: "right";
|
|
55
|
+
readonly opacity: "opacity";
|
|
56
|
+
};
|
|
57
|
+
export type ColorKey = keyof typeof COLORS;
|
|
58
|
+
export type ShortKey = keyof typeof PROPS;
|
|
59
|
+
export type Convert<T extends string> = Partial<Record<T, boolean | number | string>>;
|
|
60
|
+
export type MakeProp = Partial<Record<ShortKey, number | string>> & Partial<Record<ColorKey, boolean>> & Record<string, any>;
|
|
61
|
+
export declare const makeStyle: <T>(props: {
|
|
62
|
+
[key: string]: any;
|
|
63
|
+
}) => ViewStyle;
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { isNaN } from "underscore";
|
|
3
|
+
var COLORS;
|
|
4
|
+
(function (COLORS) {
|
|
5
|
+
COLORS[COLORS["white"] = 1] = "white";
|
|
6
|
+
COLORS[COLORS["red"] = 2] = "red";
|
|
7
|
+
COLORS[COLORS["blue"] = 3] = "blue";
|
|
8
|
+
COLORS[COLORS["black"] = 4] = "black";
|
|
9
|
+
COLORS[COLORS["green"] = 5] = "green";
|
|
10
|
+
COLORS[COLORS["yellow"] = 6] = "yellow";
|
|
11
|
+
COLORS[COLORS["pink"] = 7] = "pink";
|
|
12
|
+
COLORS[COLORS["gray"] = 8] = "gray";
|
|
13
|
+
COLORS[COLORS["primary"] = 9] = "primary";
|
|
14
|
+
})(COLORS || (COLORS = {}));
|
|
15
|
+
const PROPS = {
|
|
16
|
+
bg: "backgroundColor",
|
|
17
|
+
background: "backgroundColor",
|
|
18
|
+
w: "width",
|
|
19
|
+
width: "width",
|
|
20
|
+
minW: "minWidth",
|
|
21
|
+
maxW: "maxWidth",
|
|
22
|
+
h: "height",
|
|
23
|
+
height: "height",
|
|
24
|
+
minH: "minHeight",
|
|
25
|
+
maxH: "maxHeight",
|
|
26
|
+
pad: "padding",
|
|
27
|
+
padH: "paddingHorizontal",
|
|
28
|
+
horizontal: "paddingHorizontal",
|
|
29
|
+
padV: "paddingVertical",
|
|
30
|
+
vertical: "paddingVertical",
|
|
31
|
+
padL: "paddingLeft",
|
|
32
|
+
padT: "paddingTop",
|
|
33
|
+
padR: "paddingRight",
|
|
34
|
+
padB: "paddingBottom",
|
|
35
|
+
mar: "margin",
|
|
36
|
+
marH: "marginHorizontal",
|
|
37
|
+
marV: "marginVertical",
|
|
38
|
+
marL: "marginLeft",
|
|
39
|
+
marT: "marginTop",
|
|
40
|
+
marR: "marginRight",
|
|
41
|
+
marB: "marginBottom",
|
|
42
|
+
border: 'borderWidth',
|
|
43
|
+
borderW: 'borderWidth',
|
|
44
|
+
borderR: "borderRadius",
|
|
45
|
+
radius: "borderRadius",
|
|
46
|
+
borderC: "borderColor",
|
|
47
|
+
borderLW: "borderLeftWidth",
|
|
48
|
+
borderTW: "borderTopWidth",
|
|
49
|
+
borderRW: "borderRightWidth",
|
|
50
|
+
borderBW: "borderBottomWidth",
|
|
51
|
+
flex: 'flex',
|
|
52
|
+
zIndex: 'zIndex',
|
|
53
|
+
left: 'left',
|
|
54
|
+
top: 'top',
|
|
55
|
+
bottom: 'bottom',
|
|
56
|
+
right: 'right',
|
|
57
|
+
opacity: 'opacity'
|
|
58
|
+
};
|
|
59
|
+
const isColorKey = (key) => {
|
|
60
|
+
return key in COLORS;
|
|
61
|
+
};
|
|
62
|
+
const isShortKey = (key) => {
|
|
63
|
+
return key in PROPS;
|
|
64
|
+
};
|
|
65
|
+
export const makeStyle = (props) => {
|
|
66
|
+
const style = {};
|
|
67
|
+
Object.keys(props).forEach((key) => {
|
|
68
|
+
const match = key.match(/^(\w+)-(\w+)$/);
|
|
69
|
+
// 🎨 Color
|
|
70
|
+
if (isColorKey(key)) {
|
|
71
|
+
style.backgroundColor = key;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// 🔹 Hyphen syntax (pad-10)
|
|
75
|
+
if (match) {
|
|
76
|
+
const [, rawKey, rawValue] = match;
|
|
77
|
+
const value = isNaN(Number(rawValue))
|
|
78
|
+
? rawValue
|
|
79
|
+
: Number(rawValue);
|
|
80
|
+
if (isShortKey(rawKey)) {
|
|
81
|
+
style[PROPS[rawKey]] = value;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
style[rawKey] = value;
|
|
85
|
+
}
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
// 🔹 Normal props
|
|
89
|
+
if (isShortKey(key)) {
|
|
90
|
+
style[PROPS[key]] = props[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return StyleSheet.create({ style }).style;
|
|
94
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function sliceTextAndNumber(input) {
|
|
2
|
+
let text = "";
|
|
3
|
+
let number = "";
|
|
4
|
+
let mid = false;
|
|
5
|
+
for (let i = 0; i < input.length; i++) {
|
|
6
|
+
const currentChar = input[i];
|
|
7
|
+
if (!isNaN(parseInt(currentChar)) && mid == false) {
|
|
8
|
+
mid = i;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
if (mid) {
|
|
12
|
+
text = input.slice(0, mid);
|
|
13
|
+
number = input.slice(mid);
|
|
14
|
+
}
|
|
15
|
+
// Log.d('mid', { mid, text, number })
|
|
16
|
+
return {
|
|
17
|
+
text: mid ? text : null,
|
|
18
|
+
number: mid ? Number(number) : null,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function replaceAll(str = '', search = '', replacement = '') {
|
|
22
|
+
return str.replace(new RegExp(search, 'g'), replacement); //[g] ~~ search global
|
|
23
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ui-rn",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"repository": "https://github.com/package-dev/ui-rn",
|
|
5
5
|
"description": "ui-rn",
|
|
6
6
|
"author": "Phamha98",
|
|
7
|
-
"main": "
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
8
9
|
"peerDependencies": {
|
|
9
10
|
"react": ">=18",
|
|
10
11
|
"react-native": ">=0.70"
|
|
@@ -24,10 +25,11 @@
|
|
|
24
25
|
"typescript": "^5.9.3"
|
|
25
26
|
},
|
|
26
27
|
"scripts": {
|
|
27
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
28
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
29
|
+
"build": "npx tsc"
|
|
28
30
|
},
|
|
29
31
|
"license": "ISC",
|
|
30
32
|
"keywords": [
|
|
31
33
|
"ui-rn"
|
|
32
34
|
]
|
|
33
|
-
}
|
|
35
|
+
}
|
package/src/Text/makeStyle.ts
CHANGED
package/src/global.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module 'react-native-vector-icons/*';
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
|
|
6
|
+
// 👇 FIX LỖI CHÍNH
|
|
7
|
+
"moduleResolution": "node",
|
|
8
|
+
|
|
9
|
+
// ❌ BỎ DOM đi
|
|
10
|
+
"lib": ["ESNext"],
|
|
11
|
+
|
|
12
|
+
// 👇 CHO REACT NATIVE
|
|
13
|
+
"jsx": "react-native",
|
|
14
|
+
|
|
15
|
+
"declaration": true,
|
|
16
|
+
"outDir": "dist",
|
|
17
|
+
|
|
18
|
+
"esModuleInterop": true,
|
|
19
|
+
"skipLibCheck": true, // 👈 cực quan trọng (giảm 90% lỗi)
|
|
20
|
+
"strict": true
|
|
21
|
+
},
|
|
22
|
+
"include": ["src"]
|
|
23
|
+
}
|