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-quick-menu

v1.0.0

Published

A react-native interface for Touch 3D home screen quick actions

Downloads

4

Readme

React Native Quick Menu

Support for the new 3D Touch home screen quick actions for your React Native apps!

Please note that on Android if android:launchMode is set to default value standard in AndroidManifest.xml, the app will be re-created each time when app is being brought back from background and it won't receive quickActionShortcut event from DeviceEventEmitter, instead popInitialAction will be receiving the app shortcut event.

This project currently supports iOS 9+ and Android 7

Supported React Native Versions

| React Native version(s) | Supporting react-native-quick-actions version(s) | |-------------------------|--------------------------------------------------| | < v0.40 | v0.1.5 | | v0.40+ | v0.2.0+ |

Installing

First cd into your project's directory and grab the latest version of this code:

$ npm install react-native-quick-actions --save

Usage

Linking the Library for iOS

In order to use quick actions you must first link the library to your project. There's excellent documentation on how to do this in the React Native Docs. Make sure you do all steps including #3

Lastly, add the following lines to your AppDelegate.m file:

#import "RNQuickActionManager.h"

// @implementation AppDelegate

- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded)) completionHandler {
  [RNQuickActionManager onQuickActionPress:shortcutItem completionHandler:completionHandler];
}

// @end

Linking the Library for Android

First, add the following line in settings.gradle

include ':app',
        ':react-native-quick-actions'

project(':react-native-quick-actions').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-quick-actions/android')

Secondly, add the following line in app build.gradle

dependencies {
    ...
    compile project(':react-native-quick-actions')
}

Lastly, add the following lines in your main Application

import com.reactNativeQuickActions.AppShortcutsPackage;

protected List<ReactPackage> getPackages() {
    return Arrays.asList(
        ...
        new AppShortcutsPackage()
    );
}

Adding static quick actions - iOS only

This part is pretty easy. There are a bunch of tutorials and docs out there that go over all your options, but here is the quick and dirty version:

Add these entries into to your Info.plist file and replace the generic stuff (Action Title, .action, etc):

<key>UIApplicationShortcutItems</key>
<array>
  <dict>
    <key>UIApplicationShortcutItemIconType</key>
    <string>UIApplicationShortcutIconTypeLocation</string>
    <key>UIApplicationShortcutItemTitle</key>
    <string>Action Title</string>
    <key>UIApplicationShortcutItemType</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER).action</string>
  </dict>
</array>

A full list of available icons can be found here:

https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIApplicationShortcutIcon_Class/index.html#//apple_ref/c/tdef/UIApplicationShortcutIconType

Adding dynamic quick actions

In order to add / remove dynamic actions during application lifecycle, you need to require react-native-quick-actions and call either setShortcutItems or clearShortcutItems (useful when user is logging out).

var QuickActions = require('react-native-quick-actions');

// Add few actions
QuickActions.setShortcutItems([
  {
    type: "Orders", // Required
    title: "See your orders", // Optional, if empty, `type` will be used instead
    subtitle: "See orders you've made",
    icon: "Compose", // Pass any of UIApplicationShortcutIconType<name>
    userInfo: {
      url: "app://orders" // provide custom data, like in-app url you want to open
    }
  }
]);

// Clear them all
QuickActions.clearShortcutItems();

In order to specify icon for your shortcut item, either include UIApplicationShortcutIconType<name>, e.g. for UIApplicationShortcutIconTypeCompose go with Compose or define your asset name if you want to use image from a template (e.g. my-custom-icon if that's the name of image in Images.xcassets. Remember not to name your custom icons the same as any system icons otherwise system ones will be loaded instead).

Full list of available icons has been already listed in the previous section.

Listening for quick actions in your javascript code

First, you'll need to make sure DeviceEventEmitter is added to the list of requires for React.

var React = require('react-native');
var {
  //....things you need plus....
  DeviceEventEmitter
} = React;

Use DeviceEventEmitter to listen for quickActionShortcut messages.

var subscription = DeviceEventEmitter.addListener(
  'quickActionShortcut', function(data) {
    console.log(data.title);
    console.log(data.type);
    console.log(data.userInfo);
  });

To get any actions sent when the app is cold-launched using the following code:

var QuickActions = require('react-native-quick-actions');

QuickActions.popInitialAction().then(doSomethingWithTheAction).catch(console.error)

Check if 3D Touch is supported

The following function will alert you if the user's device supports 3D Touch. Please note this project currently only supports iOS 9+ which means this code will not work on iOS devices running versions < 9.0.

var QuickActions = require('react-native-quick-actions');

QuickActions.isSupported(function(error, supported) {
  if (!supported) {
    console.log('Device does not support 3D Touch or 3D Touch is disabled.');
  }
});

License

Copyright (c) 2015 Jordan Byron (http://github.com/jordanbyron/)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.