Skip to content

Commit

Permalink
chore: updated the painter to have the same UI for each screen size.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhalakupadhyay committed Nov 14, 2024
1 parent 29ae019 commit d542904
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/virtualbadge/view/draw_badge_paint.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:math' as math;

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class DrawBadgePaint extends CustomPainter {
final List<List<bool>> grid;
Expand All @@ -12,6 +13,10 @@ class DrawBadgePaint extends CustomPainter {
double cellWidth = size.width / grid[0].length;
double cellHeight = size.height / grid.length;

double pathOffsetX1 = 0.15.w;
double pathOffsetX2 = 0.3.w;
double pathOffsetX3 = 0.15.w;

for (int row = 0; row < grid.length; row++) {
for (int col = 0; col < grid[row].length; col++) {
final Paint paint = Paint()
Expand All @@ -20,14 +25,14 @@ class DrawBadgePaint extends CustomPainter {

final Path path = Path()
..moveTo(col * cellWidth, row * cellHeight)
..lineTo(col * cellWidth + cellWidth * 0.4, row * cellHeight)
..lineTo(col * cellWidth + cellWidth * 0.655,
..lineTo(col * cellWidth + cellWidth * pathOffsetX1, row * cellHeight)
..lineTo(col * cellWidth + cellWidth * pathOffsetX2,
row * cellHeight + cellHeight)
..lineTo(col * cellWidth + cellWidth * pathOffsetX3,
row * cellHeight + cellHeight)
..lineTo(
col * cellWidth + cellWidth * 0.25, row * cellHeight + cellHeight)
..close();

const double radians = math.pi / 4;
const double radians = math.pi / 3;
canvas.save();
canvas.translate((col + 0.5) * cellWidth, (row + 0.5) * cellHeight);
canvas.rotate(radians);
Expand Down

0 comments on commit d542904

Please sign in to comment.