Skip to content

Commit

Permalink
refactor(heat_map_day): extract containerBorder and reduce complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
albertms10 committed Dec 24, 2021
1 parent 428b94b commit 6251774
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/widgets/standalone/heat_map_calendar/heat_map_day.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ class HeatMapDay extends StatelessWidget {
return color;
}

BoxBorder? get containerBorder {
if (date == null) return null;

if (highlightToday && isOnSameDay(date!, DateTime.now())) {
return Border.all(color: Colors.orange, width: 2.0);
}

if (highlightOn?.call(date!) ?? false) {
return Border.all(color: Colors.orange[200]!, width: 2.0);
}
}

@override
Widget build(BuildContext context) {
final container = Padding(
Expand All @@ -58,13 +70,7 @@ class HeatMapDay extends StatelessWidget {
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(2.0)),
color: getColorFromThreshold(),
border: date != null
? (highlightToday && isOnSameDay(date!, DateTime.now())
? Border.all(color: Colors.orange, width: 2.0)
: highlightOn?.call(date!) ?? false
? Border.all(color: Colors.orange[200]!, width: 2.0)
: null)
: null,
border: containerBorder,
),
),
),
Expand Down

0 comments on commit 6251774

Please sign in to comment.