Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 49 additions & 7 deletions app/(modals)/grade.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,29 @@ interface GradesModalProps {
avgClass: number;
}

interface GradeBadgeProps {
icon: string;
label: string;
color: string;
theme: any;
is_outlined?: boolean;
}

const GradeBadge = ({ icon, label, color, theme, is_outlined = false }: GradeBadgeProps) => {
const backgroundColor = is_outlined ? "transparent" : adjust(color, theme.dark ? 0.3 : -0.3);
const textColor = is_outlined ? color : (colorCheck("#FFFFFF", [backgroundColor]) ? "#FFFFFF" : "#000000");
const borderStyle = is_outlined ? { borderWidth: 1, borderColor: color } : undefined;

return (
<Stack direction="horizontal" gap={8} backgroundColor={backgroundColor} vAlign="center" hAlign="center" padding={[12, 6]} radius={32} style={borderStyle}>
<Papicons size={20} name={icon} color={textColor} />
<Typography color={textColor} variant='body2'>
{label}
</Typography>
</Stack>
);
};

export default function GradesModal() {
const { params } = useRoute();
const theme = useTheme();
Expand Down Expand Up @@ -159,14 +182,33 @@ export default function GradesModal() {
/>

{grade.studentScore?.value === grade.maxScore?.value && !grade.studentScore?.disabled &&
<Stack direction="horizontal" gap={8} backgroundColor={adjust(subjectInfo.color, theme.dark ? 0.3 : -0.3)} vAlign='center' hAlign='center' padding={[12, 6]} radius={32} key={"bestgrade:" + theme.dark ? "dark" : "light"}>
<Papicons size={20} name="crown" color={colorCheck("#FFFFFF", [adjust(subjectInfo.color, theme.dark ? 0.3 : -0.3)]) ? "#FFFFFF" : "#000000"} />
<Typography color={colorCheck("#FFFFFF", [adjust(subjectInfo.color, theme.dark ? 0.3 : -0.3)]) ? "#FFFFFF" : "#000000"} variant='body2'>
{t("Modal_Grades_BestGrade")}
</Typography>
</Stack>
<GradeBadge
icon="crown"
label={t("Modal_Grades_BestGrade")}
color={subjectInfo.color}
theme={theme}
is_outlined={false}
/>
}
{grade.optional &&
<GradeBadge
icon="info"
label={t("Modal_Grades_OptionalGrade")}
color={subjectInfo.color}
theme={theme}
is_outlined={true}
/>
}

{grade.bonus &&
<GradeBadge
icon="info"
label={t("Modal_Grades_BonusGrade")}
color={subjectInfo.color}
theme={theme}
is_outlined={true}
/>
}
<Stack
card
direction="horizontal"
Expand Down Expand Up @@ -213,4 +255,4 @@ export default function GradesModal() {
/>
</>
)
}
}
2 changes: 2 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@
"Profile_Cards_Title": "QR-code and cards",
"Modal_Grades_Title": "Grade details",
"Modal_Grades_BestGrade": "Best grade of your group",
"Modal_Grades_OptionalGrade": "Optional grade",
"Modal_Grades_BonusGrade": "Bonus grade",
"Grades_Details_Title": "Details",
"Grades_NormalizedGrade_Title": "Grade normalized to 20",
"Grades_NormalizedGrade_Description": "Grade value converted to a scale of 20",
Expand Down
3 changes: 3 additions & 0 deletions locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@
"Modal_Grades_Title": "Détail de la note",
"Modal_Grades_BestGrade": "Meilleure note du groupe",

"Modal_Grades_OptionalGrade": "Note optionnelle",
"Modal_Grades_BonusGrade": "Note bonus",

"Grades_Details_Title": "Détails",
"Grades_NormalizedGrade_Title": "Note ramenée sur 20",
"Grades_NormalizedGrade_Description": "Valeur de la note convertie sur une échelle de 20",
Expand Down