Skip to content

Commit

Permalink
Merge pull request #392 from bannzai/imp/view/rest_duration
Browse files Browse the repository at this point in the history
  • Loading branch information
bannzai authored Oct 30, 2021
2 parents 261dcec + da9dbf1 commit d665e94
Show file tree
Hide file tree
Showing 51 changed files with 2,789 additions and 340 deletions.
61 changes: 61 additions & 0 deletions images/explain_rest_duration.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions lib/components/atoms/buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,26 @@ class InconspicuousButton extends StatelessWidget {

class PrimaryOutlinedButton extends StatelessWidget {
final String text;
final double fontSize;
final VoidCallback? onPressed;

const PrimaryOutlinedButton({
Key? key,
required this.onPressed,
required this.fontSize,
required this.text,
}) : super(key: key);

Widget build(BuildContext context) {
return OutlinedButton(
child: Container(
width: 204,
padding: EdgeInsets.only(top: 12, bottom: 12),
child: Center(
child: Text(
text,
style: TextStyle(
color: TextColor.main,
fontSize: 16,
fontSize: fontSize,
fontFamily: FontFamily.japanese,
fontWeight: FontWeight.w700,
),
Expand Down
2 changes: 1 addition & 1 deletion lib/components/atoms/color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PilllColors {
static final Color saturday = HexColor.fromHex("7FB9E1");
static final Color weekday = HexColor.fromHex("7E7E7E");
static final Color enable = HexColor.fromHex('E56A45');
static final Color disable = HexColor.fromHex("F2F2F2");
static final Color disable = HexColor.fromHex("EAEAEA");
static final Color divider = HexColor.fromHex("9DAFBD");

static final Color bottomBar = HexColor.fromHex("FAFAFA");
Expand Down
2 changes: 1 addition & 1 deletion lib/components/atoms/text_color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TextColor {
static final Color white = Colors.white;
static final Color darkGray = HexColor.fromHex("000000").withAlpha(153);
static final Color gray = HexColor.fromHex("7E7E7E");
static final Color lightGray = HexColor.fromHex("CDCFD1");
static final Color lightGray = HexColor.fromHex("B1B1B1");
static final Color lightGray2 = HexColor.fromHex("666666");
static final Color noshime = HexColor.fromHex("3D4662");
static final Color primary = PilllColors.primary;
Expand Down
12 changes: 9 additions & 3 deletions lib/components/organisms/calendar/utility.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@ List<DateRange> scheduledOrInTheMiddleMenstruationDateRanges(
}
assert(maxPageCount > 0);

final totalPillCount = pillSheetGroup.pillSheets
.map((e) => e.pillSheetType.totalCount)
.reduce((value, element) => value + element);
final List<DateRange> dateRanges = [];
// 大体の数を計算
for (int i = 0; i < maxPageCount; i++) {
final offset = pillSheetGroup.totalPillCountIntoGroup * i;
final offset = totalPillCount * i;
for (int pageIndex = 0;
pageIndex < pillSheetGroup.pillSheets.length;
pageIndex++) {
final pillSheet = pillSheetGroup.pillSheets[pageIndex];
final pillSheetTypes =
pillSheetGroup.pillSheets.map((e) => e.pillSheetType).toList();
final passedCount = passedTotalCount(
final passedCount = summarizedPillSheetTypeTotalCountToPageIndex(
pillSheetTypes: pillSheetTypes, pageIndex: pageIndex);
final serializedTotalPillNumber =
passedCount + pillSheet.typeInfo.totalCount;
Expand Down Expand Up @@ -91,11 +94,14 @@ List<DateRange> nextPillSheetDateRanges(
assert(maxPageCount > 0);

// 大体の数を計算
final totalPillCount = pillSheetGroup.pillSheets
.map((e) => e.pillSheetType.totalCount)
.reduce((value, element) => value + element);
final count = max(maxPageCount, pillSheetGroup.pillSheets.length) /
pillSheetGroup.pillSheets.length;
return List.generate(count.toInt(), (groupPageIndex) {
return pillSheetGroup.pillSheets.map((pillSheet) {
final offset = groupPageIndex * pillSheetGroup.totalPillCountIntoGroup;
final offset = groupPageIndex * totalPillCount;
final begin = pillSheet.estimatedLastTakenDate.add(Duration(days: 1));
final end = begin.add(Duration(days: Weekday.values.length - 1));
return DateRange(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extension WeeklyCalendarStateCompoutedProperties on WeeklyCalendarState {
int offsetForStartPositionAtLine(DateTime begin) {
return isNecessaryLineBreak(begin)
? 0
: begin.date().difference(dateRange.begin.date()).inDays;
: daysBetween(dateRange.begin.date(), begin.date());
}

DateTime buildDate(Weekday weekday) {
Expand Down
49 changes: 14 additions & 35 deletions lib/components/page/discard_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,59 +1,41 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:pilll/components/atoms/buttons.dart';
import 'package:pilll/components/atoms/font.dart';
import 'package:pilll/components/atoms/text_color.dart';

class DiscardDialog extends StatelessWidget {
final String title;
final Widget message;
final String doneButtonText;
final Function() done;
final Function()? cancel;
final List<Widget> actions;

const DiscardDialog({
Key? key,
required this.title,
required this.message,
required this.doneButtonText,
required this.done,
this.cancel,
required this.actions,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final cancel = this.cancel;
return AlertDialog(
title: SvgPicture.asset("images/alert_24.svg", width: 24, height: 24),
content: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
if (title.isNotEmpty) ...[
Text(title, style: FontType.subTitle.merge(TextColorStyle.main)),
Text(
title,
style: FontType.subTitle.merge(TextColorStyle.main),
textAlign: TextAlign.center,
),
SizedBox(
height: 15,
),
],
message,
],
),
actions: <Widget>[
SecondaryButton(
text: "キャンセル",
onPressed: cancel != null
? () => cancel()
: () {
Navigator.of(context).pop();
},
),
SecondaryButton(
text: doneButtonText,
onPressed: () {
done();
Navigator.of(context).pop();
},
),
],
actions: actions,
);
}
}
Expand All @@ -62,18 +44,15 @@ showDiscardDialog(
BuildContext context, {
required String title,
required String message,
required VoidCallback done,
required String doneText,
VoidCallback? cancel,
required List<Widget> actions,
}) {
showDialog(
context: context,
builder: (context) => DiscardDialog(
title: title,
message:
Text(message, style: FontType.assisting.merge(TextColorStyle.main)),
doneButtonText: doneText,
done: done,
cancel: cancel),
title: title,
message:
Text(message, style: FontType.assisting.merge(TextColorStyle.main)),
actions: actions,
),
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import 'package:flutter/material.dart';
import 'package:pilll/components/atoms/font.dart';
import 'package:pilll/components/atoms/text_color.dart';
import 'package:pilll/domain/calendar/components/pill_sheet_modified_history/components/pill_sheet_modified_history_date_component.dart';
import 'package:pilll/entity/pill_sheet_modified_history_value.dart';

class PillSheetModifiedHistoryBeganRestDuration extends StatelessWidget {
final DateTime estimatedEventCausingDate;
final BeganRestDurationValue? value;

const PillSheetModifiedHistoryBeganRestDuration({
Key? key,
required this.value,
required this.estimatedEventCausingDate,
}) : super(key: key);

@override
Widget build(BuildContext context) {
final value = this.value;
if (value == null) {
return Container();
}
return Container(
child: Padding(
padding: const EdgeInsets.only(top: 4, bottom: 4),
child: Row(
children: [
PillSheetModifiedHistoryDate(
estimatedEventCausingDate: estimatedEventCausingDate,
effectivePillNumber:
PillSheetModifiedHistoryDateEffectivePillNumber.hyphen()),
Spacer(),
Container(
width: PillSheetModifiedHistoryTakenActionLayoutWidths.trailing,
child: Row(
children: [
Container(
child: Text(
"休薬開始",
style: TextStyle(
color: TextColor.main,
fontSize: 12,
fontFamily: FontFamily.japanese,
fontWeight: FontWeight.w400,
),
textAlign: TextAlign.start,
),
),
Spacer(),
],
),
),
],
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import 'package:flutter/material.dart';
import 'package:pilll/components/atoms/font.dart';
import 'package:pilll/components/atoms/text_color.dart';
import 'package:pilll/domain/calendar/components/pill_sheet_modified_history/components/pill_sheet_modified_history_date_component.dart';
import 'package:pilll/entity/pill_sheet_modified_history_value.dart';

class PillSheetModifiedHistoryEndedRestDuration extends StatelessWidget {
final DateTime estimatedEventCausingDate;
final EndedRestDurationValue? value;

const PillSheetModifiedHistoryEndedRestDuration({
Key? key,
required this.estimatedEventCausingDate,
required this.value,
}) : super(key: key);

@override
Widget build(BuildContext context) {
final value = this.value;
if (value == null) {
return Container();
}
return Container(
child: Padding(
padding: const EdgeInsets.only(top: 4, bottom: 4),
child: Row(
children: [
PillSheetModifiedHistoryDate(
estimatedEventCausingDate: estimatedEventCausingDate,
effectivePillNumber:
PillSheetModifiedHistoryDateEffectivePillNumber.hyphen()),
Spacer(),
Container(
width: PillSheetModifiedHistoryTakenActionLayoutWidths.trailing,
child: Row(
children: [
Container(
child: Text(
"休薬終了",
style: TextStyle(
color: TextColor.main,
fontSize: 12,
fontFamily: FontFamily.japanese,
fontWeight: FontWeight.w400,
),
textAlign: TextAlign.start,
),
),
Spacer(),
],
),
),
],
),
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,23 @@ class CalendarPillSheetModifiedHistoryCard extends StatelessWidget {
),
),
SizedBox(height: 15),
PrimaryOutlinedButton(
text: "くわしくみる",
onPressed: () {
if (state.trialDeadlineDate == null) {
showPremiumTrialModal(context, () {
showPremiumTrialCompleteModalPreDialog(
SizedBox(
width: 204,
child: PrimaryOutlinedButton(
text: "くわしくみる",
fontSize: 16,
onPressed: () {
if (state.trialDeadlineDate == null) {
showPremiumTrialModal(context, () {
showPremiumTrialCompleteModalPreDialog(
context);
});
} else {
showPremiumIntroductionSheet(
context);
});
} else {
showPremiumIntroductionSheet(context);
}
},
}
},
),
),
],
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:pilll/domain/calendar/components/pill_sheet_modified_history/components/pill_sheet_modified_history_automatically_recorded_last_taken_date_action.dart';
import 'package:pilll/domain/calendar/components/pill_sheet_modified_history/components/pill_sheet_modified_history_began_rest_duration.dart';
import 'package:pilll/domain/calendar/components/pill_sheet_modified_history/components/pill_sheet_modified_history_changed_pill_number_action.dart';
import 'package:pilll/domain/calendar/components/pill_sheet_modified_history/components/pill_sheet_modified_history_created_pill_sheet_action.dart';
import 'package:pilll/domain/calendar/components/pill_sheet_modified_history/components/pill_sheet_modified_history_deleted_pill_sheet_action.dart';
import 'package:pilll/domain/calendar/components/pill_sheet_modified_history/components/pill_sheet_modified_history_ended_rest_duration.dart';
import 'package:pilll/domain/calendar/components/pill_sheet_modified_history/components/pill_sheet_modified_history_ended_pill_sheet_action.dart';
import 'package:pilll/domain/calendar/components/pill_sheet_modified_history/components/pill_sheet_modified_history_monthly_header.dart';
import 'package:pilll/domain/calendar/components/pill_sheet_modified_history/components/pill_sheet_modified_history_revert_taken_pill_action.dart';
Expand Down Expand Up @@ -136,6 +138,18 @@ class CalendarPillSheetModifiedHistoryList extends StatelessWidget {
return PillSheetModifiedHistoryEndedPillSheetAction(
value: history.value.endedPillSheet,
);
case PillSheetModifiedActionType.beganRestDuration:
return PillSheetModifiedHistoryBeganRestDuration(
estimatedEventCausingDate:
history.estimatedEventCausingDate,
value: history.value.beganRestDurationValue,
);
case PillSheetModifiedActionType.endedRestDuration:
return PillSheetModifiedHistoryEndedRestDuration(
estimatedEventCausingDate:
history.estimatedEventCausingDate,
value: history.value.endedRestDurationValue,
);
}
};

Expand Down
4 changes: 2 additions & 2 deletions lib/domain/calendar/date_range.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ class DateRange {
final DateTime _end;
DateTime get begin => _begin.date();
DateTime get end => _end.date();
int get days => end.difference(begin).inDays;
int get days => daysBetween(begin, end);

DateRange(this._begin, this._end);

static bool isSameDay(DateTime a, DateTime b) =>
a.year == b.year && a.month == b.month && a.day == b.day;
bool inRange(DateTime date) =>
date.isAfter(begin) && date.isBefore(end) ||
(date.isAfter(begin) && date.isBefore(end)) ||
DateRange.isSameDay(date, begin) ||
DateRange.isSameDay(date, end);
DateRange union(DateRange range) {
Expand Down
Loading

0 comments on commit d665e94

Please sign in to comment.