TetraStats/lib/utils/colors_functions.dart

24 lines
872 B
Dart
Raw Normal View History

2024-03-24 16:38:06 +00:00
import 'package:flutter/material.dart';
Color getColorOfRank(int rank){
if (rank == 1) return Colors.yellowAccent;
if (rank == 2) return Colors.blueGrey;
if (rank == 3) return Colors.brown[400]!;
if (rank <= 9) return Colors.blueAccent;
if (rank <= 99) return Colors.greenAccent;
return Colors.grey;
2024-09-08 22:10:51 +00:00
}
Color? getStatColor(num value, num? avgValue, bool higherIsBetter){
if (avgValue == null) return null;
num percentile = (higherIsBetter ? value / avgValue : avgValue / value).abs();
if (percentile > 1.50) return Colors.purpleAccent;
if (percentile > 1.20) return Colors.blueAccent;
if (percentile > 0.90) return Colors.greenAccent;
if (percentile > 0.70) return Colors.yellowAccent;
return Colors.redAccent;
}
2024-09-08 22:10:51 +00:00
Color getDifferenceColor(num diff){
return diff.isNegative ? Colors.redAccent : Colors.greenAccent;
2024-03-24 16:38:06 +00:00
}