Skip to content

Commit e9f1bd5

Browse files
committed
fix: resolve text clipping and animation lookup issue #1796
1 parent c0faebd commit e9f1bd5

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

lib/badge_animation/ani_fixed.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import 'dart:math';
12
import 'package:badgemagic/badge_animation/animation_abstract.dart';
23

34
class FixedAnimation extends BadgeAnimation {
45
@override
56
void processAnimation(int badgeHeight, int badgeWidth, int animationIndex,
67
List<List<bool>> processGrid, List<List<bool>> canvas) {
78
int newWidth = processGrid[0].length;
8-
int horizontalOffset = (badgeWidth - newWidth) ~/ 2;
9+
int horizontalOffset = max(0, (badgeWidth - newWidth) ~/ 2);
910

1011
for (int i = 0; i < badgeHeight; i++) {
1112
for (int j = 0; j < badgeWidth; j++) {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
abstract class BadgeAnimation {
22
void processAnimation(int badgeHeight, int badgeWidth, int animationIndex,
33
List<List<bool>> processGrid, List<List<bool>> canvas);
4+
5+
@override
6+
bool operator ==(Object other) => runtimeType == other.runtimeType;
7+
8+
@override
9+
int get hashCode => runtimeType.hashCode;
410
}

lib/providers/animation_badge_provider.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class AnimationBadgeProvider extends ChangeNotifier {
222222
return animation.key;
223223
}
224224
}
225-
return 0;
225+
return null;
226226
}
227227

228228
bool isAnimationActive(BadgeAnimation? badgeAnimation) {
@@ -234,7 +234,8 @@ class AnimationBadgeProvider extends ChangeNotifier {
234234
String message, Converters converters, bool isInverted) async {
235235
bool isSpecial = isSpecialAnimationSelected();
236236
if (message.isEmpty && !isSpecial) {
237-
stopAllAnimations();
237+
_timer?.cancel();
238+
_animationIndex = 0;
238239
List<List<bool>> emptyGrid =
239240
List.generate(11, (i) => List.generate(44, (j) => false));
240241
_newGrid = emptyGrid;

0 commit comments

Comments
 (0)