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

react-native-android-kit

v1.2.1

Published

A set of native Android UI components and modules for React Native framework

Downloads

21

Readme

React Native Android Kit npm version react-native version

A set of native Android UI components and modules for React Native framework. The purpose of this kit is to offer to React Native developers some new Android native components that are currently not implemented by React Native core team. For example, some components from Android Design Support Library are now available through this kit.

Table of Contents

Installation

Automatic

  • [x] Go to your root project folder

  • [x] Install react-native-android-kit from npm repository:

    npm install react-native-android-kit --save
  • [x] Link native dependencies to your project:

    node node_modules/react-native/local-cli/cli.js link react-native-android-kit

    Or, via react-native-cli if installed globally:

    react-native link react-native-android-kit

Manual

To use this kit inside your react native project, you must follow these steps:

  • [x] Go to your root project folder

  • [x] Install react-native-android-kit from npm repository:

    npm install react-native-android-kit --save
  • [x] Add the following lines to your android/settings.gradle:

    include ':ReactNativeAndroidKit'
    project(':ReactNativeAndroidKit').projectDir = file('../node_modules/react-native-android-kit/android')
  • [x] Inside android/app/build.gradle file, add compilation instruction for ReactNativeAndroidKit like that:

    dependencies {
    	...
    	compile project(':ReactNativeAndroidKit')			
    }
  • [x] Finally, edit MainApplication class (generally located at android/app/src/main/java/<main-package-path>/MainApplication.java):

    ...
    
    import com.facebook.react.ReactPackage;
    import com.facebook.react.shell.MainReactPackage;
    import fr.aybadb.rnak.RNAKPackage;	//<------------------------- Add this import statement
    
    ...
    
    public class MainApplication extends Application implements ReactApplication {
      	
    	...
    
    		@Override
    		protected List<ReactPackage> getPackages() {
    			return Arrays.<ReactPackage>asList(
    				new MainReactPackage(),
    				new RNAKPackage()	//<-------------------------- Add this statement
    			);
    		}
    	};
      
    ...

Components

TabLayoutAndroid

Introduction

