forked from callstack/react-native-paper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppbarBackAction.js
84 lines (76 loc) · 1.92 KB
/
AppbarBackAction.js
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
/* @flow */
import * as React from 'react';
import { View, Image, I18nManager, StyleSheet, Platform } from 'react-native';
import AppbarAction from './AppbarAction';
type Props = React.ElementConfig<typeof AppbarAction> & {|
/**
* Custom color for back icon.
*/
color?: string,
/**
* Optional icon size.
*/
size?: number,
/**
* Whether the button is disabled. A disabled button is greyed out and `onPress` is not called on touch.
*/
disabled?: boolean,
/**
* Accessibility label for the button. This is read by the screen reader when the user taps the button.
*/
accessibilityLabel?: string,
/**
* Function to execute on press.
*/
onPress?: () => mixed,
style?: any,
|};
/**
* A component used to display a back button in the appbar.
*/
class AppbarBackAction extends React.Component<Props> {
static displayName = 'Appbar.BackAction';
static defaultProps = {
accessibilityLabel: 'Back',
};
render() {
return (
<AppbarAction
{...this.props}
icon={
Platform.OS === 'ios'
? ({ size, color }) => (
<View
style={[
styles.wrapper,
{
width: size,
height: size,
transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
},
]}
>
<Image
source={require('../../assets/back-chevron.png')}
style={[styles.icon, { tintColor: color }]}
/>
</View>
)
: { source: 'arrow-back', direction: 'auto' }
}
/>
);
}
}
const styles = StyleSheet.create({
wrapper: {
alignItems: 'center',
justifyContent: 'center',
},
icon: {
height: 21,
width: 21,
resizeMode: 'contain',
},
});
export default AppbarBackAction;