calendar fix and update.
This commit is contained in:
@@ -19,6 +19,7 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
|
||||
Map<String, List<File>> _groupedFiles = {}; // Files grouped by folder
|
||||
Map<String, DateTime> _folderCreationDates = {}; // Folder creation dates
|
||||
Map<String, int> _folderScores = {}; // Folder scores (sum of scores of all target files inside)
|
||||
Map<String, int> _fileScores = {}; // Per-file score cache to avoid sync reads in build
|
||||
Color _bulletColor = Colors.blue; // default fallback
|
||||
Map<String, bool> _folderTypes = {}; // true = tournament, false = training
|
||||
String _folderFilter = 'all';
|
||||
@@ -136,6 +137,7 @@ Color _getColorFromName(String colorName) {
|
||||
Map<String, DateTime> folderDates = {};
|
||||
Map<String, int> folderScores = {};
|
||||
Map<String, bool> folderTypes = {};
|
||||
Map<String, int> fileScores = {};
|
||||
|
||||
for (var folder in folders) {
|
||||
String folderName = folder.path.split('/').last;
|
||||
@@ -177,7 +179,9 @@ Color _getColorFromName(String colorName) {
|
||||
for (var file in targetFiles) {
|
||||
final jsonString = await file.readAsString();
|
||||
final data = jsonDecode(jsonString);
|
||||
totalScore += _getScoreFromJson(data);
|
||||
final score = _getScoreFromJson(data);
|
||||
fileScores[file.path] = score;
|
||||
totalScore += score;
|
||||
}
|
||||
|
||||
groupedFiles[folderName] = targetFiles;
|
||||
@@ -201,6 +205,7 @@ Color _getColorFromName(String colorName) {
|
||||
_folderTypes = {
|
||||
for (var name in sortedFolderNames) name: folderTypes[name]!
|
||||
};
|
||||
_fileScores = fileScores;
|
||||
});
|
||||
} catch (e) {
|
||||
debugPrint("Error loading target data files: $e");
|
||||
@@ -782,7 +787,7 @@ Widget _buildTargetsList(String folderName) {
|
||||
children: targetFiles.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final file = entry.value;
|
||||
final score = _getScoreFromJson(jsonDecode(file.readAsStringSync()));
|
||||
final score = _fileScores[file.path] ?? 0;
|
||||
final fileName = "${_t('Target')} ${index + 1}";
|
||||
|
||||
return Container(
|
||||
|
||||
Reference in New Issue
Block a user