TabLayoutAndroid component provides a horizontal layout to display tabs. Population of the tabs to display is done through TabLayoutAndroid.Item component. Transition between tabs are managed by a ViewPager instance (you don't need to care about it: all is managed by TabLayoutAndroid component). For more details, see: Native TabLayout documentation

Props:

TabLayoutAndroid props:

It is important all children of TabLayoutAndroid are TabLayoutAndroid.Item component(s) and not composite components:

View props... ViewPagerAndroid props... backgroundColor color optional Sets the background color for TabLayout container. indicatorTabColor color optional Sets the tab indicator's color for the currently selected tab. indicatorTabHeight number optional Sets the tab indicator's height for the currently selected tab. scrollable boolean optional, default = true Set the behavior mode for the Tabs in this layout: true = SCROLLABLE tabs mode. false = FIXED tabs mode. backgroundImage string optional Set the background's TabLayout to a given Drawable (see Drawable). center boolean optional, default = true Set the gravity to use when laying out the tabs: true = CENTER tabs gravity (only takes effect if you are on FIXED tabs Mode).false = FILL tabs gravity.

By default, 60 is the height value for tabs container.

TabLayoutAndroid.Item props:

TabLayoutAndroid.Item represents a child for TabLayoutAndroid (i.e a tab instance). Especially, it's a container that allows you to store child view(s) for current tab instance. In a nutshell, it works like a container but for TabLayoutAndroid.

Besides, each TabLayoutAndroid.Item can be customized by several properties:

View props... text string optional Sets the tab label. icon string optional Sets the tab icon (see Drawable). iconPosition string optional, default = 'top' [only, if customView prop === true] Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text.Allowed values: left, top, right, bottom (if wrong string, top value is set by default). textSize number optional [only, if customView prop === true] Set the default text size to the given value, interpreted as "scaled pixel" unit (sp unit). textColor color optional [only, if customView prop === true] Sets the text color for the normal state. selectedTextColor color optional [only, if customView prop === true] Sets the text color for the selected state. customView boolean optional, default = true Sets custom view behavior for current tab.true = Custom View enabled.false = Custom View disabled: only, text and icon properties take effect.

Example

Basic Usage:
import React, { AppRegistry, StyleSheet, Text, View } from "react-native";
import { TabLayoutAndroid } from "react-native-android-kit";

class TabLayoutExample extends React.Component {
	render() {
		return (
			<View style={{flex:1}}>
			
				<TabLayoutAndroid style={{height:60}} backgroundColor='#009688' indicatorTabColor='#ffc400'
								  indicatorTabHeight={2} scrollable={false} center={false}>

					<TabLayoutAndroid.Item text='Tab1' textSize={16} textColor="white" selectedTextColor='#ffc400'
								icon='ic_home_black_24dp' iconPosition='left'>
						
						<Text>I'm the first Tab content!</Text>
						
					</TabLayoutAndroid.Item>
					
					<TabLayoutAndroid.Item text='Tab2' textSize={16} textColor='white' selectedTextColor='#ffc400'
								icon='ic_important_devices_black_24dp' iconPosition='left'>
						
						<Text>I'm the second Tab content!</Text>
						
					</TabLayoutAndroid.Item>

				</TabLayoutAndroid>
				
			</View>
		);
	}
}
Demonstration:

ButtonAndroid

Important Note: Since 0.37 react-native release, you can use <Button /> as a cross native component between Android and iOS. I recommend you to use it instead of this <ButtonAndroid /> component.

Introduction

Represents a push-button widget. Push-buttons can be pressed, or clicked, by the user to perform an action. For more details, see: Native Button documentation

Props:

View props... TouchableWithoutFeedback props... text string optional Sets the button label. textSize number optional, default = 15 Set the default text size to the given value, interpreted as "scaled pixel" unit (sp unit). textColor color optional, default = 'black' Sets the text color. backgroundColor color optional Sets the background color.

Example

Basic Usage:
import React, { StyleSheet, View, ToastAndroid } from "react-native";
import { ButtonAndroid } from "react-native-android-kit";

class ButtonExample extends React.Component {
	render() {
		return (
			<View style={{flex:1}}>
				<ButtonAndroid
					textColor='red'
					backgroundColor='#FF009688'
					textSize={12}
					text='Custom Button'
					onPress={
						() => {
							ToastAndroid.show("Event onPress", ToastAndroid.SHORT);
						}
					}
				/>
			</View>
		);
	}
}
Demonstration:

For corresponding code, see Code from demonstration application

FloatingButtonAndroid

Introduction

Floating action buttons are used for a special type of promoted action. They are distinguished by a circled icon floating above the UI. For more details, see: Native FloatingActionButton documentation

Props:

View props... TouchableWithoutFeedback props... icon string optional Sets the button icon (see Drawable). backgroundColor color optional Sets the background color. rippleColor color optional Sets the ripple color. hidden boolean optional, default = false Hides/Shows the button: true = Hides the button.false = Shows the button. rippleEffect boolean optional, default = true Defines whether this view reacts to click by a ripple effect or not: true = Ripple effect enabled.false = Ripple effect disabled.

Example:

Basic Usage:
import React, { StyleSheet, View, ToastAndroid } from "react-native";
import { FloatingButtonAndroid } from "react-native-android-kit";

class FloatingButtonExample extends React.Component {
	render() {
		return (
			<View style={{flex:1}}>
				<FloatingButtonAndroid
					style={[styles.fab,{height:100, width:100}]}
					backgroundColor='#ffff0000'
					rippleColor='black'
					icon='ic_reply_all_black_24dp'
					onPress={
						() => {
							ToastAndroid.show("Event onPress", ToastAndroid.SHORT);
						}
					}
				/>
			</View>
		);
	}
}
Demonstration:

For corresponding code, see Code from demonstration application

Misc

Color

Color value property is set via a string input. Supported formats are: '#RRGGBB' , '#AARRGGBB' or one of the following names: 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray', 'grey', 'lightgrey', 'darkgrey', 'aqua', 'fuchsia', 'lime', 'maroon', 'navy', 'olive', 'purple', 'silver', 'teal'.

Drawable

For now, only static images resources are supported. They must be located inside one of drawable folders (usually located at android/app/src/main/res/drawable or android/app/src/main/res/drawable-XXXXXX if you want to manage icon size according to display format). To target a resource, you only need to specify string basename (i.e. without extension) and it must respect underscored name. For example, if you have an image called toto-tata.png, you must specify 'toto_tata' as a property value.

Demo

If you want an overview of RNAK, it's interesting to try the demonstration code located inside ./example folder.

To build and test this demo, just follow these steps:

  • [x] Connect your device or launch your Android emulator
  • [x] Clone this repository
  • [x] Go to the example folder: cd ./example
  • [x] Install npm dependencies, build and deploy the demonstration application by running: npm install
  • [x] Enjoy RNAK demo on your device/emulator !

Todo

  • [x] TabLayoutAndroid: Homogenize component props and naming with TabBarIOS react-native implementation
  • [x] TabLayoutAndroid: Programmatically set the current active tab

License

MIT