Compare commits

..

2 Commits

Author SHA1 Message Date
Satyajit Sahoo
358d9e9feb chore: publish
- @react-navigation/bottom-tabs@5.2.1
 - @react-navigation/compat@5.1.3
 - @react-navigation/drawer@5.3.0
 - @react-navigation/material-bottom-tabs@5.1.3
 - @react-navigation/material-top-tabs@5.1.3
 - @react-navigation/native@5.1.0
 - @react-navigation/stack@5.2.1
2020-03-17 14:37:21 +01:00
Satyajit Sahoo
6a5d0a035a feat: add permanent drawer type (#7818)
Co-authored-by: NoemiRozpara <nrozpara@gmail.com>
2020-03-17 14:11:00 +01:00
19 changed files with 169 additions and 57 deletions

View File

@@ -6,6 +6,8 @@ import {
Platform, Platform,
StatusBar, StatusBar,
I18nManager, I18nManager,
Dimensions,
ScaledSize,
} from 'react-native'; } from 'react-native';
// eslint-disable-next-line import/no-unresolved // eslint-disable-next-line import/no-unresolved
import { enableScreens } from 'react-native-screens'; import { enableScreens } from 'react-native-screens';
@@ -196,10 +198,24 @@ export default function App() {
}; };
}, [theme.colors, theme.dark]); }, [theme.colors, theme.dark]);
const [dimensions, setDimensions] = React.useState(Dimensions.get('window'));
React.useEffect(() => {
const onDimensionsChange = ({ window }: { window: ScaledSize }) => {
setDimensions(window);
};
Dimensions.addEventListener('change', onDimensionsChange);
return () => Dimensions.removeEventListener('change', onDimensionsChange);
}, []);
if (!isReady) { if (!isReady) {
return null; return null;
} }
const isLargeScreen = dimensions.width > 900;
return ( return (
<PaperProvider theme={paperTheme}> <PaperProvider theme={paperTheme}>
{Platform.OS === 'ios' && ( {Platform.OS === 'ios' && (
@@ -216,7 +232,7 @@ export default function App() {
} }
theme={theme} theme={theme}
> >
<Drawer.Navigator> <Drawer.Navigator drawerType={isLargeScreen ? 'permanent' : undefined}>
<Drawer.Screen <Drawer.Screen
name="Root" name="Root"
options={{ options={{
@@ -240,7 +256,9 @@ export default function App() {
name="Home" name="Home"
options={{ options={{
title: 'Examples', title: 'Examples',
headerLeft: () => ( headerLeft: isLargeScreen
? undefined
: () => (
<Appbar.Action <Appbar.Action
color={theme.colors.text} color={theme.colors.text}
icon="menu" icon="menu"

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.2.1](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/compare/@react-navigation/bottom-tabs@5.2.0...@react-navigation/bottom-tabs@5.2.1) (2020-03-17)
**Note:** Version bump only for package @react-navigation/bottom-tabs
# [5.2.0](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/compare/@react-navigation/bottom-tabs@5.1.1...@react-navigation/bottom-tabs@5.2.0) (2020-03-16) # [5.2.0](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/compare/@react-navigation/bottom-tabs@5.1.1...@react-navigation/bottom-tabs@5.2.0) (2020-03-16)

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/bottom-tabs", "name": "@react-navigation/bottom-tabs",
"description": "Bottom tab navigator following iOS design guidelines", "description": "Bottom tab navigator following iOS design guidelines",
"version": "5.2.0", "version": "5.2.1",
"keywords": [ "keywords": [
"react-native-component", "react-native-component",
"react-component", "react-component",
@@ -35,7 +35,7 @@
}, },
"devDependencies": { "devDependencies": {
"@react-native-community/bob": "^0.10.0", "@react-native-community/bob": "^0.10.0",
"@react-navigation/native": "^5.0.10", "@react-navigation/native": "^5.1.0",
"@types/color": "^3.0.1", "@types/color": "^3.0.1",
"@types/react": "^16.9.23", "@types/react": "^16.9.23",
"@types/react-native": "^0.61.22", "@types/react-native": "^0.61.22",

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.1.3](https://github.com/react-navigation/react-navigation/tree/master/packages/compat/compare/@react-navigation/compat@5.1.2...@react-navigation/compat@5.1.3) (2020-03-17)
**Note:** Version bump only for package @react-navigation/compat
## [5.1.2](https://github.com/react-navigation/react-navigation/tree/master/packages/compat/compare/@react-navigation/compat@5.1.1...@react-navigation/compat@5.1.2) (2020-03-16) ## [5.1.2](https://github.com/react-navigation/react-navigation/tree/master/packages/compat/compare/@react-navigation/compat@5.1.1...@react-navigation/compat@5.1.2) (2020-03-16)
**Note:** Version bump only for package @react-navigation/compat **Note:** Version bump only for package @react-navigation/compat

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/compat", "name": "@react-navigation/compat",
"description": "Compatibility layer to write navigator definitions in static configuration format", "description": "Compatibility layer to write navigator definitions in static configuration format",
"version": "5.1.2", "version": "5.1.3",
"license": "MIT", "license": "MIT",
"repository": "https://github.com/react-navigation/react-navigation/tree/master/packages/compat", "repository": "https://github.com/react-navigation/react-navigation/tree/master/packages/compat",
"bugs": { "bugs": {
@@ -26,7 +26,7 @@
}, },
"devDependencies": { "devDependencies": {
"@react-native-community/bob": "^0.10.0", "@react-native-community/bob": "^0.10.0",
"@react-navigation/native": "^5.0.10", "@react-navigation/native": "^5.1.0",
"@types/react": "^16.9.23", "@types/react": "^16.9.23",
"react": "~16.9.0", "react": "~16.9.0",
"typescript": "^3.7.5" "typescript": "^3.7.5"

View File

@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [5.3.0](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/compare/@react-navigation/drawer@5.2.0...@react-navigation/drawer@5.3.0) (2020-03-17)
### Features
* add permanent drawer type ([#7818](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/issues/7818)) ([6a5d0a0](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/commit/6a5d0a035afae60d91aef78401ec8826295746fe))
# [5.2.0](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/compare/@react-navigation/drawer@5.1.1...@react-navigation/drawer@5.2.0) (2020-03-16) # [5.2.0](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/compare/@react-navigation/drawer@5.1.1...@react-navigation/drawer@5.2.0) (2020-03-16)

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/drawer", "name": "@react-navigation/drawer",
"description": "Drawer navigator component with animated transitions and gesturess", "description": "Drawer navigator component with animated transitions and gesturess",
"version": "5.2.0", "version": "5.3.0",
"keywords": [ "keywords": [
"react-native-component", "react-native-component",
"react-component", "react-component",
@@ -40,7 +40,7 @@
}, },
"devDependencies": { "devDependencies": {
"@react-native-community/bob": "^0.10.0", "@react-native-community/bob": "^0.10.0",
"@react-navigation/native": "^5.0.10", "@react-navigation/native": "^5.1.0",
"@types/react": "^16.9.23", "@types/react": "^16.9.23",
"@types/react-native": "^0.61.22", "@types/react-native": "^0.61.22",
"del-cli": "^3.0.0", "del-cli": "^3.0.0",

View File

@@ -27,8 +27,9 @@ export type DrawerNavigationConfig<T = DrawerContentOptions> = {
* - `front`: Traditional drawer which covers the screen with a overlay behind it. * - `front`: Traditional drawer which covers the screen with a overlay behind it.
* - `back`: The drawer is revealed behind the screen on swipe. * - `back`: The drawer is revealed behind the screen on swipe.
* - `slide`: Both the screen and the drawer slide on swipe to reveal the drawer. * - `slide`: Both the screen and the drawer slide on swipe to reveal the drawer.
* - `permanent`: A permanent drawer is shown as a sidebar.
*/ */
drawerType?: 'front' | 'back' | 'slide'; drawerType?: 'front' | 'back' | 'slide' | 'permanent';
/** /**
* How far from the edge of the screen the swipe gesture should activate. * How far from the edge of the screen the swipe gesture should activate.
*/ */

View File

@@ -69,6 +69,8 @@ const SPRING_CONFIG = {
restSpeedThreshold: 0.01, restSpeedThreshold: 0.01,
}; };
const ANIMATED_ONE = new Animated.Value(1);
type Binary = 0 | 1; type Binary = 0 | 1;
type Renderer = (props: { progress: Animated.Node<number> }) => React.ReactNode; type Renderer = (props: { progress: Animated.Node<number> }) => React.ReactNode;
@@ -80,7 +82,7 @@ type Props = {
onGestureRef?: (ref: PanGestureHandler | null) => void; onGestureRef?: (ref: PanGestureHandler | null) => void;
gestureEnabled: boolean; gestureEnabled: boolean;
drawerPosition: 'left' | 'right'; drawerPosition: 'left' | 'right';
drawerType: 'front' | 'back' | 'slide'; drawerType: 'front' | 'back' | 'slide' | 'permanent';
keyboardDismissMode: 'none' | 'on-drag'; keyboardDismissMode: 'none' | 'on-drag';
swipeEdgeWidth: number; swipeEdgeWidth: number;
swipeDistanceThreshold?: number; swipeDistanceThreshold?: number;
@@ -545,6 +547,7 @@ export default class DrawerView extends React.PureComponent<Props> {
gestureHandlerProps, gestureHandlerProps,
} = this.props; } = this.props;
const isOpen = drawerType === 'permanent' ? true : open;
const isRight = drawerPosition === 'right'; const isRight = drawerPosition === 'right';
const contentTranslateX = drawerType === 'front' ? 0 : this.translateX; const contentTranslateX = drawerType === 'front' ? 0 : this.translateX;
@@ -570,8 +573,10 @@ export default class DrawerView extends React.PureComponent<Props> {
const hitSlop = isRight const hitSlop = isRight
? // Extend hitSlop to the side of the screen when drawer is closed ? // Extend hitSlop to the side of the screen when drawer is closed
// This lets the user drag the drawer from the side of the screen // This lets the user drag the drawer from the side of the screen
{ right: 0, width: open ? undefined : swipeEdgeWidth } { right: 0, width: isOpen ? undefined : swipeEdgeWidth }
: { left: 0, width: open ? undefined : swipeEdgeWidth }; : { left: 0, width: isOpen ? undefined : swipeEdgeWidth };
const progress = drawerType === 'permanent' ? ANIMATED_ONE : this.progress;
return ( return (
<PanGestureHandler <PanGestureHandler
@@ -581,36 +586,47 @@ export default class DrawerView extends React.PureComponent<Props> {
onGestureEvent={this.handleGestureEvent} onGestureEvent={this.handleGestureEvent}
onHandlerStateChange={this.handleGestureStateChange} onHandlerStateChange={this.handleGestureStateChange}
hitSlop={hitSlop} hitSlop={hitSlop}
enabled={gestureEnabled} enabled={drawerType !== 'permanent' && gestureEnabled}
{...gestureHandlerProps} {...gestureHandlerProps}
> >
<Animated.View <Animated.View
onLayout={this.handleContainerLayout} onLayout={this.handleContainerLayout}
style={styles.main} style={[
styles.main,
drawerType === 'permanent' && {
flexDirection: 'row-reverse',
},
]}
> >
<Animated.View <Animated.View
style={[ style={[
styles.content, styles.content,
{ drawerType !== 'permanent' && {
transform: [{ translateX: contentTranslateX }], transform: [{ translateX: contentTranslateX }],
}, },
sceneContainerStyle as any, sceneContainerStyle as any,
]} ]}
> >
<View <View
accessibilityElementsHidden={open} accessibilityElementsHidden={isOpen}
importantForAccessibility={open ? 'no-hide-descendants' : 'auto'} importantForAccessibility={
isOpen ? 'no-hide-descendants' : 'auto'
}
style={styles.content} style={styles.content}
> >
{renderSceneContent({ progress: this.progress })} {renderSceneContent({ progress })}
</View> </View>
{// Disable overlay if sidebar is permanent
drawerType === 'permanent' ? null : (
<TapGestureHandler <TapGestureHandler
enabled={gestureEnabled} enabled={gestureEnabled}
onHandlerStateChange={this.handleTapStateChange} onHandlerStateChange={this.handleTapStateChange}
> >
<Overlay progress={this.progress} style={overlayStyle} /> <Overlay progress={progress} style={overlayStyle} />
</TapGestureHandler> </TapGestureHandler>
)}
</Animated.View> </Animated.View>
{drawerType === 'permanent' ? null : (
<Animated.Code <Animated.Code
exec={block([ exec={block([
onChange(this.manuallyTriggerSpring, [ onChange(this.manuallyTriggerSpring, [
@@ -621,23 +637,32 @@ export default class DrawerView extends React.PureComponent<Props> {
]), ]),
])} ])}
/> />
)}
<Animated.View <Animated.View
accessibilityViewIsModal={open} accessibilityViewIsModal={isOpen}
removeClippedSubviews={Platform.OS !== 'ios'} removeClippedSubviews={Platform.OS !== 'ios'}
onLayout={this.handleDrawerLayout} onLayout={this.handleDrawerLayout}
style={[ style={[
styles.container, styles.container,
isRight ? { right: offset } : { left: offset }, drawerType === 'permanent'
? // Without this, the `left`/`right` values don't get reset
isRight
? { right: 0 }
: { left: 0 }
: [
styles.nonPermanent,
{ {
transform: [{ translateX: drawerTranslateX }], transform: [{ translateX: drawerTranslateX }],
opacity: this.drawerOpacity, opacity: this.drawerOpacity,
zIndex: drawerType === 'back' ? -1 : 0,
}, },
isRight ? { right: offset } : { left: offset },
{ zIndex: drawerType === 'back' ? -1 : 0 },
],
drawerStyle as any, drawerStyle as any,
]} ]}
> >
<DrawerOpenContext.Provider value={open}> <DrawerOpenContext.Provider value={isOpen}>
{renderDrawerContent({ progress: this.progress })} {renderDrawerContent({ progress })}
</DrawerOpenContext.Provider> </DrawerOpenContext.Provider>
</Animated.View> </Animated.View>
</Animated.View> </Animated.View>
@@ -649,11 +674,13 @@ export default class DrawerView extends React.PureComponent<Props> {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
backgroundColor: 'white', backgroundColor: 'white',
maxWidth: '100%',
},
nonPermanent: {
position: 'absolute', position: 'absolute',
top: 0, top: 0,
bottom: 0, bottom: 0,
width: '80%', width: '80%',
maxWidth: '100%',
}, },
content: { content: {
flex: 1, flex: 1,

View File

@@ -221,6 +221,10 @@ export default function DrawerView({
]} ]}
drawerStyle={[ drawerStyle={[
{ width: drawerWidth, backgroundColor: colors.card }, { width: drawerWidth, backgroundColor: colors.card },
drawerType === 'permanent' && {
borderRightColor: colors.border,
borderRightWidth: StyleSheet.hairlineWidth,
},
drawerStyle, drawerStyle,
]} ]}
overlayStyle={{ backgroundColor: overlayColor }} overlayStyle={{ backgroundColor: overlayColor }}

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.1.3](https://github.com/react-navigation/react-navigation/tree/master/packages/material-bottom-tabs/compare/@react-navigation/material-bottom-tabs@5.1.2...@react-navigation/material-bottom-tabs@5.1.3) (2020-03-17)
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
## [5.1.2](https://github.com/react-navigation/react-navigation/tree/master/packages/material-bottom-tabs/compare/@react-navigation/material-bottom-tabs@5.1.1...@react-navigation/material-bottom-tabs@5.1.2) (2020-03-16) ## [5.1.2](https://github.com/react-navigation/react-navigation/tree/master/packages/material-bottom-tabs/compare/@react-navigation/material-bottom-tabs@5.1.1...@react-navigation/material-bottom-tabs@5.1.2) (2020-03-16)
**Note:** Version bump only for package @react-navigation/material-bottom-tabs **Note:** Version bump only for package @react-navigation/material-bottom-tabs

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/material-bottom-tabs", "name": "@react-navigation/material-bottom-tabs",
"description": "Integration for bottom navigation component from react-native-paper", "description": "Integration for bottom navigation component from react-native-paper",
"version": "5.1.2", "version": "5.1.3",
"keywords": [ "keywords": [
"react-native-component", "react-native-component",
"react-component", "react-component",
@@ -36,7 +36,7 @@
}, },
"devDependencies": { "devDependencies": {
"@react-native-community/bob": "^0.10.0", "@react-native-community/bob": "^0.10.0",
"@react-navigation/native": "^5.0.10", "@react-navigation/native": "^5.1.0",
"@types/react": "^16.9.23", "@types/react": "^16.9.23",
"@types/react-native": "^0.61.22", "@types/react-native": "^0.61.22",
"@types/react-native-vector-icons": "^6.4.5", "@types/react-native-vector-icons": "^6.4.5",

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.1.3](https://github.com/react-navigation/react-navigation/tree/master/packages/material-top-tabs/compare/@react-navigation/material-top-tabs@5.1.2...@react-navigation/material-top-tabs@5.1.3) (2020-03-17)
**Note:** Version bump only for package @react-navigation/material-top-tabs
## [5.1.2](https://github.com/react-navigation/react-navigation/tree/master/packages/material-top-tabs/compare/@react-navigation/material-top-tabs@5.1.1...@react-navigation/material-top-tabs@5.1.2) (2020-03-16) ## [5.1.2](https://github.com/react-navigation/react-navigation/tree/master/packages/material-top-tabs/compare/@react-navigation/material-top-tabs@5.1.1...@react-navigation/material-top-tabs@5.1.2) (2020-03-16)
**Note:** Version bump only for package @react-navigation/material-top-tabs **Note:** Version bump only for package @react-navigation/material-top-tabs

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/material-top-tabs", "name": "@react-navigation/material-top-tabs",
"description": "Integration for the animated tab view component from react-native-tab-view", "description": "Integration for the animated tab view component from react-native-tab-view",
"version": "5.1.2", "version": "5.1.3",
"keywords": [ "keywords": [
"react-native-component", "react-native-component",
"react-component", "react-component",
@@ -39,7 +39,7 @@
}, },
"devDependencies": { "devDependencies": {
"@react-native-community/bob": "^0.10.0", "@react-native-community/bob": "^0.10.0",
"@react-navigation/native": "^5.0.10", "@react-navigation/native": "^5.1.0",
"@types/react": "^16.9.23", "@types/react": "^16.9.23",
"@types/react-native": "^0.61.22", "@types/react-native": "^0.61.22",
"del-cli": "^3.0.0", "del-cli": "^3.0.0",

View File

@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [5.1.0](https://github.com/react-navigation/react-navigation/tree/master/packages/native/compare/@react-navigation/native@5.0.10...@react-navigation/native@5.1.0) (2020-03-17)
### Features
* add permanent drawer type ([#7818](https://github.com/react-navigation/react-navigation/tree/master/packages/native/issues/7818)) ([6a5d0a0](https://github.com/react-navigation/react-navigation/tree/master/packages/native/commit/6a5d0a035afae60d91aef78401ec8826295746fe))
## [5.0.10](https://github.com/react-navigation/react-navigation/tree/master/packages/native/compare/@react-navigation/native@5.0.9...@react-navigation/native@5.0.10) (2020-03-16) ## [5.0.10](https://github.com/react-navigation/react-navigation/tree/master/packages/native/compare/@react-navigation/native@5.0.9...@react-navigation/native@5.0.10) (2020-03-16)
**Note:** Version bump only for package @react-navigation/native **Note:** Version bump only for package @react-navigation/native

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/native", "name": "@react-navigation/native",
"description": "React Native integration for React Navigation", "description": "React Native integration for React Navigation",
"version": "5.0.10", "version": "5.1.0",
"keywords": [ "keywords": [
"react-native", "react-native",
"react-navigation", "react-navigation",

View File

@@ -7,7 +7,7 @@ const DefaultTheme: Theme = {
background: 'rgb(242, 242, 242)', background: 'rgb(242, 242, 242)',
card: 'rgb(255, 255, 255)', card: 'rgb(255, 255, 255)',
text: 'rgb(28, 28, 30)', text: 'rgb(28, 28, 30)',
border: 'rgb(199, 199, 204)', border: 'rgb(224, 224, 224)',
}, },
}; };

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.2.1](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/compare/@react-navigation/stack@5.2.0...@react-navigation/stack@5.2.1) (2020-03-17)
**Note:** Version bump only for package @react-navigation/stack
# [5.2.0](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/compare/@react-navigation/stack@5.1.1...@react-navigation/stack@5.2.0) (2020-03-16) # [5.2.0](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/compare/@react-navigation/stack@5.1.1...@react-navigation/stack@5.2.0) (2020-03-16)

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/stack", "name": "@react-navigation/stack",
"description": "Stack navigator component for iOS and Android with animated transitions and gestures", "description": "Stack navigator component for iOS and Android with animated transitions and gestures",
"version": "5.2.0", "version": "5.2.1",
"keywords": [ "keywords": [
"react-native-component", "react-native-component",
"react-component", "react-component",
@@ -40,7 +40,7 @@
"devDependencies": { "devDependencies": {
"@react-native-community/bob": "^0.10.0", "@react-native-community/bob": "^0.10.0",
"@react-native-community/masked-view": "^0.1.7", "@react-native-community/masked-view": "^0.1.7",
"@react-navigation/native": "^5.0.10", "@react-navigation/native": "^5.1.0",
"@types/color": "^3.0.1", "@types/color": "^3.0.1",
"@types/react": "^16.9.23", "@types/react": "^16.9.23",
"@types/react-native": "^0.61.22", "@types/react-native": "^0.61.22",