Skip to content

Commit ea54b40

Browse files
feat: UNT-T22344: TypeScript Support
1 parent 74cb676 commit ea54b40

38 files changed

+1264
-1003
lines changed

components/AnimatableView.js

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React from "react";
2+
import * as Animatable from "react-native-animatable";
3+
import SpinnerComponent from "../SpinnerComponent/SpinnerComponent";
4+
import type { AnimatableViewProps } from "./types";
5+
import styles from "../styles/SpinnerButtonStyle";
6+
7+
const AnimatableView: React.FC<AnimatableViewProps> = ({
8+
animationType,
9+
children,
10+
customSpinnerComponent,
11+
height,
12+
size,
13+
spinnerColor,
14+
spinnerType,
15+
indicatorCount,
16+
spinnerOptions,
17+
isLoading,
18+
animatedDuration,
19+
}: AnimatableViewProps) => {
20+
const isCustomeSpinner: boolean =
21+
customSpinnerComponent !== null && customSpinnerComponent !== undefined;
22+
return (
23+
<>
24+
{!isLoading && (
25+
<Animatable.View animation={animationType} duration={animatedDuration}>
26+
{children}
27+
</Animatable.View>
28+
)}
29+
{isLoading && (
30+
<Animatable.View
31+
animation={animationType}
32+
duration={animatedDuration}
33+
style={styles.absoluteView}
34+
>
35+
{isCustomeSpinner && customSpinnerComponent}
36+
{!isCustomeSpinner && (
37+
<SpinnerComponent
38+
height={height}
39+
size={size}
40+
spinnerColor={spinnerColor}
41+
spinnerType={spinnerType}
42+
indicatorCount={indicatorCount}
43+
spinnerOptions={spinnerOptions}
44+
/>
45+
)}
46+
</Animatable.View>
47+
)}
48+
</>
49+
);
50+
};
51+
52+
export default AnimatableView;

components/AnimatableView/types.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import type { ColorValue } from "react-native";
2+
import type { SpinnerOptionsProp } from "../SpinnerButton/types";
3+
4+
export type SpinnerType =
5+
| "barindicator"
6+
| "dotindicator"
7+
| "materialindicator"
8+
| "pacmanindicator"
9+
| "pulseindicator"
10+
| "skypeindicator"
11+
| "uiactivityindicator"
12+
| "waveindicator";
13+
14+
export type CommonViewProps = {
15+
children: JSX.Element;
16+
customSpinnerComponent?: JSX.Element;
17+
height: number;
18+
size: number;
19+
spinnerColor: ColorValue;
20+
spinnerType: SpinnerType;
21+
indicatorCount: number;
22+
spinnerOptions: SpinnerOptionsProp;
23+
};
24+
25+
export type AnimatableViewProps = CommonViewProps & {
26+
animationType: string;
27+
isLoading?: boolean;
28+
animatedDuration?: number;
29+
};

components/AnimatedView.js

Lines changed: 0 additions & 58 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React from "react";
2+
import { Animated } from "react-native";
3+
import SpinnerComponent from "../SpinnerComponent/SpinnerComponent";
4+
import type { AnimatedViewProps } from "./types";
5+
import styles from "../styles/SpinnerButtonStyle";
6+
7+
const AnimatedView: React.FC<AnimatedViewProps> = ({
8+
animatedChildHideStyle,
9+
animatedChildShowStyle,
10+
children,
11+
customSpinnerComponent,
12+
height,
13+
size,
14+
spinnerColor,
15+
spinnerType,
16+
indicatorCount,
17+
spinnerOptions,
18+
}: AnimatedViewProps) => {
19+
const isCustomeSpinner: boolean =
20+
customSpinnerComponent !== null && customSpinnerComponent !== undefined;
21+
return (
22+
<>
23+
<Animated.View style={animatedChildHideStyle}>{children}</Animated.View>
24+
<Animated.View style={[styles.absoluteView, animatedChildShowStyle]}>
25+
{isCustomeSpinner && customSpinnerComponent}
26+
{!isCustomeSpinner && (
27+
<SpinnerComponent
28+
height={height}
29+
size={size}
30+
spinnerColor={spinnerColor}
31+
spinnerType={spinnerType}
32+
indicatorCount={indicatorCount}
33+
spinnerOptions={spinnerOptions}
34+
/>
35+
)}
36+
</Animated.View>
37+
</>
38+
);
39+
};
40+
41+
export default AnimatedView;

components/AnimatedView/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Animated } from "react-native";
2+
import type { ViewStyle } from "react-native";
3+
import type { CommonViewProps } from "../AnimatableView/types";
4+
5+
type AnimatedStyle = Animated.WithAnimatedValue<ViewStyle>;
6+
7+
export type AnimatedViewProps = CommonViewProps & {
8+
animatedChildHideStyle?: AnimatedStyle;
9+
animatedChildShowStyle?: AnimatedStyle;
10+
};

components/ChildrenView.js

Lines changed: 0 additions & 73 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import React from "react";
2+
import LinearGradient from "../LinearGradient/LinearGradient";
3+
import RadialGradient from "../RadialGradient/RadialGradient";
4+
import type { ChildrenViewProps } from "./types";
5+
6+
const ChildrenView: React.FC<ChildrenViewProps> = ({
7+
animatedStyles,
8+
gradientType,
9+
gradientColors,
10+
gradientColoroffset,
11+
gradientColorAngle,
12+
gradientRadialRadius,
13+
gradientButtonHeight,
14+
radialRadiusx,
15+
radialRadiusy,
16+
radialRadiusRX,
17+
radialRadiusRY,
18+
children,
19+
gradientName,
20+
}: ChildrenViewProps) => {
21+
const isLinearGradient: boolean = gradientType?.trim()?.toLowerCase() === "linear";
22+
const isRadialGradient: boolean = gradientType?.trim()?.toLowerCase() === "radial";
23+
24+
if (isLinearGradient) {
25+
return (
26+
<LinearGradient
27+
angle={gradientColorAngle || 90}
28+
children={children}
29+
animatedStyles={animatedStyles}
30+
gradientColoroffset={gradientColoroffset}
31+
gradientColors={gradientColors}
32+
gradientName={gradientName}
33+
gradientRadialRadius={gradientRadialRadius}
34+
gradientButtonHeight={gradientButtonHeight}
35+
/>
36+
);
37+
} else if (isRadialGradient) {
38+
return (
39+
<RadialGradient
40+
radialRadiusx={radialRadiusx}
41+
radialRadiusy={radialRadiusy}
42+
radialRadiusRX={radialRadiusRX}
43+
radialRadiusRY={radialRadiusRY}
44+
children={children}
45+
gradientName={gradientName}
46+
animatedStyles={animatedStyles}
47+
gradientColoroffset={gradientColoroffset}
48+
gradientColors={gradientColors}
49+
gradientRadialRadius={gradientRadialRadius}
50+
gradientButtonHeight={gradientButtonHeight}
51+
/>
52+
);
53+
} else {
54+
return children;
55+
}
56+
};
57+
58+
export default ChildrenView;

0 commit comments

Comments
 (0)