@archireport/react-native-svg-draw 1.4.0 → 2.0.0

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 (130) hide show
  1. package/README.md +73 -27
  2. package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js +10 -5
  3. package/lib/commonjs/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
  4. package/lib/commonjs/components/DrawCore/CurrentAnimatedText.js.map +1 -1
  5. package/lib/commonjs/components/DrawCore/DrawContext.js +18 -0
  6. package/lib/commonjs/components/DrawCore/DrawContext.js.map +1 -0
  7. package/lib/commonjs/components/DrawCore/DrawPad.js.map +1 -1
  8. package/lib/commonjs/components/DrawCore/DrawProvider.js +103 -0
  9. package/lib/commonjs/components/DrawCore/DrawProvider.js.map +1 -0
  10. package/lib/commonjs/components/DrawCore/Item.js.map +1 -1
  11. package/lib/commonjs/components/DrawCore/index.js +41 -168
  12. package/lib/commonjs/components/DrawCore/index.js.map +1 -1
  13. package/lib/commonjs/components/DrawCore/useDrawHook.js +76 -0
  14. package/lib/commonjs/components/DrawCore/useDrawHook.js.map +1 -0
  15. package/lib/commonjs/components/DrawWithOptions/ArrowSvg.js.map +1 -1
  16. package/lib/commonjs/components/DrawWithOptions/CancelSvg.js.map +1 -1
  17. package/lib/commonjs/components/DrawWithOptions/CircleSvg.js.map +1 -1
  18. package/lib/commonjs/components/DrawWithOptions/CloseSvg.js.map +1 -1
  19. package/lib/commonjs/components/DrawWithOptions/DoubleHeadSvg.js.map +1 -1
  20. package/lib/commonjs/components/DrawWithOptions/PenSvg.js.map +1 -1
  21. package/lib/commonjs/components/DrawWithOptions/SendSvg.js.map +1 -1
  22. package/lib/commonjs/components/DrawWithOptions/SliderSvg.js +31 -0
  23. package/lib/commonjs/components/DrawWithOptions/SliderSvg.js.map +1 -0
  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 +27 -2
  27. package/lib/commonjs/components/DrawWithOptions/ThrashSvg.js.map +1 -1
  28. package/lib/commonjs/components/DrawWithOptions/index.js +124 -70
  29. package/lib/commonjs/components/DrawWithOptions/index.js.map +1 -1
  30. package/lib/commonjs/components/{DrawCore → Slider}/ColorSlider.js +45 -62
  31. package/lib/commonjs/components/Slider/ColorSlider.js.map +1 -0
  32. package/lib/commonjs/components/Slider/Sliders.js +88 -0
  33. package/lib/commonjs/components/Slider/Sliders.js.map +1 -0
  34. package/lib/commonjs/components/{DrawCore → Slider}/StrokeSlider.js +38 -47
  35. package/lib/commonjs/components/Slider/StrokeSlider.js.map +1 -0
  36. package/lib/commonjs/components/Slider/sliderStyle.js +37 -0
  37. package/lib/commonjs/components/Slider/sliderStyle.js.map +1 -0
  38. package/lib/commonjs/index.js +7 -0
  39. package/lib/commonjs/index.js.map +1 -1
  40. package/lib/module/components/DrawCore/CurrentAnimatedItem.js +10 -5
  41. package/lib/module/components/DrawCore/CurrentAnimatedItem.js.map +1 -1
  42. package/lib/module/components/DrawCore/CurrentAnimatedText.js.map +1 -1
  43. package/lib/module/components/DrawCore/DrawContext.js +11 -0
  44. package/lib/module/components/DrawCore/DrawContext.js.map +1 -0
  45. package/lib/module/components/DrawCore/DrawPad.js.map +1 -1
  46. package/lib/module/components/DrawCore/DrawProvider.js +94 -0
  47. package/lib/module/components/DrawCore/DrawProvider.js.map +1 -0
  48. package/lib/module/components/DrawCore/Item.js.map +1 -1
  49. package/lib/module/components/DrawCore/index.js +43 -170
  50. package/lib/module/components/DrawCore/index.js.map +1 -1
  51. package/lib/module/components/DrawCore/useDrawHook.js +69 -0
  52. package/lib/module/components/DrawCore/useDrawHook.js.map +1 -0
  53. package/lib/module/components/DrawWithOptions/ArrowSvg.js.map +1 -1
  54. package/lib/module/components/DrawWithOptions/CancelSvg.js.map +1 -1
  55. package/lib/module/components/DrawWithOptions/CircleSvg.js.map +1 -1
  56. package/lib/module/components/DrawWithOptions/CloseSvg.js.map +1 -1
  57. package/lib/module/components/DrawWithOptions/DoubleHeadSvg.js.map +1 -1
  58. package/lib/module/components/DrawWithOptions/PenSvg.js.map +1 -1
  59. package/lib/module/components/DrawWithOptions/SendSvg.js.map +1 -1
  60. package/lib/module/components/DrawWithOptions/SliderSvg.js +22 -0
  61. package/lib/module/components/DrawWithOptions/SliderSvg.js.map +1 -0
  62. package/lib/module/components/DrawWithOptions/SquareSvg.js.map +1 -1
  63. package/lib/module/components/DrawWithOptions/TextSvg.js.map +1 -1
  64. package/lib/module/components/DrawWithOptions/ThrashSvg.js +27 -2
  65. package/lib/module/components/DrawWithOptions/ThrashSvg.js.map +1 -1
  66. package/lib/module/components/DrawWithOptions/index.js +124 -70
  67. package/lib/module/components/DrawWithOptions/index.js.map +1 -1
  68. package/lib/module/components/Slider/ColorSlider.js +95 -0
  69. package/lib/module/components/Slider/ColorSlider.js.map +1 -0
  70. package/lib/module/components/Slider/Sliders.js +79 -0
  71. package/lib/module/components/Slider/Sliders.js.map +1 -0
  72. package/lib/module/components/Slider/StrokeSlider.js +82 -0
  73. package/lib/module/components/Slider/StrokeSlider.js.map +1 -0
  74. package/lib/module/components/Slider/sliderStyle.js +29 -0
  75. package/lib/module/components/Slider/sliderStyle.js.map +1 -0
  76. package/lib/module/index.js +1 -0
  77. package/lib/module/index.js.map +1 -1
  78. package/lib/typescript/components/DrawCore/CurrentAnimatedItem.d.ts.map +1 -1
  79. package/lib/typescript/components/DrawCore/DrawContext.d.ts +14 -0
  80. package/lib/typescript/components/DrawCore/DrawContext.d.ts.map +1 -0
  81. package/lib/typescript/components/DrawCore/DrawPad.d.ts.map +1 -1
  82. package/lib/typescript/components/DrawCore/DrawProvider.d.ts +6 -0
  83. package/lib/typescript/components/DrawCore/DrawProvider.d.ts.map +1 -0
  84. package/lib/typescript/components/DrawCore/index.d.ts +3 -11
  85. package/lib/typescript/components/DrawCore/index.d.ts.map +1 -1
  86. package/lib/typescript/components/DrawCore/useDrawHook.d.ts +18 -0
  87. package/lib/typescript/components/DrawCore/useDrawHook.d.ts.map +1 -0
  88. package/lib/typescript/components/DrawWithOptions/SliderSvg.d.ts +4 -0
  89. package/lib/typescript/components/DrawWithOptions/SliderSvg.d.ts.map +1 -0
  90. package/lib/typescript/components/DrawWithOptions/ThrashSvg.d.ts.map +1 -1
  91. package/lib/typescript/components/DrawWithOptions/index.d.ts +3 -5
  92. package/lib/typescript/components/DrawWithOptions/index.d.ts.map +1 -1
  93. package/lib/typescript/components/Slider/ColorSlider.d.ts +8 -0
  94. package/lib/typescript/components/Slider/ColorSlider.d.ts.map +1 -0
  95. package/lib/typescript/components/Slider/Sliders.d.ts +8 -0
  96. package/lib/typescript/components/Slider/Sliders.d.ts.map +1 -0
  97. package/lib/typescript/components/Slider/StrokeSlider.d.ts +6 -0
  98. package/lib/typescript/components/Slider/StrokeSlider.d.ts.map +1 -0
  99. package/lib/typescript/components/Slider/sliderStyle.d.ts +28 -0
  100. package/lib/typescript/components/Slider/sliderStyle.d.ts.map +1 -0
  101. package/lib/typescript/index.d.ts +1 -0
  102. package/lib/typescript/index.d.ts.map +1 -1
  103. package/package.json +22 -22
  104. package/src/components/DrawCore/CurrentAnimatedItem.tsx +10 -5
  105. package/src/components/DrawCore/DrawContext.tsx +22 -0
  106. package/src/components/DrawCore/DrawPad.tsx +0 -1
  107. package/src/components/DrawCore/DrawProvider.tsx +122 -0
  108. package/src/components/DrawCore/index.tsx +938 -1139
  109. package/src/components/DrawCore/useDrawHook.tsx +70 -0
  110. package/src/components/DrawWithOptions/SliderSvg.tsx +24 -0
  111. package/src/components/DrawWithOptions/ThrashSvg.tsx +29 -2
  112. package/src/components/DrawWithOptions/index.tsx +199 -146
  113. package/src/components/Slider/ColorSlider.tsx +144 -0
  114. package/src/components/Slider/Sliders.tsx +75 -0
  115. package/src/components/Slider/StrokeSlider.tsx +104 -0
  116. package/src/components/Slider/sliderStyle.tsx +28 -0
  117. package/src/index.tsx +1 -0
  118. package/src/types.d.ts +35 -1
  119. package/lib/commonjs/components/DrawCore/ColorSlider.js.map +0 -1
  120. package/lib/commonjs/components/DrawCore/StrokeSlider.js.map +0 -1
  121. package/lib/module/components/DrawCore/ColorSlider.js +0 -113
  122. package/lib/module/components/DrawCore/ColorSlider.js.map +0 -1
  123. package/lib/module/components/DrawCore/StrokeSlider.js +0 -91
  124. package/lib/module/components/DrawCore/StrokeSlider.js.map +0 -1
  125. package/lib/typescript/components/DrawCore/ColorSlider.d.ts +0 -13
  126. package/lib/typescript/components/DrawCore/ColorSlider.d.ts.map +0 -1
  127. package/lib/typescript/components/DrawCore/StrokeSlider.d.ts +0 -9
  128. package/lib/typescript/components/DrawCore/StrokeSlider.d.ts.map +0 -1
  129. package/src/components/DrawCore/ColorSlider.tsx +0 -169
  130. package/src/components/DrawCore/StrokeSlider.tsx +0 -117
