1 | function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2 |
|
3 | import * as React from 'react';
|
4 | import { Platform, StyleSheet, TouchableWithoutFeedback, View } from 'react-native';
|
5 | import color from 'color';
|
6 | import Text from '../Typography/Text';
|
7 | import { withTheme } from '../../core/theming';
|
8 | import { white } from '../../styles/colors';
|
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 | const AppbarContent = _ref => {
|
34 | let {
|
35 | color: titleColor = white,
|
36 | subtitle,
|
37 | subtitleStyle,
|
38 | onPress,
|
39 | style,
|
40 | titleRef,
|
41 | titleStyle,
|
42 | theme,
|
43 | title,
|
44 | ...rest
|
45 | } = _ref;
|
46 | const {
|
47 | fonts
|
48 | } = theme;
|
49 | const subtitleColor = color(titleColor).alpha(0.7).rgb().string();
|
50 | return React.createElement(TouchableWithoutFeedback, {
|
51 | onPress: onPress,
|
52 | disabled: !onPress
|
53 | }, React.createElement(View, _extends({
|
54 | style: [styles.container, style]
|
55 | }, rest), React.createElement(Text, {
|
56 | ref: titleRef,
|
57 | style: [{
|
58 | color: titleColor,
|
59 | ...(Platform.OS === 'ios' ? fonts.regular : fonts.medium)
|
60 | }, styles.title, titleStyle],
|
61 | numberOfLines: 1,
|
62 | accessible: true,
|
63 | accessibilityTraits: "header"
|
64 | ,
|
65 | accessibilityRole: Platform.OS === 'web' ? 'heading' : 'header'
|
66 | }, title), subtitle ? React.createElement(Text, {
|
67 | style: [styles.subtitle, {
|
68 | color: subtitleColor
|
69 | }, subtitleStyle],
|
70 | numberOfLines: 1
|
71 | }, subtitle) : null));
|
72 | };
|
73 |
|
74 | AppbarContent.displayName = 'Appbar.Content';
|
75 | const styles = StyleSheet.create({
|
76 | container: {
|
77 | flex: 1,
|
78 | paddingHorizontal: 12
|
79 | },
|
80 | title: {
|
81 | fontSize: Platform.OS === 'ios' ? 17 : 20
|
82 | },
|
83 | subtitle: {
|
84 | fontSize: Platform.OS === 'ios' ? 11 : 14
|
85 | }
|
86 | });
|
87 | export default withTheme(AppbarContent);
|
88 |
|
89 | const AppbarContentWithTheme = withTheme(AppbarContent);
|
90 |
|
91 | export { AppbarContentWithTheme as AppbarContent };
|
92 |
|
\ | No newline at end of file |