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

add switching appearance mode on record page #414

Merged
merged 49 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
5d49c61
:art: add assets of switching appearance mode
bannzai Nov 6, 2021
6fbdd05
:art: put appearance UI
bannzai Nov 7, 2021
2c62d3d
:recyle: move to components support
bannzai Nov 7, 2021
2709502
:recycle: move to components/supports/components/rest_duration
bannzai Nov 7, 2021
12f7058
:recycle: Rename to RecordPagePillSheetSupportActions
bannzai Nov 7, 2021
814b4fd
:recycle: Extract to SwitchingAppearanceMode
bannzai Nov 7, 2021
442029c
:sparkles: add switching appearance mode to store
bannzai Nov 7, 2021
9f3c74c
:sparkels: add modal
bannzai Nov 7, 2021
9f0f8b2
:art: add circle images
bannzai Nov 7, 2021
5e7e671
:sparkles: add base component of select circle
bannzai Nov 7, 2021
206ee12
:recycle: pass setting.pillSheetAppearanceMode
bannzai Nov 7, 2021
aa38518
:sparkels: implement modal
bannzai Nov 7, 2021
e99cf0b
:recycle: fix layout
bannzai Nov 7, 2021
df16afd
:recycle: fix row
bannzai Nov 7, 2021
762a6d8
:sparkels: add sequential case
bannzai Nov 7, 2021
4fbc1af
:recycle: Replace to StatelessWidget
bannzai Nov 7, 2021
153abdb
:sparkles: to hook widget
bannzai Nov 7, 2021
63d57f2
:recycle: to static method
bannzai Nov 8, 2021
69e0364
:sparkles: add test case
bannzai Nov 8, 2021
4fe2ee3
:sparkles: add test case but failed
bannzai Nov 8, 2021
242e01c
:sparkles: add test case
bannzai Nov 8, 2021
0da2214
:sparkles: add test case
bannzai Nov 8, 2021
36b9285
:memo: add reasons
bannzai Nov 8, 2021
6a755c6
:recycle: missing condition
bannzai Nov 8, 2021
2f4f270
:sparkels: add test case
bannzai Nov 8, 2021
698e1ed
:sparkles: add test case
bannzai Nov 8, 2021
d919b02
:recycle: fix test case
bannzai Nov 8, 2021
6866499
:recycle: inject setting to state
bannzai Nov 8, 2021
0b17b7b
:recycle: Rename to pillNumberIntoPillSheet
bannzai Nov 8, 2021
a0ac5e4
:sparkles: add sequential pill number widgets
bannzai Nov 8, 2021
393f4d8
:recycle: fix test case
bannzai Nov 8, 2021
15f8fa7
:recycle: fix test case
bannzai Nov 8, 2021
9fc80ea
:recycle: Refactor decided pill number widget type
bannzai Nov 8, 2021
9109fdb
:recycle: fix test case
bannzai Nov 8, 2021
c30199e
:recycle: fix test case
bannzai Nov 8, 2021
9274336
:sparkels: add test group
bannzai Nov 8, 2021
b2cc166
:recycle: fix test position
bannzai Nov 8, 2021
bd1341a
:recycle: missing test case
bannzai Nov 8, 2021
45f95a6
Switching word
bannzai Nov 9, 2021
2474abe
:recycle: add condition of premium function
bannzai Nov 9, 2021
48c1491
:memo: add analytics events
bannzai Nov 9, 2021
2669f4c
:shirt: fix indent
bannzai Nov 9, 2021
8da2871
:sparkels: add analytics
bannzai Nov 9, 2021
0c64260
:sparkels: add analytics
bannzai Nov 9, 2021
b2d278b
:memo: using to string method
bannzai Nov 9, 2021
6ace82a
:memo: add comment
bannzai Nov 9, 2021
0ac131b
:recycle: Remove unnecessary method
bannzai Nov 9, 2021
64b8b76
:recycle: remove unused file
bannzai Nov 9, 2021
990782f
:recycle: avoid compile error
bannzai Nov 9, 2021
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
3 changes: 3 additions & 0 deletions images/circle.fill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/circle.line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/switching_appearance_mode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions lib/components/molecules/select_circle.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

class SelectCircle extends StatelessWidget {
final bool isSelected;

const SelectCircle({Key? key, required this.isSelected}) : super(key: key);

@override
Widget build(BuildContext context) {
return Stack(
children: [
SizedBox(
width: 20,
height: 20,
child: SvgPicture.asset("images/circle.line.svg")),
if (isSelected)
Positioned(
top: 5,
left: 5,
width: 10,
height: 10,
child: SvgPicture.asset("images/circle.fill.svg")),
],
);
}
}
5 changes: 5 additions & 0 deletions lib/domain/record/components/header/record_page_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:pilll/domain/record/components/header/today_taken_pill_number.da
import 'package:pilll/domain/record/record_page_store.dart';
import 'package:pilll/domain/settings/today_pill_number/setting_today_pill_number_page.dart';
import 'package:pilll/entity/pill_sheet_group.dart';
import 'package:pilll/entity/setting.dart';
import 'package:pilll/util/formatter/date_time_formatter.dart';
import 'package:flutter/material.dart';

