Application Android et IOS pour l'amicale des élèves https://play.google.com/store/apps/details?id=fr.amicaleinsat.application
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.

NetworkErrorComponent.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // @flow
  2. import * as React from 'react';
  3. import {Button, Subheading, withTheme} from 'react-native-paper';
  4. import {StyleSheet, View} from "react-native";
  5. import {MaterialCommunityIcons} from "@expo/vector-icons";
  6. import i18n from 'i18n-js';
  7. type Props = {
  8. message: string,
  9. icon: string,
  10. onRefresh: Function,
  11. }
  12. type State = {
  13. refreshing: boolean,
  14. }
  15. class NetworkErrorComponent extends React.PureComponent<Props, State> {
  16. colors: Object;
  17. state = {
  18. refreshing: false,
  19. };
  20. constructor(props) {
  21. super(props);
  22. this.colors = props.theme.colors;
  23. }
  24. render() {
  25. return (
  26. <View style={{
  27. ...styles.outer,
  28. backgroundColor: this.colors.background
  29. }}>
  30. <View style={styles.inner}>
  31. <View style={styles.iconContainer}>
  32. <MaterialCommunityIcons
  33. name={this.props.icon}
  34. size={150}
  35. color={this.colors.textDisabled}/>
  36. </View>
  37. <Subheading style={{
  38. ...styles.subheading,
  39. color: this.colors.textDisabled
  40. }}>
  41. {this.props.message}
  42. </Subheading>
  43. <Button
  44. mode={'contained'}
  45. icon={'refresh'}
  46. onPress={this.props.onRefresh}
  47. style={styles.button}
  48. >
  49. {i18n.t("general.retry")}
  50. </Button>
  51. </View>
  52. </View>
  53. );
  54. }
  55. }
  56. const styles = StyleSheet.create({
  57. outer: {
  58. height: '100%',
  59. },
  60. inner: {
  61. marginTop: 'auto',
  62. marginBottom: 'auto',
  63. },
  64. iconContainer: {
  65. marginLeft: 'auto',
  66. marginRight: 'auto',
  67. marginBottom: 20
  68. },
  69. subheading: {
  70. textAlign: 'center',
  71. },
  72. button: {
  73. marginTop: 10,
  74. marginLeft: 'auto',
  75. marginRight: 'auto',
  76. }
  77. });
  78. export default withTheme(NetworkErrorComponent);