[#12867] Add accessibility IDs to toggles for e2e

This commit is contained in:
Roman Volosovskyi 2021-12-15 18:55:32 +02:00
parent 646add59b8
commit 2c23ab4c5d
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
2 changed files with 10 additions and 8 deletions

View File

@ -49,15 +49,15 @@
:hold hold
:disabled disabled}]]]))))
(defn switch-view [{:keys [transition hold disabled]}]
(defn switch-view [{:keys [transition hold disabled value]}]
[animated/view {:style (styles/switch-style transition disabled)
:accessibility-label :switch
:accessibility-label (str "switch-" (if value "on" "off"))
:accessibility-role :switch}
[animated/view {:style (styles/switch-bullet-style transition hold)}]])
(defn radio-view [{:keys [transition hold disabled]}]
(defn radio-view [{:keys [transition hold disabled value]}]
[animated/view {:style (styles/radio-style transition disabled)
:accessibility-label :radio
:accessibility-label (str "radio-" (if value "on" "off"))
:accessibility-role :radio}
[animated/view {:style (styles/radio-bullet-style transition hold)}]])
@ -67,15 +67,15 @@
[rn/touchable-without-feedback
{:on-press (when (and onChange (not disabled)) onChange)}
[rn/view {:style (styles/checkbox-style value disabled)
:accessibility-label :checkbox
:accessibility-label (str "checkbox-" (if value "on" "off"))
:accessibility-role :checkbox}
[rn/view {:style (styles/check-icon-style value)}
[icons/tiny-icon :tiny-icons/tiny-check {:color colors/white}]]]])))
(defn animated-checkbox-view [{:keys [transition hold disabled]}]
(defn animated-checkbox-view [{:keys [transition hold disabled value]}]
[animated/view
{:style (styles/animated-checkbox-style transition disabled)
:accessibility-label :checkbox
:accessibility-label (str "checkbox-" (if value "on" "off"))
:accessibility-role :checkbox}
[animated/view {:style (styles/animated-check-icon-style transition hold)}
[icons/tiny-icon :tiny-icons/tiny-check {:color colors/white}]]])

View File

@ -13,7 +13,9 @@
(merge {:style (merge
styles/wrapper
style)
:accessibility-label accessibility-label}
:accessibility-label (str accessibility-label
"-"
(if checked? "on" "off"))}
(when on-value-change
{:on-press #(on-value-change (not checked?))}))
(if checked?