Skip to content

Commit b882e29

Browse files
authored
updated typings (#118)
1 parent 56d72b3 commit b882e29

File tree

6 files changed

+39
-8
lines changed

6 files changed

+39
-8
lines changed

src/components/Actions.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const Actions = ({
1919
alert('🎉🎉🎉copied!🎉🎉🎉');
2020
};
2121
return (
22-
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
22+
<View style={s.row}>
2323
<View>
2424
<TouchableOpacity onPress={handleSetting} style={s.setting}>
2525
<SettingIcon fill={'#000'} height={30} width={30} />
@@ -36,6 +36,7 @@ export const Actions = ({
3636
};
3737

3838
const s = StyleSheet.create((theme) => ({
39+
row: { flexDirection: 'row', alignItems: 'center' },
3940
setting: {
4041
height: 50,
4142
paddingHorizontal: 15,

src/components/InputSection.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import {
88
AnimationTypes,
99
ConfigType,
1010
DEFAULT_MAX_LIMIT,
11+
SpringConfigType,
1112
SpringLimitType,
1213
StateType,
1314
Step,
15+
TimingConfigType,
1416
} from 'src/constants';
1517
import { Tabs } from './Tabs';
1618
import { WithTiming } from './WithTiming';
@@ -88,15 +90,16 @@ export const InputSection = ({
8890
{state.animationType === 'timing' && (
8991
<WithTiming
9092
handleChange={handleChange}
91-
config={state.config}
93+
config={state.config as TimingConfigType}
9294
onPlay={onPlay}
9395
handleSetting={toggleModal}
9496
/>
9597
)}
9698

9799
{state.animationType === 'spring' && (
98100
<WithSprings
99-
config={state.config}
101+
config={state.config as
102+
}
100103
limit={LIMIT}
101104
step={Step}
102105
handleChange={handleChange}

src/components/Tabs.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@ import { AnimationTypes } from 'src/constants';
55
import Timing from 'src/assets/Timing';
66
import Spring from 'src/assets/Spring';
77

8-
const Chip = ({ title, onPress, active, Icon }) => {
8+
const Chip = ({
9+
title,
10+
onPress,
11+
active,
12+
Icon,
13+
}: {
14+
title: string;
15+
onPress: (...args: any) => any;
16+
active: boolean;
17+
Icon: typeof React.Component;
18+
}) => {
919
const { theme } = StyleSheet;
1020

1121
return (
@@ -47,12 +57,14 @@ export const Tabs = ({
4757
onPress={() => handleAnimationType('spring')}
4858
title="Spring"
4959
active={active === 'spring'}
60+
// @ts-expect-error
5061
Icon={Spring}
5162
/>
5263
<Chip
5364
onPress={() => handleAnimationType('timing')}
5465
title="Timing"
5566
active={active === 'timing'}
67+
// @ts-expect-error
5668
Icon={Timing}
5769
/>
5870
</View>
@@ -70,7 +82,6 @@ const s = StyleSheet.create((theme) => ({
7082
},
7183
headBox: {
7284
flex: 1,
73-
// backgroundColor: 'red',
7485
textAlign: 'center',
7586
paddingVertical: 10,
7687
marginHorizontal: 3,
@@ -80,7 +91,6 @@ const s = StyleSheet.create((theme) => ({
8091
textAlign: 'center',
8192
},
8293
chipContainer: {
83-
// borderWidth: 1,
8494
borderColor: theme.primary,
8595
marginRight: 15,
8696
borderRadius: 100,

src/components/WithSpring.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export const WithSprings = ({
1616
config: SpringConfigType;
1717
limit: SpringLimitType;
1818
handleChange: (a: Partial<ConfigType>) => void;
19+
onPlay: () => void;
20+
handleSetting: () => void;
1921
}) => {
2022
const handleCopy = () => {
2123
Clipboard.setString(JSON.stringify(config));

src/components/WithTiming.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,23 @@ import { camelCaseToNormal, isFunction } from 'src/utils';
55
import { Slider } from './Slider';
66
import { Select } from './Select';
77
import { InputRenderer } from './InputRenderer';
8+
import { ConfigType, TimingConfigType } from 'src/constants';
89

910
const withTimingData = Object.keys(EasingConfig).map((d) => {
1011
return { label: d, value: d };
1112
});
1213

13-
export const WithTiming = ({ handleChange, config, onPlay, handleSetting }) => {
14+
export const WithTiming = ({
15+
handleChange,
16+
config,
17+
onPlay,
18+
handleSetting,
19+
}: {
20+
config: TimingConfigType;
21+
handleChange: (a: Partial<ConfigType>) => void;
22+
onPlay: () => void;
23+
handleSetting: () => void;
24+
}) => {
1425
const [ease, setEase] = React.useState('linear');
1526
const [numSlider, setNumSlider] = React.useState({ show: false, value: 2 });
1627

src/screen/HomeScreen.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ const reducer = (state: StateType, action: ActionTypes) => {
3939

4040
export const HomeScreen = () => {
4141
const x = useSharedValue(0);
42-
const [state, dispatch] = useReducer(reducer, DefaultState);
42+
const [state, dispatch] = useReducer<
43+
(state: StateType, actions: ActionTypes) => StateType
44+
>(reducer, DefaultState);
4345
useTheme();
4446

4547
const handleChange = (payload: Partial<ConfigType>) => {
@@ -58,8 +60,10 @@ export const HomeScreen = () => {
5860
const onPlay = () => {
5961
cancelAnimation(x);
6062
if (state.animationType === 'timing') {
63+
// @ts-expect-error
6164
x.value = withTiming(x.value === 0 ? 1 : 0, state.config);
6265
} else {
66+
// @ts-expect-error
6367
x.value = withSpring(x.value === 0 ? 1 : 0, state.config);
6468
}
6569
};

0 commit comments

Comments
 (0)