reanimated-color-picker 0.0.13 → 0.0.14

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.
@@ -11,12 +11,6 @@ import Animated, {
11
11
  } from 'react-native-reanimated';
12
12
  import { ALPHA_HEX, COLOR_HSVA, CONTRAST_RATIO, HSL_HEX, HSL_RGB, HSV_HSL } from './ColorsConversionFormulas';
13
13
 
14
- const PANEL_IMAGE = require('./assets/Background.png'),
15
- OPACITY_IMAGE = require('./assets/Opacity.png'),
16
- HUE_IMAGE = require('./assets/Hue.png'),
17
- SATURATION_IMAGE = require('./assets/Saturation.png'),
18
- BRIGHTNESS_IMAGE = require('./assets/Brightness.png');
19
-
20
14
  const isRtl = I18nManager.isRTL,
21
15
  HUE_MAX = 360,
22
16
  SB_MAX = 100,
@@ -62,7 +56,17 @@ const ReText = props => {
62
56
  underlineColorAndroid='transparent'
63
57
  editable={false}
64
58
  value={text.value}
65
- style={[{ fontWeight: 'bold', padding: 0, height: '100%', width: '100%', textAlign: 'center' }, customStyle, style]}
59
+ style={[
60
+ {
61
+ fontWeight: 'bold',
62
+ padding: 0,
63
+ height: '100%',
64
+ width: '100%',
65
+ textAlign: 'center',
66
+ },
67
+ customStyle,
68
+ style,
69
+ ]}
66
70
  {...{ animatedProps }}
67
71
  />
68
72
  );
