@supportworks/multi-imagepicker 7.3.2 → 8.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.
package/README.md CHANGED
@@ -1,232 +1,58 @@
1
- # @supportworks/Multi-ImagePicker
2
1
 
3
- This library wraps `react-native-image-crop-picker` for React Native apps and provides a shared image-picking flow with support for:
2
+ # @supportworks/Multi-ImagePicker
4
3
 
5
- - selecting one or more images
6
- - editing image titles/descriptions before attach
7
- - per-image metadata such as `showToCust` and `saveToDevice`
8
- - attaching images to a project, appointment, or other app-specific target
4
+ This library is used to implement react-native-image-crop-picker in iOS and Android apps built with react-native >= 0.60, which allows selection of multiple images at once.
9
5
 
10
6
  ## Getting started
11
7
 
12
- See `peerDependencies` in `package.json` and install the required libraries in the app.
13
-
14
- Install with:
15
-
16
- ```bash
17
- npm install @supportworks/Multi-ImagePicker
18
- ```
19
-
20
- Version `3.x` has breaking changes for React Native `>= 0.60`.
21
-
22
- iOS note: when building the app the first time, in Xcode under `Embedded Binaries`, add:
23
-
24
- - `RSKImageCropper.framework`
25
- - `QBImagePicker.framework`
26
-
27
- ## Current AddImages architecture
28
-
29
- `AddImages` no longer presents itself with a native React Native `Modal`.
8
+ See 'peerDependencies' list in package.json. Make sure to install all of those libraries, or add them to your app's package.json.
30
9
 
31
- Instead:
10
+ Run `npm install @supportworks/Multi-ImagePicker` or add it to your package.json
32
11
 
33
- - `AddImages` is the trigger/controller
34
- - `AddImagesProvider` renders the full-screen overlay host
12
+ NOTE: version 3.0 has breaking changes, is only for react-native >= 0.60.0, so be sure to use 'react-native-image-crop-picker' version >=0.25.0 instead of the older '@supportworks/react-native-image-crop-picker'. No other changes besides this should be needed to the code.
35
13
 
36
- This avoids nested native modal presentation problems on iOS, especially when `AddImages` is launched from a sheet, bottom modal, or other modal-like container.
37
-
38
- `AddImages` must be rendered inside an `AddImagesProvider`. If it is not, the component will throw:
39
-
40
- ```txt
41
- AddImages must be used within an AddImagesProvider.
42
- ```
43
-
44
- ## Usage - imports
14
+ iOS: When building app the first time, in XCode, Under 'Embedded Binaries', add RSKImageCropper.framework and QBImagePicker.framework.
45
15
 
16
+ ## Usage - import
46
17
  ```javascript
47
- import {
48
- AddImages,
49
- AddImagesProvider,
50
- MultiImagePicker,
51
- SelectedImages
52
- } from '@supportworks/Multi-ImagePicker'
18
+ import {AddImages, MultiImagePicker} from '@supportworks/Multi-ImagePicker';
53
19
  ```
54
20
 
55
- ## Info.plist additions for iOS
56
-
57
- Saving to Camera Roll currently applies to iOS only.
58
-
59
- ```xml
21
+ ## Info.plist additions needed to add photos to Camera Roll for iOS
22
+ ## (Saving to CameraRoll only works for iOS currently):
23
+ ```javascript
60
24
  <key>NSPhotoLibraryAddUsageDescription</key>
61
25
  <string>We allow you to save photos into your media library that were taken within the app.</string>
62
26
  <key>NSPhotoLibraryUsageDescription</key>
63
27
  <string>We access your media library to let you upload pictures you already took to your appointments.</string>
