1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Refine accessibility

This commit is contained in:
Zhiyuan Zheng
2021-04-09 21:43:12 +02:00
parent 9258f4b934
commit d4b28df091
57 changed files with 661 additions and 142 deletions

View File

@ -1,4 +1,5 @@
import Icon from '@components/Icon'
import { useAccessibility } from '@utils/accessibility/AccessibilityManager'
import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager'
import { ColorDefinitions } from '@utils/styles/themes'
@ -41,6 +42,7 @@ const MenuRow: React.FC<Props> = ({
onPress
}) => {
const { theme } = useTheme()
const { screenReaderEnabled } = useAccessibility()
const loadingSpinkit = useMemo(
() => (
@ -55,11 +57,22 @@ const MenuRow: React.FC<Props> = ({
)
return (
<View style={styles.base}>
<View
style={styles.base}
accessible
accessibilityRole={switchValue ? 'switch' : 'button'}
accessibilityState={switchValue ? { checked: switchValue } : undefined}
>
<TapGestureHandler
onHandlerStateChange={({ nativeEvent }) =>
nativeEvent.state === State.ACTIVE && !loading && onPress && onPress()
}
onHandlerStateChange={async ({ nativeEvent }) => {
if (nativeEvent.state === State.ACTIVE && !loading) {
if (screenReaderEnabled && switchOnValueChange) {
switchOnValueChange()
} else {
if (onPress) onPress()
}
}
}}
>
<View style={styles.core}>
<View style={styles.front}>