Skip to content

Commit d76f317

Browse files
committed
Reverting changes to screens
1 parent 804b06e commit d76f317

File tree

3 files changed

+132
-24
lines changed

3 files changed

+132
-24
lines changed

demo/src/screens/componentScreens/IconScreen.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ const IconScreen = () => {
1616
<Icon
1717
margin-30
1818
size={customSize ? size : undefined}
19-
tintColor={customColor ? (color as string) : undefined}
19+
tintColor={customColor ? color as string : undefined}
2020
source={Assets.icons.search}
2121
/>
2222
</View>
23+
2324
<View marginB-s3 row>
2425
<Text marginR-s2>Custom Size</Text>
2526
<Switch value={customSize} onValueChange={setCustomSize}/>
@@ -28,6 +29,7 @@ const IconScreen = () => {
2829
<Text marginB-50 marginT-s2>
2930
Custom size: {size}
3031
</Text>
32+
3133
<View marginB-s3 row>
3234
<Text marginR-s2>Custom Color</Text>
3335
<Switch value={customColor} onValueChange={setCustomColor}/>

demo/src/screens/foundationScreens/ColorsScreen.js

Lines changed: 114 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ import {
1111
Icon,
1212
Button,
1313
TextField,
14-
Incubator
14+
Incubator,
15+
ColorPalette,
16+
ColorPickerDialog
1517
} from 'react-native-ui-lib';
18+
import {renderBooleanOption} from '../ExampleScreenPresenter';
1619

1720
const {Toast} = Incubator;
1821

@@ -42,7 +45,14 @@ class ColorsScreen extends Component {
4245
searchValue: '',
4346
filteredTokens: [],
4447
showToast: false,
45-
message: undefined
48+
message: undefined,
49+
currentColor: Colors.$textPrimary,
50+
showPicker: false,
51+
isDefaultOptions: false,
52+
adjustLightness: false,
53+
adjustSaturation: false,
54+
addDarkestTints: true,
55+
avoidReverseOnDark: true
4656
};
4757

4858
scrollViewRef = React.createRef();
@@ -281,13 +291,102 @@ class ColorsScreen extends Component {
281291
);
282292
}
283293

294+
/** Color Palette */
295+
296+
showColorPicker = () => {
297+
this.setState({showPicker: true});
298+
};
299+
300+
onValueChange = (color) => {
301+
this.setState({currentColor: color});
302+
};
303+
304+
onSubmit = (color) => {
305+
this.setState({currentColor: color});
306+
};
307+
308+
onDismiss = () => {
309+
this.setState({showPicker: false});
310+
};
311+
312+
setDefaultOptions = () => {
313+
const designKitsOptions = {adjustLightness: false, adjustSaturation: false, addDarkestTints: true, avoidReverseOnDark: true};
314+
const defaultOptions = {adjustLightness: true, adjustSaturation: true, addDarkestTints: false, avoidReverseOnDark: false};
315+
if (this.state.isDefaultOptions) {
316+
this.setState({...designKitsOptions, isDefaultOptions: false});
317+
} else {
318+
this.setState({...defaultOptions, isDefaultOptions: true});
319+
}
320+
};
321+
322+
renderColorPicker = () => {
323+
const {showPicker, currentColor} = this.state;
324+
return (
325+
<ColorPickerDialog
326+
visible={showPicker}
327+
initialColor={currentColor}
328+
key={currentColor}
329+
onDismiss={this.onDismiss}
330+
onSubmit={this.onSubmit}
331+
/>
332+
);
333+
};
334+
335+
renderOptions = () => {
336+
return (
337+
<View padding-20>
338+
{renderBooleanOption.call(this, 'adjustLightness', 'adjustLightness')}
339+
{renderBooleanOption.call(this, 'adjustSaturation', 'adjustSaturation')}
340+
{renderBooleanOption.call(this, 'addDarkestTints', 'addDarkestTints')}
341+
{renderBooleanOption.call(this, 'avoidReverseOnDark', 'avoidReverseOnDark')}
342+
<Button label={this.state.isDefaultOptions ? 'Reset example' : 'Set defaults'} onPress={this.setDefaultOptions}/>
343+
</View>
344+
);
345+
};
346+
347+
renderColorPalette = () => {
348+
const {currentColor, adjustLightness, adjustSaturation, addDarkestTints, avoidReverseOnDark} = this.state;
349+
const paletteOptions = {adjustLightness, adjustSaturation, addDarkestTints, avoidReverseOnDark};
350+
const palette = Colors.generateColorPalette(currentColor, paletteOptions);
351+
return (
352+
<View margin-12 br40 style={{borderWidth: 1}}>
353+
{this.renderOptions()}
354+
<View center row>
355+
<TouchableOpacity
356+
marginH-10
357+
style={[styles.colorBox, {backgroundColor: currentColor}]}
358+
onPress={this.showColorPicker}
359+
/>
360+
<ColorPalette
361+
colors={palette}
362+
value={currentColor}
363+
swatchStyle={styles.swatchStyle}
364+
containerStyle={{marginLeft: -10}}
365+
onValueChange={this.onValueChange}
366+
/>
367+
</View>
368+
</View>
369+
);
370+
};
371+
372+
renderColorPaletteExample = () => {
373+
return (
374+
<>
375+
<Text text50 marginL-20>Generate Color Palette</Text>
376+
{this.renderColorPalette()}
377+
{this.renderColorPicker()}
378+
</>
379+
);
380+
};
381+
284382
render() {
285383
return (
286384
<>
287385
{this.renderSearch()}
288386
<ScrollView ref={this.scrollViewRef}>
289387
{this.renderDesignTokens()}
290388
{this.renderColors(SYSTEM_COLORS, 'SYSTEM COLORS')}
389+
{this.renderColorPaletteExample()}
291390
</ScrollView>
292391
{this.renderToast()}
293392
</>
@@ -303,6 +402,19 @@ const styles = StyleSheet.create({
303402
searchField: {
304403
padding: Spacings.s3,
305404
borderRadius: 8
405+
},
406+
colorBox: {
407+
width: 60,
408+
height: 60,
409+
borderWidth: 1,
410+
borderRadius: 30
411+
},
412+
swatchStyle: {
413+
width: 18,
414+
height: 40,
415+
borderRadius: 10,
416+
marginLeft: 4,
417+
marginRight: 4
306418
}
307419
});
308420

demo/src/screens/incubatorScreens/IncubatorSliderScreen.tsx

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,14 @@ const IncubatorSliderScreen = () => {
201201
<Text text90 $textNeutral>
202202
DEFAULT
203203
</Text>
204-
{
205-
// @ts-ignore
206-
<GradientSlider
207-
color={color}
208-
containerStyle={styles.gradientSliderContainer}
209-
onValueChange={onGradientValueChange}
210-
// @ts-expect-error
211-
ref={this.gradientSlider}
212-
migrate
213-
/>
214-
}
204+
<GradientSlider
205+
color={color}
206+
containerStyle={styles.gradientSliderContainer}
207+
onValueChange={onGradientValueChange}
208+
// @ts-expect-error
209+
ref={this.gradientSlider}
210+
migrate
211+
/>
215212
<View style={styles.box}>
216213
<View style={{flex: 1, backgroundColor: color, opacity: alpha}}/>
217214
</View>
@@ -220,16 +217,13 @@ const IncubatorSliderScreen = () => {
220217
<Text text90 $textNeutral>
221218
HUE
222219
</Text>
223-
{
224-
// @ts-ignore
225-
<GradientSlider
226-
type={GradientSlider.types.HUE}
227-
color={COLOR}
228-
containerStyle={styles.gradientSliderContainer}
229-
onValueChange={onGradientValueChange}
230-
migrate
231-
/>
232-
}
220+
<GradientSlider
221+
type={GradientSlider.types.HUE}
222+
color={COLOR}
223+
containerStyle={styles.gradientSliderContainer}
224+
onValueChange={onGradientValueChange}
225+
migrate
226+
/>
233227
<View style={styles.box}>
234228
<View style={{flex: 1, backgroundColor: color}}/>
235229
</View>

0 commit comments

Comments
 (0)