Skip to content

Commit fe29476

Browse files
committed
Merge branch 'master' into docs/fix-undocumented-logic-and-various-fixes
* master: Remove addItems from screen with fewItems Add vertical scroll to Carousel component (#1175) Fix Carousel gif Update Carousel gifs Fix and improve search using fuzzysearch Update PageControl docs with a gif Fix issue with Carousel props not being included in docs Fix issue with duplicate props appearing in docs site Fix order of markdown pages in docs site Update uilib-docs version to 1.0.11 Update generate types Fix/tab controller center android with rtl (#1178) Fix/responsive docs pages (#1174) Add customLoader and remove animatable (#1152) turn off TextFieldMigrator for now Update peer deps version Move IncubatorTextField screen to be in Incubator screens hierarchy Docs/mobie responsive (#1164) Update generatedTypes # Conflicts: # uilib-docs/src/components/navbar/index.js # uilib-docs/src/components/navbar/item.js # uilib-docs/src/pages/sections/IntroSection.jsx
2 parents 6afa379 + e4b582b commit fe29476

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+838
-285
lines changed

demo/src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ module.exports = {
3434
get CarouselScreen() {
3535
return require('./screens/componentScreens/CarouselScreen').default;
3636
},
37+
get CarouselVerticalScreen() {
38+
return require('./screens/componentScreens/CarouselVerticalScreen').default;
39+
},
3740
get CheckboxScreen() {
3841
return require('./screens/componentScreens/CheckboxScreen').default;
3942
},

demo/src/screens/MenuStructure.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export const navigationData = {
8686
title: 'Layouts & Templates',
8787
screens: [
8888
{title: 'Carousel', tags: 'carousel', screen: 'unicorn.components.CarouselScreen'},
89+
{title: 'Carousel (Vertical)', tags: 'carousel', screen: 'unicorn.components.CarouselVerticalScreen'},
8990
{title: 'LoadingScreen', tags: 'loading screen', screen: 'unicorn.screens.LoadingScreen'},
9091
{title: 'Modal', tags: 'modal topbar screen', screen: 'unicorn.screens.ModalScreen'},
9192
{title: 'StateScreen', tags: 'empty state screen', screen: 'unicorn.screens.EmptyStateScreen'},
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import {Carousel, Constants, Text, View, Colors} from 'react-native-ui-lib';
2+
import React, {Component} from 'react';
3+
import _ from 'lodash';
4+
import {StyleSheet} from 'react-native';
5+
import {
6+
renderBooleanOption,
7+
renderSliderOption
8+
} from '../ExampleScreenPresenter';
9+
10+
interface Props {}
11+
12+
interface State {
13+
numberOfPagesShown: number;
14+
autoplay: boolean;
15+
}
16+
17+
const BACKGROUND_COLORS = [
18+
Colors.red50,
19+
Colors.yellow20,
20+
Colors.purple50,
21+
Colors.green50,
22+
Colors.cyan50,
23+
Colors.purple20,
24+
Colors.blue60,
25+
Colors.red10,
26+
Colors.green20,
27+
Colors.purple60
28+
];
29+
30+
const pageHeight = Constants.windowHeight / 2;
31+
32+
class CarouselVerticalScreen extends Component<Props, State> {
33+
carousel = React.createRef<typeof Carousel>();
34+
35+
constructor(props: Props) {
36+
super(props);
37+
38+
this.state = {
39+
numberOfPagesShown: 5,
40+
autoplay: false
41+
};
42+
}
43+
44+
render() {
45+
const {numberOfPagesShown, autoplay} = this.state
46+
return (
47+
<View flex paddingT-20>
48+
<View marginH-20 marginB-20>
49+
{renderBooleanOption.call(this, 'autoplay', 'autoplay')}
50+
{renderSliderOption.call(
51+
this,
52+
'Number of pages shown',
53+
'numberOfPagesShown',
54+
{
55+
min: 3,
56+
max: 10,
57+
step: 1,
58+
initial: 5
59+
}
60+
)}
61+
</View>
62+
<Carousel
63+
key={'carousel'}
64+
ref={this.carousel}
65+
autoplay={autoplay}
66+
pageWidth={Constants.windowWidth}
67+
pageHeight={pageHeight}
68+
initialPage={0}
69+
containerStyle={{height: pageHeight}}
70+
allowAccessibleLayout
71+
horizontal={false}
72+
>
73+
{_.map([...Array(numberOfPagesShown)], (_, index) => (
74+
<Page
75+
style={{backgroundColor: BACKGROUND_COLORS[index]}}
76+
key={index}
77+
>
78+
<Text style={styles.pageText}>{index}</Text>
79+
</Page>
80+
))}
81+
</Carousel>
82+
</View>
83+
);
84+
}
85+
}
86+
87+
// @ts-ignore
88+
const Page = ({children, style, ...others}) => {
89+
return (
90+
<View center {...others} style={[styles.page, style]}>
91+
{children}
92+
</View>
93+
);
94+
};
95+
96+
const styles = StyleSheet.create({
97+
container: {},
98+
page: {
99+
flex: 1,
100+
height: pageHeight,
101+
width: Constants.windowWidth
102+
},
103+
pageText: {
104+
fontSize: 40,
105+
color: 'white'
106+
}
107+
});
108+
109+
export default CarouselVerticalScreen

demo/src/screens/componentScreens/LoadingScreen.js

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,22 @@
11
import React, {Component} from 'react';
2-
import {View as AnimatableView} from 'react-native-animatable';
3-
import {View, Text, LoaderScreen, Colors} from 'react-native-ui-lib';//eslint-disable-line
4-
2+
import {View, Text, LoaderScreen, Colors} from 'react-native-ui-lib';
53
export default class LoadingScreen extends Component {
6-
74
state = {
8-
loading: true,
5+
loading: true
96
};
107

118
componentDidMount() {
129
setTimeout(() => {
13-
this.setState({
14-
animationConfig: {
15-
animation: 'fadeOut',
16-
onAnimationEnd: () => this.setState({loading: false}),
17-
},
18-
});
10+
this.setState({loading: false});
1911
}, 2500);
2012
}
2113

2214
render() {
23-
const {loading, animationConfig} = this.state;
15+
const {loading} = this.state;
2416
return (
2517
<View flex bg-orange70 center>
26-
<Text text10>
27-
Content Content Content
28-
</Text>
29-
{loading &&
30-
<AnimatableView {...animationConfig}>
31-
<LoaderScreen
32-
color={Colors.blue30}
33-
message="Loading..."
34-
overlay
35-
/>
36-
</AnimatableView>
37-
}
18+
<Text text10>Content Content Content</Text>
19+
{loading && <LoaderScreen color={Colors.blue30} message="Loading..." overlay/>}
3820
</View>
3921
);
4022
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class TabControllerScreen extends Component<{}, State> {
4343

4444
const addItem: TabControllerItemProps = {icon: Assets.icons.demo.add, key: 'add', ignore: true, width: 60, onPress: this.onAddItem};
4545

46-
return [...items, addItem];
46+
return fewItems ? items : [...items, addItem];
4747
};
4848

4949
componentDidMount() {

demo/src/screens/componentScreens/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export function registerScreens(registrar) {
1010
registrar('unicorn.components.CardsScreen', () => require('./CardsScreen').default);
1111
registrar('unicorn.animations.CardScannerScreen', () => require('../componentScreens/CardScannerScreen').default);
1212
registrar('unicorn.components.CarouselScreen', () => require('./CarouselScreen').default);
13+
registrar('unicorn.components.CarouselVerticalScreen', () => require('./CarouselVerticalScreen').default);
1314
registrar('unicorn.components.CheckboxScreen', () => require('./CheckboxScreen').default);
1415
registrar('unicorn.components.ChipScreen', () => require('./ChipScreen').default);
1516
registrar('unicorn.components.ConnectionStatusBar', () => require('./ConnectionStatusBarScreen').default);
@@ -62,7 +63,5 @@ export function registerScreens(registrar) {
6263
registrar('unicorn.components.WithScrollEnablerScreen', () => require('./WithScrollEnablerScreen').default);
6364
registrar('unicorn.components.WithScrollReachedScreen', () => require('./WithScrollReachedScreen').default);
6465
registrar('unicorn.components.FaderScreen', () => require('./FaderScreen').default);
65-
// Incubator Screens
66-
registrar('unicorn.components.IncubatorTextFieldScreen', () => require('./IncubatorTextFieldScreen').default);
6766
}
6867

demo/src/screens/incubatorScreens/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
22

33
export function registerScreens(registrar) {
44
registrar('unicorn.incubator.TouchableOpacityScreen', () =>
5-
gestureHandlerRootHOC(require('./TouchableOpacityScreen').default)
6-
);
7-
registrar('unicorn.incubator.WheelPickerScreen', () =>
8-
gestureHandlerRootHOC(require('./WheelPickerScreen').default)
9-
);
5+
gestureHandlerRootHOC(require('./TouchableOpacityScreen').default));
6+
registrar('unicorn.components.IncubatorTextFieldScreen', () => require('./IncubatorTextFieldScreen').default);
7+
registrar('unicorn.incubator.WheelPickerScreen', () => gestureHandlerRootHOC(require('./WheelPickerScreen').default));
108
}

generatedTypes/components/avatar/index.d.ts

Lines changed: 96 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { PureComponent } from 'react';
2-
import { ImageSourcePropType, StyleProp, ViewStyle, ImagePropsBase, ImageStyle, TextStyle } from 'react-native';
2+
import { ImageSourcePropType, StyleProp, ViewStyle, ImagePropsBase, ImageStyle, TextStyle, AccessibilityProps } from 'react-native';
33
import { BadgeProps } from '../badge';
44
import { ImageProps } from '../image';
55
export declare enum StatusModes {
@@ -14,7 +14,7 @@ export declare enum BadgePosition {
1414
BOTTOM_RIGHT = "BOTTOM_RIGHT",
1515
BOTTOM_LEFT = "BOTTOM_LEFT"
1616
}
17-
export declare type AvatarProps = {
17+
export declare type AvatarProps = Pick<AccessibilityProps, 'accessibilityLabel'> & {
1818
/**
1919
* Adds fade in animation when Avatar image loads
2020
*/
@@ -162,7 +162,100 @@ declare function createStyles(props: AvatarProps): {
162162
};
163163
};
164164
export { Avatar };
165-
declare const _default: React.ComponentClass<AvatarProps & {
165+
declare const _default: React.ComponentClass<Pick<AccessibilityProps, "accessibilityLabel"> & {
166+
/**
167+
* Adds fade in animation when Avatar image loads
168+
*/
169+
animate?: boolean | undefined;
170+
/**
171+
* Background color for Avatar
172+
*/
173+
backgroundColor?: string | undefined;
174+
/**
175+
* Badge location on Avatar
176+
*/
177+
badgePosition?: BadgePosition | undefined;
178+
/**
179+
* Badge props passed down to Badge component
180+
*/
181+
badgeProps?: BadgeProps | undefined;
182+
/**
183+
* Additional spacing styles for the container
184+
*/
185+
containerStyle?: StyleProp<ViewStyle>;
186+
/**
187+
* The image source (external or assets)
188+
*/
189+
source?: number | import("react-native").ImageURISource | import("react-native").ImageURISource[] | undefined;
190+
/**
191+
* Image props object
192+
*/
193+
imageProps?: ImageProps | undefined;
194+
/**
195+
* Image style object used to pass additional style props
196+
* by components which render image
197+
*/
198+
imageStyle?: ImageStyle | undefined;
199+
/**
200+
* Listener-callback for when an image's (uri) loading
201+
* starts (equiv. to Image.onLoadStart()).
202+
*/
203+
onImageLoadStart?: (() => void) | undefined;
204+
/**
205+
* Listener-callback for when an image's (uri) loading
206+
* either succeeds or fails (equiv. to Image.onLoadEnd()).
207+
*/
208+
onImageLoadEnd?: (() => void) | undefined;
209+
/**
210+
* Listener-callback for when an image's (uri) loading
211+
* fails (equiv. to Image.onError()).
212+
*/
213+
onImageLoadError?: ((error: import("react-native").NativeSyntheticEvent<import("react-native").ImageErrorEventData>) => void) | undefined;
214+
/**
215+
* Label that can represent initials
216+
*/
217+
label?: string | undefined;
218+
/**
219+
* The label color
220+
*/
221+
labelColor?: string | undefined;
222+
/**
223+
* ribbon label to display on the avatar
224+
*/
225+
ribbonLabel?: string | undefined;
226+
/**
227+
* ribbon custom style
228+
*/
229+
ribbonStyle?: StyleProp<ViewStyle>;
230+
/**
231+
* ribbon label custom style
232+
*/
233+
ribbonLabelStyle?: StyleProp<TextStyle>;
234+
/**
235+
* Custom ribbon
236+
*/
237+
customRibbon?: JSX.Element | undefined;
238+
/**
239+
* Determine if to show online badge
240+
*/
241+
isOnline?: boolean | undefined;
242+
/**
243+
* AWAY, ONLINE, OFFLINE or NONE mode (if set to a value other then 'NONE' will override isOnline prop)
244+
*/
245+
status?: StatusModes | undefined;
246+
/**
247+
* Custom size for the Avatar
248+
*/
249+
size: number;
250+
/**
251+
* Press handler
252+
*/
253+
onPress?: ((props: any) => void) | undefined;
254+
/**
255+
* Used as a testing identifier
256+
*/
257+
testID?: string | undefined;
258+
} & {
166259
useCustomTheme?: boolean | undefined;
167260
}, any> & typeof Avatar;
168261
export default _default;
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { CarouselProps, CarouselState } from './types';
22
export declare function getChildrenLength(props: CarouselProps): number;
3-
export declare function calcOffset(props: CarouselProps, state: Omit<CarouselState, 'initialOffset' | 'prevProps'>): number;
4-
export declare function calcPageIndex(offset: number, props: CarouselProps, pageWidth: number): number;
3+
export declare function calcOffset(props: CarouselProps, state: Omit<CarouselState, 'initialOffset' | 'prevProps'>): {
4+
x: number;
5+
y: number;
6+
};
7+
export declare function calcPageIndex(offset: number, props: CarouselProps, pageSize: number): number;
58
export declare function isOutOfBounds(offset: number, props: CarouselProps, pageWidth: number): boolean;

generatedTypes/components/carousel/index.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ export { CarouselProps };
55
declare type DefaultProps = Partial<CarouselProps>;
66
/**
77
* @description: Carousel for scrolling pages horizontally
8-
* @gif: https://media.giphy.com/media/l0HU7f8gjpRlMRhKw/giphy.gif, https://media.giphy.com/media/3oFzmcjX9OhpyckhcQ/giphy.gif
8+
* @gif: https://user-images.githubusercontent.com/1780255/107120258-40b5bc80-6895-11eb-9596-8065d3a940ff.gif, https://user-images.githubusercontent.com/1780255/107120257-3eebf900-6895-11eb-9800-402e9e0dc692.gif
99
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/CarouselScreen.tsx
1010
* @extends: ScrollView
1111
* @extendsLink: https://facebook.github.io/react-native/docs/scrollview
12-
* @notes: This is screen width Component
12+
* @notes: This is a screen width Component
1313
*/
1414
declare class Carousel extends Component<CarouselProps, CarouselState> {
1515
static displayName: string;
@@ -24,6 +24,7 @@ declare class Carousel extends Component<CarouselProps, CarouselState> {
2424
pageWidth: number;
2525
initialOffset: {
2626
x: number;
27+
y: number;
2728
};
2829
prevProps: CarouselProps;
2930
} | {
@@ -47,7 +48,7 @@ declare class Carousel extends Component<CarouselProps, CarouselState> {
4748
getSnapToOffsets: () => number[] | undefined;
4849
shouldUsePageWidth(): number | false | undefined;
4950
shouldEnablePagination(): boolean | undefined;
50-
onContainerLayout: ({ nativeEvent: { layout: { width: containerWidth } } }: LayoutChangeEvent) => void;
51+
onContainerLayout: ({ nativeEvent: { layout: { width: containerWidth, height: containerHeight } } }: LayoutChangeEvent) => void;
5152
shouldAllowAccessibilityLayout(): boolean | undefined;
5253
onContentSizeChange: () => void;
5354
onMomentumScrollEnd: () => void;

0 commit comments

Comments
 (0)