drawTopAndTextPhase method

void drawTopAndTextPhase(
  1. Canvas canvas,
  2. Rect rect,
  3. Offset center,
  4. double radius,
  5. int startDay,
  6. int endDay,
  7. Color topColor,
  8. Color bgColor,
  9. String label,
  10. Color textColor,
)

Draw top view and inside background

Implementation

void drawTopAndTextPhase(
    Canvas canvas,
    Rect rect,
    Offset center,
    double radius,
    int startDay,
    int endDay,
    Color topColor,
    Color bgColor,
    String label,
    Color textColor) {
  final startAngle = (2 * pi / totalCycleDays) * startDay - pi / 2;
  final sweepAngle = (2 * pi / totalCycleDays) * (endDay - startDay);

  ///Draw top view
  if (theme == MenstrualCycleTheme.arcs) {
    final paint = Paint()
      ..color = topColor
      ..style = PaintingStyle.stroke
      ..strokeWidth = arcStrokeWidth; // Manage Height of Outer circle
    canvas.drawArc(
      Rect.fromCircle(center: center, radius: radius),
      startAngle,
      sweepAngle,
      false,
      paint,
    );
  }

  if (!isRemoveBackgroundPhaseColor) {
    /// Draw background color based on phase
    final paint1 = Paint()
      ..color = bgColor
      ..style = PaintingStyle.fill;
    canvas.drawArc(rect, startAngle, sweepAngle, true, paint1);
  }

  /// set text inside circle
  if (phaseTextBoundaries != PhaseTextBoundaries.none) {
    if (phaseTextBoundaries == PhaseTextBoundaries.both ||
        phaseTextBoundaries == PhaseTextBoundaries.inside) {
      drawPhaseTextInside(
          canvas, center, radius, startDay, endDay, textColor, label);
    }
  }
}