64
28
  ```
65
29
 
66
- ## Library Usage 1 - AddImages with AddImagesProvider
67
- ## How to use AddImagesProvider
68
-
69
- Wrap `AddImagesProvider` around the highest React subtree that the image picker needs to cover.
70
-
71
- That is the key rule.
72
-
73
- Examples:
74
30
 
75
- - normal screen: wrap the screen root
76
- - tabbed screen: wrap the tab container, not just the tab body
77
- - modal or sheet: wrap the modal or sheet content tree itself
78
- - bottom modal inside another screen: wrap inside that bottom modal host, not only at app root
79
-
80
- Do not assume a single provider in `App.js` is always enough. If `AddImages` is used inside a modal or sheet, an app-root provider can render behind that host instead of above it.
81
-
82
- Multiple providers in different parts of the app are acceptable when `AddImages` is used in different host layers.
83
-
84
- ## How to choose the correct provider location
85
-
86
- Start at the `AddImages` call site and walk up the render tree.
87
-
88
- Place the provider around the component that owns the highest piece of UI that should be hidden behind the picker.
89
-
90
- ### Signs the provider is too low
91
-
92
- - the picker is clipped to a smaller area
93
- - headers or tabs are still visible above it
94
- - part of the current screen remains tappable
95
-
96
- ### Signs the provider is too high or outside the wrong host
97
-
98
- - the picker renders behind a modal or sheet
99
- - touches go to the underlying modal instead of the picker
100
-
101
- ## Basic screen example
102
-
103
- Use this pattern when `AddImages` is launched from a normal full-screen page.
31
+ ## Usage - JSX Component Examples
32
+ There are 3 pieces to this library, of which one or more can be used.
104
33
 
34
+ 1: AddImages - used to easily add a button/icon/link to your app that allows you to select multiple images, with custom titles and descriptions, per image. This option eliminatres the need to use the Multi-ImagePicker option below.
105
35
  ```javascript
