Moved helper_functions to utils
Signed-off-by: Andreas Fahrecker <AndreasFahrecker@gmail.com>
This commit is contained in:
17
lib/utils/helper_functions.dart
Normal file
17
lib/utils/helper_functions.dart
Normal file
@ -0,0 +1,17 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:time_progress_tracker/models/time_progress.dart';
|
||||
|
||||
TimeProgress selectProgressById(List<TimeProgress> tpList, String id) =>
|
||||
tpList.firstWhere((tp) => tp.id == id, orElse: null);
|
||||
|
||||
List<TimeProgress> selectActiveProgresses(List<TimeProgress> tpList) =>
|
||||
tpList.where((tp) => tp.hasStarted() && !tp.hasEnded()).toList();
|
||||
|
||||
List<TimeProgress> selectInactiveProgresses(List<TimeProgress> tpList) =>
|
||||
tpList.where((tp) => !tp.hasStarted() || tp.hasEnded()).toList();
|
||||
|
||||
bool useBrightBackground(Color bC) {
|
||||
double yiq = ((bC.red * 299) + (bC.green * 587) + (bC.blue * 114)) / 1000;
|
||||
return yiq >= 186 || (bC.red == 0 && bC.green == 0 && bC.blue == 0);
|
||||
}
|
Reference in New Issue
Block a user