SettingView.js 8.7 KB
Newer Older
qq_45757468's avatar
qq_45757468 已提交
1 2
import {Component} from 'react';
import React from 'react';
qq_45757468's avatar
qq_45757468 已提交
3
import {
YYYTDMS's avatar
YYYTDMS 已提交
4 5 6 7 8 9
    Dimensions,
    Image,
    View,
    Text,
    StyleSheet,
    TouchableOpacity, ToastAndroid,
qq_45757468's avatar
qq_45757468 已提交
10
} from 'react-native';
YYYTDMS's avatar
YYYTDMS 已提交
11

qq_45757468's avatar
qq_45757468 已提交
12 13
const deviceWidthDp = Dimensions.get('window').width;
const deviceHeightDp = Dimensions.get('window').height;
qq_45757468's avatar
qq_45757468 已提交
14 15
import DropDownModal from '../SingleComponent/DropDownModal';
import RadioView from '../SingleComponent/RadioView';
YYYTDMS's avatar
YYYTDMS 已提交
16
import {PanResponder} from 'react-native';
qq_45757468's avatar
qq_45757468 已提交
17 18 19 20 21

/**
 *             偏好设置界面
 */
class SettingView extends Component {
YYYTDMS's avatar
YYYTDMS 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
    constructor() {
        super();
        this.state = {
            flag: null,
            building: null,
            floor: null,
            buildsListsetting: null,
        };
    }
    _panResponder = PanResponder.create({

        onStartShouldSetPanResponder: () => true,
        onMoveShouldSetPanResponder: () => true,
        onPanResponderGrant: () => {
            // console.log('开始移动:');
        },
        onPanResponderMove: (evt, gs) => {
            // console.log('正在移动:X轴:' + gs.dx + ',Y轴:' + gs.dy);
        },
        onPanResponderRelease: (evt, gs) => {
            // console.log('结束移动:X轴移动了:' + gs.dx + ',Y轴移动了:' + gs.dy);
            if (gs.dx > 50) {
                // console.log('由左向右');
            } else if (gs.dx < -50) {
                // console.log('由右向左');
            } else if (gs.dy > 50) {
                // console.log('由上向下');
            } else if (gs.dy < -50) {
                // console.log('由下向上');
                // this.props.navigation.back();
                this.props.navigation.goBack()
            }
        },
qq_45757468's avatar
qq_45757468 已提交
55
    });
YYYTDMS's avatar
YYYTDMS 已提交
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74




    checkCallBack = id => {
        this.setState({
            flag: id,
        });
    };
    _selectbuilding = (index, value) => {
        console.log(index + '--' + value);
        this.setState({
            building: value,
        });
    };
    _selectfloor = (index, value) => {
        console.log(index + '--' + value);
        this.setState({
            floor: index + 1,
qq_45757468's avatar
qq_45757468 已提交
75
        });
YYYTDMS's avatar
YYYTDMS 已提交
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
    };

