Skip to content

Commit e334dbe

Browse files
feat: Add multiple badge Sizes
fix: multiple calls for initstate fix: text fitting to height fix: text according to badge size fix: routing error of draw badge fix: emoji rendering issue fix: emoji and text renders correctly on any badge size fix: optimize Converters class for readability and maintainability fix: conflicts fix: removed unnecessary comments fix: conflicts in homescreen fix: build fails fix: update expected hex output for scaled characters in converters_test
1 parent e6430aa commit e334dbe

26 files changed

+1096
-585
lines changed

.github/workflows/pull_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: Badge Magic PR CI
33
on:
44
pull_request:
55
branches: [ "development" ]
6-
branches: [ "flutter_app" ]
76

87
env:
98
ANDROID_EMULATOR_API: 34
@@ -84,3 +83,4 @@ jobs:
8483
with:
8584
IPHONE_DEVICE_MODEL: ${{ env.IPHONE_DEVICE_MODEL }}
8685
IPAD_DEVICE_MODEL: ${{ env.IPAD_DEVICE_MODEL }}
86+

.github/workflows/push.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: Badge Magic Push CI
33
on:
44
push:
55
branches: ["development"]
6-
branches: ["flutter_app"]
76

87
env:
98
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -113,14 +112,14 @@ jobs:
113112
name: AAB Generated
114113
path: build/app/outputs/bundle
115114

116-
- name: Upload APK/AAB to apk branch
115+
- name: Upload APK/AAB to app branch
117116
if: ${{ github.repository == 'fossasia/badgemagic-app' }}
118117
run: |
119118
git config --global user.name "github-actions[bot]"
120119
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
121120
122-
git clone --branch=apk https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} apk
123-
cd apk
121+
git clone --branch=app https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} app
122+
cd app
124123
125124
branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
126125
@@ -145,14 +144,14 @@ jobs:
145144
146145
ls
147146
148-
echo "Pushing to apk branch"
147+
echo "Pushing to app branch"
149148
150149
git checkout --orphan temporary
151150
git add --all .
152151
git commit -am "[Auto] Update APK/AAB's from $branch ($(date +%Y-%m-%d.%H:%M:%S))"
153-
git branch -D apk
154-
git branch -m apk
155-
git push --force origin apk
152+
git branch -D app
153+
git branch -m app
154+
git push --force origin app
156155
157156
- name: Push app in open testing track
158157
if: ${{ github.repository == 'fossasia/badgemagic-app' }}
@@ -231,8 +230,8 @@ jobs:
231230
- name: Create and Upload Assets
232231
run: |
233232
echo "${{ needs.common.outputs.VERSION_CODE }}" > ./versionCode.txt
234-
git clone --branch=apk https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} apk
235-
gh release upload ${{ steps.run-release-drafter.outputs.tag_name }} apk/badge-magic-flutter_app-release.apk ./versionCode.txt --clobber
233+
git clone --branch=app https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} app
234+
gh release upload ${{ steps.run-release-drafter.outputs.tag_name }} app/badge-magic-development-release.apk ./versionCode.txt --clobber
236235
237236
screenshots-android:
238237
name: Screenshots (Android)
@@ -256,4 +255,4 @@ jobs:
256255
uses: ./.github/actions/screenshot-ios
257256
with:
258257
IPHONE_DEVICE_MODEL: ${{ env.IPHONE_DEVICE_MODEL }}
259-
IPAD_DEVICE_MODEL: ${{ env.IPAD_DEVICE_MODEL }}
258+
IPAD_DEVICE_MODEL: ${{ env.IPAD_DEVICE_MODEL }}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class ScreenSize {
2+
final int width;
3+
final int height;
4+
final String name;
5+
6+
const ScreenSize(
7+
{required this.width, required this.height, required this.name});
8+
9+
@override
10+
bool operator ==(Object other) =>
11+
identical(this, other) ||
12+
other is ScreenSize &&
13+
runtimeType == other.runtimeType &&
14+
width == other.width &&
15+
height == other.height &&
16+
name == other.name;
17+
18+
@override
19+
int get hashCode => width.hashCode ^ height.hashCode ^ name.hashCode;
20+
}
21+
22+
const List<ScreenSize> supportedScreenSizes = [
23+
ScreenSize(width: 44, height: 11, name: "Small (44x11)"),
24+
ScreenSize(width: 64, height: 16, name: "Medium (64x16)"),
25+
ScreenSize(width: 128, height: 32, name: "Large (128x32)"),
26+
];