@@ -0,0 +1,70 @@
1
+ import { DrawContext } from './DrawContext';
2
+ import { useCallback, useContext } from 'react';
3
+
4
+ const useDrawHook = () => {
5
+ const {
6
+ drawState,
7
+ dispatchDrawStates,
8
+ strokeWidth,
9
+ color,
10
+ currentItem,
11
+ itemIsSelected,
12
+ viewShot,
13
+ } = useContext(DrawContext);
14
+
15
+ const takeSnapshot = useCallback(async () => {
16
+ if (currentItem?.value) {
17
+ dispatchDrawStates({ type: 'ADD_DONE_ITEM', item: currentItem.value });
18
+ currentItem.value = null;
19
+ }
20
+ return viewShot!.current?.capture?.();
21
+ }, [currentItem, dispatchDrawStates, viewShot]);
22
+
23
+ const cancelLastAction = useCallback(() => {
24
+ itemIsSelected!.value = false;
25
+ if (currentItem?.value) {
26
+ currentItem.value = null;
27
+ }
28
+ dispatchDrawStates({
29
+ type: 'CANCEL',
30
+ });
31
+ }, [currentItem, dispatchDrawStates, itemIsSelected]);
32
+
33
+ const deleteSelectedItem = useCallback(() => {
34
+ if (currentItem?.value) {
35
+ currentItem.value = null;
36
+ dispatchDrawStates({
37
+ type: 'ADD_SCREEN_STATE',
38
+ currentItem: currentItem.value,
39
+ cancelEnabled: true,
40
+ });
41
+ }
42
+ itemIsSelected!.value = false;
43
+ }, [currentItem, dispatchDrawStates, itemIsSelected]);
44
+
45
+ const onColorStrokeChange = useCallback(() => {
46
+ 'worklet';
47
+ if (currentItem?.value) {
48
+ dispatchDrawStates({
49
+ type: 'ADD_SCREEN_STATE',
50
+ currentItem: currentItem.value,
51
+ });
52
+ }
53
+ }, [currentItem?.value, dispatchDrawStates]);
54
+
55
+ return {
56
+ drawState: drawState!,
57
+ dispatchDrawStates,
58
+ currentItem: currentItem!,
59
+ strokeWidth: strokeWidth!,
60
+ color: color!,
61
+ onColorStrokeChange,
62
+ itemIsSelected: itemIsSelected!,
63
+ cancelLastAction,
64
+ takeSnapshot: takeSnapshot!,
65
+ viewShot: viewShot!,
66
+ deleteSelectedItem,
67
+ };
68
+ };
69
+
70
+ export default useDrawHook;
@@ -0,0 +1,24 @@
1
+ import * as React from 'react';
2
+ import { View } from 'react-native';
3
+ import Svg, { SvgProps, Path } from 'react-native-svg';
4
+
5
+ function SvgSlider(props: SvgProps) {
6
+ return (
7
+ <View style={{ aspectRatio: 10, justifyContent: 'center' }}>
8
+ <Svg
9
+ width="100%"
10
+ height="100%"
11
+ viewBox="0 0 189 6"
12
+ fill="none"
13
+ {...props}
14
+ >
15
+ <Path
16
+ d="M0.99994 4.01059C0.445985 4.00473 -7.21155e-08 3.554 -1.31135e-07 3.00001C-1.90155e-07 2.44602 0.445985 1.99529 0.999941 1.98943L186 0.0317445C187.652 0.0142669 189 1.3483 189 3C189 4.65169 187.652 5.98572 186 5.96825L0.99994 4.01059Z"
17
+ fill="currentColor"
18
+ />
19
+ </Svg>
20
+ </View>
21
+ );
22
+ }
23
+
24
+ export default SvgSlider;
@@ -3,8 +3,35 @@ import Svg, { SvgProps, Path } from 'react-native-svg';
3
3
 
