-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added the Aspect ratio in the badge UI and updated the custom p…
…ainter for the badge UI. (#1147)
- Loading branch information
1 parent
60773d7
commit 777ef9f
Showing
8 changed files
with
579 additions
and
426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class BadgeUtils { | ||
MapEntry<double, double> getBadgeOffsetBackground(Size size) { | ||
var paddingPercentage = 5.0; | ||
var offsetHeightBadgeBackground = (paddingPercentage / 100) * size.height; | ||
var offsetWidthBadgeBackground = (paddingPercentage / 100) * size.width; | ||
return MapEntry(offsetHeightBadgeBackground, offsetWidthBadgeBackground); | ||
} | ||
|
||
MapEntry<double, double> getBadgeSize(double offsetHeightBadgeBackground, | ||
double offsetWidthBadgeBackground, Size size) { | ||
var badgeHeight = size.height - (2 * offsetHeightBadgeBackground); | ||
var badgeWidth = size.width - (2 * offsetWidthBadgeBackground); | ||
return MapEntry(badgeHeight, badgeWidth); | ||
} | ||
|
||
MapEntry<double, double> getCellStartCoordinate( | ||
double offsetWidthBadgeBackground, | ||
double offsetHeightBadgeBackground, | ||
double badgeWidth, | ||
double badgeHeight) { | ||
{ | ||
var cellSize = badgeWidth / 44; | ||
|
||
// Calculate offsets to center the cells within the rectangle | ||
double totalCellsWidth = (cellSize * 0.92) * 44; | ||
double totalCellsHeight = cellSize * 11; | ||
|
||
var cellStartX = | ||
offsetWidthBadgeBackground + (badgeWidth - totalCellsWidth) / 2; | ||
var cellStartY = | ||
offsetHeightBadgeBackground + (badgeHeight - totalCellsHeight) / 2; | ||
|
||
return MapEntry(cellStartX, cellStartY); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.