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

View File

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