shripalsoni04 / nativescript-angular-drawer-template

A starter project to quickly create nativescript angular project with drawer pages.
MIT License
46 stars 9 forks source link

Change menu icon #7

Closed rleal-dev closed 7 years ago

rleal-dev commented 7 years ago

Hello, I'm starting with nativescript, I would like to know how to change the icon from "drawer" to a white background.

screenshot from 2016-12-09 14 55 05

shripalsoni04 commented 7 years ago

To change drawer icon to white, follow below steps:

  1. Download white drawer icon files from https://material.io/icons/#ic_menu, and put that into App_Resources/Android and App_Resources/iOS folders similar to how I have put ic_menu_black.png. You can use any icon library, but as that black drawer icon is from md, I have given that link
  2. Use the white drawer icon by changing icon file name with your new icon file name at this line: https://github.com/shripalsoni04/nativescript-angular-drawer-template/blob/master/modules/shared/side-drawer-page/side-drawer-page.component.ts#L114
rleal-dev commented 7 years ago

I changed the icon:

private getNavigationButton() {
    let navActionItem = new ActionItem();
    navActionItem.icon = 'res://ic_menu_white_24dp';
    //navActionItem.icon = 'res://ic_menu_black';

    if (navActionItem.ios) {
        navActionItem.ios.position = 'left';
     }

    navActionItem.on('tap', this.toggleDrawer.bind(this));
    return navActionItem;
}

And placed the icon in the respective folders.

screenshot from 2016-12-09 16 11 55

The icon was not visible. Rode the command tns livesync android --emulator --watch

screenshot from 2016-12-09 16 12 10

Any other tips?

shripalsoni04 commented 7 years ago

Once you do any changes in App_Resources folder, you need to build and run the application as livesync will not be able to pick it up.

So instead of livesync command, execute tns run android or tns run ios

rleal-dev commented 7 years ago

Worked perfectly.

Thank you very much.

screenshot from 2016-12-09 16 30 10

eddy2enam commented 7 years ago

how to add icon to sidebar list