Skip to content

Commit

Permalink
removing WithReanimated
Browse files Browse the repository at this point in the history
  • Loading branch information
ilz5753 committed Dec 15, 2023
1 parent d72bbd7 commit 5bbdfc5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ilz5753/rnutils",
"version": "0.1.8",
"version": "0.1.9",
"description": "React Native Utils",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
57 changes: 28 additions & 29 deletions src/dynamicStyles/reanimated.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isEqual, isFunction } from 'lodash';
import React, { Component, useEffect, type ComponentType } from 'react';
import { isEqual } from 'lodash';
import { useEffect } from 'react';
import {
ActivityIndicator,
FlatList,
Expand All @@ -21,7 +21,6 @@ import Animated, {
useAnimatedStyle,
useDerivedValue,
useSharedValue,
type AnimateProps,
type DerivedValue,
type SharedValue,
} from 'react-native-reanimated';
Expand Down Expand Up @@ -640,29 +639,29 @@ export function useDimensionSizesStyle({
}

const $ = Animated.createAnimatedComponent;
export function WithAnimated<T extends object>(Comp: ComponentType<T>) {
type RT = Readonly<AnimateProps<T>>;
class WAC extends Component<T> {
render = () => {
let C = Comp as any;
return <C {...this.props} />;
};
}
const AnimatedComponent = $(isFunction(Comp) ? WAC : Comp) as any;
class Res<T> extends Component<T> {
render = () => <AnimatedComponent {...this.props} />;
}
return Res<RT>;
}
export const ReView = WithAnimated(View);
export const ReScrollView = WithAnimated(ScrollView);
export const ReText = WithAnimated(Text);
export const ReTextInput = WithAnimated(TextInput);
export const ReImage = WithAnimated(Image);
export const ReImageBackground = WithAnimated(ImageBackground);
export const ReActivityIndicator = WithAnimated(ActivityIndicator);
export const ReFlatList = WithAnimated(FlatList);
export const ReSectionList = WithAnimated(SectionList);
export const ReKeyboardAvoidingView = WithAnimated(KeyboardAvoidingView);
export const ReTouchableOpacity = WithAnimated(TouchableOpacity);
export const ReTouchableHighlight = WithAnimated(TouchableHighlight);
// export function WithAnimated<T extends object>(Comp: ComponentType<T>) {
// type RT = Readonly<AnimateProps<T>>;
// class WAC extends Component<T> {
// render = () => {
// let C = Comp as any;
// return <C {...this.props} />;
// };
// }
// const AnimatedComponent = $(isFunction(Comp) ? WAC : Comp) as any;
// class Res<T> extends Component<T> {
// render = () => <AnimatedComponent {...this.props} />;
// }
// return Res<RT>;
// }
export const ReView = $(View);
export const ReScrollView = $(ScrollView);
export const ReText = $(Text);
export const ReTextInput = $(TextInput);
export const ReImage = $(Image);
export const ReImageBackground = $(ImageBackground);
export const ReActivityIndicator = $(ActivityIndicator);
export const ReFlatList = $(FlatList);
export const ReSectionList = $(SectionList);
export const ReKeyboardAvoidingView = $(KeyboardAvoidingView);
export const ReTouchableOpacity = $(TouchableOpacity);
export const ReTouchableHighlight = $(TouchableHighlight);
1 change: 0 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export {
ReTouchableHighlight,
ReTouchableOpacity,
ReView,
WithAnimated,
numberPercentRegex,
useCacheShareValue,
useColorStyle,
Expand Down

0 comments on commit 5bbdfc5

Please sign in to comment.