ibrahimahmed-io / react-native-android-circular-reveal

A circular reveal component for android in React Native
MIT License
9 stars 1 forks source link

react-native-android-circular-reveal

A circular reveal component for android in React Native. Based on Circular Reveal.

Circular Reveal

Installation

$ yarn add react-native-android-circular-reveal

Option: Manually

Usage

Example with Toolbar (Trying to achieve something like whatsapp search)

import AndroidCircularReveal from 'react-native-android-circular-reveal';

import {
    StyleSheet
} from 'react-native';

import ExtraDimensions from 'react-native-extra-dimensions-android';

let screen_width = ExtraDimensions.get('REAL_WINDOW_WIDTH');

const Styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#FFF'
    },
    toolbar: {
        height: 56,
        backgroundColor: '#AE9156'
    },
    searchToolbarContainer: {
        flex: 0,
        width: screen_width,
        height: 56,
        position: 'absolute',
        top: 0,
        zIndex: 4
    },
    searchToolbar: {
        height: 56,
        backgroundColor: '#FFF',
        elevation: 4,
        borderBottomWidth: 8,
        borderBottomColor: 'rgba(0, 0, 0, 0.54)'
    },
    searchText: {
        fontFamily: 'Roboto-Regular',
        fontSize: 16,
        color: 'rgba(0,0,0, 0.87)',
        flex: 0,
        height: 56,
        width: screen_width - 72
    }
});

revealSearchToolBar() {
    this.refs['search-toolbar'].reveal(40);
};

hideSearchToolBar() {
    this.refs['search-toolbar'].hide(40);
};

render() {
    return (
        <View style={Styles.container}>
            <StatusBar backgroundColor='#9F854F' />
            <ToolbarAndroid
                style={Styles.toolbar}
                title="New group"
                titleColor={'#FFF'}
                subtitle="Add friends"
                subtitleColor={'#FFF'}
                navIcon={images.arrowBack}
                onIconClicked={() => this.dismissModal()}
                actions={[{showWithText: false, title: '', icon: images.search, show: 'always'}]}
                onActionSelected={() => this.revealSearchToolBar()}>
            </ToolbarAndroid>
            <AndroidCircularReveal 
                ref="search-toolbar"
                style={Styles.searchToolbarContainer}
                animationDuration={400}>
                <ToolbarAndroid
                    navIcon={images.arrowBackBlack}
                    onIconClicked={() => this.hideSearchToolBar()}
                    style={Styles.searchToolbar}>
                    <View style={{flex: 1, flexDirection: 'row', backgroundColor: '#FFF'}}>
                        <TextInput style={Styles.searchText} autoFocus={true} placeholder="Search" underlineColorAndroid={'transparent'} autoCorrect={false} />
                    </View>
                </ToolbarAndroid>
            </AndroidCircularReveal>
        </View>
    );
};

Properties

Prop Description
animationDuration Used to set reveal animation speed.

License

MIT License. Circular Reveal is under MIT license. © Ibrahim Ahmed 2017 - now