-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcard.js
116 lines (90 loc) · 2.69 KB
/
card.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
CARD NAME:
CARD AUTHOR:
CREATION DATE:
NOTES:
*/
import React, {Component} from 'react';
import CardComponent from './CardComponent.js';
// Add elements here for React Native components
import { StyleSheet, Text, View } from 'react-native';
// Add elements here for React Native Paper components
import { Button } from 'react-native-paper';
const size = {
width: 400,
height: 500
};
class Card extends Component{
// Card state
state = {
status: "loading",
statusText: "Stiamo caricando un po' di cose",
progress: 0
};
constructor(props){
super(props);
}
render(){
return (
<CardComponent title="Card title" size={size} status={this.state.status} statusText={this.state.statusText} progress={this.state.progress}>
{/* INSERT HERE THE CARD CONTENT */}
<Text>Card content</Text>
</CardComponent>
);
}
componentDidMount(){
// Example
setTimeout(() => {
this.setStatus("ready");
}, 2000);
}
/*
Function to call in order to update the component status
ATTENZIONE: NON MODIFICARE QUESTE FUNZIONI
*/
setStatus(type="loading", description="", progress=0){
switch (type) {
case "loading":
this.setState({
status: type,
statusText: description || "Stiamo caricando un po' di cose",
loadingText: description,
});
break;
case "progress":
this.setState({
status: type,
statusText: description || "Un po' di pazienza",
progressText: description,
progress: progress
});
break;
case "error":
this.setState({
status: type,
statusText: description || "Sembra esserci stato un problema",
errorText: description,
});
break;
case "done":
this.setState({
status: type,
statusText: description || "Ora puoi proseguire con le altre operazioni",
doneText: description,
});
break;
case "ready":
this.setState({
status: type,
});
break;
}
}
updateProgress(progress=0){
this.setState({progress});
}
}
// MODIFY STYLES HERE
const styles = new StyleSheet.create({
});
export default Card;