Skip to content

Commit 23a3c06

Browse files
committed
Merge branch 'master' into release
2 parents ae9b5f1 + d64843e commit 23a3c06

Some content is hidden

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

51 files changed

+1629
-60
lines changed

demo/src/screens/MenuStructure.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export const navigationData = {
174174
Incubator: {
175175
title: 'Incubator (Experimental)',
176176
screens: [
177+
{title: 'Calendar', tags: 'calendar', screen: 'unicorn.components.IncubatorCalendarScreen'},
177178
{title: 'ChipsInput (New)', tags: 'chips input', screen: 'unicorn.components.IncubatorChipsInputScreen'},
178179
{title: 'Native TouchableOpacity', tags: 'touchable native', screen: 'unicorn.incubator.TouchableOpacityScreen'},
179180
{title: 'Dialog (New)', tags: 'dialog modal popup alert', screen: 'unicorn.incubator.IncubatorDialogScreen'},

demo/src/screens/componentScreens/ColorSwatchScreen.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ export default class ColorSwatchScreen extends Component {
5151
this.setState({color2: value});
5252
};
5353

54+
unavailableOnPress = () => {
55+
console.log(`Pressed on unavailable color swatch!`);
56+
};
57+
5458
render() {
5559
const {color, color1, color2, selected} = this.state;
5660

@@ -61,10 +65,16 @@ export default class ColorSwatchScreen extends Component {
6165
Single ColorSwatch
6266
</Text>
6367
<View row>
64-
<ColorSwatch selected={selected} onPress={this.onPress}/>
6568
<View>
66-
<ColorSwatch selected color={Colors.$backgroundMajorLight}/>
67-
<Text>Disabled</Text>
69+
<ColorSwatch selected={selected} onPress={this.onPress}/>
70+
</View>
71+
<View>
72+
<ColorSwatch color={Colors.$backgroundMajorLight}/>
73+
<Text text90R>Disabled</Text>
74+
</View>
75+
<View>
76+
<ColorSwatch unavailable onPress={this.unavailableOnPress} color={Colors.yellow10}/>
77+
<Text text90R>Unavailable</Text>
6878
</View>
6979
</View>
7080

demo/src/screens/incubatorScreens/IncubatorCalendarScreen/MockData.ts

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React, {Component} from 'react';
2+
import {View, Incubator} from 'react-native-ui-lib';
3+
import {data} from './MockData';
4+
5+
export default class CalendarScreen extends Component {
6+
// constructor(props) {
7+
// super(props);
8+
9+
// setTimeout(() => {
10+
// this.setState({date: 1676026748000});
11+
// }, 2000);
12+
// }
13+
14+
state = {
15+
date: undefined
16+
};
17+
18+
render() {
19+
return (
20+
<View flex>
21+
<Incubator.Calendar data={data} staticHeader initialDate={this.state.date}>
22+
<Incubator.Calendar.Agenda/>
23+
</Incubator.Calendar>
24+
</View>
25+
);
26+
}
27+
}

demo/src/screens/incubatorScreens/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
22

33
export function registerScreens(registrar) {
4+
registrar('unicorn.components.IncubatorCalendarScreen', () => require('./IncubatorCalendarScreen').default);
45
registrar('unicorn.components.IncubatorChipsInputScreen', () => require('./IncubatorChipsInputScreen').default);
56
registrar('unicorn.incubator.TouchableOpacityScreen', () =>
67
gestureHandlerRootHOC(require('./TouchableOpacityScreen').default));

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"pre-push": "npm run build:dev && npm run test",
3333
"docs:deploy": "./scripts/deployDocs.sh",
3434
"docs:build": "node scripts/buildDocs.js",
35+
"calendar:createMocks": "node scripts/createCalendarMockData.js",
3536
"snippets:build": "node scripts/generateSnippets.js",
3637
"demo": "./scripts/demo.sh",
3738
"release": "node ./scripts/release.js"
@@ -40,6 +41,7 @@
4041
"babel-plugin-transform-inline-environment-variables": "^0.0.2",
4142
"color": "^3.1.0",
4243
"commons-validator-js": "^1.0.237",
44+
"date-fns": "^2.29.3",
4345
"deprecated-react-native-prop-types": "^2.3.0",
4446
"hoist-non-react-statics": "^3.0.0",
4547
"lodash": "^4.17.21",
@@ -107,7 +109,7 @@
107109
"react-native": "0.68.2",
108110
"react-native-gesture-handler": "2.5.0",
109111
"react-native-haptic-feedback": "^1.11.0",
110-
"react-native-linear-gradient": "2.5.6",
112+
"react-native-linear-gradient": "2.6.2",
111113
"react-native-navigation": "7.30.0",
112114
"react-native-reanimated": "2.13.0",
113115
"react-native-shimmer-placeholder": "^2.0.6",

scripts/buildPackages.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ const packages = [
1010
filename: 'config.js',
1111
content: `module.exports = require('./src/commons/Config').default;\n`
1212
},
13+
{
14+
filename: 'constants.js',
15+
content: `module.exports = require('./src/commons/Constants').default;\n`
16+
},
1317
{
1418
filename: 'core.js',
1519
components: ['View', 'Text', 'Image', 'TouchableOpacity', 'Button'],

scripts/createCalendarMockData.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const fs = require('fs');
2+
const HOUR_IN_MS = 60 * 60 * 1000;
3+
const ID_LENGTH = 10;
4+
5+
function generateId() {
6+
let result = '';
7+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
8+
const charactersLength = characters.length;
9+
for (let i = 0; i < ID_LENGTH; i++) {
10+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
11+
}
12+
return result;
13+
}
14+
15+
const data = [];
16+
17+
for (let year = 2021; year <= 2023; ++year) {
18+
for (let month = 0; month <= 11; ++month) {
19+
for (let day = 1; day <= 31; day += Math.random() > 0.5 ? 2 : 1) {
20+
for (let hour = 9; hour <= 19; hour += Math.random() > 0.5 ? 4 : 3) {
21+
const startDate = new Date(year, month, day, hour, 0);
22+
if (startDate.getDay() >= 2 && startDate.getDay() <= 5) {
23+
const start = startDate.getTime();
24+
const end = start + HOUR_IN_MS * (Math.random() > 0.5 ? 0.5 : 1);
25+
const id = generateId();
26+
data.push({id, start, end});
27+
}
28+
}
29+
}
30+
}
31+
}
32+
33+
console.log(`${data.length} events were created`);
34+
35+
fs.writeFileSync('demo/src/screens/incubatorScreens/IncubatorCalendarScreen/MockData.ts',
36+
`// Note: to generate new data run calendar:createMocks and update createCalendarMockData script \n` +
37+
`export const data = ${JSON.stringify(data)};`);

src/components/checkbox/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ class Checkbox extends Component<CheckboxProps, CheckboxState> {
240240
render() {
241241
const {label, labelStyle, containerStyle, labelProps} = this.props;
242242
return label ? (
243-
<View row centerV style={[containerStyle]}>
243+
<View row centerV style={containerStyle}>
244244
{this.renderCheckbox()}
245-
<Text style={[this.styles.checkboxLabel, labelStyle]} {...labelProps} onPress={this.onPress}>
245+
<Text flexS style={[this.styles.checkboxLabel, labelStyle]} {...labelProps} onPress={this.onPress}>
246246
{label}
247247
</Text>
248248
</View>

src/components/colorSwatch/colorSwatch.api.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
{"name": "onPress", "type": "(value: string, options: object) => void", "description": "Callback from press event"},
2020
{"name": "index", "type": "number", "description": "The index of the Swatch if in array"},
2121
{"name": "style", "type": "ViewStyle", "description": "Component's style"},
22-
{"name": "testID", "type": "string", "description": "The test id for e2e tests"}
22+
{"name": "testID", "type": "string", "description": "The test id for e2e tests"},
23+
{"name": "unavailable", "type": "boolean", "description": "Is the initial state is unavailable"},
24+
{"name": "size", "type": "number", "description": "Color Swatch size"}
2325
],
24-
"snippet": [
25-
"<ColorSwatch color={Colors.red30$1} selected={true$2} onPress={() => console.log('pressed')$3}/>"
26-
]
26+
"snippet": ["<ColorSwatch color={Colors.red30$1} selected={true$2} onPress={() => console.log('pressed')$3}/>"]
2727
}

0 commit comments

Comments
 (0)