    componentDidMount() {
        const {buildsListsort} = this.props.route.params;
        const {x1, x2, x3, zl, d1, d2, d3, w1, w2, w3, w4} =
            this.props.route.params.buildsListsort;
        const buildName = [x1, x2, x3, zl, d1, d2, d3, w1, w2, w3, w4];
        if (JSON.stringify(buildsListsort) == '{}') {
            console.log('');
        } else {
            console.log('传参', buildsListsort);
            for (let i = 0; i < buildName.length; i++) {
                buildName[i].sort((a, b) => {
                    return a.people_num - b.people_num;
                });
            }
            this.setState({buildsListsetting: buildsListsort}, () => {
                console.log('回调', this.state.buildsListsetting);
            });
        }
qq_45757468's avatar
qq_45757468 已提交
96
    }
qq_45757468's avatar
qq_45757468 已提交
97

YYYTDMS's avatar
YYYTDMS 已提交
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
    render() {
        const {navigation} = this.props;
        const {buildsListsort} = this.props.route.params;
        // console.log('pppppp', this.state.buildsListsetting);
        // console.log('处理后', buildsListsort);
        return (
            <View  style={styles.container} {...this._panResponder.panHandlers}>
                <View style={styles.box1}>
                    <Image
                        source={require('../../../images/Map/Behavior.png')}
                        style={styles.box1image}
                    />
                    <Text style={styles.box1text}>偏好设置</Text>
                </View>
                <View style={styles.box2}>
                    <DropDownModal
                        data={[
                            '西3楼',
                            '西2楼',
                            '西1楼',
                            '中楼',
                            '东1楼',
                            '东2楼',
                            '东3楼',
                            '文1楼',
                            '东2楼',
                            '东3楼',
                            '东4楼',
                        ]}
                        title={'区域'}
                        imgSource={require('../../../images/Map/regionalRules.png')}
                        onChoosed={this._selectbuilding}
                    />
                </View>
                <View style={styles.box3}>
                    <DropDownModal
                        data={['1楼', '2楼', '3楼', '4楼', '5楼']}
                        title={'楼层'}
                        imgSource={require('../../../images/Map/floor.png')}
                        onChoosed={this._selectfloor}
                    />
                </View>
                <View style={styles.box4}>
                    <Image
                        source={require('../../../images/Map/Mytalent.png')}
                        style={styles.box4image}
                    />
qq_45757468's avatar
qq_45757468 已提交
145

YYYTDMS's avatar
YYYTDMS 已提交
146 147 148
                    <View style={{flex: 2}}>
                        <Text style={styles.text}>人少</Text>
                    </View>
qq_45757468's avatar
qq_45757468 已提交
149

YYYTDMS's avatar
YYYTDMS 已提交
150 151 152 153 154
                    <RadioView
                        id={1}
                        onCheck={this.checkCallBack}
                        checked={this.state.flag === 1}
                    />
qq_45757468's avatar
qq_45757468 已提交
155

YYYTDMS's avatar
YYYTDMS 已提交
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
                    <View style={{flex: 2}}>
                        <Text style={styles.text}>人多</Text>
                    </View>

                    <RadioView
                        id={2}
                        onCheck={this.checkCallBack}
                        checked={this.state.flag === 2}
                    />
                    <View style={{flex: 1.5}}/>
                </View>
                <View style={styles.box5}>
                    <TouchableOpacity
                        style={{
                            backgroundColor: '#F6C354',
                            width: deviceWidthDp / 4,
                            height: deviceHeightDp / 20,
                            marginBottom: 20,
                            justifyContent: 'center',
                            marginRight: 30,
                        }}
                        onPress={() => {
                            // console.log('this.state.flag', this.state.flag);
                            // console.log('this.state.building', this.state.building);
                            // console.log('this.state.floor', this.state.floor);
                            if (
                                this.state.flag == null ||
                                this.state.building == null ||
                                this.state.floor == null
                            ) {

                                ToastAndroid.show('请设置偏好~~(^v^)', 500);
                            } else {
                                navigation.navigate('RecommendView', {
                                    list: this.state.buildsListsetting,
                                    build: this.state.building,
                                    floor: this.state.floor,
                                    flag: this.state.flag,
                                });
                            }
                        }}>
                        <Text style={{color: '#FFFFFF', textAlign: 'center'}}>
                            开始匹配
                        </Text>
                    </TouchableOpacity>
                </View>
                <View style={{flex: 10}}>
                    <Image
                        source={require('../../../images/Map/loading.png')}
                        style={styles.box5image}
                    />
                </View>
            </View>
        );
    }
qq_45757468's avatar
qq_45757468 已提交
211
}
YYYTDMS's avatar
YYYTDMS 已提交
212

qq_45757468's avatar
qq_45757468 已提交
213
const styles = StyleSheet.create({
YYYTDMS's avatar
YYYTDMS 已提交
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
    container: {
        flexDirection: 'column',
        flex: 1,
        backgroundColor: '#F6B972',
    },
    box1: {
        flexDirection: 'row',
        flex: 1,
        justifyContent: 'center',
        // backgroundColor: 'black',
    },
    box1image: {
        height: deviceHeightDp / 25,
        width: deviceWidthDp / 25,
        resizeMode: 'contain',
    },
    box1text: {
        textAlign: 'center',
        paddingTop: 5,
        color: '#FFFFFF',
    },
    box2: {
        flex: 1,
    },
    box3: {
        flex: 1,
    },
    box4: {
        flexDirection: 'row',
        flex: 1,
    },
    box4image: {
        width: null,
        height: null,
        flex: 1.2,
        resizeMode: 'contain',
    },
    text: {
        fontSize: 22,
        color: '#FFFFFF',
        textAlignVertical: 'center',
        flex: 1,
        textAlign: 'right',
    },
    box5: {
        flex: 1,
        alignItems: 'flex-end',
    },
    box5image: {
        width: null,
        height: null,
        flex: 1,
        resizeMode: 'contain',
    },
    box6: {
        flex: 1,
    },
qq_45757468's avatar
qq_45757468 已提交
271
});
qq_45757468's avatar
qq_45757468 已提交
272
export default SettingView;