| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- /**
- * 首页地图工具和搜索框组件
- * @邠心vbe on 2022/12/20
- */
- import React, { Component } from 'react';
- import { View, StyleSheet, Text, Pressable } from 'react-native';
- import BottomModal from '../../../components/BottomModal';
- import Filter from './Filter';
- import { PageList } from '../../Router';
- import { BackButton } from '../../../components/Toolbar';
-
- export default class SearchTool extends Component {
- constructor(props) {
- super(props);
- this.state = {
- showFilter: false,
- filterIndex: {},
- filterTotal: 0,
- };
- }
- componentDidUpdate() {
- if (this.props.count != this.state.filterTotal) {
- this.setState({
- filterTotal: this.props.count
- })
- }
- }
- findFilter(data, index) {
- this.setState({
- filterIndex: index
- });
- this.hideFilter();
- if (this.props.onFilter) {
- this.props.onFilter(data);
- }
- }
- showFilter() {
- this.setState({
- showFilter: true
- });
- }
- hideFilter() {
- this.setState({
- showFilter: false
- });
- }
- /*getNearestStation() {
- navigator.geolocation.getCurrentPosition(location => {
- let params = {
- lat: location.coords.latitude,
- lng: location.coords.longitude
- }
- Dialog.showProgressDialog();
- apiStation.getNearestSite(params).then(res => {
- Dialog.dismissLoading();
- if (res.data.sitePk) {
- var station = {
- id: res.data.sitePk,
- name: res.data.siteName,
- address: res.data.address,
- latitude: res.data.locationLatitude,
- longitude: res.data.locationLongitude,
- }
- setTimeout(() => {
- utils.directMaps(station.latitude, station.longitude, station.address);
- }, 500);
- } else {
- toastShort("您附近没有充电桩");
- }
- }).catch(err => {
- toastShort(err);
- Dialog.dismissLoading();
- });
- });
- }*/
- render() {
- return (
- <View>
- <View style={styles.searchView}>
- <Pressable
- style={styles.searchInput}
- onPress={() => {
- startPage(PageList.search);
- }}>
- <Feather
- name={'search'}
- size={24}
- color={'#444'}/>
- <Text style={styles.searchText}>
- {$t('home.search')}
- </Text>
- </Pressable>
- <BackButton
- style={styles.mapIcon}
- onPress={() => this.showFilter()}>
- <FontAwesome
- name='filter'
- size={26}
- color={colorPrimary}/>
- </BackButton>
- <BackButton
- style={styles.mapIcon}
- onPress={() => this.props.onLocation()}>
- <MaterialIcons
- name='my-location'
- size={26}
- color={colorPrimary}/>
- </BackButton>
- {/* <View style={styles.mapToolView}>
- <TouchableOpacity
- style={styles.mapIcon}
- activeOpacity={0.7}
- onPress={() => {
- startPage(PageList.scanqr, {actionDetail: true});
- }}>
- <FontAwesome
- name='qrcode'
- size={25}
- color={colorPrimary}/>
- </TouchableOpacity>
- </View> */}
- </View>
- <BottomModal
- visible={this.state.showFilter}
- onHide={() => {
- this.hideFilter()
- }}>
- <Filter
- index={this.state.filterIndex}
- count={this.state.filterTotal}
- onDone={(data, index) => this.findFilter(data, index)}
- onHide={() => this.hideFilter()}/>
- </BottomModal>
- </View>
- );
- }
- }
- const styles = StyleSheet.create({
- searchView: {
- alignItems: 'center',
- flexDirection: 'row',
- ...$padding(8, 16, 16),
- backgroundColor: colorThemes
- },
- searchInput: {
- flex: 1,
- alignItems: 'center',
- borderWidth: 1,
- borderStyle: 'solid',
- borderRadius: 60,
- borderColor: '#CCD0E7',
- flexDirection: 'row',
- paddingLeft: 16,
- paddingRight: 16,
- backgroundColor: 'rgba(255, 255, 255, 0.5)'
- },
- searchText: {
- flex: 1,
- color: '#444',
- padding: 8,
- fontSize: 15
- },
- mapIcon: {
- width: 32,
- height: 32,
- marginLeft: 16,
- alignItems: 'center',
- justifyContent: 'center',
- },
- mapToolView: {
- right: 24,
- zIndex: 10,
- bottom: 112,
- width: 56,
- position: 'absolute',
- alignItems: 'center'
- },
- bottomView: {
- left: 0,
- right: 0,
- bottom: 32,
- zIndex: 210,
- alignItems: 'center',
- position: 'absolute',
- },
- bottomButton: {
- elevation: 1.5,
- paddingLeft: 32,
- paddingRight: 32,
- borderRadius: 54,
- overflow: 'hidden',
- justifyContent: 'center'
- }
- })
|