@archireport/react-native-svg-draw 2.2.1 → 2.3.1

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.
Files changed (116) hide show
  1. package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js +293 -31
  2. package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
  3. package/lib/commonjs/components/DrawCore/CurrentAnimatedText.js +12 -11
  4. package/lib/commonjs/components/DrawCore/CurrentAnimatedText.js.map +1 -1
  5. package/lib/commonjs/components/DrawCore/DrawContext.js.map +1 -1
  6. package/lib/commonjs/components/DrawCore/DrawPad.js +14 -5
  7. package/lib/commonjs/components/DrawCore/DrawPad.js.map +1 -1
  8. package/lib/commonjs/components/DrawCore/DrawProvider.js +6 -2
  9. package/lib/commonjs/components/DrawCore/DrawProvider.js.map +1 -1
  10. package/lib/commonjs/components/DrawCore/Item.js +156 -8
  11. package/lib/commonjs/components/DrawCore/Item.js.map +1 -1
  12. package/lib/commonjs/components/DrawCore/index.js +163 -76
  13. package/lib/commonjs/components/DrawCore/index.js.map +1 -1
  14. package/lib/commonjs/components/DrawCore/useDrawHook.js +4 -2
  15. package/lib/commonjs/components/DrawCore/useDrawHook.js.map +1 -1
  16. package/lib/commonjs/components/DrawWithOptions/ArrowSvg.js.map +1 -1
  17. package/lib/commonjs/components/DrawWithOptions/CancelSvg.js.map +1 -1
  18. package/lib/commonjs/components/DrawWithOptions/CircleSvg.js.map +1 -1
  19. package/lib/commonjs/components/DrawWithOptions/CloseSvg.js.map +1 -1
  20. package/lib/commonjs/components/DrawWithOptions/DoubleHeadSvg.js.map +1 -1
  21. package/lib/commonjs/components/DrawWithOptions/PenSvg.js.map +1 -1
  22. package/lib/commonjs/components/DrawWithOptions/SendSvg.js.map +1 -1
  23. package/lib/commonjs/components/DrawWithOptions/SliderSvg.js.map +1 -1
  24. package/lib/commonjs/components/DrawWithOptions/SquareSvg.js.map +1 -1
  25. package/lib/commonjs/components/DrawWithOptions/TextSvg.js.map +1 -1
  26. package/lib/commonjs/components/DrawWithOptions/ThrashSvg.js.map +1 -1
  27. package/lib/commonjs/components/DrawWithOptions/index.js +14 -0
  28. package/lib/commonjs/components/DrawWithOptions/index.js.map +1 -1
  29. package/lib/commonjs/components/Slider/ColorSlider.js.map +1 -1
  30. package/lib/commonjs/components/Slider/Sliders.js.map +1 -1
  31. package/lib/commonjs/components/Slider/StrokeSlider.js.map +1 -1
  32. package/lib/commonjs/components/Slider/sliderStyle.js.map +1 -1
  33. package/lib/commonjs/index.js.map +1 -1
  34. package/lib/module/components/DrawCore/CurrentAnimatedItem.js +295 -33
  35. package/lib/module/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
  36. package/lib/module/components/DrawCore/CurrentAnimatedText.js +12 -11
  37. package/lib/module/components/DrawCore/CurrentAnimatedText.js.map +1 -1
  38. package/lib/module/components/DrawCore/DrawContext.js.map +1 -1
  39. package/lib/module/components/DrawCore/DrawPad.js +14 -5
  40. package/lib/module/components/DrawCore/DrawPad.js.map +1 -1
  41. package/lib/module/components/DrawCore/DrawProvider.js +6 -2
  42. package/lib/module/components/DrawCore/DrawProvider.js.map +1 -1
  43. package/lib/module/components/DrawCore/Item.js +152 -10
  44. package/lib/module/components/DrawCore/Item.js.map +1 -1
  45. package/lib/module/components/DrawCore/index.js +164 -77
  46. package/lib/module/components/DrawCore/index.js.map +1 -1
  47. package/lib/module/components/DrawCore/useDrawHook.js +4 -2
  48. package/lib/module/components/DrawCore/useDrawHook.js.map +1 -1
  49. package/lib/module/components/DrawWithOptions/ArrowSvg.js.map +1 -1
  50. package/lib/module/components/DrawWithOptions/CancelSvg.js.map +1 -1
  51. package/lib/module/components/DrawWithOptions/CircleSvg.js.map +1 -1
  52. package/lib/module/components/DrawWithOptions/CloseSvg.js.map +1 -1
  53. package/lib/module/components/DrawWithOptions/DoubleHeadSvg.js.map +1 -1
  54. package/lib/module/components/DrawWithOptions/PenSvg.js.map +1 -1
  55. package/lib/module/components/DrawWithOptions/SendSvg.js.map +1 -1
  56. package/lib/module/components/DrawWithOptions/SliderSvg.js.map +1 -1
  57. package/lib/module/components/DrawWithOptions/SquareSvg.js.map +1 -1
  58. package/lib/module/components/DrawWithOptions/TextSvg.js.map +1 -1
  59. package/lib/module/components/DrawWithOptions/ThrashSvg.js.map +1 -1
  60. package/lib/module/components/DrawWithOptions/index.js +14 -0
  61. package/lib/module/components/DrawWithOptions/index.js.map +1 -1
  62. package/lib/module/components/Slider/ColorSlider.js.map +1 -1
  63. package/lib/module/components/Slider/Sliders.js.map +1 -1
  64. package/lib/module/components/Slider/StrokeSlider.js.map +1 -1
  65. package/lib/typescript/components/DrawCore/CurrentAnimatedItem.d.ts +3 -6
  66. package/lib/typescript/components/DrawCore/CurrentAnimatedItem.d.ts.map +1 -1
  67. package/lib/typescript/components/DrawCore/CurrentAnimatedText.d.ts +0 -1
  68. package/lib/typescript/components/DrawCore/CurrentAnimatedText.d.ts.map +1 -1
  69. package/lib/typescript/components/DrawCore/DrawContext.d.ts +2 -0
  70. package/lib/typescript/components/DrawCore/DrawContext.d.ts.map +1 -1
  71. package/lib/typescript/components/DrawCore/DrawPad.d.ts +0 -1
  72. package/lib/typescript/components/DrawCore/DrawPad.d.ts.map +1 -1
  73. package/lib/typescript/components/DrawCore/DrawProvider.d.ts.map +1 -1
  74. package/lib/typescript/components/DrawCore/Item.d.ts +27 -1
  75. package/lib/typescript/components/DrawCore/Item.d.ts.map +1 -1
  76. package/lib/typescript/components/DrawCore/index.d.ts +0 -1
  77. package/lib/typescript/components/DrawCore/index.d.ts.map +1 -1
  78. package/lib/typescript/components/DrawCore/useDrawHook.d.ts +1 -1
  79. package/lib/typescript/components/DrawCore/useDrawHook.d.ts.map +1 -1
  80. package/lib/typescript/components/DrawWithOptions/ArrowSvg.d.ts +0 -1
  81. package/lib/typescript/components/DrawWithOptions/ArrowSvg.d.ts.map +1 -1
  82. package/lib/typescript/components/DrawWithOptions/CancelSvg.d.ts +0 -1
  83. package/lib/typescript/components/DrawWithOptions/CancelSvg.d.ts.map +1 -1
  84. package/lib/typescript/components/DrawWithOptions/CircleSvg.d.ts +0 -1
  85. package/lib/typescript/components/DrawWithOptions/CircleSvg.d.ts.map +1 -1
  86. package/lib/typescript/components/DrawWithOptions/CloseSvg.d.ts +0 -1
  87. package/lib/typescript/components/DrawWithOptions/CloseSvg.d.ts.map +1 -1
  88. package/lib/typescript/components/DrawWithOptions/DoubleHeadSvg.d.ts +0 -1
  89. package/lib/typescript/components/DrawWithOptions/DoubleHeadSvg.d.ts.map +1 -1
  90. package/lib/typescript/components/DrawWithOptions/PenSvg.d.ts +0 -1
  91. package/lib/typescript/components/DrawWithOptions/PenSvg.d.ts.map +1 -1
  92. package/lib/typescript/components/DrawWithOptions/SendSvg.d.ts +0 -1
  93. package/lib/typescript/components/DrawWithOptions/SendSvg.d.ts.map +1 -1
  94. package/lib/typescript/components/DrawWithOptions/SliderSvg.d.ts +0 -1
  95. package/lib/typescript/components/DrawWithOptions/SliderSvg.d.ts.map +1 -1
  96. package/lib/typescript/components/DrawWithOptions/SquareSvg.d.ts +0 -1
  97. package/lib/typescript/components/DrawWithOptions/SquareSvg.d.ts.map +1 -1
  98. package/lib/typescript/components/DrawWithOptions/TextSvg.d.ts +0 -1
  99. package/lib/typescript/components/DrawWithOptions/TextSvg.d.ts.map +1 -1
  100. package/lib/typescript/components/DrawWithOptions/ThrashSvg.d.ts +0 -1
  101. package/lib/typescript/components/DrawWithOptions/ThrashSvg.d.ts.map +1 -1
  102. package/lib/typescript/components/DrawWithOptions/index.d.ts.map +1 -1
  103. package/lib/typescript/components/Slider/StrokeSlider.d.ts +0 -1
  104. package/lib/typescript/components/Slider/StrokeSlider.d.ts.map +1 -1
  105. package/lib/typescript/components/Slider/sliderStyle.d.ts +2 -2
  106. package/package.json +5 -5
  107. package/src/components/DrawCore/CurrentAnimatedItem.tsx +340 -20
  108. package/src/components/DrawCore/CurrentAnimatedText.tsx +13 -6
  109. package/src/components/DrawCore/DrawContext.tsx +2 -0
  110. package/src/components/DrawCore/DrawPad.tsx +17 -3
  111. package/src/components/DrawCore/DrawProvider.tsx +6 -0
  112. package/src/components/DrawCore/Item.tsx +190 -9
  113. package/src/components/DrawCore/index.tsx +219 -100
  114. package/src/components/DrawCore/useDrawHook.tsx +2 -0
  115. package/src/components/DrawWithOptions/index.tsx +18 -0
  116. package/src/types.d.ts +7 -0
