Skip to content

Commit 4bee561

Browse files
committed
Add type definition file
1 parent f9e13ca commit 4bee561

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"react-native": "*",
2828
"react": "*"
2929
},
30+
"types": "src/index.d.ts",
3031
"devDependencies": {
3132
"@types/react": "^16.4.6",
3233
"@types/react-native": "^0.55.27",

src/index.d.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**
2+
* Utility class for opening http or https URL in Custom Tabs.
3+
*/
4+
export class CustomTabs {
5+
6+
/**
7+
* Opens the URL on Custom Tab.
8+
*
9+
* @param url the Uri to be opened.
10+
* @param option the Option to customize Custom Tabs of look & feel.
11+
*/
12+
static openURL(url: string, option: TabOption = {}): Promise<boolean>;
13+
}
14+
15+
/**
16+
* Options to customize Custom Tabs of look & feel.
17+
*/
18+
export interface TabOption {
19+
20+
/**
21+
* the Toolbar color.
22+
* Supported formats are: #RRGGBB, #AARRGGBB, etc.
23+
*
24+
* {@link http://d.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String) Color.parseColor(String)}
25+
*/
26+
toolbarColor?: string;
27+
28+
/**
29+
* Enables the url bar to hide as the user scrolls down on the page.
30+
*/
31+
enableUrlBarHiding?: boolean;
32+
33+
/**
34+
* Sets whether the title should be shown in the custom tab.
35+
*/
36+
showPageTitle?: boolean;
37+
38+
/**
39+
* Whether to add a default shared items of the menu.
40+
*/
41+
enableDefaultShare?: boolean;
42+
43+
/**
44+
* Sets the exit and start animations.
45+
*
46+
* Each property needs to be an Andrion animation resource ID,
47+
* e.g. 'com.github.droibit.android.reactnative.customtabs.example:anim/slide_out_bottom'
48+
*
49+
* @see ANIMATIONS_FADE
50+
* @see ANIMATIONS_SLIDE
51+
*/
52+
animations?: Animations;
53+
54+
/**
55+
* Sets any custom headers that should be used.
56+
*/
57+
headers?: any;
58+
59+
/**
60+
* Workaround that Custom Tabs doesn't close on redirecting back to app scheme.
61+
*/
62+
forceCloseOnRedirection?: boolean;
63+
}
64+
65+
/**
66+
* Custom Tabs start and end Animation.
67+
*/
68+
export interface Animations {
69+
startEnter: string;
70+
startExit: string;
71+
endEnter: string;
72+
endExit: string;
73+
}
74+
75+
/**
76+
* Fade in at start, Fade out at exit.
77+
*/
78+
export const ANIMATIONS_FADE: Animations;
79+
80+
/**
81+
* Slide in from left at start, Slide out to right.at exit.
82+
*/
83+
export const ANIMATIONS_SLIDE: Animations;

0 commit comments

Comments
 (0)