更多菜单点击无法正常显示

来源:10-1 可配置菜单的实现-1

Leonard_

2018-09-05

http://img.mukewang.com/szimg/5b8f82ef0001100c07201294.jpg


http://img.mukewang.com/szimg/5b8f82ff00015f7716800796.jpg

写回答

1回答

CrazyCodeBoy

2018-09-06

问题分析:出现上述问题有可能由两种情况导致:

1. 样式设置不对;

2. MoreMenu的render方法实现不对;

可参考:

renderMoreView() {
    const {theme, menus} = this.props;
    return (
        <MenuDialog
            ref={dialog => this.dialog = dialog}
            menus={menus}
            theme={theme}
            onSelect={(tab) => this.onMoreMenuSelect(tab)}
        />
    );
}

MenuDialog:
render() {
        const {onClose, menus, onSelect, theme} = this.props;
        return (<Modal
            transparent={true}
            visible={this.state.visible}
            onRequestClose={() => onClose()}
        >
            <TouchableOpacity
                style={styles.container}
                onPress={() => this.dismiss()}
            >
                <Image
                    source={require('../../res/images/arrow_top.png')}
                    style={styles.arrow}
                />
                <View
                    style={styles.content}
                >
                    {menus.map((result, i, arr) => {
                        let menu = arr[i];
                        return <TouchableOpacity
                            key={i}
                            onPress={() => {
                                onSelect(arr[i])
                            }}
                            underlayColor={'transparent'}
                        >
                            <View style={{alignItems: 'center', flexDirection: 'row'}}>
                                <Image source={menu.icon}
                                       resizeMode={'stretch'}
                                       style={[styles.icon, theme.styles.tabBarSelectedIcon]}
                                />
                                <Text
                                    style={styles.text}
                                >{menu.name}</Text>
                                {
                                    i !== menus.length - 1 ? <View
                                        style={styles.line}
                                    /> : null
                                }
                            </View>
                        </TouchableOpacity>
                    })}
                </View>
            </TouchableOpacity>
        </Modal>)
    }
}
const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: 'rgba(0,0,0,0.6)',
        alignItems: 'flex-end'
    },
    arrow: {
        marginTop: 56 + (DeviceInfo.isIPhoneX_deprecated ? 24 : 0),
        width: 16,
        height: 6,
        marginRight: 18,
        resizeMode: 'contain'
    },
    content: {
        backgroundColor: 'white',
        borderRadius: 3,
        paddingTop: 3,
        paddingBottom: 3,
        marginRight: 3
    },
    text: {
        fontSize: 16,
        color: 'black',
        fontWeight: '400',
        paddingRight: 15
    },
    line: {
        height: 0.3,
        backgroundColor: 'darkgray'
    },
    icon: {
        width: 16,
        height: 16,
        margin: 10,
        marginLeft: 15
    }
});



0
0

React Native技术精讲与高质量上线App开发

一个真实的上线项目,一次完整的开发过程,全面掌握React Native技术

1577 学习 · 727 问题

查看课程