Skip to content

Commit 9f67f84

Browse files
feat: add type definitions
1 parent 88526b4 commit 9f67f84

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed

index.d.ts

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import React from 'react';
2+
import {
3+
ImageSourcePropType,
4+
NativeScrollEvent,
5+
NativeSyntheticEvent,
6+
TextStyle,
7+
ViewStyle,
8+
} from 'react-native';
9+
10+
export interface HeaderTypeProp {
11+
type?: 'TabbedHeader' | 'DetailsHeader' | 'AvatarHeader'
12+
}
13+
14+
export interface HeaderSizeProps {
15+
height: number;
16+
width: number;
17+
x: number;
18+
y: number;
19+
}
20+
21+
export interface OnChangeTabArguments {
22+
from: number;
23+
i: number;
24+
ref: any;
25+
}
26+
27+
export interface Tab {
28+
content: React.ReactElement;
29+
title: string;
30+
}
31+
32+
export interface SharedProps {
33+
backgroundColor: string;
34+
backgroundImage?: ImageSourcePropType;
35+
headerHeight?: number;
36+
snapToEdge?: boolean;
37+
bounces: boolean;
38+
39+
}
40+
41+
export interface IconProps {
42+
leftTopIcon?: ImageSourcePropType;
43+
leftTopIconOnPress?: () => void;
44+
rightTopIcon?: ImageSourcePropType;
45+
rightTopIconOnPress?: () => void;
46+
}
47+
48+
export interface TabsSharedProps {
49+
tabTextActiveStyle: TextStyle;
50+
tabTextContainerActiveStyle: ViewStyle;
51+
tabTextContainerStyle: ViewStyle;
52+
tabTextStyle: TextStyle;
53+
tabWrapperStyle: ViewStyle;
54+
tabs: Tab[];
55+
tabsContainerStyle: ViewStyle;
56+
}
57+
58+
59+
export interface TabbedHeaderProps extends SharedProps, TabsSharedProps {
60+
foregroundImage: ImageSourcePropType;
61+
header: () => React.ReactElement;
62+
logo: ImageSourcePropType;
63+
logoContainerStyle: ViewStyle;
64+
logoResizeMode: string;
65+
logoStyle: ViewStyle;
66+
renderBody: (title: string) => React.ReactElement;
67+
scrollEvent: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
68+
title: string;
69+
titleStyle: TextStyle;
70+
}
71+
72+
export interface DetailsHeaderProps extends SharedProps, IconProps {
73+
hasBorderRadius: boolean;
74+
iconNumber: number;
75+
image: number;
76+
renderBody: (title: string) => React.ReactElement;
77+
tag: string;
78+
title: string;
79+
}
80+
81+
export interface AvatarHeaderProps extends SharedProps, IconProps {
82+
foreground: () => React.ReactElement;
83+
hasBorderRadius: boolean;
84+
header: () => React.ReactElement;
85+
image: number;
86+
parallaxHeight: number;
87+
renderBody: (title: string) => React.ReactElement;
88+
scrollEvent: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
89+
snapStartThreshold: boolean | number;
90+
snapStopThreshold: boolean | number;
91+
snapValue: boolean | number;
92+
subtitle: string;
93+
title: string;
94+
transparentHeader: boolean;
95+
}
96+
97+
export interface CustomHeaderProps extends SharedProps, TabsSharedProps {
98+
background: React.ReactElement;
99+
children: React.ReactElement;
100+
foreground: React.ReactElement;
101+
header: React.ReactElement;
102+
headerSize?: ({ x, y, width, height }: HeaderSizeProps) => void;
103+
initialPage: number;
104+
onChangeTab?: ({ i, ref, from }: OnChangeTabArguments) => void;
105+
onEndReached?: () => void;
106+
parallaxHeight: number;
107+
scrollEvent: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
108+
snapStartThreshold: boolean | number;
109+
snapStopThreshold: boolean | number;
110+
snapValue: boolean | number;
111+
tabsContainerBackgroundColor: string;
112+
transparentHeader: boolean;
113+
}
114+
115+
type StickyParallaxHeaderProps = HeaderTypeProp & (DetailsHeaderProps | AvatarHeaderProps | TabbedHeaderProps | CustomHeaderProps)
116+
117+
export default class StickyParallaxHeader extends React.Component<StickyParallaxHeaderProps, any> { }

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "react-native-sticky-parallax-header",
33
"version": "0.2.1",
44
"main": "src/index.js",
5+
"types": "src/index.d.ts",
56
"repository": "https://github.com/netguru/sticky-parallax-header",
67
"author": "IdaszakDaniel <idaszak1@gmail.com>",
78
"license": "MIT",

0 commit comments

Comments
 (0)