|
|
import React, { Component } from 'react';
|
|
|
import { Dimensions, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
|
|
|
|
|
import RankBody from './RankBody';
|
|
|
import { List } from 'immutable';
|
|
|
|
|
|
let monthUpperData = List([{name: '昵称', amount: 99, rank: 354}]);
|
|
|
let monthLowerData = List([
|
|
|
{name: '昵称', amount: 9999999, rank: 1},
|
|
|
{name: '昵称', amount: 9999999, rank: 2},
|
|
|
{name: '昵称', amount: 9999999, rank: 3},
|
|
|
]);
|
|
|
let totalUpperData = List([{name: '昵称', amount: 99, rank: 354}]);
|
|
|
let totalLowerData = List([
|
|
|
{name: '昵称', amount: 9999999, rank: 1},
|
|
|
{name: '昵称', amount: 9999999, rank: 2},
|
|
|
{name: '昵称', amount: 9999999, rank: 3},
|
|
|
{name: '昵称', amount: 9999999, rank: 4},
|
|
|
{name: '昵称', amount: 9999999, rank: 5},
|
|
|
{name: '昵称', amount: 9999999, rank: 6},
|
|
|
{name: '昵称', amount: 9999999, rank: 7},
|
|
|
{name: '昵称', amount: 9999999, rank: 8},
|
|
|
{name: '昵称', amount: 9999999, rank: 9},
|
|
|
{name: '昵称', amount: 9999999, rank: 10},
|
|
|
{name: '昵称', amount: 9999999, rank: 11},
|
|
|
{name: '昵称', amount: 9999999, rank: 12},
|
|
|
]);
|
|
|
// let arr1 = [
|
|
|
// {name: '昵称', amount: 9999999, rank: 1},
|
|
|
// {name: '昵称', amount: 9999999, rank: 2},
|
|
|
// {name: '昵称', amount: 9999999, rank: 3},
|
|
|
// {name: '昵称', amount: 9999999, rank: 4},
|
|
|
// {name: '昵称', amount: 9999999, rank: 5},
|
|
|
// {name: '昵称', amount: 9999999, rank: 6},
|
|
|
// {name: '昵称', amount: 9999999, rank: 7},
|
|
|
// {name: '昵称', amount: 9999999, rank: 8},
|
|
|
// {name: '昵称', amount: 9999999, rank: 9},
|
|
|
// {name: '昵称', amount: 9999999, rank: 10},
|
|
|
// {name: '昵称', amount: 9999999, rank: 11},
|
|
|
// {name: '昵称', amount: 9999999, rank: 12},
|
|
|
// ];
|
|
|
// let arr2 = arr1.concat(arr1).concat(arr1).concat(arr1).concat(arr1).concat(arr1).concat(arr1).concat(arr1).concat(arr1).concat(arr1);
|
|
|
// let arr3 = arr2.concat(arr2).concat(arr2).concat(arr2).concat(arr2).concat(arr2).concat(arr2).concat(arr2).concat(arr2).concat(arr2);
|
|
|
// totalLowerData = List(arr3);
|
|
|
|
|
|
const { width } = Dimensions.get('window');
|
|
|
|
|
|
export default class TalentRank extends Component {
|
|
|
state = { monthRank: true }
|
|
|
render() {
|
|
|
const { monthRank } = this.state;
|
|
|
return (
|
|
|
<View style={styles.container}>
|
|
|
<View style={[styles.topContainer, styles.center]}>
|
|
|
<View style={styles.btnWrapper}>
|
|
|
<TouchableOpacity onPress={() => this._toggleRank(true)}>
|
|
|
<View style={[styles.rankBtn, styles.center, monthRank ? styles.btnChoose : null]}>
|
|
|
<Text style={[styles.rankBtnFont, monthRank ? styles.btnTextChoose : null]}>本月排行</Text>
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
<TouchableOpacity style={styles.positionFixed} onPress={() => this._toggleRank(false)}>
|
|
|
<View style={[styles.rankBtn, styles.center, !monthRank ? styles.btnChoose : null]}>
|
|
|
<Text style={[styles.rankBtnFont, !monthRank ? styles.btnTextChoose : null]}>总排行</Text>
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
</View>
|
|
|
</View>
|
|
|
<ScrollView ref="scrollView" style={styles.container}
|
|
|
contentContainerStyle={styles.contentContainerStyle}
|
|
|
horizontal={true}
|
|
|
scrollEnabled={false} showsHorizontalScrollIndicator={false}>
|
|
|
<View style={styles.bodyContainer}>
|
|
|
<RankBody title="我的排名" monthRank={true} dataSource={monthUpperData} style={{height: 80}}/>
|
|
|
<RankBody title="全部排名" monthRank={true} dataSource={monthLowerData} style={{flex: 1, marginTop: 20}}/>
|
|
|
</View>
|
|
|
<View style={styles.bodyContainer}>
|
|
|
<RankBody title="我的排名" dataSource={totalUpperData} style={{height: 80}}/>
|
|
|
<RankBody title="全部排名" dataSource={totalLowerData} style={{flex: 1, marginTop: 20}}/>
|
|
|
</View>
|
|
|
</ScrollView>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
_toggleRank(monthRank) {
|
|
|
// this.setState({height: 400});
|
|
|
this.setState({monthRank: monthRank});
|
|
|
const { scrollView } = this.refs;
|
|
|
scrollView && (monthRank ? scrollView.scrollTo({x: 0, y: 0}) : scrollView.scrollToEnd())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
container: {
|
|
|
flex: 1
|
|
|
},
|
|
|
center: {
|
|
|
justifyContent: 'center',
|
|
|
alignItems: 'center'
|
|
|
},
|
|
|
topContainer: {
|
|
|
height: 67,
|
|
|
},
|
|
|
btnWrapper: {
|
|
|
width: 178,
|
|
|
borderColor: '#444444',
|
|
|
borderWidth: 1,
|
|
|
borderRadius: 4,
|
|
|
flexDirection: 'row',
|
|
|
},
|
|
|
rankBtn: {
|
|
|
width: 92,
|
|
|
height: 36,
|
|
|
borderRadius: 3,
|
|
|
},
|
|
|
rankBtnFont: {
|
|
|
fontSize: 14,
|
|
|
fontFamily: 'PingFang-SC-Regular',
|
|
|
color: '#444444',
|
|
|
},
|
|
|
btnChoose: {
|
|
|
backgroundColor: '#444444',
|
|
|
},
|
|
|
btnTextChoose: {
|
|
|
color: 'white'
|
|
|
},
|
|
|
positionFixed: {
|
|
|
position: 'absolute',
|
|
|
right: 0,
|
|
|
},
|
|
|
bodyContainer: {
|
|
|
flex: 1,
|
|
|
paddingHorizontal: 20,
|
|
|
},
|
|
|
contentContainerStyle: {
|
|
|
width: 2 * width,
|
|
|
}
|
|
|
}); |
|
|
\ No newline at end of file |
...
|
...
|
|