Skip to content

Commit 01b67b8

Browse files
Timer funcionando
1 parent 3892900 commit 01b67b8

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/containers/CardDescription.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const CardDescription: React.FC<ScreenProps> = ({
2424
onPress2,
2525
onPress3,
2626
}) => {
27-
const [timestamp, setTimestamp] = useState("00:00:00");
2827
const [time, setTime] = useState(0);
2928
const [isActive, setIsActive] = useState(false);
3029
let button1 = "";
@@ -77,6 +76,16 @@ const CardDescription: React.FC<ScreenProps> = ({
7776

7877
const navigation = useNavigation();
7978

79+
const getTime = () => {
80+
const min = (time % 3600) / 60;
81+
const hour = time / 3600;
82+
const sec = time % 60;
83+
const formatHour = Math.floor(hour).toString().padStart(2, "0");
84+
const formatMin = Math.floor(min).toString().padStart(2, "0");
85+
const formatSec = sec.toString().padStart(2, "0");
86+
return `${formatHour}:${formatMin}:${formatSec}`;
87+
};
88+
8089
const handlePress1 = () => {
8190
toggle();
8291
onPress1();
@@ -110,7 +119,7 @@ const CardDescription: React.FC<ScreenProps> = ({
110119
style={styles.imagePadding}
111120
source={require("../assets/clock-carousel.png")}
112121
/>
113-
<Text style={styles.normalText}>{time}</Text>
122+
<Text style={styles.normalText}>{getTime()}</Text>
114123
</View>
115124
<View style={styles.cardInfo}>
116125
<Image

tsconfig.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"target": "esnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
55
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
66
"lib": [
7-
"es6"
7+
"es2017",
8+
"dom",
9+
"scripthost"
810
] /* Specify library files to be included in the compilation. */,
911
"allowJs": true /* Allow javascript files to be compiled. */,
1012
// "checkJs": true, /* Report errors in .js files. */

0 commit comments

Comments
 (0)