From 068415232e2bf008efe8e348ea8fc4109212e13a Mon Sep 17 00:00:00 2001 From: bannzai Date: Tue, 22 Mar 2022 10:15:22 +0900 Subject: [PATCH] Revert "Add pill sheet count sheet to initial setting" --- images/notch.svg | 3 - .../initial_setting_store.dart | 37 +++-- .../pill_sheet_count_sheet.dart | 95 ------------ ...initial_setting_pill_sheet_group_page.dart | 140 ++++++++++++++++++ .../card_layout.dart | 0 ...itial_setting_pill_category_type_page.dart | 63 ++++---- .../initial_setting_reminder_times_page.dart | 2 +- ...setting_select_today_pill_number_page.dart | 2 +- lib/domain/root/root.dart | 2 +- .../initial_setting_store_test.dart | 20 +-- 10 files changed, 208 insertions(+), 156 deletions(-) delete mode 100644 images/notch.svg delete mode 100644 lib/domain/initial_setting/pill_category_type/pill_sheet_count_sheet.dart create mode 100644 lib/domain/initial_setting/pill_sheet_group/initial_setting_pill_sheet_group_page.dart rename lib/domain/initial_setting/{pill_category_type => pill_type}/card_layout.dart (100%) rename lib/domain/initial_setting/{pill_category_type => pill_type}/initial_setting_pill_category_type_page.dart (89%) diff --git a/images/notch.svg b/images/notch.svg deleted file mode 100644 index a0f9d20d8b..0000000000 --- a/images/notch.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/lib/domain/initial_setting/initial_setting_store.dart b/lib/domain/initial_setting/initial_setting_store.dart index 9518c8f9ec..ad089bff9a 100644 --- a/lib/domain/initial_setting/initial_setting_store.dart +++ b/lib/domain/initial_setting/initial_setting_store.dart @@ -83,15 +83,18 @@ class InitialSettingStateStore extends StateNotifier { } void selectedPillCategoryType( - InitialSettingPillCategoryType pillCategoryType, int? sheetCount) { + InitialSettingPillCategoryType pillCategoryType) { state = state.copyWith(pillType: pillCategoryType); state = state.copyWith(todayPillNumber: null); switch (pillCategoryType) { case InitialSettingPillCategoryType.pill_category_type_yaz_flex: state = state.copyWith( - pillSheetTypes: - List.generate(sheetCount!, (_) => PillSheetType.pillsheet_28_0), + pillSheetTypes: [ + PillSheetType.pillsheet_28_0, + PillSheetType.pillsheet_28_0, + PillSheetType.pillsheet_28_0, + ], pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, ); break; @@ -107,29 +110,41 @@ class InitialSettingStateStore extends StateNotifier { break; case InitialSettingPillCategoryType.pill_category_type_21_rest_7: state = state.copyWith( - pillSheetTypes: - List.generate(sheetCount!, (_) => PillSheetType.pillsheet_21), + pillSheetTypes: [ + PillSheetType.pillsheet_21, + PillSheetType.pillsheet_21, + PillSheetType.pillsheet_21, + ], pillSheetAppearanceMode: PillSheetAppearanceMode.number, ); break; case InitialSettingPillCategoryType.pill_category_type_24_fake_4: state = state.copyWith( - pillSheetTypes: - List.generate(sheetCount!, (_) => PillSheetType.pillsheet_28_4), + pillSheetTypes: [ + PillSheetType.pillsheet_28_4, + PillSheetType.pillsheet_28_4, + PillSheetType.pillsheet_28_4, + ], pillSheetAppearanceMode: PillSheetAppearanceMode.number, ); break; case InitialSettingPillCategoryType.pill_category_type_24_rest_4: state = state.copyWith( - pillSheetTypes: List.generate( - sheetCount!, (_) => PillSheetType.pillsheet_24_rest_4), + pillSheetTypes: [ + PillSheetType.pillsheet_24_rest_4, + PillSheetType.pillsheet_24_rest_4, + PillSheetType.pillsheet_24_rest_4, + ], pillSheetAppearanceMode: PillSheetAppearanceMode.number, ); break; case InitialSettingPillCategoryType.pill_category_type_21_fake_7: state = state.copyWith( - pillSheetTypes: - List.generate(sheetCount!, (_) => PillSheetType.pillsheet_28_7), + pillSheetTypes: [ + PillSheetType.pillsheet_28_7, + PillSheetType.pillsheet_28_7, + PillSheetType.pillsheet_28_7, + ], pillSheetAppearanceMode: PillSheetAppearanceMode.number, ); break; diff --git a/lib/domain/initial_setting/pill_category_type/pill_sheet_count_sheet.dart b/lib/domain/initial_setting/pill_category_type/pill_sheet_count_sheet.dart deleted file mode 100644 index 0da9075158..0000000000 --- a/lib/domain/initial_setting/pill_category_type/pill_sheet_count_sheet.dart +++ /dev/null @@ -1,95 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_svg/svg.dart'; -import 'package:pilll/analytics.dart'; -import 'package:pilll/components/atoms/color.dart'; -import 'package:pilll/components/atoms/font.dart'; -import 'package:pilll/components/atoms/text_color.dart'; -import 'package:pilll/domain/initial_setting/initial_setting_store.dart'; -import 'package:pilll/domain/initial_setting/today_pill_number/initial_setting_select_today_pill_number_page.dart'; -import 'package:pilll/entity/initial_setting_pill_category_type.dart'; - -class PillSheetCountSheet extends StatelessWidget { - final InitialSettingPillCategoryType pillCategoryType; - final InitialSettingStateStore store; - - const PillSheetCountSheet( - {Key? key, required this.pillCategoryType, required this.store}) - : super(key: key); - @override - Widget build(BuildContext context) { - return Container( - padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 15), - height: 235, - decoration: const BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(10))), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SvgPicture.asset("images/notch.svg"), - const SizedBox(height: 24), - const Text("処方されるシート数は?", - style: TextStyle( - color: TextColor.main, - fontSize: 16, - fontFamily: FontFamily.japanese, - fontWeight: FontWeight.bold, - )), - const SizedBox(height: 40), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - ...List.generate(6, (index) => index + 1).map((number) { - return GestureDetector( - onTap: () { - analytics.logEvent( - name: "i_s_pill_sheet_count_sheet_selected", - parameters: { - "pill_sheet_count": number, - "pill_category_type": pillCategoryType.toString(), - }); - Navigator.of(context).pop(); - - store.selectedPillCategoryType(pillCategoryType, number); - - Navigator.of(context).push( - InitialSettingSelectTodayPillNumberPageRoute.route()); - }, - child: Container( - padding: const EdgeInsets.symmetric( - horizontal: 16.5, vertical: 11), - decoration: BoxDecoration( - border: Border.all( - color: PilllColors.secondary, - width: 1, - ), - borderRadius: BorderRadius.circular(46), - ), - child: Text("$number", - style: const TextStyle( - color: TextColor.main, - fontSize: 16, - fontFamily: FontFamily.number, - fontWeight: FontWeight.bold, - )), - ), - ); - }).toList(), - ], - ), - ], - ), - ); - } -} - -void showPillSheetCountSheet(BuildContext context, - {required InitialSettingPillCategoryType pillCategoryType, - required InitialSettingStateStore store}) { - showModalBottomSheet( - context: context, - builder: (context) => PillSheetCountSheet( - pillCategoryType: pillCategoryType, - store: store, - ), - ); -} 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 new file mode 100644 index 0000000000..6bd8c4c5f3 --- /dev/null +++ b/lib/domain/initial_setting/pill_sheet_group/initial_setting_pill_sheet_group_page.dart @@ -0,0 +1,140 @@ +import 'package:pilll/analytics.dart'; +import 'package:pilll/components/atoms/font.dart'; +import 'package:pilll/components/page/hud.dart'; +import 'package:pilll/components/template/setting_pill_sheet_group/setting_pill_sheet_group.dart'; +import 'package:pilll/domain/initial_setting/initial_setting_state.dart'; +import 'package:pilll/domain/initial_setting/today_pill_number/initial_setting_select_today_pill_number_page.dart'; +import 'package:pilll/domain/initial_setting/initial_setting_store.dart'; +import 'package:pilll/components/atoms/buttons.dart'; +import 'package:pilll/components/atoms/color.dart'; +import 'package:pilll/components/atoms/text_color.dart'; +import 'package:flutter/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:pilll/entity/pill_sheet_type.dart'; + +class InitialSettingPillSheetGroupPage extends HookConsumerWidget { + @override + Widget build(BuildContext context, WidgetRef ref) { + final store = ref.watch(initialSettingStoreProvider.notifier); + final state = ref.watch(initialSettingStoreProvider); + + return HUD( + shown: state.isLoading, + child: Scaffold( + backgroundColor: PilllColors.background, + appBar: AppBar( + leading: IconButton( + icon: const Icon(Icons.arrow_back, color: Colors.black), + onPressed: () => Navigator.of(context).pop(), + ), + title: const Text( + "2/4", + style: TextStyle(color: TextColor.black), + ), + backgroundColor: PilllColors.white, + ), + body: SafeArea( + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 40), + child: Stack( + children: [ + SingleChildScrollView( + child: Column( + children: [ + const SizedBox(height: 24), + Text( + "処方されるシートについて\n教えてください", + style: FontType.sBigTitle.merge(TextColorStyle.main), + textAlign: TextAlign.center, + ), + InitialSettingPillSheetGroupPageBody( + state: state, store: store), + const SizedBox(height: 100), + ], + ), + ), + Align( + alignment: Alignment.bottomCenter, + child: Container( + width: MediaQuery.of(context).size.width, + color: PilllColors.background, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + if (state.pillSheetTypes.isNotEmpty) + PrimaryButton( + text: "次へ", + onPressed: () async { + analytics.logEvent( + name: "next_to_today_pill_number"); + Navigator.of(context).push( + InitialSettingSelectTodayPillNumberPageRoute + .route()); + }, + ), + const SizedBox(height: 35), + ], + ), + ), + ), + ], + ), + ), + ), + ), + ); + } +} + +class InitialSettingPillSheetGroupPageBody extends StatelessWidget { + const InitialSettingPillSheetGroupPageBody({ + Key? key, + required this.state, + required this.store, + }) : super(key: key); + + final InitialSettingState state; + final InitialSettingStateStore store; + + @override + Widget build(BuildContext context) { + return Column( + children: [ + const SizedBox(height: 6), + SettingPillSheetGroup( + pillSheetTypes: state.pillSheetTypes, + onAdd: (pillSheetType) { + analytics.logEvent( + name: "initial_setting_add_pill_sheet_group", + parameters: {"pill_sheet_type": pillSheetType.fullName}); + store.addPillSheetType(pillSheetType); + }, + onChange: (index, pillSheetType) { + analytics.logEvent( + name: "initial_setting_change_pill_sheet_group", + parameters: { + "index": index, + "pill_sheet_type": pillSheetType.fullName + }); + store.changePillSheetType(index, pillSheetType); + }, + onDelete: (index) { + analytics.logEvent( + name: "initial_setting_delete_pill_sheet_group", + parameters: {"index": index}); + store.removePillSheetType(index); + }), + ], + ); + } +} + +extension InitialSettingPillSheetGroupPageRoute + on InitialSettingPillSheetGroupPage { + static Route route() { + return MaterialPageRoute( + settings: const RouteSettings(name: "InitialSettingPillSheetGroupPage"), + builder: (_) => InitialSettingPillSheetGroupPage(), + ); + } +} diff --git a/lib/domain/initial_setting/pill_category_type/card_layout.dart b/lib/domain/initial_setting/pill_type/card_layout.dart similarity index 100% rename from lib/domain/initial_setting/pill_category_type/card_layout.dart rename to lib/domain/initial_setting/pill_type/card_layout.dart diff --git a/lib/domain/initial_setting/pill_category_type/initial_setting_pill_category_type_page.dart b/lib/domain/initial_setting/pill_type/initial_setting_pill_category_type_page.dart similarity index 89% rename from lib/domain/initial_setting/pill_category_type/initial_setting_pill_category_type_page.dart rename to lib/domain/initial_setting/pill_type/initial_setting_pill_category_type_page.dart index 4e7bce8b99..1c3aa2c413 100644 --- a/lib/domain/initial_setting/pill_category_type/initial_setting_pill_category_type_page.dart +++ b/lib/domain/initial_setting/pill_type/initial_setting_pill_category_type_page.dart @@ -4,13 +4,13 @@ import 'package:pilll/analytics.dart'; import 'package:pilll/components/atoms/buttons.dart'; import 'package:pilll/components/atoms/font.dart'; import 'package:pilll/components/page/hud.dart'; -import 'package:pilll/domain/initial_setting/pill_category_type/pill_sheet_count_sheet.dart'; +import 'package:pilll/domain/initial_setting/pill_sheet_group/initial_setting_pill_sheet_group_page.dart'; import 'package:pilll/domain/initial_setting/initial_setting_store.dart'; import 'package:pilll/components/atoms/color.dart'; import 'package:pilll/components/atoms/text_color.dart'; import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:pilll/domain/initial_setting/pill_category_type/card_layout.dart'; +import 'package:pilll/domain/initial_setting/pill_type/card_layout.dart'; import 'package:pilll/domain/initial_setting/today_pill_number/initial_setting_select_today_pill_number_page.dart'; import 'package:pilll/entity/initial_setting_pill_category_type.dart'; import 'package:pilll/router/router.dart'; @@ -61,7 +61,7 @@ class InitialSettingPillCategoryTypePage extends HookConsumerWidget { backgroundColor: PilllColors.background, appBar: AppBar( title: const Text( - "1/3", + "1/4", style: TextStyle(color: TextColor.black), ), backgroundColor: PilllColors.white, @@ -130,12 +130,11 @@ class InitialSettingPillCategoryTypePage extends HookConsumerWidget { initialSettingPillCategoryUserPropertyName, pillCategoryType.toString()); - showPillSheetCountSheet( - context, - pillCategoryType: - pillCategoryType, - store: store, - ); + store.selectedPillCategoryType( + pillCategoryType); + Navigator.of(context).push( + InitialSettingPillSheetGroupPageRoute + .route()); }, ), const SizedBox(height: 20), @@ -167,12 +166,11 @@ class InitialSettingPillCategoryTypePage extends HookConsumerWidget { initialSettingPillCategoryUserPropertyName, pillCategoryType.toString()); - showPillSheetCountSheet( - context, - pillCategoryType: - pillCategoryType, - store: store, - ); + store.selectedPillCategoryType( + pillCategoryType); + Navigator.of(context).push( + InitialSettingPillSheetGroupPageRoute + .route()); }, ), const SizedBox(height: 20), @@ -199,12 +197,11 @@ class InitialSettingPillCategoryTypePage extends HookConsumerWidget { initialSettingPillCategoryUserPropertyName, pillCategoryType.toString()); - showPillSheetCountSheet( - context, - pillCategoryType: - pillCategoryType, - store: store, - ); + store.selectedPillCategoryType( + pillCategoryType); + Navigator.of(context).push( + InitialSettingPillSheetGroupPageRoute + .route()); }, ), ], @@ -244,7 +241,7 @@ class InitialSettingPillCategoryTypePage extends HookConsumerWidget { pillCategoryType.toString()); store.selectedPillCategoryType( - pillCategoryType, null); + pillCategoryType); Navigator.of(context).push( InitialSettingSelectTodayPillNumberPageRoute .route()); @@ -274,12 +271,11 @@ class InitialSettingPillCategoryTypePage extends HookConsumerWidget { initialSettingPillCategoryUserPropertyName, pillCategoryType.toString()); - showPillSheetCountSheet( - context, - pillCategoryType: - pillCategoryType, - store: store, - ); + store.selectedPillCategoryType( + pillCategoryType); + Navigator.of(context).push( + InitialSettingPillSheetGroupPageRoute + .route()); }, ), const SizedBox(height: 20), @@ -309,12 +305,11 @@ class InitialSettingPillCategoryTypePage extends HookConsumerWidget { initialSettingPillCategoryUserPropertyName, pillCategoryType.toString()); - showPillSheetCountSheet( - context, - pillCategoryType: - pillCategoryType, - store: store, - ); + store.selectedPillCategoryType( + pillCategoryType); + Navigator.of(context).push( + InitialSettingPillSheetGroupPageRoute + .route()); }, ), ], diff --git a/lib/domain/initial_setting/reminder_times/initial_setting_reminder_times_page.dart b/lib/domain/initial_setting/reminder_times/initial_setting_reminder_times_page.dart index e9aebc150c..f8e9392e4a 100644 --- a/lib/domain/initial_setting/reminder_times/initial_setting_reminder_times_page.dart +++ b/lib/domain/initial_setting/reminder_times/initial_setting_reminder_times_page.dart @@ -105,7 +105,7 @@ class InitialSettingReminderTimesPage extends HookConsumerWidget { onPressed: () => Navigator.of(context).pop(), ), title: const Text( - "3/3", + "4/4", style: TextStyle(color: TextColor.black), ), backgroundColor: PilllColors.white, diff --git a/lib/domain/initial_setting/today_pill_number/initial_setting_select_today_pill_number_page.dart b/lib/domain/initial_setting/today_pill_number/initial_setting_select_today_pill_number_page.dart index f47cd3a294..2cd93bcc9c 100644 --- a/lib/domain/initial_setting/today_pill_number/initial_setting_select_today_pill_number_page.dart +++ b/lib/domain/initial_setting/today_pill_number/initial_setting_select_today_pill_number_page.dart @@ -31,7 +31,7 @@ class InitialSettingSelectTodayPillNumberPage extends HookConsumerWidget { onPressed: () => Navigator.of(context).pop(), ), title: const Text( - "2/3", + "3/4", style: TextStyle(color: TextColor.black), ), backgroundColor: PilllColors.white, diff --git a/lib/domain/root/root.dart b/lib/domain/root/root.dart index 7eae8fc2fa..6ab3611b88 100644 --- a/lib/domain/root/root.dart +++ b/lib/domain/root/root.dart @@ -6,7 +6,7 @@ import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:firebase_performance/firebase_performance.dart'; import 'package:pilll/analytics.dart'; import 'package:pilll/components/page/ok_dialog.dart'; -import 'package:pilll/domain/initial_setting/pill_category_type/initial_setting_pill_category_type_page.dart'; +import 'package:pilll/domain/initial_setting/pill_type/initial_setting_pill_category_type_page.dart'; import 'package:pilll/entity/config.dart'; import 'package:pilll/entity/user.dart'; import 'package:pilll/performance.dart'; diff --git a/test/domain/initial_setting/initial_setting_store_test.dart b/test/domain/initial_setting/initial_setting_store_test.dart index fd74c5ba54..32821e4519 100644 --- a/test/domain/initial_setting/initial_setting_store_test.dart +++ b/test/domain/initial_setting/initial_setting_store_test.dart @@ -52,7 +52,7 @@ void main() { final store = container.read(initialSettingStoreProvider.notifier); store.selectedPillCategoryType( - InitialSettingPillCategoryType.pill_category_type_yaz_flex, 3); + InitialSettingPillCategoryType.pill_category_type_yaz_flex); expect(container.read(initialSettingStateProvider).pillSheetTypes, [ PillSheetType.pillsheet_28_0, PillSheetType.pillsheet_28_0, @@ -85,7 +85,7 @@ void main() { final store = container.read(initialSettingStoreProvider.notifier); store.selectedPillCategoryType( - InitialSettingPillCategoryType.pill_category_type_yaz_flex, 3); + InitialSettingPillCategoryType.pill_category_type_yaz_flex); expect(container.read(initialSettingStateProvider).pillSheetTypes, [ PillSheetType.pillsheet_28_0, PillSheetType.pillsheet_28_0, @@ -93,7 +93,7 @@ void main() { ]); store.selectedPillCategoryType( - InitialSettingPillCategoryType.pill_category_type_jemina, null); + InitialSettingPillCategoryType.pill_category_type_jemina); expect(container.read(initialSettingStateProvider).pillSheetTypes, [ PillSheetType.pillsheet_28_0, PillSheetType.pillsheet_28_0, @@ -135,7 +135,7 @@ void main() { pageIndex: 0, pillNumberIntoPillSheet: 28)); store.selectedPillCategoryType( - InitialSettingPillCategoryType.pill_category_type_jemina, null); + InitialSettingPillCategoryType.pill_category_type_jemina); expect(container.read(initialSettingStateProvider).pillSheetTypes, [ PillSheetType.pillsheet_28_0, PillSheetType.pillsheet_28_0, @@ -171,7 +171,7 @@ void main() { final store = container.read(initialSettingStoreProvider.notifier); store.selectedPillCategoryType( - InitialSettingPillCategoryType.pill_category_type_yaz_flex, 3); + InitialSettingPillCategoryType.pill_category_type_yaz_flex); store.addPillSheetType(PillSheetType.pillsheet_28_0); expect(container.read(initialSettingStateProvider).pillSheetTypes, [ PillSheetType.pillsheet_28_0, @@ -208,7 +208,7 @@ void main() { final store = container.read(initialSettingStoreProvider.notifier); store.selectedPillCategoryType( - InitialSettingPillCategoryType.pill_category_type_yaz_flex, 3); + InitialSettingPillCategoryType.pill_category_type_yaz_flex); store.addPillSheetType(PillSheetType.pillsheet_28_0); store.changePillSheetType(1, PillSheetType.pillsheet_24_0); expect(container.read(initialSettingStateProvider).pillSheetTypes, [ @@ -246,7 +246,7 @@ void main() { final store = container.read(initialSettingStoreProvider.notifier); store.selectedPillCategoryType( - InitialSettingPillCategoryType.pill_category_type_yaz_flex, 3); + InitialSettingPillCategoryType.pill_category_type_yaz_flex); store.addPillSheetType(PillSheetType.pillsheet_28_0); store.changePillSheetType(1, PillSheetType.pillsheet_24_0); store.removePillSheetType(0); @@ -387,7 +387,7 @@ void main() { final store = container.read(initialSettingStoreProvider.notifier); store.selectedPillCategoryType( - InitialSettingPillCategoryType.pill_category_type_21_rest_7, 3); + InitialSettingPillCategoryType.pill_category_type_21_rest_7); store.removePillSheetType(1); store.removePillSheetType(1); store.setTodayPillNumber(pageIndex: 0, pillNumberIntoPillSheet: 1); @@ -484,7 +484,7 @@ void main() { final store = container.read(initialSettingStoreProvider.notifier); store.selectedPillCategoryType( - InitialSettingPillCategoryType.pill_category_type_yaz_flex, 3); + InitialSettingPillCategoryType.pill_category_type_yaz_flex); store.addPillSheetType(PillSheetType.pillsheet_21); store.removePillSheetType(1); store.removePillSheetType(1); @@ -560,7 +560,7 @@ void main() { final store = container.read(initialSettingStoreProvider.notifier); store.selectedPillCategoryType( - InitialSettingPillCategoryType.pill_category_type_24_rest_4, 3); + InitialSettingPillCategoryType.pill_category_type_24_rest_4); store.removePillSheetType(1); store.removePillSheetType(1);