mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-09 07:28:14 -07:00
feat: UI 2.0 and other Improvements (#357)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
9ca06eaa37
commit
e7b5bb40ff
169 changed files with 4584 additions and 3626 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:iconsax_plus/iconsax_plus.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:iconsax_plus/iconsax_plus.dart';
|
||||
|
||||
import 'package:fladder/models/book_model.dart';
|
||||
import 'package:fladder/models/item_base_model.dart';
|
||||
|
|
@ -41,6 +41,37 @@ extension ItemBaseModelsBooleans on List<ItemBaseModel> {
|
|||
}
|
||||
return groupedItems;
|
||||
}
|
||||
|
||||
FladderItemType get getMostCommonType {
|
||||
final Map<FladderItemType, int> counts = {};
|
||||
|
||||
for (final item in this) {
|
||||
final type = item.type;
|
||||
counts[type] = (counts[type] ?? 0) + 1;
|
||||
}
|
||||
|
||||
return counts.entries.reduce((a, b) => a.value >= b.value ? a : b).key;
|
||||
}
|
||||
|
||||
double? getMostCommonAspectRatio({double tolerance = 0.01}) {
|
||||
final Map<int, List<double>> buckets = {};
|
||||
|
||||
for (final item in this) {
|
||||
final aspectRatio = item.primaryRatio;
|
||||
if (aspectRatio == null) continue;
|
||||
|
||||
final bucketKey = (aspectRatio / tolerance).round();
|
||||
|
||||
buckets.putIfAbsent(bucketKey, () => []).add(aspectRatio);
|
||||
}
|
||||
|
||||
if (buckets.isEmpty) return null;
|
||||
|
||||
final mostCommonBucket = buckets.entries.reduce((a, b) => a.value.length >= b.value.length ? a : b);
|
||||
|
||||
final average = mostCommonBucket.value.reduce((a, b) => a + b) / mostCommonBucket.value.length;
|
||||
return average;
|
||||
}
|
||||
}
|
||||
|
||||
enum ItemActions {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue