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-change-icon

v5.0.0

Published

Change application icon programmatically in React-Native.

Downloads

28,001

Readme





  • Just upload your images from earlier, and checkmark both iPhone and Android.
  • This will give you a .zip file with the files needed.

  • You need to rename and sort these files slightly differently for both iOS and Android.

Android 🤖

  1. Simply just rename them to something appropriate - typically this follows the naming convention ic_launcher_<type>.png e.g. ic_launcher_dark.png
    • Make sure to keep them within the folder structure they are in mipmap-hdpi... etc.
  2. Create a single android directory with all the mipmap-* directories inside. Inside them place all your generated icons.

iOS 🍏

  1. You will need the generated folder called AppIcon.appiconset as this contains your icons.
  2. Rename this folder a bit like above for Android using a naming convention such as <type>.appiconset e.g. Dark.appiconset
  3. You will also need to edit the Contents.json to change and references from Assets.xcassets/AppIcon.appiconset to what you have renamed the file now e.g. Images.xcassets/AppIcon.appiconset

Android 🤖

  1. Drag all of the mipmap folders into android/app/src/main/res/

iOS 🍏

  1. Drag all of the .appiconset folders into ios/<app-name>/Images.xcassets

Android 🤖

  1. Add an alias for each of your new icons within the AndroidManifest.xml (within <application>).
    • Make sure these have the properties as shown below.
    • Create an alias for .MainActivityDefault as well but for this, set android:enabled="true".
    • For the name prefix it .MainActivity... followed by the name you will use to reference your icon. e.g. for our light icon we will use .MainActivityLight
  2. You'll have to remove the LAUNCHER intent filter from the main <activity> as we have added the launcher in .MainActivityDefault.
<activity-alias 
	android:name=".MainActivityLight"
	android:enabled="false"
	android:exported="true"
	android:icon="@mipmap/ic_launcher_light"
	android:targetActivity=".MainActivity">
	<intent-filter>
		<action android:name="android.intent.action.MAIN" />
		<category android:name="android.intent.category.LAUNCHER" />
	</intent-filter>
	</activity-alias>

iOS 🍏

  1. At the bottom of your Info.plist insert a key for CFBundleIcons
  2. Within this dictionary add another key for CFBundleAlternateIcons
  3. Finally then within this dictionary you can add in the keys for you new icons
    • The key is the name you will reference from within code.
    • Set the first array item to the name of the .appiconset we created earlier.
  4. In XCode, in your app's General settings, under App Icons and Launch Screen, set "App Icon" to Default and check the "Include all app icon assets" checkbox below.
<key>Dark</key>
<dict>
	<key>CFBundleIconFiles</key>
	<array>
		<string>Dark</string>
	</array>
	<key>UIPrerenderedIcon</key>
	<false/>
</dict>

import { changeIcon, getIcon, resetIcon } from 'react-native-change-icon';

// Pass the name of icon to be enabled
changeIcon('Dark');
changeIcon('Light');

// Get the icon currently enabled
getIcon();

// Reset the Icon to the default
resetIcon();

All functions are typed and return a promise that either resolves successfully, or will reject with the error that has occurred.