Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new icon component usage logic #24

Merged
merged 8 commits into from
May 15, 2021
Merged

Conversation

enesozturk
Copy link
Owner

Previously, to use icon in <MenuItem/>, you have to provide icon component in list that goes with items prop of <HoldMenu/> component like below.

const list = [
  {
  title: 'Home',
  icon: () => <Icon name="home" size={18} />
  },
  {
    title: 'Delete',
    icon: () => <Icon name="trash" size={18} />
   }
]

<HoldMenu items={list}>{...}</HoldMenu>

Now I decided to create animated icon component and use it in every <MenuItem/>. So only thing to do is providing an Icon component to <HoldMenuProvider/> and in the menu list, just set the name of the icon. It is possible to use Reanimated for the props for styles of the icon. I noticed that this made the animations little bit more performant. New usage is like below.

const list = [
  { title: 'Home, icon: 'home' },
  { title: 'Trash', icon: 'trash' }
]

// In App.js
import FeatherIcon from 'react-native-vector-icons/Feather';

<HoldMenuProvider iconComponent={FeatherIcon} theme="light">
  {...}
</HoldMenuProvider>

Cons

So far I worked with the 'react-native-vector-icons' for the example project. I will try to use expo vector icons as well and try to make it work.

@enesozturk enesozturk merged commit 073c117 into develop May 15, 2021
@enesozturk enesozturk deleted the feature/animated-icon-comp branch May 15, 2021 18:56
enesozturk added a commit that referenced this pull request May 15, 2021
* feat: Add Tap and Double Tap Support

* fix: remove unnecessary memo

* fix: disable calling animations again when they are already active

* feat: new prop to pass params to onPress handlers

* feat: add optional haptic feedback

* chore: replace react-native-haptic-feedback with expo-haptics

* chore:  update yarn lock and prop example usage

* chore: make methodParams optional

* chore: rename methodParams prop name as actionParams

* chore: update actionParams prop types

* docs: update props doc for actionParams

* docs: add haptic feedback and activate on props

* refactor: updates reanimated and unimodules deps and setups (#25)

* fix: typo for seperator word (#15)

* fix: typo

* chore: remove all typo for seperator

Co-authored-by: Enes Ozturk <enesozturk.d@gmail.com>

* feat: disable touchable of the hold item when menu active (#8)

* feat: optional prop to close menu when tap to hold item

* docs: add closeOnTap to the props

* chore: update whatsapp example

* refactor: update hold item comp and types

* feat: new icon component usage logic (#24)

* feat: add animated icon component

* chore: remove theme prop passing to children

* chore: update playground example with hold menu icon comp

* chore: update icon handling logic

* chore: update icon rendering in menu item

* chore: updates examples and pass feather icons to hold menu

* chore: update telegram example

* docs: add icon docs and update other details

* fix: typo for separator word that missed on rebase (#26)

* fix: typo for separator word that missed on rebase

* chore: update wrong separator words

* chore: release v0.1.0

Co-authored-by: ksitko <k@alz.ai>
Co-authored-by: Zhigang Fang <zhigang1992@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant