Add accessibility labels for chat long press (#14685)

This commit is contained in:
Ibrahem Khalil 2023-01-06 14:39:14 +02:00 committed by GitHub
parent b358a23060
commit 4cdc166e41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 222 additions and 190 deletions

View File

@ -26,7 +26,7 @@
[quo/text {:style {:margin-left 10}} extra-text]]))
(defn confirmation-drawer
[{:keys [title description context button-text on-press extra-action extra-text]}]
[{:keys [title description context button-text on-press extra-action extra-text accessibility-label]}]
(let [extra-action-selected? (reagent/atom false)]
(fn []
(let [{:keys [group-chat chat-id public-key color name]} context
@ -38,7 +38,9 @@
id]))
photo-path (when-not (empty? (:images contact))
(rf/sub [:chats/photo-path id]))]
[rn/view {:style {:margin-horizontal 20}}
[rn/view
{:style {:margin-horizontal 20}
:accessibility-label accessibility-label}
[quo/text
{:weight :semi-bold
:size :heading-1} title]

View File

@ -8,7 +8,7 @@
[utils.re-frame :as rf]))
(defn- entry
[{:keys [icon label on-press danger? sub-label chevron? add-divider?]}]
[{:keys [icon label on-press danger? sub-label chevron? add-divider? accessibility-label]}]
{:pre [(keyword? icon)
(string? label)
(fn? on-press)
@ -20,7 +20,8 @@
:danger? danger?
:sub-label sub-label
:right-icon (when chevron? :i/chevron-right)
:add-divider? add-divider?})
:add-divider? add-divider?
:accessibility-label accessibility-label})
(defn hide-sheet-and-dispatch
[event]
@ -57,6 +58,7 @@
{:title (i18n/label :t/clear-history?)
:description (i18n/label :t/clear-history-confirmation-content)
:context item
:accessibility-label :clear-history-confirm
:button-text (i18n/label :t/clear-history)
:on-press #(hide-sheet-and-dispatch [:chat.ui/clear-history chat-id])}))}]))
@ -69,6 +71,7 @@
{:title (i18n/label :t/delete-chat?)
:description (i18n/label :t/delete-chat-confirmation)
:context item
:accessibility-label :delete-chat-confirm
:button-text (i18n/label :t/delete-chat)
:on-press #(hide-sheet-and-dispatch [:chat.ui/remove-chat chat-id])}))}]))
@ -81,6 +84,7 @@
{:title (i18n/label :t/leave-group?)
:description (i18n/label :t/leave-chat-confirmation)
:context item
:accessibility-label :leave-group
:button-text (i18n/label :t/leave-group)
:on-press #(do
(rf/dispatch [:navigate-back])
@ -96,6 +100,7 @@
{:title (i18n/label :t/block-user?)
:description (i18n/label :t/block-contact-details)
:context item
:accessibility-label :block-user
:button-text (i18n/label :t/block-user)
:on-press #(hide-sheet-and-dispatch [:contact.ui/block-contact-confirmed
public-key])}))}]))
@ -112,6 +117,7 @@
#(unmute-chat-action chat-id)
#(mute-chat-action chat-id))
:danger? false
:accessibility-label :mute-chat
:sub-label nil
:chevron? true})))
@ -121,6 +127,7 @@
:label (i18n/label :t/mark-as-read)
:on-press #(mark-all-read-action chat-id)
:danger? false
:accessibility-label :mark-as-read
:sub-label nil
:chevron? false
:add-divider? true}))
@ -132,6 +139,7 @@
:on-press #(clear-history-action chat-id)
:danger? true
:sub-label nil
:accessibility-label :clear-history
:chevron? false
:add-divider? true}))
@ -141,15 +149,18 @@
:label (i18n/label :t/delete-chat)
:on-press #(delete-chat-action item)
:danger? true
:accessibility-label :delete-chat
:sub-label nil
:chevron? false}))
(defn leave-group-entry
[item extra-data]
(entry {:icon :i/log-out
(entry
{:icon :i/log-out
:label (i18n/label :t/leave-group)
:on-press #(leave-group-action item (if extra-data (:chat-id extra-data) (:chat-id item)))
:danger? true
:accessibility-label :leave-group
:sub-label nil
:chevron? false
:add-divider? extra-data}))
@ -160,6 +171,7 @@
:label (i18n/label :t/view-profile)
:on-press #(show-profile-action chat-id)
:danger? false
:accessibility-label :view-profile
:sub-label nil
:chevron? false}))
@ -169,6 +181,7 @@
:label (i18n/label :t/edit-nickname)
:on-press #(edit-nickname-action chat-id)
:danger? false
:accessibility-label :edit-nickname
:sub-label nil
:chevron? false}))
@ -179,6 +192,7 @@
:label (i18n/label :t/edit-name-and-image)
:on-press #(js/alert "TODO: to be implemented, requires design input")
:danger? false
:accessibility-label :edit-name-and-image
:sub-label nil
:chevron? false}))
@ -190,6 +204,7 @@
:on-press #(js/alert "TODO: to be implemented, requires design input")
:danger? false
:sub-label "All messages" ; TODO: placeholder
:accessibility-label :manage-notifications
:chevron? true
:add-divider? add-divider?}))
@ -200,6 +215,7 @@
:label (i18n/label :t/fetch-messages)
:on-press #(js/alert "TODO: to be implemented, requires design input")
:danger? false
:accessibility-label :fetch-messages
:sub-label nil
:chevron? true}))
@ -210,6 +226,7 @@
:label (i18n/label :t/pinned-messages)
:on-press #(js/alert "TODO: to be implemented, requires design input")
:danger? false
:accessibility-label :pinned-messages
:sub-label nil
:chevron? true}))
@ -219,6 +236,7 @@
:label (i18n/label :t/remove-from-contacts)
:on-press #(hide-sheet-and-dispatch [:contact.ui/remove-contact-pressed contact])
:danger? false
:accessibility-label :remove-from-contacts
:sub-label nil
:chevron? false}))
@ -229,6 +247,7 @@
:label (i18n/label :t/rename)
:on-press #(js/alert "TODO: to be implemented, requires design input")
:danger? false
:accessibility-label :rename-contact
:sub-label nil
:chevron? false}))
@ -239,6 +258,7 @@
:label (i18n/label :t/show-qr)
:on-press #(js/alert "TODO: to be implemented, requires design input")
:danger? false
:accessibility-label :show-qr-code
:sub-label nil
:chevron? false}))
@ -249,6 +269,7 @@
:label (i18n/label :t/share-profile)
:on-press #(js/alert "TODO: to be implemented")
:danger? false
:accessibility-label :share-profile
:sub-label nil
:chevron? false}))
@ -259,6 +280,7 @@
:label (i18n/label :t/share)
:on-press #(js/alert "TODO: to be implemented")
:danger? false
:accessibility-label :share-group
:sub-label nil
:chevron? false}))
@ -269,6 +291,7 @@
:label (i18n/label :t/mark-untrustworthy)
:on-press #(js/alert "TODO: to be implemented, requires status-go impl.")
:danger? true
:accessibility-label :mark-untrustworthy
:sub-label nil
:chevron? false
:add-divider? true}))
@ -279,6 +302,7 @@
:label (i18n/label :t/block-user)
:on-press #(block-user-action item)
:danger? true
:accessibility-label :block-user
:sub-label nil
:chevron? false}))
@ -290,6 +314,7 @@
:on-press #(hide-sheet-and-dispatch [:group-chats.ui/remove-member-pressed chat-id
public-key true])
:danger? true
:accessibility-label :remove-from-group
:sub-label nil
:chevron? false
:add-divider? true})))
@ -300,6 +325,7 @@
:label (i18n/label :t/group-details)
:on-press #(hide-sheet-and-dispatch [:show-group-chat-profile chat-id])
:danger? false
:accessibility-label :group-details
:sub-label nil
:chevron? false}))
@ -310,6 +336,7 @@
:label (i18n/label :t/add-members)
:on-press #(js/alert "TODO: to be implemented")
:danger? false
:accessibility-label :add-members
:sub-label nil
:chevron? false}))
@ -320,6 +347,7 @@
:label (i18n/label :t/manage-members)
:on-press #(js/alert "TODO: to be implemented")
:danger? false
:accessibility-label :manage-members
:sub-label nil
:chevron? false}))
@ -330,6 +358,7 @@
:label (i18n/label :t/edit-name-and-image)
:on-press #(js/alert "TODO: to be implemented")
:danger? false
:accessibility-label :edit-group
:sub-label nil
:chevron? false}))
@ -340,6 +369,7 @@
:label (i18n/label :t/change-group-privacy)
:on-press #(js/alert "TODO: to be implemented")
:danger? false
:accessibility-label :group-privacy
:sub-label nil
:chevron? false}))