Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix #593

Merged
merged 6 commits into from
May 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ class RecordPagePillSheet extends StatelessWidget {
}
} else if (setting.pillSheetAppearanceMode ==
PillSheetAppearanceMode.sequential) {
final pageOffset = summarizedPillCountWithPillSheetsToEndIndex(
pillSheets: pillSheetGroup.pillSheets,
final pageOffset = summarizedPillCountWithPillSheetTypesToEndIndex(
pillSheetTypes:
pillSheetGroup.pillSheets.map((e) => e.pillSheetType).toList(),
endIndex: pageIndex,
);
if (setting.pillNumberForFromMenstruation == 0 ||
Expand Down Expand Up @@ -244,8 +245,10 @@ class RecordPagePillSheet extends StatelessWidget {
return left <= pillNumberIntoPillSheet &&
pillNumberIntoPillSheet <= right;
}
final passedCount = summarizedPillCountWithPillSheetsToEndIndex(
pillSheets: pillSheetGroup.pillSheets, endIndex: pageIndex);
final passedCount = summarizedPillCountWithPillSheetTypesToEndIndex(
pillSheetTypes:
pillSheetGroup.pillSheets.map((e) => e.pillSheetType).toList(),
endIndex: pageIndex);
final serialiedPillNumber = passedCount + pillNumberIntoPillSheet;

final menstruationRangeList =
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 @@ -227,16 +227,3 @@ int pillSheetPillNumber({
restDurations: pillSheet.restDurations, upperDate: targetDate) +
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;
});
}
17 changes: 11 additions & 6 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 =
summarizedPillCountWithPillSheetsToEndIndex(
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 =
summarizedPillCountWithPillSheetsToEndIndex(
pillSheets: pillSheets, endIndex: activedPillSheet.groupIndex);
summarizedPillCountWithPillSheetTypesToEndIndex(
pillSheetTypes: pillSheets.map((e) => e.pillSheetType).toList(),
endIndex: activedPillSheet.groupIndex);

var sequentialLastTakenPillNumber =
passedPillCountForPillSheetTypes + activedPillSheet.lastTakenPillNumber;
Expand All @@ -129,8 +132,10 @@ class PillSheetGroup with _$PillSheetGroup {
}

int get estimatedEndPillNumber {
var estimatedEndPillNumber = summarizedPillCountWithPillSheetsToEndIndex(
pillSheets: pillSheets, endIndex: pillSheets.length);
var estimatedEndPillNumber =
summarizedPillCountWithPillSheetTypesToEndIndex(
pillSheetTypes: pillSheets.map((e) => e.pillSheetType).toList(),
endIndex: pillSheets.length);

final displayNumberSetting = this.displayNumberSetting;
if (displayNumberSetting != null) {
Expand Down