Skip to content

Commit 2feb180

Browse files
committed
Revert "Create TabControllerProps namespace"
This reverts commit cd52f05.
1 parent ede0f36 commit 2feb180

File tree

9 files changed

+81
-96
lines changed

9 files changed

+81
-96
lines changed

generatedTypes/components/tabController/PageCarousel.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { PureComponent } from 'react';
2-
import _ from 'lodash';
32
import Animated from 'react-native-reanimated';
43
/**
54
* @description: TabController's Page Carousel
@@ -14,7 +13,7 @@ declare class PageCarousel extends PureComponent {
1413
componentDidMount(): void;
1514
onTabChange: ([index]: readonly number[]) => void;
1615
scrollToPage: (pageIndex: number) => void;
17-
renderCodeBlock: (() => JSX.Element) & _.MemoizedFunction;
16+
renderCodeBlock: () => Animated.Node<number>;
1817
render(): JSX.Element;
1918
}
2019
export default PageCarousel;

generatedTypes/components/tabController/TabController.d.ts

Lines changed: 0 additions & 76 deletions
This file was deleted.

generatedTypes/components/tabController/TabPage.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { PureComponent } from 'react';
22
import Reanimated from 'react-native-reanimated';
3-
import _ from 'lodash';
43
export interface TabPageProps {
54
/**
65
* The index of the the TabPage
@@ -66,6 +65,6 @@ export default class TabPage extends PureComponent<TabPageProps> {
6665
width?: undefined;
6766
} | undefined)[];
6867
lazyLoad: () => void;
69-
renderCodeBlock: (() => JSX.Element) & _.MemoizedFunction;
68+
renderCodeBlock: () => Reanimated.Node<number>;
7069
render(): JSX.Element;
7170
}
Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,76 @@
1-
import { default as TabController, TabControllerProps as _TabControllerProps, TabBarItemProps as _TabBarItemProps } from './TabController';
2-
declare namespace Props {
3-
type TabControllerProps = _TabControllerProps;
4-
type TabBarItemProps = _TabBarItemProps;
1+
import React, { Component } from 'react';
2+
import Reanimated from 'react-native-reanimated';
3+
import TabBar from './TabBar';
4+
import TabBarItem, { TabBarItemProps } from './TabBarItem';
5+
import TabPage from './TabPage';
6+
import PageCarousel from './PageCarousel';
7+
export { TabBarItemProps };
8+
export interface TabControllerProps {
9+
/**
10+
* The list of tab bar items
11+
*/
12+
items: TabBarItemProps[];
13+
/**
14+
* Initial selected index
15+
*/
16+
selectedIndex: number;
17+
/**
18+
* callback for when index has change (will not be called on ignored items)
19+
*/
20+
onChangeIndex?: (index: number) => void;
21+
/**
22+
* When using TabController.PageCarousel this should be turned on
23+
*/
24+
asCarousel?: boolean;
25+
/**
26+
* Pass for custom carousel page width
27+
*/
28+
carouselPageWidth?: number;
529
}
6-
export { TabController, Props as TabControllerProps };
30+
interface StateProps {
31+
selectedIndex: number;
32+
asCarousel?: boolean;
33+
pageWidth: number;
34+
items: TabControllerProps['items'];
35+
itemStates: any[];
36+
ignoredItems: any[];
37+
targetPage: any;
38+
currentPage: any;
39+
carouselOffset: any;
40+
containerWidth: any;
41+
registerTabItems: (tabItemsCount: number, ignoredItems: StateProps['ignoredItems']) => void;
42+
onChangeIndex?: (index: number) => void;
43+
}
44+
/**
45+
* @description: A performant solution for a tab controller with lazy load mechanism
46+
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/TabControllerScreen/index.js
47+
* @notes: This component is based on react-native-gesture-handler
48+
* @important: On Android, if using react-native-navigation, make sure to wrap your screen with gestureHandlerRootHOC
49+
* @importantLink: https://kmagiera.github.io/react-native-gesture-handler/docs/getting-started.html#with-wix-react-native-navigation-https-githubcom-wix-react-native-navigation
50+
*/
51+
declare class TabController extends Component<TabControllerProps, StateProps> {
52+
static displayName: string;
53+
static contextType: React.Context<{}>;
54+
static TabBar: typeof TabBar;
55+
static TabBarItem: typeof TabBarItem;
56+
static TabPage: typeof TabPage;
57+
static PageCarousel: typeof PageCarousel;
58+
static defaultProps: {
59+
selectedIndex: number;
60+
activeOpacity: number;
61+
};
62+
constructor(props: TabControllerProps);
63+
static getDerivedStateFromProps(nextProps: TabControllerProps, prevState: StateProps): {
64+
pageWidth: number;
65+
} | null;
66+
componentDidUpdate(_prevProps: TabControllerProps, prevState: StateProps): void;
67+
get pageWidth(): number;
68+
registerTabItems: (tabItemsCount: number, ignoredItems: StateProps['ignoredItems']) => void;
69+
onPageChange: ([index]: readonly number[]) => void;
70+
renderCodeBlock: () => Reanimated.Node<number>;
71+
render(): JSX.Element;
72+
}
73+
declare const _default: React.ComponentClass<TabControllerProps & {
74+
useCustomTheme?: boolean | undefined;
75+
}, any> & typeof TabController;
76+
export default _default;