Expand All @@ -17,11 +18,13 @@ abstract class RecordPageInformationHeaderConst {
class RecordPageInformationHeader extends StatelessWidget {
final DateTime today;
final PillSheetGroup? pillSheetGroup;
final Setting setting;
final RecordPageStore store;
const RecordPageInformationHeader({
Key? key,
required this.today,
required this.pillSheetGroup,
required this.setting,
required this.store,
}) : super(key: key);

Expand All @@ -32,6 +35,7 @@ class RecordPageInformationHeader extends StatelessWidget {
Widget build(BuildContext context) {
final pillSheetGroup = this.pillSheetGroup;
final activedPillSheet = pillSheetGroup?.activedPillSheet;
final setting = this.setting;

return Container(
height: RecordPageInformationHeaderConst.height,
Expand All @@ -53,6 +57,7 @@ class RecordPageInformationHeader extends StatelessWidget {
SizedBox(width: 28),
TodayTakenPillNumber(
pillSheetGroup: pillSheetGroup,
setting: setting,
onPressed: () {
analytics.logEvent(
name: "tapped_record_information_header");
Expand Down
27 changes: 22 additions & 5 deletions lib/domain/record/components/header/today_taken_pill_number.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,39 @@ import 'package:pilll/components/atoms/text_color.dart';
import 'package:pilll/entity/pill_sheet_group.dart';
import 'package:pilll/entity/pill_sheet_type.dart';
import 'package:flutter/material.dart';
import 'package:pilll/entity/setting.dart';

class TodayTakenPillNumber extends StatelessWidget {
final PillSheetGroup? pillSheetGroup;
final VoidCallback onPressed;
final Setting setting;

const TodayTakenPillNumber({
Key? key,
required this.pillSheetGroup,
required this.onPressed,
required this.setting,
}) : super(key: key);

PillSheetAppearanceMode get _appearanceMode =>
setting.pillSheetAppearanceMode;

@override
Widget build(BuildContext context) {
return GestureDetector(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"💊 今日飲むピル",
style: FontType.assisting.merge(TextColorStyle.noshime),
),
if (_appearanceMode == PillSheetAppearanceMode.sequential)
Text(
"💊 今日は服用",
style: FontType.assisting.merge(TextColorStyle.noshime),
),
if (_appearanceMode != PillSheetAppearanceMode.sequential)
Text(
"💊 今日飲むピル",
style: FontType.assisting.merge(TextColorStyle.noshime),
),
_content(),
],
),
Expand Down Expand Up @@ -64,7 +76,12 @@ class TodayTakenPillNumber extends StatelessWidget {
children: <Widget>[
Text("${activedPillSheet.todayPillNumber}",
style: FontType.xHugeNumber.merge(TextColorStyle.main)),
Text("番", style: FontType.assistingBold.merge(TextColorStyle.noshime)),
if (_appearanceMode == PillSheetAppearanceMode.sequential)
Text("日目",
style: FontType.assistingBold.merge(TextColorStyle.noshime)),
if (_appearanceMode != PillSheetAppearanceMode.sequential)
Text("番",
style: FontType.assistingBold.merge(TextColorStyle.noshime)),
],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,31 @@ import 'package:pilll/components/atoms/font.dart';
import 'package:pilll/util/formatter/date_time_formatter.dart';

class PlainPillNumber extends StatelessWidget {
final int pillNumber;
final int pillNumberIntoPillSheet;

const PlainPillNumber({Key? key, required this.pillNumber}) : super(key: key);
const PlainPillNumber({Key? key, required this.pillNumberIntoPillSheet})
: super(key: key);
@override
Widget build(BuildContext context) {
return Text(
"$pillNumberIntoPillSheet",
style: FontType.smallTitle.merge(TextStyle(color: PilllColors.weekday)),
textScaleFactor: 1,
);
}
}

class SequentialPillNumber extends StatelessWidget {
final int offset;
final int pillNumberIntoPillSheet;

const SequentialPillNumber(
{Key? key, required this.offset, required this.pillNumberIntoPillSheet})
: super(key: key);
@override
Widget build(BuildContext context) {
return Text(
"$pillNumber",
"${offset + pillNumberIntoPillSheet}",
style: FontType.smallTitle.merge(TextStyle(color: PilllColors.weekday)),
textScaleFactor: 1,
);
Expand All @@ -32,14 +50,32 @@ class PlainPillDate extends StatelessWidget {
}

class MenstruationPillNumber extends StatelessWidget {
final int pillNumber;
final int pillNumberIntoPillSheet;

const MenstruationPillNumber(
{Key? key, required this.pillNumberIntoPillSheet})
: super(key: key);
@override
Widget build(BuildContext context) {
return Text(
"$pillNumberIntoPillSheet",
style: FontType.smallTitle.merge(TextStyle(color: PilllColors.primary)),
textScaleFactor: 1,
);
}
}

class MenstruationSequentialPillNumber extends StatelessWidget {
final int offset;
final int pillNumberIntoPillSheet;

const MenstruationPillNumber({Key? key, required this.pillNumber})
const MenstruationSequentialPillNumber(
{Key? key, required this.offset, required this.pillNumberIntoPillSheet})
: super(key: key);
@override
Widget build(BuildContext context) {
return Text(
"$pillNumber",
"${offset + pillNumberIntoPillSheet}",
style: FontType.smallTitle.merge(TextStyle(color: PilllColors.primary)),
textScaleFactor: 1,
);
Expand Down
79 changes: 49 additions & 30 deletions lib/domain/record/components/pill_sheet/record_page_pill_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ class RecordPagePillSheet extends StatelessWidget {
return Container(
width: PillSheetViewLayout.componentWidth,
child: PillMarkWithNumberLayout(
textOfPillNumber: _textOfPillNumber(
textOfPillNumber: textOfPillNumber(
state: state,
pillSheetGroup: pillSheetGroup,
pillSheet: pillSheet,
setting: setting,
pillNumberIntoPillSheet: pillNumberIntoPillSheet,
pageIndex: pageIndex,
),
Expand Down Expand Up @@ -119,53 +121,71 @@ class RecordPagePillSheet extends StatelessWidget {
});
}

Widget _textOfPillNumber({
static Widget textOfPillNumber({
required RecordPageState state,
required PillSheetGroup pillSheetGroup,
required PillSheet pillSheet,
required int pillNumberIntoPillSheet,
required int pageIndex,
required Setting setting,
}) {
final DateTime date =
calculatedDateOfAppearancePill(pillSheet, pillNumberIntoPillSheet);
final isDateMode = () {
if (!(state.isPremium || state.isTrial)) {
return false;
}
if (state.appearanceMode != PillSheetAppearanceMode.date) {
return false;
}
return true;
}();

if (setting.pillNumberForFromMenstruation == 0 ||
setting.durationMenstruation == 0) {
if (isDateMode) {
return PlainPillDate(date: date);
} else {
return PlainPillNumber(pillNumber: pillNumberIntoPillSheet);
}
}

final isPremiumOrTrial = state.isPremium || state.isTrial;
final containedMenstruationDuration =
RecordPagePillSheet.isContainedMenstruationDuration(
pillNumberIntoPillSheet: pillNumberIntoPillSheet,
pillSheetGroup: pillSheetGroup,
setting: setting,
pageIndex: pageIndex,
);
if (isPremiumOrTrial &&
state.appearanceMode == PillSheetAppearanceMode.date) {
final DateTime date =
calculatedDateOfAppearancePill(pillSheet, pillNumberIntoPillSheet);

if (setting.pillNumberForFromMenstruation == 0 ||
setting.durationMenstruation == 0) {
return PlainPillDate(date: date);
}

if (isDateMode) {
if (containedMenstruationDuration && (state.isPremium || state.isTrial)) {
if (containedMenstruationDuration) {
return MenstruationPillDate(date: date);
} else {
return PlainPillDate(date: date);
}
} else if (state.appearanceMode == PillSheetAppearanceMode.sequential) {
final offset = summarizedPillSheetTypeTotalCountToPageIndex(
pillSheetTypes:
pillSheetGroup.pillSheets.map((e) => e.pillSheetType).toList(),
pageIndex: pageIndex,
);
if (setting.pillNumberForFromMenstruation == 0 ||
setting.durationMenstruation == 0) {
return SequentialPillNumber(
offset: offset, pillNumberIntoPillSheet: pillNumberIntoPillSheet);
}

if (isPremiumOrTrial) {
if (containedMenstruationDuration) {
return MenstruationSequentialPillNumber(
offset: offset, pillNumberIntoPillSheet: pillNumberIntoPillSheet);
}
}
return SequentialPillNumber(
offset: offset, pillNumberIntoPillSheet: pillNumberIntoPillSheet);
} else {
if (containedMenstruationDuration && (state.isPremium || state.isTrial)) {
return MenstruationPillNumber(pillNumber: pillNumberIntoPillSheet);
} else {
return PlainPillNumber(pillNumber: pillNumberIntoPillSheet);
if (setting.pillNumberForFromMenstruation == 0 ||
setting.durationMenstruation == 0) {
return PlainPillNumber(
pillNumberIntoPillSheet: pillNumberIntoPillSheet);
}

if (isPremiumOrTrial) {
if (containedMenstruationDuration) {
return MenstruationPillNumber(
pillNumberIntoPillSheet: pillNumberIntoPillSheet);
}
}
return PlainPillNumber(pillNumberIntoPillSheet: pillNumberIntoPillSheet);
}
}

Expand Down Expand Up @@ -202,7 +222,6 @@ class RecordPagePillSheet extends StatelessWidget {
return left <= pillNumberIntoPillSheet &&
pillNumberIntoPillSheet <= right;
}

final pillSheetTypes =
pillSheetGroup.pillSheets.map((e) => e.pillSheetType).toList();
final passedCount = summarizedPillSheetTypeTotalCountToPageIndex(
Expand Down
Loading