@react-navigation/stack#StackNavigationProp TypeScript Examples

The following examples show how to use @react-navigation/stack#StackNavigationProp. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocationService.ts    From hamagen-react-native with MIT License 6 votes vote down vote up
goToFilterDrivingIfNeeded = async (navigation: StackNavigationProp<any>) => {
  try {
    const res = await checkMotionPermissions();

    if (res === RESULTS.BLOCKED || res === RESULTS.GRANTED || res === RESULTS.UNAVAILABLE) {
      return;
    }

    const motionPermissionCTA = JSON.parse(await AsyncStorage.getItem(MOTION_PERMISSION_CALL_TO_ACTION) || 'false');

    if (!motionPermissionCTA || ((motionPermissionCTA.tries < 5) && (moment(motionPermissionCTA.lastTry).diff(moment(), 'days') > 5))) {
      navigation.navigate('FilterDriving');
    }
  } catch (error) {
    onError({ error });
  }
}
Example #2
Source File: modal-close.tsx    From protect-scotland with Apache License 2.0 6 votes vote down vote up
ModalClose: FC<ModalCloseProps> = ({
  onPress,
  notification = false,
  icon
}) => {
  const navigation = useNavigation<StackNavigationProp<any>>();
  const {t} = useTranslation();

  const handlePress = () => (onPress ? onPress() : navigation.pop());

  return (
    <TouchableWithoutFeedback onPress={handlePress} accessibilityRole="button">
      <Image
        source={icon || CloseIcon}
        accessibilityIgnoresInvertColors={false}
        accessibilityLabel={t('common:close:label')}
        accessibilityHint={
          notification
            ? t('common:close:notification:hint')
            : t('common:close:hint')
        }
      />
    </TouchableWithoutFeedback>
  );
}
Example #3
Source File: calculator.tsx    From protect-scotland with Apache License 2.0 6 votes vote down vote up
CalculatorModal: FC<CalculatorModalProps> = () => {
  const {t} = useTranslation();
  const insets = useSafeArea();
  const navigation = useNavigation<StackNavigationProp<any>>();

  return (
    <ScrollView
      keyboardShouldPersistTaps="always"
      style={styles.container}
      contentContainerStyle={[
        styles.contentContainer,
        {paddingBottom: insets.bottom + SPACING_BOTTOM}
      ]}>
      <ModalHeader
        heading="calculator:heading"
        color="amber"
        onClosePress={() => navigation.goBack()}
      />
      <View style={styles.top}>
        <Illustration
          source={CalculatorIllustration}
          accessibilityIgnoresInvertColors={false}
          accessibilityHint={t('calculator:illustrationAlt')}
          accessibilityLabel={t('calculator:illustrationAlt')}
        />
        <Markdown markdownStyles={markdownStyles}>
          {t('calculator:body')}
        </Markdown>
        <Spacing s={18} />
        <Text style={styles.highlight}>{t('calculator:highlight')}</Text>
        <Spacing s={50} />
      </View>
    </ScrollView>
  );
}
Example #4
Source File: loginPrompt.ts    From magento_react_native_graphql with MIT License 6 votes vote down vote up
showLoginPrompt = (
  message: string,
  navigation: StackNavigationProp<AppStackParamList>,
): void => {
  Alert.alert(
    translate('common.dearUser'),
    message,
    [
      {
        text: translate('common.login'),
        onPress: () =>
          navigation.navigate(
            Routes.NAVIGATION_TO_AUTHENTICATION_SPLASH_SCREEN,
            { screen: Routes.NAVIGATION_TO_LOGIN_SCREEN },
          ),
      },
      {
        text: translate('common.signup'),
        onPress: () =>
          navigation.navigate(
            Routes.NAVIGATION_TO_AUTHENTICATION_SPLASH_SCREEN,
            { screen: Routes.NAVIGATION_TO_SIGNUP_SCREEN },
          ),
      },
    ],
    { cancelable: true },
  );
}
Example #5
Source File: DeepLinkService.ts    From hamagen-react-native with MIT License 5 votes vote down vote up
onOpenedFromDeepLink = (url: string, navigation: StackNavigationProp<any>) => {
  const { token } = parseQueryParamsFromUrlScheme(url);

  if (token) {
    return navigation.navigate('ShareLocations', { token });
  }
}
Example #6
Source File: types.ts    From rn-clean-architecture-template with MIT License 5 votes vote down vote up
NavigationProps = StackNavigationProp<
  ParamsType,
  '{{name}}'
>;
Example #7
Source File: __name__.type.ts    From rn-clean-architecture-template with MIT License 5 votes vote down vote up
NavigationProps = StackNavigationProp<ParamsType, '{{$name}}'>;