Skip to content

Commit

Permalink
release v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
skb1129 committed Dec 14, 2018
1 parent 237b332 commit d0d05c5
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 113 deletions.
49 changes: 32 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@

# react-native-change-icon
# React Native Change Icon

Change Application Icon Programmatically.
- [x] iOS
- [ ] Android

## Getting started

`$ npm install react-native-change-icon --save`
`$ yarn add install react-native-change-icon`

### Mostly automatic installation
### Mostly automatic installation (Recommended)

`$ react-native link react-native-change-icon`

### Manual installation


#### iOS

1. In XCode, in the project navigator, right click `Libraries``Add Files to [your project's name]`
2. Go to `node_modules``react-native-change-icon` and add `RNChangeIcon.xcodeproj`
3. In XCode, in the project navigator, select your project. Add `libRNChangeIcon.a` to your project's `Build Phases``Link Binary With Libraries`
4. Run your project (`Cmd+R`)<

#### Android
#### Android (Currently Not Functional)

1. Open up `android/app/src/main/java/[...]/MainActivity.java`
1. Open up `android/app/src/main/java/[...]/MainApplication.java`
- Add `import com.reactlibrary.RNChangeIconPackage;` to the imports at the top of the file
- Add `new RNChangeIconPackage()` to the list returned by the `getPackages()` method
2. Append the following lines to `android/settings.gradle`:
Expand All @@ -34,20 +37,32 @@
compile project(':react-native-change-icon')
```

#### Windows
[Read it! :D](https://github.com/ReactWindows/react-native)
## Usage

1. In Visual Studio add the `RNChangeIcon.sln` in `node_modules/react-native-change-icon/windows/RNChangeIcon.sln` folder to their solution, reference from their app.
2. Open up your `MainPage.cs` app
- Add `using Change.Icon.RNChangeIcon;` to the usings at the top of the file
- Add `new RNChangeIconPackage()` to the `List<IReactPackage>` returned by the `Packages` method
#### iOS

1. Open your project in Xcode and create an **App Icons** group inside you app's group.
2. Add all the app icons you need inside this group with names like *[email protected]*, *[email protected]*.
3. Your directory structure in Xcode would look like:

![Xcode Directory](images/App_Icons.png)

4. Open the **Info.plist** file.
5. Add *Icon files (iOS 5)* to the *Information Property List*.
6. Add *CFBundleAlternateIcons* as a dictionary to the *Icon files (iOS 5)*, it is used for alternative icons.
7. Add dictionaries under *CFBundleAlternateIcons* named as your icon names in **App Icons** group.
8. For each dictionary, two properties, *UIPrerenderedIcon* and *CFBundleIconFiles* need to be configured.
9. Set the type of *UIPrerenderedIcon* to *String* and its value to *NO*.
10. Set the type of *CFBundleIconFiles* to *Array* and set its first key, *Item 0*'s type to *String* and its value to the corresponding icon names.
11. After all these steps, your **Info.plist** file should look like:

![Info.plist](images/Info.plist.png)

Now you can use the following code to change application icon:

## Usage
```javascript
import RNChangeIcon from 'react-native-change-icon';
import { changeIcon } from 'react-native-change-icon';

// TODO: What to do with the module?
RNChangeIcon;
// Pass the name of icon as string to the "changeIcon" function
changeIcon('icon_name');
```

36 changes: 0 additions & 36 deletions android/build.gradle

This file was deleted.

6 changes: 0 additions & 6 deletions android/src/main/AndroidManifest.xml

This file was deleted.

22 changes: 0 additions & 22 deletions android/src/main/java/com/reactlibrary/RNChangeIconModule.java

This file was deleted.

28 changes: 0 additions & 28 deletions android/src/main/java/com/reactlibrary/RNChangeIconPackage.java

This file was deleted.

Binary file added images/App_Icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Info.plist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 14 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@
{
"name": "react-native-change-icon",
"version": "1.0.0",
"description": "",
"description": "React Native Change Application Icon Programmatically.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"react-native"
"react-native",
"icon",
"change",
"programmatically",
"dynamic"
],
"author": "",
"license": "",
"author": "Surya Kant Bansal <[email protected]>",
"homepage": "https://github.com/skb1129/react-native-change-icon",
"nativePackage": true,
"repository": {
"type": "git",
"url": "https://github.com/skb1129/react-native-change-icon.git"
},
"license": "MIT",
"peerDependencies": {
"react-native": ">=0.55.4"
}
Expand Down

0 comments on commit d0d05c5

Please sign in to comment.