@@ -8,17 +8,14 @@ import {
8
8
  Image,
9
9
  ImageRequireSource,
10
10
  ImageURISource,
11
- InputAccessoryView,
12
- Platform,
11
+ KeyboardAvoidingView,
13
12
  } from 'react-native';
14
13
  import Animated, {
15
14
  runOnJS,
16
15
  useAnimatedGestureHandler,
17
16
  useAnimatedKeyboard,
18
17
  useAnimatedReaction,
19
- useAnimatedStyle,
20
18
  useSharedValue,
21
- withTiming,
22
19
  } from 'react-native-reanimated';
23
20
  import {
24
21
  PanGestureHandler,
@@ -48,6 +45,9 @@ const styles = StyleSheet.create({
48
45
  fontSize: 16,
49
46
  color: 'white',
50
47
  width: '100%',
48
+ opacity: 0,
49
+ height: 20,
50
+ maxWidth: 20,
51
51
  },
52
52
  });
53
53
 
@@ -90,8 +90,6 @@ const pDistance = (
90
90
  return Math.sqrt(dx * dx + dy * dy);
91
91
  };
92
92
 
93
- const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);
94
-
95
93
  const DEFAULT_TEXT = '';
96
94
 
97
95
  const THRESHOLD = 20;
@@ -165,6 +163,19 @@ const drawNewItem = (
165
163
  color: style.color.value,
166
164
  };
