created search bar and functionabilty

This commit is contained in:
ue 2018-11-01 20:08:05 +03:00
parent 50a326ea55
commit 4c5d39e969
4 changed files with 79 additions and 18 deletions

View File

@ -60,4 +60,13 @@ export default EStyleSheet.create({
flexGrow: 1, flexGrow: 1,
fontWeight: '500', fontWeight: '500',
}, },
textInput: {
color: '$iconColor',
alignSelf: 'center',
fontSize: 16,
marginLeft: 16,
flexGrow: 1,
fontWeight: '500',
width: '$deviceWidth / 1.4',
},
}); });

View File

@ -1,5 +1,7 @@
import React, { Component, Fragment } from 'react'; import React, { Component, Fragment } from 'react';
import { View, SafeAreaView, Text } from 'react-native'; import {
View, SafeAreaView, Text, TextInput,
} from 'react-native';
import { TextButton } from '../..'; import { TextButton } from '../..';
import { IconButton } from '../../iconButton'; import { IconButton } from '../../iconButton';
// Constants // Constants
@ -19,7 +21,9 @@ class EditorHeaderView extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = {}; this.state = {
isInputVisible: false,
};
} }
// Component Life Cycles // Component Life Cycles
@ -36,6 +40,20 @@ class EditorHeaderView extends Component {
_handleOnDropdownSelect = () => {}; _handleOnDropdownSelect = () => {};
_handleSearchButtonPress = () => {
const { isInputVisible } = this.state;
this.setState({ isInputVisible: !isInputVisible });
};
_handleOnSearch = (value) => {
const { handleOnSearch } = this.props;
handleOnSearch(value);
};
_handleOnInputChange = () => {};
render() { render() {
const { const {
handleOnPressBackButton, handleOnPressBackButton,
@ -50,8 +68,9 @@ class EditorHeaderView extends Component {
handleRightIconPress, handleRightIconPress,
isModalHeader, isModalHeader,
handleOnPressClose, handleOnPressClose,
isHasSearch,
} = this.props; } = this.props;
const { isInputVisible } = this.state;
return ( return (
<SafeAreaView> <SafeAreaView>
<View style={styles.container}> <View style={styles.container}>
@ -62,10 +81,11 @@ class EditorHeaderView extends Component {
name={isModalHeader ? 'close' : 'md-arrow-back'} name={isModalHeader ? 'close' : 'md-arrow-back'}
onPress={() => (isModalHeader ? handleOnPressClose() : handleOnPressBackButton())} onPress={() => (isModalHeader ? handleOnPressClose() : handleOnPressBackButton())}
/> />
{!isInputVisible && (
<Text style={[title && styles.title, quickTitle && styles.quickTitle]}> <Text style={[title && styles.title, quickTitle && styles.quickTitle]}>
{quickTitle || title} {quickTitle || title}
</Text> </Text>
)}
{isHasDropdown && ( {isHasDropdown && (
<View> <View>
@ -78,11 +98,30 @@ class EditorHeaderView extends Component {
</View> </View>
)} )}
{rightIconName && ( {rightIconName
&& !isHasSearch && (
<IconButton
style={styles.rightIcon}
size={25}
onPress={() => handleRightIconPress()}
iconStyle={styles.rightIcon}
name={rightIconName}
/>
)}
{isInputVisible && (
<TextInput
onChangeText={value => this._handleOnSearch(value)}
autoFocus
style={styles.textInput}
/>
)}
{isHasSearch && (
<IconButton <IconButton
style={styles.rightIcon} style={styles.rightIcon}
size={25} size={25}
onPress={() => handleRightIconPress()} onPress={() => this._handleSearchButtonPress()}
iconStyle={styles.rightIcon} iconStyle={styles.rightIcon}
name={rightIconName} name={rightIconName}
/> />

View File

@ -1,7 +1,5 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Text } from 'react-native'; import { Text, Animated } from 'react-native';
import { Container } from 'native-base';
// Components // Components
import { Logo } from '../../../components'; import { Logo } from '../../../components';
@ -10,15 +8,28 @@ import styles from './splashStyles';
class SplashScreen extends Component { class SplashScreen extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = {
fadeAnim: new Animated.Value(0),
};
} }
componentDidMount = () => {
const { fadeAnim } = this.state;
Animated.timing(fadeAnim, {
toValue: 1,
duration: 6000,
}).start();
};
render() { render() {
const { fadeAnim } = this.state;
return ( return (
<Container style={styles.container}> <Animated.View style={[styles.container, { opacity: fadeAnim }]}>
<Logo style={styles.logo} /> <Logo style={styles.logo} />
<Text style={styles.title}>eSteem</Text> <Text style={styles.title}>eSteem</Text>
<Text style={styles.subTitle}>mobile</Text> <Text style={styles.subTitle}>mobile</Text>
</Container> </Animated.View>
); );
} }
} }

View File

@ -22,6 +22,7 @@ class VotersScreen extends Component {
super(props); super(props);
this.state = { this.state = {
data: props.votes, data: props.votes,
filterResult: null,
}; };
} }
@ -42,11 +43,12 @@ class VotersScreen extends Component {
return itemName.indexOf(_text) > -1; return itemName.indexOf(_text) > -1;
}); });
this.setState({ data: newData });
this.setState({ filterResult: newData });
}; };
render() { render() {
const { data } = this.state; const { data, filterResult } = this.state;
const headerTitle = `Voters Info (${data && data.length})`; const headerTitle = `Voters Info (${data && data.length})`;
return ( return (
@ -55,7 +57,7 @@ class VotersScreen extends Component {
title={headerTitle} title={headerTitle}
rightIconName="ios-search" rightIconName="ios-search"
isHasSearch isHasSearch
handleRightIconPress={this._handleSearch} handleOnSearch={this._handleSearch}
/> />
<FilterBar <FilterBar
dropdownIconName="md-arrow-dropdown" dropdownIconName="md-arrow-dropdown"
@ -63,7 +65,7 @@ class VotersScreen extends Component {
defaultText="REWARDS" defaultText="REWARDS"
onDropdownSelect={this._handleOnDropdownSelect} onDropdownSelect={this._handleOnDropdownSelect}
/> />
<VotersDisplay votes={data} /> <VotersDisplay votes={filterResult || data} />
</View> </View>
); );
} }