V5 (#1222)
* chore(flutter): change BoxFit of VLC player * chore(flutter): remove unused imports * chore(flutter sample): tweak breakpoints, ignore some lints * chore(flutter): minor code readability improvements * chore(flutter): extract out platform_widget_builder to its own "package" * fix(flutter): fix a theme bug with PlatformDialog * chore(persistence): test plugin on macOS * Generated the macos runner for the example * Re-generated the android runner because it was using the v1 embedding * chore(persistence): test plugin on web * chore(persistence): add Windows runner to example * chore(persistence): add linux runner to example * feat(flutter): branded context menus * chore(flutter): fix bug where lines would be shown in between menu items * chore(flutter): import/export fixes * chore(flutter): move file * chore(flutter): /src/channel Also refactors several /channel widgets to use class widgets instead of methods. Some methods, however, have been left as those cases do actually produce cleaner code. chore(flutter): fix bad directory placement chore(flutter): fix bad directory placement * chore(flutter): more directory organization * chore(flutter): navigator improvements * chore(flutter): void async improvements * chore(flutter): fix imports/exports * docs(flutter): documentation updates for /attachment * docs(flutter): doc updates For: * /avatars * /bottom_sheets * /channel * feat(flutter): selectable message text on web & desktop * Squashed commit of the following: commit 50b249edb6b2ee2d744e4e00e97f81979026aab4 Author: GroovinChip <groovinchip@gmail.com> Date: Wed Mar 16 14:55:05 2022 -0400 chore(flutter): wrapping up docs commit 7d289ae45e20c0109bcdb4496f7b693e2adc4ef9 Author: GroovinChip <groovinchip@gmail.com> Date: Wed Mar 16 14:42:09 2022 -0400 chore(flutter): more docs & typedefs commit 6b36f6f3864f15b52e441d58ee7e62577ff8f843 Author: GroovinChip <groovinchip@gmail.com> Date: Wed Mar 16 14:22:34 2022 -0400 chore(flutter): more doc fixes commit 1a9a6de3c836e9ee5d6373033f1d9a7da830bddc Merge: 59188f5d 88abf99f Author: GroovinChip <groovinchip@gmail.com> Date: Wed Mar 16 13:17:52 2022 -0400 Merge branch 'desk_web_dev' into utils commit 59188f5d9c1dd68edd531086cdfd9d42faf93fc8 Author: GroovinChip <groovinchip@gmail.com> Date: Wed Mar 16 12:48:16 2022 -0400 chore(flutter): add todo commit 9b4a986ca5757f284677eb5335637d11ccb1d642 Author: GroovinChip <groovinchip@gmail.com> Date: Wed Mar 16 12:43:12 2022 -0400 chore(flutter): more docs and typedefs updates commit 8786d2dd82b94f673b36371fb2b33a1ebcc9840a Author: GroovinChip <groovinchip@gmail.com> Date: Wed Mar 16 12:14:14 2022 -0400 chore(flutter): more typedef and doc template updates commit 9e906beb0e7a054c13a32c8c8c5b0e2a9e27bb21 Author: GroovinChip <groovinchip@gmail.com> Date: Wed Mar 16 10:46:04 2022 -0400 chore(flutter): create /uitils and move files Fixes subsequent imports/exports * chore(flutter): update file_selector plugin * chore(flutter): include utils/typedefs.dart in library export * Squashed commit of the following: commit 501228afa614b0d740858dec1ebedd3f671e2c96 Author: GroovinChip <groovinchip@gmail.com> Date: Thu Mar 17 16:18:12 2022 -0400 feat(flutter): ensure fullscreen media feature works on ALL platforms commit cd0aab92bc7d90af03258829a5aae66125578af5 Author: GroovinChip <groovinchip@gmail.com> Date: Thu Mar 17 14:26:48 2022 -0400 feat(flutter): working conditional import for initializing VLC * fix(flutter): remove stray import causing web to break * chore(flutter): ensure context menus can show on web in sample * feat(flutter) FullScreenMedia context menus for Web * feat(flutter): branded context menus * chore(flutter): no success dialog on file download (web) * chore(flutter): remove platform UI packages * chore(flutter): properly show/hide delete message menu item Also deletes deprecated PlatformDialog * feat(flutter): 'view info' channel preview context menu * feat(flutter): more menu actions for ChannelPreview Also new ConfirmationDialog and add missing docs * feat(flutter/localizations): translations related to channel mutes * chore(flutter): remove prints and fix super.didChangeDependencies order * chore(flutter): rename some things in ChannelBottomSheet * chore(flutter): more sensible name in TypingIndicator * chore(flutter): remove unused code in MessageWidget * feat(flutter): ChannelInfoDialog * chore(flutter): organize files more Also refactors out some internal MessageListView widgets * fix(flutter): fix render overflow issue * chore(flutter): move MediaListView * chore(flutter): remove unused imports * fix(flutter): fix weird share menu placement on macos * chore(flutter): clean up fullscreenmedia conditional imports * chore(flutter): adjust package exports * chore(flutter): update dart_vlc * chore(flutter): clean up platform checks * chore(flutter): run flutter format on lib * chore(flutter): minor sample cleanup * chore(flutter): ensure vlc doesn't get initialized in non-desktop testing environments * test(flutter): reformat existing tests * fix(flutter): pass onThreadReplyTap down to ThreadReplyButton * First round of new tests commit a90bed427521123fdaa4c5e276744a224fac2b68 Author: GroovinChip <groovinchip@gmail.com> Date: Thu Apr 7 12:34:19 2022 -0400 test(flutter): Username test commit d7bc179c20eae2713c9248191518bf1d955104a9 Author: GroovinChip <groovinchip@gmail.com> Date: Thu Apr 7 12:30:47 2022 -0400 chore(flutter): remove unused imports commit 09c9517de2917dc5ccd7de019b50a7875386991c Author: GroovinChip <groovinchip@gmail.com> Date: Thu Apr 7 12:29:58 2022 -0400 test(flutter): ThreadSeparator test commit 9422d1129211aaaac9a51ca4d29fe94bde06593c Author: GroovinChip <groovinchip@gmail.com> Date: Thu Apr 7 12:19:43 2022 -0400 chore(flutter): rename LoadingIndicator parameter commit 63af943a1a16e78a1e0377d76176420bd7e1fbc7 Author: GroovinChip <groovinchip@gmail.com> Date: Thu Apr 7 11:47:46 2022 -0400 test(flutter): FloatingDateDivider test commit d8e67cf6fca2b76ac091a9047104c0910d5fdfef Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 15:19:39 2022 -0400 test(flutter): InputAttachment tests commit d2b7d5dd3304c8be6f74bf5b0281d7a95dd027ec Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 14:41:40 2022 -0400 test(flutter): DmCheckbox tests commit 01567f235a2f00880bb530b232489e3790159b25 Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 14:16:08 2022 -0400 chore(flutter): remove unused imports commit c9625858e840df6082506ae9374f1d2710053cbd Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 14:15:44 2022 -0400 test(flutter): CountdownButton tests commit d770474bb11ee8b36a3b0e18db31695fd812a6b3 Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 14:11:37 2022 -0400 test(flutter): CommandButton tests commit 95e63706d1dd971373d39d471894a38bb2a634f2 Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 14:07:43 2022 -0400 test(flutter): ClearInputItem tests commit 4156586945c91408cb7943b6c57c2ae560a2857c Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 14:03:59 2022 -0400 test(flutter): AttachmentButton tests commit bba042806326999aabf338636c6e33900de86160 Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 13:00:42 2022 -0400 test(flutter): golden test for SendButton commit e2cd0f00b9eeb8d81399f6316edb298234de12dc Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 12:56:52 2022 -0400 chore(flutter): deal with lints commit b4e045f9cbd54c4d42c3f30acfe72d5f8ccf9d82 Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 12:56:00 2022 -0400 test(flutter): SendButton test commit 4e3d5db0bddb97e508fcdda2e7272fe31e70808f Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 12:38:21 2022 -0400 test(flutter): KeyboardShortcutRunner tests commit 0dfd7a0bd6fd6bc76902e87f62ac29da0b01bac6 Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 12:17:30 2022 -0400 test(flutter): UploadProgressIndicator commit ec50c8aea716bdc19e4308e367c8331211c61ea3 Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 11:47:53 2022 -0400 test(flutter): SendingIndicator tests commit e87bd1450fb5bfb713a867c7e831968f76428848 Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 11:32:35 2022 -0400 test(flutter): more gallery tests commit 93d46ca649277fe6d289a70f0bdd23584fd0ab94 Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 11:17:29 2022 -0400 test(flutter): remove bad mock commit c7b03a39f0f3ca7a334dfb908f3473b5e4deab38 Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 10:45:45 2022 -0400 chore(flutter): minor refactor commit 33aeb7b5ed398287cb930f3b4702f47a82fce2c6 Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 09:49:07 2022 -0400 test(flutter): MessageDialog tests commit 220b3ae591e135d9606254666e04d4771945d0ae Author: GroovinChip <groovinchip@gmail.com> Date: Tue Mar 29 09:42:51 2022 -0400 test(flutter): DeleteMessageDialog tests commit db508478bb96749971f563de87b6c2a49e1e4e57 Author: GroovinChip <groovinchip@gmail.com> Date: Mon Mar 28 14:46:41 2022 -0400 test(flutter): ConfirmationDialog tests commit e8172dad6bfe18f40b65554ef2c6c16d7437cb56 Author: GroovinChip <groovinchip@gmail.com> Date: Mon Mar 28 14:35:50 2022 -0400 test(flutter): ChannelInfoDialog test commit 04c21458a601af3c3f4a5fc5ce9e8b61493c208c Author: GroovinChip <groovinchip@gmail.com> Date: Mon Mar 28 13:57:02 2022 -0400 test(flutter): DownloadMenuItem tests commit afee1dace543e2fef8543f9b035f684b2ee00f3b Author: GroovinChip <groovinchip@gmail.com> Date: Mon Mar 28 13:53:21 2022 -0400 test(flutter): StreamChatContextMenuItem tests commit 4616b1a973d0cf5224b5a71914c9908339c8462a Author: GroovinChip <groovinchip@gmail.com> Date: Mon Mar 28 13:02:07 2022 -0400 test(flutter): golden test for ErrorAlertSheet commit 22fb8241ae333f57ade8e8550f87695929836b2b Author: GroovinChip <groovinchip@gmail.com> Date: Mon Mar 28 12:59:01 2022 -0400 test(flutter): golden test for EditMessageSheet commit 0be79964827f344ba66e99cb9e5bd3d627aed01d Author: GroovinChip <groovinchip@gmail.com> Date: Mon Mar 28 12:56:08 2022 -0400 test(flutter): golden test for AttachmentModalSheet commit 0ae842a98143478885bc211c788353c8bca57b40 Author: GroovinChip <groovinchip@gmail.com> Date: Mon Mar 28 12:53:26 2022 -0400 test(flutter): GroupAvatar tests commit 697d294c6c7e1bba1d9089a53d5c60d8609ea64e Author: GroovinChip <groovinchip@gmail.com> Date: Mon Mar 28 12:30:25 2022 -0400 test(flutter): UserAvatar tests commit c03ba4124068c83d3a49c4db00ca18a659801c23 Author: GroovinChip <groovinchip@gmail.com> Date: Mon Mar 28 11:04:55 2022 -0400 test(flutter): ErrorAlertSheet test commit 3414f28530b0e22614b83af20361f21dd4967fae Author: GroovinChip <groovinchip@gmail.com> Date: Mon Mar 28 10:45:37 2022 -0400 test(flutter): EditMessageSheet test commit b2962b641dfbf14c11d3da7f80a4be27f9980d90 Author: GroovinChip <groovinchip@gmail.com> Date: Mon Mar 28 10:37:18 2022 -0400 test(flutter): AttachmentModalSheet test test(flutter): AttachmentModalSheet test chore(flutter): update exports commit 7d7e278692c65dea84e7ef3b2d3c1311ebb28408 Author: GroovinChip <groovinchip@gmail.com> Date: Mon Mar 28 09:52:29 2022 -0400 test(flutter): more organization commit 4479b649835acc62d8a0553f9505a0af8077abfc Author: GroovinChip <groovinchip@gmail.com> Date: Mon Mar 28 09:33:06 2022 -0400 test(flutter): tweak AttachmentHandler tests commit b4a41106567e3c08105ce8dc272b1ebf40b3b0bb Author: GroovinChip <groovinchip@gmail.com> Date: Mon Mar 28 09:24:00 2022 -0400 chore(flutter): streamline attachment handling * MobileAttachmentHandler for streamlining related code for mobile * Break out DesktopAttachmentHandler into its own file * Update minSdk version in Android runner commit bfb06d31b79cd941d8b611c7e89e2d7728a394cb Merge: a44b3b39 15c83d03 Author: GroovinChip <groovinchip@gmail.com> Date: Fri Mar 25 13:00:27 2022 -0400 Merge branch 'desk_web_dev' into tests commit a44b3b390adc25a00d1597bb1460973e8555fa9e Author: GroovinChip <groovinchip@gmail.com> Date: Fri Mar 25 12:59:14 2022 -0400 chore(flutter): start cleaning up test dir commit de104a3491d942d12f72dd66152b62c6e8b10a5b Author: GroovinChip <groovinchip@gmail.com> Date: Fri Mar 25 12:56:48 2022 -0400 test(flutter): VideoAttachment test commit 4748a1c081a3272f7fdbdeb69c501344e221e01e Author: GroovinChip <groovinchip@gmail.com> Date: Fri Mar 25 12:52:30 2022 -0400 test(flutter): UrlAttachment test commit 54408ef70f07c60adf8350553fdf3173e5edd7c7 Author: GroovinChip <groovinchip@gmail.com> Date: Fri Mar 25 12:48:24 2022 -0400 test(flutter): ImageGroup test commit 811cff069e490c6bd03be0c0ac2f5ec86fb990e9 Author: GroovinChip <groovinchip@gmail.com> Date: Fri Mar 25 12:46:04 2022 -0400 test(flutter): ImageAttachment test commit a72677976c6524e76793432b0520e99cac4e7a62 Author: GroovinChip <groovinchip@gmail.com> Date: Fri Mar 25 12:34:06 2022 -0400 test(flutter): GiphyAttachment test commit 32ddac022e2c149726b4b6607f41850d556055b8 Author: GroovinChip <groovinchip@gmail.com> Date: Fri Mar 25 12:28:01 2022 -0400 test(flutter): FileAttachment test commit 6534958cab775be1fb9bda56e67caa4746aa1502 Author: GroovinChip <groovinchip@gmail.com> Date: Fri Mar 25 12:14:25 2022 -0400 test(flutter): AttachmentError test commit 718a83c10c4e883ce01c9c002ced24de671d30b9 Author: GroovinChip <groovinchip@gmail.com> Date: Fri Mar 25 12:06:43 2022 -0400 test(flutter): AttachmentUploadStateBuilder test commit a05108c460e36b2e425e4ec06f8bf408b0c20e97 Author: GroovinChip <groovinchip@gmail.com> Date: Fri Mar 25 11:44:34 2022 -0400 chore(flutter): minor cleanup commit 6e73038ac3714a2bd96f8c587af7f743bf2b2023 Author: GroovinChip <groovinchip@gmail.com> Date: Fri Mar 25 11:43:23 2022 -0400 test(flutter): AttachmentTitle test commit c6ee52ec951877feef31dc1427eec3bfc2bd8fcb Author: GroovinChip <groovinchip@gmail.com> Date: Fri Mar 25 11:43:11 2022 -0400 test(flutter): minor cleanup commit 09845cd845aa8c546043f4ae04805a8e6f53f61c Author: GroovinChip <groovinchip@gmail.com> Date: Fri Mar 25 11:42:52 2022 -0400 chore(flutter): improve device segmentation & vlc init check commit 172e6b25a064b5147b7641f29ebff3c920156f70 Author: GroovinChip <groovinchip@gmail.com> Date: Fri Mar 25 10:37:43 2022 -0400 test(flutter): attachment_handler tests commit 5f5a91c70cd7c069f39518f1f50bb74ab484c7e9 Author: GroovinChip <groovinchip@gmail.com> Date: Wed Mar 23 13:55:27 2022 -0400 test(flutter): test PlatformWidgetBuilder & DesktopWidgetBuilder commit 5a457b7557cb4127b74ee022389a24e5e9150601 Author: GroovinChip <groovinchip@gmail.com> Date: Wed Mar 23 13:55:05 2022 -0400 chore(flutter): make base platform widgets testable Also fix environment check in stream_chat.dart commit 88fb16018103c581236aeebd978e705b223b2243 Author: GroovinChip <groovinchip@gmail.com> Date: Wed Mar 23 11:59:19 2022 -0400 chore(flutter): add readme to conditional_parent_widget library commit e9307f8a6a5639d59358c245f033f9d9b209fe20 Author: GroovinChip <groovinchip@gmail.com> Date: Wed Mar 23 11:54:54 2022 -0400 test(flutter): ConditionalParentBuilder tests * chore(flutter): add thumblr dependency * chore(flutter): fix typos * chore(flutter): properly order super calls * feat(flutter) video thumbnails on desktop * chore(flutter): fix incorrect file name * chore(flutter): fix docs for generateVideoThumbnail * chore(flutter): remove incorrect comment * chore(flutter): run flutter format * chore(flutter): ignore lint * chore(flutter): flutter format * chore(flutter): fix tests * fix(flutter): fix MessageListView bug caused by rebase * chore(flutter): migrate desktop stuff to v4/stream_message_input.dart * chore(flutter): migrate over desktop changes for message replies * chore(flutter): fix message replies on desktop * chore(flutter): address lints * chore(flutter): update dart_vlc * chore(flutter): melos clean & update photo_view * fix(ui): port #1118 * fix(ui): use attachmentButtonBuilder * fix(ui): fix file attachment * format * fix(ui): fix message bottom row * chore(flutter sample): use modern window look * chore(flutter): pass userAvatarBuilder through to MessageWidgetContent Also pass onUserAvatarTap & userAvatarBuilder through to UserAvatarTransform * chore: fix MessageWidget menu actions * fix(flutter): fix "enter" sending empty messages in StreamMessageInput * fix(flutter): fix Giphys not loading in quoted messages * chore(flutter): update thumblr * feat(flutter): keyboard navigation for gallery items * fix(ui): fix double date divider * fix(ui): add scroll to bottom back * fix(ui): use mouse region * fix(ui): remove backbutton in desktop example * fix(ui): rename full screen media widget * feat(flutter): elevation prop for gallery header * chore(flutter): update dart_vlc * fix(flutter): fix "show in chat" showing when it shouldn't * fix(flutter): fix "show in chat" for mobile * docs(flutter): minor doc update * chore(flutter): add onMessageSwiped in example app * chore(flutter): pass usernameBuilder through to BottomRow * fix(flutter): hacky fix for chonky link previews * fix(flutter): fix chonky text messages * feat(flutter): press "esc" to close gallery Also refactors KeyboardShortcutRunner API * chore(flutter): fix innaccurate name * fix(ui): fix attachment + long text sizing * add key to channelpage * fix(ui): better example * fix format * fix example * chore(flutter): revert modern window look * improvement(flutter): improve `GalleryNavigationItem` * Make buttons more visible * Spacing from the sides of the screen * fix video thumbnail * fix split view * fix(ui): fix giphy in thread * feat(flutter): desktop message reactions commit 4b880ecb6d4dcbf315a7d41d863174817a9c530a Author: Reuben Turner <groovinchip@gmail.com> Date: Thu Jun 9 12:25:21 2022 -0400 fix(flutter): fixes for desktop reactions * Fix reactions for reverse messages * Ensure reactions near the edges of MessageListView show properly commit f511513f8dbb272397e81d08bad33ee60108d738 Author: Salvatore Giordano <salvatoregiordanoo@gmail.com> Date: Thu Jun 9 16:43:03 2022 +0200 fix(ui): fix DesktopReactionBuilder and Portal commit c4885648330552f5212c5ba6b771c0f07023f6ae Merge: 2b710a2b 72b34c21 Author: Reuben Turner <groovinchip@gmail.com> Date: Wed Jun 8 14:12:44 2022 -0400 Merge branch 'desk_web_dev' into desktop_reactions commit 2b710a2bb610326123d5b7f75c26caa705114c9b Author: Reuben Turner <groovinchip@gmail.com> Date: Mon Jun 6 12:19:12 2022 -0400 chore(flutter): add debug props commit e24dabc1de12da8dce697b6d4e1a3617e9835549 Author: Reuben Turner <groovinchip@gmail.com> Date: Mon Jun 6 12:00:03 2022 -0400 feat(flutter): first pass at desktop reactions popup on mouse hover * fix(flutter): potential fix for #1199 * fix(flutter): fix non-reversed reactions placement * refactor(flutter): extract bottom reaction, stacked reaction with debug props * fix(flutter): fixes for desktop reactions * Fix bottom row being rendered above reaction buttons * Fix padding issues related to avatars * chore(flutter): add back lost changes from 2b1fb6a Also removed commented code * chore(flutter): stacked reactions update * Show "You" if userId matches the reaction username (per design) * Ensure long names don't throw off alignment * chore(flutter): format * fix(ui): fix mime type generation * chore(flutter): tweak desktop video * chore(flutter): add some missing things from develop * merge develop * fix merge * fix merge * format * fix tests * increate test action timeout * remove test * refactor(ui,core): remove deprecated code and cleanup * run builder * update coverage threasholds * refactor(ui): remove arrow function from countdown button * Update packages/stream_chat_flutter/lib/src/message_input/countdown_button.dart * Update packages/stream_chat_flutter/lib/src/message_input/countdown_button.dart * update comment * fix(ui): fix attachment + link solution * fix(ui): fix attachment + link solution * chore(flutter) update changelog and version * chore(localizations): update changelog and versions * chore(llc,core,ui,persistence,localizations): update changelog and pubspec * chore(llc,core,ui,persistence,localizations): update changelog and pubspec * fix example * fix deps * fix(ui): fix enter sending the message while in slowmode * fix(ui): fix reaction list * fix web * fix(ui): fix image download when using assetUrl * fix(ui): fix typo in changelog * fix(ui): fix gallery navigation * fix(ui): fix giphy sending size * fix(ui): add keyboard shorcuts to gallery view * fix(ui): fix gallery footer * fix(core): allow scroll notification bubbling in lazy load scroll view * fix(ui): fix lazy load scroll view * fix(ui): fix loading to unread position * fix(ui): fix last message preview * chore(ui): update changelog * fix tests * fix(llc): fix connecting while connecting and disconneting (#1237) * fix(llc): fix connecting while connecting and disconneting * chore(llc): update changelog * chore(llc): add test * chore(llc): improve test * fix(llc): _resetRequestFlags regardless of the connection status * feat(llc): add support for AttachmentFileUploaderProvider. (#1246) * feat(llc): add support for `AttachmentFileUploaderProvider`. Signed-off-by: xsahil03x <xdsahil@gmail.com> * chore(llc): update CHANGELOG.md Signed-off-by: xsahil03x <xdsahil@gmail.com> * refactor(llc): Remove deprecated attachmentFileUploader field. Signed-off-by: xsahil03x <xdsahil@gmail.com> * port no localization * fix(ui): fix jiffy locale initialization (#1255) * fix(ui): fix jiffy locale initialization * chore(ui): update changelog * fix(ui): cleanup * chore(llc,core,ui,persistence,localizations): align changelog * chore(llc,core,ui,persistence,localizations): add links to 4.x changelogs * fix(ui): fix date divider not showing (#1259) * fix(ui): fix date divider not showing * chore(ui): update changelog * chore(ui): minor changes Signed-off-by: xsahil03x <xdsahil@gmail.com> * fix(ui): fix separator Signed-off-by: xsahil03x <xdsahil@gmail.com> Co-authored-by: Sahil Kumar <xdsahil@gmail.com> * chore(ui): add contextmenu requirements for web (#1261) * fix unread separator * feat(ui): `StreamChatConfiguration` class (#1128) * feat: StreamChatConfiguration class See #1125 for more details * chore(flutter): update changelog * fix analysis * cleanup * feat(ui): add enforceUniqueReactions to `StreamChatConfiguration` widget * add tests * refactor(ui): rename StreamChatConfigurationProvider and StreamChatConfiguration * refactor(ui): rename StreamChat.config to streamChatConfigData * refactor(ui): make enforceUniqueReactions non nullable * chore(ui): fix analysis errors * refactor(ui): make config fields non nullable * chore(ui): format Co-authored-by: Salvatore Giordano <salvatoregiordanoo@gmail.com> * feat(ui, core): add StreamAutocomplete (#1263) * feat(ui, core): add stream_autocomplete.dart Signed-off-by: xsahil03x <xdsahil@gmail.com> * refactor(core, ui): refactor message input controller Signed-off-by: xsahil03x <xdsahil@gmail.com> * fix(ui): minor fixes Signed-off-by: xsahil03x <xdsahil@gmail.com> * feat(ui): add StreamAutocompleteOptions widget Signed-off-by: xsahil03x <xdsahil@gmail.com> * Update packages/stream_chat_flutter/lib/src/autocomplete/stream_autocomplete.dart * fix(ui): cleanup * chore(core, ui): cleanup Signed-off-by: xsahil03x <xdsahil@gmail.com> * chore(ui): ignore no empty block * chore(ui): more cleanup Signed-off-by: xsahil03x <xdsahil@gmail.com> * fix(ui): fix command button for bigger screens, other fixes. Signed-off-by: xsahil03x <xdsahil@gmail.com> Co-authored-by: Salvatore Giordano <salvatoregiordanoo@gmail.com> * fix(ui): increase default file limit to 100MB (#1279) * fix(ui): increase default file limit to 100MB * Update packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart * fix(ui): export kDefaultMaxAttachmentSize and use it in `StreamAttachmentPicker` default * feat(ui): show dialog after clicking on the camera button and permission is denied (#1262) * feat(ui): show dialog after clicking on the camera button and permission is denied * chore(ui): update changelog * Remove permission_handler plugin and refactor * cleanup * cleanup * add tests * fix(ui): reset the permission state on resume * cleanup * fix concurrent calls * fix(ui): cleanup * fix(ui): add try catch * fix(llc, ui): copy file to tempdir before uploading a file and do not serialize bytes (#1285) * fix(llc, ui): copy file to tempdir before uploading a file and do not serialize bytes * fix(llc): do not save failed messages with attachments on web * fix(llc): replace every with any * chore(llc): add test * fix analysis * fix analysis * chore(llc,core,ui,persistence): align changelog with v4 * fix(ui): do not linkify system message mentions * chore(llc,core,ui,persistence,localizations): update changelog and pubspec (#1289) * chore(ui): update deps * chore(llc,core,ui,persistence,localizations): update changelog and pubspec * chore(ui): publish beta.2 * feat(core,ui): add StreamMemberListView, StreamMemberGridView, and StreamMemberListController (#1291) * feat(core,ui): add StreamMemberListView, StreamMemberGridView, and StreamMemberListController * chore(core,ui): update changelog * fix(ui): fix exports * chore(ui): add tests * chore(ui): add StreamMemberGridTile typedef * chore(ui): minor changes Signed-off-by: xsahil03x <xdsahil@gmail.com> Co-authored-by: Sahil Kumar <xdsahil@gmail.com> * fix(ui): do not send empty message * refactor(ui,localization): removed emoji picker and connected (#1292) * refactor(ui,localization): removed emoji picker and connected * chore(ui,localizations): update changelog * chore(repo): update ui coverage threashold * doc(ui): add autocomplete_triggers guide * chore(ui): add tests for isOnlyEmoji * chore(ui): add tests for isOnlyEmoji * feat(ui): add `StreamAutocompleteTrigger.triggerOnlyAfterSpace` * fix(llc): Fix `Channel.removeMessage` not able to remove thread message. (#1294) Signed-off-by: xsahil03x <xdsahil@gmail.com> * chore(ui): flutter format Signed-off-by: xsahil03x <xdsahil@gmail.com> * fix(ui): fix `stopTyping` unhandled exceptions when network is off or spotty. (#1296) * feat(llc, ui): Introduce `keyStrokeHandler` to properly handle keyStrokes. Signed-off-by: xsahil03x <xdsahil@gmail.com> * chore(ui): update CHANGELOG.md Signed-off-by: xsahil03x <xdsahil@gmail.com> * test(llc): add key_stroke_handler_test.dart Signed-off-by: xsahil03x <xdsahil@gmail.com> * chore(ui): update CHANGELOG.md Signed-off-by: xsahil03x <xdsahil@gmail.com> * fix(core): only handle the channel list event if the state is success. Signed-off-by: xsahil03x <xdsahil@gmail.com> * feat(llc): add `hide_history` flag in `channel.addMembers`. Signed-off-by: xsahil03x <xdsahil@gmail.com> * refactor(llc): Convert positional argument to optional arguments Signed-off-by: xsahil03x <xdsahil@gmail.com> * test(llc): update tests Signed-off-by: xsahil03x <xdsahil@gmail.com> * perf: improve image resizing * fix(core): use copyWith while setting controller items. Signed-off-by: xsahil03x <xdsahil@gmail.com> * feat(ui): Added `thumbnailSize`, `thumbnailResizeType`, and `thumbnailCropType` params to `StreamMessageWidget` and `StreamAttachmentPicker` to customize the appearance of image thumbnails. Signed-off-by: xsahil03x <xdsahil@gmail.com> * fix analysis * Release v4.5.0 (#1308) * chore(llc, ui, core): bump version to v4.5.0 Signed-off-by: xsahil03x <xdsahil@gmail.com> * chore(ui, core): update CHANGELOG.md Signed-off-by: xsahil03x <xdsahil@gmail.com> Signed-off-by: xsahil03x <xdsahil@gmail.com> * third party video integration * fix llc * refactor: clean up and add docs * chore(llc): update changelog * chore(llc): add tests * chore(llc): add more tests * fix analysis * chore(llc): add more tests * chore(llc): add more tests * fix(llc): only start listening to event once connected. Signed-off-by: xsahil03x <xdsahil@gmail.com> * chore(llc): update CHANGELOG.md Signed-off-by: xsahil03x <xdsahil@gmail.com> * chore(llc): move files to correct folders. Signed-off-by: xsahil03x <xdsahil@gmail.com> * fix(ui): Fix message text hiding because of a flutter bug (#1327) * fix(ui): remove clip * chore(ui): update changelog * cleanup * fix(ui): hitting "enter" on the android keyboard sends the message instead of going to a new line. Signed-off-by: xsahil03x <xdsahil@gmail.com> * feat(ui): add support for additional text field params in message input. Signed-off-by: xsahil03x <xdsahil@gmail.com> * fix analysis * remove print * chore(llc,core,ui): update pubspec and changelogs (#1333) * fix(ui): show placeholder for web video thumbs * fix file download on web * fix reply and show buttons * remove tests * treat svg as files * fix(ui): change default image resize to clip * solve some todos * polish v5 fixing analysis issues * feat(ui): stream attachment picker bottom sheet (#1336) * refactor(ui): improve stream_attachment_handler.dart, add stream_attachment_picker_bottom_sheet.dart Signed-off-by: xsahil03x <xdsahil@gmail.com> * feat(ui): add copyWith in command_button.dart Signed-off-by: xsahil03x <xdsahil@gmail.com> * chore(ui): remove permission_manager.dart Signed-off-by: xsahil03x <xdsahil@gmail.com> * fix(ui): some fixes Signed-off-by: xsahil03x <xdsahil@gmail.com> * fix(ui): more fixes Signed-off-by: xsahil03x <xdsahil@gmail.com> * chore(ui): fix lints, add doc comments Signed-off-by: xsahil03x <xdsahil@gmail.com> * chore(ci): update flutter version Signed-off-by: xsahil03x <xdsahil@gmail.com> * chore(ui): more fixes Signed-off-by: xsahil03x <xdsahil@gmail.com> * chore(ui): more fixes Signed-off-by: xsahil03x <xdsahil@gmail.com> * chore(ui): more fixes Signed-off-by: xsahil03x <xdsahil@gmail.com> * chore(ci): update melos and flutter version Signed-off-by: xsahil03x <xdsahil@gmail.com> Signed-off-by: xsahil03x <xdsahil@gmail.com> Co-authored-by: Salvatore Giordano <salvatoregiordanoo@gmail.com> * remove todo * update changelog * update changelogs * revert * update coverage threasholds Signed-off-by: xsahil03x <xdsahil@gmail.com> Co-authored-by: GroovinChip <groovinchip@gmail.com> Co-authored-by: Sahil Kumar <xdsahil@gmail.com> Co-authored-by: Gordon Hayes <pggordonhayes@gmail.com> Co-authored-by: Sacha Arbonel <sacha.arbonel@hotmail.fr>
This commit is contained in:
committed by
GitHub
parent
3e1d6e91c7
commit
4f2542291c
@@ -128,7 +128,7 @@ If you're not sure if you've set up push notifications correctly (e.g. you don't
|
||||
11. After configuring [stream-cli](https://github.com/GetStream/stream-cli) paste the following command on command line using your user ID
|
||||
|
||||
```shell
|
||||
stream-cli chat test-push --user-id <USER-ID>
|
||||
stream chat:push:test -u <USER-ID>
|
||||
```
|
||||
|
||||
You should get a test push notification
|
||||
|
||||
@@ -223,7 +223,7 @@ If you're not sure whether you've set up push notifications correctly, for examp
|
||||
9. Tap on `Device ID` and copy it
|
||||
11. After configuring [stream-cli](https://github.com/GetStream/stream-cli), run the following command using your user ID:
|
||||
```shell
|
||||
stream-cli chat test-push --user-id <USER-ID>
|
||||
stream chat:push:test -u <USER-ID>
|
||||
```
|
||||
|
||||
You should get a test push notification 🥳
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
---
|
||||
id: autocomplete_triggers
|
||||
title: Adding Custom Autocomplete Triggers
|
||||
---
|
||||
|
||||
Adding Custom Autocomplete Triggers
|
||||
|
||||
### Introduction
|
||||
|
||||
The [StreamMessageInput](../stream_chat_flutter/message_input.mdx) widget provides a way to add custom autocomplete triggers using the `StreamMessageInput.customAutocompleteTriggers` property.
|
||||
|
||||
By default we provide autocomplete triggers for mentions and commands, but it's very easy to add your custom ones.
|
||||
|
||||
### Add Emoji Autocomplete Trigger
|
||||
|
||||
To add a custom emoji autocomplete trigger, you must first create an `AutoCompleteOptions` widget.
|
||||
This widget will be used to show the autocomplete options.
|
||||
|
||||
For this example we're using two external dependencies:
|
||||
|
||||
- [emojis](https://pub.dev/packages/emojis)
|
||||
- [substring_highlight](https://pub.dev/packages/substring_highlight)
|
||||
|
||||
```dart
|
||||
import 'package:emojis/emoji.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
import 'package:substring_highlight/substring_highlight.dart';
|
||||
|
||||
/// Overlay for displaying emoji that can be used
|
||||
class StreamEmojiAutocompleteOptions extends StatelessWidget {
|
||||
/// Constructor for creating a [StreamEmojiAutocompleteOptions]
|
||||
const StreamEmojiAutocompleteOptions({
|
||||
super.key,
|
||||
required this.query,
|
||||
this.onEmojiSelected,
|
||||
});
|
||||
|
||||
/// Query for searching emoji.
|
||||
final String query;
|
||||
|
||||
/// Callback called when an emoji is selected.
|
||||
final ValueSetter<Emoji>? onEmojiSelected;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final emojis = Emoji.all().where((it) {
|
||||
final normalizedQuery = query.toUpperCase();
|
||||
final normalizedShortName = it.shortName.toUpperCase();
|
||||
|
||||
return normalizedShortName.contains(normalizedQuery);
|
||||
});
|
||||
|
||||
if (emojis.isEmpty) return const SizedBox.shrink();
|
||||
|
||||
return StreamAutocompleteOptions<Emoji>(
|
||||
options: emojis,
|
||||
optionBuilder: (context, emoji) {
|
||||
final themeData = Theme.of(context);
|
||||
return ListTile(
|
||||
dense: true,
|
||||
horizontalTitleGap: 0,
|
||||
leading: Text(
|
||||
emoji.char,
|
||||
style: themeData.textTheme.headline6!.copyWith(
|
||||
fontSize: 24,
|
||||
),
|
||||
),
|
||||
title: SubstringHighlight(
|
||||
text: emoji.shortName,
|
||||
term: query,
|
||||
textStyleHighlight: themeData.textTheme.headline6!.copyWith(
|
||||
color: Colors.yellow,
|
||||
fontSize: 14.5,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
textStyle: themeData.textTheme.headline6!.copyWith(
|
||||
fontSize: 14.5,
|
||||
),
|
||||
),
|
||||
onTap: onEmojiSelected == null ? null : () => onEmojiSelected!(emoji),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Now it's time to use the `StreamEmojiAutocompleteOptions` widget.
|
||||
|
||||
```dart
|
||||
StreamMessageInput(
|
||||
customAutocompleteTriggers: [
|
||||
StreamAutocompleteTrigger(
|
||||
trigger: ':',
|
||||
minimumRequiredCharacters: 2,
|
||||
optionsViewBuilder: (
|
||||
context,
|
||||
autocompleteQuery,
|
||||
messageEditingController,
|
||||
) {
|
||||
final query = autocompleteQuery.query;
|
||||
return StreamEmojiAutocompleteOptions(
|
||||
query: query,
|
||||
onEmojiSelected: (emoji) {
|
||||
// accepting the autocomplete option.
|
||||
StreamAutocomplete.of(context).acceptAutocompleteOption(
|
||||
emoji.char,
|
||||
keepTrigger: false,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
```
|
||||
@@ -1,696 +0,0 @@
|
||||
---
|
||||
id: initialize_stream_chat_widget_tree
|
||||
sidebar_position: 15
|
||||
title: Initialize Stream Chat in Part of the Widget Tree
|
||||
---
|
||||
|
||||
If you’re creating a full-scale chat application, you probably want to have Stream Chat Flutter initialized at the top of your widget tree and the Stream user connected as soon as they open the application.
|
||||
|
||||
However, if you only need chat functionality in a part of your application, then it’ll be better to delay Stream Chat initialization to when it’s needed.
|
||||
This guide demonstrates three alternative ways for you to initialize Stream Chat Flutter for a part of your widget tree and to only connect a user when needed.
|
||||
|
||||
## What To Keep In Mind?
|
||||
|
||||
Before investigating potential solutions, let’s first take a look at the relevant Stream Chat widgets and classes.
|
||||
|
||||
Most of the Stream Chat Flutter UI widgets rely on having a [StreamChat](https://getstream.io/chat/docs/sdk/flutter/stream_chat_flutter/stream_chat_and_theming/) ancestor in the widget tree.
|
||||
The **StreamChat** widget is an [InheritedWidget](https://api.flutter.dev/flutter/widgets/InheritedWidget-class.html) that exposes the **StreamChatClient** through **BuildContext**.
|
||||
This widget also initializes the [StreamChatCore](../stream_chat_flutter_core/stream_chat_core.mdx) widget and the **StreamChatTheme**.
|
||||
|
||||
**StreamChatCore** is a **StatefulWidget** used to react to life cycle changes and system updates.
|
||||
When the app goes into the background, the WebSocket connection is closed.
|
||||
Conversely, a new connection is initiated when the app is back in the foreground.
|
||||
|
||||
What is important to take note of is that **a connection is only established if a user is connected**.
|
||||
|
||||
This means that if you have not yet called `client.connectUser(user, token)`, no connection will be made, and only background listeners will be registered to determine the app's foreground state.
|
||||
|
||||
## Option 1: Builder and Connect/Disconnect User
|
||||
|
||||
This option requires you to wrap your whole application with the **StreamChat** widget and to call `connectUser` and `disconnectUser` as needed.
|
||||
|
||||
This option is the easiest, however, it requires **StreamChat** to be at the top of each route and as a result, will have a slight overhead as it’ll create the above-mentioned Stream widgets that may not yet be needed.
|
||||
|
||||
### Exposing the StreamChat Widget
|
||||
|
||||
First, you must expose the client and base Stream Chat widgets to the whole application.
|
||||
|
||||
```dart
|
||||
void main() {
|
||||
final client = StreamChatClient(
|
||||
'q29npdvqjr99',
|
||||
logLevel: Level.OFF,
|
||||
);
|
||||
|
||||
runApp(MyApp(client: client));
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({
|
||||
Key? key,
|
||||
required this.client,
|
||||
}) : super(key: key);
|
||||
|
||||
final StreamChatClient client;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
builder: (context, child) {
|
||||
return StreamChat(client: client, child: child);
|
||||
},
|
||||
home: const HomeScreen(),
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In the above code, you:
|
||||
|
||||
1. Create a **StreamChatClient** instance
|
||||
2. Pass the instance to the **StreamChat** widget
|
||||
3. Expose **StreamChat** to the whole application within the **MaterialApp** `builder`
|
||||
|
||||
A few important things to note:
|
||||
|
||||
- The `builder` wraps the **StreamChat** widget for every route of our application. No matter where you are in the widget tree, you’ll be able to call `StreamChat.of(context)`.
|
||||
- The state will only be created once for our application, as **StreamChat** is a **StatefulWidget** and the position of **StreamChat** in the widget tree remains the same throughout the application lifecycle.
|
||||
- No connection will be made until you call `connectUser`.
|
||||
|
||||
### Connecting and Disconnecting Users
|
||||
|
||||
In **MaterialApp** above, the home page is set to **HomeScreen**. This screen could look something like the following:
|
||||
|
||||
```dart
|
||||
class HomeScreen extends StatelessWidget {
|
||||
const HomeScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: const Center(
|
||||
child: Text('Home Screen'),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (context) => const ChatSetup()));
|
||||
},
|
||||
child: const Icon(
|
||||
Icons.message,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This screen shows a floating action button that on click navigates the user to the **ChatSetup**. We want to connect and disconnect a Stream user only when they go to the chat setup screen.
|
||||
|
||||
```dart
|
||||
class ChatSetup extends StatefulWidget {
|
||||
const ChatSetup({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ChatSetup> createState() => _ChatSetupState();
|
||||
}
|
||||
|
||||
class _ChatSetupState extends State<ChatSetup> {
|
||||
late final Future<OwnUser> connectionFuture;
|
||||
late final client = StreamChat.of(context).client;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
connectionFuture = client.connectUser(
|
||||
User(id: 'USER_ID'),
|
||||
'TOKEN',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
client.disconnectUser();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: FutureBuilder(
|
||||
future: connectionFuture,
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
switch (snapshot.connectionState) {
|
||||
case ConnectionState.waiting:
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
default:
|
||||
if (snapshot.hasError) {
|
||||
return Text('Error: ${snapshot.error}');
|
||||
} else {
|
||||
return const ChannelListPage();
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Within `initState` you call `connectUser`; once the future for `connectUser` has completed a connection to the Stream API is established, you can then display the relevant Stream Chat UI widgets.
|
||||
|
||||
Once the **ChatScreen** widget is disposed of, then `disconnectUser` will be called within the `dispose` method.
|
||||
|
||||
### Caution
|
||||
|
||||
In this example, `disconnectUser` will **only** be called when the **ChatSetup** widget is disposed.
|
||||
|
||||
You need to ensure that this widget (route) is completely disposed of, or you need to call `disconnectUser` and `connectUser` manually when navigating to relevant parts of your application.
|
||||
|
||||
For example, let’s say you have a button within one of the chat screens to navigate to a completely different part of your app, then you want to make sure the **ChatScreen** route is disposed of by forcing it to be removed:
|
||||
|
||||
```dart
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
MaterialPageRoute(
|
||||
builder: ((context) => const HomeScreen()),
|
||||
),
|
||||
(Route<dynamic> route) => false,
|
||||
);
|
||||
```
|
||||
|
||||
Or let’s say you wanted to pop back to the first route:
|
||||
|
||||
```dart
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
```
|
||||
|
||||
Both of these will ensure the route is disposed of and the user is disconnected as a result.
|
||||
|
||||
## Option 2: A Nested Navigator
|
||||
|
||||
Another approach would be to introduce a new [Navigator](https://api.flutter.dev/flutter/widgets/Navigator-class.html).
|
||||
This has the benefit that everything related to Stream chat is contained to a specific part of the widget tree.
|
||||
|
||||
### Defining Routes and Subroutes
|
||||
|
||||
In this example, our application has the following routes.
|
||||
|
||||
```dart
|
||||
const routeHome = '/';
|
||||
const routePrefixChat = '/chat/';
|
||||
const routeChatHome = '$routePrefixChat$routeChatChannels';
|
||||
const routeChatChannels = 'chat_channels';
|
||||
const routeChatChannel = 'chat_channel';
|
||||
```
|
||||
|
||||
For the `/chat/` subroutes (**routePrefixChat**), this approach initializes Stream Chat in our application and introduces a nested navigator.
|
||||
|
||||
Let’s explore the code:
|
||||
|
||||
```dart
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
const MyApp({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MyApp> createState() => _MyAppState();
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> {
|
||||
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Provider.value(
|
||||
value: navigatorKey,
|
||||
child: MaterialApp(
|
||||
navigatorKey: navigatorKey,
|
||||
initialRoute: routeHome,
|
||||
onGenerateRoute: (settings) {
|
||||
late Widget page;
|
||||
if (settings.name == routeHome) {
|
||||
page = const HomeScreen();
|
||||
} else if (settings.name!.startsWith(routePrefixChat)) {
|
||||
final subRoute = settings.name!.substring(routePrefixChat.length);
|
||||
page = ChatSetup(
|
||||
setupChatRoute: subRoute,
|
||||
);
|
||||
} else {
|
||||
throw Exception('Unknown route: ${settings.name}');
|
||||
}
|
||||
|
||||
return MaterialPageRoute<dynamic>(
|
||||
builder: (context) {
|
||||
return page;
|
||||
},
|
||||
settings: settings,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In the above code you’re:
|
||||
|
||||
1. Creating a navigator key, passing it to `MaterialApp`, and exposing it to the whole application using Provider (you can expose it however you want).
|
||||
2. Creating `onGenerateRoute` that specifies what page to show depending on the route. Most importantly, if the route contains the **routePrefixChat,** it navigates to the **ChatSetup** page and passes in the remainder of the route.
|
||||
|
||||
For example, `Navigator.pushNamed(context, routeChatHome)` will navigate to the **ChatSetup** page and pass in the subroute **routeChatChannels.**
|
||||
|
||||
### Stream Chat Initialization, User Connection, and Nested Navigation
|
||||
|
||||
Within the **ChatSetup** widget, we’ll initialize Stream chat, connect a user, and create a new Navigator that handles the sub-navigation for the chat-specific pages.
|
||||
|
||||
```dart
|
||||
class ChatSetup extends StatefulWidget {
|
||||
const ChatSetup({Key? key, required this.setupChatRoute}) : super(key: key);
|
||||
|
||||
final String setupChatRoute;
|
||||
|
||||
@override
|
||||
State<ChatSetup> createState() => _ChatSetupState();
|
||||
}
|
||||
|
||||
class _ChatSetupState extends State<ChatSetup> {
|
||||
late final Future<OwnUser> connectionFuture;
|
||||
late final client = StreamChatClient(
|
||||
'KEY',
|
||||
logLevel: Level.OFF,
|
||||
);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
connectionFuture = client.connectUser(
|
||||
User(id: 'USER_ID'),
|
||||
'TOKEN',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
client.disconnectUser();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
child: StreamChat(
|
||||
client: client,
|
||||
child: FutureBuilder(
|
||||
future: connectionFuture,
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
switch (snapshot.connectionState) {
|
||||
case ConnectionState.waiting:
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
default:
|
||||
if (snapshot.hasError) {
|
||||
return Text('Error: ${snapshot.error}');
|
||||
} else {
|
||||
return Navigator(
|
||||
initialRoute: widget.setupChatRoute,
|
||||
onGenerateRoute: _onGenerateRoute,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Route _onGenerateRoute(RouteSettings settings) {
|
||||
late Widget page;
|
||||
switch (settings.name) {
|
||||
case routeChatChannels:
|
||||
page = ChannelListPage(
|
||||
client: client,
|
||||
);
|
||||
break;
|
||||
case routeChatChannel:
|
||||
final channel = settings.arguments as Channel;
|
||||
page = StreamChannel(
|
||||
channel: channel,
|
||||
child: const ChannelPage(),
|
||||
);
|
||||
break;
|
||||
default:
|
||||
throw Exception('Unknown route: ${settings.name}');
|
||||
}
|
||||
return MaterialPageRoute<dynamic>(
|
||||
builder: (context) {
|
||||
return page;
|
||||
},
|
||||
settings: settings,
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This **ChatSetup** widget is similar to what it was in the first option, the only difference is that we’re also introducing a nested navigator and handling those nested routes.
|
||||
|
||||
The steps for the above code are:
|
||||
|
||||
1. Create a **StreamChatClient** instance
|
||||
2. Call `connectUser` within `initState` and await the result using a **FutureBuilder**
|
||||
3. Introduce a **StreamChat** widget into the widget tree
|
||||
4. Introduce a new **Navigator** for the chat-specific routes
|
||||
5. Call `disconnectUser` within `dispose`
|
||||
|
||||
### Displaying Stream Chat UI Widgets and Global Navigation
|
||||
|
||||
Then finally, the **ChannelListPage** could look something like the following:
|
||||
|
||||
```dart
|
||||
class ChannelListPage extends StatefulWidget {
|
||||
const ChannelListPage({
|
||||
super.key,
|
||||
required this.client,
|
||||
});
|
||||
|
||||
final StreamChatClient client;
|
||||
|
||||
@override
|
||||
State<ChannelListPage> createState() => _ChannelListPageState();
|
||||
}
|
||||
|
||||
class _ChannelListPageState extends State<ChannelListPage> {
|
||||
late final _controller = StreamChannelListController(
|
||||
client: widget.client,
|
||||
filter: Filter.in_(
|
||||
'members',
|
||||
[StreamChat.of(context).currentUser!.id],
|
||||
),
|
||||
sort: const [SortOption('last_message_at')],
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _popChatPages() {
|
||||
final nav = context.read<GlobalKey<NavigatorState>>();
|
||||
nav.currentState!.pop();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
_popChatPages();
|
||||
return true;
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: BackButton(
|
||||
onPressed: () {
|
||||
_popChatPages();
|
||||
},
|
||||
),
|
||||
),
|
||||
body: RefreshIndicator(
|
||||
onRefresh: _controller.refresh,
|
||||
child: StreamChannelListView(
|
||||
controller: _controller,
|
||||
onChannelTap: (channel) {
|
||||
Navigator.pushNamed(context, routeChatChannel,
|
||||
arguments: channel);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
There are two important things to note in the above code:
|
||||
|
||||
- We’re accessing the global **NavigatorState** using Provider and calling `pop()` on the back press. This will ensure that this entire route is disposed of and that the Stream connection is closed.
|
||||
- Within `onChannelTap` we’re calling `pushNamed` and passing in the route to display a single channel page. This uses the navigator introduced in **ChatSetup**, which is the closest navigator within the widget tree.
|
||||
|
||||
A few things to take note of:
|
||||
|
||||
- You’ll always need to access the global navigator if you want to dispose of this route. you need to ensure that this route is popped or replaced, otherwise, the Stream connection will remain active for as long as the chat route is on the stack (or manually disconnected).
|
||||
|
||||
## Option 3: Navigator 2.0 - Using GoRouter
|
||||
|
||||
This final example will be a combination of the first two options. The following code is an example of how to initialize Stream Chat in a part of the widget tree using the [GoRouter package](https://pub.dev/packages/go_router). This solution will change depending on how you do routing in your Flutter application and which package (if any) you use.
|
||||
|
||||
### Application Routes and Conditional Stream Initialization
|
||||
|
||||
For this example we have the following routes and subroutes:
|
||||
|
||||
```dart
|
||||
|_ '/' -> home page
|
||||
|_ 'settings/' - settings page
|
||||
|_ 'chat/' - chat home, shows the channels list page
|
||||
|_ 'channel/' - specific channel page
|
||||
```
|
||||
|
||||
In the **MyApp** widget, we’ll initialize **GoRouter** and the **StreamChatClient**.
|
||||
However, we will only expose the **StreamChat** widget for certain routes.
|
||||
Additionally, we’ll create a **ChatSetup** widget that connects and disconnects the user.
|
||||
This widget will also **only** be injected for the `/chat` routes.
|
||||
|
||||
```dart
|
||||
class MyApp extends StatefulWidget {
|
||||
const MyApp({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MyApp> createState() => _MyAppState();
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> {
|
||||
final _client = StreamChatClient(
|
||||
'q29npdvqjr99',
|
||||
logLevel: Level.OFF,
|
||||
);
|
||||
bool wasPreviousRouteChat = false;
|
||||
|
||||
late final _router = GoRouter(
|
||||
initialLocation: '/',
|
||||
navigatorBuilder: (context, state, child) {
|
||||
if (state.location.startsWith('/chat')) {
|
||||
wasPreviousRouteChat = true;
|
||||
return StreamChat(
|
||||
client: _client,
|
||||
child: ChatSetup(client: _client, child: child),
|
||||
);
|
||||
} else {
|
||||
if (wasPreviousRouteChat) {
|
||||
wasPreviousRouteChat = false;
|
||||
return StreamChat(
|
||||
client: _client,
|
||||
child: child,
|
||||
);
|
||||
} else {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
},
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/',
|
||||
builder: (context, state) => const HomeScreen(),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'settings',
|
||||
builder: (context, state) => const SettingsPage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: 'chat',
|
||||
builder: (context, state) => const ChannelListPage(),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'channel',
|
||||
builder: (context, state) {
|
||||
final channel = state.extra as Channel;
|
||||
return StreamChannel(
|
||||
channel: channel,
|
||||
child: const ChannelPage(),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp.router(
|
||||
routeInformationParser: _router.routeInformationParser,
|
||||
routeInformationProvider: _router.routeInformationProvider,
|
||||
routerDelegate: _router.routerDelegate,
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you’re unfamiliar with GoRouter it will help to first read the documentation and then come back to this guide.
|
||||
|
||||
There are a few important things to note in the above code:
|
||||
|
||||
- Define our routes and subroutes
|
||||
- Specify the initial route with `initialLocation`
|
||||
- Use the `navigatorBuilder` to wrap certain routes with **StreamChat** and **ChatSetup**.
|
||||
- The `wasPreviousRouteChat` \***\*boolean is used to determine if the previous route was a chat route. This is important because when you press the back button from the `/chat` route and navigate to the `/` route, the **StreamChat** widget still needs to be accessible while the navigation transition occurs. However, if you then navigate to the `/setting` route, you no longer need the **StreamChat\*\* widget and can safely remove it.
|
||||
|
||||
### Navigating With GoRouter
|
||||
|
||||
Within the **HomeScreen** you can create a button that on press navigates to the `/chat` route:
|
||||
|
||||
```dart
|
||||
GoRouter.of(context).go('/chat');
|
||||
```
|
||||
|
||||
### Connecting and Disconnecting Users
|
||||
|
||||
Same as before, we’ll use the **ChatSetup** widget to connect and disconnect a user.
|
||||
This time the widget also takes in a **child** widget to display once the connection is finished.
|
||||
The child widget is dependent on the route we’re navigating to.
|
||||
|
||||
```dart
|
||||
class ChatSetup extends StatefulWidget {
|
||||
const ChatSetup({
|
||||
Key? key,
|
||||
required this.client,
|
||||
required this.child,
|
||||
}) : super(key: key);
|
||||
|
||||
final StreamChatClient client;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
State<ChatSetup> createState() => _ChatSetupState();
|
||||
}
|
||||
|
||||
class _ChatSetupState extends State<ChatSetup> {
|
||||
late final Future<OwnUser> connectionFuture;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
connectionFuture = widget.client.connectUser(
|
||||
User(id: 'USER_ID'),
|
||||
'TOKEN',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
widget.client.disconnectUser();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
child: FutureBuilder(
|
||||
future: connectionFuture,
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
switch (snapshot.connectionState) {
|
||||
case ConnectionState.waiting:
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
default:
|
||||
if (snapshot.hasError) {
|
||||
return Text('Error: ${snapshot.error}');
|
||||
} else {
|
||||
return widget.child;
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This will connect the Stream chat user within `initState` and disconnect the user on `dispose`. This is similar to the previous examples we explored.
|
||||
|
||||
### Displaying the Stream UI Widgets
|
||||
|
||||
The **ChannelListPage** can look something like the following:
|
||||
|
||||
```dart
|
||||
class ChannelListPage extends StatefulWidget {
|
||||
const ChannelListPage({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ChannelListPage> createState() => _ChannelListPageState();
|
||||
}
|
||||
|
||||
class _ChannelListPageState extends State<ChannelListPage> {
|
||||
late final client = StreamChat.of(context).client;
|
||||
late final _controller = StreamChannelListController(
|
||||
client: client,
|
||||
filter: Filter.in_(
|
||||
'members',
|
||||
[StreamChat.of(context).currentUser!.id],
|
||||
),
|
||||
sort: const [SortOption('last_message_at')],
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: RefreshIndicator(
|
||||
onRefresh: _controller.refresh,
|
||||
child: StreamChannelListView(
|
||||
controller: _controller,
|
||||
onChannelTap: (channel) {
|
||||
GoRouter.of(context).go('/chat/channel', extra: channel);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This is the same as before, the only difference is that the navigation is slightly different; now we’re navigating to the `/chat/channel` route for individual channel pages.
|
||||
|
||||
## Conclusion
|
||||
|
||||
This guide demonstrated three different ways to initialize Stream Chat in a part of the Flutter widget tree.
|
||||
|
||||
There are two key takeaways
|
||||
|
||||
1. Accessing **StreamChat** depends on your location in the widget tree
|
||||
2. How you ultimately decide to expose **StreamChat** and connect users will be up to your application architecture and how you manage routing.
|
||||
|
||||
The above are only examples that can be refined and tweaked to suit your needs.
|
||||
@@ -27,7 +27,6 @@ class UserListPageState extends State<UserListPage> {
|
||||
/// [StreamUserListController].
|
||||
late final userListController = StreamUserListController(
|
||||
client: StreamChatCore.of(context).client,
|
||||
filter: Filter.notEqual('id', StreamChatCore.of(context).currentUser!),
|
||||
);
|
||||
```
|
||||
|
||||
@@ -110,4 +109,4 @@ Widget build(BuildContext context) => Scaffold(
|
||||
);
|
||||
```
|
||||
|
||||
In this case we're using the [`LazyLoadScrollView`](./lazy_load_scroll_view.mdx) widget to load more data when the user scrolls to the bottom of the list.
|
||||
In this case we're using the [`LazyLoadScrollView`](./lazy_load_scroll_view.mdx) widget to load more data when the user scrolls to the bottom of the list.
|
||||
+1
-1
@@ -128,7 +128,7 @@ If you're not sure if you've set up push notifications correctly (e.g. you don't
|
||||
11. After configuring [stream-cli](https://github.com/GetStream/stream-cli) paste the following command on command line using your user ID
|
||||
|
||||
```shell
|
||||
stream-cli chat test-push --user-id <USER-ID>
|
||||
stream chat:push:test -u <USER-ID>
|
||||
```
|
||||
|
||||
You should get a test push notification
|
||||
|
||||
+1
-1
@@ -215,7 +215,7 @@ If you're not sure whether you've set up push notifications correctly, for examp
|
||||
9. Tap on `Device ID` and copy it
|
||||
11. After configuring [stream-cli](https://github.com/GetStream/stream-cli), run the following command using your user ID:
|
||||
```shell
|
||||
stream-cli chat test-push --user-id <USER-ID>
|
||||
stream chat:push:test -u <USER-ID>
|
||||
```
|
||||
|
||||
You should get a test push notification 🥳
|
||||
|
||||
Reference in New Issue
Block a user