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

RestDuration can begin special date #479

Merged
merged 20 commits into from
Feb 1, 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
8 changes: 4 additions & 4 deletions lib/domain/modal/release_note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ReleaseNote extends StatelessWidget {
child: Container(
padding: EdgeInsets.only(top: 40, left: 40, right: 40),
child: Text(
"服用済みのピルを未服用状態に戻せるように",
"今日以外の日から休薬を開始できるように",
style: FontType.subTitle.merge(TextColorStyle.black),
textAlign: TextAlign.center,
),
Expand All @@ -57,7 +57,7 @@ class ReleaseNote extends StatelessWidget {
children: [
Text(
'''
服用済みのピルマークをタップすることで未服用にできます。間違って服用済みにしてしまった時に便利です
休薬を開始したい日まで未服用にする事で休薬できます。服用済みのピルマークをタップすることで未服用にできます
''',
style: FontType.assisting.merge(TextColorStyle.main),
),
Expand Down Expand Up @@ -85,7 +85,7 @@ class ReleaseNote extends StatelessWidget {
}

showReleaseNotePreDialog(BuildContext context) async {
final key = ReleaseNoteKey.version3_7_0;
final key = ReleaseNoteKey.version3_8_0;
final storage = await SharedPreferences.getInstance();
if (storage.getBool(key) ?? false) {
return;
Expand All @@ -103,7 +103,7 @@ openReleaseNote() async {
final ChromeSafariBrowser browser = new ChromeSafariBrowser();
await browser.open(
url: Uri.parse(
"https://pilll.wraptas.site/b24b2277dca2464899d575b6c2e70932"),
"https://pilll.wraptas.site/fcc86789fece40e39c0c03f58e58d883"),
options: ChromeSafariBrowserClassOptions(
android:
AndroidChromeCustomTabsOptions(addDefaultShareMenuItem: false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ import 'package:flutter_svg/svg.dart';
import 'package:pilll/components/atoms/buttons.dart';
import 'package:pilll/components/atoms/font.dart';
import 'package:pilll/components/atoms/text_color.dart';
import 'package:pilll/entity/pill_sheet.dart';
import 'package:pilll/entity/pill_sheet_group.dart';
import 'package:pilll/entity/setting.dart';
import 'package:pilll/util/formatter/date_time_formatter.dart';

class RecordPageRestDurationDialog extends StatelessWidget {
final RecordPageRestDurationDialogTitle title;
final VoidCallback onDone;

const RecordPageRestDurationDialog({
Key? key,
required this.title,
required this.onDone,
}) : super(key: key);

Expand All @@ -22,14 +28,35 @@ class RecordPageRestDurationDialog extends StatelessWidget {
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text("今日から休薬しますか?",
style: FontType.subTitle.merge(TextColorStyle.main)),
title,
SizedBox(height: 24),
Text("休薬するとピル番号は進みません",
style: FontType.assisting.merge(TextColorStyle.main)),
SizedBox(height: 24),
SvgPicture.asset("images/explain_rest_duration.svg"),
SizedBox(height: 24),
Text(
"※休薬開始日を変えたい場合",
style: TextStyle(
color: TextColor.main,
fontSize: 14,
fontFamily: FontFamily.japanese,
fontWeight: FontWeight.w700,
),
textAlign: TextAlign.left,
),
SizedBox(height: 8),
Text(
"希望日まで未服用にする必要があります。服用済みのピルマークをタップすることで未服用にできます",
style: TextStyle(
color: TextColor.main,
fontFamily: FontFamily.japanese,
fontSize: 14,
fontWeight: FontWeight.w400,
),
textAlign: TextAlign.left,
),
SizedBox(height: 24),
],
),
actions: <Widget>[
Expand All @@ -50,11 +77,59 @@ class RecordPageRestDurationDialog extends StatelessWidget {
}
}

showRecordPageRestDurationDialog(BuildContext context, VoidCallback onDone) {
showRecordPageRestDurationDialog(
BuildContext context, {
required PillSheetAppearanceMode appearanceMode,
required PillSheet activedPillSheet,
required PillSheetGroup pillSheetGroup,
required VoidCallback onDone,
}) {
showDialog(
context: context,
builder: (context) => RecordPageRestDurationDialog(
title: RecordPageRestDurationDialogTitle(
appearanceMode: appearanceMode,
activedPillSheet: activedPillSheet,
pillSheetGroup: pillSheetGroup),
onDone: onDone,
),
);
}

class RecordPageRestDurationDialogTitle extends StatelessWidget {
final PillSheetAppearanceMode appearanceMode;
final PillSheet activedPillSheet;
final PillSheetGroup pillSheetGroup;

const RecordPageRestDurationDialogTitle({
Key? key,
required this.appearanceMode,
required this.activedPillSheet,
required this.pillSheetGroup,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return Text("$_numberから休薬しますか?",
style: TextStyle(
color: TextColor.main,
fontSize: 16,
fontWeight: FontWeight.w600,
fontFamily: FontFamily.japanese,
));
}

String get _number {
switch (appearanceMode) {
case PillSheetAppearanceMode.number:
return "${activedPillSheet.lastTakenPillNumber + 1}番";
case PillSheetAppearanceMode.date:
final date = activedPillSheet
.displayPillTakeDate(activedPillSheet.lastTakenPillNumber + 1);
final dateString = DateTimeFormatter.monthAndDay(date);
return "$dateString";
case PillSheetAppearanceMode.sequential:
return "${pillSheetGroup.sequentialLastTakenPillNumber + 1}日目";
}
}
}
Original file line number Diff line number Diff line change
@@ -1,48 +1,51 @@
import 'package:flutter/material.dart';
import 'package:flutter_app_badger/flutter_app_badger.dart';
import 'package:pilll/analytics.dart';
import 'package:pilll/components/atoms/buttons.dart';
import 'package:pilll/domain/record/components/pill_sheet/components/record_page_rest_duration_dialog.dart';
import 'package:pilll/domain/record/components/supports/components/rest_duration/invalid_already_taken_pill_dialog.dart';
import 'package:pilll/domain/record/components/supports/components/rest_duration/invalid_insufficient_rest_duration_dialog.dart';
import 'package:pilll/domain/record/record_page_store.dart';
import 'package:pilll/entity/pill_sheet.dart';
import 'package:pilll/entity/pill_sheet_group.dart';
import 'package:pilll/entity/setting.dart';

class ManualRestDurationButton extends StatelessWidget {
const ManualRestDurationButton({
class BeginManualRestDurationButton extends StatelessWidget {
final PillSheetAppearanceMode appearanceMode;
final PillSheet activedPillSheet;
final PillSheetGroup pillSheetGroup;
final RecordPageStore store;

const BeginManualRestDurationButton({
Key? key,
required this.restDuration,
required this.appearanceMode,
required this.activedPillSheet,
required this.store,
required this.pillSheetGroup,
required this.store,
}) : super(key: key);

final RestDuration? restDuration;
final PillSheet activedPillSheet;
final RecordPageStore store;
final PillSheetGroup pillSheetGroup;

@override
Widget build(BuildContext context) {
final restDuration = this.restDuration;

return SizedBox(
width: 80,
child: SmallAppOutlinedButton(
text: restDuration == null ? "休薬する" : "休薬終了",
text: "休薬する",
onPressed: () async {
analytics.logEvent(
name: "manual_rest_duration_pressed",
parameters: {"is_begin": restDuration == null});
if (restDuration == null) {
if (activedPillSheet.todayPillIsAlreadyTaken) {
showInvalidAlreadyTakenPillDialog(context);
} else if (activedPillSheet.todayPillNumber - 1 >
activedPillSheet.lastTakenPillNumber) {
showInvalidInsufficientRestDurationDialog(context);
} else {
showRecordPageRestDurationDialog(context, () async {
name: "begin_manual_rest_duration_pressed",
parameters: {"pill_sheet_id": activedPillSheet.id});

if (activedPillSheet.todayPillIsAlreadyTaken) {
showInvalidAlreadyTakenPillDialog(context);
} else {
showRecordPageRestDurationDialog(
context,
appearanceMode: appearanceMode,
pillSheetGroup: pillSheetGroup,
activedPillSheet: activedPillSheet,
onDone: () async {
analytics.logEvent(name: "done_rest_duration");
FlutterAppBadger.removeBadge();

Navigator.of(context).pop();
await store.beginResting(
pillSheetGroup: pillSheetGroup,
Expand All @@ -56,21 +59,7 @@ class ManualRestDurationButton extends StatelessWidget {
content: Text("休薬期間が始まりました"),
),
);
});
}
} else {
await store.endResting(
pillSheetGroup: pillSheetGroup,
activedPillSheet: activedPillSheet,
restDuration: restDuration,
);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: Duration(
seconds: 2,
),
content: Text("休薬期間が終了しました"),
),
},
);
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import 'package:flutter/material.dart';
import 'package:pilll/analytics.dart';
import 'package:pilll/components/atoms/buttons.dart';
import 'package:pilll/domain/record/record_page_store.dart';
import 'package:pilll/entity/pill_sheet.dart';
import 'package:pilll/entity/pill_sheet_group.dart';

class EndManualRestDurationButton extends StatelessWidget {
final RestDuration restDuration;
final PillSheet activedPillSheet;
final PillSheetGroup pillSheetGroup;
final RecordPageStore store;

const EndManualRestDurationButton({
Key? key,
required this.restDuration,
required this.activedPillSheet,
required this.pillSheetGroup,
required this.store,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return SizedBox(
width: 80,
child: SmallAppOutlinedButton(
text: "休薬終了",
onPressed: () async {
analytics.logEvent(
name: "end_manual_rest_duration_pressed",
);

await store.endResting(
pillSheetGroup: pillSheetGroup,
activedPillSheet: activedPillSheet,
restDuration: restDuration,
);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: Duration(
seconds: 2,
),
content: Text("休薬期間が終了しました"),
),
);
},
),
);
}
}

This file was deleted.

Loading