unicorn-demo-app 7.8.0 → 7.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +3 -0
- package/src/screens/MenuStructure.js +5 -0
- package/src/screens/componentScreens/CheckboxScreen.tsx +17 -7
- package/src/screens/componentScreens/ColorPickerScreen.tsx +23 -2
- package/src/screens/nativeComponentScreens/DynamicFontsScreen.tsx +120 -0
- package/src/screens/nativeComponentScreens/index.js +1 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -164,6 +164,9 @@ module.exports = {
|
|
|
164
164
|
return require('./screens/componentScreens/WizardScreen').default;
|
|
165
165
|
},
|
|
166
166
|
// nativeComponentScreens
|
|
167
|
+
get DynamicFontsScreen() {
|
|
168
|
+
return require('./screens/nativeComponentScreens/DynamicFontsScreen').default;
|
|
169
|
+
},
|
|
167
170
|
get HighlightOverlayViewScreen() {
|
|
168
171
|
return require('./screens/nativeComponentScreens/HighlightOverlayViewScreen').default;
|
|
169
172
|
},
|
|
@@ -141,6 +141,11 @@ export const navigationData = {
|
|
|
141
141
|
tags: 'KeyboardAwareScrollView',
|
|
142
142
|
screen: 'unicorn.components.KeyboardAwareScrollViewScreen'
|
|
143
143
|
},
|
|
144
|
+
{
|
|
145
|
+
title: 'Dynamic Fonts',
|
|
146
|
+
tags: 'dynamic fonts load download',
|
|
147
|
+
screen: 'unicorn.nativeComponents.DynamicFontsScreen'
|
|
148
|
+
},
|
|
144
149
|
{
|
|
145
150
|
title: 'Highlight Overlay',
|
|
146
151
|
tags: 'native overlay',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, {Component} from 'react';
|
|
2
2
|
import {StyleSheet} from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import {Assets, Colors, View, Text, Checkbox} from 'react-native-ui-lib'; //eslint-disable-line
|
|
4
4
|
|
|
5
5
|
export default class CheckboxScreen extends Component {
|
|
6
6
|
state = {
|
|
@@ -9,9 +9,10 @@ export default class CheckboxScreen extends Component {
|
|
|
9
9
|
value3: true,
|
|
10
10
|
value4: true,
|
|
11
11
|
value5: false,
|
|
12
|
-
value6: false
|
|
12
|
+
value6: false,
|
|
13
|
+
value7: true
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
+
|
|
15
16
|
render() {
|
|
16
17
|
return (
|
|
17
18
|
<View flex padding-page>
|
|
@@ -19,7 +20,8 @@ export default class CheckboxScreen extends Component {
|
|
|
19
20
|
Checkbox
|
|
20
21
|
</Text>
|
|
21
22
|
|
|
22
|
-
<Text
|
|
23
|
+
<Text marginV-s4>Customizable UI</Text>
|
|
24
|
+
|
|
23
25
|
<View row marginB-s5 centerV>
|
|
24
26
|
<Checkbox value={this.state.value1} onValueChange={value1 => this.setState({value1})}/>
|
|
25
27
|
<Checkbox
|
|
@@ -50,10 +52,18 @@ export default class CheckboxScreen extends Component {
|
|
|
50
52
|
containerStyle={styles.checkbox}
|
|
51
53
|
/>
|
|
52
54
|
|
|
55
|
+
<Checkbox
|
|
56
|
+
value={this.state.value7}
|
|
57
|
+
onValueChange={value7 => this.setState({value7})}
|
|
58
|
+
indeterminate
|
|
59
|
+
label={'Indeterminate state'}
|
|
60
|
+
color={Colors.green20}
|
|
61
|
+
containerStyle={styles.checkbox}
|
|
62
|
+
/>
|
|
63
|
+
|
|
53
64
|
<View row style={styles.row}>
|
|
54
|
-
<Text $textDefault marginR-10>
|
|
55
|
-
|
|
56
|
-
</Text>
|
|
65
|
+
<Text $textDefault marginR-10>Disabled States</Text>
|
|
66
|
+
|
|
57
67
|
<Checkbox
|
|
58
68
|
disabled
|
|
59
69
|
value={this.state.value5}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import React, {Component} from 'react';
|
|
3
3
|
import {StyleSheet, ScrollView} from 'react-native';
|
|
4
|
-
import {Colors, View, Text, ColorPicker, ColorPalette, ColorName, ColorInfo} from 'react-native-ui-lib';
|
|
4
|
+
import {Colors, View, Text, ColorPicker, ColorPalette, ColorName, ColorInfo, TouchableOpacity, ColorPickerDialog} from 'react-native-ui-lib';
|
|
5
5
|
import {renderMultipleSegmentOptions} from '../ExampleScreenPresenter';
|
|
6
6
|
|
|
7
7
|
interface State {
|
|
@@ -10,6 +10,7 @@ interface State {
|
|
|
10
10
|
customColors: string[];
|
|
11
11
|
paletteChange: boolean;
|
|
12
12
|
backgroundColor: string;
|
|
13
|
+
showPicker: boolean;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
const INITIAL_COLOR = Colors.$backgroundPrimaryHeavy;
|
|
@@ -31,7 +32,8 @@ export default class ColorPickerScreen extends Component<{}, State> {
|
|
|
31
32
|
textColor: Colors.$textDefaultLight,
|
|
32
33
|
customColors: [],
|
|
33
34
|
paletteChange: false,
|
|
34
|
-
backgroundColor: Colors.$backgroundDefault
|
|
35
|
+
backgroundColor: Colors.$backgroundDefault,
|
|
36
|
+
showPicker: false
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
onDismiss = () => {
|
|
@@ -123,6 +125,25 @@ export default class ColorPickerScreen extends Component<{}, State> {
|
|
|
123
125
|
</Text>
|
|
124
126
|
</View>
|
|
125
127
|
</View>
|
|
128
|
+
|
|
129
|
+
<Text center text60 marginT-10>Color Picker Dialog</Text>
|
|
130
|
+
<View center>
|
|
131
|
+
<TouchableOpacity
|
|
132
|
+
margin-10
|
|
133
|
+
center
|
|
134
|
+
style={{width: 60, height: 60, borderWidth: 1, borderRadius: 30, backgroundColor: color}}
|
|
135
|
+
onPress={() => this.setState({showPicker: true})}
|
|
136
|
+
>
|
|
137
|
+
<Text>Press</Text>
|
|
138
|
+
</TouchableOpacity>
|
|
139
|
+
</View>
|
|
140
|
+
<ColorPickerDialog
|
|
141
|
+
visible={this.state.showPicker}
|
|
142
|
+
initialColor={color}
|
|
143
|
+
key={color}
|
|
144
|
+
onDismiss={() => this.setState({showPicker: false})}
|
|
145
|
+
onSubmit={this.onSubmit}
|
|
146
|
+
/>
|
|
126
147
|
</ScrollView>
|
|
127
148
|
);
|
|
128
149
|
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import React, {Component, Fragment} from 'react';
|
|
2
|
+
import {ScrollView} from 'react-native';
|
|
3
|
+
import {View, Text, Button, DynamicFonts} from 'react-native-ui-lib';
|
|
4
|
+
import {renderMultipleSegmentOptions} from '../ExampleScreenPresenter';
|
|
5
|
+
|
|
6
|
+
enum FontLoadingEnum {
|
|
7
|
+
SINGLE_FONT = 'singleFont',
|
|
8
|
+
FONT_FAMILY = 'fontFamily'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type State = {
|
|
12
|
+
fontLoadingType: FontLoadingEnum;
|
|
13
|
+
loadedFonts: string[];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default class DynamicFontsScreen extends Component<{}, State> {
|
|
17
|
+
private fontDownloader: InstanceType<typeof DynamicFonts> = new DynamicFonts({debug: true});
|
|
18
|
+
|
|
19
|
+
state = {
|
|
20
|
+
fontLoadingType: FontLoadingEnum.SINGLE_FONT,
|
|
21
|
+
loadedFonts: []
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
renderSingleFont = () => {
|
|
25
|
+
const {loadedFonts} = this.state;
|
|
26
|
+
return (
|
|
27
|
+
<Fragment>
|
|
28
|
+
<Text style={{fontSize: 24, lineHeight: 28, fontFamily: 'System'}}>{`
|
|
29
|
+
System:
|
|
30
|
+
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
|
|
31
|
+
`}</Text>
|
|
32
|
+
{loadedFonts.length > 0 && (
|
|
33
|
+
<Text marginT-20 style={{fontSize: 24, lineHeight: 28, fontFamily: loadedFonts[0]}}>{`
|
|
34
|
+
${loadedFonts}:
|
|
35
|
+
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
|
|
36
|
+
`}</Text>
|
|
37
|
+
)}
|
|
38
|
+
<Button
|
|
39
|
+
marginV-20
|
|
40
|
+
label="Load a single font"
|
|
41
|
+
onPress={async () => {
|
|
42
|
+
try {
|
|
43
|
+
const loadedFonts = await this.fontDownloader.getFont({
|
|
44
|
+
fontUri:
|
|
45
|
+
'https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/TypographyKits/fonts/Vollkorn/Vollkorn-Regular.ttf',
|
|
46
|
+
fontName: 'Vollkorn-Regular',
|
|
47
|
+
fontExtension: 'ttf'
|
|
48
|
+
});
|
|
49
|
+
this.setState({loadedFonts: [loadedFonts]});
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.log('Error!', error);
|
|
52
|
+
}
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
</Fragment>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
renderFontFamily = () => {
|
|
60
|
+
const {loadedFonts} = this.state;
|
|
61
|
+
return (
|
|
62
|
+
<Fragment>
|
|
63
|
+
<Text style={{fontSize: 16, lineHeight: 18, fontFamily: 'System'}}>{`
|
|
64
|
+
System:
|
|
65
|
+
ABCDEFGH abcdefgh
|
|
66
|
+
`}</Text>
|
|
67
|
+
<ScrollView>
|
|
68
|
+
{loadedFonts?.map(loadedFont => (
|
|
69
|
+
<Text key={loadedFont} style={{fontSize: 16, lineHeight: 18, fontFamily: loadedFont}}>{`
|
|
70
|
+
${loadedFont}:
|
|
71
|
+
ABCDEFGH abcdefgh
|
|
72
|
+
`}</Text>
|
|
73
|
+
))}
|
|
74
|
+
</ScrollView>
|
|
75
|
+
|
|
76
|
+
<Button
|
|
77
|
+
marginV-20
|
|
78
|
+
label="Load a complete font family"
|
|
79
|
+
onPress={async () => {
|
|
80
|
+
try {
|
|
81
|
+
const loadedFonts = await this.fontDownloader.getFontFamily('https://wixmp-1d257fba8470f1b562a0f5f2.wixmp.com/TypographyKits/fonts/Vollkorn/',
|
|
82
|
+
[
|
|
83
|
+
'Bold',
|
|
84
|
+
'BoldItalic',
|
|
85
|
+
'ExtraBold',
|
|
86
|
+
'ExtraBoldItalic',
|
|
87
|
+
'Italic',
|
|
88
|
+
'Medium',
|
|
89
|
+
'MediumItalic',
|
|
90
|
+
'Regular',
|
|
91
|
+
'SemiBold'
|
|
92
|
+
],
|
|
93
|
+
'ttf',
|
|
94
|
+
'Vollkorn-');
|
|
95
|
+
this.setState({loadedFonts});
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.log('Error!', error);
|
|
98
|
+
}
|
|
99
|
+
}}
|
|
100
|
+
/>
|
|
101
|
+
</Fragment>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
render() {
|
|
106
|
+
const {fontLoadingType, loadedFonts} = this.state;
|
|
107
|
+
return (
|
|
108
|
+
<View bg-grey80 flex padding-20>
|
|
109
|
+
{renderMultipleSegmentOptions.call(this, 'Font loading:', 'fontLoadingType', [
|
|
110
|
+
{label: 'Single', value: FontLoadingEnum.SINGLE_FONT},
|
|
111
|
+
{label: 'Family', value: FontLoadingEnum.FONT_FAMILY}
|
|
112
|
+
])}
|
|
113
|
+
<View flex center key={`${loadedFonts}`}>
|
|
114
|
+
{fontLoadingType === FontLoadingEnum.SINGLE_FONT ? this.renderSingleFont() : this.renderFontFamily()}
|
|
115
|
+
{loadedFonts && <Text text80>Loaded fonts: {loadedFonts.map(loadedFont => `${loadedFont} `)}</Text>}
|
|
116
|
+
</View>
|
|
117
|
+
</View>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export function registerScreens(registrar) {
|
|
2
|
+
registrar('unicorn.nativeComponents.DynamicFontsScreen', () => require('./DynamicFontsScreen').default);
|
|
2
3
|
registrar('unicorn.nativeComponents.HighlightOverlayViewScreen', () => require('./HighlightOverlayViewScreen').default);
|
|
3
4
|
registrar('unicorn.nativeComponents.SafeAreaSpacerViewScreen', () => require('./SafeAreaSpacerViewScreen').default);
|
|
4
5
|
registrar('unicorn.nativeComponents.KeyboardTrackingViewScreen', () => require('./KeyboardTrackingViewScreen').default);
|