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

top-bar-nav

v1.2.2

Published

A top bar navigator for React Native that is super light, simple, and customizable.

Downloads

318

Readme

top-bar-nav

A top bar navigator for React Native that is super light, simple, and customizable.

Install

npm install --save top-bar-nav

Import

import TopBarNav from 'top-bar-nav';

Usage

import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import TopBarNav from './TopBarNav';

const Scene = ({ index }) => (
	<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
		<Text style={{ fontSize: 20 }}>{index}</Text>
	</View>
);

const ROUTES = {
	Scene
	// ideally you would have a ROUTES object with multiple React component scenes
};

// There are three types of labels (image, text, and element)
const ROUTESTACK = [
	{ image: require('./search.png'), title: 'Scene' },
	{ text: 'Hello', title: 'Scene' }, // title is just the name of the Component being rendered.  See the renderScene property below
	{ element: <Text>World</Text>, title: 'Scene' }
];

export default class Example extends React.Component {
	render() {
		return (
			<View style={{ flex: 1 }}>
				<TopBarNav
					// routeStack and renderScene are required props
					routeStack={ROUTESTACK}
					renderScene={(route, i) => {
						// This is a lot like the now deprecated Navigator component
						let Component = ROUTES[route.title];
						return <Component index={i} />;
					}}
					// Below are optional props
					headerStyle={[styles.headerStyle, { paddingTop: 30 }]} // probably want to add paddingTop if using TopBarNav for the  entire height of screen to account for notches/status bars
					labelStyle={styles.labelStyle}
					underlineStyle={styles.underlineStyle}
					imageStyle={styles.imageStyle}
					sidePadding={40} // Can't set sidePadding in headerStyle because it's needed to calculate the width of the tabs
					inactiveOpacity={1}
					fadeLabels={true}
				/>
			</View>
		);
	}

	anotherRender() {
		// if rendering the nav bar at the bottom is your thing
		return (
			<View style={{ flex: 1 }}>
				<View style={{ flex: 1, transform: [{ scaleY: -1 }] }}>
					<TopBarNav
						// routeStack and renderScene are required props
						routeStack={ROUTESTACK}
						renderScene={(route, i) => {
							// This is a lot like the now deprecated Navigator component
							let Component = ROUTES[route.title];
							return (
								<View style={{ flex: 1, transform: [{ scaleY: -1 }] }}>
									<Component index={i} />
								</View>
							);
						}}
						// Below are optional props
						headerStyle={{ paddingTop: 20, transform: [{ scaleY: -1 }] }} // probably want to add paddingTop: 20 if using TopBarNav for the  entire height of screen on iOS
						underlineStyle={{ height: 3 }}
					/>
				</View>
			</View>
		);
	}
}

const styles = StyleSheet.create({
	headerStyle: {
		borderBottomWidth: 1,
		borderColor: '#e6faff',
		backgroundColor: '#3385ff'
	},
	labelStyle: {
		fontSize: 15,
		fontWeight: '500',
		color: '#fff'
	},
	imageStyle: {
		height: 20,
		width: 20,
		tintColor: '#e6faff'
	},
	underlineStyle: {
		height: 3.6,
		backgroundColor: '#e6faff',
		width: 40
	}
});

Demo

Props

static propTypes = {
	routeStack: PropTypes.array.isRequired,
	initialIndex: PropTypes.number,
	renderScene: PropTypes.func,
	headerStyle: stylePropType,
	textStyle: stylePropType,
	imageStyle: stylePropType,
	underlineStyle: stylePropType,
	sidePadding: PropTypes.number,
	inactiveOpacity: PropTypes.number,
	fadeLabels: PropTypes.bool,
	scrollViewProps: PropTypes.object
};

static defaultProps = {
	initialIndex: 0,
	sidePadding: 0,
	inactiveOpacity: 0.5,
	fadeLabels: false,
	scrollViewProps: {}
};