Giter Club home page Giter Club logo

react-native-transition's People

Contributors

basudz365 avatar syaau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-native-transition's Issues

Transition doesn't re-render with conditional renders

component code:

import React from 'react';
import { 
  AppRegistry,
  View,
  StyleSheet,
  DatePickerAndroid,
  TextInput,
  ScrollView, 
  FlatList,
  Image,
} from 'react-native';
import { Button as IconButton } from 'react-native-elements';

import { createTransition,SlideLeft} from 'react-native-transition';

const Transition = createTransition(SlideLeft);

var ImagePicker = require('react-native-image-picker');


class SendScreen extends React.Component {
    constructor(props) {
    super(props);
      this.state = {
      avatarSource: null,
      textBttn : "Select Image"
          };
  } 

   async  _onPressButton() {
    try { 
  const {action, year, month, day} = await DatePickerAndroid.open({
    date: new Date(2020, 4, 25)
  });
  if (action !== DatePickerAndroid.dismissedAction) {
    // Selected year, month (0-11), day
  }
} catch ({code, message}) {
  console.warn('Cannot open date picker', message);
}
  } 

switch = () => {
    Transition.show(
     <View style={{flex: 1,backgroundColor: '#ffffff'}}>
      <View style={{flex: 1,margin: 15,backgroundColor: '#ffffff'}}>
      <Text style={{fontSize: 20,fontWeight: 'bold',marginTop: 8,marginBottom: 20}}> Pickup & Drop Locations </Text>
       <Item regular style={{margin: 10,elevation: 1,height:50,marginRight: 0,shadowColor: '#000000',
    shadowOffset: {
      width: 0,
      height: 3
    },
    shadowRadius: 4,
    shadowOpacity: 1.0}}>
            <Input placeholder='FROM: CITY OR COUNTRY' style={{fontSize: 14}}onChangeText={(text) => this.setState({text})}
        />
          </Item>
      <Item regular style={{margin: 10,elevation: 1,height:50,marginRight: 0,shadowColor: '#000000',
    shadowOffset: {
      width: 0,
      height: 3
    },
    shadowRadius: 4,
    shadowOpacity: 0.1}}>
            <Input placeholder='TO: CITY OR COUNTRY' style={{fontSize: 14}}onChangeText={(text) => this.setState({text})}
        />
          </Item>
     
   <IconButton
          
          icon={{name: "date-range", size: 32}}
          buttonStyle={{backgroundColor: "#397af8", borderRadius: 8, margin: 15}}
          textStyle={{textAlign: 'center'}}
          title={`ENTER DATE`}
          onPress={this._onPressButton}/>

     <View style={{width: 300,
height: 50,position: 'absolute',
bottom: 10,
right: 10}}>     
     <IconButton
          
          icon={{name: "arrow-forward", size: 32}}
          buttonStyle={{
borderRadius: 30,
backgroundColor: '#ee6e73',
}}
          textStyle={{textAlign: 'center'}}
          title={`NEXT`}
          iconRight={true}
          onPress={this.switch}
/>
</View>
          </View>
          </View>

    );
  }

  _selectImage() {

    var options = {
  title: 'Select Image',
  storageOptions: {
    skipBackup: true,
    path: 'images'
  }
  };
  ImagePicker.showImagePicker(options, (response) => {
  console.log('Response = ', response);

  if (response.didCancel) {
    console.log('User cancelled image picker');
  }
  else if (response.error) {
    console.log('ImagePicker Error: ', response.error);
  }
  else {
     let source = { uri: 'data:image/jpeg;base64,' + response.data };

    this.setState({
      avatarSource: source,
      textBttn: "Selected"
    });
  console.log("state = "+this.state.avatarSource);
  console.log("state = "+this.state.textBttn);
  }
});
  }

  static navigationOptions = {
    title: 'SEND ANYTHING ANYWHERE'
  };
 
  render() {
    return (
      
      <View style={{flex: 1,backgroundColor: '#ffffff'}}>
      <Transition>
<View style={{flex: 1,margin: 15,backgroundColor: '#ffffff',}}>
      <Text style={{fontSize: 20,fontWeight: 'bold',marginTop: 10,marginBottom: 20}}> Details of Package </Text>
      { this.state.avatarSource === null ?  
        <IconButton  
          icon={{name: "photo-camera", size: 32}}
          buttonStyle={{backgroundColor: "#397af8", borderRadius: 2,marginLeft: 50,height: 50, width: 200}}
          textStyle={{textAlign: 'center',color: "#000000"}}
          title={this.state.textBttn}
          onPress={() => this._selectImage()}/> : <Image style={styles.avatar} source={this.state.avatarSource} />
          }
   
          
           <View style={{width: 300,
height: 50,position: 'absolute',
bottom: 10,
right: 10}}>     
     <IconButton
          
          icon={{name: "arrow-forward", size: 32}}
          buttonStyle={{
borderRadius: 30,
backgroundColor: '#ee6e73',
}}
          textStyle={{textAlign: 'center'}}
          title={`NEXT`}
          iconRight={true}
          onPress={this.switch}
/>
</View>
 </View>
 </Transition>
          </View>

     );


  }
}

My issue is that the view doesn't re-render when the image is selected, however on removing Transition it is working perfectly. Any ideas why?

Question: Is it possible to use 2 transitions?