4
4
  function ThrashSvg(props: SvgProps) {
5
5
  return (
6
- <Svg viewBox="0 0 28 29" {...props}>
7
- <Path d="M14 0a3.5 3.5 0 013.5 3.5l-.001 1.166h4.668c.601 0 1.096.456 1.16 1.04l.006.127c0 .645-.522 1.167-1.166 1.167l-1.168-.001L21 22.167a3.5 3.5 0 01-3.308 3.494l-.192.006H5.833a3.5 3.5 0 01-3.5-3.5V6.999L1.167 7a1.166 1.166 0 01-1.16-1.04L0 5.833c0-.644.522-1.166 1.167-1.166l4.666-.001V3.5A3.5 3.5 0 019.141.005L9.333 0zM6.982 7l-2.316-.001v15.168c0 .601.456 1.096 1.04 1.16l.127.006H17.5c.644 0 1.167-.522 1.167-1.166l-.001-15.168h-2.315L16.333 7h-.018l-9.298-.001L7 7h-.018zm2.351 3.5c.645 0 1.167.522 1.167 1.167v7a1.166 1.166 0 01-2.333 0v-7c0-.645.522-1.167 1.166-1.167zm4.667 0c.644 0 1.167.522 1.167 1.167v7a1.167 1.167 0 01-2.334 0v-7c0-.645.523-1.167 1.167-1.167zm0-8.167H9.333c-.644 0-1.166.523-1.166 1.167l-.001 1.166h7V3.5c0-.601-.454-1.096-1.039-1.16L14 2.333z" />
6
+ <Svg width="25" height="25" viewBox="0 0 25 25" fill="none" {...props}>
7
+ <Path
8
+ d="M3.5 6.5L5.5 6.5L21.5 6.5"
9
+ stroke="currentColor"
10
+ stroke-width="2"
11
+ stroke-linecap="round"
12
+ stroke-linejoin="round"
13
+ />
14
+ <Path
15
+ d="M8.5 6.5V4.5C8.5 3.96957 8.71071 3.46086 9.08579 3.08579C9.46086 2.71071 9.96957 2.5 10.5 2.5L14.5 2.5C15.0304 2.5 15.5391 2.71071 15.9142 3.08579C16.2893 3.46086 16.5 3.96957 16.5 4.5V6.5M19.5 6.5L19.5 20.5C19.5 21.0304 19.2893 21.5391 18.9142 21.9142C18.5391 22.2893 18.0304 22.5 17.5 22.5L7.5 22.5C6.96957 22.5 6.46086 22.2893 6.08579 21.9142C5.71071 21.5391 5.5 21.0304 5.5 20.5L5.5 6.5L19.5 6.5Z"
16
+ stroke="currentColor"
17
+ stroke-width="2"
18
+ stroke-linecap="round"
19
+ stroke-linejoin="round"
20
+ />
21
+ <Path
22
+ d="M10.5 11.5L10.5 17.5"
23
+ stroke="currentColor"
24
+ stroke-width="2"
25
+ stroke-linecap="round"
26
+ stroke-linejoin="round"
27
+ />
28
+ <Path
29
+ d="M14.5 11.5L14.5 17.5"
30
+ stroke="currentColor"
31
+ stroke-width="2"
32
+ stroke-linecap="round"
33
+ stroke-linejoin="round"
34
+ />
8
35
  </Svg>
9
36
  );
10
37
  }
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useEffect, useRef, useState } from 'react';
1
+ import React, { useCallback, useEffect, useState } from 'react';
2
2
  import {
3
3
  Pressable,
4
4
  View,
@@ -8,39 +8,49 @@ import {
8
8
  ImageURISource,
9
9
  Keyboard,
10
10
  } from 'react-native';
11
- import DrawCore from '../DrawCore';
12
- import type { DrawItemType, DrawCoreProps } from '../../types';
13
- import PenSvg from './PenSvg';
14
11
  import DoubleHeadSvg from './DoubleHeadSvg';
15
12
  import CircleSvg from './CircleSvg';
16
13
  import SquareSvg from './SquareSvg';
17
14
  import ArrowSvg from './ArrowSvg';
18
15
  import TextSvg from './TextSvg';
19
16
  import CloseSvg from './CloseSvg';
17
+ import PenSvg from './PenSvg';
18
+ import useDrawHook from '../DrawCore/useDrawHook';
19
+ import Sliders from '../Slider/Sliders';
20
+ import DrawCore from '../DrawCore';
20
21
  import ThrashSvg from './ThrashSvg';
21
- import SendSvg from './SendSvg';
22
22
  import CancelSvg from './CancelSvg';
23
+ import SendSvg from './SendSvg';
23
24
 
24
25
  const styles = StyleSheet.create({
25
- container: { flex: 1, backgroundColor: '#000000' },
26
+ container: { flex: 1 },
27
+ actionButton: {
28
+ backgroundColor: 'grey',
29
+ padding: 10,
30
+ justifyContent: 'center',
31
+ alignContent: 'center',
32
+ alignItems: 'center',
33
+ height: 40,
34
+ borderRadius: 20,
35
+ width: 40,
36
+ },
26
37
  option: {
27
- width: 30,
28
- height: 30,
38
+ width: 22,
39
+ height: 20,
29
40
  justifyContent: 'center',
30
41
  alignItems: 'center',
31
- marginHorizontal: 4,
42
+ marginHorizontal: 8,
32
43
  },
33
44
  toolbar: {
34
45
  flexDirection: 'row',
35
- alignItems: 'center',
36
46
  justifyContent: 'space-between',
37
47
  paddingBottom: 30,
38
48
  paddingTop: 15,
39
49
  paddingHorizontal: 15,
40
50
  },
41
51
  drawOptions: {
42
- flexDirection: 'row',
43
- alignItems: 'center',
52
+ flex: 1,
53
+ paddingHorizontal: 10,
44
54
  },
45
55
  sendButton: {
46
56
  backgroundColor: '#3a6cff',
@@ -61,33 +71,25 @@ const styles = StyleSheet.create({
61
71
  },
62
72
  });
63
73
 
64
- export default function DrawWithOptions({
65
- close,
66
- takeSnapshot,
74
+ export default function DrawWithOption({
67
75
  linearGradient,
68
76
  image,
69
- defaultDrawingMode = 'ellipse',
77
+ close,
78
+ takeSnapshot,
70
79
  }: {
71
- close?: () => void;
72
- takeSnapshot?: (snap: Promise<string | undefined>) => void;
73
80
  linearGradient: React.ComponentType<{ colors: any[] } & ViewProps>;
74
81
  image?: ImageRequireSource | ImageURISource;
75
- defaultDrawingMode?: DrawItemType;
82
+ close?: () => void;
83
+ takeSnapshot?: (snap: Promise<string | undefined>) => void;
76
84
  }) {
77
- const drawRef = useRef<DrawCoreProps>(null);
78
-
79
- const [drawingMode, setDrawingMode] =
80
- useState<DrawItemType>(defaultDrawingMode);
81
-
82
- const [selectedItem, setSelectedItem] = useState(false);
83
-
84
- const [cancelEnabled, setCancelEnabled] = useState(false);
85
-
86
- const onPressSend = useCallback(() => {
87
- if (drawRef.current) {
88
- takeSnapshot?.(drawRef.current.takeSnapshot());
89
- }
90
- }, [takeSnapshot]);
85
+ const {
86
+ itemIsSelected,
87
+ cancelLastAction,
88
+ takeSnapshot: takeSnapshotAction,
89
+ deleteSelectedItem,
90
+ dispatchDrawStates,
91
+ drawState,
92
+ } = useDrawHook();
91
93
 
92
94
  const [showToolbar, setShowToolbar] = useState(true);
93
95
 
@@ -96,12 +98,15 @@ export default function DrawWithOptions({
96
98
  setShowToolbar(true);
97
99
  });
98
100
 
99
- const sudDidShow = Keyboard.addListener('keyboardDidShow', (event) => {
100
- // avoid events triggered by InputAccessoryView
101
- if (event.endCoordinates.height > 100) {
102
- setShowToolbar(false);
101
+ const sudDidShow = Keyboard.addListener(
102
+ 'keyboardDidShow',
103
+ (event: { endCoordinates: { height: number } }) => {
104
+ // avoid events triggered by InputAccessoryView
105
+ if (event.endCoordinates.height > 100) {
106
+ setShowToolbar(false);
107
+ }
103
108
  }
104
- });
109
+ );
105
110
 
106
111
  // cleanup function
107
112
  return () => {
@@ -110,136 +115,184 @@ export default function DrawWithOptions({
110
115
  };
111
116
  }, []);
112
117
 
118
+ const takeSnapshotAndGetUri = useCallback(async () => {
119
+ if (takeSnapshot) {
120
+ takeSnapshot(takeSnapshotAction());
121
+ }
122
+ }, [takeSnapshot, takeSnapshotAction]);
113
123
  return (
114
124
  <View style={styles.container}>
115
125
  <View style={styles.toolbar}>
116
- <Pressable style={styles.option} onPress={close}>
117
- <CloseSvg height={20} width={20} fill="#ffffff" />
118
- </Pressable>
119
- <View style={styles.drawOptions}>
120
- <Pressable
121
- style={styles.option}
122
- onPress={() => {
123
- setDrawingMode('pen');
124
- }}
125
- >
126
- <PenSvg
127
- height={23}
128
- width={22}
129
- stroke="#ffffff"
130
- strokeWidth="2"
131
- opacity={drawingMode === 'pen' ? 1 : 0.5}
132
- />
133
- </Pressable>
134
- <Pressable
135
- style={styles.option}
136
- onPress={() => {
137
- setDrawingMode('doubleHead');
138
- }}
139
- >
140
- <DoubleHeadSvg
141
- height={20}
142
- width={20}
143
- fill="#ffffff"
144
- opacity={drawingMode === 'doubleHead' ? 1 : 0.5}
145
- />
146
- </Pressable>
147
- <Pressable
148
- style={styles.option}
149
- onPress={() => {
150
- setDrawingMode('singleHead');
151
- }}
152
- >
153
- <ArrowSvg
154
- height={23}
155
- width={23}
156
- fill="#ffffff"
157
- opacity={drawingMode === 'singleHead' ? 1 : 0.5}
158
- />
159
- </Pressable>
160
- <Pressable
161
- style={styles.option}
162
- onPress={() => {
163
- setDrawingMode('rectangle');
164
- }}
165
- >
166
- <SquareSvg
167
- height={27}
168
- width={27}
169
- fill="#ffffff"
170
- opacity={drawingMode === 'rectangle' ? 1 : 0.5}
171
- />
126
+ <View style={styles.actionButton}>
127
+ <Pressable onPress={close}>
128
+ <CloseSvg height={20} width={20} fill="#ffffff" />
172
129
  </Pressable>
173
- <Pressable
174
- style={styles.option}
175
- onPress={() => {
176
- setDrawingMode('ellipse');
177
- }}
178
- >
179
- <CircleSvg
180
- fill="#ffffff"
181
- height={26}
182
- width={26}
183
- opacity={drawingMode === 'ellipse' ? 1 : 0.5}
184
- />
185
- </Pressable>
186
-
187
- <Pressable
188
- style={styles.option}
189
- onPress={() => {
190
- setDrawingMode('text');
130
+ </View>
131
+ <View style={styles.drawOptions}>
132
+ <View
133
+ style={{
134
+ flexDirection: 'row',
135
+ alignSelf: 'center',
136
+ borderWidth: 1,
137
+ borderColor: 'grey',
138
+ borderRadius: 25,
139
+ height: 40,
140
+ paddingHorizontal: 10,
141
+ paddingVertical: 10,
191
142
  }}
192
143
  >
193
- <TextSvg
194
- height={28}
195
- width={28}
196
- fill="#ffffff"
197
- opacity={drawingMode === 'text' ? 1 : 0.5}
198
- />
199
- </Pressable>
200
- </View>
201
- </View>
202
- <DrawCore
203
- ref={drawRef}
204
- drawingMode={drawingMode}
205
- image={image}
206
- linearGradient={linearGradient}
207
- onSelectionChange={setSelectedItem}
208
- onCancelChange={setCancelEnabled}
209
- />
210
-
211
- {showToolbar ? (
212
- <View style={styles.bottomToolBar}>
213
- {selectedItem ? (
214
144
  <Pressable
215
145
  style={styles.option}
216
146
  onPress={() => {
217
- drawRef.current?.deleteSelectedItem();
147
+ dispatchDrawStates({
148
+ type: 'SET_DRAWING_MODE',
149
+ drawingMode: 'pen',
150
+ });
218
151
  }}
219
152
  >
220
- <ThrashSvg width={28} height={28} fill="white" />
153
+ <PenSvg
154
+ height={23}
155
+ width={22}
156
+ stroke="#ffffff"
157
+ strokeWidth="2"
158
+ opacity={drawState.drawingMode === 'pen' ? 1 : 0.5}
159
+ />
221
160
  </Pressable>
222
- ) : null}
223
- {cancelEnabled ? (
224
161
  <Pressable
225
162
  style={styles.option}
226
163
  onPress={() => {
227
- drawRef.current?.cancelLastAction();
164
+ dispatchDrawStates({
165
+ type: 'SET_DRAWING_MODE',
166
+ drawingMode: 'doubleHead',
167
+ });
228
168
  }}
229
169
  >
230
- <CancelSvg
231
- width={27}
170
+ <DoubleHeadSvg
171
+ height={20}
172
+ width={20}
173
+ fill="#ffffff"
174
+ opacity={drawState.drawingMode === 'doubleHead' ? 1 : 0.5}
175
+ />
176
+ </Pressable>
177
+ <Pressable
178
+ style={styles.option}
179
+ onPress={() => {
180
+ dispatchDrawStates({
181
+ type: 'SET_DRAWING_MODE',
182
+ drawingMode: 'singleHead',
183
+ });
184
+ }}
185
+ >
186
+ <ArrowSvg
187
+ height={23}
188
+ width={23}
189
+ fill="#ffffff"
190
+ opacity={drawState.drawingMode === 'singleHead' ? 1 : 0.5}
191
+ />
192
+ </Pressable>
193
+ <Pressable
194
+ style={styles.option}
195
+ onPress={() => {
196
+ dispatchDrawStates({
197
+ type: 'SET_DRAWING_MODE',
198
+ drawingMode: 'rectangle',
199
+ });
200
+ }}
201
+ >
202
+ <SquareSvg
232
203
  height={27}
233
- stroke="#ffffff"
234
- strokeWidth={2}
204
+ width={27}
205
+ fill="#ffffff"
206
+ opacity={drawState.drawingMode === 'rectangle' ? 1 : 0.5}
235
207
  />
236
208
  </Pressable>
237
- ) : null}
238
- <Pressable style={styles.sendButton} onPress={onPressSend}>
239
- <SendSvg fill="#fff" width={20} height={20} />
209
+ <Pressable
210
+ style={styles.option}
211
+ onPress={() => {
212
+ dispatchDrawStates({
213
+ type: 'SET_DRAWING_MODE',
214
+ drawingMode: 'ellipse',
215
+ });
216
+ }}
217
+ >
218
+ <CircleSvg
219
+ fill="#ffffff"
220
+ height={26}
221
+ width={26}
222
+ opacity={drawState.drawingMode === 'ellipse' ? 1 : 0.5}
223
+ />
224
+ </Pressable>
225
+
226
+ <Pressable
227
+ style={styles.option}
228
+ onPress={() => {
229
+ dispatchDrawStates({
230
+ type: 'SET_DRAWING_MODE',
231
+ drawingMode: 'text',
232
+ });
233
+ }}
234
+ >
235
+ <TextSvg
236
+ height={28}
237
+ width={28}
238
+ color={'grey'}
239
+ opacity={drawState.drawingMode === 'text' ? 1 : 0.5}
240
+ />
241
+ </Pressable>
242
+ </View>
243
+ </View>
244
+
245
+ <View style={styles.actionButton}>
246
+ <Pressable onPress={takeSnapshotAndGetUri}>
247
+ <SendSvg height={20} width={20} fill="#ffffff" />
240
248
  </Pressable>
241
249
  </View>
242
- ) : null}
250
+ </View>
251
+ <View
252
+ style={{
253
+ marginHorizontal: 0,
254
+ flex: 1,
255
+ }}
256
+ >
257
+ <DrawCore image={image} />
258
+ </View>
259
+
260
+ <Sliders linearGradient={linearGradient} />
261
+
262
+ <View style={{ height: 70 }}>
263
+ {showToolbar ? (
264
+ <View style={styles.bottomToolBar}>
265
+ {itemIsSelected.value ? (
266
+ <View style={{ ...styles.actionButton, marginRight: 10 }}>
267
+ <Pressable style={styles.option} onPress={deleteSelectedItem}>
268
+ <ThrashSvg
269
+ width={28}
270
+ height={28}
271
+ color="white"
272
+ strokeWidth={2}
273
+ />
274
+ </Pressable>
275
+ </View>
276
+ ) : null}
277
+ {drawState.cancelEnabled ? (
278
+ <View
279
+ style={{
280
+ ...styles.actionButton,
281
+ }}
282
+ >
283
+ <Pressable style={styles.option} onPress={cancelLastAction}>
284
+ <CancelSvg
285
+ width={28}
286
+ height={28}
287
+ color={'grey'}
288
+ strokeWidth={2}
289
+ />
290
+ </Pressable>
291
+ </View>
292
+ ) : null}
293
+ </View>
294
+ ) : null}
295
+ </View>
243
296
  </View>
244
297
  );
245
298
  }