Skip to content

Commit

Permalink
🐚 dart format lib -l 200
Browse files Browse the repository at this point in the history
  • Loading branch information
bannzai committed Nov 21, 2024
1 parent f2f68e9 commit a1357a0
Show file tree
Hide file tree
Showing 277 changed files with 2,851 additions and 7,409 deletions.
16 changes: 5 additions & 11 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ class App extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
navigatorKey: navigatorKey,
navigatorObservers: [
FirebaseAnalyticsObserver(analytics: firebaseAnalytics)
],
navigatorObservers: [FirebaseAnalyticsObserver(analytics: firebaseAnalytics)],
theme: ThemeData(
useMaterial3: false,
appBarTheme: const AppBarTheme(
Expand Down Expand Up @@ -55,8 +53,7 @@ class App extends StatelessWidget {
headerBackgroundColor: PilllColors.primary,
),
switchTheme: SwitchThemeData(
thumbColor: WidgetStateProperty.resolveWith<Color?>(
(Set<WidgetState> states) {
thumbColor: WidgetStateProperty.resolveWith<Color?>((Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
return null;
}
Expand All @@ -65,8 +62,7 @@ class App extends StatelessWidget {
}
return null;
}),
trackColor: WidgetStateProperty.resolveWith<Color?>(
(Set<WidgetState> states) {
trackColor: WidgetStateProperty.resolveWith<Color?>((Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
return null;
}
Expand All @@ -77,8 +73,7 @@ class App extends StatelessWidget {
}),
),
radioTheme: RadioThemeData(
fillColor: WidgetStateProperty.resolveWith<Color?>(
(Set<WidgetState> states) {
fillColor: WidgetStateProperty.resolveWith<Color?>((Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
return null;
}
Expand All @@ -90,8 +85,7 @@ class App extends StatelessWidget {
}),
),
checkboxTheme: CheckboxThemeData(
fillColor: WidgetStateProperty.resolveWith<Color?>(
(Set<WidgetState> states) {
fillColor: WidgetStateProperty.resolveWith<Color?>((Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
return null;
}
Expand Down
26 changes: 6 additions & 20 deletions lib/components/atoms/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class PrimaryButton extends HookWidget {
alignment: Alignment.center,
children: [
ElevatedButton(
style: ButtonStyle(
backgroundColor: WidgetStateProperty.resolveWith((statuses) {
style: ButtonStyle(backgroundColor: WidgetStateProperty.resolveWith((statuses) {
if (statuses.contains(WidgetState.disabled)) {
return PilllColors.lightGray;
}
Expand All @@ -46,8 +45,7 @@ class PrimaryButton extends HookWidget {
}
},
child: ConstrainedBox(
constraints: const BoxConstraints(
maxHeight: 44, minHeight: 44, minWidth: 180),
constraints: const BoxConstraints(maxHeight: 44, minHeight: 44, minWidth: 180),
child: Center(
child: Text(text,
style: const TextStyle(
Expand Down Expand Up @@ -82,8 +80,7 @@ class UndoButton extends HookWidget {
alignment: Alignment.center,
children: [
ElevatedButton(
style: ButtonStyle(
backgroundColor: WidgetStateProperty.resolveWith((statuses) {
style: ButtonStyle(backgroundColor: WidgetStateProperty.resolveWith((statuses) {
if (statuses.contains(WidgetState.disabled)) {
return PilllColors.lightGray;
}
Expand All @@ -106,8 +103,7 @@ class UndoButton extends HookWidget {
}
},
child: ConstrainedBox(
constraints: const BoxConstraints(
maxHeight: 44, minHeight: 44, minWidth: 180, maxWidth: 180),
constraints: const BoxConstraints(maxHeight: 44, minHeight: 44, minWidth: 180, maxWidth: 180),
child: Center(
child: Text(text,
style: const TextStyle(
Expand Down Expand Up @@ -213,11 +209,7 @@ class InconspicuousButton extends HookWidget {
child: Stack(
alignment: Alignment.center,
children: [
Text(text,
style: TextStyle(
color: isProcessing.value
? TextColor.lightGray
: TextColor.gray)),
Text(text, style: TextStyle(color: isProcessing.value ? TextColor.lightGray : TextColor.gray)),
if (isProcessing.value) _Loading(),
],
),
Expand Down Expand Up @@ -381,13 +373,7 @@ class AlertButton extends HookWidget {
children: [
Text(
text,
style: TextStyle(
fontFamily: FontFamily.japanese,
fontWeight: FontWeight.w600,
fontSize: 14,
color: (isProcessing.value || onPressed == null)
? TextColor.gray
: TextColor.primary),
style: TextStyle(fontFamily: FontFamily.japanese, fontWeight: FontWeight.w600, fontSize: 14, color: (isProcessing.value || onPressed == null) ? TextColor.gray : TextColor.primary),
),
if (isProcessing.value) _Loading(),
],
Expand Down
3 changes: 1 addition & 2 deletions lib/components/atoms/color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ abstract class PilllColors {
static const Color duration = Color(0xFF6A7DA5);
static final Color overlay = secondary.withAlpha(20);

static final Color modalBackground =
const Color(0xFF333333).withAlpha((255 * 0.7).round());
static final Color modalBackground = const Color(0xFF333333).withAlpha((255 * 0.7).round());
static const Color white = Colors.white;

static Color get disabledSheet => PilllColors.pillSheet;
Expand Down
3 changes: 1 addition & 2 deletions lib/components/molecules/diagonal_striped_line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ class DiagonalStripedLine extends CustomPainter {
DiagonalStripedLine({required this.color, required this.isNecessaryBorder});
@override
void paint(Canvas canvas, Size size) {
canvas.drawRect(
Rect.fromLTWH(0, 0, size.width, size.height), Paint()..color = color);
canvas.drawRect(Rect.fromLTWH(0, 0, size.width, size.height), Paint()..color = color);
if (!isNecessaryBorder) {
return;
}
Expand Down
3 changes: 1 addition & 2 deletions lib/components/molecules/dots_page_indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class DotsIndicator extends AnimatedWidget {
}

Widget _buildDot(int index) {
final isSelected =
index == (controller.page ?? controller.initialPage).round();
final isSelected = index == (controller.page ?? controller.initialPage).round();
return SizedBox(
width: 25,
child: Center(
Expand Down
3 changes: 1 addition & 2 deletions lib/components/molecules/dotted_line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ class DottedLine extends StatelessWidget {
width: double.infinity,
height: 1,
child: LayoutBuilder(builder: (context, constraints) {
final dashAndDashGapCount = _calculateDashAndDashGapCount(
min(constraints.maxWidth, lineLength));
final dashAndDashGapCount = _calculateDashAndDashGapCount(min(constraints.maxWidth, lineLength));

return Wrap(
direction: Axis.horizontal,
Expand Down
3 changes: 1 addition & 2 deletions lib/components/molecules/indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class Indicator extends StatelessWidget {
);
}
return const Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation(PilllColors.secondary)),
child: CircularProgressIndicator(valueColor: AlwaysStoppedAnimation(PilllColors.secondary)),
);
}
}
Expand Down
13 changes: 2 additions & 11 deletions lib/components/molecules/select_circle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,8 @@ class SelectCircle extends StatelessWidget {
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")),
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")),
],
);
}
Expand Down
37 changes: 10 additions & 27 deletions lib/components/organisms/calendar/band/calendar_band_function.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import 'package:pilll/utils/datetime/day.dart';
// 予定されている生理日
// maxDateRangeCountは主にユニットテストの時に嬉しい引数になっているがプロダクションコードでもそのまま使用している
// ユースケースとして大体の未来のものを返せれば良いので厳密な計算結果が欲しいわけではないので動作確認とユニットテストをしやすい方式をとっている
List<DateRange> scheduledMenstruationDateRanges(PillSheetGroup? pillSheetGroup,
Setting? setting, List<Menstruation> menstruations,
[int maxDateRangeCount = 15]) {
List<DateRange> scheduledMenstruationDateRanges(PillSheetGroup? pillSheetGroup, Setting? setting, List<Menstruation> menstruations, [int maxDateRangeCount = 15]) {
if (pillSheetGroup == null || setting == null) {
return [];
}
Expand All @@ -25,31 +23,22 @@ List<DateRange> scheduledMenstruationDateRanges(PillSheetGroup? pillSheetGroup,
}
assert(maxDateRangeCount > 0);

final scheduledMenstruationDateRanges =
pillSheetGroup.menstruationDateRanges(setting: setting);
final scheduledMenstruationDateRanges = pillSheetGroup.menstruationDateRanges(setting: setting);
List<DateRange> dateRanges = scheduledMenstruationDateRanges;
final pillSheetGroupTotalPillCount = pillSheetGroup.pillSheetTypes
.fold(0, (p, e) => p + e.typeInfo.totalCount);
final pillSheetGroupTotalPillCount = pillSheetGroup.pillSheetTypes.fold(0, (p, e) => p + e.typeInfo.totalCount);
for (var i = 1; i <= maxDateRangeCount; i++) {
final offset = pillSheetGroupTotalPillCount * i;
final dateRangesWithOffset = scheduledMenstruationDateRanges
.map((e) => DateRange(e.begin.addDays(offset), e.end.addDays(offset)))
.toList();
final dateRangesWithOffset = scheduledMenstruationDateRanges.map((e) => DateRange(e.begin.addDays(offset), e.end.addDays(offset))).toList();
dateRanges = [...dateRanges, ...dateRangesWithOffset];
}

final menstruationDateRanges = menstruations.map((e) => e.dateRange);
// `今日より前の生理予定日` と `すでに記録済みの生理予定日` はこのタイミングで除外する。scheduledMenstruationDateRangesを作成するタイミングだと後続のoffsetを含めた処理に影響が出る。
// 例えば現在2シートめでこのwhere句でフィルタリングしてしまうと、1シート目とoffsetを考慮した生理予定日が表示されないようになる
dateRanges = dateRanges
.where((scheduledMenstruationRange) =>
!scheduledMenstruationRange.end.isBefore(today()))
.where((scheduledMenstruationRange) {
dateRanges = dateRanges.where((scheduledMenstruationRange) => !scheduledMenstruationRange.end.isBefore(today())).where((scheduledMenstruationRange) {
// すでに記録されている生理については除外したものを予定されている生理とする
return menstruationDateRanges
.where((menstruationDateRange) =>
menstruationDateRange.inRange(scheduledMenstruationRange.begin) ||
menstruationDateRange.inRange(scheduledMenstruationRange.end))
.where((menstruationDateRange) => menstruationDateRange.inRange(scheduledMenstruationRange.begin) || menstruationDateRange.inRange(scheduledMenstruationRange.end))
.isEmpty;
}).toList();

Expand All @@ -61,16 +50,13 @@ List<DateRange> scheduledMenstruationDateRanges(PillSheetGroup? pillSheetGroup,
}
}

List<DateRange> nextPillSheetDateRanges(PillSheetGroup pillSheetGroup,
[int maxDateRangeCount = 15]) {
List<DateRange> nextPillSheetDateRanges(PillSheetGroup pillSheetGroup, [int maxDateRangeCount = 15]) {
if (pillSheetGroup.pillSheets.isEmpty) {
return [];
}
assert(maxDateRangeCount > 0);

final totalPillCount = pillSheetGroup.pillSheets
.map((e) => e.pillSheetType.totalCount)
.reduce((value, element) => value + element);
final totalPillCount = pillSheetGroup.pillSheets.map((e) => e.pillSheetType.totalCount).reduce((value, element) => value + element);
var dateRanges = <DateRange>[];
for (int i = 0; i < maxDateRangeCount; i++) {
final offset = totalPillCount * i;
Expand All @@ -89,8 +75,7 @@ List<DateRange> nextPillSheetDateRanges(PillSheetGroup pillSheetGroup,
}
}

int bandLength(
DateRange range, CalendarBandModel bandModel, bool isLineBreaked) {
int bandLength(DateRange range, CalendarBandModel bandModel, bool isLineBreaked) {
return range
.union(
DateRange(
Expand All @@ -107,7 +92,5 @@ bool isNecessaryLineBreak(DateTime date, DateRange dateRange) {
}

int offsetForStartPositionAtLine(DateTime begin, DateRange dateRange) {
return isNecessaryLineBreak(begin, dateRange)
? 0
: daysBetween(dateRange.begin.date(), begin.date());
return isNecessaryLineBreak(begin, dateRange) ? 0 : daysBetween(dateRange.begin.date(), begin.date());
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class CalendarScheduledMenstruationBandModel extends CalendarBandModel {

class CalendarMenstruationBandModel extends CalendarBandModel {
final Menstruation menstruation;
CalendarMenstruationBandModel(this.menstruation)
: super(menstruation.beginDate, menstruation.endDate);
CalendarMenstruationBandModel(this.menstruation) : super(menstruation.beginDate, menstruation.endDate);
}

class CalendarNextPillSheetBandModel extends CalendarBandModel {
Expand Down
24 changes: 6 additions & 18 deletions lib/components/organisms/calendar/band/calendar_band_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import 'package:pilll/provider/pill_sheet_group.dart';
import 'package:pilll/provider/setting.dart';
import 'package:riverpod/riverpod.dart';

final calendarMenstruationBandListProvider =
Provider<AsyncValue<List<CalendarMenstruationBandModel>>>((ref) {
final calendarMenstruationBandListProvider = Provider<AsyncValue<List<CalendarMenstruationBandModel>>>((ref) {
final allMenstruations = ref.watch(allMenstruationProvider);

if (allMenstruations is AsyncLoading) {
Expand All @@ -16,17 +15,14 @@ final calendarMenstruationBandListProvider =

try {
return AsyncValue.data(
allMenstruations.value!
.map((menstruation) => CalendarMenstruationBandModel(menstruation))
.toList(),
allMenstruations.value!.map((menstruation) => CalendarMenstruationBandModel(menstruation)).toList(),
);
} catch (error, stackTrace) {
return AsyncValue.error(error, stackTrace);
}
});

final calendarScheduledMenstruationBandListProvider = Provider.autoDispose<
AsyncValue<List<CalendarScheduledMenstruationBandModel>>>((ref) {
final calendarScheduledMenstruationBandListProvider = Provider.autoDispose<AsyncValue<List<CalendarScheduledMenstruationBandModel>>>((ref) {
return AsyncValueGroup.group3(
ref.watch(latestPillSheetGroupProvider),
ref.watch(settingProvider),
Expand All @@ -36,16 +32,11 @@ final calendarScheduledMenstruationBandListProvider = Provider.autoDispose<
t.$1,
t.$2,
t.$3,
)
.map((dateRange) => CalendarScheduledMenstruationBandModel(
dateRange.begin, dateRange.end))
.toList(),
).map((dateRange) => CalendarScheduledMenstruationBandModel(dateRange.begin, dateRange.end)).toList(),
);
});

final calendarNextPillSheetBandListProvider =
Provider.autoDispose<AsyncValue<List<CalendarNextPillSheetBandModel>>>(
(ref) {
final calendarNextPillSheetBandListProvider = Provider.autoDispose<AsyncValue<List<CalendarNextPillSheetBandModel>>>((ref) {
final pillSheetGroup = ref.watch(latestPillSheetGroupProvider);

if (pillSheetGroup is AsyncLoading) {
Expand All @@ -59,10 +50,7 @@ final calendarNextPillSheetBandListProvider =

try {
return AsyncValue.data(
nextPillSheetDateRanges(pillSheetGroupValue, 15)
.map((dateRange) =>
CalendarNextPillSheetBandModel(dateRange.begin, dateRange.end))
.toList(),
nextPillSheetDateRanges(pillSheetGroupValue, 15).map((dateRange) => CalendarNextPillSheetBandModel(dateRange.begin, dateRange.end)).toList(),
);
} catch (error, stackTrace) {
return AsyncValue.error(error, stackTrace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ class CalendarNextPillSheetBand extends StatelessWidget {
child: Stack(
children: [
CustomPaint(
painter: DiagonalStripedLine(
color: PilllColors.duration, isNecessaryBorder: false),
painter: DiagonalStripedLine(color: PilllColors.duration, isNecessaryBorder: false),
size: Size(width, CalendarBandConst.height),
),
Container(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@ class CalendarDayRecord extends StatelessWidget {
SvgPicture.asset(
"images/laugh.svg",
height: 10,
colorFilter:
const ColorFilter.mode(PilllColors.green, BlendMode.srcIn),
colorFilter: const ColorFilter.mode(PilllColors.green, BlendMode.srcIn),
),
);
case PhysicalConditionStatus.bad:
widgets.add(
SvgPicture.asset(
"images/angry.svg",
height: 10,
colorFilter:
const ColorFilter.mode(PilllColors.danger, BlendMode.srcIn),
colorFilter: const ColorFilter.mode(PilllColors.danger, BlendMode.srcIn),
),
);
}
Expand Down
Loading

0 comments on commit a1357a0

Please sign in to comment.