@planningcenter/chat-react-native 3.2.0-rc.0 → 3.2.0-rc.10
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/build/components/conversation/message_form.d.ts +2 -2
- package/build/components/conversation/message_form.d.ts.map +1 -1
- package/build/components/conversation/message_form.js +95 -41
- package/build/components/conversation/message_form.js.map +1 -1
- package/build/components/conversation/message_reaction.d.ts +2 -2
- package/build/components/conversations/action_toggle_button.d.ts +21 -0
- package/build/components/conversations/action_toggle_button.d.ts.map +1 -0
- package/build/components/conversations/action_toggle_button.js +48 -0
- package/build/components/conversations/action_toggle_button.js.map +1 -0
- package/build/components/conversations/conversation_actions.d.ts +10 -0
- package/build/components/conversations/conversation_actions.d.ts.map +1 -0
- package/build/components/conversations/conversation_actions.js +84 -0
- package/build/components/conversations/conversation_actions.js.map +1 -0
- package/build/components/conversations/conversation_preview.d.ts +2 -1
- package/build/components/conversations/conversation_preview.d.ts.map +1 -1
- package/build/components/conversations/conversation_preview.js +27 -9
- package/build/components/conversations/conversation_preview.js.map +1 -1
- package/build/components/conversations/conversations.d.ts +2 -3
- package/build/components/conversations/conversations.d.ts.map +1 -1
- package/build/components/conversations/conversations.js +5 -11
- package/build/components/conversations/conversations.js.map +1 -1
- package/build/components/conversations/mute_indicator.d.ts +5 -0
- package/build/components/conversations/mute_indicator.d.ts.map +1 -0
- package/build/components/conversations/mute_indicator.js +19 -0
- package/build/components/conversations/mute_indicator.js.map +1 -0
- package/build/components/conversations/unread_count_badge.d.ts +2 -1
- package/build/components/conversations/unread_count_badge.d.ts.map +1 -1
- package/build/components/conversations/unread_count_badge.js +9 -1
- package/build/components/conversations/unread_count_badge.js.map +1 -1
- package/build/components/display/action_button.js +1 -2
- package/build/components/display/action_button.js.map +1 -1
- package/build/components/display/badge.d.ts +5 -4
- package/build/components/display/badge.d.ts.map +1 -1
- package/build/components/display/badge.js +5 -2
- package/build/components/display/badge.js.map +1 -1
- package/build/components/display/button.d.ts +3 -2
- package/build/components/display/button.d.ts.map +1 -1
- package/build/components/display/button.js.map +1 -1
- package/build/components/display/icon.d.ts +14 -1
- package/build/components/display/icon.d.ts.map +1 -1
- package/build/components/display/icon.js +9 -0
- package/build/components/display/icon.js.map +1 -1
- package/build/components/display/icon_button.d.ts +2 -2
- package/build/components/display/icon_button.d.ts.map +1 -1
- package/build/components/display/icon_button.js.map +1 -1
- package/build/components/display/index.d.ts +1 -0
- package/build/components/display/index.d.ts.map +1 -1
- package/build/components/display/index.js +1 -0
- package/build/components/display/index.js.map +1 -1
- package/build/components/display/person.d.ts +3 -1
- package/build/components/display/person.d.ts.map +1 -1
- package/build/components/display/person.js +2 -2
- package/build/components/display/person.js.map +1 -1
- package/build/components/display/text.js.map +1 -1
- package/build/components/display/toggle_button.d.ts +43 -0
- package/build/components/display/toggle_button.d.ts.map +1 -0
- package/build/components/display/toggle_button.js +67 -0
- package/build/components/display/toggle_button.js.map +1 -0
- package/build/components/display/utils/button_colors.d.ts +3 -3
- package/build/components/display/utils/button_colors.d.ts.map +1 -1
- package/build/components/display/utils/button_colors.js +1 -1
- package/build/components/display/utils/button_colors.js.map +1 -1
- package/build/components/page/error_boundary.d.ts +1 -1
- package/build/components/primitive/avatar_primitive.d.ts.map +1 -1
- package/build/components/primitive/avatar_primitive.js +3 -2
- package/build/components/primitive/avatar_primitive.js.map +1 -1
- package/build/components/primitive/banner_primitive.d.ts +2 -1
- package/build/components/primitive/banner_primitive.d.ts.map +1 -1
- package/build/components/primitive/banner_primitive.js +0 -1
- package/build/components/primitive/banner_primitive.js.map +1 -1
- package/build/contexts/api_provider.js.map +1 -1
- package/build/contexts/chat_context.d.ts +2 -0
- package/build/contexts/chat_context.d.ts.map +1 -1
- package/build/contexts/chat_context.js +6 -1
- package/build/contexts/chat_context.js.map +1 -1
- package/build/contexts/conversations_context.d.ts +14 -0
- package/build/contexts/conversations_context.d.ts.map +1 -0
- package/build/contexts/conversations_context.js +38 -0
- package/build/contexts/conversations_context.js.map +1 -0
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts +214 -0
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts.map +1 -0
- package/build/hooks/groups/use_group_members_for_new_conversation.js +50 -0
- package/build/hooks/groups/use_group_members_for_new_conversation.js.map +1 -0
- package/build/hooks/use_conversation.d.ts +1 -1
- package/build/hooks/use_conversation.d.ts.map +1 -1
- package/build/hooks/use_conversation.js +1 -1
- package/build/hooks/use_conversation.js.map +1 -1
- package/build/hooks/use_conversations.d.ts +6 -32
- package/build/hooks/use_conversations.d.ts.map +1 -1
- package/build/hooks/use_conversations.js +15 -14
- package/build/hooks/use_conversations.js.map +1 -1
- package/build/hooks/use_conversations_actions.d.ts +221 -0
- package/build/hooks/use_conversations_actions.d.ts.map +1 -0
- package/build/hooks/use_conversations_actions.js +93 -0
- package/build/hooks/use_conversations_actions.js.map +1 -0
- package/build/hooks/use_conversations_cache.d.ts +18 -0
- package/build/hooks/use_conversations_cache.d.ts.map +1 -0
- package/build/hooks/{use_conversation_jolt_events.js → use_conversations_cache.js} +27 -17
- package/build/hooks/use_conversations_cache.js.map +1 -0
- package/build/hooks/use_conversations_jolt_events.d.ts +3 -0
- package/build/hooks/use_conversations_jolt_events.d.ts.map +1 -0
- package/build/hooks/use_conversations_jolt_events.js +12 -0
- package/build/hooks/use_conversations_jolt_events.js.map +1 -0
- package/build/hooks/use_create_android_ripple_color.d.ts +1 -1
- package/build/hooks/use_create_android_ripple_color.d.ts.map +1 -1
- package/build/hooks/use_giphy.d.ts +9 -0
- package/build/hooks/use_giphy.d.ts.map +1 -0
- package/build/hooks/use_giphy.js +63 -0
- package/build/hooks/use_giphy.js.map +1 -0
- package/build/hooks/use_jolt.d.ts.map +1 -1
- package/build/hooks/use_jolt.js +39 -10
- package/build/hooks/use_jolt.js.map +1 -1
- package/build/hooks/use_message_create.d.ts +11 -0
- package/build/hooks/use_message_create.d.ts.map +1 -0
- package/build/hooks/use_message_create.js +35 -0
- package/build/hooks/use_message_create.js.map +1 -0
- package/build/navigation/index.d.ts +24 -7
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +26 -9
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_filter_recipients/conversation_filter_recipients_screen.d.ts.map +1 -0
- package/build/screens/conversation_filter_recipients/conversation_filter_recipients_screen.js.map +1 -0
- package/build/screens/conversation_filters/components/conversation_filters.js.map +1 -1
- package/build/screens/conversation_filters/components/rows.d.ts +2 -1
- package/build/screens/conversation_filters/components/rows.d.ts.map +1 -1
- package/build/screens/conversation_filters/components/rows.js +19 -14
- package/build/screens/conversation_filters/components/rows.js.map +1 -1
- package/build/screens/conversation_filters/hooks/filters.js +1 -1
- package/build/screens/conversation_filters/hooks/filters.js.map +1 -1
- package/build/screens/conversation_new/components/form_list.d.ts +12 -0
- package/build/screens/conversation_new/components/form_list.d.ts.map +1 -0
- package/build/screens/conversation_new/components/form_list.js +42 -0
- package/build/screens/conversation_new/components/form_list.js.map +1 -0
- package/build/screens/conversation_new/components/groups_form.d.ts +7 -0
- package/build/screens/conversation_new/components/groups_form.d.ts.map +1 -0
- package/build/screens/conversation_new/components/groups_form.js +128 -0
- package/build/screens/conversation_new/components/groups_form.js.map +1 -0
- package/build/screens/conversation_new/components/member_error_card.d.ts +5 -0
- package/build/screens/conversation_new/components/member_error_card.d.ts.map +1 -0
- package/build/screens/conversation_new/components/member_error_card.js +17 -0
- package/build/screens/conversation_new/components/member_error_card.js.map +1 -0
- package/build/screens/conversation_new/components/source_app_error_card.d.ts +2 -0
- package/build/screens/conversation_new/components/source_app_error_card.d.ts.map +1 -0
- package/build/screens/conversation_new/components/source_app_error_card.js +16 -0
- package/build/screens/conversation_new/components/source_app_error_card.js.map +1 -0
- package/build/screens/conversation_new/components/team_form.d.ts +8 -0
- package/build/screens/conversation_new/components/team_form.d.ts.map +1 -0
- package/build/screens/conversation_new/components/team_form.js +11 -0
- package/build/screens/conversation_new/components/team_form.js.map +1 -0
- package/build/screens/conversation_new/conversation_new_screen.d.ts +12 -0
- package/build/screens/conversation_new/conversation_new_screen.d.ts.map +1 -0
- package/build/screens/conversation_new/conversation_new_screen.js +16 -0
- package/build/screens/conversation_new/conversation_new_screen.js.map +1 -0
- package/build/screens/conversation_new/utils/fake_member_data.d.ts +3 -0
- package/build/screens/conversation_new/utils/fake_member_data.d.ts.map +1 -0
- package/build/screens/conversation_new/utils/fake_member_data.js +129 -0
- package/build/screens/conversation_new/utils/fake_member_data.js.map +1 -0
- package/build/screens/conversation_screen.d.ts +1 -0
- package/build/screens/conversation_screen.d.ts.map +1 -1
- package/build/screens/conversation_screen.js +1 -1
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.d.ts.map +1 -0
- package/build/screens/{create → conversation_select_recipients}/conversation_select_recipients_screen.js +6 -5
- package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.js.map +1 -0
- package/build/screens/conversations/components/chat_group_badge.d.ts +3 -0
- package/build/screens/conversations/components/chat_group_badge.d.ts.map +1 -0
- package/build/screens/conversations/components/chat_group_badge.js +40 -0
- package/build/screens/conversations/components/chat_group_badge.js.map +1 -0
- package/build/screens/conversations/components/list_header_component.d.ts +3 -0
- package/build/screens/conversations/components/list_header_component.d.ts.map +1 -0
- package/build/screens/conversations/components/list_header_component.js +92 -0
- package/build/screens/conversations/components/list_header_component.js.map +1 -0
- package/build/screens/{conversations_screen.d.ts → conversations/conversations_screen.d.ts} +1 -1
- package/build/screens/conversations/conversations_screen.d.ts.map +1 -0
- package/build/screens/conversations/conversations_screen.js +28 -0
- package/build/screens/conversations/conversations_screen.js.map +1 -0
- package/build/screens/design_system_screen.d.ts.map +1 -1
- package/build/screens/design_system_screen.js +10 -1
- package/build/screens/design_system_screen.js.map +1 -1
- package/build/screens/message_actions_screen.d.ts +2 -2
- package/build/screens/message_actions_screen.d.ts.map +1 -1
- package/build/screens/message_actions_screen.js +1 -1
- package/build/screens/message_actions_screen.js.map +1 -1
- package/build/screens/send_giphy_screen.d.ts +10 -0
- package/build/screens/send_giphy_screen.d.ts.map +1 -0
- package/build/screens/send_giphy_screen.js +98 -0
- package/build/screens/send_giphy_screen.js.map +1 -0
- package/build/types/resources/groups/groups_group_resource.d.ts +1 -1
- package/build/types/resources/groups/groups_group_resource.js.map +1 -1
- package/build/types/resources/groups/groups_member_resource_with_person.d.ts +14 -0
- package/build/types/resources/groups/groups_member_resource_with_person.d.ts.map +1 -0
- package/build/types/resources/groups/groups_member_resource_with_person.js +2 -0
- package/build/types/resources/groups/groups_member_resource_with_person.js.map +1 -0
- package/build/types/resources/member.d.ts +0 -10
- package/build/types/resources/member.d.ts.map +1 -1
- package/build/types/resources/member.js.map +1 -1
- package/build/utils/cache/page_mutations.d.ts +18 -0
- package/build/utils/cache/page_mutations.d.ts.map +1 -1
- package/build/utils/cache/page_mutations.js +13 -0
- package/build/utils/cache/page_mutations.js.map +1 -1
- package/build/utils/client/client.d.ts +2 -2
- package/build/utils/client/client.d.ts.map +1 -1
- package/build/utils/client/client.js +12 -4
- package/build/utils/client/client.js.map +1 -1
- package/build/utils/client/request_helpers.d.ts +15 -8
- package/build/utils/client/request_helpers.d.ts.map +1 -1
- package/build/utils/client/request_helpers.js +2 -1
- package/build/utils/client/request_helpers.js.map +1 -1
- package/build/utils/client/transform_request_data.d.ts +11 -6
- package/build/utils/client/transform_request_data.d.ts.map +1 -1
- package/build/utils/client/transform_request_data.js +1 -1
- package/build/utils/client/transform_request_data.js.map +1 -1
- package/build/utils/client/transform_response.d.ts +1 -1
- package/build/utils/client/transform_response.d.ts.map +1 -1
- package/build/utils/client/transform_response.js +2 -0
- package/build/utils/client/transform_response.js.map +1 -1
- package/build/utils/client/utils.d.ts +3 -3
- package/build/utils/client/utils.d.ts.map +1 -1
- package/build/utils/client/utils.js +6 -6
- package/build/utils/client/utils.js.map +1 -1
- package/build/utils/date.d.ts.map +1 -1
- package/build/utils/date.js +1 -0
- package/build/utils/date.js.map +1 -1
- package/build/utils/deepCamelCaseKeys.d.ts.map +1 -1
- package/build/utils/deepCamelCaseKeys.js +3 -1
- package/build/utils/deepCamelCaseKeys.js.map +1 -1
- package/build/utils/parse_simple_markdown.d.ts +1 -1
- package/build/utils/parse_simple_markdown.d.ts.map +1 -1
- package/build/utils/parse_simple_markdown.js +2 -1
- package/build/utils/parse_simple_markdown.js.map +1 -1
- package/build/utils/request/conversation.d.ts +1 -3
- package/build/utils/request/conversation.d.ts.map +1 -1
- package/build/utils/request/conversation.js +37 -30
- package/build/utils/request/conversation.js.map +1 -1
- package/build/utils/space.js.map +1 -1
- package/build/utils/uri.d.ts +2 -2
- package/build/utils/uri.d.ts.map +1 -1
- package/build/utils/uri.js +2 -2
- package/build/utils/uri.js.map +1 -1
- package/build/vendor/tapestry/alias_tokens_color_map.d.ts +8 -0
- package/build/vendor/tapestry/alias_tokens_color_map.d.ts.map +1 -1
- package/build/vendor/tapestry/alias_tokens_color_map.js +8 -0
- package/build/vendor/tapestry/alias_tokens_color_map.js.map +1 -1
- package/build/vendor/tapestry/tokens.d.ts +2 -0
- package/build/vendor/tapestry/tokens.d.ts.map +1 -1
- package/build/vendor/tapestry/tokens.js +2 -0
- package/build/vendor/tapestry/tokens.js.map +1 -1
- package/package.json +8 -6
- package/src/__tests__/utils/cache/page_mutations.ts +49 -15
- package/src/components/conversation/message_form.tsx +127 -58
- package/src/components/conversations/action_toggle_button.tsx +84 -0
- package/src/components/conversations/conversation_actions.tsx +146 -0
- package/src/components/conversations/conversation_preview.tsx +46 -16
- package/src/components/conversations/conversations.tsx +13 -18
- package/src/components/conversations/mute_indicator.tsx +21 -0
- package/src/components/conversations/unread_count_badge.tsx +8 -1
- package/src/components/display/action_button.tsx +1 -2
- package/src/components/display/badge.tsx +12 -8
- package/src/components/display/button.tsx +3 -3
- package/src/components/display/icon.tsx +16 -3
- package/src/components/display/icon_button.tsx +2 -2
- package/src/components/display/index.ts +1 -0
- package/src/components/display/person.tsx +4 -3
- package/src/components/display/text.tsx +1 -1
- package/src/components/display/toggle_button.tsx +157 -0
- package/src/components/display/utils/button_colors.ts +8 -3
- package/src/components/primitive/avatar_primitive.tsx +5 -3
- package/src/components/primitive/banner_primitive.tsx +2 -3
- package/src/contexts/api_provider.tsx +1 -1
- package/src/contexts/chat_context.tsx +8 -1
- package/src/contexts/conversations_context.tsx +69 -0
- package/src/hooks/groups/use_group_members_for_new_conversation.ts +57 -0
- package/src/hooks/use_conversation.ts +5 -5
- package/src/hooks/use_conversations.ts +34 -16
- package/src/hooks/use_conversations_actions.ts +108 -0
- package/src/hooks/{use_conversation_jolt_events.ts → use_conversations_cache.ts} +35 -20
- package/src/hooks/use_conversations_jolt_events.ts +21 -0
- package/src/hooks/use_giphy.ts +97 -0
- package/src/hooks/use_jolt.ts +53 -12
- package/src/hooks/use_message_create.ts +55 -0
- package/src/navigation/index.tsx +32 -9
- package/src/screens/conversation_filters/components/conversation_filters.tsx +1 -1
- package/src/screens/conversation_filters/components/rows.tsx +44 -14
- package/src/screens/conversation_filters/hooks/filters.ts +1 -1
- package/src/screens/conversation_new/components/form_list.tsx +67 -0
- package/src/screens/conversation_new/components/groups_form.tsx +191 -0
- package/src/screens/conversation_new/components/member_error_card.tsx +20 -0
- package/src/screens/conversation_new/components/source_app_error_card.tsx +24 -0
- package/src/screens/conversation_new/components/team_form.tsx +18 -0
- package/src/screens/conversation_new/conversation_new_screen.tsx +26 -0
- package/src/screens/conversation_new/utils/fake_member_data.ts +130 -0
- package/src/screens/conversation_screen.tsx +2 -1
- package/src/screens/{create → conversation_select_recipients}/conversation_select_recipients_screen.tsx +6 -5
- package/src/screens/conversations/components/chat_group_badge.tsx +47 -0
- package/src/screens/conversations/components/list_header_component.tsx +130 -0
- package/src/screens/conversations/conversations_screen.tsx +43 -0
- package/src/screens/design_system_screen.tsx +29 -0
- package/src/screens/message_actions_screen.tsx +4 -4
- package/src/screens/send_giphy_screen.tsx +155 -0
- package/src/types/resources/groups/groups_group_resource.ts +1 -1
- package/src/types/resources/groups/groups_member_resource_with_person.ts +13 -0
- package/src/types/resources/member.ts +0 -11
- package/src/utils/cache/page_mutations.ts +22 -0
- package/src/utils/client/client.ts +15 -7
- package/src/utils/client/request_helpers.ts +15 -6
- package/src/utils/client/transform_request_data.ts +13 -4
- package/src/utils/client/transform_response.ts +3 -0
- package/src/utils/client/types.d.ts +2 -1
- package/src/utils/client/utils.ts +13 -12
- package/src/utils/date.ts +1 -0
- package/src/utils/deepCamelCaseKeys.ts +3 -2
- package/src/utils/parse_simple_markdown.ts +3 -1
- package/src/utils/request/conversation.ts +39 -34
- package/src/utils/space.ts +1 -1
- package/src/utils/uri.ts +2 -2
- package/src/vendor/tapestry/alias_tokens_color_map.ts +12 -0
- package/src/vendor/tapestry/tokens.ts +2 -0
- package/build/hooks/use_conversation_jolt_events.d.ts +0 -2
- package/build/hooks/use_conversation_jolt_events.d.ts.map +0 -1
- package/build/hooks/use_conversation_jolt_events.js.map +0 -1
- package/build/screens/conversations_screen.d.ts.map +0 -1
- package/build/screens/conversations_screen.js +0 -144
- package/build/screens/conversations_screen.js.map +0 -1
- package/build/screens/create/conversation_create_screen.d.ts +0 -9
- package/build/screens/create/conversation_create_screen.d.ts.map +0 -1
- package/build/screens/create/conversation_create_screen.js +0 -123
- package/build/screens/create/conversation_create_screen.js.map +0 -1
- package/build/screens/create/conversation_filter_recipients_screen.d.ts.map +0 -1
- package/build/screens/create/conversation_filter_recipients_screen.js.map +0 -1
- package/build/screens/create/conversation_select_recipients_screen.d.ts.map +0 -1
- package/build/screens/create/conversation_select_recipients_screen.js.map +0 -1
- package/src/screens/conversations_screen.tsx +0 -222
- package/src/screens/create/conversation_create_screen.tsx +0 -148
- /package/build/screens/{create → conversation_filter_recipients}/conversation_filter_recipients_screen.d.ts +0 -0
- /package/build/screens/{create → conversation_filter_recipients}/conversation_filter_recipients_screen.js +0 -0
- /package/build/screens/{create → conversation_select_recipients}/conversation_select_recipients_screen.d.ts +0 -0
- /package/src/screens/{create → conversation_filter_recipients}/conversation_filter_recipients_screen.tsx +0 -0
|
@@ -14,7 +14,7 @@ interface MessagesFormRootProps extends ViewProps {
|
|
|
14
14
|
declare function MessageFormRoot({ conversation, children }: MessagesFormRootProps): React.JSX.Element;
|
|
15
15
|
declare function MessageFormInput(): React.JSX.Element;
|
|
16
16
|
declare function MessageFormSubmitBtn(): React.JSX.Element;
|
|
17
|
-
declare function MessageFormAttachmentPicker(): React.JSX.Element;
|
|
18
|
-
declare function MessageFormCommands(): React.JSX.Element;
|
|
17
|
+
declare function MessageFormAttachmentPicker(): React.JSX.Element | null;
|
|
18
|
+
declare function MessageFormCommands(): React.JSX.Element | null;
|
|
19
19
|
export {};
|
|
20
20
|
//# sourceMappingURL=message_form.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message_form.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_form.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"message_form.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_form.tsx"],"names":[],"mappings":"AACA,OAAO,KAA0C,MAAM,OAAO,CAAA;AAC9D,OAAO,EAA+B,SAAS,EAAE,MAAM,cAAc,CAAA;AAGrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAKlD,eAAO,MAAM,WAAW;;;;;;CAMvB,CAAA;AAED,UAAU,qBAAsB,SAAQ,SAAS;IAC/C,YAAY,EAAE,oBAAoB,CAAA;CACnC;AAYD,iBAAS,eAAe,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,qBAAqB,qBAsEzE;AAED,iBAAS,gBAAgB,sBAqBxB;AAED,iBAAS,oBAAoB,sBAe5B;AAED,iBAAS,2BAA2B,6BAenC;AAED,iBAAS,mBAAmB,6BA4B3B"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { useTheme as useNavigationTheme } from '@react-navigation/native';
|
|
2
|
-
import {
|
|
3
|
-
import React from 'react';
|
|
1
|
+
import { useNavigation, useTheme as useNavigationTheme, useRoute } from '@react-navigation/native';
|
|
2
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
4
3
|
import { StyleSheet, TextInput, View } from 'react-native';
|
|
5
|
-
import { IconButton } from '../../components';
|
|
4
|
+
import { IconButton, Text } from '../../components';
|
|
6
5
|
import { useTheme } from '../../hooks';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { updateOrCreateRecordInPagesData } from '../../utils';
|
|
6
|
+
import { useMessageCreate } from '../../hooks/use_message_create';
|
|
7
|
+
import { ChatContext } from '../../contexts/chat_context';
|
|
10
8
|
export const MessageForm = {
|
|
11
9
|
Root: MessageFormRoot,
|
|
12
10
|
TextInput: MessageFormInput,
|
|
@@ -19,57 +17,106 @@ const MessageFormContext = React.createContext({
|
|
|
19
17
|
setText: (_text) => { },
|
|
20
18
|
onSubmit: () => { },
|
|
21
19
|
disabled: false,
|
|
20
|
+
canGiphy: false,
|
|
21
|
+
usingGiphy: false,
|
|
22
|
+
setUsingGiphy: (_usingGiphy) => { },
|
|
22
23
|
});
|
|
23
24
|
function MessageFormRoot({ conversation, children }) {
|
|
25
|
+
const { giphyApiKey } = useContext(ChatContext);
|
|
26
|
+
const canGiphy = !!giphyApiKey;
|
|
24
27
|
const styles = useMessageFormStyles();
|
|
25
28
|
const [text, setText] = React.useState('');
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
url: `/me/conversations/${conversation.id}/messages`,
|
|
34
|
-
data: {
|
|
35
|
-
...requestParams.data,
|
|
36
|
-
data: {
|
|
37
|
-
type: 'Message',
|
|
38
|
-
attributes: { text },
|
|
39
|
-
},
|
|
40
|
-
fields: fieldsWithValueJoined,
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
},
|
|
44
|
-
onSuccess: (result) => {
|
|
45
|
-
const updatedMessage = result.data;
|
|
46
|
-
const queryKey = getMessagesQueryKey({ conversation_id: conversation.id });
|
|
29
|
+
const [usingGiphy, setUsingGiphy] = useState(false);
|
|
30
|
+
const navigation = useNavigation();
|
|
31
|
+
const route = useRoute();
|
|
32
|
+
const { status, isPending, reset, mutate } = useMessageCreate({ conversationId: conversation.id });
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (canGiphy && !usingGiphy && text.startsWith('/giphy ')) {
|
|
35
|
+
setUsingGiphy(true);
|
|
47
36
|
setText('');
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
37
|
+
}
|
|
38
|
+
}, [canGiphy, text, usingGiphy]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
switch (status) {
|
|
41
|
+
case 'success':
|
|
42
|
+
setText('');
|
|
43
|
+
reset();
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}, [reset, status]);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (route.params.clear_input) {
|
|
49
|
+
setText('');
|
|
50
|
+
setUsingGiphy(false);
|
|
51
|
+
navigation.setParams({ ...route.params, clear_input: false });
|
|
52
|
+
}
|
|
53
|
+
}, [navigation, route.params]);
|
|
54
|
+
const canSubmit = (() => {
|
|
55
|
+
if (isPending)
|
|
56
|
+
return false;
|
|
57
|
+
if (text.length > 0)
|
|
58
|
+
return true;
|
|
59
|
+
return false;
|
|
60
|
+
})();
|
|
61
|
+
const disabled = !canSubmit;
|
|
62
|
+
const handleSubmit = () => {
|
|
63
|
+
if (!canSubmit)
|
|
64
|
+
return;
|
|
65
|
+
if (canGiphy && usingGiphy) {
|
|
66
|
+
TextInput.State.blurTextInput(TextInput.State.currentlyFocusedInput());
|
|
67
|
+
navigation.navigate('SendGiphy', {
|
|
68
|
+
conversation_id: conversation.id,
|
|
69
|
+
search_term: text,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
mutate({ text });
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return (<MessageFormContext.Provider value={{
|
|
77
|
+
text,
|
|
78
|
+
setText,
|
|
79
|
+
onSubmit: handleSubmit,
|
|
80
|
+
disabled,
|
|
81
|
+
canGiphy,
|
|
82
|
+
usingGiphy,
|
|
83
|
+
setUsingGiphy,
|
|
84
|
+
}}>
|
|
55
85
|
<View style={styles.textInputContainer}>{children}</View>
|
|
56
86
|
</MessageFormContext.Provider>);
|
|
57
87
|
}
|
|
58
88
|
function MessageFormInput() {
|
|
59
89
|
const styles = useMessageFormStyles();
|
|
60
|
-
const { text, setText, onSubmit } = React.useContext(MessageFormContext);
|
|
61
|
-
return (<
|
|
90
|
+
const { text, setText, onSubmit, usingGiphy } = React.useContext(MessageFormContext);
|
|
91
|
+
return (<View style={styles.textInput}>
|
|
92
|
+
{usingGiphy ? (<View style={styles.giphyBadge}>
|
|
93
|
+
<Text>/Giphy</Text>
|
|
94
|
+
</View>) : null}
|
|
95
|
+
|
|
96
|
+
<TextInput aria-disabled={true} placeholder="Send a message" onChangeText={setText} value={text} onSubmitEditing={onSubmit}/>
|
|
97
|
+
</View>);
|
|
62
98
|
}
|
|
63
99
|
function MessageFormSubmitBtn() {
|
|
64
100
|
const styles = useMessageFormStyles();
|
|
65
|
-
const { onSubmit, disabled } = React.useContext(MessageFormContext);
|
|
66
|
-
return (<IconButton disabled={disabled} accessibilityLabel=
|
|
101
|
+
const { onSubmit, disabled, usingGiphy } = React.useContext(MessageFormContext);
|
|
102
|
+
return (<IconButton disabled={disabled} accessibilityLabel={usingGiphy ? 'Search Giphy' : 'Send message'} size="md" appearance="neutral" style={styles.textInputSend} name={usingGiphy ? 'general.search' : 'general.upArrow'} onPress={onSubmit}/>);
|
|
67
103
|
}
|
|
68
104
|
function MessageFormAttachmentPicker() {
|
|
105
|
+
const { usingGiphy } = React.useContext(MessageFormContext);
|
|
106
|
+
if (usingGiphy) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
69
109
|
return (<IconButton accessibilityLabel="Shazam" size="md" appearance="neutral" name={'general.paperclip'}/>);
|
|
70
110
|
}
|
|
71
111
|
function MessageFormCommands() {
|
|
72
|
-
|
|
112
|
+
const { canGiphy, usingGiphy, setUsingGiphy } = React.useContext(MessageFormContext);
|
|
113
|
+
if (!canGiphy) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
if (usingGiphy) {
|
|
117
|
+
return (<IconButton accessibilityLabel="Exit Giphy Search" size="md" appearance="neutral" name={'general.x'} onPress={() => setUsingGiphy(false)}/>);
|
|
118
|
+
}
|
|
119
|
+
return (<IconButton accessibilityLabel="Search Giphy" size="md" appearance="neutral" name={'general.bolt'} onPress={() => setUsingGiphy(true)}/>);
|
|
73
120
|
}
|
|
74
121
|
const useMessageFormStyles = () => {
|
|
75
122
|
const theme = useTheme();
|
|
@@ -91,12 +138,19 @@ const useMessageFormStyles = () => {
|
|
|
91
138
|
paddingHorizontal: 20,
|
|
92
139
|
borderColor: theme.colors.fillColorNeutral050Base,
|
|
93
140
|
flex: 1,
|
|
141
|
+
flexDirection: 'row',
|
|
142
|
+
gap: 12,
|
|
143
|
+
},
|
|
144
|
+
giphyBadge: {
|
|
145
|
+
backgroundColor: theme.colors.fillColorNeutral050Base,
|
|
146
|
+
borderRadius: 24,
|
|
147
|
+
padding: 8,
|
|
148
|
+
paddingHorizontal: 12,
|
|
94
149
|
},
|
|
95
150
|
textInputSend: {
|
|
96
151
|
borderRadius: 24,
|
|
97
152
|
height: 36,
|
|
98
153
|
width: 36,
|
|
99
|
-
backgroundColor: theme.colors.fillColorNeutral040,
|
|
100
154
|
},
|
|
101
155
|
});
|
|
102
156
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message_form.js","sourceRoot":"","sources":["../../../src/components/conversation/message_form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AACzE,OAAO,EAAgB,WAAW,EA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;AAED,SAAS,mBAAmB;IAC1B,OAAO,CACL,CAAC,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,EAAG,CAChG,CAAA;AACH,CAAC;AAED,MAAM,oBAAoB,GAAG,GAAG,EAAE;IAChC,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAA;IACxB,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAA;IAE5C,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,kBAAkB,EAAE;YAClB,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,uBAAuB;YACjD,cAAc,EAAE,CAAC;YACjB,OAAO,EAAE,EAAE;YACX,eAAe,EAAE,eAAe,CAAC,MAAM,CAAC,IAAI;YAC5C,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,EAAE;SACR;QACD,SAAS,EAAE;YACT,YAAY,EAAE,EAAE;YAChB,WAAW,EAAE,CAAC;YACd,OAAO,EAAE,EAAE;YACX,iBAAiB,EAAE,EAAE;YACrB,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,uBAAuB;YACjD,IAAI,EAAE,CAAC;SACR;QACD,aAAa,EAAE;YACb,YAAY,EAAE,EAAE;YAChB,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,EAAE;YACT,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,mBAAmB;SAClD;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useTheme as useNavigationTheme } from '@react-navigation/native'\nimport { InfiniteData, useMutation, useQueryClient } from '@tanstack/react-query'\nimport React from 'react'\nimport { StyleSheet, TextInput, View, ViewProps } from 'react-native'\nimport { IconButton } from '../../components'\nimport { useTheme } from '../../hooks'\nimport { useApiClient } from '../../hooks/use_api_client'\nimport { getMessagesQueryKey, getMessagesRequestArgs } from '../../hooks/use_conversation_messages'\nimport { ApiCollection, ApiResource, ConversationResource, MessageResource } from '../../types'\nimport { updateOrCreateRecordInPagesData } from '../../utils'\n\nexport const MessageForm = {\n Root: MessageFormRoot,\n TextInput: MessageFormInput,\n SubmitButton: MessageFormSubmitBtn,\n AttachmentPicker: MessageFormAttachmentPicker,\n Commands: MessageFormCommands,\n}\n\ninterface MessagesFormRootProps extends ViewProps {\n conversation: ConversationResource\n}\n\nconst MessageFormContext = React.createContext({\n text: '',\n setText: (_text: string) => {},\n onSubmit: () => {},\n disabled: false,\n})\n\nfunction MessageFormRoot({ conversation, children }: MessagesFormRootProps) {\n const styles = useMessageFormStyles()\n const [text, setText] = React.useState('')\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n\n const { mutate, isPending } = useMutation({\n mutationFn: async () => {\n const requestParams = getMessagesRequestArgs({ conversation_id: conversation.id })\n const fieldsWithValueJoined = Object.fromEntries(\n Object.entries(requestParams.data.fields).map(([k, v]) => [k, v.join(',')])\n )\n\n return apiClient.chat.post({\n url: `/me/conversations/${conversation.id}/messages`,\n data: {\n ...requestParams.data,\n data: {\n type: 'Message',\n attributes: { text },\n },\n fields: fieldsWithValueJoined,\n },\n })\n },\n onSuccess: (result: ApiResource<MessageResource>) => {\n const updatedMessage = result.data\n type QueryData = InfiniteData<ApiCollection<MessageResource>>\n const queryKey = getMessagesQueryKey({ conversation_id: conversation.id })\n\n setText('')\n queryClient.setQueryData<QueryData>(queryKey, data =>\n updateOrCreateRecordInPagesData({\n data,\n record: updatedMessage,\n })\n )\n },\n })\n\n return (\n <MessageFormContext.Provider\n value={{ text, setText, onSubmit: () => mutate(), disabled: isPending }}\n >\n <View style={styles.textInputContainer}>{children}</View>\n </MessageFormContext.Provider>\n )\n}\n\nfunction MessageFormInput() {\n const styles = useMessageFormStyles()\n const { text, setText, onSubmit } = React.useContext(MessageFormContext)\n\n return (\n <TextInput\n aria-disabled={true}\n placeholder=\"Send a message\"\n onChangeText={setText}\n value={text}\n style={styles.textInput}\n onSubmitEditing={onSubmit}\n />\n )\n}\n\nfunction MessageFormSubmitBtn() {\n const styles = useMessageFormStyles()\n const { onSubmit, disabled } = React.useContext(MessageFormContext)\n\n return (\n <IconButton\n disabled={disabled}\n accessibilityLabel=\"Send message\"\n size=\"md\"\n appearance=\"neutral\"\n style={styles.textInputSend}\n name={'general.upArrow'}\n onPress={onSubmit}\n />\n )\n}\n\nfunction MessageFormAttachmentPicker() {\n return (\n <IconButton\n accessibilityLabel=\"Shazam\"\n size=\"md\"\n appearance=\"neutral\"\n name={'general.paperclip'}\n />\n )\n}\n\nfunction MessageFormCommands() {\n return (\n <IconButton accessibilityLabel=\"Shazam\" size=\"md\" appearance=\"neutral\" name={'general.bolt'} />\n )\n}\n\nconst useMessageFormStyles = () => {\n const theme = useTheme()\n const navigationTheme = useNavigationTheme()\n\n return StyleSheet.create({\n textInputContainer: {\n borderColor: theme.colors.fillColorNeutral050Base,\n borderTopWidth: 1,\n padding: 12,\n backgroundColor: navigationTheme.colors.card,\n flexDirection: 'row',\n alignItems: 'center',\n gap: 12,\n },\n textInput: {\n borderRadius: 24,\n borderWidth: 1,\n padding: 12,\n paddingHorizontal: 20,\n borderColor: theme.colors.fillColorNeutral050Base,\n flex: 1,\n },\n textInputSend: {\n borderRadius: 24,\n height: 36,\n width: 36,\n backgroundColor: theme.colors.fillColorNeutral040,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"message_form.js","sourceRoot":"","sources":["../../../src/components/conversation/message_form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,IAAI,kBAAkB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAClG,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAa,MAAM,cAAc,CAAA;AACrE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,kB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;QACD,UAAU,EAAE;YACV,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,uBAAuB;YACrD,YAAY,EAAE,EAAE;YAChB,OAAO,EAAE,CAAC;YACV,iBAAiB,EAAE,EAAE;SACtB;QACD,aAAa,EAAE;YACb,YAAY,EAAE,EAAE;YAChB,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,EAAE;SACV;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useNavigation, useTheme as useNavigationTheme, useRoute } from '@react-navigation/native'\nimport React, { useContext, useEffect, useState } from 'react'\nimport { StyleSheet, TextInput, View, ViewProps } from 'react-native'\nimport { IconButton, Text } from '../../components'\nimport { useTheme } from '../../hooks'\nimport { ConversationResource } from '../../types'\nimport { useMessageCreate } from '../../hooks/use_message_create'\nimport { ConversationScreenProps } from '../../screens/conversation_screen'\nimport { ChatContext } from '../../contexts/chat_context'\n\nexport const MessageForm = {\n Root: MessageFormRoot,\n TextInput: MessageFormInput,\n SubmitButton: MessageFormSubmitBtn,\n AttachmentPicker: MessageFormAttachmentPicker,\n Commands: MessageFormCommands,\n}\n\ninterface MessagesFormRootProps extends ViewProps {\n conversation: ConversationResource\n}\n\nconst MessageFormContext = React.createContext({\n text: '',\n setText: (_text: string) => {},\n onSubmit: () => {},\n disabled: false,\n canGiphy: false,\n usingGiphy: false,\n setUsingGiphy: (_usingGiphy: boolean) => {},\n})\n\nfunction MessageFormRoot({ conversation, children }: MessagesFormRootProps) {\n const { giphyApiKey } = useContext(ChatContext)\n const canGiphy = !!giphyApiKey\n const styles = useMessageFormStyles()\n const [text, setText] = React.useState('')\n const [usingGiphy, setUsingGiphy] = useState(false)\n const navigation = useNavigation()\n const route = useRoute() as ConversationScreenProps['route']\n const { status, isPending, reset, mutate } = useMessageCreate({ conversationId: conversation.id })\n\n useEffect(() => {\n if (canGiphy && !usingGiphy && text.startsWith('/giphy ')) {\n setUsingGiphy(true)\n setText('')\n }\n }, [canGiphy, text, usingGiphy])\n\n useEffect(() => {\n switch (status) {\n case 'success':\n setText('')\n reset()\n break\n }\n }, [reset, status])\n\n useEffect(() => {\n if (route.params.clear_input) {\n setText('')\n setUsingGiphy(false)\n navigation.setParams({ ...route.params, clear_input: false })\n }\n }, [navigation, route.params])\n\n const canSubmit = (() => {\n if (isPending) return false\n if (text.length > 0) return true\n return false\n })()\n const disabled = !canSubmit\n\n const handleSubmit = () => {\n if (!canSubmit) return\n\n if (canGiphy && usingGiphy) {\n TextInput.State.blurTextInput(TextInput.State.currentlyFocusedInput())\n navigation.navigate('SendGiphy', {\n conversation_id: conversation.id,\n search_term: text,\n })\n } else {\n mutate({ text })\n }\n }\n\n return (\n <MessageFormContext.Provider\n value={{\n text,\n setText,\n onSubmit: handleSubmit,\n disabled,\n canGiphy,\n usingGiphy,\n setUsingGiphy,\n }}\n >\n <View style={styles.textInputContainer}>{children}</View>\n </MessageFormContext.Provider>\n )\n}\n\nfunction MessageFormInput() {\n const styles = useMessageFormStyles()\n const { text, setText, onSubmit, usingGiphy } = React.useContext(MessageFormContext)\n\n return (\n <View style={styles.textInput}>\n {usingGiphy ? (\n <View style={styles.giphyBadge}>\n <Text>/Giphy</Text>\n </View>\n ) : null}\n\n <TextInput\n aria-disabled={true}\n placeholder=\"Send a message\"\n onChangeText={setText}\n value={text}\n onSubmitEditing={onSubmit}\n />\n </View>\n )\n}\n\nfunction MessageFormSubmitBtn() {\n const styles = useMessageFormStyles()\n const { onSubmit, disabled, usingGiphy } = React.useContext(MessageFormContext)\n\n return (\n <IconButton\n disabled={disabled}\n accessibilityLabel={usingGiphy ? 'Search Giphy' : 'Send message'}\n size=\"md\"\n appearance=\"neutral\"\n style={styles.textInputSend}\n name={usingGiphy ? 'general.search' : 'general.upArrow'}\n onPress={onSubmit}\n />\n )\n}\n\nfunction MessageFormAttachmentPicker() {\n const { usingGiphy } = React.useContext(MessageFormContext)\n\n if (usingGiphy) {\n return null\n }\n\n return (\n <IconButton\n accessibilityLabel=\"Shazam\"\n size=\"md\"\n appearance=\"neutral\"\n name={'general.paperclip'}\n />\n )\n}\n\nfunction MessageFormCommands() {\n const { canGiphy, usingGiphy, setUsingGiphy } = React.useContext(MessageFormContext)\n\n if (!canGiphy) {\n return null\n }\n\n if (usingGiphy) {\n return (\n <IconButton\n accessibilityLabel=\"Exit Giphy Search\"\n size=\"md\"\n appearance=\"neutral\"\n name={'general.x'}\n onPress={() => setUsingGiphy(false)}\n />\n )\n }\n\n return (\n <IconButton\n accessibilityLabel=\"Search Giphy\"\n size=\"md\"\n appearance=\"neutral\"\n name={'general.bolt'}\n onPress={() => setUsingGiphy(true)}\n />\n )\n}\n\nconst useMessageFormStyles = () => {\n const theme = useTheme()\n const navigationTheme = useNavigationTheme()\n\n return StyleSheet.create({\n textInputContainer: {\n borderColor: theme.colors.fillColorNeutral050Base,\n borderTopWidth: 1,\n padding: 12,\n backgroundColor: navigationTheme.colors.card,\n flexDirection: 'row',\n alignItems: 'center',\n gap: 12,\n },\n textInput: {\n borderRadius: 24,\n borderWidth: 1,\n padding: 12,\n paddingHorizontal: 20,\n borderColor: theme.colors.fillColorNeutral050Base,\n flex: 1,\n flexDirection: 'row',\n gap: 12,\n },\n giphyBadge: {\n backgroundColor: theme.colors.fillColorNeutral050Base,\n borderRadius: 24,\n padding: 8,\n paddingHorizontal: 12,\n },\n textInputSend: {\n borderRadius: 24,\n height: 36,\n width: 36,\n },\n })\n}\n"]}
|
|
@@ -10,8 +10,8 @@ export declare const useReactionStyles: ({ mine }: {
|
|
|
10
10
|
}) => {
|
|
11
11
|
reaction: {
|
|
12
12
|
borderWidth: number;
|
|
13
|
-
borderColor:
|
|
14
|
-
backgroundColor:
|
|
13
|
+
borderColor: string;
|
|
14
|
+
backgroundColor: string;
|
|
15
15
|
borderRadius: number;
|
|
16
16
|
paddingVertical: number;
|
|
17
17
|
paddingHorizontal: number;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type PressableProps } from 'react-native-gesture-handler';
|
|
3
|
+
import { IconString } from '../display';
|
|
4
|
+
interface ActionToggleButtonProps extends PressableProps {
|
|
5
|
+
backgroundColor: string;
|
|
6
|
+
toggled: boolean;
|
|
7
|
+
toggleContent: {
|
|
8
|
+
true: {
|
|
9
|
+
iconName: IconString;
|
|
10
|
+
label: string;
|
|
11
|
+
};
|
|
12
|
+
false: {
|
|
13
|
+
iconName: IconString;
|
|
14
|
+
label: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
loading?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function ActionToggleButton({ backgroundColor, onPress, toggleContent, disabled, toggled, loading, ...props }: ActionToggleButtonProps): React.JSX.Element;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=action_toggle_button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action_toggle_button.d.ts","sourceRoot":"","sources":["../../../src/components/conversations/action_toggle_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7E,OAAO,EAAQ,UAAU,EAAiB,MAAM,YAAY,CAAA;AAI5D,UAAU,uBAAwB,SAAQ,cAAc;IACtD,eAAe,EAAE,MAAM,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE;QACb,IAAI,EAAE;YAAE,QAAQ,EAAE,UAAU,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAA;QAC7C,KAAK,EAAE;YAAE,QAAQ,EAAE,UAAU,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAA;KAC/C,CAAA;IACD,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,kBAAkB,CAAC,EACjC,eAAe,EACf,OAAO,EACP,aAAa,EACb,QAAgB,EAChB,OAAO,EACP,OAAe,EACf,GAAG,KAAK,EACT,EAAE,uBAAuB,qBA8BzB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
import { Pressable } from 'react-native-gesture-handler';
|
|
4
|
+
import { Icon, Spinner, Text } from '../display';
|
|
5
|
+
import { useCreateAndroidRippleColor, useTheme } from '../../hooks';
|
|
6
|
+
import { platformFontWeightMedium, platformPressedOpacityStyle } from '../../utils/styles';
|
|
7
|
+
export function ActionToggleButton({ backgroundColor, onPress, toggleContent, disabled = false, toggled, loading = false, ...props }) {
|
|
8
|
+
const styles = useStyles({ backgroundColor, disabled });
|
|
9
|
+
const androidRippleColor = useCreateAndroidRippleColor({
|
|
10
|
+
color: backgroundColor,
|
|
11
|
+
});
|
|
12
|
+
const { iconName, label } = toggleContent[toggled ? 'true' : 'false'];
|
|
13
|
+
return (<Pressable onPress={onPress} style={({ pressed }) => [styles.button, pressed && platformPressedOpacityStyle]} android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }} disabled={disabled || loading} accessibilityRole="togglebutton" accessibilityState={{ checked: toggled }} {...props}>
|
|
14
|
+
{loading ? (<Spinner size={20}/>) : (<>
|
|
15
|
+
<Icon name={iconName} style={styles.icon} size={20}/>
|
|
16
|
+
<Text variant="footnote" style={styles.text}>
|
|
17
|
+
{label}
|
|
18
|
+
</Text>
|
|
19
|
+
</>)}
|
|
20
|
+
</Pressable>);
|
|
21
|
+
}
|
|
22
|
+
const useStyles = ({ backgroundColor, disabled }) => {
|
|
23
|
+
const { colors } = useTheme();
|
|
24
|
+
const fillColor = disabled ? colors.textColorDefaultDisabled : colors.fillColorNeutral100Inverted;
|
|
25
|
+
const buttonBackgroundColor = disabled
|
|
26
|
+
? colors.fillColorButtonNeutralSolidDisabled
|
|
27
|
+
: backgroundColor;
|
|
28
|
+
return StyleSheet.create({
|
|
29
|
+
button: {
|
|
30
|
+
flex: 1,
|
|
31
|
+
flexDirection: 'column',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
justifyContent: 'center',
|
|
34
|
+
gap: 4,
|
|
35
|
+
height: '100%',
|
|
36
|
+
backgroundColor: buttonBackgroundColor,
|
|
37
|
+
},
|
|
38
|
+
icon: {
|
|
39
|
+
color: fillColor,
|
|
40
|
+
marginTop: 4,
|
|
41
|
+
},
|
|
42
|
+
text: {
|
|
43
|
+
color: fillColor,
|
|
44
|
+
fontWeight: platformFontWeightMedium,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=action_toggle_button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action_toggle_button.js","sourceRoot":"","sources":["../../../src/components/conversations/action_toggle_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,SAAS,EAAuB,MAAM,8BAA8B,CAAA;AAC7E,OAAO,EAAE,IAAI,EAAc,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,2BAA2B,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACnE,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAY1F,MAAM,UAAU,kBAAkB,CAAC,EACjC,eAAe,EACf,OAAO,EACP,aAAa,EACb,QAAQ,GAAG,KAAK,EAChB,OAAO,EACP,OAAO,GAAG,KAAK,EACf,GAAG,KAAK,EACgB;IACxB,MAAM,MAAM,GAAG,SAAS,CAAC,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,CAAA;IACvD,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;QACrD,KAAK,EAAE,eAAe;KACvB,CAAC,CAAA;IAEF,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CA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B,GAAG,QAAQ;QACpC,CAAC,CAAC,MAAM,CAAC,mCAAmC;QAC5C,CAAC,CAAC,eAAe,CAAA;IAEnB,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,MAAM,EAAE;YACN,IAAI,EAAE,CAAC;YACP,aAAa,EAAE,QAAQ;YACvB,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;YACxB,GAAG,EAAE,CAAC;YACN,MAAM,EAAE,MAAM;YACd,eAAe,EAAE,qBAAqB;SACvC;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,SAAS;YAChB,SAAS,EAAE,CAAC;SACb;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,SAAS;YAChB,UAAU,EAAE,wBAAwB;SACrC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { StyleSheet } from 'react-native'\nimport { Pressable, type PressableProps } from 'react-native-gesture-handler'\nimport { Icon, IconString, Spinner, Text } from '../display'\nimport { useCreateAndroidRippleColor, useTheme } from '../../hooks'\nimport { platformFontWeightMedium, platformPressedOpacityStyle } from '../../utils/styles'\n\ninterface ActionToggleButtonProps extends PressableProps {\n backgroundColor: string\n toggled: boolean\n toggleContent: {\n true: { iconName: IconString; label: string }\n false: { iconName: IconString; label: string }\n }\n loading?: boolean\n}\n\nexport function ActionToggleButton({\n backgroundColor,\n onPress,\n toggleContent,\n disabled = false,\n toggled,\n loading = false,\n ...props\n}: ActionToggleButtonProps) {\n const styles = useStyles({ backgroundColor, disabled })\n const androidRippleColor = useCreateAndroidRippleColor({\n color: backgroundColor,\n })\n\n const { iconName, label } = toggleContent[toggled ? 'true' : 'false']\n\n return (\n <Pressable\n onPress={onPress}\n style={({ pressed }) => [styles.button, pressed && platformPressedOpacityStyle]}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n disabled={disabled || loading}\n accessibilityRole=\"togglebutton\"\n accessibilityState={{ checked: toggled }}\n {...props}\n >\n {loading ? (\n <Spinner size={20} />\n ) : (\n <>\n <Icon name={iconName} style={styles.icon} size={20} />\n <Text variant=\"footnote\" style={styles.text}>\n {label}\n </Text>\n </>\n )}\n </Pressable>\n )\n}\n\nconst useStyles = ({ backgroundColor, disabled }: Partial<ActionToggleButtonProps>) => {\n const { colors } = useTheme()\n const fillColor = disabled ? colors.textColorDefaultDisabled : colors.fillColorNeutral100Inverted\n const buttonBackgroundColor = disabled\n ? colors.fillColorButtonNeutralSolidDisabled\n : backgroundColor\n\n return StyleSheet.create({\n button: {\n flex: 1,\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 4,\n height: '100%',\n backgroundColor: buttonBackgroundColor,\n },\n icon: {\n color: fillColor,\n marginTop: 4,\n },\n text: {\n color: fillColor,\n fontWeight: platformFontWeightMedium,\n },\n })\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ViewStyle } from 'react-native';
|
|
3
|
+
import { ConversationResource } from '../../types';
|
|
4
|
+
export declare function ConversationActions({ children, conversation, style, onPress, }: {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
conversation: ConversationResource;
|
|
7
|
+
onPress: () => void;
|
|
8
|
+
style?: ViewStyle;
|
|
9
|
+
}): React.JSX.Element;
|
|
10
|
+
//# sourceMappingURL=conversation_actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation_actions.d.ts","sourceRoot":"","sources":["../../../src/components/conversations/conversation_actions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAA4C,MAAM,OAAO,CAAA;AAClF,OAAO,EAAyC,SAAS,EAAE,MAAM,cAAc,CAAA;AAU/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAIlD,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,YAAY,EACZ,KAAK,EACL,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,SAAS,CAAA;IACnB,YAAY,EAAE,oBAAoB,CAAA;IAClC,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB,qBA+CA"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Platform, Pressable, StyleSheet, View } from 'react-native';
|
|
3
|
+
import ReanimatedSwipeable from 'react-native-gesture-handler/ReanimatedSwipeable';
|
|
4
|
+
import { useConversationsContext } from '../../contexts/conversations_context';
|
|
5
|
+
import { useTheme } from '../../hooks';
|
|
6
|
+
import { useConversationsMarkRead, useConversationsMute, } from '../../hooks/use_conversations_actions';
|
|
7
|
+
import { tokens } from '../../vendor/tapestry/tokens';
|
|
8
|
+
import { ActionToggleButton } from './action_toggle_button';
|
|
9
|
+
export function ConversationActions({ children, conversation, style, onPress, }) {
|
|
10
|
+
const swipeableRef = useRef(null);
|
|
11
|
+
const styles = useStyles();
|
|
12
|
+
const { activeConversationId, setActiveConversationId } = useConversationsContext();
|
|
13
|
+
const [disabled, setDisabled] = useState(false);
|
|
14
|
+
const overshootLeft = Platform.OS === 'ios';
|
|
15
|
+
const handleSwipeableClose = () => {
|
|
16
|
+
setDisabled(false);
|
|
17
|
+
swipeableRef.current?.close();
|
|
18
|
+
};
|
|
19
|
+
const handleSwipeableOpen = () => {
|
|
20
|
+
setDisabled(true);
|
|
21
|
+
setActiveConversationId(conversation.id);
|
|
22
|
+
};
|
|
23
|
+
const handlePress = useCallback(() => {
|
|
24
|
+
if (disabled || !onPress)
|
|
25
|
+
return;
|
|
26
|
+
onPress();
|
|
27
|
+
}, [disabled, onPress]);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (activeConversationId === conversation.id)
|
|
30
|
+
return;
|
|
31
|
+
handleSwipeableClose();
|
|
32
|
+
}, [activeConversationId, conversation.id]);
|
|
33
|
+
return (<ReanimatedSwipeable ref={swipeableRef} childrenContainerStyle={styles.swipeableChildContainer} containerStyle={styles.swipeableContainer} overshootFriction={8} overshootLeft={overshootLeft} overshootRight={false} onSwipeableOpenStartDrag={handleSwipeableOpen} onSwipeableClose={() => setDisabled(false)} renderLeftActions={() => (<LeftActions conversation={conversation} onClose={handleSwipeableClose}/>)}>
|
|
34
|
+
<Pressable onPress={handlePress} style={style}>
|
|
35
|
+
{children}
|
|
36
|
+
</Pressable>
|
|
37
|
+
</ReanimatedSwipeable>);
|
|
38
|
+
}
|
|
39
|
+
function LeftActions({ conversation, onClose }) {
|
|
40
|
+
const styles = useStyles();
|
|
41
|
+
const emptyConversation = conversation.lastMessageCreatedAt === null;
|
|
42
|
+
const muteToggleContent = {
|
|
43
|
+
true: { iconName: 'general.bell', label: 'Unmute' },
|
|
44
|
+
false: { iconName: 'general.bellMuted', label: 'Mute' },
|
|
45
|
+
};
|
|
46
|
+
const latestMessageUnreadToggleContent = {
|
|
47
|
+
true: { iconName: 'general.outlinedTextMessage', label: 'Mark read' },
|
|
48
|
+
false: { iconName: 'general.textMessageNotifications', label: 'Mark unread' },
|
|
49
|
+
};
|
|
50
|
+
const { muted, setMuted, isPending } = useConversationsMute({ conversation });
|
|
51
|
+
const { read, markRead, isPending: markReadPending } = useConversationsMarkRead({ conversation });
|
|
52
|
+
const handleMute = useCallback(() => {
|
|
53
|
+
setMuted(!muted);
|
|
54
|
+
onClose();
|
|
55
|
+
}, [muted, onClose, setMuted]);
|
|
56
|
+
const handleLatestMessageUnread = useCallback(() => {
|
|
57
|
+
markRead(!read);
|
|
58
|
+
onClose();
|
|
59
|
+
}, [read, onClose, markRead]);
|
|
60
|
+
return (<View style={styles.actionButtonContainer}>
|
|
61
|
+
<ActionToggleButton loading={markReadPending} disabled={emptyConversation} toggled={!read} onPress={handleLatestMessageUnread} toggleContent={latestMessageUnreadToggleContent} backgroundColor={tokens.fillColorInteractionSwipeDefault}/>
|
|
62
|
+
<ActionToggleButton loading={isPending} toggled={muted} onPress={handleMute} toggleContent={muteToggleContent} backgroundColor={tokens.fillColorInteractionSwipeSecondary}/>
|
|
63
|
+
</View>);
|
|
64
|
+
}
|
|
65
|
+
const ACTION_BUTTON_WIDTH = 120;
|
|
66
|
+
const ACTION_BUTTON_COUNT = 2;
|
|
67
|
+
const useStyles = () => {
|
|
68
|
+
const { colors } = useTheme();
|
|
69
|
+
return StyleSheet.create({
|
|
70
|
+
swipeableChildContainer: {
|
|
71
|
+
backgroundColor: colors.surfaceColor100,
|
|
72
|
+
},
|
|
73
|
+
actionButtonContainer: {
|
|
74
|
+
flexDirection: 'row',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
width: ACTION_BUTTON_WIDTH * ACTION_BUTTON_COUNT,
|
|
77
|
+
alignContent: 'stretch',
|
|
78
|
+
},
|
|
79
|
+
swipeableContainer: {
|
|
80
|
+
backgroundColor: colors.surfaceColor090,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=conversation_actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation_actions.js","sourceRoot":"","sources":["../../../src/components/conversations/conversation_actions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAa,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAa,MAAM,cAAc,CAAA;AAC/E,OAAO,mBAEN,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAA;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EACL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,uCAAuC,CAAA;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE3D,MAA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E;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAC7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,uBAAuB,EAAE;YACvB,eAAe,EAAE,MAAM,CAAC,eAAe;SACxC;QACD,qBAAqB,EAAE;YACrB,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,KAAK,EAAE,mBAAmB,GAAG,mBAAmB;YAChD,YAAY,EAAE,SAAS;SACxB;QACD,kBAAkB,EAAE;YAClB,eAAe,EAAE,MAAM,CAAC,eAAe;SACxC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React, { ReactNode, useCallback, useEffect, useRef, useState } from 'react'\nimport { Platform, Pressable, StyleSheet, View, ViewStyle } from 'react-native'\nimport ReanimatedSwipeable, {\n SwipeableMethods,\n} from 'react-native-gesture-handler/ReanimatedSwipeable'\nimport { useConversationsContext } from '../../contexts/conversations_context'\nimport { useTheme } from '../../hooks'\nimport {\n useConversationsMarkRead,\n useConversationsMute,\n} from '../../hooks/use_conversations_actions'\nimport { ConversationResource } from '../../types'\nimport { tokens } from '../../vendor/tapestry/tokens'\nimport { ActionToggleButton } from './action_toggle_button'\n\nexport function ConversationActions({\n children,\n conversation,\n style,\n onPress,\n}: {\n children: ReactNode\n conversation: ConversationResource\n onPress: () => void\n style?: ViewStyle\n}) {\n const swipeableRef = useRef<SwipeableMethods>(null)\n const styles = useStyles()\n const { activeConversationId, setActiveConversationId } = useConversationsContext()\n const [disabled, setDisabled] = useState(false)\n const overshootLeft = Platform.OS === 'ios'\n\n const handleSwipeableClose = () => {\n setDisabled(false)\n swipeableRef.current?.close()\n }\n\n const handleSwipeableOpen = () => {\n setDisabled(true)\n setActiveConversationId(conversation.id)\n }\n\n const handlePress = useCallback(() => {\n if (disabled || !onPress) return\n onPress()\n }, [disabled, onPress])\n\n useEffect(() => {\n if (activeConversationId === conversation.id) return\n\n handleSwipeableClose()\n }, [activeConversationId, conversation.id])\n\n return (\n <ReanimatedSwipeable\n ref={swipeableRef}\n childrenContainerStyle={styles.swipeableChildContainer}\n containerStyle={styles.swipeableContainer}\n overshootFriction={8}\n overshootLeft={overshootLeft}\n overshootRight={false}\n onSwipeableOpenStartDrag={handleSwipeableOpen}\n onSwipeableClose={() => setDisabled(false)}\n renderLeftActions={() => (\n <LeftActions conversation={conversation} onClose={handleSwipeableClose} />\n )}\n >\n <Pressable onPress={handlePress} style={style}>\n {children}\n </Pressable>\n </ReanimatedSwipeable>\n )\n}\n\ninterface LeftActionsProps {\n conversation: ConversationResource\n onClose: () => void\n}\n\nfunction LeftActions({ conversation, onClose }: LeftActionsProps) {\n const styles = useStyles()\n const emptyConversation = conversation.lastMessageCreatedAt === null\n\n const muteToggleContent = {\n true: { iconName: 'general.bell', label: 'Unmute' },\n false: { iconName: 'general.bellMuted', label: 'Mute' },\n } as const\n\n const latestMessageUnreadToggleContent = {\n true: { iconName: 'general.outlinedTextMessage', label: 'Mark read' },\n false: { iconName: 'general.textMessageNotifications', label: 'Mark unread' },\n } as const\n const { muted, setMuted, isPending } = useConversationsMute({ conversation })\n const { read, markRead, isPending: markReadPending } = useConversationsMarkRead({ conversation })\n\n const handleMute = useCallback(() => {\n setMuted(!muted)\n onClose()\n }, [muted, onClose, setMuted])\n\n const handleLatestMessageUnread = useCallback(() => {\n markRead(!read)\n onClose()\n }, [read, onClose, markRead])\n\n return (\n <View style={styles.actionButtonContainer}>\n <ActionToggleButton\n loading={markReadPending}\n disabled={emptyConversation}\n toggled={!read}\n onPress={handleLatestMessageUnread}\n toggleContent={latestMessageUnreadToggleContent}\n backgroundColor={tokens.fillColorInteractionSwipeDefault}\n />\n <ActionToggleButton\n loading={isPending}\n toggled={muted}\n onPress={handleMute}\n toggleContent={muteToggleContent}\n backgroundColor={tokens.fillColorInteractionSwipeSecondary}\n />\n </View>\n )\n}\n\nconst ACTION_BUTTON_WIDTH = 120\nconst ACTION_BUTTON_COUNT = 2\n\nconst useStyles = () => {\n const { colors } = useTheme()\n return StyleSheet.create({\n swipeableChildContainer: {\n backgroundColor: colors.surfaceColor100,\n },\n actionButtonContainer: {\n flexDirection: 'row',\n alignItems: 'center',\n width: ACTION_BUTTON_WIDTH * ACTION_BUTTON_COUNT,\n alignContent: 'stretch',\n },\n swipeableContainer: {\n backgroundColor: colors.surfaceColor090,\n },\n })\n}\n"]}
|
|
@@ -3,7 +3,8 @@ import { ConversationResource } from '../../types';
|
|
|
3
3
|
interface ConversationPreviewProps {
|
|
4
4
|
conversation: ConversationResource;
|
|
5
5
|
onPress: () => void;
|
|
6
|
+
showBadges?: boolean;
|
|
6
7
|
}
|
|
7
|
-
export declare const ConversationPreview: ({ conversation, onPress }: ConversationPreviewProps) => React.JSX.Element;
|
|
8
|
+
export declare const ConversationPreview: ({ conversation, onPress, showBadges, }: ConversationPreviewProps) => React.JSX.Element;
|
|
8
9
|
export {};
|
|
9
10
|
//# sourceMappingURL=conversation_preview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation_preview.d.ts","sourceRoot":"","sources":["../../../src/components/conversations/conversation_preview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"conversation_preview.d.ts","sourceRoot":"","sources":["../../../src/components/conversations/conversation_preview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAQlD,UAAU,wBAAwB;IAChC,YAAY,EAAE,oBAAoB,CAAA;IAClC,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,eAAO,MAAM,mBAAmB,2CAI7B,wBAAwB,sBAkC1B,CAAA"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
3
|
import { AvatarGroup, Heading, Text, Badge } from '../display';
|
|
4
4
|
import { formatDatePreview } from '../../utils/date';
|
|
5
5
|
import { useTheme } from '../../hooks';
|
|
6
6
|
import { UnreadCountBadge } from './unread_count_badge';
|
|
7
|
-
|
|
7
|
+
import { ConversationActions } from './conversation_actions';
|
|
8
|
+
import { MuteIndicator } from './mute_indicator';
|
|
9
|
+
export const ConversationPreview = ({ conversation, onPress, showBadges = true, }) => {
|
|
8
10
|
const styles = useStyles();
|
|
9
|
-
const { lastMessageAuthorName, lastMessageCreatedAt, lastMessageTextPreview, previewAvatarUrls, title, unreadCount, badges, } = conversation;
|
|
10
|
-
return (<
|
|
11
|
+
const { lastMessageAuthorName, lastMessageCreatedAt, lastMessageTextPreview, previewAvatarUrls, title, unreadCount, badges, muted, } = conversation;
|
|
12
|
+
return (<ConversationActions conversation={conversation} style={styles.previewRow} onPress={onPress}>
|
|
11
13
|
<AvatarGroup size="lg" sourceUris={previewAvatarUrls || []}/>
|
|
12
14
|
<View style={styles.conversationBody}>
|
|
13
15
|
<Heading numberOfLines={1} variant="h3" style={styles.title}>
|
|
@@ -16,15 +18,25 @@ export const ConversationPreview = ({ conversation, onPress }) => {
|
|
|
16
18
|
<Text variant="tertiary" numberOfLines={2}>
|
|
17
19
|
{lastMessageAuthorName}: {lastMessageTextPreview}
|
|
18
20
|
</Text>
|
|
19
|
-
<
|
|
20
|
-
{badges?.map(badge => (<Badge key={badge.text} variant="meta" productLogoName={badge.appName} label={badge.pcoResourceType} metaLabel={badge.text || ''}/>))}
|
|
21
|
-
</View>
|
|
21
|
+
<ConversationBadges visible={showBadges} badges={badges}/>
|
|
22
22
|
</View>
|
|
23
23
|
<View style={styles.metaContainer}>
|
|
24
24
|
<Text variant="tertiary">{formatDatePreview(lastMessageCreatedAt)}</Text>
|
|
25
|
-
<
|
|
25
|
+
<View style={styles.statusContainer}>
|
|
26
|
+
<UnreadCountBadge count={unreadCount} showDot={muted}/>
|
|
27
|
+
<MuteIndicator muted={muted}/>
|
|
28
|
+
</View>
|
|
26
29
|
</View>
|
|
27
|
-
</
|
|
30
|
+
</ConversationActions>);
|
|
31
|
+
};
|
|
32
|
+
const ConversationBadges = ({ visible, badges }) => {
|
|
33
|
+
const styles = useStyles();
|
|
34
|
+
if (!visible || !badges || badges.length === 0) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return (<View style={styles.badges}>
|
|
38
|
+
{badges.map(badge => (<Badge key={badge.text} variant="meta" productLogoName={badge.appName} label={badge.pcoResourceType} metaLabel={badge.text || ''}/>))}
|
|
39
|
+
</View>);
|
|
28
40
|
};
|
|
29
41
|
const useStyles = () => {
|
|
30
42
|
const { colors } = useTheme();
|
|
@@ -48,11 +60,17 @@ const useStyles = () => {
|
|
|
48
60
|
},
|
|
49
61
|
metaContainer: {
|
|
50
62
|
rowGap: 4,
|
|
63
|
+
alignItems: 'flex-end',
|
|
51
64
|
},
|
|
52
65
|
badges: {
|
|
53
66
|
marginTop: 4,
|
|
54
67
|
alignItems: 'flex-start',
|
|
55
68
|
},
|
|
69
|
+
statusContainer: {
|
|
70
|
+
flexDirection: 'row',
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
gap: 4,
|
|
73
|
+
},
|
|
56
74
|
});
|
|
57
75
|
};
|
|
58
76
|
//# sourceMappingURL=conversation_preview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation_preview.js","sourceRoot":"","sources":["../../../src/components/conversations/conversation_preview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"conversation_preview.js","sourceRoot":"","sources":["../../../src/components/conversations/conversation_preview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,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,OAAO,CAAC,CAC/B,KAAK,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAC7B,SAAS,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,EAC5B,CACH,CAAC,CACJ;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAE7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,UAAU,EAAE;YACV,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;YACN,iBAAiB,EAAE,CAAC;YACpB,iBAAiB,EAAE,MAAM,CAAC,qBAAqB;YAC/C,UAAU,EAAE,EAAE;YACd,aAAa,EAAE,EAAE;YACjB,iBAAiB,EAAE,EAAE;SACtB;QACD,KAAK,EAAE;YACL,QAAQ,EAAE,EAAE;YACZ,KAAK,EAAE,MAAM,CAAC,uBAAuB;SACtC;QACD,gBAAgB,EAAE;YAChB,IAAI,EAAE,CAAC;YACP,MAAM,EAAE,CAAC;SACV;QACD,aAAa,EAAE;YACb,MAAM,EAAE,CAAC;YACT,UAAU,EAAE,UAAU;SACvB;QACD,MAAM,EAAE;YACN,SAAS,EAAE,CAAC;YACZ,UAAU,EAAE,YAAY;SACzB;QACD,eAAe,EAAE;YACf,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,CAAC;SACP;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { ConversationResource } from '../../types'\nimport { AvatarGroup, Heading, Text, Badge } from '../display'\nimport { formatDatePreview } from '../../utils/date'\nimport { useTheme } from '../../hooks'\nimport { UnreadCountBadge } from './unread_count_badge'\nimport { ConversationActions } from './conversation_actions'\nimport { MuteIndicator } from './mute_indicator'\n\ninterface ConversationPreviewProps {\n conversation: ConversationResource\n onPress: () => void\n showBadges?: boolean\n}\n\nexport const ConversationPreview = ({\n conversation,\n onPress,\n showBadges = true,\n}: ConversationPreviewProps) => {\n const styles = useStyles()\n const {\n lastMessageAuthorName,\n lastMessageCreatedAt,\n lastMessageTextPreview,\n previewAvatarUrls,\n title,\n unreadCount,\n badges,\n muted,\n } = conversation\n\n return (\n <ConversationActions conversation={conversation} style={styles.previewRow} onPress={onPress}>\n <AvatarGroup size=\"lg\" sourceUris={previewAvatarUrls || []} />\n <View style={styles.conversationBody}>\n <Heading numberOfLines={1} variant=\"h3\" style={styles.title}>\n {title}\n </Heading>\n <Text variant=\"tertiary\" numberOfLines={2}>\n {lastMessageAuthorName}: {lastMessageTextPreview}\n </Text>\n <ConversationBadges visible={showBadges} badges={badges} />\n </View>\n <View style={styles.metaContainer}>\n <Text variant=\"tertiary\">{formatDatePreview(lastMessageCreatedAt)}</Text>\n <View style={styles.statusContainer}>\n <UnreadCountBadge count={unreadCount} showDot={muted} />\n <MuteIndicator muted={muted} />\n </View>\n </View>\n </ConversationActions>\n )\n}\n\nconst ConversationBadges = ({ visible, badges }: { visible: boolean; badges?: any[] }) => {\n const styles = useStyles()\n\n if (!visible || !badges || badges.length === 0) {\n return null\n }\n\n return (\n <View style={styles.badges}>\n {badges.map(badge => (\n <Badge\n key={badge.text}\n variant=\"meta\"\n productLogoName={badge.appName}\n label={badge.pcoResourceType}\n metaLabel={badge.text || ''}\n />\n ))}\n </View>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n previewRow: {\n flexDirection: 'row',\n gap: 8,\n borderBottomWidth: 1,\n borderBottomColor: colors.borderColorDefaultDim,\n paddingTop: 12,\n paddingBottom: 12,\n paddingHorizontal: 16,\n },\n title: {\n fontSize: 16,\n color: colors.textColorDefaultPrimary,\n },\n conversationBody: {\n flex: 1,\n rowGap: 2,\n },\n metaContainer: {\n rowGap: 4,\n alignItems: 'flex-end',\n },\n badges: {\n marginTop: 4,\n alignItems: 'flex-start',\n },\n statusContainer: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 4,\n },\n })\n}\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
interface ConversationsProps extends Partial<ConversationRequestArgs> {
|
|
2
|
+
interface ConversationsProps {
|
|
4
3
|
ListHeaderComponent?: React.ComponentType<any> | React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined;
|
|
5
4
|
}
|
|
6
|
-
export declare const Conversations: ({ ListHeaderComponent
|
|
5
|
+
export declare const Conversations: ({ ListHeaderComponent }: ConversationsProps) => React.JSX.Element;
|
|
7
6
|
export {};
|
|
8
7
|
//# sourceMappingURL=conversations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../../src/components/conversations/conversations.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../../src/components/conversations/conversations.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,UAAU,kBAAkB;IAC1B,mBAAmB,CAAC,EAChB,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,GACxB,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,GAClE,IAAI,GACJ,SAAS,CAAA;CACd;AAED,eAAO,MAAM,aAAa,4BAA6B,kBAAkB,sBAwCxE,CAAA"}
|