Skip to content

Commit d9a3d77

Browse files
committed
BREAKING: rename Toolbar to Appbar and add Appbar.Header
1 parent 5fc7f33 commit d9a3d77

File tree

18 files changed

+383
-267
lines changed

18 files changed

+383
-267
lines changed
9.55 KB
Loading
18.4 KB
Loading

docs/assets/screenshots/appbar.png

2.37 KB
Loading
-4.99 KB
Binary file not shown.
-3.29 KB
Binary file not shown.

example/src/ToolbarExample.js renamed to example/src/AppbarExample.js

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import * as React from 'react';
44
import { View, Platform, StyleSheet } from 'react-native';
55
import {
66
Colors,
7+
Appbar,
8+
FAB,
79
Switch,
810
Paragraph,
9-
Toolbar,
1011
withTheme,
1112
} from 'react-native-paper';
1213
import type { Theme } from 'react-native-paper/types';
@@ -25,28 +26,28 @@ const initialParams = {
2526

2627
const MORE_ICON = Platform.OS === 'ios' ? 'more-horiz' : 'more-vert';
2728

28-
class ToolbarExample extends React.Component<Props> {
29-
static title = 'Toolbar';
29+
class AppbarExample extends React.Component<Props> {
30+
static title = 'Appbar';
3031
static navigationOptions = ({ navigation }) => {
3132
const params = { ...initialParams, ...navigation.state.params };
3233

3334
return {
3435
header: (
35-
<Toolbar>
36+
<Appbar.Header>
3637
{params.showLeftIcon && (
37-
<Toolbar.BackAction onPress={() => navigation.goBack()} />
38+
<Appbar.BackAction onPress={() => navigation.goBack()} />
3839
)}
39-
<Toolbar.Content
40+
<Appbar.Content
4041
title="Title"
4142
subtitle={params.showSubtitle ? 'Subtitle' : null}
4243
/>
4344
{params.showSearchIcon && (
44-
<Toolbar.Action icon="search" onPress={() => {}} />
45+
<Appbar.Action icon="search" onPress={() => {}} />
4546
)}
4647
{params.showMoreIcon && (
47-
<Toolbar.Action icon={MORE_ICON} onPress={() => {}} />
48+
<Appbar.Action icon={MORE_ICON} onPress={() => {}} />
4849
)}
49-
</Toolbar>
50+
</Appbar.Header>
5051
),
5152
};
5253
};
@@ -113,6 +114,13 @@ class ToolbarExample extends React.Component<Props> {
113114
}
114115
/>
115116
</View>
117+
<Appbar style={styles.bottom}>
118+
<Appbar.Action icon="archive" onPress={() => {}} />
119+
<Appbar.Action icon="mail" onPress={() => {}} />
120+
<Appbar.Action icon="label" onPress={() => {}} />
121+
<Appbar.Action icon="delete" onPress={() => {}} />
122+
</Appbar>
123+
<FAB icon="reply" onPress={() => {}} style={styles.fab} />
116124
</View>
117125
);
118126
}
@@ -131,6 +139,17 @@ const styles = StyleSheet.create({
131139
paddingVertical: 8,
132140
paddingHorizontal: 16,
133141
},
142+
bottom: {
143+
position: 'absolute',
144+
left: 0,
145+
right: 0,
146+
bottom: 0,
147+
},
148+
fab: {
149+
position: 'absolute',
150+
right: 16,
151+
bottom: 28,
152+
},
134153
});
135154

136-
export default withTheme(ToolbarExample);
155+
export default withTheme(AppbarExample);

example/src/ExampleList.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import SurfaceExample from './SurfaceExample';
2323
import SwitchExample from './SwitchExample';
2424
import TextExample from './TextExample';
2525
import TextInputExample from './TextInputExample';
26-
import ToolbarExample from './ToolbarExample';
26+
import AppbarExample from './AppbarExample';
2727
import type { Theme } from 'react-native-paper/types';
2828

2929
type Props = {
@@ -32,6 +32,7 @@ type Props = {
3232
};
3333

3434
export const examples = {
35+
appbar: AppbarExample,
3536
bottomNavigation: BottomNavigationExample,
3637
button: ButtonExample,
3738
card: CardExample,
@@ -52,7 +53,6 @@ export const examples = {
5253
switch: SwitchExample,
5354
text: TextExample,
5455
textInput: TextInputExample,
55-
toolbar: ToolbarExample,
5656
};
5757

5858
const data = Object.keys(examples).map(id => ({ id, data: examples[id] }));

example/src/RootNavigator.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import * as React from 'react';
44
import { createStackNavigator } from 'react-navigation';
5-
import { Toolbar } from 'react-native-paper';
5+
import { Appbar } from 'react-native-paper';
66
import ExampleList, { examples } from './ExampleList';
77

88
const routes = Object.keys(examples)
@@ -13,10 +13,10 @@ const routes = Object.keys(examples)
1313

1414
Screen.navigationOptions = props => ({
1515
header: (
16-
<Toolbar>
17-
<Toolbar.BackAction onPress={() => props.navigation.goBack()} />
18-
<Toolbar.Content title={(Comp: any).title} />
19-
</Toolbar>
16+
<Appbar.Header>
17+
<Appbar.BackAction onPress={() => props.navigation.goBack()} />
18+
<Appbar.Content title={(Comp: any).title} />
19+
</Appbar.Header>
2020
),
2121
/* $FlowFixMe */
2222
...(typeof Comp.navigationOptions === 'function'
@@ -38,10 +38,13 @@ export default createStackNavigator(
3838
{
3939
navigationOptions: ({ navigation }) => ({
4040
header: (
41-
<Toolbar>
42-
<Toolbar.Action icon="menu" onPress={() => navigation.openDrawer()} />
43-
<Toolbar.Content title="Examples" />
44-
</Toolbar>
41+
<Appbar.Header>
42+
<Appbar.Action
43+
icon="menu"
44+
onPress={() => navigation.navigate('DrawerOpen')}
45+
/>
46+
<Appbar.Content title="Examples" />
47+
</Appbar.Header>
4548
),
4649
}),
4750
}

src/babel/__fixtures__/rewrite-imports/code.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
BottomNavigation,
55
Button,
66
FAB,
7-
Toolbar,
7+
Appbar,
88
Colors,
99
NonExistent,
1010
NonExistentSecond as Stuff,

src/babel/__fixtures__/rewrite-imports/output.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import PaperProvider from 'react-native-paper/src/core/Provider';
33
import BottomNavigation from 'react-native-paper/src/components/BottomNavigation';
44
import Button from 'react-native-paper/src/components/Button';
55
import FAB from 'react-native-paper/src/components/FAB/FAB';
6-
import Toolbar from 'react-native-paper/src/components/Toolbar/Toolbar';
6+
import Appbar from 'react-native-paper/src/components/Appbar/Appbar';
77
import * as Colors from 'react-native-paper/src/styles/colors';
88
import { NonExistent, NonExistentSecond as Stuff } from 'react-native-paper';

0 commit comments

Comments
 (0)