@@ -82,7 +86,8 @@ export default function ColorPicker({
82
86
  const initialColor = useRef(COLOR_HSVA(value));
83
87
  const previewColorFormat = useRef('hex');
84
88
 
85
- const panelThumbeSize = useRef(thumbsSize);
89
+ const panel1ThumbeSize = useRef(thumbsSize);
90
+ const panel2ThumbeSize = useRef(thumbsSize);
86
91
  const hueThumbeSize = useRef(thumbsSize);
87
92
  const brightnessThumbeSize = useRef(thumbsSize);
88
93
  const saturationThumbeSize = useRef(thumbsSize);
@@ -97,11 +102,25 @@ export default function ColorPicker({
97
102
  const { h, s, l } = HSV_HSL(color.h, color.s, color.b);
98
103
  return `hsl(${h}, ${s}%, ${l}%)`;
99
104
  };
100
- const color_hsla = (color = { h: hue.current, s: saturation.current, b: brightness.current, a: alpha.current }) => {
105
+ const color_hsla = (
106
+ color = {
107
+ h: hue.current,
108
+ s: saturation.current,
109
+ b: brightness.current,
110
+ a: alpha.current,
111
+ }
112
+ ) => {
101
113
  const { h, s, l } = HSV_HSL(color.h, color.s, color.b);
102
114
  return `hsla(${h}, ${s}%, ${l}%, ${color.a / 100})`;
103
115
  };
104
- const color_hex = (color = { h: hue.current, s: saturation.current, b: brightness.current, a: alpha.current }) => {
116
+ const color_hex = (
117
+ color = {
118
+ h: hue.current,
119
+ s: saturation.current,
120
+ b: brightness.current,
121
+ a: alpha.current,
122
+ }
123
+ ) => {
105
124
  const { h, s, l } = HSV_HSL(color.h, color.s, color.b);
106
125
  return HSL_HEX(h, s, l) + (color.a === 100 ? '' : ALPHA_HEX(color.a));
107
126
  };
@@ -110,7 +129,14 @@ export default function ColorPicker({
110
129
  const { r, g, b } = HSL_RGB(h, s, l);
111
130
  return `rgb(${r}, ${g}, ${b})`;
112
131
  };
113
- const color_rgba = (color = { h: hue.current, s: saturation.current, b: brightness.current, a: alpha.current }) => {
132
+ const color_rgba = (
133
+ color = {
134
+ h: hue.current,
135
+ s: saturation.current,
136
+ b: brightness.current,
137
+ a: alpha.current,
138
+ }
139
+ ) => {
114
140
  const { h, s, l } = HSV_HSL(color.h, color.s, color.b);
115
141
  const { r, g, b } = HSL_RGB(h, s, l);
116
142
  return `rgba(${r}, ${g}, ${b}, ${color.a / 100})`;
@@ -118,11 +144,25 @@ export default function ColorPicker({
118
144
  const color_hsv = (color = { h: hue.current, s: saturation.current, b: brightness.current }) => {
119
145
  return `hsv(${color.h}, ${color.s}%, ${color.b}%)`;
120
146
  };
121
- const color_hsva = (color = { h: hue.current, s: saturation.current, b: brightness.current, a: alpha.current }) => {
147
+ const color_hsva = (
148
+ color = {
149
+ h: hue.current,
150
+ s: saturation.current,
151
+ b: brightness.current,
152
+ a: alpha.current,
153
+ }
154
+ ) => {
122
155
  return `hsva(${color.h}, ${color.s}%, ${color.b}%, ${color.a / 100})`;
123
156
  };
124
157
 
125
- const returnedResults = (color = { h: hue.current, s: saturation.current, b: brightness.current, a: alpha.current }) => {
158
+ const returnedResults = (
159
+ color = {
160
+ h: hue.current,
161
+ s: saturation.current,
162
+ b: brightness.current,
163
+ a: alpha.current,
164
+ }
165
+ ) => {
126
166
  return {
127
167
  hex: color_hex(color),
128
168
  rgb: color_rgb(color),
@@ -135,23 +175,33 @@ export default function ColorPicker({
135
175
  };
136
176
 
137
177
  const previewColor = useSharedValue(color_hex());
138
- const previewColorStyle = useAnimatedStyle(() => ({ backgroundColor: previewColor.value }));
178
+ const previewColorStyle = useAnimatedStyle(() => ({
179
+ backgroundColor: previewColor.value,
180
+ }));
139
181
  const previewColorWithoutOpacity = useAnimatedStyle(() => ({
140
182
  backgroundColor: previewColor.value.length > 7 ? previewColor.value.substring(0, 7) : previewColor.value,
141
183
  }));
142
184
  const activeHue = useSharedValue(HSL_HEX(hue.current, 100, 50));
143
- const activeHueStyle = useAnimatedStyle(() => ({ backgroundColor: activeHue.value }));
185
+ const activeHueStyle = useAnimatedStyle(() => ({
186
+ backgroundColor: activeHue.value,
187
+ }));
188
+
189
+ const saturationPanel1_handlePos = useSharedValue(0); // for saturation panle 1 adobe style
190
+ const brightnessPanel1_handlePos = useSharedValue(0); // for brightness panle 1 adobe style
191
+
192
+ const huePanel2_handlePos = useSharedValue(0); // for hue panle 2 windows style
193
+ const saturationPanel2_handlePos = useSharedValue(0); // for saturation panle 2 windows style
144
194
 
145
195
  const hue_handlePos = useSharedValue(0); // for hue slider
146
- const saturationPanel_handlePos = useSharedValue(0); // for saturation panle
147
196
  const saturationSlider_handlePos = useSharedValue(0); // for saturation slider
148
- const brightnessPanel_handlePos = useSharedValue(0); // for brightness panel
149
197
  const brightnessSlider_handlePos = useSharedValue(0); // for brightness slider
150
198
  const opacity_handlePos = useSharedValue(0); // for opacity slider
151
199
  const previewTextColor = useSharedValue('#ffffff'); // for result text color
152
200
  const previewText = useSharedValue(returnedResults()[previewColorFormat.current]); // for result text
153
201
 
154
- const previewTextColorStyle = useAnimatedStyle(() => ({ color: previewTextColor.value }));
202
+ const previewTextColorStyle = useAnimatedStyle(() => ({
203
+ color: previewTextColor.value,
204
+ }));
155
205
 
156
206
  const onGestureEventFinish = () => {
157
207
  onComplete?.(returnedResults());
@@ -194,6 +244,19 @@ export default function ColorPicker({
194
244
  onChange?.(returnedResults());
195
245
  };
196
246
 
247
+ const updateHS = (hueChannel, saturationChannel) => {
248
+ saturation.current = saturationChannel;
249
+ hue.current = hueChannel;
250
+ previewColor.value = color_hex(); // to update result color.
251
+ previewText.value = returnedResults()[previewColorFormat.current]; // update result text
252
+ // change result text color based on lightness
253
+ const contrast = CONTRAST_RATIO(hue.current, saturation.current, brightness.current, previewTextColor.value);
254
+ previewTextColor.value =
255
+ contrast < CONTRAST_RATIO_MIN ? (previewTextColor.value === '#ffffff' ? '#000000' : '#ffffff') : previewTextColor.value;
256
+
257
+ onChange?.(returnedResults());
258
+ };
259
+
197
260
  const updateHue = hueChannel => {
198
261
  hue.current = hueChannel;
199
262
  previewColor.value = color_hex(); // to update result color.
@@ -231,33 +294,38 @@ export default function ColorPicker({
231
294
  const contrast = CONTRAST_RATIO(hue.current, saturation.current, brightness.current, previewTextColor.value);
232
295
  previewTextColor.value =
233
296
  contrast < CONTRAST_RATIO_MIN ? (previewTextColor.value === '#ffffff' ? '#000000' : '#ffffff') : previewTextColor.value;
234
- // saturation
235
- saturationPanel_handlePos.value = withTiming(
236
- isRtl ? (s / SB_MAX) * width - width + panelThumbeSize.current / 2 : (s / SB_MAX) * width - panelThumbeSize.current / 2,
297
+ //~ saturation
298
+ saturationPanel1_handlePos.value = withTiming(
299
+ isRtl ? (s / SB_MAX) * width - width + panel1ThumbeSize.current / 2 : (s / SB_MAX) * width - panel1ThumbeSize.current / 2,
237
300
  duration
238
- );
301
+ ); // panel 1 adobe style
302
+ saturationPanel2_handlePos.value = withTiming(width - (s / SB_MAX) * width - panel2ThumbeSize.current / 2, duration); // panel 2 windows style
239
303
  saturationSlider_handlePos.value = withTiming(
240
304
  isRtl
241
305
  ? (s / SB_MAX) * width - width + saturationThumbeSize.current / 2
242
306
  : (s / SB_MAX) * width - saturationThumbeSize.current / 2,
243
307
  duration
244
308
  );
245
- // brightness
246
- brightnessPanel_handlePos.value = withTiming(width - (b / SB_MAX) * width - panelThumbeSize.current / 2, duration);
309
+ //~ brightness
310
+ brightnessPanel1_handlePos.value = withTiming(width - (b / SB_MAX) * width - panel1ThumbeSize.current / 2, duration);
247
311
  brightnessSlider_handlePos.value = withTiming(
248
312
  isRtl
249
313
  ? (b / SB_MAX) * width - width + brightnessThumbeSize.current / 2
250
314
  : (b / SB_MAX) * width - brightnessThumbeSize.current / 2,
251
315
  duration
252
316
  );
253
- // hue
317
+ //~ hue
254
318
  hue_handlePos.value = withTiming(
255
319
  isRtl
256
320
  ? width - (h / HUE_MAX) * width - width + hueThumbeSize.current / 2
257
321
  : width - (h / HUE_MAX) * width - hueThumbeSize.current / 2,
258
322
  100
259
323
  );
260
- // opacity
324
+ huePanel2_handlePos.value = withTiming(
325
+ isRtl ? (h / HUE_MAX) * width - width + panel2ThumbeSize.current / 2 : (h / HUE_MAX) * width - panel2ThumbeSize.current / 2,
326
+ duration
327
+ ); // panel 2 windows style
328
+ //~ opacity
261
329
  opacity_handlePos.value = withTiming(
262
330
  isRtl
263
331
  ? (a / OPACITY_MAX) * width - width + opacityThumbeSize.current / 2
@@ -291,9 +359,11 @@ export default function ColorPicker({
291
359
  previewColorFormat,
292
360
 
293
361
  setHandlesPos,
294
- saturationPanel_handlePos,
362
+ saturationPanel1_handlePos,
363
+ brightnessPanel1_handlePos,
364
+ saturationPanel2_handlePos,
365
+ huePanel2_handlePos,
295
366
  saturationSlider_handlePos,
296
- brightnessPanel_handlePos,
297
367
  brightnessSlider_handlePos,
298
368
  hue_handlePos,
299
369
  opacity_handlePos,
@@ -301,13 +371,15 @@ export default function ColorPicker({
301
371
  updateSaturation,
302
372
  updateBrightness,
303
373
  updateSB,
374
+ updateHS,
304
375
  updateOpacity,
305
376
  updateHue,
306
377
 
307
378
  tracksHeight,
308
379
  thumbsSize,
309
380
 
310
- panelThumbeSize,
381
+ panel1ThumbeSize,
382
+ panel2ThumbeSize,
311
383
  saturationThumbeSize,
312
384
  brightnessThumbeSize,
313
385
  hueThumbeSize,
@@ -331,18 +403,20 @@ export default function ColorPicker({
331
403
  return <GestureHandlerRootView style={[styles.wrapper, style]}>{ColorPickerModules}</GestureHandlerRootView>;
332
404
  }
333
405
 
334
- export function Panel({
406
+ export function Panel1({
335
407
  activeHueStyle,
336
408
  previewTextColor,
337
409
  previewColorWithoutOpacity,
338
- saturationPanel_handlePos,
410
+ saturationPanel1_handlePos,
411
+ brightnessPanel1_handlePos,
412
+ saturationPanel2_handlePos,
339
413
  saturationSlider_handlePos,
340
- brightnessPanel_handlePos,
341
414
  brightnessSlider_handlePos,
342
415
  updateSB,
343
416
  onGestureEventFinish,
344
417
  setHandlesPos,
345
- panelThumbeSize,
418
+ panel1ThumbeSize,
419
+ panel2ThumbeSize,
346
420
  brightnessThumbeSize,
347
421
  saturationThumbeSize,
348
422
  width,
@@ -350,7 +424,7 @@ export function Panel({
350
424
  thumbSize = thumbsSize, // by user
351
425
  style = {}, // by user
352
426
  }) {
353
- panelThumbeSize.current = thumbSize;
427
+ panel1ThumbeSize.current = thumbSize;
354
428
 
355
429
  useEffect(() => {
356
430
  setHandlesPos();
@@ -362,8 +436,8 @@ export function Panel({
362
436
  backgroundColor: previewTextColor.value === '#ffffff' ? '#ffffff50' : '#00000050',
363
437
  borderColor: previewTextColor.value,
364
438
  transform: [
365
- { translateX: saturationPanel_handlePos.value },
366
- { translateY: brightnessPanel_handlePos.value },
439
+ { translateX: saturationPanel1_handlePos.value },
440
+ { translateY: brightnessPanel1_handlePos.value },
367
441
  { scale: scale_panelHandle.value },
368
442
  ],
369
443
  }));
@@ -387,16 +461,20 @@ export function Panel({
387
461
  const saturationX = Math.round(percentX * SB_MAX);
388
462
  const brightnessY = Math.round(SB_MAX - percentY * SB_MAX);
389
463
 
390
- saturationPanel_handlePos.value = isRtl ? percentX * width - width + thumbSize / 2 : percentX * width - thumbSize / 2;
391
- brightnessPanel_handlePos.value = percentY * width - thumbSize / 2;
464
+ saturationPanel1_handlePos.value = isRtl ? percentX * width - width + thumbSize / 2 : percentX * width - thumbSize / 2;
465
+ brightnessPanel1_handlePos.value = percentY * width - thumbSize / 2;
392
466
 
393
467
  brightnessSlider_handlePos.value = isRtl
394
468
  ? (brightnessY / SB_MAX) * width - width + brightnessThumbeSize.current / 2
395
469
  : (brightnessY / SB_MAX) * width - brightnessThumbeSize.current / 2;
470
+
396
471
  saturationSlider_handlePos.value = isRtl
397
472
  ? (saturationX / SB_MAX) * width - width + saturationThumbeSize.current / 2
398
473
  : (saturationX / SB_MAX) * width - saturationThumbeSize.current / 2;
399
474
 
475
+ // panel 2 windows style
476
+ saturationPanel2_handlePos.value = width - (saturationX / SB_MAX) * width - panel2ThumbeSize.current / 2;
477
+
400
478
  runOnJS(updateSB)(saturationX, brightnessY);
401
479
  },
402
480
  onFinish: () => {
@@ -408,9 +486,135 @@ export function Panel({
408
486
  return (
409
487
  <PanGestureHandler onGestureEvent={panel_GestureEvent} minDist={0}>
410
488
  <Animated.View style={[styles.panel_container, style, { width, height: width }, styles.override, activeHueStyle]}>
411
- <Image source={PANEL_IMAGE} style={{ borderRadius: style.borderRadius ?? 5, width, height: width }} />
489
+ <Image
490
+ source={require('./assets/Background1.png')}
491
+ style={{
492
+ borderRadius: style.borderRadius ?? 5,
493
+ width,
494
+ height: width,
495
+ }}
496
+ />
412
497
  <Animated.View
413
- style={[styles.handle, { width: thumbSize, height: thumbSize, borderRadius: thumbSize / 2 }, panel_handleStyle]}
498
+ style={[
499
+ styles.handle,
500
+ {
501
+ width: thumbSize,
502
+ height: thumbSize,
503
+ borderRadius: thumbSize / 2,
504
+ },
505
+ panel_handleStyle,
506
+ ]}
507
+ >
508
+ <Animated.View style={[styles.handleInner, { borderRadius: thumbSize / 2 }, previewColorWithoutOpacity]} />
509
+ </Animated.View>
510
+ </Animated.View>
511
+ </PanGestureHandler>
512
+ );
513
+ }
514
+
515
+ export function Panel2({
516
+ previewTextColor,
517
+ previewColorWithoutOpacity,
518
+ saturationPanel1_handlePos,
519
+ saturationPanel2_handlePos,
520
+ huePanel2_handlePos,
521
+ hue_handlePos,
522
+ saturationSlider_handlePos,
523
+ onGestureEventFinish,
524
+ setHandlesPos,
525
+ panel1ThumbeSize,
526
+ panel2ThumbeSize,
527
+ hueThumbeSize,
528
+ saturationThumbeSize,
529
+ updateHS,
530
+ width,
531
+ thumbsSize,
532
+ thumbSize = thumbsSize, // by user
533
+ style = {}, // by user
534
+ }) {
535
+ panel2ThumbeSize.current = thumbSize;
536
+
537
+ useEffect(() => {
538
+ setHandlesPos();
539
+ }, []);
540
+
541
+ const scale_panelHandle = useSharedValue(1);
542
+
543
+ const panel_handleStyle = useAnimatedStyle(() => ({
544
+ backgroundColor: previewTextColor.value === '#ffffff' ? '#ffffff50' : '#00000050',
545
+ borderColor: previewTextColor.value,
546
+ transform: [
547
+ { translateX: huePanel2_handlePos.value },
548
+ { translateY: saturationPanel2_handlePos.value },
549
+ { scale: scale_panelHandle.value },
550
+ ],
551
+ }));
552
+
553
+ const panel_GestureEvent = useAnimatedGestureHandler({
554
+ onStart: (event, ctx) => {
555
+ ctx.x = event.x;
556
+ ctx.y = event.y;
557
+ scale_panelHandle.value = withTiming(HANDLES_SCALE, { duration: 100 });
558
+ },
559
+ onActive: (event, ctx) => {
560
+ const clamp = (v, max) => Math.min(Math.max(v, 0), max);
561
+
562
+ const x = event.translationX;
563
+ const y = event.translationY;
564
+ const posX = clamp(x + ctx.x, width);
565
+ const posY = clamp(y + ctx.y, width);
566
+ const percentX = posX / width;
567
+ const percentY = posY / width;
568
+
569
+ const hueX = Math.round(percentX * HUE_MAX);
570
+ const saturationY = Math.round(SB_MAX - percentY * SB_MAX);
571
+
572
+ huePanel2_handlePos.value = isRtl ? percentX * width - width + thumbSize / 2 : percentX * width - thumbSize / 2;
573
+
574
+ saturationPanel2_handlePos.value = percentY * width - thumbSize / 2;
575
+
576
+ hue_handlePos.value = isRtl
577
+ ? width - (hueX / HUE_MAX) * width - width + hueThumbeSize.current / 2
578
+ : width - (hueX / HUE_MAX) * width - hueThumbeSize.current / 2;
579
+
580
+ saturationSlider_handlePos.value = isRtl
581
+ ? (saturationY / SB_MAX) * width - width + saturationThumbeSize.current / 2
582
+ : (saturationY / SB_MAX) * width - saturationThumbeSize.current / 2;
583
+
584
+ // panel 1 adobe style
585
+ saturationPanel1_handlePos.value = isRtl
586
+ ? (saturationY / SB_MAX) * width - width + panel1ThumbeSize.current / 2
587
+ : (saturationY / SB_MAX) * width - panel1ThumbeSize.current / 2;
588
+
589
+ runOnJS(updateHS)(hueX, saturationY);
590
+ },
591
+ onFinish: () => {
592
+ scale_panelHandle.value = withTiming(1, { duration: 100 });
593
+ runOnJS(onGestureEventFinish)();
594
+ },
595
+ });
596
+
597
+ return (
598
+ <PanGestureHandler onGestureEvent={panel_GestureEvent} minDist={0}>
599
+ <Animated.View style={[styles.panel_container, style, { width, height: width }, styles.override]}>
600
+ <Image
601
+ source={require('./assets/Background2.png')}
602
+ style={{
603
+ borderRadius: style.borderRadius ?? 5,
604
+ width,
605
+ height: width,
606
+ }}
607
+ />
608
+ <Animated.View
609
+ style={[
610
+ styles.handle,
611
+ {
612
+ width: thumbSize,
613
+ height: thumbSize,
614
+ borderRadius: thumbSize / 2,
615
+ },
616
+ panel_handleStyle,
617
+ ]}
414
618
  >
415
619
  <Animated.View style={[styles.handleInner, { borderRadius: thumbSize / 2 }, previewColorWithoutOpacity]} />
416
620
  </Animated.View>
@@ -448,7 +652,7 @@ export function Preview({
448
652
  <View style={[styles.preview, { width }, style]}>
449
653
  {!hideInitialColor && (
450
654
  <View style={[styles.previewChildren, { backgroundColor: value }]}>
451
- {hideText && (
655
+ {!hideText && (
452
656
  <Text style={[{ color: initialColorText.color }, { fontWeight: 'bold' }, textStyle]}>
453
657
  {initialColorText.formated}
454
658
  </Text>
@@ -469,8 +673,10 @@ export function HueSlider({
469
673
  updateHue,
470
674
  onGestureEventFinish,
471
675
  hue_handlePos,
676
+ huePanel2_handlePos,
472
677
  previewColorWithoutOpacity,
473
678
  tracksHeight,
679
+ panel2ThumbeSize,
474
680
  thumbsSize,
475
681
  thumbSize = thumbsSize, // by user
476
682
  ringColor = '#ffffff', // by user
@@ -514,6 +720,11 @@ export function HueSlider({
514
720
 
515
721
  hue_handlePos.value = isRtl ? percent * width - width + thumbSize / 2 : percent * width - thumbSize / 2;
516
722
 
723
+ // panel 2 windows style
724
+ huePanel2_handlePos.value = isRtl
725
+ ? (hueX / HUE_MAX) * width - width + panel2ThumbeSize.current / 2
726
+ : (hueX / HUE_MAX) * width - panel2ThumbeSize.current / 2;
727
+
517
728
  runOnJS(updateHue)(hueX);
518
729
  },
519
730
  onFinish: () => {
@@ -528,7 +739,7 @@ export function HueSlider({
528
739
  <PanGestureHandler onGestureEvent={HueGestureEvent} minDist={0}>
529
740
  <Animated.View style={[{ position: 'relative', height: tracksHeight }, style, { width }, styles.override]}>
530
741
  <View style={[styles.sliderImageContainer, { borderRadius: style.borderRadius ?? 5 }]}>
531
- <Image source={HUE_IMAGE} style={styles.sliderImage} />
742
+ <Image source={require('./assets/Hue.png')} style={styles.sliderImage} />
532
743
  </View>
533
744
  <Animated.View
534
745
  style={[
@@ -553,11 +764,13 @@ export function HueSlider({
553
764
  export function SaturationSlider({
554
765
  width,
555
766
  saturationThumbeSize,
556
- panelThumbeSize,
767
+ panel2ThumbeSize,
768
+ panel1ThumbeSize,
557
769
  setHandlesPos,
558
770
  updateSaturation,
559
771
  onGestureEventFinish,
560
- saturationPanel_handlePos,
772
+ saturationPanel1_handlePos,
773
+ saturationPanel2_handlePos,
561
774
  saturationSlider_handlePos,
562
775
  previewColorWithoutOpacity,
563
776
  tracksHeight,
@@ -592,7 +805,9 @@ export function SaturationSlider({
592
805
  {
593
806
  onStart: (event, ctx) => {
594
807
  ctx.x = event.x;
595
- scale_saturationHandle.value = withTiming(HANDLES_SCALE, { duration: 100 });
808
+ scale_saturationHandle.value = withTiming(HANDLES_SCALE, {
809
+ duration: 100,
810
+ });
596
811
  },
597
812
  onActive: (event, ctx) => {
598
813
  const clamp = (v, max) => Math.min(Math.max(v, 0), max);
@@ -604,9 +819,12 @@ export function SaturationSlider({
604
819
  const saturationX = Math.round(percent * SB_MAX);
605
820
 
606
821
  saturationSlider_handlePos.value = isRtl ? percent * width - width + thumbSize / 2 : percent * width - thumbSize / 2;
607
- saturationPanel_handlePos.value = isRtl
608
- ? (saturationX / SB_MAX) * width - width + panelThumbeSize.current / 2
609
- : (saturationX / SB_MAX) * width - panelThumbeSize.current / 2;
822
+ // panel 2 windows style
823
+ saturationPanel1_handlePos.value = isRtl
824
+ ? (saturationX / SB_MAX) * width - width + panel1ThumbeSize.current / 2
825
+ : (saturationX / SB_MAX) * width - panel1ThumbeSize.current / 2;
826
+ // panel 2 windows style
827
+ saturationPanel2_handlePos.value = width - (saturationX / SB_MAX) * width - panel2ThumbeSize.current / 2;
610
828
 
611
829
  runOnJS(updateSaturation)(saturationX);
612
830
  },
@@ -622,7 +840,7 @@ export function SaturationSlider({
622
840
  <PanGestureHandler onGestureEvent={SaturationGestureEvent} minDist={0}>
623
841
  <Animated.View style={[{ position: 'relative', height: tracksHeight }, style, { width }, styles.override]}>
624
842
  <Animated.View style={[styles.sliderImageContainer, { borderRadius: style.borderRadius ?? 5 }, activeHueStyle]}>
625
- <Image source={SATURATION_IMAGE} style={styles.sliderImage} />
843
+ <Image source={require('./assets/Saturation.png')} style={styles.sliderImage} />
626
844
  </Animated.View>
627
845
  <Animated.View
628
846
  style={[
@@ -647,11 +865,11 @@ export function SaturationSlider({
647
865
  export function BrightnessSlider({
648
866
  width,
649
867
  brightnessThumbeSize,
650
- panelThumbeSize,
868
+ panel1ThumbeSize,
651
869
  setHandlesPos,
652
870
  updateBrightness,
653
871
  onGestureEventFinish,
654
- brightnessPanel_handlePos,
872
+ brightnessPanel1_handlePos,
655
873
  brightnessSlider_handlePos,
656
874
  previewColorWithoutOpacity,
657
875
  tracksHeight,
@@ -686,7 +904,9 @@ export function BrightnessSlider({
686
904
  {
687
905
  onStart: (event, ctx) => {
688
906
  ctx.x = event.x;
689
- scale_brightnessHandle.value = withTiming(HANDLES_SCALE, { duration: 100 });
907
+ scale_brightnessHandle.value = withTiming(HANDLES_SCALE, {
908
+ duration: 100,
909
+ });
690
910
  },
691
911
  onActive: (event, ctx) => {
692
912
  const clamp = (v, max) => Math.min(Math.max(v, 0), max);
@@ -698,7 +918,7 @@ export function BrightnessSlider({
698
918
  const brightnessX = Math.round(percent * SB_MAX);
699
919
 
700
920
  brightnessSlider_handlePos.value = isRtl ? percent * width - width + thumbSize / 2 : percent * width - thumbSize / 2;
701
- brightnessPanel_handlePos.value = width - (brightnessX / SB_MAX) * width - panelThumbeSize.current / 2;
921
+ brightnessPanel1_handlePos.value = width - (brightnessX / SB_MAX) * width - panel1ThumbeSize.current / 2;
702
922
 
703
923
  runOnJS(updateBrightness)(brightnessX);
704
924
  },
@@ -714,7 +934,7 @@ export function BrightnessSlider({
714
934
  <PanGestureHandler onGestureEvent={BrightnessGestureEvent} minDist={0}>
715
935
  <Animated.View style={[{ position: 'relative', height: tracksHeight }, style, { width }, styles.override]}>
716
936
  <Animated.View style={[styles.sliderImageContainer, { borderRadius: style.borderRadius ?? 5 }, activeHueStyle]}>
717
- <Image source={BRIGHTNESS_IMAGE} style={styles.sliderImage} />
937
+ <Image source={require('./assets/Brightness.png')} style={styles.sliderImage} />
718
938
  </Animated.View>
719
939
  <Animated.View
720
940
  style={[
@@ -800,7 +1020,7 @@ export function OpacitySlider({
800
1020
  <PanGestureHandler onGestureEvent={opacityGestureEvent} minDist={0}>
801
1021
  <Animated.View style={[{ position: 'relative', height: tracksHeight }, style, { width }, styles.override]}>
802
1022
  <Animated.View style={[styles.sliderImageContainer, { borderRadius: style.borderRadius ?? 5 }, activeHueStyle]}>
803
- <Image source={OPACITY_IMAGE} style={styles.sliderImage} />
1023
+ <Image source={require('./assets/Opacity.png')} style={styles.sliderImage} />
804
1024
  </Animated.View>
805
1025
  <Animated.View
806
1026
  style={[
File without changes
Binary file
package/lib/index.d.ts CHANGED
@@ -147,7 +147,8 @@ interface OpacityProps {
147
147
 
148
148
  declare const ColorPicker: React.FunctionComponent<ColorPickerProps>;
149
149
  export declare const Preview: React.FunctionComponent<PreviewPorps>;
150
- export declare const Panel: React.FunctionComponent<PanelProps>;
150
+ export declare const Panel1: React.FunctionComponent<PanelProps>;
151
+ export declare const Panel2: React.FunctionComponent<PanelProps>;
151
152
  export declare const HueSlider: React.FunctionComponent<HueProps>;
152
153
  export declare const BrightnessSlider: React.FunctionComponent<BrightnessProps>;
153
154
  export declare const SaturationSlider: React.FunctionComponent<SaturationProps>;
package/lib/index.js CHANGED
@@ -1,4 +1,13 @@
1
- import ColorPicker from './ColorPicker.js';
2
-
3
- export default ColorPicker;
4
- export { Panel, Swatches, Preview, OpacitySlider, HueSlider, BrightnessSlider, SaturationSlider } from './ColorPicker.js';
1
+ import ColorPicker from './ColorPicker.js';
2
+
3
+ export default ColorPicker;
4
+ export {
5
+ Panel1,
6
+ Panel2,
7
+ Swatches,
8
+ Preview,
9
+ OpacitySlider,
10
+ HueSlider,
11
+ BrightnessSlider,
12
+ SaturationSlider,
13
+ } from './ColorPicker.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reanimated-color-picker",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "source": "lib/index.js",
package/readme.md CHANGED
@@ -26,7 +26,8 @@
26
26
  - [ColorPicker Wrapper](#small_red_trianglecolorpicker-wrapper)
27
27
  - [Built-in Components](#small_red_trianglebuilt-in-components)
28
28
  - [`<Preview />`](#small_orange_diamondpreview-).
29
- - [`<Panel />`](#small_orange_diamondpanel-).
29
+ - [`<Panel1 />`](#small_orange_diamondpanel1-).
30
+ - [`<Panel2 />`](#small_orange_diamondpanel2-).
30
31
  - [`<HueSlider />`](#small_orange_diamondhueslider-).
31
32
  - [`<SaturationSlider />`](#small_orange_diamondsaturationslider-).
32
33
  - [`<BrightnessSlider />`](#small_orange_diamondbrightnessslider-).
@@ -169,11 +170,24 @@ export default function App() {
169
170
 
170
171
  > **Note** some style properties will be overwritten.
171
172
 
172
- ### :small_orange_diamond:`<Panel />`
173
+ ### :small_orange_diamond:`<Panel1 />`
173
174
 
174
- ![panel](https://github.com/alabsi91/reanimated-color-picker/blob/main/images/panel.png?raw=true)
175
+ ![panel1](https://github.com/alabsi91/reanimated-color-picker/blob/main/images/panel1.png?raw=true)
175
176
 
176
- - A square-shaped slider used for changing the color's brightness and saturation.
177
+ - A square-shaped slider (adobe style) used for changing the color's brightness and saturation.
178
+
179
+ | Property | Type | Default | Description |
180
+ | :-------- | :----: | :-----: | :---------------------------------------- |
181
+ | thumbSize | number | `35` | panel handle (thumb) size (height\*width) |
182
+ | style | object | / | panle container style |
183
+
184
+ > **Note** some style properties will be overwritten.
185
+
186
+ ### :small_orange_diamond:`<Panel2 />`
187
+
188
+ ![panel2](https://github.com/alabsi91/reanimated-color-picker/blob/main/images/panel2.png?raw=true)
189
+
190
+ - A square-shaped slider (windows style) used for changing the color's hue and saturation.
177
191
 
178
192
  | Property | Type | Default | Description |
179
193
  | :-------- | :----: | :-----: | :---------------------------------------- |