Skip to content

Commit

Permalink
Replace
Browse files Browse the repository at this point in the history
  • Loading branch information
bannzai committed May 15, 2022
1 parent 6ab7fed commit ca36a9b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ class RecordPagePillSheet extends StatelessWidget {
}
} else if (setting.pillSheetAppearanceMode ==
PillSheetAppearanceMode.sequential) {
final pageOffset =
summarizedPillSheetPillDayCountWithPillSheetsToEndIndex(
pillSheets: pillSheetGroup.pillSheets,
final pageOffset = summarizedPillCountWithPillSheetTypesToEndIndex(
pillSheetTypes:
pillSheetGroup.pillSheets.map((e) => e.pillSheetType).toList(),
endIndex: pageIndex,
);
if (setting.pillNumberForFromMenstruation == 0 ||
Expand Down
13 changes: 0 additions & 13 deletions lib/entity/pill_sheet.codegen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,3 @@ int summarizedPillSheetPillDayCountWithPillSheetsToEndIndex(
1;
});
}

int summarizedPillCountWithPillSheetsToEndIndex(
{required List<PillSheet> pillSheets, required int endIndex}) {
if (endIndex == 0) {
return 0;
}

return pillSheets.sublist(0, endIndex).fold(0, (int result, pillSheet) {
return result +
daysBetween(pillSheet.beginingDate, pillSheet.estimatedEndTakenDate) +
1;
});
}
11 changes: 7 additions & 4 deletions lib/entity/pill_sheet_group.codegen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:pilll/entity/firestore_timestamp_converter.dart';
import 'package:pilll/entity/pill_sheet.codegen.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:pilll/entity/pill_sheet_type.dart';

part 'pill_sheet_group.codegen.g.dart';
part 'pill_sheet_group.codegen.freezed.dart';
Expand Down Expand Up @@ -68,8 +69,9 @@ class PillSheetGroup with _$PillSheetGroup {
}

final passedPillCountForPillSheetTypes =
summarizedPillSheetPillDayCountWithPillSheetsToEndIndex(
pillSheets: pillSheets, endIndex: activedPillSheet.groupIndex);
summarizedPillCountWithPillSheetTypesToEndIndex(
pillSheetTypes: pillSheets.map((e) => e.pillSheetType).toList(),
endIndex: activedPillSheet.groupIndex);

var sequentialTodayPillNumber =
passedPillCountForPillSheetTypes + activedPillSheet.todayPillNumber;
Expand Down Expand Up @@ -103,8 +105,9 @@ class PillSheetGroup with _$PillSheetGroup {
}

final passedPillCountForPillSheetTypes =
summarizedPillSheetPillDayCountWithPillSheetsToEndIndex(
pillSheets: pillSheets, endIndex: activedPillSheet.groupIndex);
summarizedPillCountWithPillSheetTypesToEndIndex(
pillSheetTypes: pillSheets.map((e) => e.pillSheetType).toList(),
endIndex: activedPillSheet.groupIndex);

var sequentialLastTakenPillNumber =
passedPillCountForPillSheetTypes + activedPillSheet.lastTakenPillNumber;
Expand Down

0 comments on commit ca36a9b

Please sign in to comment.