lib/bademagic_module/utils/byte_array_utils.dart

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ List<int> hexStringToByteArray(String hexString) {
2929
return data;
3030
}
3131

32-
List<List<bool>> hexStringToBool(String hexString) {
33-
int rows = 11;
32+
List<List<bool>> hexStringToBool(String hexString, int rows) {
3433
if (hexString.length % 2 != 0 || !isValidHex(hexString)) {
3534
throw ArgumentError("Invalid hex string: $hexString");
3635
}
@@ -39,23 +38,18 @@ List<List<bool>> hexStringToBool(String hexString) {
3938
int rowIndex = 0;
4039

4140
for (int i = 0; i < hexString.length; i += 2) {
42-
// Convert the hex string into a byte (int)
4341
int byte = int.parse(hexString.substring(i, i + 2), radix: 16);
44-
45-
// Convert the byte into a binary representation and then into booleans
4642
for (int bit = 7; bit >= 0; bit--) {
4743
boolArray[rowIndex].add(((byte >> bit) & 1) == 1);
4844
}
49-
50-
// Move to the next row after filling current one
5145
rowIndex = (rowIndex + 1) % rows;
5246
}
5347

5448
return boolArray;
5549
}
5650

57-
List<List<int>> byteArrayToBinaryArray(List<int> byteArray) {
58-
List<List<int>> binaryArray = List.generate(11, (_) => []);
51+
List<List<int>> byteArrayToBinaryArray(List<int> byteArray, int rows) {
52+
List<List<int>> binaryArray = List.generate(rows, (_) => []);
5953

6054
int rowIndex = 0;
6155
for (int byte in byteArray) {
@@ -66,32 +60,27 @@ List<List<int>> byteArrayToBinaryArray(List<int> byteArray) {
6660

6761
binaryArray[rowIndex].addAll(binaryRepresentation);
6862

69-
rowIndex = (rowIndex + 1) % 11;
63+
rowIndex = (rowIndex + 1) % rows;
7064
}
7165

72-
logger.d(
73-
"binaryArray: $binaryArray"); // Use print instead of logger for standalone example
66+
logger.d("binaryArray: $binaryArray");
7467
return binaryArray;
7568
}
7669

7770
String hexToBin(String hex) {
78-
// Convert hex to binary string
7971
String binaryString = BigInt.parse(hex, radix: 16).toRadixString(2);
80-
81-
// Pad the binary string with leading zeros if necessary to ensure it's a multiple of 8 bits
8272
int paddingLength = (8 - (binaryString.length % 8)) % 8;
8373
binaryString = binaryString.padLeft(binaryString.length + paddingLength, '0');
8474
logger.d("binaryString: $binaryString");
8575
return binaryString;
8676
}
8777

88-
List<List<int>> binaryStringTo2DList(String binaryString) {
89-
int maxHeight = 11;
78+
List<List<int>> binaryStringTo2DList(String binaryString, int maxHeight) {
9079
List<List<int>> binary2DList = List.generate(maxHeight, (_) => []);
9180

9281
for (int x = 0; x < binaryString.length; x++) {
9382
int a = 0;
94-
for (int y = a; y < 11; y++) {
83+
for (int y = a; y < maxHeight; y++) {
9584
for (int z = 0; z < 8; z++) {
9685
binary2DList[y].add(int.parse(binaryString[x++]));
9786
if (x >= binaryString.length) {
@@ -102,6 +91,9 @@ List<List<int>> binaryStringTo2DList(String binaryString) {
10291
break;
10392
}
10493
}
94+
if (x >= binaryString.length) {
95+
break;
96+
}
10597
}
10698
logger.d("binary2DList: $binary2DList");
10799
return binary2DList;

0 commit comments

Comments
 (0)