SafeAreaView: Custom description method extended with inset values

Summary:
That should help with debugging SafeAreaView-related issues (esp. to see the info inside view hierarchy recursive description).

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D19539216

fbshipit-source-id: 1bee481c2766ad2d130e435582876d9f5ed27b3c
This commit is contained in:
Valentin Shergin
2020-01-23 12:53:49 -08:00
committed by Facebook Github Bot
parent 2db0c75cd4
commit f92b161eb3
@@ -30,6 +30,21 @@
RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)decoder)
RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
- (NSString *)description
{
NSString *superDescription = [super description];
// Cutting the last `>` character.
if (superDescription.length > 0 && [superDescription characterAtIndex:superDescription.length - 1] == '>') {
superDescription = [superDescription substringToIndex:superDescription.length - 1];
}
return [NSString stringWithFormat:@"%@; safeAreaInsets = %@; appliedSafeAreaInsets = %@>",
superDescription,
NSStringFromUIEdgeInsets([self safeAreaInsetsIfSupportedAndEnabled]),
NSStringFromUIEdgeInsets(_currentSafeAreaInsets)];
}
- (BOOL)isSupportedByOS
{
return [self respondsToSelector:@selector(safeAreaInsets)];