Skip to content

Commit cc42a3c

Browse files
committed
Merge branch 'master' into daniel/skeleton_view
2 parents fdc4c77 + f2c4339 commit cc42a3c

File tree

32 files changed

+1629
-99
lines changed

32 files changed

+1629
-99
lines changed

demo/src/screens/ExampleScreenPresenter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function renderBooleanGroup(title, options) {
4444
marginR-s2
4545
useCustomTheme
4646
key={key}
47-
textID={key}
47+
testID={key}
4848
value={value}
4949
onValueChange={value => this.setState({[key]: value})}
5050
/>

demo/src/screens/componentScreens/DateTimePickerScreen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default class DateTimePickerScreen extends Component {
7070
containerStyle={{marginVertical: 20}}
7171
title={'Date'}
7272
placeholder={'Select a date'}
73-
renderExpandableInput={this.renderCustomInput}
73+
renderInput={this.renderCustomInput}
7474
dateFormat={'MMM D, YYYY'}
7575
// value={new Date('2015-03-25T12:00:00-06:30')}
7676
/>

demo/src/screens/componentScreens/TabControllerScreen/index.tsx

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {Component} from 'react';
2-
import {ActivityIndicator} from 'react-native';
2+
import {ActivityIndicator, StyleSheet} from 'react-native';
33
import {Assets, TabController, Colors, View, Text, Button, TabControllerItemProps} from 'react-native-ui-lib';
44
import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
55
import _ from 'lodash';
@@ -20,7 +20,6 @@ interface State {
2020
}
2121

2222
class TabControllerScreen extends Component<{}, State> {
23-
2423
constructor(props: {}) {
2524
super(props);
2625
this.state = {
@@ -36,12 +35,23 @@ class TabControllerScreen extends Component<{}, State> {
3635
}
3736

3837
generateTabItems = (fewItems = this.state.fewItems): TabControllerItemProps[] => {
39-
let items: TabControllerItemProps[] = _.chain(TABS)
38+
const items: TabControllerItemProps[] = _.chain(TABS)
4039
.take(fewItems ? 3 : TABS.length)
41-
.map<TabControllerItemProps>(tab => ({label: tab, key: tab}))
40+
.map<TabControllerItemProps>((tab, index) => ({
41+
label: tab,
42+
key: tab,
43+
icon: index === 2 ? Assets.icons.demo.dashboard : undefined,
44+
badge: index === 5 ? {label: '2'} : undefined
45+
}))
4246
.value();
4347

44-
const addItem: TabControllerItemProps = {icon: Assets.icons.demo.add, key: 'add', ignore: true, width: 60, onPress: this.onAddItem};
48+
const addItem: TabControllerItemProps = {
49+
icon: Assets.icons.demo.add,
50+
key: 'add',
51+
ignore: true,
52+
width: 60,
53+
onPress: this.onAddItem
54+
};
4555

4656
return fewItems ? items : [...items, addItem];
4757
};
@@ -93,7 +103,7 @@ class TabControllerScreen extends Component<{}, State> {
93103
renderLoadingPage() {
94104
return (
95105
<View flex center>
96-
<ActivityIndicator size="large" />
106+
<ActivityIndicator size="large"/>
97107
<Text text60L marginT-10>
98108
Loading
99109
</Text>
@@ -108,13 +118,13 @@ class TabControllerScreen extends Component<{}, State> {
108118
return (
109119
<Container {...containerProps}>
110120
<TabController.TabPage index={0}>
111-
<Tab1 />
121+
<Tab1/>
112122
</TabController.TabPage>
113123
<TabController.TabPage index={1}>
114-
<Tab2 />
124+
<Tab2/>
115125
</TabController.TabPage>
116126
<TabController.TabPage index={2} lazy lazyLoadTime={1500} renderLoading={this.renderLoadingPage}>
117-
<Tab3 />
127+
<Tab3/>
118128
</TabController.TabPage>
119129

120130
{_.map(_.takeRight(TABS, TABS.length - 3), (title, index) => {
@@ -147,10 +157,12 @@ class TabControllerScreen extends Component<{}, State> {
147157
// uppercase
148158
// indicatorStyle={{backgroundColor: 'green', height: 3}}
149159
// indicatorInsets={0}
150-
// spreadItems={false}
160+
spreadItems={!fewItems}
161+
backgroundColor={fewItems ? 'transparent' : undefined}
151162
// labelColor={'green'}
152163
// selectedLabelColor={'red'}
153-
// labelStyle={{fontSize: 20}}
164+
labelStyle={styles.labelStyle}
165+
selectedLabelStyle={styles.selectedLabelStyle}
154166
// iconColor={'green'}
155167
// selectedIconColor={'blue'}
156168
enableShadow
@@ -192,3 +204,12 @@ class TabControllerScreen extends Component<{}, State> {
192204
}
193205

194206
export default gestureHandlerRootHOC(TabControllerScreen);
207+
208+
const styles = StyleSheet.create({
209+
labelStyle: {
210+
fontSize: 16
211+
},
212+
selectedLabelStyle: {
213+
fontSize: 16
214+
}
215+
});

demo/src/screens/incubatorScreens/WheelPickerScreen.tsx

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useCallback, useState} from 'react';
1+
import React, {useCallback, useMemo, useState} from 'react';
22
import {View, Text, Incubator, Colors, Typography, Button, Dialog} from 'react-native-ui-lib';
33
import _ from 'lodash';
44

@@ -29,42 +29,42 @@ const useData = (initialMonth?: string, initialYear?: string, initialDays?: numb
2929
const [selectedDays, setDays] = useState<number | undefined>(initialDays);
3030
const [showDialog, setShowDialog] = useState(false);
3131

32-
const onPickDaysPress = () => {
32+
const onPickDaysPress = useCallback(() => {
3333
setShowDialog(true);
34-
};
34+
}, []);
3535

36-
const onDialogDismissed = () => {
36+
const onDialogDismissed = useCallback(() => {
3737
setShowDialog(false);
38-
};
38+
}, []);
3939

40-
const onMonthChange = (item: string | undefined, _: number) => {
40+
const onMonthChange = useCallback((item: string | undefined, _: number) => {
4141
setMonth(item);
42-
};
42+
}, []);
4343

44-
const onYearChange = (item: string | undefined, _: number) => {
44+
const onYearChange = useCallback((item: string | undefined, _: number) => {
4545
setYear(item);
46-
};
46+
}, []);
4747

48-
const onDaysChange = (item: number | undefined, _: number) => {
48+
const onDaysChange = useCallback((item: number | undefined, _: number) => {
4949
setDays(item);
50-
};
50+
}, []);
5151

52-
const getMonths = useCallback(() => {
52+
const monthItems = useMemo(() => {
5353
return _.map(months, item => ({label: item, value: item}));
5454
}, []);
5555

56-
const getYears = useCallback(() => {
56+
const yearItems = useMemo(() => {
5757
return _.map(years, item => ({label: '' + item, value: item}));
5858
}, []);
5959

60-
const getDays = useCallback(() => {
60+
const dayItems = useMemo(() => {
6161
return _.map(days, item => ({label: '' + item, value: item}));
6262
}, []);
6363

6464
return {
65-
getMonths,
66-
getYears,
67-
getDays,
65+
monthItems,
66+
yearItems,
67+
dayItems,
6868
onMonthChange,
6969
onYearChange,
7070
onDaysChange,
@@ -81,13 +81,13 @@ export default () => {
8181
const {
8282
selectedMonth,
8383
onMonthChange,
84-
getMonths,
84+
monthItems,
8585
selectedYear,
8686
onYearChange,
87-
getYears,
87+
yearItems,
8888
selectedDays,
8989
onDaysChange,
90-
getDays,
90+
dayItems,
9191
onPickDaysPress,
9292
onDialogDismissed,
9393
showDialog
@@ -104,7 +104,7 @@ export default () => {
104104
onChange={onMonthChange}
105105
activeTextColor={Colors.primary}
106106
inactiveTextColor={Colors.grey20}
107-
items={getMonths()}
107+
items={monthItems}
108108
textStyle={Typography.text60R}
109109
selectedValue={selectedMonth}
110110
/>
@@ -115,18 +115,13 @@ export default () => {
115115
onChange={onYearChange}
116116
numberOfVisibleRows={3}
117117
selectedValue={selectedYear}
118-
items={getYears()}
118+
items={yearItems}
119119
/>
120120
</View>
121121

122-
<Button marginT-40 label={'Pick Days'} marginH-120 onPress={onPickDaysPress}/>
122+
<Button marginT-40 label={'Pick Days'} marginH-100 onPress={onPickDaysPress}/>
123123
<Dialog width={'90%'} height={260} bottom visible={showDialog} onDismiss={onDialogDismissed}>
124-
<Incubator.WheelPicker
125-
onChange={onDaysChange}
126-
selectedValue={selectedDays}
127-
label={'Days'}
128-
items={getDays()}
129-
/>
124+
<Incubator.WheelPicker onChange={onDaysChange} selectedValue={selectedDays} label={'Days'} items={dayItems}/>
130125
</Dialog>
131126
</View>
132127
</View>

generatedTypes/components/hint/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export interface HintProps {
107107
interface HintState {
108108
targetLayout?: HintTargetFrame;
109109
targetLayoutInWindow?: HintTargetFrame;
110+
animationEnded: boolean;
110111
}
111112
/**
112113
* @description: Hint component for displaying a tooltip over wrapped component
@@ -122,12 +123,16 @@ declare class Hint extends Component<HintProps, HintState> {
122123
static positions: typeof HintPositions;
123124
targetRef: ElementRef<typeof RNView> | null;
124125
hintRef: ElementRef<typeof RNView> | null;
126+
animationDuration: number;
125127
state: {
126128
targetLayoutInWindow: undefined;
127129
targetLayout: HintTargetFrame | undefined;
130+
animationEnded: boolean;
128131
};
129132
visibleAnimated: Animated.Value;
130133
componentDidUpdate(prevProps: HintProps): void;
134+
animateHint: () => void;
135+
toggleAnimationEndedToRemoveHint: () => void;
131136
focusAccessibilityOnHint: () => void;
132137
setTargetRef: (ref: ElementRef<typeof RNView>) => void;
133138
setHintRef: (ref: ElementRef<typeof RNView>) => void;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
import { ViewProps, ScrollViewProps } from 'react-native';
3+
import { ForwardRefInjectedProps } from '../../commons/forwardRef';
4+
export declare type FadedScrollViewProps = ViewProps & ScrollViewProps & {
5+
children?: React.ReactNode | React.ReactNode[];
6+
};
7+
declare type Props = FadedScrollViewProps & ForwardRefInjectedProps;
8+
declare const _default: React.ComponentType<Props>;
9+
export default _default;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference types="react" />
2+
/**
3+
* @description: TabController's Page Carousel
4+
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/TabControllerScreen/index.tsx
5+
* @notes: You must pass `asCarousel` flag to TabController and render your TabPages inside a PageCarousel
6+
*/
7+
declare function PageCarousel({ ...props }: {
8+
[x: string]: any;
9+
}): JSX.Element;
10+
export default PageCarousel;
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import React from 'react';
2+
import { StyleProp, ViewStyle } from 'react-native';
3+
import { TabControllerItemProps } from './TabBarItem';
4+
export interface TabControllerBarProps {
5+
/**
6+
* The list of tab bar items
7+
*/
8+
items?: TabControllerItemProps[];
9+
/**
10+
* Tab Bar height
11+
*/
12+
height?: number;
13+
/**
14+
* Show Tab Bar bottom shadow
15+
*/
16+
enableShadow?: boolean;
17+
/**
18+
* custom shadow style
19+
*/
20+
shadowStyle?: StyleProp<ViewStyle>;
21+
/**
22+
* custom style for the selected indicator
23+
*/
24+
indicatorStyle?: StyleProp<ViewStyle>;
25+
/**
26+
* custom label style
27+
*/
28+
labelStyle?: TabControllerItemProps['labelStyle'];
29+
/**
30+
* custom selected label style
31+
*/
32+
selectedLabelStyle?: TabControllerItemProps['selectedLabelStyle'];
33+
/**
34+
* the default label color
35+
*/
36+
labelColor?: string;
37+
/**
38+
* the selected label color
39+
*/
40+
selectedLabelColor?: string;
41+
/**
42+
* whether to change the text to uppercase
43+
*/
44+
uppercase?: boolean;
45+
/**
46+
* icon tint color
47+
*/
48+
iconColor?: string;
49+
/**
50+
* icon selected tint color
51+
*/
52+
selectedIconColor?: string;
53+
/**
54+
* TODO: rename to feedbackColor
55+
* Apply background color on press for TouchableOpacity
56+
*/
57+
activeBackgroundColor?: string;
58+
/**
59+
* The TabBar background Color
60+
*/
61+
backgroundColor?: string;
62+
/**
63+
* The TabBar container width
64+
*/
65+
containerWidth?: number;
66+
/**
67+
* Pass to center selected item
68+
*/
69+
centerSelected?: boolean;
70+
/**
71+
* Whether the tabBar should be spread (default: true)
72+
*/
73+
spreadItems?: boolean;
74+
/**
75+
* The indicator insets (default: Spacings.s4, set to 0 to make it wide as the item)
76+
*/
77+
indicatorInsets?: number;
78+
/**
79+
* Additional styles for the container
80+
*/
81+
containerStyle?: StyleProp<ViewStyle>;
82+
/**
83+
* Used as a testing identifier
84+
*/
85+
testID?: string;
86+
}
87+
declare const _default: React.ComponentClass<TabControllerBarProps & {
88+
useCustomTheme?: boolean | undefined;
89+
}, any>;
90+
export default _default;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
import Reanimated from 'react-native-reanimated';
3+
interface TabControllerContext {
4+
selectedIndex?: number;
5+
items?: any[];
6+
asCarousel?: boolean;
7+
containerWidth: Reanimated.SharedValue<number>;
8+
pageWidth?: number;
9+
/** static page index */
10+
currentPage: Reanimated.SharedValue<number>;
11+
/** transition page index (can be a fraction when transitioning between pages) */
12+
targetPage: Reanimated.SharedValue<number>;
13+
carouselOffset: Reanimated.SharedValue<number>;
14+
}
15+
declare const TabBarContext: React.Context<TabControllerContext>;
16+
export default TabBarContext;

0 commit comments

Comments
 (0)