Skip to content

Commit 6a41b44

Browse files
committed
Merge branch 'master' into release
2 parents c9d96d5 + c56e413 commit 6a41b44

Some content is hidden

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

68 files changed

+1227
-371
lines changed

GestureDetectorMock.tsx

-67
This file was deleted.

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,7 @@ class MyScreen extends Component {
127127
}
128128
}
129129
```
130+
131+
## Contributing
132+
See [Contribution Guide](https://github.com/wix/react-native-ui-lib/blob/master/CONTRIBUTING.md)
133+

demo/src/screens/componentScreens/HintsScreen.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const reactions = ['❤️', '😮', '😔', '😂', '😡'];
1010
type HintScreenProps = {};
1111

1212
export default class HintsScreen extends Component<HintScreenProps> {
13-
1413
state = {
1514
showHint: true,
1615
useShortMessage: false,
@@ -134,6 +133,7 @@ export default class HintsScreen extends Component<HintScreenProps> {
134133
const message = useShortMessage
135134
? 'Add other cool and useful stuff.'
136135
: 'Add other cool and useful stuff through adding apps to your visitors to enjoy.';
136+
const color = !showCustomContent && showReactionStrip ? {color: Colors.$backgroundDefault} : undefined;
137137

138138
return (
139139
<View flex>
@@ -178,7 +178,7 @@ export default class HintsScreen extends Component<HintScreenProps> {
178178
? this.renderReactionStrip()
179179
: undefined
180180
}
181-
color={!showCustomContent && showReactionStrip ? Colors.$backgroundDefault : undefined}
181+
{...color}
182182
removePaddings={!showCustomContent && showReactionStrip}
183183
enableShadow={enableShadow}
184184
testID={'Hint'}

demo/src/screens/componentScreens/ModalScreen.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export default class ModalScreen extends Component<ModalScreenProps, State> {
6363
<View bg-violet80 flex style={styles.page}>
6464
<Modal.TopBar
6565
title="another example"
66+
subtitle="with a subtitle"
6667
onCancel={() => Alert.alert('cancel')}
6768
onDone={() => Alert.alert('done')}
6869
cancelIcon={null}

demo/src/screens/componentScreens/SegmentedControlScreen.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const segments = {
1414
},
1515
{label: 'Short'}
1616
],
17-
forth: [{label: 'With'}, {label: 'Custom'}, {label: 'Colors'}],
17+
forth: [{label: 'With'}, {label: 'Custom'}, {label: 'Style'}],
1818
fifth: [{label: 'Full'}, {label: 'Width'}],
1919
sixth: [{label: 'Full'}, {label: 'Width'}, {label: 'With'}, {label: 'A'}, {label: 'Very Long Segment'}]
2020
};
@@ -49,6 +49,8 @@ const SegmentedControlScreen = () => {
4949
backgroundColor={Colors.$backgroundInverted}
5050
activeBackgroundColor={Colors.$backgroundNeutralIdle}
5151
inactiveColor={Colors.$textDisabled}
52+
style={styles.customStyle}
53+
segmentsStyle={styles.customSegmentsStyle}
5254
/>
5355
</View>
5456
<SegmentedControl
@@ -70,6 +72,13 @@ const SegmentedControlScreen = () => {
7072
const styles = StyleSheet.create({
7173
container: {
7274
marginTop: 20
75+
},
76+
customStyle: {
77+
height: 50,
78+
width: 300
79+
},
80+
customSegmentsStyle: {
81+
height: 50
7382
}
7483
});
7584

demo/src/screens/componentScreens/SliderScreen.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,13 @@ export default class SliderScreen extends Component<SliderScreenProps, SliderScr
157157
Disabled
158158
</Text>
159159
<Slider minimumValue={100} maximumValue={200} value={120} containerStyle={styles.slider} disabled/>
160+
</Fragment>
161+
);
162+
}
160163

164+
renderCustomSlider() {
165+
return (
166+
<>
161167
<Text $textDefault text70BO marginT-15>
162168
Custom with Steps
163169
</Text>
@@ -174,7 +180,7 @@ export default class SliderScreen extends Component<SliderScreenProps, SliderScr
174180
minimumTrackTintColor={Colors.violet40}
175181
maximumTrackTintColor={Colors.violet70}
176182
/>
177-
</Fragment>
183+
</>
178184
);
179185
}
180186

@@ -317,6 +323,7 @@ export default class SliderScreen extends Component<SliderScreenProps, SliderScr
317323
{this.renderDefaultSliderExample()}
318324
{this.renderNegativeSliderExample()}
319325
{this.renderDisabledSliderExample()}
326+
{this.renderCustomSlider()}
320327
{this.renderRangeSliderExample()}
321328
{this.renderRangeSliderWithValuesExample()}
322329
{this.renderGradientSlidersExample()}

demo/src/screens/componentScreens/SortableListScreen.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const SortableListScreen = () => {
7676
const Container = locked ? View : TouchableOpacity;
7777
return (
7878
<Container
79+
// TODO: fix Android selection color
7980
style={[styles.itemContainer, isSelected && styles.selectedItemContainer]}
8081
onPress={() => toggleItemSelection(item)}
8182
// overriding the BG color to anything other than white will cause Android's elevation to fail
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import _ from 'lodash';
2+
import {data} from './MockData';
3+
4+
const PAGE_SIZE = 100;
5+
const FAKE_FETCH_TIME = 1500;
6+
7+
class MockServer {
8+
async getEvents(date: number): Promise<any[]> {
9+
return new Promise(resolve => {
10+
const eventIndexByDate = _.findIndex(data, event => {
11+
return event.start > date;
12+
});
13+
14+
setTimeout(() => {
15+
const newEvents = _.slice(data, eventIndexByDate - PAGE_SIZE / 2, eventIndexByDate + PAGE_SIZE / 2);
16+
resolve(newEvents);
17+
}, FAKE_FETCH_TIME);
18+
});
19+
}
20+
}
21+
22+
export default new MockServer();
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,49 @@
1+
import _ from 'lodash';
12
import React, {Component} from 'react';
2-
import {View, Incubator} from 'react-native-ui-lib';
3-
import {data} from './MockData';
3+
import {Incubator} from 'react-native-ui-lib';
4+
import MockServer from './MockServer';
45

56
export default class CalendarScreen extends Component {
6-
// constructor(props) {
7-
// super(props);
8-
9-
// setTimeout(() => {
10-
// this.setState({date: 1676026748000});
11-
// }, 2000);
12-
// }
7+
pageIndex = 0;
138

149
state = {
15-
date: undefined
10+
date: new Date().getTime(),
11+
events: [] as any[],
12+
showLoader: false
1613
};
17-
14+
15+
componentDidMount(): void {
16+
this.loadEvents(this.state.date);
17+
}
18+
19+
loadEvents = async (date: number) => {
20+
this.setState({showLoader: true});
21+
const {events} = this.state;
22+
const newEvents = await MockServer.getEvents(date);
23+
this.pageIndex++;
24+
this.setState({events: _.uniqBy([...events, ...newEvents], e => e.id), showLoader: false});
25+
};
26+
27+
onChangeDate = (date: number) => {
28+
console.log('Date change: ', date);
29+
const {events} = this.state;
30+
if (date < events[0]?.start || date > _.last(events)?.start) {
31+
console.log('Load new events');
32+
this.loadEvents(date);
33+
}
34+
};
35+
36+
onEndReached = (date: number) => {
37+
console.log('Reached End: ', date);
38+
this.loadEvents(date);
39+
};
40+
1841
render() {
42+
const {date, events, showLoader} = this.state;
1943
return (
20-
<View flex>
21-
<Incubator.Calendar data={data} staticHeader initialDate={this.state.date}>
22-
<Incubator.Calendar.Agenda/>
23-
</Incubator.Calendar>
24-
</View>
44+
<Incubator.Calendar data={events} initialDate={date} onChangeDate={this.onChangeDate} staticHeader>
45+
<Incubator.Calendar.Agenda onEndReached={this.onEndReached} showLoader={showLoader}/>
46+
</Incubator.Calendar>
2547
);
2648
}
2749
}

0 commit comments

Comments
 (0)