-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathScreenWrapper.tsx
More file actions
114 lines (111 loc) · 3.48 KB
/
ScreenWrapper.tsx
File metadata and controls
114 lines (111 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import React from 'react';
import {
View,
StyleSheet,
TouchableHighlight,
Text,
PlatformColor,
AccessibilityInfo,
} from 'react-native';
import {useNavigation, DrawerActions, getDrawerStatusFromState} from '../Navigation';
const createStyles = () =>
StyleSheet.create({
container: {
flexDirection: 'row',
width: '100%',
height: '100%',
backgroundColor: PlatformColor('Background'),
},
navBar: {
backgroundColor: PlatformColor('Background'),
width: 48,
height: '100%',
paddingBottom: 20,
},
navItem: {
flexGrow: 1,
flexShrink: 1,
height: '100%',
alignSelf: 'stretch',
borderTopLeftRadius: 8,
borderColor: 'rgba(233, 233, 233, 0.47)',
borderLeftWidth: 1,
},
insetNavItem: {
paddingLeft: 36,
},
menu: {
margin: 5,
height: 34,
width: 38,
borderRadius: 3,
alignItems: 'center',
justifyContent: 'center',
},
icon: {
fontFamily: 'Segoe MDL2 Assets',
fontSize: 16,
color: PlatformColor('TextControlForeground'),
},
});
type ScreenWrapperProps = React.PropsWithChildren<{
doNotInset?: boolean;
}>;
export function ScreenWrapper({
children,
doNotInset,
}: ScreenWrapperProps): JSX.Element {
const navigation = useNavigation();
const styles = createStyles();
const isDrawerOpen = getDrawerStatusFromState(navigation.getState()) === 'open';
return (
<View style={styles.container}>
<View
// accessibilityRole="button"
accessibilityLabel="Navigation bar"
accessibilityState={{ expanded: isDrawerOpen }}
accessibilityLiveRegion='assertive'
// accessibilityHint={isDrawerOpen ? 'Tap to collapse navigation menu' : 'Tap to expand navigation menu'}
// tooltip={isDrawerOpen ? 'Tap to collapse navigation menu' : 'Tap to expand navigation menu'}
// requires react-native-gesture-handler to be imported in order to pass testing.
// blocked by #125
/*accessibilityState={{
expanded: useIsDrawerOpen(),
}}*/
style={styles.navBar}
>
<View>
<TouchableHighlight
accessibilityRole="button"
accessibilityLabel="Navigation menu"
tooltip={'Expand navigation menu'}
tooltipProperties={{MaxWidth: 500}}
// requires react-native-gesture-handler to be imported in order to pass testing.
// blocked by #125
//accessibilityState={{expanded: useIsDrawerOpen()}}
style={styles.menu}
accessibilityHint={'Tap to expand navigation menu'}
onPress={() => {
navigation.dispatch(DrawerActions.toggleDrawer());
if (!isDrawerOpen) {
AccessibilityInfo.announceForAccessibility('Navigation menu expanded');
}
}}
onAccessibilityTap={() => {
navigation.dispatch(DrawerActions.toggleDrawer());
if (!isDrawerOpen) {
AccessibilityInfo.announceForAccessibility('Navigation menu expanded');
}
}}
activeOpacity={0.5783}
underlayColor="rgba(0, 0, 0, 0.0241);">
<Text style={styles.icon} accessibilityLabel="Navigation bar hamburger icon text"></Text>
</TouchableHighlight>
</View>
</View>
<View style={[styles.navItem, doNotInset ? {} : styles.insetNavItem]}>
{children}
</View>
</View>
);
}