From eb5e44d6d654abd14979fe15656c2e655fde5dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20CHAUVIN?= Date: Mon, 26 Sep 2022 12:24:05 +0200 Subject: [PATCH] [UPD] made the progress bar easier to modify --- front/components/progressBar.tsx | 63 +++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/front/components/progressBar.tsx b/front/components/progressBar.tsx index d219c0a..79fdc17 100644 --- a/front/components/progressBar.tsx +++ b/front/components/progressBar.tsx @@ -1,25 +1,28 @@ import React from "react"; -import { View } from "react-native"; const ProgressBar = ( - props: { - progress: number; - maxValue: number; + props: { + progress: number; + maxValue: number; barWidth: number; title?: string; }) => { const { progress, maxValue, barWidth, title } = props; + const box = { + width: `${barWidth}%`, + height: 20, + margin: 20, + } + const containerStyles = { - height: 20, - width: `${barWidth}%`, - backgroundColor: "#e0e0de", - borderRadius: 50, - margin: 20 - } - - function computePercent(progress: number, maxValue: number) + padding: 2, + backgroundColor: "#e0e0de", + borderRadius: 50, + } + + function computePercent(progress: number, maxValue: number) { return progress * 100 / maxValue;; } @@ -29,28 +32,43 @@ const ProgressBar = ( width: `${computePercent(progress, maxValue)}%`, backgroundColor: "#18A558", borderRadius: 'inherit', - textAlign: 'center' + textAlign: 'center', } - + const labelStyles = { padding: 5, color: 'white', - fontWeight: 'bold' + fontWeight: 'bold', + } + + const titleStyle = { + padding: 5, + color: 'black', + fontWeight: 'bold', + fontSize: 20, + textAlign: 'center', } if (title != null) { - // put the title in the middle TODO return ( -
-
- - {`${computePercent(progress, maxValue)}%`} - +
+
+ {title}
+
+
+ + {`${computePercent(progress, maxValue)}%`} + +
+
+

ceci est un sous titre yay

- ); + ); } + return ( +
@@ -58,6 +76,7 @@ const ProgressBar = (
+
); }