167
165
  break;
166
+ case 'doubleArrows':
167
+ currentItem.value = {
168
+ type: mode.value,
169
+ data: {
170
+ x1: position.x,
171
+ y1: position.y,
172
+ x2: position.x,
173
+ y2: position.y,
174
+ },
175
+ strokeWidth: style.strokeWidth.value,
176
+ color: style.color.value,
177
+ };
178
+ break;
168
179
  case 'text':
169
180
  currentItem.value = {
170
181
  type: mode.value,
@@ -227,6 +238,7 @@ const DrawCore = ({
227
238
  currentItem,
228
239
  itemIsSelected,
229
240
  viewShot,
241
+ doubleArrowTextInput,
230
242
  } = useDrawHook();
231
243
 
232
244
  const onCancelChangeWrapper = (arg: boolean) => {
@@ -282,14 +294,22 @@ const DrawCore = ({
282
294
  itemIsSelected.value = false;
283
295
  }, [drawState.drawingMode, mode, currentItem, addDoneItem, itemIsSelected]);
284
296
 
285
- const showTextInput = useSharedValue(false);
297
+ const showTextInput = useSharedValue(false); //TODO: remove
298
+
299
+ const textFocusState = useCallback(() => {
300
+ //setShowTextInputState(true);
301
+ console.log('textFocusState');
302
+ doubleArrowTextInput?.current?.focus();
303
+ }, [doubleArrowTextInput]);
286
304
 
287
305
  const textFocus = useCallback(() => {
306
+ console.log('textFocus');
288
307
  textInputRef.current?.focus();
289
308
  }, []);
290
309
 
291
310
  useEffect(() => {
292
311
  if (currentItem.value?.type === 'text') {
312
+ console.log('use effect text');
293
313
  showTextInput.value = true;
294
314
  textFocus();
295
315
  currentItem.value = {
@@ -310,9 +330,10 @@ const DrawCore = ({
310
330
  ctx.startX = startX;
311
331
  ctx.startY = startY;
312
332
  ctx.newlyCreated = false;
313
-
333
+ console.log('**********************************');
334
+ console.log('onGestureEvent');
314
335
  //panPosition.value = withTiming(RIGHT_PANE_WIDTH);
315
-
336
+ console.log('onStart', currentItem.value?.type);
316
337
  initialItem.value = currentItem.value;
317
338
  switch (currentItem.value?.type) {
318
339
  case 'ellipse':
@@ -427,6 +448,7 @@ const DrawCore = ({
427
448
 
428
449
  break;
429
450
  case 'doubleHead':
451
+ case 'doubleArrows':
430
452
  case 'singleHead':
431
453
  const x1 =
432
454
  typeof currentItem.value.data.x1 === 'string'
@@ -489,7 +511,8 @@ const DrawCore = ({
489
511
  typeof currentItem.value.data.height === 'string'
490
512
  ? parseFloat(currentItem.value.data.height)
491
513
  : currentItem.value.data.height || 0;
492
-
514
+ console.log(heightText);
515
+ console.log(widthText);
493
516
  if (
494
517
  startX <= xText + THRESHOLD &&
495
518
  startX >= xText - THRESHOLD &&
@@ -515,9 +538,26 @@ const DrawCore = ({
515
538
  (heightText < 0 && startY < yText && startY > yText + heightText))
516
539
  ) {
517
540
  ctx.zone = 'CENTER';
541
+ console.log('on active center');
518
542
  } else {
519
543
  ctx.zone = 'OUT';
544
+ console.log('on active out');
520
545
  initialItem.value = null;
546
+
547
+ ctx.newlyCreated = true;
548
+ runOnJS(setTextVal)('');
549
+ drawNewItem(
550
+ mode,
551
+ currentItem,
552
+ addDoneItem,
553
+ { x: startX, y: startY },
554
+ { textBaseHeight, strokeWidth, color }
555
+ );
556
+
557
+ itemIsSelected!.value = true;
558
+ onCancelChangeWrapper && runOnJS(onCancelChangeWrapper)(true);
559
+
560
+ runOnJS(textFocus)();
521
561
  }
522
562
 
523
563
  break;
@@ -540,6 +580,26 @@ const DrawCore = ({
540
580
  default:
541
581
  ctx.zone = 'OUT';
542
582
  initialItem.value = null;
583
+ if (drawState.drawingMode === 'text') {
584
+ /* NEW GEOFF */
585
+ console.log('on active out');
586
+ ctx.newlyCreated = true;
587
+
588
+ runOnJS(setTextVal)('');
589
+
590
+ drawNewItem(
591
+ mode,
592
+ currentItem,
593
+ addDoneItem,
594
+ { x: startX, y: startY },
595
+ { textBaseHeight, strokeWidth, color }
596
+ );
597
+
598
+ itemIsSelected!.value = true;
599
+ onCancelChangeWrapper && runOnJS(onCancelChangeWrapper)(true);
600
+
601
+ runOnJS(textFocus)();
602
+ }
543
603
  break;
544
604
  }
545
605
  },
@@ -548,11 +608,13 @@ const DrawCore = ({
548
608
  ctx
549
609
  ) => {
550
610
  const { startX, startY, zone, newlyCreated } = ctx;
551
- if (zone === 'OUT' && newlyCreated === false) {
611
+ if (zone === 'OUT' && newlyCreated === false && mode.value !== 'text') {
612
+ console.log('on active out');
552
613
  ctx.newlyCreated = true;
614
+ /*
553
615
  if (mode.value === 'text') {
554
616
  runOnJS(setTextVal)('');
555
- }
617
+ }*/
556
618
  drawNewItem(
557
619
  mode,
558
620
  currentItem,
@@ -800,6 +862,7 @@ const DrawCore = ({
800
862
  break;
801
863
  case 'singleHead':
802
864
  case 'doubleHead':
865
+ case 'doubleArrows':
803
866
  if (initialItem.value?.type === currentItem.value.type) {
804
867
  const x1 =
805
868
  typeof initialItem.value?.data.x1 === 'string'
@@ -827,6 +890,10 @@ const DrawCore = ({
827
890
  type: currentItem.value.type,
828
891
  strokeWidth: currentItem.value.strokeWidth,
829
892
  color: currentItem.value.color,
893
+ text:
894
+ currentItem.value.type === 'doubleArrows'
895
+ ? currentItem.value.text ?? ''
896
+ : '',
830
897
  data: {
831
898
  x1: x1 + translationX,
832
899
  y1: y1 + translationY,
@@ -840,6 +907,10 @@ const DrawCore = ({
840
907
  type: currentItem.value.type,
841
908
  strokeWidth: currentItem.value.strokeWidth,
842
909
  color: currentItem.value.color,
910
+ text:
911
+ currentItem.value.type === 'doubleArrows'
912
+ ? currentItem.value.text ?? ''
913
+ : '',
843
914
  data: {
844
915
  x1: x1,
845
916
  y1: y1,
@@ -853,6 +924,10 @@ const DrawCore = ({
853
924
  type: currentItem.value.type,
854
925
  strokeWidth: currentItem.value.strokeWidth,
855
926
  color: currentItem.value.color,
927
+ text:
928
+ currentItem.value.type === 'doubleArrows'
929
+ ? currentItem.value.text ?? ''
930
+ : '',
856
931
  data: {
857
932
  x1: x1 + translationX,
858
933
  y1: y1 + translationY,
@@ -867,6 +942,10 @@ const DrawCore = ({
867
942
  type: currentItem.value.type,
868
943
  strokeWidth: currentItem.value.strokeWidth,
869
944
  color: currentItem.value.color,
945
+ text:
946
+ currentItem.value.type === 'doubleArrows'
947
+ ? currentItem.value.text ?? ''
948
+ : '',
870
949
  data: {
871
950
  x1: startX,
872
951
  y1: startY,
@@ -877,6 +956,7 @@ const DrawCore = ({
877
956
  }
878
957
  break;
879
958
  case 'text':
959
+ console.log('on active text');
880
960
  if (initialItem.value?.type === currentItem.value.type) {
881
961
  const xText =
882
962
  typeof initialItem.value?.data.x === 'string'
@@ -956,6 +1036,9 @@ const DrawCore = ({
956
1036
  }
957
1037
  },
958
1038
  onEnd: (_event) => {
1039
+ if (currentItem.value?.type === 'doubleArrows') {
1040
+ runOnJS(textFocusState)();
1041
+ }
959
1042
  if (currentItem.value?.type === 'text') {
960
1043
  runOnJS(textFocus)();
961
1044
 
@@ -981,6 +1064,7 @@ const DrawCore = ({
981
1064
 
982
1065
  const sudDidShow = Keyboard.addListener('keyboardDidShow', (event) => {
983
1066
  // avoid events triggered by InputAccessoryView
1067
+ console.log('keyboardDidShow dc');
984
1068
  if (event.endCoordinates.height > 100) {
985
1069
  showTextInput.value = true;
986
1070
  }
@@ -1011,45 +1095,17 @@ const DrawCore = ({
1011
1095
  }) => {
1012
1096
  switch (currentItem.value?.type) {
1013
1097
  case 'singleHead':
1014
- currentItem.value = {
1015
- type: currentItem.value.type,
1016
- data: currentItem.value.data,
1017
- strokeWidth: sw,
1018
- color: c,
1019
- };
1020
- break;
1021
1098
  case 'doubleHead':
1022
- currentItem.value = {
1023
- type: currentItem.value.type,
1024
- data: currentItem.value.data,
1025
- strokeWidth: sw,
1026
- color: c,
1027
- };
1028
- break;
1099
+ case 'doubleArrows':
1029
1100
  case 'ellipse':
1030
- currentItem.value = {
1031
- type: currentItem.value.type,
1032
- data: currentItem.value.data,
1033
- strokeWidth: sw,
1034
- color: c,
1035
- };
1036
- break;
1037
1101
  case 'rectangle':
1038
- currentItem.value = {
1039
- type: currentItem.value.type,
1040
- data: currentItem.value.data,
1041
- strokeWidth: sw,
1042
- color: c,
1043
- };
1044
- break;
1045
-
1046
1102
  case 'pen':
1047
1103
  currentItem.value = {
1048
1104
  type: currentItem.value.type,
1049
1105
  data: currentItem.value.data,
1050
1106
  strokeWidth: sw,
1051
1107
  color: c,
1052
- };
1108
+ } as DrawItem;
1053
1109
  break;
1054
1110
  case 'text':
1055
1111
  currentItem.value = {
@@ -1067,12 +1123,14 @@ const DrawCore = ({
1067
1123
 
1068
1124
  const onPressItem = useCallback(
1069
1125
  (item: DrawItem, index: number) => () => {
1126
+ console.log('onPressItem');
1070
1127
  itemIsSelected.value = true;
1071
1128
 
1072
1129
  const previousItem = currentItem.value;
1073
1130
 
1074
1131
  strokeWidth.value = item.strokeWidth;
1075
1132
  color.value = item.color;
1133
+ console.log('item', item);
1076
1134
  currentItem.value = item;
1077
1135
 
1078
1136
  deleteDoneItem(index);
@@ -1083,6 +1141,10 @@ const DrawCore = ({
1083
1141
 
1084
1142
  if (item.type === 'text') {
1085
1143
  setTextVal(item.text ?? '');
1144
+ textInputRef.current?.focus();
1145
+ } else if (item.type === 'doubleArrows') {
1146
+ //setTextVal(item.text ?? '');
1147
+ //textInputRef.current?.focus();
1086
1148
  } else {
1087
1149
  textInputRef.current?.blur();
1088
1150
  }
@@ -1096,6 +1158,39 @@ const DrawCore = ({
1096
1158
  addDoneItem,
1097
1159
  ]
1098
1160
  );
1161
+ /*
1162
+ const onPressItemText = useCallback(
1163
+ (item: DrawItem, index: number) => () => {
1164
+ itemIsSelected.value = true;
1165
+
1166
+ const previousItem = currentItem.value;
1167
+
1168
+ strokeWidth.value = item.strokeWidth;
1169
+ color.value = item.color;
1170
+ currentItem.value = item;
1171
+
1172
+ deleteDoneItem(index);
1173
+
1174
+ if (previousItem) {
1175
+ addDoneItem(previousItem);
1176
+ }
1177
+
1178
+ if (item.type === 'text') {
1179
+ setTextVal(item.text ?? '');
1180
+
1181
+ } else {
1182
+ textInputRef.current?.blur();
1183
+ }
1184
+ },
1185
+ [
1186
+ itemIsSelected,
1187
+ currentItem,
1188
+ strokeWidth,
1189
+ color,
1190
+ deleteDoneItem,
1191
+ addDoneItem,
1192
+ ]
1193
+ );*/
1099
1194
 
1100
1195
  const onTextHeightChange = useCallback(
1101
1196
  (height: number) => {
@@ -1149,26 +1244,36 @@ const DrawCore = ({
1149
1244
  // do not remove keyboard will appear over the drawing frame and not shift it
1150
1245
  useAnimatedKeyboard();
1151
1246
 
1152
- const textInputContainerStyle = useAnimatedStyle(() => {
1153
- return {
1154
- position: 'absolute',
1155
- top: 0,
1156
- height: 50,
1157
- width: '100%',
1158
- display: 'flex',
1159
- opacity: showTextInput.value ? withTiming(1) : withTiming(0),
1160
- };
1161
- }, [showTextInput.value]);
1162
-
1163
- const textInputStyle = useAnimatedStyle(() => {
1164
- return {
1165
- color: 'white',
1166
- height: 20,
1167
- display: showTextInput.value ? 'flex' : 'none',
1168
- opacity: showTextInput.value ? withTiming(1) : withTiming(0),
1169
- };
1170
- }, [showTextInput.value]);
1247
+ /*
1248
+ const onEndEditingTextInput = useCallback(() => {
1249
+ console.log('onEndEditingTextInput');
1250
+ setShowTextInputState(false);
1251
+ if (currentItem.value && currentItem.value.type === 'doubleArrows') {
1252
+ console.log(currentItem.value.text);
1253
+ addScreenStates(currentItem.value);
1254
+ }
1255
+ }, [currentItem, addScreenStates]);
1256
+
1257
+ const onChangeText = useCallback(
1258
+ (value: string) => {
1259
+ if (
1260
+ value &&
1261
+ currentItem.value &&
1262
+ currentItem.value.type === 'doubleArrows'
1263
+ ) {
1264
+ console.log('******************');
1265
+ console.log(value);
1266
+ console.log(currentItem.value);
1171
1267
 
1268
+ currentItem.value = {
1269
+ ...currentItem.value,
1270
+ text: value,
1271
+ };
1272
+ }
1273
+ },
1274
+ [currentItem]
1275
+ );
1276
+ */
1172
1277
  return (
1173
1278
  <View style={styles.container}>
1174
1279
  <View
@@ -1183,52 +1288,63 @@ const DrawCore = ({
1183
1288
  });
1184
1289
  }}
1185
1290
  >
1186
- <PanGestureHandler onGestureEvent={onGestureEvent}>
1187
- <Animated.View style={imageSize || drawRegion}>
1188
- <View ref={drawContainer}>
1189
- {image ? (
1190
- imageSize && originalImageSize ? (
1291
+ <KeyboardAvoidingView behavior="position" keyboardVerticalOffset={70}>
1292
+ <PanGestureHandler onGestureEvent={onGestureEvent}>
1293
+ <Animated.View style={imageSize || drawRegion}>
1294
+ <View ref={drawContainer}>
1295
+ {image ? (
1296
+ imageSize && originalImageSize ? (
1297
+ <ViewShot
1298
+ ref={viewShot}
1299
+ options={{
1300
+ format: 'jpg',
1301
+ quality: 1,
1302
+ }}
1303
+ style={imageSize}
1304
+ >
1305
+ <ImageBackground source={image} style={styles.bgImage}>
1306
+ <DrawPad
1307
+ currentItem={currentItem}
1308
+ doneItems={drawState.doneItems}
1309
+ onPressItem={onPressItem}
1310
+ onTextHeightChange={onTextHeightChange}
1311
+ />
1312
+ </ImageBackground>
1313
+ </ViewShot>
1314
+ ) : null
1315
+ ) : drawRegion ? (
1191
1316
  <ViewShot
1192
1317
  ref={viewShot}
1193
1318
  options={{
1194
1319
  format: 'jpg',
1195
1320
  quality: 1,
1321
+ ...drawRegion,
1196
1322
  }}
1197
- style={imageSize}
1323
+ style={drawRegion}
1198
1324
  >
1199
- <ImageBackground source={image} style={styles.bgImage}>
1200
- <DrawPad
1201
- currentItem={currentItem}
1202
- doneItems={drawState.doneItems}
1203
- onPressItem={onPressItem}
1204
- onTextHeightChange={onTextHeightChange}
1205
- />
1206
- </ImageBackground>
1325
+ <DrawPad
1326
+ addBackground
1327
+ currentItem={currentItem}
1328
+ doneItems={drawState.doneItems}
1329
+ onPressItem={onPressItem}
1330
+ onTextHeightChange={onTextHeightChange}
1331
+ />
1207
1332
  </ViewShot>
1208
- ) : null
1209
- ) : drawRegion ? (
1210
- <ViewShot
1211
- ref={viewShot}
1212
- options={{
1213
- format: 'jpg',
1214
- quality: 1,
1215
- ...drawRegion,
1216
- }}
1217
- style={drawRegion}
1218
- >
1219
- <DrawPad
1220
- addBackground
1221
- currentItem={currentItem}
1222
- doneItems={drawState.doneItems}
1223
- onPressItem={onPressItem}
1224
- onTextHeightChange={onTextHeightChange}
1225
- />
1226
- </ViewShot>
1227
- ) : null}
1228
- </View>
1229
- </Animated.View>
1230
- </PanGestureHandler>
1231
- {Platform.OS === 'ios' ? (
1333
+ ) : null}
1334
+ </View>
1335
+ </Animated.View>
1336
+ </PanGestureHandler>
1337
+
1338
+ <TextInput
1339
+ ref={textInputRef}
1340
+ style={styles.textInput}
1341
+ onEndEditing={textInputRef.current?.clear}
1342
+ onChangeText={setTextVal}
1343
+ value={textVal}
1344
+ autoCorrect={false}
1345
+ />
1346
+ </KeyboardAvoidingView>
1347
+ {/*Platform.OS === 'ios' ? (
1232
1348
  <InputAccessoryView>
1233
1349
  <AnimatedTextInput
1234
1350
  ref={textInputRef}
@@ -1238,6 +1354,9 @@ const DrawCore = ({
1238
1354
  value={textVal}
1239
1355
  autoCorrect={false}
1240
1356
  />
1357
+ <View
1358
+ style={{ height: 10, width: '100%', backgroundColor: 'green' }}
1359
+ ></View>
1241
1360
  </InputAccessoryView>
1242
1361
  ) : (
1243
1362
  <Animated.View style={textInputContainerStyle}>
@@ -1252,7 +1371,7 @@ const DrawCore = ({
1252
1371
  />
1253
1372
  )}
1254
1373
  </Animated.View>
1255
- )}
1374
+ )*/}
1256
1375
  </View>
1257
1376
  </View>
1258
1377
  );
@@ -10,6 +10,7 @@ const useDrawHook = () => {
10
10
  currentItem,
11
11
  itemIsSelected,
12
12
  viewShot,
13
+ doubleArrowTextInput,
13
14
  } = useContext(DrawContext);
14
15
 
15
16
  const takeSnapshot = useCallback(async () => {
@@ -64,6 +65,7 @@ const useDrawHook = () => {
64
65
  takeSnapshot: takeSnapshot!,
65
66
  viewShot: viewShot!,
66
67
  deleteSelectedItem,
68
+ doubleArrowTextInput,
67
69
  };
68
70
  };
69
71
 
@@ -106,6 +106,7 @@ function DrawWithOptionsCore({
106
106
  const sudDidShow = Keyboard.addListener(
107
107
  'keyboardDidShow',
108
108
  (event: { endCoordinates: { height: number } }) => {
109
+ console.log('keyboardDidShow dwo');
109
110
  // avoid events triggered by InputAccessoryView
110
111
  if (event.endCoordinates.height > 100) {
111
112
  setShowToolbar(false);
@@ -244,6 +245,23 @@ function DrawWithOptionsCore({
244
245
  opacity={drawState.drawingMode === 'text' ? 1 : 0.5}
245
246
  />
246
247
  </Pressable>
248
+
249
+ <Pressable
250
+ style={styles.option}
251
+ onPress={() => {
252
+ dispatchDrawStates({
253
+ type: 'SET_DRAWING_MODE',
254
+ drawingMode: 'doubleArrows',
255
+ });
256
+ }}
257
+ >
258
+ <DoubleHeadSvg
259
+ height={20}
260
+ width={20}
261
+ fill="#ffffff"
262
+ opacity={drawState.drawingMode === 'doubleArrows' ? 1 : 0.5}
263
+ />
264
+ </Pressable>
247
265
  </View>
248
266
  </View>
249
267
 
package/src/types.d.ts CHANGED
@@ -18,6 +18,13 @@ export type Size = { width: number; height: number };
18
18
  export type DrawItem = (
19
19
  | { type: 'singleHead'; data: LineProps }
20
20
  | { type: 'doubleHead'; data: LineProps }
21
+ | {
22
+ type: 'doubleArrows';
23
+ data: LineProps;
24
+ text?: string;
25
+ strokeWidth: number;
26
+ color?: string;
27
+ }
21
28
  | { type: 'rectangle'; data: RectProps }
22
29
  | { type: 'ellipse'; data: EllipseProps }
23
30
  | { type: 'text'; data: ForeignObjectProps; text?: string }