npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dark-engine/native-navigation

v1.4.2

Published

Dark navigation for NativeScript platform

Downloads

38

Readme

@dark-engine/native-navigation 🌖

Dark router for NativeScript platform.

More about Dark

Features

  • 📚 Stack navigation
  • 📂 Tab navigation
  • 🎆 Modal navigation
  • 🌳 Nested screens
  • 🔢 Parameters
  • 💃 Animated transitions
  • 📈 Hooks
  • ✂️ No deps

Installation

npm:

npm install @dark-engine/native-navigation

yarn:

yarn add @dark-engine/native-navigation

API

import {
  type NavigationOptions,
  NavigationContainer,
  StackNavigator,
  TabNavigator,
  TransitionName,
  useNavigation,
  VERSION,
} from '@dark-engine/native-navigation';

Usage

In order to use navigation, you need to wrap the application root in a NavigationContainer and pass a defaultPathname to it, which will display the selected screen when the application starts. Inside this container, you must place the selected navigator and describe the collection of screens for navigation. Each screen must have a name and a component to be rendered.

Navigation via StackNavigator

StackNavigator is the main navigation method that implements the logic of changing screens.

import { NavigationContainer, StackNavigator } from '@dark-engine/native-navigation';
const App = component(() => {
  return (
    <NavigationContainer defaultPathname='/Feed'>
      <StackNavigator.Root>
        <StackNavigator.Screen name='Feed' component={Feed} />
        <StackNavigator.Screen name='Friends' component={Friends} />
        <StackNavigator.Screen name='Profile' component={Profile} />
        <StackNavigator.Screen name='Settings' component={Settings} />
      </StackNavigator.Root>
    </NavigationContainer>
  );
});

Navigation via TabNavigator

The TabNavigator is a wrapper around the StackNavigator that displays tab buttons at the bottom to control screens. Using the StackNavigator wrapping approach, you can also implement a navigation strategy through a Drawer or Modal.

import { NavigationContainer, TabNavigator } from '@dark-engine/native-navigation';
const App = component(() => {
  return (
    <NavigationContainer defaultPathname='/Feed'>
      <TabNavigator.Root>
        <TabNavigator.Screen name='Feed' component={Feed} />
        <TabNavigator.Screen name='Friends' component={Friends} />
        <TabNavigator.Screen name='Profile' component={Profile} />
        <TabNavigator.Screen name='Settings' component={Settings} />
      </TabNavigator.Root>
    </NavigationContainer>
  );
});

You can customize Tabs view through passing bottomNavigationOptions to TabNavigator.Root and renderTab to TabNavigator.Screen to render tabs with icons.

Navigating to screen

To navigate to a new screen, you need to use the navigateTo method, which provided by the useNavigation hook.

import { useNavigation } from '@dark-engine/native-navigation';
const { navigateTo } = useNavigation();

return (
  <StackLayout>
    <Button onTap={() => navigateTo('/Dashboard')}>Dashboard</Button>
  </StackLayout>
);

The method supports passing NavigationOptions, which include a parameter for the new screen, as well as a flag to enable support for animated transitions.

import { CoreTypes } from '@nativescript/core';
import { useNavigation, TransitionName } from '@dark-engine/native-navigation';
navigateTo('/Profile', {
  params: { id: 25 },
  animated: true,
  transition: {
    curve: CoreTypes.AnimationCurve.easeInOut,
    name: TransitionName.slide,
    duration: 200,
  }
});

Back navigation

const { goBack } = useNavigation();

return (
  <StackLayout>
    <Button onTap={() => goBack()}>back</Button>
  </StackLayout>
);

Access to params

const { params } = useNavigation();
const id = Number(params.get('id'));

useEffect(() => {
  fetch(`https://jsonplaceholder.typicode.com/albums/${id}`)
    .then(x => x.json())
    .then(x => setAlbum(x));
}, [id]);

Nested screens

You can nest navigators to create nested screens like /Home/Dashboard, /Home/Profile and so on.

const Home = component(() => {
  return (
    <StackLayout height='100%'>
      <StackNavigator.Root>
        <StackNavigator.Screen name='Dashboard' component={Dashboard} />
        <StackNavigator.Screen name='Profile' component={Profile} />
      </StackNavigator.Root>
    </StackLayout>
  );
});

const App = component(() => {
  return (
    <NavigationContainer defaultPathname='/Home/Dashboard'>
      <TabNavigator.Root>
        <TabNavigator.Screen name='Home' component={Home} />
        <TabNavigator.Screen name='Settings' component={Settings} />
        <TabNavigator.Screen name='Contacts' component={Contacts} />
      </TabNavigator.Root>
    </NavigationContainer>
  );
});

LICENSE

MIT © Alex Plex