alabsi91 / reanimated-color-picker Goto Github PK
View Code? Open in Web Editor NEWA Pure JavaScript Color Picker for React Native
Home Page: https://alabsi91.github.io/reanimated-color-picker/
License: MIT License
A Pure JavaScript Color Picker for React Native
Home Page: https://alabsi91.github.io/reanimated-color-picker/
License: MIT License
Getting this warniong with the <Swatches/>
component:
WARN (ADVICE) View #963 of type RCTView has a shadow set but cannot calculate shadow efficiently. Consider setting a background color to fix this, or apply the shadow to a more specific component.
Use the <Swatches/>
component like:
<Swatches
style={{ paddingTop: 10, paddingHorizontal: 10 }}
swatchStyle={{
shadowOpacity: enableSwatchShadow ? 0.2 : 0,
shadowRadius: 4,
width: 30,
height: 30
}}
colors={SWATCHES_COLORS}
/>
No response
3.0.1
0.73.4
3.8.1
2.14.0
iOS
Hermes
Expo bare workflow
Paper (Old Architecture)
Debug mode
Error tips reactNativeReanimated.useSharedValue is not a function
When I look in ColorPicker.js
, find that import { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
, goto react-native-reanimated
package, I do not find useSharedValue
value or function, I guess its version was wrong.
ColorPicker is not working properly when using Panel3 and wrapping that component in ScrollView, It works fine when disabling the scroll in ScrollView. Ideally, it should work seamlessly with ScrollView as well
No response
2.4.2
0.68.0
2.11.0
2.5.0
Android, iOS
V8
React Native (without Expo)
Paper (Old Architecture)
Release mode
Reproducible Example:
Hey there! ๐ This is probably one of the best color pickers! Awesome work :)
I was wondering if there's a way to adjust thumb scaling when a pan gesture starts, and as far as I can see, it isn't possible (yet). Do you want me to open a new PR with the implementation of this feature?
I'm having a memory leak problem when using the library, when I do excessive color change actions on the panel or slider the app crashes and closes. One of the solutions I thought of would be to activate the input or slider only in the ColorPicker OnComplete action and not automatically when the user changes the color but I don't know how to implement it:
<ColorPicker
value="red"
onComplete={onSelectColor}
boundedThumb
thumbSize={18}
thumbStyle={{ borderWidth: 10 }}
thumbInnerStyle={{ backgroundColor: 'transparent' }}
>
<Panel1
style={{
height: 150,
}}
/>
<InputWidget
containerStyle={{
marginTop: 10,
}}
inputTitleStyle={{ display: 'none' }}
iconStyle={{
display: 'none',
width: 0,
}}
inputStyle={{
height: 30,
width: 85,
backgroundColor: theme.colors.back1,
borderColor: theme.colors.sysGrey4,
alignSelf: 'flex-end',
textTransform: 'uppercase',
color: theme.colors.text1,
fontSize: 15,
borderRadius: 5,
marginRight: 0,
}}
/>
<HueSlider
style={{ marginTop: 10, borderRadius: 22 }}
sliderThickness={18}
/>
No response
2.3.2
0.66.3
2.2.4
2.8.0
Android, iOS
JSC
React Native (without Expo)
Paper (Old Architecture)
Debug mode
It would be really useful to be able to pass the initial color when opening the color panel. I could look into adding it as a functionality if any help is needed.
Using <Panel5 />
, when first loading the picker, the color set as "value" is not reflected in the selector. The color is indeed selected, but the selector remains on "white". This happens on some colors, not all.
For example, if setting "black", "#785800" or "#0056d6" to "value", the selector stays on those colors when the picker in loaded.
But if setting "#0041a8", "#bd3812" or "#f5ed00" to "value", the right color is set and shows in the preview, but the selector stays on the "white" square. Even though all these colors are available on the grid. Again, the value color is selected, but visually the selector stays on "white".
<ColorPicker value={'#0041a8'}
<Panel5 />
No response
2.3.5
0.72.4
3.5.4
2.12.1
iOS
Hermes
React Native (without Expo)
Fabric (New Architecture)
Debug mode
Is there a way to have a color slider without having the swatches? It seems that using a hue slider only works when you add a swatches component, and I just want a color slider
The problem is Panel1 can modifiy HueSlider position when you move to a pure black or pure white (see video).
HueSlider is move too from right to left if you move to the righest position.
This occours in iOS and Android
Example Code:
const [internalColor, setInternalColor] = useState<string>(color);
const onColorSelect = ({ hex }: { hex: string }) => setInternalColor(hex);
return (
<ColorPicker
value={internalColor}
sliderThickness={16}
thumbSize={32}
thumbShape="circle"
onComplete={onColorSelect}
boundedThumb
>
<Panel1 />
<HueSlider />
<View>
<View>
<Text>{translate('addIncomeForm.customColorPicker.hex')}</Text>
<InputWidget
disableAlphaChannel
formats={['HEX']}
/>
</View>
<View>
<Text>{translate('addIncomeForm.customColorPicker.rgb')}</Text>
<InputWidget
disableAlphaChannel
formats={['RGB']}
/>
</View>
</View>
</ColorPicker>
)
No response
2.3.4
0.71.13
3.5.4
2.13.1
Android, iOS
Hermes
React Native (without Expo)
Paper (Old Architecture)
Release mode
Hi!, I'm using the Swatches to assign a color to some object, the component is so defined:
<ColorPicker
value={ac.dc.color.value}
sliderThickness={25}
thumbSize={30}
style={{ width: '75%', justifyContent: 'center' }}
onComplete={ac.dc.onSelectColor}>
<Swatches
swatchStyle={styles.swatchStyle}
colors={PedalsColourCode}
/>
</ColorPicker>
the colors assigned to "colors" are the following:
'#FF9800',
'#FF5722',
'#795548',
'#9E9E9E',
'#607D8B',
When I assign the color to my object, with onSelectColor, the "hex" assigned is similar BUT different from that one defined.
Eg:
PedalsColourCode: ["#FF9800", "#FF5722", "#795548", "#9E9E9E", "#607D8B"]
hexColourAssigned: #795649
The assigned hex #795649 is different from the defined #795548.
Am I missing something?
When trying to use the color picker with Expo SDK 51 the following error occurs. This issue only occurs on Web. I can confirm it doesn't happen on Android, not sure about iOS.
Static Rendering Error (Node.js)
Cannot access 'colorKitUI' before initialization
Call Stack
factory
node_modules/reanimated-color-picker/lib/commonjs/colorKit/index.js
loadModuleImplementation
node_modules/metro-runtime/src/polyfills/require.js
guardedLoadModule
node_modules/metro-runtime/src/polyfills/require.js
require
node_modules/metro-runtime/src/polyfills/require.js
factory
node_modules/reanimated-color-picker/lib/commonjs/ColorPicker.js
loadModuleImplementation
node_modules/metro-runtime/src/polyfills/require.js
guardedLoadModule
node_modules/metro-runtime/src/polyfills/require.js
require
node_modules/metro-runtime/src/polyfills/require.js
factory
node_modules/reanimated-color-picker/lib/commonjs/index.js
loadModuleImplementation
node_modules/metro-runtime/src/polyfills/require.js
Create a bare Expo SDK 51 project and import reanimated-color-picker
No response
3.0.3
0.74.1
3.10.1
2.16.1
Web
Hermes
Expo bare workflow
Paper (Old Architecture)
Debug mode
Hi - love this project. I am currently using it to work on a basic react app. I was wondering if there was any roadmap to expand and add more Panels? Ideally I am looking for one that gives Panel 3 level control but also allows the brightness slider to be embedded into the Panel such that the end user can get darker shades without needing to adjust another slider.
I'd be happy to give implementing a go if you're open to a pull request.
When I use the colorpicker, the library calculates all the color convention values, but the HSV variant throws an error:
index.ts:1359 [colorKit.HSV] An error occurred while attempting to convert the provided parameter into an
HSV color. As a result, the default color "black" will be used instead.
I use the <Panel5 />
picker and the hex value as output. I don't use the HSV at all.
No response
3.0.1
0.72.6
~3.3.0
~2.12.0
Android, iOS, Web
Hermes
Expo managed workflow
Paper (Old Architecture)
Debug mode
When the preview style there is a set border radius that is bigger than zero it causes a unclean overlay of the transparancy grid below it to overlap which results in an ugly looking edge.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
<Preview />
ComponentNo response
2.2.0
0.71.6
2.14.4
2.9.0
Android, Web
JSC
Expo managed workflow
Paper (Old Architecture)
Debug mode
I'm randomly getting this error with reanimated latest version, and I think it might be related to the Preview componet and its animatedProps.
Will do more research later and complete with more info.
No steps
No response
3.0.3
0.73.4
3.6.2
2.14.0
iOS
Hermes
Expo managed workflow
Fabric (New Architecture)
Release mode
In 2.x versions, setting the thumbColor
, atleast on the default thumb, would set the color of the ring surrounding the thumb, but the inner color would still reflect the color selection.
In 3.0, setting the thumbColor
will control the fill color and the surrounding ring color.
Is there a way to control the default thumb's outer ring color without overriding the fill color like in 2.x?
Thank you for all the incredible work you've done with this library!
Render a Panel3 with the thumbColor
prop
https://snack.expo.dev/@adamhari-kashoo/reanimated-color-picker
(visit Panel3 Brightness)
3.0.0
0.73.2
3.6.1
2.14.0
Web
JSC
React Native (without Expo)
Paper (Old Architecture)
Debug mode
in ios slider does not work but in Android, it works fine.
yes, put 'react-native-reanimated/plugin' in babel.config.js
all steps I did as your mentioned in the documentation, but does not work
you can use any example code
No response
2.3.0
0.71.7
3.1.0
2.10.1
iOS
JSC
React Native (without Expo)
Fabric (New Architecture)
Debug mode
Error: Exception in HostFunction: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZN8facebook5react19ReadableNativeArrayC1EN5folly7dynamicE" referenced by...
No response
2.3.2
0.72.3
2.17.0
2.12.1
Android
Hermes
React Native (without Expo)
Paper (Old Architecture)
Debug mode
Hi, thank you for the nice library.
I am trying to use the Panel5
component to allow users to pick colors, but the function passed to the onChange
prop of the ColorPicker
wrapper doesn't execute.
I am using react-native-reanimated
version 2.8.0
, and have found out that when I upgrade react-native-reanimated
to a version higher than 3.0.0
, the passed function gets executed as expected.
However, due to other libraries depending on react-native-reanimated
, it is difficult for me to upgrade the version react-native-reanimated
.
additional information
In the ColorPicker
component in your library, the below changes do make the component work as I have expected. But I have no deep understanding of the code. Just adding this in case it might help :)
// onGestureChange function inside ColorPicker.tsx
const onGestureChange = (color?: SupportedColorFormats) => {
'worklet';
if (!onChange) return;
const colorObject = returnedResults(color);
// executing runOnJS makes it work, but I have no understanding of why..
runOnJS(onChange)(colorObject)
// below is the original code,
// try {
// // run on the UI thread
// onChange(colorObject);
// } catch (error) {
// // run on the JS thread
// runOnJS(onChange)(colorObject);
// }
};
react-native-reanimated
version 2.8.0
, react-native-gesture-handler
version 2.10.1
with reanimated-color-picker
version 3.0.3
onChange
prop of the ColorPicker
wrapper componentPanel5
as a child to the Colorpicker
wrapper.Panel5
component -> doesn't trigger function passed to the onChange
prop, making it impossible to get the pressed color value.No response
3.0.3
0.66.4
2.8.0
2.10.1
iOS
JSC
React Native (without Expo)
Paper (Old Architecture)
Debug mode
I am just copy pasting one of your examples but it is not working on my side.
color.hex is not moving when I press anywhere on the Color picker.
selectedColor.value is not updating.
Plus I am inside a react-native Modal, I am using ScrollView from react-native-gesture-handler and it is not working as expected, i cant move inside the Panel3.
https://github.com/alabsi91/reanimated-color-picker/blob/main/Example/src/Panel3Saturation.tsx
const selectedColor = useSharedValue(colors.cards.black);
const onColorSelect = (color: returnedResults) => {
'worklet';
console.log('color.hex:', color.hex);
selectedColor.value = color.hex;
};
const backgroundColorStyle = useAnimatedStyle(() => ({
backgroundColor: selectedColor.value,
}));
return (
<Animated.View style={[styles.header, backgroundColorStyle]}>
<Text>Test</Text>
<ScrollView style={styles.scrollView}>
<View style={styles.colorPickerContainer}>
<ColorPicker
thumbSize={THUMB_SIZE}
style={styles.colorPicker}
value={selectedColor.value}
onChange={onColorSelect}>
<Panel3 />
</ColorPicker>
</View>
</ScrollView>
</Animated.View>
)
Thank you for your help!
Copy paste this example:
https://github.com/alabsi91/reanimated-color-picker/blob/main/Example/src/Panel3Saturation.tsx
No response
^3.0.3
0.73.4
^3.7.0
^2.15.0
Android, iOS
JSC
React Native (without Expo)
Paper (Old Architecture)
Debug mode
I am experiencing an issue with the ColorPicker component when used with Panel3. Specifically, the ColorPicker scrolls along with the page when it should remain stationary.
Here are the details:
Scrolling Issue: The ColorPicker moves when scrolling within a KeyboardAwareScrollView. I also tried using react-native-gesture-handler's ScrollView but encountered the same problem.
Function Callbacks: We are using two functions, onChange and onComplete. When the scrolling issue occurs, the onComplete function does not get called.
Problems:
I am sharing the problem video for a better understanding.
here is my code:
<View style={styles.container}>
<GestureHandlerRootView style={{ paddingBottom: 150 }}>
<KeyboardAwareScrollView
enableOnAndroid
bounces={false}
showsVerticalScrollIndicator={false}
contentContainerStyle={{ paddingBottom: normalize(36) }}
keyboardShouldPersistTaps="handled"
enableResetScrollToCoords={false}
>
<View style={styles.colorWheelContainer}>
<ColorPicker
value={defaultColor}
thumbInnerStyle={[styles.thumbStyle, thumbStyle]}
onChange={onChange}
onComplete={(color) => {
onComplete(color?.hex)
}}
>
<Panel3 style={[styles.panelStyle, colorWheelStyle]} />
</ColorPicker>
</View>
</KeyboardAwareScrollView>
</GestureHandlerRootView>
</View>
To reproduce do the same thing which is in the video, Just press press and drag.
No response
3.4.2
0.70.10
2.14.0
2.5.0
Android, iOS
JSC
React Native (without Expo)
Paper (Old Architecture)
Debug mode
There should be a setting to say if the colorpicker should support transparancy or is always to be at full visibility.
getting this error message 'TypeError: (0 , _$$_REQUIRE(...).useSharedValue) is not a function' whenever im importing useSharedValue, useAnimatedStyle
import useSharedValue, useAnimatedStyle
No response
2.3.2
0.66
1.7.0
1.9
Android, iOS
JSC
React Native (without Expo)
Paper (Old Architecture)
Debug mode
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.