decreaseMinutes method
Implementation
void decreaseMinutes(BuildContext context, {int min = -5}) {
if (maxHours.isNotNullOrEmpty) {
if ((taskHrsController?.text.length ?? 0) > 4) {
if (taskHrsController?.text
.toHourTime()?.inSeconds == 0) {
return;
}
var time = taskHrsController?.text
.toHourTime()
?.addDuration(Duration(minutes: min));
// var maxTime = Time.fromStr(maxHours.toNotNull);
// var maxTime = timesheetProvider.findBalanceHours(projects: projects, except: currentTask);
Time? maxTime = Time.now();
if (kDebugMode) {
print("MAX_MINUS_TIME:\t$maxTime");
}
if ((maxTime == Time.fromSeconds(0)) || ((maxTime?.inSeconds ?? 0) < (taskHrs.toNotNull.toHourTime()?.inSeconds ?? 0))) {
var actualTaskHrs = taskHrs.toNotNull.toHourTime();
maxTime = actualTaskHrs;
}
if ((time?.inSeconds ?? 0) > (maxTime?.inSeconds ?? 0)) {
Message.showToast(
context: context,
message: "Spent cannot be more than tracked hours",
duration: 3);
} else {
if ((time?.inSeconds ?? 0) >= Time.fromMinutes(5).inSeconds) {
taskHrsController?.text =
"${time?.duration.diff}".toHHMM().toNotNull;
focusNode.unfocus();
} else {
Message.showToast(
context: context,
message: "Spent cannot be less than 5 minutes",
duration: 3);
}
}
}
}
}