Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 28480

Icons from react-native-vector-icons onpress needs to click twice to work

$
0
0

I use react-native-vector-icons.

  1. Click the input
  2. Keyboard goes up
  3. When pressing the icon, icon doesn't trigger, the keyboard will go down first rather than the onpress method icon triggers while having the keyboard is on

Expected Result would like a live chat, while keyboard is up submit icon will always trigger.

I tried to enwrap it in scrollview with keyboardshouldpersisttaps and it doesn't work.

<KeyboardAvoidingView
        behavior={Platform.OS === 'ios' ? 'padding' : null}
        style={{ flex: 1 }}
        keyboardVerticalOffset={64}
      >
        <View style={styles.slide} key={i}>
          <TouchableHighlight
            style={styles.video}
            onPress={this.handleDoubleTap}
            onLongPress={this.handlePlayAndPause}
          >
            <ViewportAwareVideo
              key={i}
              source={{ uri: firstVideoUri }}
              shouldPlay={this.state.shouldPlay}
              isLooping
              preTriggerRatio={-0.4} // default is 0
              retainOnceInViewport={false} // default is false
              style={styles.video}
              onPlaybackStatusUpdate={this._onPlaybackStatusUpdate}
              progressUpdateIntervalMillis={1000}
              resizeMode='contain'
              innerRef={ref => (this._videoRef = ref)}
              onViewportEnter={() => {
                this.setState({ shouldPlay: true });
              }}
              onViewportLeave={() => {
                this.setState({ shouldPlay: false });
              }}
            />
          </TouchableHighlight>

          {this.state.shouldPlay ? null : (
            <TouchableHighlight
              onPress={this.handlePlayAndPause}
              style={styles.pauseBtn}
            >
              <IconComponent name='play-circle' size={50} color='black' />
            </TouchableHighlight>
          )}

          <CopilotStep
            name='swipeUp'
            text='Swipe up to view next video'
            order={5}
          >
            <WalkthroughableView style={styles.topSection}>
              <Text style={styles.imageHeadingText}>{product.name}</Text>
              {product.short_description === '' ? null : (
                <HTML
                  html={product.short_description}
                  imagesMaxWidth={Dimensions.get('window').width}
                  containerStyle={styles.imageDescText}
                  baseFontStyle={styles.htmlStyle}
                />
              )}
              <CopilotStep
                name='swipeRight'
                text='Swipe right to view product details'
                order={6}
              >
                <WalkthroughableView
                  style={{
                    flexDirection: 'row',
                    flexWrap: 'wrap',
                    paddingHorizontal: 20,
                    paddingVertical: 5
                  }}
                >
                  {product.tags.map((value, index) => {
                    return (
                      <Text key={index} style={styles.tagText}>
                        {value.name.charAt(0) === '#'
                          ? value.name
                          : '#' + value.name}
                      </Text>
                    );
                  })}
                </WalkthroughableView>
              </CopilotStep>
              {product.total_sales > 0 ? (
                <View
                  style={{
                    flexDirection: 'row',
                    flexWrap: 'wrap',
                    paddingHorizontal: 20,
                    paddingVertical: 5
                  }}
                >
                  <Text style={styles.totalSales}>
                    {product.total_sales +
                      (product.total_sales > 100
                        ? '+ bought'
                        : ' bought in the last 24 hours')}
                  </Text>
                </View>
              ) : null}
            </WalkthroughableView>
          </CopilotStep>

          <View style={styles.bottomSection}>
            <View style={{ flex: 1, justifyContent: 'flex-end', height: 30 }}>
              {this.state.messages.map((message, index) => (
                <React.Fragment key={index}>
                  <View
                    key={index}
                    style={{
                      flexDirection: 'row',
                      alignItems: 'center',
                      marginHorizontal: 5,
                      marginVertical: 5,
                      paddingLeft: 10,
                      height: 20
                    }}
                  >
                    <Image
                      style={{ width: 20, height: 20, borderRadius: 20 / 2 }}
                      source={{ uri: 'https://picsum.photos/20/20' }}
                    />
                    <Text
                      style={{
                        fontFamily: Constants.fontHeader,
                        marginHorizontal: 5,
                        color: '#007AFF'
                      }}
                    >
                      {message.user.name}
                    </Text>
                    <Text
                      style={{
                        fontFamily: Constants.fontHeader,
                        marginHorizontal: 5,
                        color: 'white'
                      }}
                    >
                      {message.text}
                    </Text>
                  </View>
                </React.Fragment>
              ))}
            </View>
            <CopilotStep
              name='chatOnFeed'
              text='Click here to chat on video feed'
              order={7}
            >
              <WalkthroughableTextInput
                style={{
                  // position: 'absolute',
                  // bottom: 0,
                  // left: 0,
                  fontFamily: Constants.fontFamily,
                  marginBottom: 110,
                  marginHorizontal: 5,
                  marginVertical: 5,
                  paddingRight: 35,
                  paddingLeft: 20,
                  height: 35,
                  width: width - 60,
                  backgroundColor: 'white',
                  borderRadius: 25
                }}
                onChangeText={messageText => this.setState({ messageText })}
                value={this.state.messageText}
                placeholder='Share your thoughts'
                placeholderTextColor='#9B9B9B'
              />
            </CopilotStep>

            <IconComponent
              style={{ position: 'absolute', bottom: 115, right: 10 }}
              name='arrow-right'
              size={25}
              color='black'
              onPress={product => this.sendMessage(product)}
            />
          </View>

          <View style={styles.iconBar}>
            <CopilotStep
              name='productDetail'
              text='Click here to got to product details'
              order={8}
            >
              <WalkthroughableText>
                <IconComponent
                  style={styles.iconBarIcon}
                  name='shopping-cart'
                  size={iconSize}
                  color='white'
                  onPress={() => {
                    this.props.onViewProductScreen({ product });
                    this.setState({ shouldPlay: false });
                  }}
                />
              </WalkthroughableText>
            </CopilotStep>
            <Text style={styles.iconBarText}>Shop</Text>
            <CopilotStep
              name='like'
              text='Click here to like this product'
              order={9}
            >
              <WalkthroughableText>
                <Entypo
                  style={styles.iconBarIcon}
                  name='heart'
                  size={30}
                  color={this.state.isInWishList ? 'red' : 'white'}
                  onPress={() => {
                    this.state.isInWishList
                      ? this.props.removeWishListItem(product)
                      : this.props.addWishListItem(product);

                    this.setState(prevState => ({
                      isInWishList: !prevState.isInWishList
                    }));
                  }}
                />
              </WalkthroughableText>
            </CopilotStep>
            <Text style={styles.iconBarText}>Like</Text>
            <CopilotStep
              name='share'
              text='Click here to share this product'
              order={10}
            >
              <WalkthroughableText>
                <IconComponent
                  style={styles.iconBarIcon}
                  name='share'
                  size={iconSize}
                  color='white'
                  onPress={this.onShare}
                />
              </WalkthroughableText>
            </CopilotStep>
            <Text style={styles.iconBarText}>Share</Text>
            <CopilotStep
              name='fullChat'
              text='Click here to view full chat'
              order={11}
            >
              <WalkthroughableText>
                <IconComponent
                  style={[styles.iconBarIcon, { paddingTop: 4 }]}
                  name='message-circle'
                  size={iconSize}
                  color='white'
                  onPress={product => this.sendChat(product)}
                />
              </WalkthroughableText>
            </CopilotStep>
          </View>
        </View>
      </KeyboardAvoidingView>
    );

You can see my problem is on IconComponent after the WalkthroughableTextInput


Viewing all articles
Browse latest Browse all 28480

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>