Skip to content

Commit

Permalink
fix: accessibilité rapport ux (#210)
Browse files Browse the repository at this point in the history
Signed-off-by: fc-santos <filipesantos@live.ca>
  • Loading branch information
fc-santos authored Jan 16, 2025
1 parent 88cfb06 commit aaa11a2
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ describe('DismissiblePopupModal Component', () => {
onCallToActionPressed={onCallToActionPressed}
/>
)
const dismissButton = getByTestId(testIdWithKey('Dismiss'))
fireEvent(dismissButton, 'press')
const closeButton = getByTestId(testIdWithKey('Close'))
fireEvent(closeButton, 'press')

expect(onDismissPressed).toBeCalledTimes(1)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ exports[`DismissiblePopupModal Component Renders correctly with call to action 1
}
>
<Text
accessible={false}
allowFontScaling={false}
selectable={false}
style={
Expand Down Expand Up @@ -154,7 +155,7 @@ exports[`DismissiblePopupModal Component Renders correctly with call to action 1
}
>
<View
accessibilityLabel="Global.Dismiss"
accessibilityLabel="Global.Close"
accessibilityRole="button"
accessibilityState={
{
Expand Down Expand Up @@ -196,7 +197,7 @@ exports[`DismissiblePopupModal Component Renders correctly with call to action 1
"opacity": 1,
}
}
testID="com.ariesbifold:id/Dismiss"
testID="com.ariesbifold:id/Close"
>
<Text
allowFontScaling={false}
Expand Down Expand Up @@ -454,6 +455,7 @@ exports[`DismissiblePopupModal Component Renders correctly without call to actio
}
>
<Text
accessible={false}
allowFontScaling={false}
selectable={false}
style={
Expand Down Expand Up @@ -504,7 +506,7 @@ exports[`DismissiblePopupModal Component Renders correctly without call to actio
}
>
<View
accessibilityLabel="Global.Dismiss"
accessibilityLabel="Global.Close"
accessibilityRole="button"
accessibilityState={
{
Expand Down Expand Up @@ -546,7 +548,7 @@ exports[`DismissiblePopupModal Component Renders correctly without call to actio
"opacity": 1,
}
}
testID="com.ariesbifold:id/Dismiss"
testID="com.ariesbifold:id/Close"
>
<Text
allowFontScaling={false}
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/AddCredentialSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const AddCredentialSlider: React.FC = () => {

return (
<Modal animationType="slide" transparent={true} visible={addCredentialPressed} onRequestClose={deactivateSlider}>
<TouchableOpacity style={styles.outsideListener} onPress={deactivateSlider} />
<TouchableOpacity style={styles.outsideListener} onPress={deactivateSlider} accessible={false} />
<View style={styles.centeredView}>
<View style={styles.modalView}>
<TouchableOpacity
Expand Down
7 changes: 6 additions & 1 deletion app/src/components/Help/HelpListSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ const HelpListSlider: React.FC = () => {

return (
<Modal transparent={true} visible={addHelpPressed} onRequestClose={deactivateSlider}>
<TouchableOpacity style={styles.outsideListener} onPress={deactivateSlider} hitSlop={hitSlop} />
<TouchableOpacity
style={styles.outsideListener}
onPress={deactivateSlider}
hitSlop={hitSlop}
accessible={false}
/>
<View style={styles.centeredView}>
{/* Suppression de l'animation d'opacité */}
<View style={styles.modalView}>
Expand Down
6 changes: 3 additions & 3 deletions app/src/components/modals/DismissablePopupModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const DismissiblePopupModal: React.FC<DismissiblePopupModalProps> = ({
<View style={styles.container}>
<View style={styles.headerContainer}>
<View style={styles.infoIcon}>
<Icon name={infoIconName} size={iconSize} color={iconColor} />
<Icon name={infoIconName} size={iconSize} color={iconColor} accessible={false} />
</View>
<View style={styles.headerTextContainer}>
<Text style={styles.headerText} testID={testIdWithKey('HeaderText')}>
Expand All @@ -121,8 +121,8 @@ const DismissiblePopupModal: React.FC<DismissiblePopupModalProps> = ({
<View style={styles.dismissIcon}>
<TouchableOpacity
onPress={onDismissPressed}
testID={testIdWithKey('Dismiss')}
accessibilityLabel={t('Global.Dismiss')}
testID={testIdWithKey('Close')}
accessibilityLabel={t('Global.Close')}
accessibilityRole={'button'}
hitSlop={hitSlop}
>
Expand Down
2 changes: 1 addition & 1 deletion app/src/localization/fr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const translation = {
Dismiss: 'Rejeter',
On: 'Activé',
Off: 'Fermer',
Close: 'Retirer',
Close: 'Fermer',
Save: 'Enregistrer',
ShowDetails: 'Afficher les détails',
Biometrics: 'Biométrie',
Expand Down
3 changes: 1 addition & 2 deletions app/src/screens/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ const HelpCenter: React.FC = () => {
flex: 1,
justifyContent: 'flex-end',
...TextTheme.headingOne,
margin: 10,
paddingBottom: 20,
},
sectionCopyrightText: {
...TextTheme.caption,
color: TextTheme.normal.color,
textAlign: 'left',
textDecorationLine: 'none',
marginLeft: 10,
},
})
return (
Expand Down
4 changes: 2 additions & 2 deletions app/src/screens/HelpCenter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ const HelpCenter: React.FC<HelpCenterProps> = ({ navigation }) => {
flex: 1,
justifyContent: 'flex-end',
...TextTheme.headingOne,
margin: 10,
marginTop: 10,
paddingBottom: 20,
},
sectionCopyrightText: {
...TextTheme.caption,
color: TextTheme.normal.color,
textAlign: 'left',
textDecorationLine: 'none',
marginLeft: 10,
},
})

Expand Down
65 changes: 26 additions & 39 deletions app/src/screens/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { i18n, Locales } from '@hyperledger/aries-bifold-core/App/localization'
import { StackScreenProps } from '@react-navigation/stack'
import React, { useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { ScrollView, StyleSheet, Text, View, TouchableOpacity, Pressable, Modal } from 'react-native'
import { ScrollView, StyleSheet, Text, View, TouchableOpacity, Modal, AccessibilityRole } from 'react-native'
import { getBuildNumber, getVersion } from 'react-native-device-info'
import { SafeAreaView } from 'react-native-safe-area-context'
import MaterialIcon from 'react-native-vector-icons/MaterialIcons'
Expand Down Expand Up @@ -75,12 +75,6 @@ const Settings: React.FC<SettingsProps> = ({ navigation }) => {
flexGrow: 1,
paddingHorizontal: 20,
},
sectionRow: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
gap: 8,
},
rowTitle: {
...TextTheme.headingFour,
flex: 1,
Expand All @@ -97,15 +91,15 @@ const Settings: React.FC<SettingsProps> = ({ navigation }) => {
},
})
const SectionHeader = ({ title }: { title: string }): JSX.Element => (
<>
<View style={[styles.section, styles.sectionHeader]}>
<Text style={[TextTheme.headingThree, { flexShrink: 1 }]}>{title}</Text>
</View>
</>
<View style={[styles.section, styles.sectionHeader]}>
<Text style={[TextTheme.headingThree, { flexShrink: 1 }]} accessibilityRole="header">
{title}
</Text>
</View>
)
interface SectionRowProps {
title: string
accessibilityLabel?: string
accessibilityRole?: AccessibilityRole
testID?: string
children: JSX.Element
showRowSeparator?: boolean
Expand All @@ -115,31 +109,23 @@ const Settings: React.FC<SettingsProps> = ({ navigation }) => {
}
const SectionRow = ({
title,
accessibilityLabel,
accessibilityRole = undefined,
testID,
onPress,
children,
showRowSeparator,
subContent,
rowIcon,
}: SectionRowProps) => (
<TouchableOpacity accessibilityLabel={accessibilityLabel} testID={testID} onPress={onPress}>
<TouchableOpacity testID={testID} onPress={onPress} accessibilityRole={accessibilityRole}>
<View style={[styles.section]}>
<Pressable
onPress={onPress}
accessible={true}
accessibilityLabel={accessibilityLabel}
testID={testID}
style={styles.sectionRow}
>
<View style={{ flexDirection: 'row' }}>
<Text style={styles.rowTitle}>{title}</Text>
<View style={{ flexDirection: 'row' }}>
<Text style={styles.rowTitle}>{title}</Text>

{children}
{children}

{rowIcon}
</View>
</Pressable>
{rowIcon}
</View>
{subContent}
</View>
{showRowSeparator && (
Expand All @@ -149,7 +135,9 @@ const Settings: React.FC<SettingsProps> = ({ navigation }) => {
)}
</TouchableOpacity>
)
const arrowIcon = <MaterialIcon name={'keyboard-arrow-right'} size={iconSize} />
const arrowIcon = (
<MaterialIcon name={'keyboard-arrow-right'} size={iconSize} accessible={false} accessibilityLabel="" />
)
return (
<SafeAreaView style={styles.container} edges={['left', 'right']}>
<Modal
Expand All @@ -166,8 +154,8 @@ const Settings: React.FC<SettingsProps> = ({ navigation }) => {
<SectionHeader title={t('Settings.Preference')} />
<SectionRow
title={t('Settings.Language')}
accessibilityLabel={t('Settings.Language')}
testID={testIdWithKey(t('Settings.Language').toLowerCase())}
accessibilityRole="button"
testID={testIdWithKey('Language')}
onPress={() => navigation.navigate(Screens.Language)}
rowIcon={arrowIcon}
>
Expand All @@ -176,8 +164,8 @@ const Settings: React.FC<SettingsProps> = ({ navigation }) => {
<SectionHeader title={t('Settings.Security')} />
<SectionRow
title={t('Settings.MyPin')}
accessibilityLabel={t('Settings.MyPin')}
testID={testIdWithKey(t('Settings.MyPin').toLowerCase())}
accessibilityRole="button"
testID={testIdWithKey('MyPin')}
onPress={() =>
navigation
.getParent()
Expand All @@ -191,8 +179,8 @@ const Settings: React.FC<SettingsProps> = ({ navigation }) => {
<View style={[styles.sectionSeparator]}></View>
<SectionRow
title={t('Settings.Biometrics')}
accessibilityLabel={t('Settings.Biometrics')}
testID={testIdWithKey(t('Settings.Biometrics').toLowerCase())}
accessibilityRole="button"
testID={testIdWithKey('Biometrics')}
onPress={() => navigation.navigate(Screens.UseBiometry)}
showRowSeparator
rowIcon={arrowIcon}
Expand All @@ -206,8 +194,8 @@ const Settings: React.FC<SettingsProps> = ({ navigation }) => {
<View style={[styles.sectionSeparator]}></View>
<SectionRow
title={t('Developer.Environment')}
accessibilityLabel={t('Developer.Environment')}
testID={testIdWithKey(t('Developer.Environment').toLowerCase())}
accessibilityRole="button"
testID={testIdWithKey('Environment')}
showRowSeparator={true}
onPress={() => {
setEnvironmentModalVisible(true)
Expand All @@ -224,8 +212,7 @@ const Settings: React.FC<SettingsProps> = ({ navigation }) => {
<View style={[styles.sectionSeparator]}></View>
<SectionRow
title={t('Settings.Version')}
accessibilityLabel={t('Settings.Version')}
testID={testIdWithKey(t('Settings.Version').toLowerCase())}
testID={testIdWithKey('Version')}
onPress={() => {
incrementDeveloperMenuCounter()
}}
Expand Down
13 changes: 7 additions & 6 deletions app/src/screens/UseBiometry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ const UseBiometry: React.FC = () => {
marginRight: 10,
justifyContent: 'center',
},
biometryAvailableGap: {
rowGap: 16,
},
})

useEffect(() => {
Expand Down Expand Up @@ -320,20 +323,18 @@ const UseBiometry: React.FC = () => {
<HeaderText title={!inBiometryScreenFromSettings ? t('Screens.Biometry') : t('Screens.UseBiometry')} />
<View style={{ marginTop: 20 }}>
{biometryAvailable ? (
<>
<View style={styles.biometryAvailableGap}>
<Text style={TextTheme.normal}>{t('Biometry.EnabledText1')}</Text>
<Text></Text>
<Text style={TextTheme.normal}>
{t('Biometry.EnabledText2')}
<Text style={TextTheme.bold}> {t('Biometry.Warning')}</Text>
</Text>
</>
</View>
) : (
<>
<View style={styles.biometryAvailableGap}>
<Text style={TextTheme.normal}>{t('Biometry.NotEnabledText1')}</Text>
<Text></Text>
<Text style={TextTheme.normal}>{t('Biometry.NotEnabledText2')}</Text>
</>
</View>
)}
</View>
<View
Expand Down

0 comments on commit aaa11a2

Please sign in to comment.