I have a setup where I touch a button, and I use the SlideLeft to bring a new page in, but when I close that page, I want it to SlideRight. Right now it will also slide left. Is there a way to specify the reverse animation of the one used to bring the new view in?

Right now my thought is to hold that direction in state, then based on the state render a different transition element. My only worry is that when the app first boots, I have no idea which transition should be the default. I will have a slide from the top down (and then back up when done), slide left, slide right (and their opposites), etc...

Customize existing animations.

Hi,
First of all the library is amazing and pretty easy to use. Now , I have to use the SlideRight and SlideLeft animations but with a slight change. Instead of sliding the view completely I have to slide it partially(upto some specific offset, like a menu drawer). So how can I edit these transitions? Any kind of help is appreciated.

Transition content doesn't render inside a ScrollView

This transition lib doesn't render anything if it's inside a ScrollView. Code to reproduce is very simple:

  <Transition duration={300} easing={Easing.ease}>
    <Text>I don't render :(</Text>
  </Transition>
</ScrollView>

If you switch the ScrollView to a View then it'll render. This was tested on Android, couldn't get my iOS test bed running to test.

I haven't dug into it super deep but it smells like the same issue as ptomasroos/react-native-scrollable-tab-view#187 -- if you use ViewPagerAndroid it's no good, and breaks in ScrollViews.

Transition is not re-rendering child props

It seems that every state under <Transition> tag is not being updated.

Parent Component

import React, { Component } from 'react';
import {
    View,
    Text,
    StyleSheet,
    TouchableOpacity,
} from 'react-native';
import {
    createTransition,
    SlideLeft
} from 'react-native-transition';
import Icon from 'react-native-vector-icons/FontAwesome';

//Modules
import * as Exchange from '../modules/exchanges';


//Pages
import Bundle from './info-bundle';
import EditWallet from './edit-wallet';


const Transition = createTransition(SlideLeft);
//<Bundle backText='PRICE' frontText={this.state.bitcoinPrice} topText='MercadoBitcoin'/>
export default class Main extends Component {
    constructor() {
        super();
        this.state = {
            bitcoinPrice: '2'
        };
    }
    getExchangePrice = (exchange) => {
        console.log('State: ' + this.state.bitcoinPrice);
        console.log('Exchanges: ' + exchange);
        this.setState({ bitcoinPrice: '1' });
    }
    switchToWallet = () => {
        Transition.show(
            <EditWallet />
        );
    }
    render() {
        return (
            <Transition duration={500}>
                <View style={styles.container}>
                    <View style={styles.configButton}>
                        <Icon name="cog" size={40} color='rgba(255,173,0,0.5)'></Icon>
                    </View>
                    <TouchableOpacity
                        style={styles.bundleOrientation}
                        onPress={this.switchToWallet}>
                        <Bundle backText='WALLET' frontText='0.00347' />
                    </TouchableOpacity>
                    <TouchableOpacity style={styles.bundleOrientation} onPress={() => this.getExchangePrice(Exchange.exchanges.MERCADO_BITCOIN)}>
                        <Text style={styles.text1}>{this.state.bitcoinPrice}</Text>
                    </TouchableOpacity>
                    <View style={styles.bundleOrientation}>
                        <Bundle backText='TOTAL' frontText='172.42' />
                    </View>
                </View>
            </Transition>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: 'rgb(58,62,91)',
    },
    bundleOrientation: {
        flex: 1,
        alignSelf: 'stretch',
        zIndex: -1,
    },
    configButton: {
        alignSelf: 'flex-start',
        padding: 15,
        zIndex: 1,
    },
    text1: {
        fontSize: 30,
        alignSelf:'center',
        color:'white'
    }
});

Child Component

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

export default class InfoBundle extends Component {
    render() {
        return (
            <View style={styles.container}>
                <View style={styles.aboveTextView}>
                    <Text style={styles.aboveText}>{this.props.topText}</Text>
                </View>
                <View style={styles.bigTextView}>
                    <Text style={styles.bigText}>{this.props.backText}</Text>
                </View>
                <View style={styles.normalTextView}>
                    <Text style={styles.normalText}>{this.props.frontText}</Text>
                </View>
            </View>
        );
    }
}


const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        alignSelf: 'stretch',
    },
    bigText: {
        color: 'rgba(255,173,0,0.3)',
        fontWeight: 'bold',
        fontSize: 70,
    },
    bigTextView: {
        zIndex: -1
    },
    normalText: {
        color: 'rgb(255,173,0)',
        fontWeight: 'bold',
        fontSize: 40,
    },
    normalTextView: {
        zIndex: 1,
        top: -45
    },
    aboveText: {
        color: 'rgb(255,255,255)',
        fontWeight: 'bold',
    },
    aboveTextView: {
        zIndex: 1,
        bottom: -18
    }

});

When i click the second <TouchableOpacity> in parent component to change child value it just doesn't update.

Maybe this problem is related to #4 .

Please help!

I cloned your example project . It work correctly. But when I add a new screen like this:

import React, { Component } from 'react';
import { View } from 'react-native';
import YourView from './Demo';
class ABC extends Component {
state = { }
render() {
return (
<View style={{ flex: 1}}>
{/* View 1 /}
{/
View 2 , If I remove this line , app run correctly like your demo */}

);
}
}

export default ABC;

result :
simulator screen shot sep 21 2017 4 34 41 pm
when I touch Next button of View 1 , transition effect of view 2 work , transition effect of view 1 not work .
Can you show me how to fix this error? Thank for reading!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.