generatedTypes/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export {default as Overlay, OverlayTypes} from './components/overlay';
4242
export {default as RadioButton, RadioButtonPropTypes, RadioButtonProps} from './components/radioButton/RadioButton';
4343
export {default as RadioGroup, RadioGroupPropTypes, RadioGroupProps} from './components/radioButton/RadioGroup';
4444
export {default as Switch, SwitchProps} from './components/switch';
45-
export {TabController, TabControllerProps} from './components/tabController';
45+
export {default as TabController, TabControllerProps, TabBarItemProps} from './components/tabController';
4646
export {default as TabBar, TabBarProps} from './components/TabBar';
4747
export {default as Fader, FaderProps, FaderPosition} from './components/fader';
4848
export {default as ExpandableSection, ExpandableSectionProps} from './components/expandableSection';

src/components/tabController/TabBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ class TabBar extends PureComponent<Props, State> {
431431
renderCodeBlock = _.memoize(() => {
432432
const {currentPage, targetPage} = this.context;
433433
const {itemsWidths, itemsOffsets} = this.state;
434-
const nodes: any[] = []; // TODO: typescript?
434+
const nodes = [];
435435

436436
nodes.push(set(this._indicatorOffset,
437437
interpolate(currentPage, {

src/components/tabController/index.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export default {
148148
return require('./components/stepper').default;
149149
},
150150
get TabController() {
151-
return require('./components/tabController').TabController;
151+
return require('./components/tabController').default;
152152
},
153153
get TabBar() {
154154
return require('./components/tabBar').default;

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export {default as Overlay, OverlayTypes} from './components/overlay';
3636
export {default as RadioButton, RadioButtonPropTypes, RadioButtonProps} from './components/radioButton/RadioButton';
3737
export {default as RadioGroup, RadioGroupPropTypes, RadioGroupProps} from './components/radioButton/RadioGroup';
3838
export {default as Switch, SwitchProps} from './components/switch';
39-
export {TabController, TabControllerProps} from './components/tabController';
39+
export {default as TabController, TabControllerProps, TabBarItemProps} from './components/tabController';
4040
export {default as TabBar, TabBarProps} from './components/TabBar';
4141
export {default as Fader, FaderProps, FaderPosition} from './components/fader';
4242
export {default as ExpandableSection, ExpandableSectionProps} from './components/expandableSection';

0 commit comments

Comments
 (0)