Skip to content
This repository has been archived by the owner on Feb 25, 2020. It is now read-only.

Commit

Permalink
fix: fix types for navigationConfig
Browse files Browse the repository at this point in the history
closes #211, #222
  • Loading branch information
satya164 committed Sep 30, 2019
1 parent 5cbb835 commit 1fc659d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
6 changes: 4 additions & 2 deletions src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export type HeaderLayoutPreset = 'left' | 'center';

export type HeaderTransitionPreset = 'fade-in-place' | 'uikit';

export type HeaderBackgroundTransitionPreset = 'translate' | 'fade';
export type HeaderBackgroundTransitionPreset = 'translate' | 'fade' | 'toggle';

export type HeaderProps = {
mode: HeaderMode;
Expand Down Expand Up @@ -142,15 +142,17 @@ export type NavigationStackConfig = {
headerBackgroundTransitionPreset?: HeaderBackgroundTransitionPreset;
headerBackTitleVisible?: boolean;
disableKeyboardHandling?: boolean;
transparentCard?: boolean;
cardShadowEnabled?: boolean;
cardOverlayEnabled?: boolean;
cardStyle?: StyleProp<ViewStyle>;
onTransitionStart?: () => void;
onTransitionEnd?: () => void;
transitionConfig?: (
transitionProps: TransitionProps,
prevTransitionProps?: TransitionProps,
isModal?: boolean
) => HeaderTransitionConfig;
) => TransitionConfig;
};

export type NavigationStackScreenProps<
Expand Down
2 changes: 1 addition & 1 deletion src/views/StackView/StackView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class StackView extends React.Component<Props> {
return (
<StackViewLayout
{...navigationConfig}
shadowEnabled={this.getShadowEnabled()}
cardShadowEnabled={this.getShadowEnabled()}
cardOverlayEnabled={this.getCardOverlayEnabled()}
onGestureBegin={this.props.onGestureBegin}
onGestureCanceled={this.props.onGestureCanceled}
Expand Down
21 changes: 6 additions & 15 deletions src/views/StackView/StackViewLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
I18nManager,
Easing,
Dimensions,
StyleProp,
ViewStyle,
LayoutChangeEvent,
} from 'react-native';
Expand Down Expand Up @@ -42,27 +41,18 @@ import {
TransitionConfig,
HeaderTransitionConfig,
HeaderProps,
NavigationStackConfig,
} from '../../types';

type Props = {
mode?: 'modal' | 'card';
headerMode?: 'screen' | 'float' | 'none';
headerLayoutPreset?: 'left' | 'center';
headerTransitionPreset?: 'fade-in-place' | 'uikit';
headerBackgroundTransitionPreset?: 'fade' | 'translate' | 'toggle';
headerBackTitleVisible?: boolean;
type Props = NavigationStackConfig & {
isLandscape: boolean;
shadowEnabled?: boolean;
cardOverlayEnabled?: boolean;
transparentCard?: boolean;
cardStyle?: StyleProp<ViewStyle>;
transitionProps: TransitionProps;
lastTransitionProps?: TransitionProps;
transitionConfig?: (
transitionProps: TransitionProps,
prevTransitionProps?: TransitionProps,
isModal?: boolean
) => HeaderTransitionConfig;
) => TransitionConfig;
onGestureBegin?: () => void;
onGestureEnd?: () => void;
onGestureCanceled?: () => void;
Expand Down Expand Up @@ -137,6 +127,7 @@ const getDefaultHeaderHeight = (isLandscape: boolean) => {

class StackViewLayout extends React.Component<Props, State> {
static contextType = ThemeContext;

context!: React.ContextType<typeof ThemeContext>;

private panGestureRef: React.RefObject<PanGestureHandler>;
Expand Down Expand Up @@ -945,7 +936,7 @@ class StackViewLayout extends React.Component<Props, State> {
private renderCard = (scene: Scene) => {
const {
transitionProps,
shadowEnabled,
cardShadowEnabled,
cardOverlayEnabled,
transparentCard,
cardStyle,
Expand All @@ -956,7 +947,7 @@ class StackViewLayout extends React.Component<Props, State> {
screenInterpolator &&
screenInterpolator({
...transitionProps,
shadowEnabled,
shadowEnabled: cardShadowEnabled,
cardOverlayEnabled,
position: this.position,
scene,
Expand Down

0 comments on commit 1fc659d

Please sign in to comment.