From c851d99e516e1f65d51eb53f554a46008bf49b79 Mon Sep 17 00:00:00 2001 From: TheKeeroll <57570053+TheKeeroll@users.noreply.github.com> Date: Wed, 10 Aug 2022 17:38:39 +0300 Subject: [PATCH] readme and example update (#65) * added getIcon method if default icon is selected returns "default" else returns selected icon name * brought try...catch back, removed unused in android part, stored coponentClass... in var * added example and updated readme for getIcon * Update README.md --- README.md | 9 ++++++--- example/src/App.tsx | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2593430..ff53ada 100644 --- a/README.md +++ b/README.md @@ -108,12 +108,15 @@ protected List getPackages() { Now you can use the following code to change application icon: ```javascript -import { changeIcon } from 'react-native-change-icon'; +import { changeIcon, getIcon } from 'react-native-change-icon'; // Pass the name of icon to be enabled changeIcon('iconname'); -``` -`changeIcon` function returns a promise. The promise is resolved only when the icon is changed. +//or get currently selected icon +getIcon(); +``` +`changeIcon` function returns a promise. The promise is resolved only when the icon is changed.\ +`getIcon` function returns `Promise` with the name of the selected icon or "default" if default icon is selected **Please refer to the example app for demo on implementation** diff --git a/example/src/App.tsx b/example/src/App.tsx index cc4fa62..6b8735f 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,16 +1,25 @@ import * as React from 'react'; import { StyleSheet, View, Text, TouchableOpacity } from 'react-native'; -import { changeIcon } from 'react-native-change-icon'; +import { changeIcon, getIcon } from 'react-native-change-icon'; export default function App() { + const [currentIconName, setCurrentIconName] = React.useState('') + return ( - changeIcon('checked')}> + { + changeIcon('checked') + getIcon().then(name=>setCurrentIconName(name)) + }}> SWITCH TO CHECKED ICON - changeIcon('cancel')}> + { + changeIcon('cancel') + getIcon().then(name=>setCurrentIconName(name)) + }}> SWITCH TO CANCEL ICON + {'Icon name: ' + currentIconName} ); } @@ -26,5 +35,5 @@ const styles = StyleSheet.create({ fontSize: 20, textAlign: 'center', margin: 10, - }, + } });