mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-30 01:11:46 +00:00
Added logging for keypaths
This commit is contained in:
parent
bebfce57b9
commit
8be9ea150c
15
README.md
15
README.md
@ -7,6 +7,7 @@
|
||||
- [MacOS Sample App](#macos-sample-app)
|
||||
- [Objective C Examples](#objective-c-examples)
|
||||
- [Swift Examples](#swift-examples)
|
||||
- [Debugging Lottie](#debugging)
|
||||
- [iOS View Controller Transitioning](#ios-view-controller-transitioning)
|
||||
- [Changing Animations At Runtime](#changing-animations-at-runtime)
|
||||
- [Supported After Effects Features](#supported-after-effects-features)
|
||||
@ -208,6 +209,19 @@ return animationController;
|
||||
|
||||
```
|
||||
|
||||
## Debugging
|
||||
Lottie has a couple of debugging features to know about.
|
||||
When an animation is loaded unsupported features are logged out in the console with their function names.
|
||||
|
||||
If you checkout LOTHelpers.h you will see two debug flags. `ENABLE_DEBUG_LOGGING` and `ENABLE_DEBUG_SHAPES`.
|
||||
`ENABLE_DEBUG_LOGGING` increases the verbosity of Lottie Logging. It logs anytime an animation node is set during animation. If your animation if not working, turn this on and play your animation. The console log might give you some clues as to whats going on.
|
||||
|
||||
`ENABLE_DEBUG_SHAPES` Draws a colored square for the anchor-point of every layer and shape. This is helpful to see if anything is on screen.
|
||||
|
||||
### Keypaths
|
||||
|
||||
LOTAnimationView provides `- (void)logHierarchyKeypaths` which will recursively log all settable keypaths for the animation. This is helpful for changing animationations at runtime.
|
||||
|
||||
## Changing Animations At Runtime
|
||||
|
||||
Lottie can do more than just play beautiful animations. Lottie allows you to **change** animations at runtime.
|
||||
@ -257,6 +271,7 @@ animationView3.setValue(UIColor.red, forKeypath: "BG-On.Group 1.Fill 1.Color", a
|
||||
animationView4.setValue(UIColor.orange, forKeypath: "BG-On.Group 1.Fill 1.Color", atFrame: 0)
|
||||
```
|
||||
The keyPath is a dot separated path of layer and property names from After Effects.
|
||||
LOTAnimationView provides `- (void)logHierarchyKeypaths` which will recursively log all settable keypaths for the animation.
|
||||

|
||||
"BG-On.Group 1.Fill 1.Color"
|
||||
|
||||
|
@ -144,4 +144,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)logHierarchyKeypathsWithParent:(NSString * _Nullable)parent {
|
||||
NSString *keypath = parent;
|
||||
if (parent && self.layerName) {
|
||||
keypath = [NSString stringWithFormat:@"%@.%@", parent, self.layerName];
|
||||
}
|
||||
for (LOTLayerContainer *layer in _childLayers) {
|
||||
[layer logHierarchyKeypathsWithParent:keypath];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -27,4 +27,7 @@
|
||||
- (BOOL)setValue:(nonnull id)value
|
||||
forKeypath:(nonnull NSString *)keypath
|
||||
atFrame:(nullable NSNumber *)frame;
|
||||
|
||||
- (void)logHierarchyKeypathsWithParent:(NSString * _Nullable)parent;
|
||||
|
||||
@end
|
||||
|
@ -260,4 +260,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)logHierarchyKeypathsWithParent:(NSString * _Nullable)parent {
|
||||
[_contentsGroup logHierarchyKeypathsWithParent:parent
|
||||
];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -13,7 +13,6 @@
|
||||
#import "CGGeometry+LOTAdditions.h"
|
||||
#import "LOTBezierPath.h"
|
||||
|
||||
#define DEBUG_USE_NEW_RENDERER YES
|
||||
#define ENABLE_DEBUG_LOGGING NO
|
||||
#define ENABLE_DEBUG_SHAPES NO
|
||||
|
||||
|
@ -155,6 +155,9 @@
|
||||
[self.layer addSublayer:_compContainer];
|
||||
_compContainer.currentFrame = @0;
|
||||
[CATransaction commit];
|
||||
if (ENABLE_DEBUG_LOGGING) {
|
||||
[self logHierarchyKeypaths];
|
||||
}
|
||||
}
|
||||
|
||||
# pragma mark - External Methods
|
||||
@ -487,4 +490,8 @@
|
||||
[self _callCompletionIfNecessary:complete];
|
||||
}
|
||||
|
||||
- (void)logHierarchyKeypaths {
|
||||
[_compContainer logHierarchyKeypathsWithParent:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -138,6 +138,9 @@ typedef void (^LOTAnimationCompletionBlock)(BOOL animationFinished);
|
||||
forKeypath:(nonnull NSString *)keypath
|
||||
atFrame:(nullable NSNumber *)frame;
|
||||
|
||||
/// Logs all child keypaths
|
||||
- (void)logHierarchyKeypaths;
|
||||
|
||||
/**
|
||||
* Adds a custom subview to the animation using a LayerName from After Effects
|
||||
* as a reference point.
|
||||
|
@ -63,4 +63,6 @@ extern NSInteger indentation_level;
|
||||
|
||||
- (void)logString:(NSString *_Nonnull)string;
|
||||
|
||||
- (void)logHierarchyKeypathsWithParent:(NSString * _Nullable)parent;
|
||||
|
||||
@end
|
||||
|
@ -42,10 +42,10 @@ NSInteger indentation_level = 0;
|
||||
return NO;
|
||||
}
|
||||
NSString *name = NSStringFromClass([self class]);
|
||||
if (ENABLE_DEBUG_LOGGING) [self logString:[NSString stringWithFormat:@"%@ %lu Checking for update", name, (unsigned long)self.hash]];
|
||||
if (ENABLE_DEBUG_LOGGING) [self logString:[NSString stringWithFormat:@"%@ %lu %@ Checking for update", name, (unsigned long)self.hash, self.keyname]];
|
||||
BOOL localUpdate = [self needsUpdateForFrame:frame] || forceUpdate;
|
||||
if (localUpdate && ENABLE_DEBUG_LOGGING) {
|
||||
[self logString:[NSString stringWithFormat:@"%@ %lu Performing update", name, (unsigned long)self.hash]];
|
||||
[self logString:[NSString stringWithFormat:@"%@ %lu %@ Performing update", name, (unsigned long)self.hash, self.keyname]];
|
||||
}
|
||||
BOOL inputUpdated = [_inputNode updateWithFrame:frame
|
||||
withModifierBlock:modifier
|
||||
@ -105,7 +105,7 @@ NSInteger indentation_level = 0;
|
||||
forFrame:(nullable NSNumber *)frame {
|
||||
NSArray *components = [keypath componentsSeparatedByString:@"."];
|
||||
NSString *firstKey = components.firstObject;
|
||||
if ([firstKey isEqualToString:self.keyname]) {
|
||||
if ([firstKey isEqualToString:self.keyname] && components.count > 1) {
|
||||
NSString *nextPath = [keypath stringByReplacingCharactersInRange:NSMakeRange(0, firstKey.length + 1) withString:@""];
|
||||
return [self setInterpolatorValue:value forKey:nextPath forFrame:frame];
|
||||
}
|
||||
@ -123,4 +123,18 @@ NSInteger indentation_level = 0;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)logHierarchyKeypathsWithParent:(NSString *)parent {
|
||||
NSString *keypath = self.keyname;
|
||||
if (parent && self.keyname) {
|
||||
keypath = [NSString stringWithFormat:@"%@.%@", parent, self.keyname];
|
||||
}
|
||||
if (keypath) {
|
||||
for (NSString *interpolator in self.valueInterpolators.allKeys) {
|
||||
[self logString:[NSString stringWithFormat:@"%@.%@", keypath, interpolator]];
|
||||
}
|
||||
}
|
||||
|
||||
[self.inputNode logHierarchyKeypathsWithParent:parent];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -186,4 +186,19 @@
|
||||
return [_rootNode setValue:value forKeyAtPath:key forFrame:frame];
|
||||
}
|
||||
|
||||
- (void)logHierarchyKeypathsWithParent:(NSString * _Nullable)parent {
|
||||
NSString *keypath = self.keyname;
|
||||
if (parent && self.keyname) {
|
||||
keypath = [NSString stringWithFormat:@"%@.%@", parent, self.keyname];
|
||||
}
|
||||
if (keypath) {
|
||||
for (NSString *interpolator in self.valueInterpolators.allKeys) {
|
||||
[self logString:[NSString stringWithFormat:@"%@.%@", keypath, interpolator]];
|
||||
}
|
||||
[_rootNode logHierarchyKeypathsWithParent:keypath];
|
||||
}
|
||||
|
||||
[self.inputNode logHierarchyKeypathsWithParent:parent];
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
x
Reference in New Issue
Block a user