Commit 7068222
authored
chore: customizability of context menu (#3558)
## 🎯 Goal
This PR introduces a `MessageOverlayWrapper` component so that
integrations can pick which part of the `Message` they want to move to
the contextual menu. The component handles all bookkeeping on its own
and makes sure that a single measurement source (target) is active at a
time.
It comes paired with a `messageOverlayTargetId` for the simple purpose
of performance (self registration would work as well here, however I did
notice that sometimes 2 layout passes had to be done before registration
could be finished, in order for the other portals to unmount - causing a
nasty remount on the first render and so this guards against that).
Usage:
```
import { MessageContent as DefaultMessageContent } from 'stream-chat-react-native';
// ...
const OverlayTargetedMessageContent = (
props: React.ComponentProps<typeof DefaultMessageContent>,
) => (
<MessageOverlayWrapper targetId='message-content'>
<DefaultMessageContent {...props} />
</MessageOverlayWrapper>
);
// ...
<WithComponents overrides={{ MessageContent: OverlayTargetedMessageContent }}>
<Channel
{...otherProps}
messageOverlayTargetId='message-content'
>
{/* channel children */}
</Channel>
</WithComponents>
```
## 🛠 Implementation details
<!-- Provide a description of the implementation -->
## 🎨 UI Changes
<!-- Add relevant screenshots -->
<details>
<summary>iOS</summary>
<table>
<thead>
<tr>
<td>Before</td>
<td>After</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<!--<img src="" /> -->
</td>
<td>
<!--<img src="" /> -->
</td>
</tr>
</tbody>
</table>
</details>
<details>
<summary>Android</summary>
<table>
<thead>
<tr>
<td>Before</td>
<td>After</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<!--<img src="" /> -->
</td>
<td>
<!--<img src="" /> -->
</td>
</tr>
</tbody>
</table>
</details>
## 🧪 Testing
<!-- Explain how this change can be tested (or why it can't be tested)
-->
## ☑️ Checklist
- [ ] I have signed the [Stream
CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform)
(required)
- [ ] PR targets the `develop` branch
- [ ] Documentation is updated
- [ ] New code is tested in main example apps, including all possible
scenarios
- [ ] SampleApp iOS and Android
- [ ] Expo iOS and Android1 parent 4e97097 commit 7068222
File tree
16 files changed
+393
-102
lines changed- examples/SampleApp
- ios
- package/src
- components
- Channel
- hooks
- Message
- MessageItemView/__tests__
- hooks
- __tests__
- Thread/__tests__/__snapshots__
- contexts
- messageContext
- messagesContext
16 files changed
+393
-102
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3327 | 3327 | | |
3328 | 3328 | | |
3329 | 3329 | | |
3330 | | - | |
| 3330 | + | |
3331 | 3331 | | |
3332 | 3332 | | |
3333 | 3333 | | |
| |||
3354 | 3354 | | |
3355 | 3355 | | |
3356 | 3356 | | |
3357 | | - | |
| 3357 | + | |
3358 | 3358 | | |
3359 | | - | |
| 3359 | + | |
3360 | 3360 | | |
3361 | 3361 | | |
3362 | 3362 | | |
| |||
3827 | 3827 | | |
3828 | 3828 | | |
3829 | 3829 | | |
3830 | | - | |
| 3830 | + | |
3831 | 3831 | | |
3832 | 3832 | | |
3833 | 3833 | | |
| |||
3836 | 3836 | | |
3837 | 3837 | | |
3838 | 3838 | | |
3839 | | - | |
| 3839 | + | |
3840 | 3840 | | |
3841 | 3841 | | |
3842 | 3842 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7674 | 7674 | | |
7675 | 7675 | | |
7676 | 7676 | | |
7677 | | - | |
7678 | | - | |
7679 | | - | |
7680 | | - | |
| 7677 | + | |
| 7678 | + | |
| 7679 | + | |
| 7680 | + | |
7681 | 7681 | | |
7682 | 7682 | | |
7683 | 7683 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| 264 | + | |
264 | 265 | | |
265 | 266 | | |
266 | 267 | | |
| |||
464 | 465 | | |
465 | 466 | | |
466 | 467 | | |
| 468 | + | |
467 | 469 | | |
468 | 470 | | |
469 | 471 | | |
| |||
1665 | 1667 | | |
1666 | 1668 | | |
1667 | 1669 | | |
| 1670 | + | |
1668 | 1671 | | |
1669 | 1672 | | |
1670 | 1673 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
| 104 | + | |
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
| |||
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
| 132 | + | |
130 | 133 | | |
131 | 134 | | |
132 | 135 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
39 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
40 | 46 | | |
41 | 47 | | |
42 | 48 | | |
| |||
207 | 213 | | |
208 | 214 | | |
209 | 215 | | |
| 216 | + | |
210 | 217 | | |
211 | 218 | | |
212 | 219 | | |
| |||
278 | 285 | | |
279 | 286 | | |
280 | 287 | | |
| 288 | + | |
281 | 289 | | |
282 | 290 | | |
283 | 291 | | |
| |||
323 | 331 | | |
324 | 332 | | |
325 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
326 | 343 | | |
327 | 344 | | |
328 | 345 | | |
329 | 346 | | |
330 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
331 | 356 | | |
332 | 357 | | |
333 | 358 | | |
| |||
655 | 680 | | |
656 | 681 | | |
657 | 682 | | |
658 | | - | |
659 | | - | |
660 | 683 | | |
661 | 684 | | |
662 | 685 | | |
| |||
771 | 794 | | |
772 | 795 | | |
773 | 796 | | |
| 797 | + | |
| 798 | + | |
774 | 799 | | |
775 | 800 | | |
776 | 801 | | |
| |||
781 | 806 | | |
782 | 807 | | |
783 | 808 | | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
784 | 817 | | |
785 | 818 | | |
786 | 819 | | |
| |||
817 | 850 | | |
818 | 851 | | |
819 | 852 | | |
820 | | - | |
821 | | - | |
822 | | - | |
823 | | - | |
824 | | - | |
825 | | - | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
836 | | - | |
837 | | - | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | | - | |
842 | | - | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
858 | | - | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
859 | 881 | | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
875 | | - | |
876 | | - | |
877 | | - | |
878 | | - | |
879 | | - | |
880 | | - | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | | - | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
887 | 889 | | |
888 | | - | |
889 | | - | |
| 890 | + | |
| 891 | + | |
890 | 892 | | |
891 | | - | |
892 | | - | |
893 | | - | |
894 | | - | |
895 | | - | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
896 | 921 | | |
897 | 922 | | |
898 | 923 | | |
| |||
905 | 930 | | |
906 | 931 | | |
907 | 932 | | |
| 933 | + | |
908 | 934 | | |
909 | 935 | | |
910 | 936 | | |
| |||
918 | 944 | | |
919 | 945 | | |
920 | 946 | | |
| 947 | + | |
921 | 948 | | |
922 | 949 | | |
923 | 950 | | |
| |||
958 | 985 | | |
959 | 986 | | |
960 | 987 | | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
961 | 993 | | |
962 | 994 | | |
963 | 995 | | |
| |||
0 commit comments