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

How to resize rightButtons image? #141

Open
dhioetanasti opened this issue Aug 21, 2017 · 0 comments
Open

How to resize rightButtons image? #141

dhioetanasti opened this issue Aug 21, 2017 · 0 comments

Comments

@dhioetanasti
Copy link

dhioetanasti commented Aug 21, 2017

I need to use buttons with image on the right side of navigation bar, but unable to resize the image, so i initially followed the docs => http://airbnb.io/native-navigation/docs/api/navigator-config.html and tried to do something like this

render() {
        const img = {
            uri:'../Icon/filter.png',
            height:23,
            width:25
        }
        const img2 = {
            uri:'../Icon/add.png',
            height:23,
            width:25
        }

        const btn = {
            image:img
        }
        const btn2 = {
            image:img2
        }

        let buttonArray = [btn, btn2]

        return (
            <Navigator.Config
                title= {'My App'}
                rightButtons={buttonArray}
                onRightPress={(index) => this.navBarButtonTapped(index)}
            >
            </Navigator.Config>
        );
}

but got a JSON value error

then i tried to do this

    import FilterImage from '../Icon/filter.png'
    import AddImage from '../Icon/plus.png'
    
    render() {
        let buttonArray = [{image: AddImage}, {}]

        return (
            <Navigator.Config
                title= {'My App'}
                rightButtons={buttonArray}
                onRightPress={(index) => this.navBarButtonTapped(index)}
            >
            {
                hasNoPromoAtAll ?
                    this.renderNoResult()
                    :
                    this.renderContent()
            }
            </Navigator.Config>
        );
    }

and it works, the images appear but i unable to resize the image that way, is there a way to do it properly?

Edit
my first way above works with uri being the name of the image asset on the native side (xcasset on iOS), but when i tried to define the height and the width, i got this error :Image source size {60, 60} does not match loaded image size {30, 30}.

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

No branches or pull requests

1 participant