You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

155 lines
4.4 KiB

  1. import React, {Component} from 'react';
  2. import { StyleSheet, TouchableOpacity, Text,FlatList } from 'react-native';
  3. import { Container, Header, Content, List, ListItem, Left, Body, Right, Title, Button, Icon, Row,Col,Card, CardItem, Footer, View } from 'native-base';
  4. import { api_url, faq, font_title, font_description } from '../config/Constants';
  5. import Accordian from '../config/Accordian';
  6. import * as colors from '../assets/css/Colors';
  7. import { Loader } from '../components/GeneralComponents';
  8. import axios from 'axios';
  9. import { connect } from 'react-redux';
  10. import { fb } from '../config/firebaseConfig';
  11. import { serviceActionPending, serviceActionError, serviceActionSuccess } from '../actions/FaqActions';
  12. class Faq extends Component<Props> {
  13. constructor(props) {
  14. super(props)
  15. this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
  16. this.Faq();
  17. }
  18. handleBackButtonClick= () => {
  19. this.props.navigation.goBack(null);
  20. }
  21. faq_details = (data) => {
  22. this.props.navigation.navigate('FaqDetails',{ data : data });
  23. }
  24. Faq = async () => {
  25. this.props.serviceActionPending();
  26. await axios({
  27. method: 'get',
  28. url: api_url + faq
  29. })
  30. .then(async response => {
  31. await this.props.serviceActionSuccess(response.data)
  32. })
  33. .catch(error => {
  34. this.props.serviceActionError(error);
  35. });
  36. }
  37. render() {
  38. const { isLoding, error, data, message, status } = this.props
  39. return (
  40. <Container>
  41. <View>
  42. <View style={styles.faq_style1}>
  43. <TouchableOpacity style={styles.faq_style2} onPress={this.handleBackButtonClick} activeOpacity={1} >
  44. <Icon onPress={this.handleBackButtonClick} style={styles.faq_style3} name='arrow-back' />
  45. </TouchableOpacity>
  46. <View style={styles.faq_style4} />
  47. <Text style={styles.faq_style5}>Faq</Text>
  48. </View>
  49. </View>
  50. <Content>
  51. <List>
  52. <FlatList
  53. data={data}
  54. renderItem={({ item,index }) => (
  55. <ListItem onPress={() => this.faq_details(item)} >
  56. <Left>
  57. <Text style={styles.faq_style6} >{item.question}</Text>
  58. </Left>
  59. <Right>
  60. <Icon style={styles.faq_style7} name="ios-arrow-forward" />
  61. </Right>
  62. </ListItem>
  63. )}
  64. keyExtractor={item => item.question}
  65. />
  66. </List>
  67. </Content>
  68. {/* <Loader visible={isLoding} /> */}
  69. </Container>
  70. );
  71. }
  72. }
  73. function mapStateToProps(state){
  74. return{
  75. isLoding : state.faq.isLoding,
  76. error : state.faq.error,
  77. data : state.faq.data,
  78. message : state.faq.message,
  79. status : state.faq.status,
  80. };
  81. }
  82. const mapDispatchToProps = (dispatch) => ({
  83. serviceActionPending: () => dispatch(serviceActionPending()),
  84. serviceActionError: (error) => dispatch(serviceActionError(error)),
  85. serviceActionSuccess: (data) => dispatch(serviceActionSuccess(data))
  86. });
  87. export default connect(mapStateToProps,mapDispatchToProps)(Faq);
  88. const styles = StyleSheet.create({
  89. faq_style1:{alignItems:'flex-start', margin:10},
  90. faq_style2:{width:100, justifyContent:'center'},
  91. faq_style3:{color:colors.theme_fg_two, fontSize:30},
  92. faq_style4:{margin:5},
  93. faq_style5:{fontSize:25, color:colors.theme_fg_two, fontFamily: font_title},
  94. faq_style6:{color: colors.theme_fg_two,fontFamily:font_title,fontSize: 15},
  95. faq_style7:{color:colors.theme_fg_two},
  96. container: {
  97. alignItems: 'center'
  98. },
  99. header: {
  100. justifyContent: "flex-start",
  101. height: "10%",
  102. backgroundColor: colors.theme_bg,
  103. borderBottomLeftRadius: 45,
  104. borderBottomRightRadius: 45,
  105. shadowOffset: { width: 0, height: 15 },
  106. shadowColor: colors.theme_bg,
  107. shadowOpacity: 0.1,
  108. shadowRadius: 8,
  109. elevation: 10,
  110. },
  111. header_card: {
  112. alignItems: "center",
  113. borderRadius: 15,
  114. justifyContent: "center",
  115. },
  116. header_card_item: {
  117. borderTopLeftRadius: 15,
  118. borderTopRightRadius: 15,
  119. borderBottomLeftRadius: 15,
  120. borderBottomRightRadius: 15,
  121. shadowOffset: { width: 0, height: 15 },
  122. shadowColor: colors.theme_bg,
  123. shadowOpacity: 0.1,
  124. shadowRadius: 8,
  125. elevation: 10,
  126. },
  127. header_body: {
  128. flex: 3,
  129. justifyContent: 'center'
  130. },
  131. title:{
  132. alignSelf:'center',
  133. color:colors.theme_fg_two,
  134. alignSelf:'center',
  135. fontSize:16,
  136. fontFamily:font_title,
  137. },
  138. });