mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-08 21:49:41 +00:00
* Initial ASLayoutSpecPlayground commit * Initial exploratory stab at the main challenge of the app - visualizing ASLayoutSpecs * Halfway through moving debug features out of ASDK framework files and into debug files. Project builds. * [ASLayoutSpecPlayground] Created new Inspector node, cleaning up internal implementation to start formalizing support for layout spec visualization. * Workaround for ensuring creation of visualizerNode for ALL layoutspecs * continued development * Layout Inspector Work in Progress * Resizing the playground works in the shrink direction, not for grow. * added new ASLayoutableInspectorNode features * Cleaned up examples code. * Cleaning up code. * more code cleanup * [ASLayoutableInspector] Transition to an ASTableNode-based architecture to support larger numbers of buttons / customizable types. * [ASLayoutableInspector] Support different layoutable property types to set up buttons that can edit all of them. * Huy debugging * Refactored layout inspector code for extensibility. * Properly lock layoutableContextMap * Fix context handling in ASDisplayNode:measureWithSizeRange * Fix ASLayoutSpecPlayground:ViewController:toggleVisualization * added slider to InspectorCell * [ASLayoutSpecPlayground] Improvements to propagation of visualize mode, resize handle, minor cleanup. * Fix to ASEnvironment * [ASLayoutSpecPlayground] Fix a few minor issues from the merge with latest master. * Implement layout spec cache * add pager ndoe * add more examples * add more layout examples * [ASLayoutPlayground] Fix merge issues * [ASLayoutPlayground] Fix up the example project from the 2.0 API changes. * [ASLayoutPlayground] Some fixes (#2411) * [ASLayoutPlayground]: Some fixes * Fixed crash when tapping descender. * Fixed setting the item to inspect. * Fixed button states in inspector node. * Added sliders for spacingBefore, spacingAfter, ascender. * [ASLayoutSpecPlayground] Deselect the buttons when editing is over. * [ASLayoutSpecPlayground] Changed flexGrow/Shrink's values from YES/NO to 1.0/0.0 * [Project] Create new Debug/ directory for advanced tools dedicated to debugging. * [LayoutSpecPlayground] Rename project without AS in title, to be consistent with LayoutSpecExamples. * [Bulid] Fix Xcode project to use new Debug subdirectory / group. * [Bulid] Fix a small merge error. * [Build] Fix build issue for Framework target. * [Bulid] Fix podspec to expose InspectorNode header; Remove old-cocoapods emojis from ASDKgram :) * Move aside ASLayoutSpecPlayground-Swift to match master * [LayoutSpecPlayground] Cleanup implementation in several files, xcodeproj, etc. * [ASControlNode] Add comment for new assertion, to be enabled in a separate diff.
74 lines
2.4 KiB
Objective-C
74 lines
2.4 KiB
Objective-C
//
|
|
// ASLayoutSpec+Debug.m
|
|
// AsyncDisplayKit
|
|
//
|
|
// Created by Hannah Troisi on 3/20/16.
|
|
//
|
|
//
|
|
|
|
#import "ASLayoutSpec+Debug.h"
|
|
#import "ASDisplayNode+Beta.h"
|
|
#import "AsyncDisplayKit.h"
|
|
#import "ASLayoutElementInspectorNode.h"
|
|
|
|
@implementation ASLayoutSpecVisualizerNode
|
|
|
|
- (instancetype)initWithLayoutSpec:(ASLayoutSpec *)layoutSpec
|
|
{
|
|
self = [super init];
|
|
if (self) {
|
|
self.borderWidth = 2;
|
|
self.borderColor = [[UIColor redColor] CGColor];
|
|
self.layoutSpec = layoutSpec;
|
|
self.layoutSpec.neverShouldVisualize = YES;
|
|
self.automaticallyManagesSubnodes = YES;
|
|
self.shouldCacheLayoutSpec = YES;
|
|
[self addTarget:self action:@selector(visualizerNodeTapped:) forControlEvents:ASControlNodeEventTouchUpInside];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
|
{
|
|
CGFloat insetFloat = [ASLayoutElementInspectorNode sharedInstance].vizNodeInsetSize;
|
|
UIEdgeInsets insets = UIEdgeInsetsMake(insetFloat, insetFloat, insetFloat, insetFloat);
|
|
|
|
// FIXME in framework: auto pass properties to children
|
|
ASInsetLayoutSpec *insetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:self.layoutSpec];
|
|
insetSpec.neverShouldVisualize = YES;
|
|
|
|
// propogate child's layoutSpec properties to the inset that we are adding
|
|
// insetSpec.style.flexGrow = _layoutSpec.style.flexGrow;
|
|
// insetSpec.style.flexShrink = _layoutSpec.style.flexShrink;
|
|
// insetSpec.alignSelf = _layoutSpec.alignSelf;
|
|
|
|
// NSLog(@"%@: vizNode = %f, child = %f", self, insetSpec.style.flexGrow, _layoutSpec.style.flexGrow);
|
|
|
|
return insetSpec;
|
|
}
|
|
|
|
- (void)setLayoutSpec:(ASLayoutSpec *)layoutSpec // FIXME: this is duplicated in InspectorNode - make it a category on ASLayoutSpec?
|
|
{
|
|
_layoutSpec = layoutSpec; // FIXME: should copy layoutSpec properities to self?
|
|
|
|
if ([layoutSpec isKindOfClass:[ASInsetLayoutSpec class]]) {
|
|
self.borderColor = [[UIColor redColor] CGColor];
|
|
|
|
} else if ([layoutSpec isKindOfClass:[ASStackLayoutSpec class]]) {
|
|
self.borderColor = [[UIColor greenColor] CGColor];
|
|
}
|
|
}
|
|
|
|
- (NSString *)description
|
|
{
|
|
return [self.layoutSpec description]; // FIXME: expand on layoutSpec description (e.g. have StackLayoutSpec return horz/vert)
|
|
}
|
|
|
|
- (void)visualizerNodeTapped:(UIGestureRecognizer *)sender
|
|
{
|
|
[[ASLayoutElementInspectorNode sharedInstance] setLayoutElementToEdit:self.layoutSpec];
|
|
}
|
|
|
|
@end
|
|
|