Skip to content

Commit 9bce97c

Browse files
committed
fix: resolve text clipping and animation lookup issue #1796
1 parent c0041d6 commit 9bce97c

3 files changed

Lines changed: 12 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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,11 @@ class AnimationBadgeProvider extends ChangeNotifier {
218218
int? getAnimationIndex() {
219219
for (var animation in animationMap.entries) {
220220
if (animation.value != null && animation.value == _currentAnimation) {
221+
logger.i("Animation Index: ${animation.key}");
221222
return animation.key;
222223
}
223224
}
224-
return 0;
225+
return null;
225226
}
226227

227228
bool isAnimationActive(BadgeAnimation? badgeAnimation) {
@@ -233,7 +234,8 @@ class AnimationBadgeProvider extends ChangeNotifier {
233234
String message, Converters converters, bool isInverted) async {
234235
bool isSpecial = isSpecialAnimationSelected();
235236
if (message.isEmpty && !isSpecial) {
236-
stopAllAnimations();
237+
_timer?.cancel();
238+
_animationIndex = 0;
237239
List<List<bool>> emptyGrid =
238240
List.generate(11, (i) => List.generate(44, (j) => false));
239241
_newGrid = emptyGrid;

0 commit comments

Comments
 (0)