106
- import React from 'react'
107
- import { View } from 'react-native'
108
- import { AddImages, AddImagesProvider } from '@supportworks/Multi-ImagePicker'
109
-
110
- const ProjectScreen = ({ Project, Api }) => {
111
- const onImagesAdded = () => {
112
- // refresh screen state after attach
113
- }
114
-
115
- return (
116
- <AddImagesProvider>
117
- <View style={{ flex: 1 }}>
118
- <Header />
119
- <Content />
36
+ onImagesAdded() {
37
+ //callback from MultiImagePicker, after images added
38
+ let cRef = this;
120
39
 
121
- <AddImages
122
- parentStyle={styles.AddPhoto}
123
- prospectInst={Project}
124
- addPicture={Api.addOnePictureToProject}
125
- callback={onImagesAdded}
126
- >
127
- <CameraButton />
128
- </AddImages>
129
- </View>
130
- </AddImagesProvider>
131
- )
40
+ if (cRef.props.callback) {
41
+ cRef.props.callback("photos added");
42
+ }
43
+ }
44
+
45
+ render() {
46
+ ...
47
+ <AddImages parentStyle={styles.AddPhoto} prospectInst={Project} addPicture={Api.addOnePictureToProject} callback={cRef.onImagesAdded}>
48
+ <View style={styles.AddPhotoIcon}>
49
+ <Icons.IconCameraFill width="24" height="24" fill={colors.blue} fillOpacity="1" />
50
+ </View>
51
+ </AddImages>
52
+ ...
132
53
  }
133
54
  ```
134
-
135
- ## Modal or sheet example
136
-
137
- Use this pattern when `AddImages` is launched from inside a bottom sheet or modal-like container.
138
-
139
- If the underlying modal chrome is still visible at the top, set `sheetTopInset={0}`.
140
-
141
- ```javascript
142
- import React from 'react'
143
- import { AddImagesProvider } from '@supportworks/Multi-ImagePicker'
144
- import SwipeModal from '@supportworks/core-controls/src/SwipeModal'
145
-
146
- const SheetAddImagesProvider = ({ children }) => (
147
- <AddImagesProvider sheetTopInset={0}>
148
- {children}
149
- </AddImagesProvider>
150
- )
151
-
152
- const MyScreen = () => (
153
- <SwipeModal
154
- contentWrapper={SheetAddImagesProvider}
155
- visible={showBottomModal}
156
- close={closeBottomModal}
157
- >
158
- <BottomModalContent />
159
- </SwipeModal>
160
- )
161
- ```
162
-
163
- ## AddImages props
164
-
165
- `AddImages` is still the main trigger component. Common props include:
166
-
167
- - `parentStyle`: style passed to `MultiImagePicker`
168
- - `prospectInst`: project/appointment instance passed back to `addPicture`
169
- - `addPicture`: async handler for saving one image
170
- - `callback`: called after images are attached
171
- - `hitSlop`: passed to the picker trigger
172
- - `allowEdit`: whether filenames/descriptions can be edited
173
- - `annotationAllowed`: whether annotations are allowed
174
- - `showToCustomerAllowed`: whether "show to customer" is available
175
- - `maxCount`: max images selectable
176
- - `children`: the button/icon/link users tap to open the picker
177
-
178
- ## Troubleshooting
179
-
180
- ### The picker is not full screen
181
-
182
- The provider is probably too low in the tree.
183
-
184
- Move `AddImagesProvider` higher, around the component that owns the header/tabs/navigation you want covered.
185
-
186
- ### The picker appears behind a modal or sheet
187
-
188
- The provider is probably outside the modal or sheet host.
189
-
190
- Move the provider inside that modal or sheet content tree.
191
-
192
- ### The top of the old modal is still visible
193
-
194
- Use:
195
-
196
- ```javascript
197
- <AddImagesProvider sheetTopInset={0}>
198
- ```
199
-
200
- This is useful when the picker is hosted inside an existing modal or bottom-sheet style container and should fully cover that host.
201
-
202
- ## ChatGPT / implementation prompt
203
-
204
- This section is intentionally written so it can be pasted into a ChatGPT or Codex prompt when integrating `AddImages` into an app.
205
-
206
- ```txt
207
- The Multi-ImagePicker library uses AddImagesProvider and AddImages.
208
-
209
- AddImages is only the trigger/controller. It does not use a native Modal to present itself.
210
- AddImagesProvider is the overlay host that renders the full-screen picker UI.
211
-
212
- When integrating AddImages:
213
- 1. Find every AddImages call site.
214
- 2. Trace the render tree upward from each call site.
215
- 3. Place AddImagesProvider around the highest React subtree that the picker needs to cover.
216
- 4. If AddImages is used inside a modal, bottom sheet, SwipeModal, react-native-modal, or other sheet host, place AddImagesProvider inside that host's content tree, not only at app root.
217
- 5. If the picker is clipped or headers/tabs still show above it, the provider is too low.
218
- 6. If the picker renders behind a modal or sheet, the provider is outside the correct host.
219
- 7. If the underlying modal chrome is still visible at the top, use AddImagesProvider with sheetTopInset={0}.
220
-
221
- Use AddImages + AddImagesProvider as the default integration path. Only use MultiImagePicker or SelectedImages directly when custom flow control is required.
222
- ```
223
-
224
- ## Library Usage 2 - MultiImagePicker
225
- `MultiImagePicker` allows you to select multiple images and return the results in arrays.
226
- The child you include (AddButton in this example) should display an icon that will be touched to open the picker.
227
- Note that your child component will be wrapped with a TouchableOpacity component, so any props you supply for
228
- MultiImagePicker will be passed to that TouchableOpacity component.
229
-
55
+ 2: Multi-Image Picker - this allows you to select multiple images and return the results in arrays. The child you include (AddButton in this example) should display an icon that will be touched to open the picker. Note that your child component will be wrapped with a TouchableOpacity component, so any props you supply for MultiImagePicker will be passed to that TouchableOpacity component.
230
56
  ```javascript
231
57
  onImageSelect(payload) {
232
58
  //handle return of selected images from MultiImagePicker
@@ -248,25 +74,23 @@ render() {
248
74
  ...
249
75
  }
250
76
  ```
251
-
252
-
253
- ## Library Usage 3 - SelectedImages
254
- `SelectedImages` allows you to display the images that were selected, before saving them, so you can edit their titles and descriptions.
255
-
77
+ 3: Selected Image component - this allows you to display the images that were selected, before saving them, so you can edit their titles and descriptions.
256
78
  ```javascript
257
-
258
- onItemChange (idx, patch) {
259
- this.setState((prevState) => {
260
- const items = prevState.items.map((item, i) => (i === idx ? {...item, ...patch} : item))
261
- const allValid = items.every(it => it?.isValid !== false)
262
- return {items, allImageDataValid: allValid}
263
- })
79
+ setAllImageDataValid(allValid) {
80
+ //handle return of selected images from MultiImagePicker <SelectedImages>
81
+ //payload expected: (boolean) true if all selected images are valid, false otherwise
82
+ let cRef = this;
83
+ let initAllValid = cRef.state.allImageDataValid;
84
+ if (allValid !== initAllValid) {
85
+ //need to set state since overall validity flipped
86
+ cRef.setState({allImageDataValid: allValid});
87
+ }
264
88
  }
265
-
89
+
266
90
  render() {
267
91
  ...
268
92
  <KeyboardAwareScrollView>
269
- <SelectedImages items={cRef.state.items} onItemChange={cRef.onItemChange}/>
93
+ <SelectedImages imgArr={cRef.imgArr} imgDescArr={cRef.imgDescArr} imgValidArr={cRef.imgValidArr} callback={cRef.setAllImageDataValid}/>
270
94
  </KeyboardAwareScrollView>
271
95
  ...
272
96
  }
package/TestMIP.js ADDED
@@ -0,0 +1,103 @@
1
+ import React from 'react'
2
+ import { Text, View, StyleSheet } from 'react-native'
3
+ import AddImages from './src/components/AddImages'
4
+ // import { AddImages as AddImagesOLD } from '../../../../node_modules/@supportworks/multi-imagepicker/index'
5
+ import Project from '../../../lib/Project'
6
+ import { SafeAreaView } from 'react-native-safe-area-context'
7
+ import { CommonButton } from '@supportworks/core-controls'
8
+ import { MultiImagePicker } from './index'
9
+ import { colors } from '@supportworks/app-styler'
10
+ import AsyncStorage from '@react-native-async-storage/async-storage'
11
+
12
+ export class TestMIP extends React.Component {
13
+ constructor (props) {
14
+ super(props)
15
+ this.onImagesAddedAI = this.onImagesAddedAI.bind(this)
16
+ this.onImagesAddedMIP = this.onImagesAddedMIP.bind(this)
17
+ this.addOnePictureToProject = this.addOnePictureToProject.bind(this)
18
+ }
19
+
20
+ triggerAction () {
21
+ this.addImages.triggerAction()
22
+ }
23
+
24
+ /* triggerActionOLD () {
25
+ this.addImagesOLD.triggerAction()
26
+ } */
27
+
28
+ onImagesAddedAI () {
29
+ // callback from AddImages, after images added
30
+ const cRef = this
31
+ }
32
+
33
+ addOnePictureToProject (imgObj, description, prospect) {
34
+ console.log('-----TestMIP addOnePictureToProject, imgObj: ' + JSON.stringify(imgObj))
35
+ console.log('-----TestMIP addOnePictureToProject, description: ' + description)
36
+ }
37
+
38
+ onImagesAddedMIP (payload) {
39
+ // callback from MultiImagePicker, after images added
40
+ const cRef = this
41
+
42
+ const imgArr = payload.imageArray
43
+ const imgDescArr = payload.imageDescArray
44
+ const imgValidArr = payload.imageValidArray
45
+ console.log('-----TestMIP onImagesAddedMIP: ' + JSON.stringify(payload))
46
+ }
47
+
48
+ render () {
49
+ const cRef = this
50
+
51
+ return (
52
+ <SafeAreaView>
53
+ <View style={{ padding: 16 }}>
54
+ <CommonButton variant='filled' size='large' label='Open Multi Image Picker - AddImages' onPress={() => cRef.triggerAction()} />
55
+ </View>
56
+ <AddImages
57
+ ref={o => cRef.addImages = o} prospectInst={Project} callback={cRef.onImagesAddedAI}
58
+ annotationAllowed
59
+ showToCustomerAllowed
60
+ addPicture={(imgObj, description, prospect) => cRef.addOnePictureToProject(imgObj, description, null)}
61
+ />
62
+
63
+ <MultiImagePicker callback={cRef.onImagesAddedMIP}>
64
+ <View style={styles.MIP}>
65
+ <Text style={{ color: 'white' }}>Open Multi Image Picker - MultiImagePicker</Text>
66
+ </View>
67
+ </MultiImagePicker>
68
+
69
+ <View style={{ padding: 16 }}>
70
+ <CommonButton variant='filled' size='large' label='Reset CRM Dialog Flag' onPress={async () => await AsyncStorage.removeItem('@MIP_UploadWarningsModal_Skip')} />
71
+ </View>
72
+
73
+ <View style={{ padding: 16 }}>
74
+ <CommonButton variant='filled' size='large' label='Reset ShowToCust Flag' onPress={async () => await AsyncStorage.removeItem('@MIP_ShowToCustomer')} />
75
+ </View>
76
+
77
+ {/* <View style={{ padding: 16 }}>
78
+ <CommonButton variant='filled' size='large' label='Open Multi Image Picker - AddImages OLD' onPress={() => cRef.triggerActionOLD()} color={'secondary'} />
79
+ </View>
80
+ <AddImagesOLD
81
+ ref={o => cRef.addImagesOLD = o} prospectInst={Project} callback={cRef.onImagesAddedAI}
82
+ annotationAllowed
83
+ showToCustomerAllowed
84
+ addPicture={(imgObj, description, prospect) => cRef.addOnePictureToProject(imgObj, description, null)}
85
+ /> */}
86
+ </SafeAreaView>
87
+ )
88
+ }
89
+ }
90
+
91
+ const styles = StyleSheet.create({
92
+ MIP: {
93
+ flexDirection: 'row',
94
+ alignItems: 'center',
95
+ justifyContent: 'center',
96
+ padding: 16,
97
+ backgroundColor: colors.buttonPrimary,
98
+ borderRadius: 16,
99
+ margin: 16
100
+ }
101
+ })
102
+
103
+ export default TestMIP
package/changes.md CHANGED
@@ -1,24 +1,12 @@
1
1
 
2
- # NOTE: v7 is only for non-expo react-native apps since v8 has CameraModal which is for expo only
3
-
4
- # v7.3.2 2026-04-27
5
- * SYNCED UP WITH V8, EXCEPT CAMERAMODAL STUFF SINCE THAT IS FOR EXPO ONLY
6
- * removed handlebar from AddImagesProvider since we want to force full screen
7
-
8
- # v7.3.1 2026-04-21
9
- * SYNCED UP WITH V8, EXCEPT CAMERAMODAL STUFF SINCE THAT IS FOR EXPO ONLY
10
- * added AddImagesProvider, required to wrap AddImages. Updated AddImages to use context from that provider.
11
- * updated ReadMe with explanation and AI prompt to use to implement AddImages elsewhere in apps
12
- * changed UploadWarningModal to just be a regular component instead of a modal, to fix multiple nested modals issue on older iPads
13
-
14
- # v7.0.7 2026-01-22
15
- * replaced deprecated SafeAreaViews
2
+ # v8.0.0 2025-11-21
3
+ * added CameraModal for ios
4
+ * this version should only be used for RN 0.82+
16
5
 
17
6
  # v7.0.0 2025-11-21
18
7
  * converted components to functional components
19
8
  * made significant UI updates based on DEV-7191 (Photos To Add)
20
9
  * this version likely only useful for RN <= 0.72 due to SafeAreaView changes later
21
- * plus, this v7 does not have the CameraModal that v8 has, so can't use that in RN 72, non-expo apps
22
10
 
23
11
  # v6.0.0 2025-06-08
24
12
  * removed runtime permissions request for android photos and videos, as necessary for Google Play Store compliance
package/index.js CHANGED
@@ -5,15 +5,15 @@ import MIPickerApi from './src/lib/MIPickerApi'
5
5
  import ImageIndicators from './src/components/ImageIndicators'
6
6
  import ActionBar from './src/components/ActionBar'
7
7
  import ImageDetailsModal from './src/components/ImageDetailsModal'
8
- import AddImagesProvider from './src/components/AddImagesProvider'
8
+ import CameraModal from './src/components/CameraModal'
9
9
 
10
10
  export {
11
11
  MultiImagePicker,
12
12
  SelectedImages,
13
13
  AddImages,
14
- AddImagesProvider,
15
14
  MIPickerApi,
16
15
  ImageIndicators,
17
16
  ActionBar,
18
- ImageDetailsModal
17
+ ImageDetailsModal,
18
+ CameraModal
19
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supportworks/multi-imagepicker",
3
- "version": "7.3.2",
3
+ "version": "8.0.0",
4
4
  "description": "Android and iOS customized multiple image picker. For react-native >= 0.60.",
5
5
  "main": "index.js",
6
6
  "author": {
@@ -33,12 +33,12 @@ const ActionBar = (
33
33
  {false && <TouchableOpacity style={styles.IconContainer} onPress={onPressDetails}>
34
34
  <Icons.IconArrowRightTop />
35
35
  </TouchableOpacity>}
36
- <TouchableOpacity style={[styles.IconContainer, (!allowSaveToDevice && !annotationAllowed && !allowShowToCustomer) ? styles.IconContainerLast : null]} onPress={onPressDetails}>
36
+ <TouchableOpacity style={styles.IconContainer} onPress={onPressDetails}>
37
37
  <Icons.IconNotesWrite />
38
38
  </TouchableOpacity>
39
39
  {allowSaveToDevice && (
40
40
  <TouchableOpacity
41
- style={[styles.IconContainer, (!annotationAllowed && !allowShowToCustomer) ? styles.IconContainerLast : null]}
41
+ style={styles.IconContainer}
42
42
  onPress={onToggleSaveToDevice}
43
43
  >
44
44
  {saveToDevice
@@ -47,7 +47,7 @@ const ActionBar = (
47
47
  </TouchableOpacity>
48
48
  )}
49
49
  {annotationAllowed && (
50
- <TouchableOpacity style={[styles.IconContainer, !allowShowToCustomer ? styles.IconContainerLast : null]} onPress={onAnnotate}>
50
+ <TouchableOpacity style={styles.IconContainer} onPress={onAnnotate}>
51
51
  <Icons.IconAnnotate />
52
52
  </TouchableOpacity>
53
53
  )}