Skip to content

Commit 1d9a811

Browse files
authored
New component - ColorPickerDialog (#2737)
* Expose ColorPickerDialog component * add to demo screen
1 parent f1e6dd4 commit 1d9a811

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

demo/src/screens/componentScreens/ColorPickerScreen.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import _ from 'lodash';
22
import React, {Component} from 'react';
33
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';
55
import {renderMultipleSegmentOptions} from '../ExampleScreenPresenter';
66

77
interface State {
@@ -10,6 +10,7 @@ interface State {
1010
customColors: string[];
1111
paletteChange: boolean;
1212
backgroundColor: string;
13+
showPicker: boolean;
1314
}
1415

1516
const INITIAL_COLOR = Colors.$backgroundPrimaryHeavy;
@@ -31,7 +32,8 @@ export default class ColorPickerScreen extends Component<{}, State> {
3132
textColor: Colors.$textDefaultLight,
3233
customColors: [],
3334
paletteChange: false,
34-
backgroundColor: Colors.$backgroundDefault
35+
backgroundColor: Colors.$backgroundDefault,
36+
showPicker: false
3537
};
3638

3739
onDismiss = () => {
@@ -123,6 +125,25 @@ export default class ColorPickerScreen extends Component<{}, State> {
123125
</Text>
124126
</View>
125127
</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+
/>
126147
</ScrollView>
127148
);
128149
}

src/components/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export default {
3535
get ColorPalette() {
3636
return require('./colorPicker/ColorPalette').default;
3737
},
38+
get ColorPickerDialog() {
39+
return require('./colorPicker/ColorPickerDialog').default;
40+
},
3841
get ColorPicker() {
3942
return require('./colorPicker').default;
4043
},

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export {default as ChipsInput, ChipsInputProps, ChipsInputChipProps} from './com
6464
export {default as Chip, ChipProps} from './components/chip';
6565
export {default as ColorPicker, ColorPickerProps} from './components/colorPicker';
6666
export {default as ColorPalette, ColorPaletteProps} from './components/colorPalette';
67+
export {default as ColorPickerDialog, ColorPickerDialogProps} from './components/colorPicker/ColorPickerDialog';
6768
export {default as ColorSliderGroup, ColorSliderGroupProps} from './components/slider/ColorSliderGroup';
6869
export {default as ColorSwatch, ColorSwatchProps, ColorInfo} from './components/colorSwatch';
6970
export {default as ConnectionStatusBar, ConnectionStatusBarProps} from './components/connectionStatusBar';

0 commit comments

Comments
 (0)