From 542dc7f1633a729e04d0e138aaca8988f2123d9d Mon Sep 17 00:00:00 2001 From: bannzai Date: Fri, 17 Sep 2021 07:33:34 +0900 Subject: [PATCH 01/11] :memo: fix wording --- lib/domain/settings/components/rows/pill_sheet_remove.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/domain/settings/components/rows/pill_sheet_remove.dart b/lib/domain/settings/components/rows/pill_sheet_remove.dart index 631cd88330..e9f17a7e71 100644 --- a/lib/domain/settings/components/rows/pill_sheet_remove.dart +++ b/lib/domain/settings/components/rows/pill_sheet_remove.dart @@ -22,8 +22,8 @@ class PillSheetRemoveRow extends HookWidget { context: context, builder: (_) { return DiscardDialog( - title: "ピルシートを破棄しますか?", - message: "現在、服用記録をしているピルシートを削除します。", + title: "${store.pillSheetWord}を破棄しますか?", + message: "現在、服用記録をしている${store.pillSheetWord}を削除します。", doneButtonText: "破棄する", done: () { store.deletePillSheet().catchError((error) { From d077c042591133a2110f02e1721067fe931a3654 Mon Sep 17 00:00:00 2001 From: bannzai Date: Fri, 17 Sep 2021 08:15:22 +0900 Subject: [PATCH 02/11] :recycle: Remove unnecessary callbacks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # # ==== Emojis ==== # 🐛 :bug: バグ修正 # 🤘 :metal: 機能改善 # 🐚 :shell: コマンドを実行した結果とか # ✨ :sparkles: 部分的な機能追加 # 🎉 :tada: 盛大に祝うべき大きな機能追加 # 💉 :syringe: libraryの追加 # 📝 :memo: ドキュメント・READMEの整備 # ♻️ :recycle: リファクタリング # 🚿 :shower: 不要な機能・使われなくなった機能の削除 # 💚 :green_heart: テストやCIの修正・改善 # 👕 :shirt: Lintエラーの修正やコードスタイルの修正 # 🚀 :rocket: パフォーマンス改善 # 🆙 :up: 依存パッケージなどのアップデート # 🔒 :lock: 新機能の公開範囲の制限 # 👮 :cop: セキュリティ関連の改善 # 🎨 :art: デザイン修正 # 🚧 :construction: WIP 一時的なコミット # ==== Format ==== # :emoji: Subject # # Commit body... # ==== The Seven Rules ==== # 1. Separate subject from body with a blank line # 2. Limit the subject line to 50 characters # 3. Capitalize the subject line # 4. Do not end the subject line with a period # 5. Use the imperative mood in the subject line # 6. Wrap the body at 72 characters # 7. Use the body to explain what and why vs. how # # How to Write a Git Commit Message http://chris.beams.io/posts/git-commit/ # reference from http://memo.goodpatch.co/2016/07/beautiful-commits-with-emojis/ # for https://github.com/bannzai/commit_template --- .../organisms/pill_sheet/setting_pill_sheet_view.dart | 8 ++------ .../setting_menstruation_pill_sheet_list.dart | 11 ----------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/lib/components/organisms/pill_sheet/setting_pill_sheet_view.dart b/lib/components/organisms/pill_sheet/setting_pill_sheet_view.dart index d7aa190145..18961fcacb 100644 --- a/lib/components/organisms/pill_sheet/setting_pill_sheet_view.dart +++ b/lib/components/organisms/pill_sheet/setting_pill_sheet_view.dart @@ -12,7 +12,6 @@ import 'package:pilll/entity/weekday.dart'; class SettingPillSheetView extends StatelessWidget { final int pageIndex; final List pillSheetTypes; - final int selectedPillNumberPageIndex; final int? selectedPillNumberIntoPillSheet; final Function(int pageIndex, int pillNumberIntoPillSheet) markSelected; @@ -22,7 +21,6 @@ class SettingPillSheetView extends StatelessWidget { Key? key, required this.pageIndex, required this.pillSheetTypes, - required this.selectedPillNumberPageIndex, required this.selectedPillNumberIntoPillSheet, required this.markSelected, }) : super(key: key); @@ -87,10 +85,8 @@ class SettingPillSheetView extends StatelessWidget { PillMarkType _pillMarkTypeFor({ required int pillNumberIntoPillSheet, }) { - if (selectedPillNumberPageIndex == pageIndex) { - if (selectedPillNumberIntoPillSheet == pillNumberIntoPillSheet) { - return PillMarkType.selected; - } + if (selectedPillNumberIntoPillSheet == pillNumberIntoPillSheet) { + return PillMarkType.selected; } if (pillSheetType.dosingPeriod < pillNumberIntoPillSheet) { diff --git a/lib/components/template/setting_menstruation/setting_menstruation_pill_sheet_list.dart b/lib/components/template/setting_menstruation/setting_menstruation_pill_sheet_list.dart index 6d42311029..c540276ca7 100644 --- a/lib/components/template/setting_menstruation/setting_menstruation_pill_sheet_list.dart +++ b/lib/components/template/setting_menstruation/setting_menstruation_pill_sheet_list.dart @@ -7,16 +7,12 @@ import 'package:pilll/entity/pill_sheet_type.dart'; class SettingMenstruationPillSheetList extends HookWidget { final List pillSheetTypes; - final int selectedPillSheetPageIndex; final int? Function(int pageIndex) selectedPillNumber; - final Function(int) onPageChanged; final Function(int pageIndex, int pillNumber) markSelected; SettingMenstruationPillSheetList({ required this.pillSheetTypes, - required this.selectedPillSheetPageIndex, required this.selectedPillNumber, - required this.onPageChanged, required this.markSelected, }); @@ -25,12 +21,6 @@ class SettingMenstruationPillSheetList extends HookWidget { final pageController = usePageController( viewportFraction: (PillSheetViewLayout.width + 20) / MediaQuery.of(context).size.width); - pageController.addListener(() { - final page = pageController.page; - if (page != null) { - onPageChanged(page.toInt()); - } - }); return Column( children: [ Container( @@ -54,7 +44,6 @@ class SettingMenstruationPillSheetList extends HookWidget { child: SettingPillSheetView( pageIndex: pageIndex, pillSheetTypes: pillSheetTypes, - selectedPillNumberPageIndex: selectedPillSheetPageIndex, selectedPillNumberIntoPillSheet: selectedPillNumber(pageIndex), markSelected: (pageIndex, number) => From 8ccc0b8e9b3a289474e5b771f587b81e9bf24fc4 Mon Sep 17 00:00:00 2001 From: bannzai Date: Fri, 17 Sep 2021 08:15:50 +0900 Subject: [PATCH 03/11] :recycle: Remove unnecessary page management properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # # ==== Emojis ==== # 🐛 :bug: バグ修正 # 🤘 :metal: 機能改善 # 🐚 :shell: コマンドを実行した結果とか # ✨ :sparkles: 部分的な機能追加 # 🎉 :tada: 盛大に祝うべき大きな機能追加 # 💉 :syringe: libraryの追加 # 📝 :memo: ドキュメント・READMEの整備 # ♻️ :recycle: リファクタリング # 🚿 :shower: 不要な機能・使われなくなった機能の削除 # 💚 :green_heart: テストやCIの修正・改善 # 👕 :shirt: Lintエラーの修正やコードスタイルの修正 # 🚀 :rocket: パフォーマンス改善 # 🆙 :up: 依存パッケージなどのアップデート # 🔒 :lock: 新機能の公開範囲の制限 # 👮 :cop: セキュリティ関連の改善 # 🎨 :art: デザイン修正 # 🚧 :construction: WIP 一時的なコミット # ==== Format ==== # :emoji: Subject # # Commit body... # ==== The Seven Rules ==== # 1. Separate subject from body with a blank line # 2. Limit the subject line to 50 characters # 3. Capitalize the subject line # 4. Do not end the subject line with a period # 5. Use the imperative mood in the subject line # 6. Wrap the body at 72 characters # 7. Use the body to explain what and why vs. how # # How to Write a Git Commit Message http://chris.beams.io/posts/git-commit/ # reference from http://memo.goodpatch.co/2016/07/beautiful-commits-with-emojis/ # for https://github.com/bannzai/commit_template --- .../initial_setting_state.dart | 2 - .../initial_setting_state.freezed.dart | 57 +++++-------------- .../setting_menstruation_state.dart | 4 +- 3 files changed, 15 insertions(+), 48 deletions(-) diff --git a/lib/domain/initial_setting/initial_setting_state.dart b/lib/domain/initial_setting/initial_setting_state.dart index 91192d7d3a..f95a0ca0b6 100644 --- a/lib/domain/initial_setting/initial_setting_state.dart +++ b/lib/domain/initial_setting/initial_setting_state.dart @@ -37,8 +37,6 @@ abstract class InitialSettingState implements _$InitialSettingState { bool isLoading, @Default(false) bool isAccountCooperationDidEnd, - @Default(0) - currentMenstruationPageIndex, }) = _InitialSettingState; DateTime? reminderTimeOrDefault(int index) { diff --git a/lib/domain/initial_setting/initial_setting_state.freezed.dart b/lib/domain/initial_setting/initial_setting_state.freezed.dart index 13a1aa9c60..aacd6a532d 100644 --- a/lib/domain/initial_setting/initial_setting_state.freezed.dart +++ b/lib/domain/initial_setting/initial_setting_state.freezed.dart @@ -183,13 +183,12 @@ class _$InitialSettingStateTearOff { int fromMenstruation = 23, int durationMenstruation = 4, List reminderTimes = const [ - ReminderTime(hour: 21, minute: 0), - ReminderTime(hour: 22, minute: 0) + const ReminderTime(hour: 21, minute: 0), + const ReminderTime(hour: 22, minute: 0) ], bool isOnReminder = true, bool isLoading = false, - bool isAccountCooperationDidEnd = false, - dynamic currentMenstruationPageIndex = 0}) { + bool isAccountCooperationDidEnd = false}) { return _InitialSettingState( pillSheetTypes: pillSheetTypes, todayPillNumber: todayPillNumber, @@ -199,7 +198,6 @@ class _$InitialSettingStateTearOff { isOnReminder: isOnReminder, isLoading: isLoading, isAccountCooperationDidEnd: isAccountCooperationDidEnd, - currentMenstruationPageIndex: currentMenstruationPageIndex, ); } } @@ -218,8 +216,6 @@ mixin _$InitialSettingState { bool get isOnReminder => throw _privateConstructorUsedError; bool get isLoading => throw _privateConstructorUsedError; bool get isAccountCooperationDidEnd => throw _privateConstructorUsedError; - dynamic get currentMenstruationPageIndex => - throw _privateConstructorUsedError; @JsonKey(ignore: true) $InitialSettingStateCopyWith get copyWith => @@ -239,8 +235,7 @@ abstract class $InitialSettingStateCopyWith<$Res> { List reminderTimes, bool isOnReminder, bool isLoading, - bool isAccountCooperationDidEnd, - dynamic currentMenstruationPageIndex}); + bool isAccountCooperationDidEnd}); $InitialSettingTodayPillNumberCopyWith<$Res>? get todayPillNumber; } @@ -264,7 +259,6 @@ class _$InitialSettingStateCopyWithImpl<$Res> Object? isOnReminder = freezed, Object? isLoading = freezed, Object? isAccountCooperationDidEnd = freezed, - Object? currentMenstruationPageIndex = freezed, }) { return _then(_value.copyWith( pillSheetTypes: pillSheetTypes == freezed @@ -299,10 +293,6 @@ class _$InitialSettingStateCopyWithImpl<$Res> ? _value.isAccountCooperationDidEnd : isAccountCooperationDidEnd // ignore: cast_nullable_to_non_nullable as bool, - currentMenstruationPageIndex: currentMenstruationPageIndex == freezed - ? _value.currentMenstruationPageIndex - : currentMenstruationPageIndex // ignore: cast_nullable_to_non_nullable - as dynamic, )); } @@ -334,8 +324,7 @@ abstract class _$InitialSettingStateCopyWith<$Res> List reminderTimes, bool isOnReminder, bool isLoading, - bool isAccountCooperationDidEnd, - dynamic currentMenstruationPageIndex}); + bool isAccountCooperationDidEnd}); @override $InitialSettingTodayPillNumberCopyWith<$Res>? get todayPillNumber; @@ -362,7 +351,6 @@ class __$InitialSettingStateCopyWithImpl<$Res> Object? isOnReminder = freezed, Object? isLoading = freezed, Object? isAccountCooperationDidEnd = freezed, - Object? currentMenstruationPageIndex = freezed, }) { return _then(_InitialSettingState( pillSheetTypes: pillSheetTypes == freezed @@ -397,9 +385,6 @@ class __$InitialSettingStateCopyWithImpl<$Res> ? _value.isAccountCooperationDidEnd : isAccountCooperationDidEnd // ignore: cast_nullable_to_non_nullable as bool, - currentMenstruationPageIndex: currentMenstruationPageIndex == freezed - ? _value.currentMenstruationPageIndex - : currentMenstruationPageIndex, )); } } @@ -413,13 +398,12 @@ class _$_InitialSettingState extends _InitialSettingState { this.fromMenstruation = 23, this.durationMenstruation = 4, this.reminderTimes = const [ - ReminderTime(hour: 21, minute: 0), - ReminderTime(hour: 22, minute: 0) + const ReminderTime(hour: 21, minute: 0), + const ReminderTime(hour: 22, minute: 0) ], this.isOnReminder = true, this.isLoading = false, - this.isAccountCooperationDidEnd = false, - this.currentMenstruationPageIndex = 0}) + this.isAccountCooperationDidEnd = false}) : super._(); @JsonKey(defaultValue: const []) @@ -434,8 +418,8 @@ class _$_InitialSettingState extends _InitialSettingState { @override final int durationMenstruation; @JsonKey(defaultValue: const [ - ReminderTime(hour: 21, minute: 0), - ReminderTime(hour: 22, minute: 0) + const ReminderTime(hour: 21, minute: 0), + const ReminderTime(hour: 22, minute: 0) ]) @override final List reminderTimes; @@ -448,13 +432,10 @@ class _$_InitialSettingState extends _InitialSettingState { @JsonKey(defaultValue: false) @override final bool isAccountCooperationDidEnd; - @JsonKey(defaultValue: 0) - @override - final dynamic currentMenstruationPageIndex; @override String toString() { - return 'InitialSettingState(pillSheetTypes: $pillSheetTypes, todayPillNumber: $todayPillNumber, fromMenstruation: $fromMenstruation, durationMenstruation: $durationMenstruation, reminderTimes: $reminderTimes, isOnReminder: $isOnReminder, isLoading: $isLoading, isAccountCooperationDidEnd: $isAccountCooperationDidEnd, currentMenstruationPageIndex: $currentMenstruationPageIndex)'; + return 'InitialSettingState(pillSheetTypes: $pillSheetTypes, todayPillNumber: $todayPillNumber, fromMenstruation: $fromMenstruation, durationMenstruation: $durationMenstruation, reminderTimes: $reminderTimes, isOnReminder: $isOnReminder, isLoading: $isLoading, isAccountCooperationDidEnd: $isAccountCooperationDidEnd)'; } @override @@ -486,12 +467,7 @@ class _$_InitialSettingState extends _InitialSettingState { isAccountCooperationDidEnd) || const DeepCollectionEquality().equals( other.isAccountCooperationDidEnd, - isAccountCooperationDidEnd)) && - (identical(other.currentMenstruationPageIndex, - currentMenstruationPageIndex) || - const DeepCollectionEquality().equals( - other.currentMenstruationPageIndex, - currentMenstruationPageIndex))); + isAccountCooperationDidEnd))); } @override @@ -504,8 +480,7 @@ class _$_InitialSettingState extends _InitialSettingState { const DeepCollectionEquality().hash(reminderTimes) ^ const DeepCollectionEquality().hash(isOnReminder) ^ const DeepCollectionEquality().hash(isLoading) ^ - const DeepCollectionEquality().hash(isAccountCooperationDidEnd) ^ - const DeepCollectionEquality().hash(currentMenstruationPageIndex); + const DeepCollectionEquality().hash(isAccountCooperationDidEnd); @JsonKey(ignore: true) @override @@ -523,8 +498,7 @@ abstract class _InitialSettingState extends InitialSettingState { List reminderTimes, bool isOnReminder, bool isLoading, - bool isAccountCooperationDidEnd, - dynamic currentMenstruationPageIndex}) = _$_InitialSettingState; + bool isAccountCooperationDidEnd}) = _$_InitialSettingState; _InitialSettingState._() : super._(); @override @@ -545,9 +519,6 @@ abstract class _InitialSettingState extends InitialSettingState { @override bool get isAccountCooperationDidEnd => throw _privateConstructorUsedError; @override - dynamic get currentMenstruationPageIndex => - throw _privateConstructorUsedError; - @override @JsonKey(ignore: true) _$InitialSettingStateCopyWith<_InitialSettingState> get copyWith => throw _privateConstructorUsedError; diff --git a/lib/domain/settings/menstruation/setting_menstruation_state.dart b/lib/domain/settings/menstruation/setting_menstruation_state.dart index bf557be8a6..fdb0fa6138 100644 --- a/lib/domain/settings/menstruation/setting_menstruation_state.dart +++ b/lib/domain/settings/menstruation/setting_menstruation_state.dart @@ -5,7 +5,5 @@ part 'setting_menstruation_state.freezed.dart'; @freezed abstract class SettingMenstruationState implements _$SettingMenstruationState { SettingMenstruationState._(); - factory SettingMenstruationState({ - @Default(0) currentPageIndex, - }) = _SettingMenstruationState; + factory SettingMenstruationState() = _SettingMenstruationState; } From 2e5c55d9fbb64d9e4b59cb7d088d86d7f68ab512 Mon Sep 17 00:00:00 2001 From: bannzai Date: Fri, 17 Sep 2021 08:16:27 +0900 Subject: [PATCH 04/11] :sparkels: calculated maximum pill number on component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # # ==== Emojis ==== # 🐛 :bug: バグ修正 # 🤘 :metal: 機能改善 # 🐚 :shell: コマンドを実行した結果とか # ✨ :sparkles: 部分的な機能追加 # 🎉 :tada: 盛大に祝うべき大きな機能追加 # 💉 :syringe: libraryの追加 # 📝 :memo: ドキュメント・READMEの整備 # ♻️ :recycle: リファクタリング # 🚿 :shower: 不要な機能・使われなくなった機能の削除 # 💚 :green_heart: テストやCIの修正・改善 # 👕 :shirt: Lintエラーの修正やコードスタイルの修正 # 🚀 :rocket: パフォーマンス改善 # 🆙 :up: 依存パッケージなどのアップデート # 🔒 :lock: 新機能の公開範囲の制限 # 👮 :cop: セキュリティ関連の改善 # 🎨 :art: デザイン修正 # 🚧 :construction: WIP 一時的なコミット # ==== Format ==== # :emoji: Subject # # Commit body... # ==== The Seven Rules ==== # 1. Separate subject from body with a blank line # 2. Limit the subject line to 50 characters # 3. Capitalize the subject line # 4. Do not end the subject line with a period # 5. Use the imperative mood in the subject line # 6. Wrap the body at 72 characters # 7. Use the body to explain what and why vs. how # # How to Write a Git Commit Message http://chris.beams.io/posts/git-commit/ # reference from http://memo.goodpatch.co/2016/07/beautiful-commits-with-emojis/ # for https://github.com/bannzai/commit_template --- .../setting_menstruation_dynamic_description.dart | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/components/template/setting_menstruation/setting_menstruation_dynamic_description.dart b/lib/components/template/setting_menstruation/setting_menstruation_dynamic_description.dart index 8be7beb22e..1b5ab31817 100644 --- a/lib/components/template/setting_menstruation/setting_menstruation_dynamic_description.dart +++ b/lib/components/template/setting_menstruation/setting_menstruation_dynamic_description.dart @@ -17,17 +17,17 @@ abstract class SettingMenstruationDynamicDescriptionConstants { } class SettingMenstruationDynamicDescription extends StatelessWidget { + final List pillSheetTypes; final int fromMenstruation; final int durationMenstruation; - final PillSheetType Function() retrieveFocusedPillSheetType; final void Function(int from) fromMenstructionDidDecide; final void Function(int duration) durationMenstructionDidDecide; const SettingMenstruationDynamicDescription({ Key? key, + required this.pillSheetTypes, required this.fromMenstruation, required this.durationMenstruation, - required this.retrieveFocusedPillSheetType, required this.fromMenstructionDidDecide, required this.durationMenstructionDidDecide, }) : super(key: key); @@ -120,8 +120,10 @@ class SettingMenstruationDynamicDescription extends StatelessWidget { } void _showFromModalSheet(BuildContext context) { - int keepSelectedFromMenstruation = - min(fromMenstruation, retrieveFocusedPillSheetType().totalCount); + final maximumCount = pillSheetTypes + .map((e) => e.totalCount) + .reduce((value, element) => value + element); + int keepSelectedFromMenstruation = min(fromMenstruation, maximumCount); showModalBottomSheet( context: context, builder: (BuildContext context) { @@ -146,8 +148,7 @@ class SettingMenstruationDynamicDescription extends StatelessWidget { }, child: CupertinoPicker( itemExtent: 40, - children: List.generate( - retrieveFocusedPillSheetType().totalCount + 1, (index) { + children: List.generate(maximumCount + 1, (index) { if (index == 0) { return "-"; } From d4ded55a340b4ca0c04620c90c5be1dc742fab21 Mon Sep 17 00:00:00 2001 From: bannzai Date: Fri, 17 Sep 2021 08:17:15 +0900 Subject: [PATCH 05/11] :bug: Enhancement paging flush --- .../initial_setting_store.dart | 10 ++- .../initial_setting_menstruation_page.dart | 14 +--- ...ect_today_pill_number_pill_sheet_list.dart | 2 - .../setting_menstruation_page.dart | 14 +--- .../setting_menstruation_state.freezed.dart | 77 +++---------------- .../setting_menstruation_store.dart | 12 ++- ...ing_today_pill_number_pill_sheet_list.dart | 1 - 7 files changed, 28 insertions(+), 102 deletions(-) diff --git a/lib/domain/initial_setting/initial_setting_store.dart b/lib/domain/initial_setting/initial_setting_store.dart index 952a8958c6..bd75f91a62 100644 --- a/lib/domain/initial_setting/initial_setting_store.dart +++ b/lib/domain/initial_setting/initial_setting_store.dart @@ -136,10 +136,6 @@ class InitialSettingStateStore extends StateNotifier { state = state.copyWith(todayPillNumber: null); } - setCurrentMenstruationPageIndex(int pageIndex) { - state = state.copyWith(currentMenstruationPageIndex: pageIndex); - } - void setFromMenstruation({ required int pageIndex, required int fromMenstruation, @@ -149,6 +145,12 @@ class InitialSettingStateStore extends StateNotifier { state = state.copyWith(fromMenstruation: fromMenstruation + offset); } + void pickFromMenstruation({ + required int serializedPillNumberIntoGroup, + }) { + state = state.copyWith(fromMenstruation: serializedPillNumberIntoGroup); + } + void setDurationMenstruation({ required int durationMenstruation, }) { diff --git a/lib/domain/initial_setting/menstruation/initial_setting_menstruation_page.dart b/lib/domain/initial_setting/menstruation/initial_setting_menstruation_page.dart index ac78b86699..c1639556c0 100644 --- a/lib/domain/initial_setting/menstruation/initial_setting_menstruation_page.dart +++ b/lib/domain/initial_setting/menstruation/initial_setting_menstruation_page.dart @@ -20,12 +20,8 @@ class InitialSettingMenstruationPage extends HookWidget { title: "4/5", pillSheetList: SettingMenstruationPillSheetList( pillSheetTypes: state.pillSheetTypes, - selectedPillSheetPageIndex: state.currentMenstruationPageIndex, selectedPillNumber: (pageIndex) => store.retrieveMenstruationSelectedPillNumber(pageIndex), - onPageChanged: (pageIndex) { - store.setCurrentMenstruationPageIndex(pageIndex); - }, markSelected: (pageIndex, number) { analytics.logEvent( name: "from_menstruation_initial_setting", @@ -43,15 +39,13 @@ class InitialSettingMenstruationPage extends HookWidget { text: "次へ", ), dynamicDescription: SettingMenstruationDynamicDescription( + pillSheetTypes: state.pillSheetTypes, fromMenstruation: state.fromMenstruation, fromMenstructionDidDecide: (number) { analytics.logEvent( name: "from_menstruation_initial_setting", parameters: {"number": number}); - store.setFromMenstruation( - pageIndex: state.currentMenstruationPageIndex, - fromMenstruation: number, - ); + store.pickFromMenstruation(serializedPillNumberIntoGroup: number); }, durationMenstruation: state.durationMenstruation, durationMenstructionDidDecide: (number) { @@ -59,13 +53,9 @@ class InitialSettingMenstruationPage extends HookWidget { name: "duration_menstruation_initial_setting", parameters: { "number": number, - "page": state.currentMenstruationPageIndex }); store.setDurationMenstruation(durationMenstruation: number); }, - retrieveFocusedPillSheetType: () { - return state.pillSheetTypes[state.currentMenstruationPageIndex]; - }, ), ); } diff --git a/lib/domain/initial_setting/today_pill_number/select_today_pill_number_pill_sheet_list.dart b/lib/domain/initial_setting/today_pill_number/select_today_pill_number_pill_sheet_list.dart index b47ea1e9e1..eb4317daae 100644 --- a/lib/domain/initial_setting/today_pill_number/select_today_pill_number_pill_sheet_list.dart +++ b/lib/domain/initial_setting/today_pill_number/select_today_pill_number_pill_sheet_list.dart @@ -43,8 +43,6 @@ class SelectTodayPillNumberPillSheetList extends HookWidget { child: SettingPillSheetView( pageIndex: index, pillSheetTypes: state.pillSheetTypes, - selectedPillNumberPageIndex: - state.todayPillNumber?.pageIndex, selectedPillNumberIntoPillSheet: state.todayPillNumber?.pillNumberIntoPillSheet, markSelected: (pageIndex, number) { diff --git a/lib/domain/settings/menstruation/setting_menstruation_page.dart b/lib/domain/settings/menstruation/setting_menstruation_page.dart index d148edae16..bbfb022c60 100644 --- a/lib/domain/settings/menstruation/setting_menstruation_page.dart +++ b/lib/domain/settings/menstruation/setting_menstruation_page.dart @@ -15,7 +15,6 @@ class SettingMenstruationPage extends HookWidget { @override Widget build(BuildContext context) { final store = useProvider(settingMenstruationStoreProvider); - final state = useProvider(settingMenstruationStoreProvider.state); final settingState = useProvider(settingStateProvider); final setting = settingState.entity; if (setting == null) { @@ -25,12 +24,8 @@ class SettingMenstruationPage extends HookWidget { title: "生理について", pillSheetList: SettingMenstruationPillSheetList( pillSheetTypes: setting.pillSheetTypes, - selectedPillSheetPageIndex: state.currentPageIndex, selectedPillNumber: (pageIndex) => store.retrieveMenstruationSelectedPillNumber(setting, pageIndex), - onPageChanged: (number) { - store.setCurrentPageIndex(number); - }, markSelected: (pageIndex, number) { analytics.logEvent(name: "from_menstruation_setting", parameters: { "number": number, @@ -44,15 +39,15 @@ class SettingMenstruationPage extends HookWidget { }, ), dynamicDescription: SettingMenstruationDynamicDescription( + pillSheetTypes: setting.pillSheetTypes, fromMenstruation: setting.pillNumberForFromMenstruation, fromMenstructionDidDecide: (number) { analytics.logEvent( name: "from_menstruation_initial_setting", parameters: {"number": number}); - store.modifyFromMenstruation( + store.modifyFromMenstruationFromPicker( setting: setting, - pageIndex: state.currentPageIndex, - fromMenstruation: number, + serializedPillNumberIntoGroup: number, ); }, durationMenstruation: setting.durationMenstruation, @@ -65,9 +60,6 @@ class SettingMenstruationPage extends HookWidget { durationMenstruation: number, ); }, - retrieveFocusedPillSheetType: () { - return setting.pillSheetTypes[state.currentPageIndex]; - }, ), doneButton: null, ); diff --git a/lib/domain/settings/menstruation/setting_menstruation_state.freezed.dart b/lib/domain/settings/menstruation/setting_menstruation_state.freezed.dart index a301d15250..84ab755f40 100644 --- a/lib/domain/settings/menstruation/setting_menstruation_state.freezed.dart +++ b/lib/domain/settings/menstruation/setting_menstruation_state.freezed.dart @@ -16,10 +16,8 @@ final _privateConstructorUsedError = UnsupportedError( class _$SettingMenstruationStateTearOff { const _$SettingMenstruationStateTearOff(); - _SettingMenstruationState call({dynamic currentPageIndex = 0}) { - return _SettingMenstruationState( - currentPageIndex: currentPageIndex, - ); + _SettingMenstruationState call() { + return _SettingMenstruationState(); } } @@ -27,20 +25,13 @@ class _$SettingMenstruationStateTearOff { const $SettingMenstruationState = _$SettingMenstruationStateTearOff(); /// @nodoc -mixin _$SettingMenstruationState { - dynamic get currentPageIndex => throw _privateConstructorUsedError; - - @JsonKey(ignore: true) - $SettingMenstruationStateCopyWith get copyWith => - throw _privateConstructorUsedError; -} +mixin _$SettingMenstruationState {} /// @nodoc abstract class $SettingMenstruationStateCopyWith<$Res> { factory $SettingMenstruationStateCopyWith(SettingMenstruationState value, $Res Function(SettingMenstruationState) then) = _$SettingMenstruationStateCopyWithImpl<$Res>; - $Res call({dynamic currentPageIndex}); } /// @nodoc @@ -51,28 +42,13 @@ class _$SettingMenstruationStateCopyWithImpl<$Res> final SettingMenstruationState _value; // ignore: unused_field final $Res Function(SettingMenstruationState) _then; - - @override - $Res call({ - Object? currentPageIndex = freezed, - }) { - return _then(_value.copyWith( - currentPageIndex: currentPageIndex == freezed - ? _value.currentPageIndex - : currentPageIndex // ignore: cast_nullable_to_non_nullable - as dynamic, - )); - } } /// @nodoc -abstract class _$SettingMenstruationStateCopyWith<$Res> - implements $SettingMenstruationStateCopyWith<$Res> { +abstract class _$SettingMenstruationStateCopyWith<$Res> { factory _$SettingMenstruationStateCopyWith(_SettingMenstruationState value, $Res Function(_SettingMenstruationState) then) = __$SettingMenstruationStateCopyWithImpl<$Res>; - @override - $Res call({dynamic currentPageIndex}); } /// @nodoc @@ -86,63 +62,28 @@ class __$SettingMenstruationStateCopyWithImpl<$Res> @override _SettingMenstruationState get _value => super._value as _SettingMenstruationState; - - @override - $Res call({ - Object? currentPageIndex = freezed, - }) { - return _then(_SettingMenstruationState( - currentPageIndex: currentPageIndex == freezed - ? _value.currentPageIndex - : currentPageIndex, - )); - } } /// @nodoc class _$_SettingMenstruationState extends _SettingMenstruationState { - _$_SettingMenstruationState({this.currentPageIndex = 0}) : super._(); - - @JsonKey(defaultValue: 0) - @override - final dynamic currentPageIndex; + _$_SettingMenstruationState() : super._(); @override String toString() { - return 'SettingMenstruationState(currentPageIndex: $currentPageIndex)'; + return 'SettingMenstruationState()'; } @override bool operator ==(dynamic other) { - return identical(this, other) || - (other is _SettingMenstruationState && - (identical(other.currentPageIndex, currentPageIndex) || - const DeepCollectionEquality() - .equals(other.currentPageIndex, currentPageIndex))); + return identical(this, other) || (other is _SettingMenstruationState); } @override - int get hashCode => - runtimeType.hashCode ^ - const DeepCollectionEquality().hash(currentPageIndex); - - @JsonKey(ignore: true) - @override - _$SettingMenstruationStateCopyWith<_SettingMenstruationState> get copyWith => - __$SettingMenstruationStateCopyWithImpl<_SettingMenstruationState>( - this, _$identity); + int get hashCode => runtimeType.hashCode; } abstract class _SettingMenstruationState extends SettingMenstruationState { - factory _SettingMenstruationState({dynamic currentPageIndex}) = - _$_SettingMenstruationState; + factory _SettingMenstruationState() = _$_SettingMenstruationState; _SettingMenstruationState._() : super._(); - - @override - dynamic get currentPageIndex => throw _privateConstructorUsedError; - @override - @JsonKey(ignore: true) - _$SettingMenstruationStateCopyWith<_SettingMenstruationState> get copyWith => - throw _privateConstructorUsedError; } diff --git a/lib/domain/settings/menstruation/setting_menstruation_store.dart b/lib/domain/settings/menstruation/setting_menstruation_store.dart index d8b8df2627..b3b5722e0b 100644 --- a/lib/domain/settings/menstruation/setting_menstruation_store.dart +++ b/lib/domain/settings/menstruation/setting_menstruation_store.dart @@ -28,6 +28,14 @@ class SettingMenstruationStateStore pillNumberForFromMenstruation: fromMenstruation + offset)); } + Future modifyFromMenstruationFromPicker({ + required Setting setting, + required int serializedPillNumberIntoGroup, + }) { + return _settingService.update(setting.copyWith( + pillNumberForFromMenstruation: serializedPillNumberIntoGroup)); + } + Future modifyDurationMenstruation({ required Setting setting, required int durationMenstruation, @@ -36,10 +44,6 @@ class SettingMenstruationStateStore .update(setting.copyWith(durationMenstruation: durationMenstruation)); } - setCurrentPageIndex(int pageIndex) { - state = state.copyWith(currentPageIndex: pageIndex); - } - int? retrieveMenstruationSelectedPillNumber( Setting setting, int pageIndex, diff --git a/lib/domain/settings/today_pill_number/setting_today_pill_number_pill_sheet_list.dart b/lib/domain/settings/today_pill_number/setting_today_pill_number_pill_sheet_list.dart index 8ad85aeea2..4ed74d031a 100644 --- a/lib/domain/settings/today_pill_number/setting_today_pill_number_pill_sheet_list.dart +++ b/lib/domain/settings/today_pill_number/setting_today_pill_number_pill_sheet_list.dart @@ -46,7 +46,6 @@ class SettingTodayPillNumberPillSheetList extends HookWidget { child: SettingPillSheetView( pageIndex: pageIndex, pillSheetTypes: pillSheetTypes, - selectedPillNumberPageIndex: selectedPageIndex, selectedPillNumberIntoPillSheet: selectedTodayPillNumberIntoPillSheet, markSelected: (pageIndex, number) { From 73ffb02350f54b4582b8a744929c99b934fca865 Mon Sep 17 00:00:00 2001 From: bannzai Date: Fri, 17 Sep 2021 08:18:06 +0900 Subject: [PATCH 06/11] :recycle: Remove unnecessary property --- .../organisms/pill_sheet/setting_pill_sheet_view_test.dart | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/components/organisms/pill_sheet/setting_pill_sheet_view_test.dart b/test/components/organisms/pill_sheet/setting_pill_sheet_view_test.dart index 96f9c4f5b3..3db72cd7f7 100644 --- a/test/components/organisms/pill_sheet/setting_pill_sheet_view_test.dart +++ b/test/components/organisms/pill_sheet/setting_pill_sheet_view_test.dart @@ -25,7 +25,6 @@ void main() { final widget = SettingPillSheetView( pageIndex: 0, pillSheetTypes: [pillSheetType], - selectedPillNumberPageIndex: 0, selectedPillNumberIntoPillSheet: null, markSelected: (p, i) => {}, ); @@ -52,7 +51,6 @@ void main() { final widget = SettingPillSheetView( pageIndex: 0, pillSheetTypes: [pillSheetType], - selectedPillNumberPageIndex: 0, selectedPillNumberIntoPillSheet: null, markSelected: (p, i) => {}, ); @@ -79,7 +77,6 @@ void main() { final widget = SettingPillSheetView( pageIndex: 0, pillSheetTypes: [pillSheetType], - selectedPillNumberPageIndex: 0, selectedPillNumberIntoPillSheet: 10, markSelected: (p, i) => {}, ); @@ -105,7 +102,6 @@ void main() { final widget = SettingPillSheetView( pageIndex: 0, pillSheetTypes: [pillSheetType], - selectedPillNumberPageIndex: 0, selectedPillNumberIntoPillSheet: null, markSelected: (p, i) => {}, ); From dfb1ecba799ce34890e06bf30e886f080810ab65 Mon Sep 17 00:00:00 2001 From: bannzai Date: Fri, 17 Sep 2021 08:22:39 +0900 Subject: [PATCH 07/11] :recycle: adjustment extract selected today pill number --- lib/domain/initial_setting/initial_setting_state.dart | 7 +++++++ .../select_today_pill_number_pill_sheet_list.dart | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/domain/initial_setting/initial_setting_state.dart b/lib/domain/initial_setting/initial_setting_state.dart index f95a0ca0b6..ca5bb9e8a2 100644 --- a/lib/domain/initial_setting/initial_setting_state.dart +++ b/lib/domain/initial_setting/initial_setting_state.dart @@ -155,4 +155,11 @@ abstract class InitialSettingState implements _$InitialSettingState { return DateTime(t.year, t.month, t.day, reminderTime.hour, reminderTime.minute, t.second, t.millisecond, t.microsecond); } + + int? selectedTodayPillNumberIntoPillSheet({required int pageIndex}) { + if (todayPillNumber?.pageIndex != pageIndex) { + return null; + } + return todayPillNumber?.pillNumberIntoPillSheet; + } } diff --git a/lib/domain/initial_setting/today_pill_number/select_today_pill_number_pill_sheet_list.dart b/lib/domain/initial_setting/today_pill_number/select_today_pill_number_pill_sheet_list.dart index eb4317daae..f55a3b8d66 100644 --- a/lib/domain/initial_setting/today_pill_number/select_today_pill_number_pill_sheet_list.dart +++ b/lib/domain/initial_setting/today_pill_number/select_today_pill_number_pill_sheet_list.dart @@ -44,7 +44,8 @@ class SelectTodayPillNumberPillSheetList extends HookWidget { pageIndex: index, pillSheetTypes: state.pillSheetTypes, selectedPillNumberIntoPillSheet: - state.todayPillNumber?.pillNumberIntoPillSheet, + state.selectedTodayPillNumberIntoPillSheet( + pageIndex: index), markSelected: (pageIndex, number) { analytics.logEvent( name: "selected_today_number_initial_setting", From b56f0bd10d85e87a32ff2b61d8f371c6943d8257 Mon Sep 17 00:00:00 2001 From: bannzai Date: Fri, 17 Sep 2021 08:30:53 +0900 Subject: [PATCH 08/11] :recycle: fix extract today pill number --- .../today_pill_number/setting_today_pill_number_page.dart | 3 +-- .../setting_today_pill_number_pill_sheet_list.dart | 6 ++---- .../today_pill_number/setting_today_pill_number_state.dart | 7 +++++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/domain/settings/today_pill_number/setting_today_pill_number_page.dart b/lib/domain/settings/today_pill_number/setting_today_pill_number_page.dart index d942872d60..315c9e872e 100644 --- a/lib/domain/settings/today_pill_number/setting_today_pill_number_page.dart +++ b/lib/domain/settings/today_pill_number/setting_today_pill_number_page.dart @@ -61,9 +61,8 @@ class SettingTodayPillNumberPage extends HookWidget { pillSheetTypes: pillSheetGroup.pillSheets .map((e) => e.pillSheetType) .toList(), - selectedPageIndex: state.selectedPillSheetPageIndex, selectedTodayPillNumberIntoPillSheet: - state.selectedPillMarkNumberIntoPillSheet, + state.selectedTodayPillNumberIntoPillSheet, markSelected: (pageIndex, pillNumberIntoPillSheet) => store.markSelected( pageIndex: pageIndex, diff --git a/lib/domain/settings/today_pill_number/setting_today_pill_number_pill_sheet_list.dart b/lib/domain/settings/today_pill_number/setting_today_pill_number_pill_sheet_list.dart index 4ed74d031a..01e2c7c952 100644 --- a/lib/domain/settings/today_pill_number/setting_today_pill_number_pill_sheet_list.dart +++ b/lib/domain/settings/today_pill_number/setting_today_pill_number_pill_sheet_list.dart @@ -8,14 +8,12 @@ import 'package:pilll/entity/pill_sheet_type.dart'; class SettingTodayPillNumberPillSheetList extends HookWidget { final List pillSheetTypes; - final int selectedPageIndex; - final int selectedTodayPillNumberIntoPillSheet; + final int? Function(int pageIndex) selectedTodayPillNumberIntoPillSheet; final Function(int pageIndex, int pillNumberIntoPillSheet) markSelected; const SettingTodayPillNumberPillSheetList({ Key? key, required this.pillSheetTypes, - required this.selectedPageIndex, required this.selectedTodayPillNumberIntoPillSheet, required this.markSelected, }) : super(key: key); @@ -47,7 +45,7 @@ class SettingTodayPillNumberPillSheetList extends HookWidget { pageIndex: pageIndex, pillSheetTypes: pillSheetTypes, selectedPillNumberIntoPillSheet: - selectedTodayPillNumberIntoPillSheet, + selectedTodayPillNumberIntoPillSheet(pageIndex), markSelected: (pageIndex, number) { analytics.logEvent( name: "selected_today_number_initial_setting", diff --git a/lib/domain/settings/today_pill_number/setting_today_pill_number_state.dart b/lib/domain/settings/today_pill_number/setting_today_pill_number_state.dart index 1b8cc0524b..019b045c90 100644 --- a/lib/domain/settings/today_pill_number/setting_today_pill_number_state.dart +++ b/lib/domain/settings/today_pill_number/setting_today_pill_number_state.dart @@ -10,4 +10,11 @@ abstract class SettingTodayPillNumberState @Default(0) int selectedPillSheetPageIndex, @Default(0) int selectedPillMarkNumberIntoPillSheet, }) = _SettingTodayPillNumberState; + + int? selectedTodayPillNumberIntoPillSheet(int pageIndex) { + if (selectedPillSheetPageIndex != pageIndex) { + return null; + } + return selectedPillMarkNumberIntoPillSheet; + } } From 546d08d05423e696aa023cc6233f2d125d676bd6 Mon Sep 17 00:00:00 2001 From: bannzai Date: Fri, 17 Sep 2021 08:36:01 +0900 Subject: [PATCH 09/11] :bug: Bugfix decided lastTakenDate after initial setting --- .../initial_setting_state.dart | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/domain/initial_setting/initial_setting_state.dart b/lib/domain/initial_setting/initial_setting_state.dart index ca5bb9e8a2..9ed2622f2b 100644 --- a/lib/domain/initial_setting/initial_setting_state.dart +++ b/lib/domain/initial_setting/initial_setting_state.dart @@ -127,25 +127,23 @@ abstract class InitialSettingState implements _$InitialSettingState { return null; } final pillSheetType = pillSheetTypes[pageIndex]; - final pillSheetBeginPillNumber = pageIndex * pillSheetType.totalCount + 1; - final pillSheetEndPillNumber = - pastedTotalCount(pillSheetTypes: pillSheetTypes, pageIndex: pageIndex) + - pillSheetType.totalCount; - if (pillSheetBeginPillNumber <= todayPillNumber.pillNumberIntoPillSheet && - todayPillNumber.pillNumberIntoPillSheet <= pillSheetEndPillNumber) { - // Between current PillSheet - return today().subtract(Duration(days: 1)); - } else if (todayPillNumber.pillNumberIntoPillSheet < - pillSheetEndPillNumber) { + if (todayPillNumber.pageIndex < pageIndex) { // Right side PillSheet return null; - } else { + } else if (todayPillNumber.pageIndex > pageIndex) { // Left side PillSheet return _beginingDate( pageIndex: pageIndex, todayPillNumber: todayPillNumber, pillSheetTypes: pillSheetTypes, ).add(Duration(days: pillSheetType.totalCount - 1)); + } else { + // Current PillSheet + return _beginingDate( + pageIndex: pageIndex, + todayPillNumber: todayPillNumber, + pillSheetTypes: pillSheetTypes, + ).add(Duration(days: todayPillNumber.pillNumberIntoPillSheet - 2)); } } From 29ab921a1386b8c9a92acf9ac4fb173187edaf5e Mon Sep 17 00:00:00 2001 From: bannzai Date: Fri, 17 Sep 2021 08:37:04 +0900 Subject: [PATCH 10/11] :memo: fix wording --- .../pill_sheet_group/initial_setting_pill_sheet_group_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/domain/initial_setting/pill_sheet_group/initial_setting_pill_sheet_group_page.dart b/lib/domain/initial_setting/pill_sheet_group/initial_setting_pill_sheet_group_page.dart index fd99b8e1d2..0a6e43f353 100644 --- a/lib/domain/initial_setting/pill_sheet_group/initial_setting_pill_sheet_group_page.dart +++ b/lib/domain/initial_setting/pill_sheet_group/initial_setting_pill_sheet_group_page.dart @@ -39,7 +39,7 @@ class InitialSettingPillSheetGroupPage extends HookWidget { children: [ SizedBox(height: 24), Text( - "お手元のピルシートの枚数を\n選んでください", + "処方されるピルシートについて\n教えてください", style: FontType.title.merge(TextColorStyle.main), textAlign: TextAlign.center, ), From 992d2c58705e283fcf15fa1b1a3eb49dd8e43751 Mon Sep 17 00:00:00 2001 From: bannzai Date: Fri, 17 Sep 2021 08:38:54 +0900 Subject: [PATCH 11/11] :memo: fix test case --- test/domain/initial_setting/initial_setting_store_test.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/test/domain/initial_setting/initial_setting_store_test.dart b/test/domain/initial_setting/initial_setting_store_test.dart index 7adfbe7764..4e3e751ea2 100644 --- a/test/domain/initial_setting/initial_setting_store_test.dart +++ b/test/domain/initial_setting/initial_setting_store_test.dart @@ -554,6 +554,7 @@ void main() { final pillSheet2 = PillSheet( typeInfo: PillSheetType.pillsheet_21.typeInfo, beginingDate: _today, + lastTakenDate: _today.subtract(Duration(days: 1)), groupIndex: 1, ); final pillSheetService = MockPillSheetService();