Commit e61c05c
authored
feat: native image picker rework (#3398)
This pull request introduces extensive updates to the attachment picker
functionality, focusing on adding a new `disableAttachmentPicker` mode.
When enabled, this mode bypasses the custom attachment picker UI and
instead uses native pickers or alternate flows for attachments and
commands. The changes also include several refactorings to ensure that
button behavior, UI rendering, and command handling adapt correctly to
this new mode, as well as minor improvements to styles and performance.
**Attachment Picker Disable Mode and UI Adaptation:**
* Added `disableAttachmentPicker` support throughout the attachment
picker and its context, defaulting to true if the image media library is
unavailable. This flag is now used to conditionally render the custom
picker UI and to switch to native pickers or alternate flows for
attachments, commands, and polls.
(`package/src/components/Channel/Channel.tsx`
[[1]](diffhunk://#diff-f7139f4cdb523365cfc277d72b827a3432325b9c6460cf14628f9df67d0e4d85R544)
[[2]](diffhunk://#diff-f7139f4cdb523365cfc277d72b827a3432325b9c6460cf14628f9df67d0e4d85L555-R556)
[[3]](diffhunk://#diff-f7139f4cdb523365cfc277d72b827a3432325b9c6460cf14628f9df67d0e4d85L2047-R2047);
`package/src/components/AttachmentPicker/AttachmentPicker.tsx`
[[4]](diffhunk://#diff-509e397cee3ad5197cf9a2710f06f9cbd3d2e586f6c23ea908bf95f3ab576161R39)
[[5]](diffhunk://#diff-509e397cee3ad5197cf9a2710f06f9cbd3d2e586f6c23ea908bf95f3ab576161R125-R129);
`package/src/components/AttachmentPicker/components/AttachmentTypePickerButton.tsx`
[[6]](diffhunk://#diff-c006c56f76295b093e39458e91083b0e0fc85cf255507c867cf2d1a6fac971c1R40-R46)
[[7]](diffhunk://#diff-c006c56f76295b093e39458e91083b0e0fc85cf255507c867cf2d1a6fac971c1L54-R73)
[[8]](diffhunk://#diff-c006c56f76295b093e39458e91083b0e0fc85cf255507c867cf2d1a6fac971c1L79-R105)
[[9]](diffhunk://#diff-c006c56f76295b093e39458e91083b0e0fc85cf255507c867cf2d1a6fac971c1L112-R136)
[[10]](diffhunk://#diff-c006c56f76295b093e39458e91083b0e0fc85cf255507c867cf2d1a6fac971c1L133-R151)
[[11]](diffhunk://#diff-c006c56f76295b093e39458e91083b0e0fc85cf255507c867cf2d1a6fac971c1R161-R163)
[[12]](diffhunk://#diff-c006c56f76295b093e39458e91083b0e0fc85cf255507c867cf2d1a6fac971c1R178-R206)
* Refactored all attachment picker buttons (`MediaPickerButton`,
`CameraPickerButton`, `FilePickerButton`, `PollPickerButton`,
`CommandsPickerButton`) to respect the `disableAttachmentPicker` flag,
invoking native pickers or alternate flows as appropriate.
(`package/src/components/AttachmentPicker/components/AttachmentTypePickerButton.tsx`
[[1]](diffhunk://#diff-c006c56f76295b093e39458e91083b0e0fc85cf255507c867cf2d1a6fac971c1L79-R105)
[[2]](diffhunk://#diff-c006c56f76295b093e39458e91083b0e0fc85cf255507c867cf2d1a6fac971c1L112-R136)
[[3]](diffhunk://#diff-c006c56f76295b093e39458e91083b0e0fc85cf255507c867cf2d1a6fac971c1L133-R151)
[[4]](diffhunk://#diff-c006c56f76295b093e39458e91083b0e0fc85cf255507c867cf2d1a6fac971c1R161-R163)
[[5]](diffhunk://#diff-c006c56f76295b093e39458e91083b0e0fc85cf255507c867cf2d1a6fac971c1R178-R206)
**Command Picker and Sheet Handling:**
* Updated the command picker logic to provide a bottom sheet modal for
commands when the attachment picker is disabled, and adjusted command
item press handling to close the sheet and focus the input.
(`package/src/components/AttachmentPicker/components/AttachmentTypePickerButton.tsx`
[[1]](diffhunk://#diff-c006c56f76295b093e39458e91083b0e0fc85cf255507c867cf2d1a6fac971c1R178-R206);
`package/src/components/AttachmentPicker/components/AttachmentPickerContent.tsx`
[[2]](diffhunk://#diff-dff257697e52bec2944a78a9987f720bd6c9950bed33d58dc6bbf46181ede85bL103-R164)
* Refactored command picker item components to separate UI and logic,
allowing for different behaviors based on the attachment picker mode.
(`package/src/components/AttachmentPicker/components/AttachmentPickerContent.tsx`
[package/src/components/AttachmentPicker/components/AttachmentPickerContent.tsxL103-R164](diffhunk://#diff-dff257697e52bec2944a78a9987f720bd6c9950bed33d58dc6bbf46181ede85bL103-R164))
**Component and Style Improvements:**
* Replaced usage of `BottomSheetFlatList` with `FlatList` in the command
picker for improved compatibility and performance.
(`package/src/components/AttachmentPicker/components/AttachmentPickerContent.tsx`
[[1]](diffhunk://#diff-dff257697e52bec2944a78a9987f720bd6c9950bed33d58dc6bbf46181ede85bL18)
[[2]](diffhunk://#diff-dff257697e52bec2944a78a9987f720bd6c9950bed33d58dc6bbf46181ede85bL172-R205)
* Improved style definitions for better readability and maintainability,
including minor fixes in selection bar and video attachment preview
styles.
(`examples/SampleApp/src/components/AttachmentPickerSelectionBar.tsx`
[[1]](diffhunk://#diff-57b9f4c03eb9f2df19ce1eea85d2cf0b7faf0a582365a328b58972f726bd9d15L51-R56);
`package/src/components/MessageInput/components/AttachmentPreview/VideoAttachmentUploadPreview.tsx`
[[2]](diffhunk://#diff-330a667985a8bee41fcea36cb15f6ea4e35014752a052048c464a36983386feeL84-R84)
[[3]](diffhunk://#diff-330a667985a8bee41fcea36cb15f6ea4e35014752a052048c464a36983386feeL104-R109)
**Other Notable Changes:**
* Increased the number of columns in the emoji reaction picker and
disabled virtualization to improve animation performance.
(`package/src/components/MessageMenu/MessageReactionPicker.tsx`
[package/src/components/MessageMenu/MessageReactionPicker.tsxL164-R171](diffhunk://#diff-6300d8032dafbd2a4ee021a951f2566d63ba247cefa8b50b75fdf5a7bc87e1f2L164-R171))
* Cleaned up redundant code related to the attachment picker toggle and
context usage.
(`package/src/components/MessageInput/components/InputButtons/AttachButton.tsx`
[[1]](diffhunk://#diff-decf71a1820966bd3433e3ba63c1a7a4c67f4dcecdd2bad18b6b5c39acd79cb8L25)
[[2]](diffhunk://#diff-decf71a1820966bd3433e3ba63c1a7a4c67f4dcecdd2bad18b6b5c39acd79cb8L44-L46)1 parent d3c5777 commit e61c05c
File tree
13 files changed
+377
-147
lines changed- examples/SampleApp/src/components
- package/src
- components
- AttachmentPicker
- components
- Channel
- MessageInput/components
- AttachmentPreview
- InputButtons
- MessageMenu
- UIComponents
- contexts
- __tests__
- bottomSheetContext
- icons
13 files changed
+377
-147
lines changedLines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
52 | 57 | | |
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| 93 | + | |
| 94 | + | |
92 | 95 | | |
93 | 96 | | |
94 | 97 | | |
| |||
97 | 100 | | |
98 | 101 | | |
99 | 102 | | |
100 | | - | |
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
| |||
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
123 | | - | |
124 | | - | |
125 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
126 | 130 | | |
127 | 131 | | |
128 | 132 | | |
| |||
Lines changed: 47 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
18 | | - | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| |||
100 | 103 | | |
101 | 104 | | |
102 | 105 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
108 | 113 | | |
109 | 114 | | |
110 | 115 | | |
111 | 116 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
130 | 163 | | |
131 | | - | |
| 164 | + | |
132 | 165 | | |
133 | 166 | | |
134 | 167 | | |
| |||
169 | 202 | | |
170 | 203 | | |
171 | 204 | | |
172 | | - | |
| 205 | + | |
173 | 206 | | |
174 | 207 | | |
175 | 208 | | |
| |||
Lines changed: 56 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| |||
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
42 | | - | |
| 46 | + | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
| |||
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
54 | | - | |
| 58 | + | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
60 | | - | |
61 | | - | |
| 64 | + | |
| 65 | + | |
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
65 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
66 | 74 | | |
67 | 75 | | |
68 | 76 | | |
| |||
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
79 | | - | |
| 87 | + | |
80 | 88 | | |
81 | 89 | | |
82 | | - | |
| 90 | + | |
83 | 91 | | |
84 | 92 | | |
85 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
86 | 98 | | |
87 | 99 | | |
88 | 100 | | |
89 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
90 | 106 | | |
91 | 107 | | |
92 | 108 | | |
| |||
109 | 125 | | |
110 | 126 | | |
111 | 127 | | |
112 | | - | |
| 128 | + | |
113 | 129 | | |
114 | 130 | | |
115 | 131 | | |
116 | 132 | | |
117 | 133 | | |
118 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
119 | 137 | | |
120 | 138 | | |
121 | 139 | | |
| |||
130 | 148 | | |
131 | 149 | | |
132 | 150 | | |
133 | | - | |
| 151 | + | |
134 | 152 | | |
135 | 153 | | |
136 | 154 | | |
| |||
140 | 158 | | |
141 | 159 | | |
142 | 160 | | |
143 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
144 | 164 | | |
145 | 165 | | |
146 | 166 | | |
| |||
155 | 175 | | |
156 | 176 | | |
157 | 177 | | |
| 178 | + | |
158 | 179 | | |
159 | | - | |
| 180 | + | |
160 | 181 | | |
161 | 182 | | |
162 | 183 | | |
163 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
164 | 189 | | |
165 | 190 | | |
| 191 | + | |
| 192 | + | |
166 | 193 | | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
173 | 207 | | |
174 | 208 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
541 | 541 | | |
542 | 542 | | |
543 | 543 | | |
| 544 | + | |
544 | 545 | | |
545 | 546 | | |
546 | 547 | | |
| |||
552 | 553 | | |
553 | 554 | | |
554 | 555 | | |
555 | | - | |
| 556 | + | |
556 | 557 | | |
557 | 558 | | |
558 | 559 | | |
| |||
583 | 584 | | |
584 | 585 | | |
585 | 586 | | |
586 | | - | |
587 | 587 | | |
588 | 588 | | |
589 | 589 | | |
| |||
2044 | 2044 | | |
2045 | 2045 | | |
2046 | 2046 | | |
2047 | | - | |
| 2047 | + | |
2048 | 2048 | | |
2049 | 2049 | | |
2050 | 2050 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
0 commit comments