Guest User

Untitled

a guest
Jan 16th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. import React from 'react'
  2. import PropTypes from 'prop-types'
  3. import { withNavigation } from 'react-navigation'
  4. import { View, TouchableOpacity, Text, StyleSheet } from 'react-native'
  5. import Ionicons from 'react-native-vector-icons/Ionicons'
  6.  
  7. class HeaderDropdown extends React.Component {
  8. toggleDropdownVisibility = () => {
  9. const isWalletDropdownVisible = this.props.navigation.getParam(
  10. 'isWalletDropdownVisible'
  11. )
  12.  
  13. // toggle dropdown
  14. this.props.navigation.setParams({
  15. isWalletDropdownVisible: !isWalletDropdownVisible
  16. })
  17. }
  18.  
  19. render () {
  20. const isWalletDropdownVisible = this.props.navigation.getParam(
  21. 'isWalletDropdownVisible'
  22. )
  23.  
  24. return (
  25. <TouchableOpacity
  26. activeOpacity={0.7}
  27. onPress={this.toggleDropdownVisibility}
  28. >
  29. <View style={styles.textWrap}>
  30. <Text style={styles.text}>{this.props.title}</Text>
  31. <View style={styles.iconWrap}>
  32. <Ionicons
  33. name={isWalletDropdownVisible ? 'ios-arrow-up' : 'ios-arrow-down'}
  34. color={'rgba(255, 255, 255, 0.7)'}
  35. size={14}
  36. />
  37. </View>
  38. </View>
  39. </TouchableOpacity>
  40. )
  41. }
  42. }
  43.  
  44. HeaderDropdown.propTypes = {
  45. navigation: PropTypes.object.isRequired,
  46. title: PropTypes.string.isRequired
  47. }
  48.  
  49. const styles = StyleSheet.create({
  50. textWrap: {
  51. display: 'flex',
  52. flexDirection: 'row',
  53. alignItems: 'center'
  54. },
  55. text: {
  56. display: 'flex',
  57. alignItems: 'center',
  58. color: '#fff',
  59. fontSize: 16,
  60. fontWeight: 'bold'
  61. },
  62. iconWrap: {
  63. marginTop: 2,
  64. marginLeft: 3
  65. }
  66. })
  67.  
  68. export default withNavigation(HeaderDropdown)
Add Comment
Please, Sign In to add comment