mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-29 00:21:41 +03:00
created filter for userlist dropdown
This commit is contained in:
parent
d54264ac49
commit
28623f60b8
@ -134,6 +134,7 @@ class EditorHeaderView extends Component {
|
|||||||
onChangeText={value => this._handleOnSearch(value)}
|
onChangeText={value => this._handleOnSearch(value)}
|
||||||
autoFocus
|
autoFocus
|
||||||
placeholder="Search"
|
placeholder="Search"
|
||||||
|
autoCapitalize="none"
|
||||||
style={styles.textInput}
|
style={styles.textInput}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import {
|
import {
|
||||||
View, FlatList, Text, TouchableOpacity,
|
View, FlatList, Text, TouchableOpacity,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
@ -13,25 +13,18 @@ import FastImage from 'react-native-fast-image';
|
|||||||
import styles from './votersDisplayStyles';
|
import styles from './votersDisplayStyles';
|
||||||
// const DEFAULT_IMAGE = require('../../../../assets/esteem.png');
|
// const DEFAULT_IMAGE = require('../../../../assets/esteem.png');
|
||||||
|
|
||||||
class VotersDisplayView extends Component {
|
class VotersDisplayView extends PureComponent {
|
||||||
/* Props
|
/* Props
|
||||||
* ------------------------------------------------
|
* ------------------------------------------------
|
||||||
* @prop { type } name - Description....
|
* @prop { type } name - Description....
|
||||||
*/
|
*/
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Component Life Cycles
|
|
||||||
|
|
||||||
// Component Functions
|
// Component Functions
|
||||||
_renderItem = (item, index) => {
|
_renderItem = (item, index) => {
|
||||||
const { handleOnUserPress } = this.props;
|
const { handleOnUserPress } = this.props;
|
||||||
const reputation = `(${item.reputation})`;
|
const reputation = `(${item.reputation})`;
|
||||||
const value = `$ ${item.value}`;
|
const value = `$ ${item.value}`;
|
||||||
const percent = `${item.value}%`;
|
const percent = `${item.percent}%`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[styles.voteItemWrapper, index % 2 !== 0 && styles.voteItemWrapperGray]}>
|
<View style={[styles.voteItemWrapper, index % 2 !== 0 && styles.voteItemWrapperGray]}>
|
||||||
@ -55,13 +48,15 @@ class VotersDisplayView extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { votes } = this.props;
|
const { votes } = this.props;
|
||||||
|
console.log(votes);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
{votes.length > 0 ? (
|
{votes.length > 0 ? (
|
||||||
<FlatList
|
<FlatList
|
||||||
data={votes}
|
data={votes}
|
||||||
keyExtractor={item => item.voter.toString()}
|
keyExtractor={item => item.voter}
|
||||||
|
removeClippedSubviews={false}
|
||||||
renderItem={({ item, index }) => this._renderItem(item, index)}
|
renderItem={({ item, index }) => this._renderItem(item, index)}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { View } from 'react-native';
|
import { View } from 'react-native';
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
@ -8,9 +7,8 @@ import { EditorHeader } from '../../../components/editorHeader';
|
|||||||
import { FilterBar } from '../../../components/filterBar';
|
import { FilterBar } from '../../../components/filterBar';
|
||||||
import { VotersDisplay } from '../../../components/votersDisplay';
|
import { VotersDisplay } from '../../../components/votersDisplay';
|
||||||
|
|
||||||
// Styles
|
// Utils
|
||||||
// eslint-disable-next-line
|
import { isBefore } from '../../../utils/time';
|
||||||
//import styles from './_styles';
|
|
||||||
|
|
||||||
class VotersScreen extends Component {
|
class VotersScreen extends Component {
|
||||||
/* Props
|
/* Props
|
||||||
@ -29,7 +27,26 @@ class VotersScreen extends Component {
|
|||||||
// Component Life Cycles
|
// Component Life Cycles
|
||||||
|
|
||||||
// Component Functions
|
// Component Functions
|
||||||
_handleOnDropdownSelect = () => {};
|
_handleOnDropdownSelect = (index) => {
|
||||||
|
const { data } = this.state;
|
||||||
|
const _data = data;
|
||||||
|
|
||||||
|
switch (index) {
|
||||||
|
case '0':
|
||||||
|
_data.sort((a, b) => Number(b.value) - Number(a.value));
|
||||||
|
break;
|
||||||
|
case '1':
|
||||||
|
_data.sort((a, b) => b.percent - a.percent);
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
_data.sort((a, b) => (isBefore(a.time, b.time) ? 1 : -1));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({ filterResult: _data });
|
||||||
|
};
|
||||||
|
|
||||||
_handleRightIconPress = () => {};
|
_handleRightIconPress = () => {};
|
||||||
|
|
||||||
@ -38,7 +55,6 @@ class VotersScreen extends Component {
|
|||||||
|
|
||||||
const newData = data.filter((item) => {
|
const newData = data.filter((item) => {
|
||||||
const itemName = item.voter.toUpperCase();
|
const itemName = item.voter.toUpperCase();
|
||||||
// ${item.name.first.toUpperCase()} ${item.name.last.toUpperCase()}`;
|
|
||||||
const _text = text.toUpperCase();
|
const _text = text.toUpperCase();
|
||||||
|
|
||||||
return itemName.indexOf(_text) > -1;
|
return itemName.indexOf(_text) > -1;
|
||||||
@ -65,7 +81,7 @@ class VotersScreen extends Component {
|
|||||||
defaultText="REWARDS"
|
defaultText="REWARDS"
|
||||||
onDropdownSelect={this._handleOnDropdownSelect}
|
onDropdownSelect={this._handleOnDropdownSelect}
|
||||||
/>
|
/>
|
||||||
<VotersDisplay votes={filterResult || data} />
|
<VotersDisplay key={Math.random()} votes={filterResult || data} />
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,10 @@ export const getTimeFromNow = (value) => {
|
|||||||
.fromNow();
|
.fromNow();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getFormatedCreatedDate = value => {
|
export const getFormatedCreatedDate = (value) => {
|
||||||
if (!value) return null;
|
if (!value) return null;
|
||||||
|
|
||||||
return moment(value).format("DD MMM, YYYY");
|
return moment(value).format('DD MMM, YYYY');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const isBefore = (a, b) => moment(a).isBefore(b);
|
||||||
|
Loading…
Reference in New Issue
Block a user