React native 本机基地SwipeRow-可以';t增加按下/触摸不透明度

React native 本机基地SwipeRow-可以';t增加按下/触摸不透明度,react-native,native-base,React Native,Native Base,我试图将TouchableOpacity添加到native base的SwipeRow组件中,但它不起作用。 如果我在我的“body”项目中添加TouchableOpacity,则列表中不会显示任何内容。 在我当前的代码中,只有当我点击每个项目的边缘(如分割每个项目的线)…在项目中心,什么都不会发生时,触摸才会起作用。刷得很好。 这是我的代码: import React, { Component } from "react"; import { Container, Header,

我试图将TouchableOpacity添加到native base的SwipeRow组件中,但它不起作用。 如果我在我的“body”项目中添加TouchableOpacity,则列表中不会显示任何内容。 在我当前的代码中,只有当我点击每个项目的边缘(如分割每个项目的线)…在项目中心,什么都不会发生时,触摸才会起作用。刷得很好。 这是我的代码:

import React, { Component } from "react";
import {
  Container,
  Header,
  Title,
  Content,
  Text,
  Button,
  Icon,
  SwipeRow,
  Left,
  Body,
  Footer
} from "native-base";
import { FlatList, View, TouchableOpacity } from "react-native";
import { connect } from "react-redux";
import ArchiveItem from "./components/archiveItem";

import styles from "./styles";
import { translate } from "../../i18n";
var i18n_opt = { scope: "archive" };

class Archive extends Component {
  rows = [];
  constructor(props) {
    super(props);
    this.rows = [];
  }

  _renderItem = ({ item }) => {
    return (
      <TouchableOpacity onPress={() => alert("teste")}>
        <SwipeRow
          style={styles.swipe}
          ref={c => {
            this.rows.push({ ref: c, id: item.id });
          }}
          rightOpenValue={-65}
          onRowOpen={() => {
            this.rows.forEach(ref => {
              if (ref.id != item.id) {
                ref.ref._root.closeRow();
              }
            });
          }}
          body={<ArchiveItem item={item} />}
          right={
            <Button
              danger
              onPress={() => alert("Trash")}
              style={styles.swipebuttons}
            >
              <Icon active name="trash" />
            </Button>
          }
        />
      </TouchableOpacity>
    );
  };

  render() {
    const { archive } = this.props;

    return (
      <Container style={styles.container}>
        <Header>
          <Left>
            <Button
              transparent
              onPress={() => this.props.navigation.navigate("DrawerOpen")}
            >
              <Icon name="menu" />
            </Button>
          </Left>
          <Body>
            <Title>{translate("title", { ...i18n_opt })}</Title>
          </Body>
        </Header>

        <Content>
          <FlatList
            data={archive}
            renderItem={this._renderItem}
            keyExtractor={item => item.id.toString()}
          />
        </Content>

        <Footer>
          <Button
            onPress={() => {
              this.rows.forEach(ref => {
                ref.ref._root.closeRow();
              });
            }}
          >
            <Text>teste</Text>
          </Button>
        </Footer>
      </Container>
    );
  }
}

const mapStateToProps = state => {
  return {
    archive: state.archive
  };
};

export default connect(
  mapStateToProps,
  {}
)(Archive);
import React,{Component}来自“React”;
进口{
集装箱,
标题,
标题
内容,,
文本,
按钮
偶像
斯威佩罗,
左边
身体,
页脚
}来自“本土基地”;
从“react native”导入{FlatList,View,TouchableOpacity};
从“react redux”导入{connect};
从“/components/ArchiveItem”导入ArchiveItem;
从“/styles”导入样式;
从“./../i18n”导入{translate}”;
var i18n_opt={scope:“archive”};
类存档扩展了组件{
行=[];
建造师(道具){
超级(道具);
this.rows=[];
}
_renderItem=({item})=>{
返回(
警报(“测试仪”)}>
{
this.rows.push({ref:c,id:item.id});
}}
rightOpenValue={-65}
onRowOpen={()=>{
this.rows.forEach(ref=>{
如果(参考id!=项目id){
ref.ref._root.closeRow();
}
});
}}
正文={}
对={
警报(“垃圾”)}
style={styles.swipebuttons}
>
}
/>
);
};
render(){
const{archive}=this.props;
返回(
this.props.navigation.navigate(“drawerropen”)}
>
{翻译(“标题,{…i18n_opt})}
item.id.toString()}
/>
{
this.rows.forEach(ref=>{
ref.ref._root.closeRow();
});
}}
>
睾丸
);
}
}
常量mapStateToProps=状态=>{
返回{
存档:state.archive
};
};
导出默认连接(
MapStateTops,
{}
)(档案);
以及该项目:

import React, { Component } from "react";
import {Text, TouchableHighlight, View} from 'react-native';

import {
    Grid,
    Row,
    Col
} from 'native-base';

import styles from "../styles";


class ArchiveItem extends Component {

    render() {

        const item = this.props.item;

        return (

                <Grid>                                        
                    <Col size={90}>                    
                        <Row>
                            <Col size={67}><Text style={{alignSelf: 'flex-start', fontWeight: 'bold', fontSize: 14}}>Jonis</Text></Col>
                            <Col size={33}><Text style={{fontSize: 10, alignSelf: 'flex-end', marginRight: 3}}>Total time: 00:00:01</Text></Col>
                        </Row>
                        <Row>
                            <Col><Text style={styles.itemHeaderText}>Laps</Text></Col>
                            <Col><Text style={styles.itemHeaderText}>Last Lap</Text></Col>
                            <Col><Text style={styles.itemHeaderText}>Best lap</Text></Col>
                            <Col><Text style={styles.itemHeaderText}>Best time</Text></Col>
                            <Col><Text style={[styles.itemHeaderText,styles.itemAlignRight, {marginRight: 5}]}>Dif</Text></Col>
                        </Row>
                        <Row>
                            <Col><Text style={styles.itemValueText}>30</Text></Col>
                            <Col><Text style={[styles.itemValueText, {fontWeight: 'bold'}]}>01:02:03</Text></Col>
                            <Col><Text style={styles.itemValueText}>8</Text></Col>
                            <Col><Text style={[styles.itemValueText, { color: '#90db18', fontWeight: 'bold' }]}>01:01:01</Text></Col>
                            <Col><Text style={[styles.itemValueText,styles.itemAlignRight, {marginRight: 5}]}>+1s</Text></Col>
                        </Row>                            
                    </Col>                    
                </Grid>   

        );

    }


}


export default ArchiveItem;
import React,{Component}来自“React”;
从“react native”导入{Text,TouchableHighlight,View};
进口{
网格,
一行
上校
}来自“本土基地”;
从“./样式”导入样式;
类ArchiveItem扩展组件{
render(){
const item=this.props.item;
返回(
乔尼斯
总时间:00:00:01
膝
最后一圈
最佳圈数
最佳时机
Dif
30
01:02:03
8.
01:01:01
+1s
);
}
}
导出默认档案项;

touchablepacity
包裹
SwipeRow
而不是用
touchablepacity
包裹
ArchiveItem

只需用touchablepacity包裹SwipeRow的主体道具,就可以了me@Oleg明亮的