Skip to content

Commit

Permalink
Merge pull request #8 from willowtreeapps/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
chrsmys authored Dec 4, 2017
2 parents d963d97 + 220e6b5 commit bb59e83
Show file tree
Hide file tree
Showing 69 changed files with 1,025 additions and 219 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ -(instancetype)initWithPreviewTargetView:(UIView *)view

self.accessibilityTextLabel.text = view.accessibilityLabel ? view.accessibilityLabel : @"--";

self.frameLabel.text = [NSString stringWithFormat:@"X: %.1f Y: %.1f Width: %.1f Height: %.1f", self.frame.origin.x, self.frame.origin.y, self.frame.size.width, self.frame.size.height];
self.frameLabel.text = [NSString stringWithFormat:@"X: %.1f Y: %.1f Width: %.1f Height: %.1f", view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height];

return self;
}
Expand Down
32 changes: 23 additions & 9 deletions AttributesInspector/HYPAttributeInspectorInteractionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,40 @@ -(void)tapGesture:(UITapGestureRecognizer *)tapGesture

-(void)viewSelected:(UIView *)selection
{
if (self.lastSelectedView == selection)
if (self.currentlySelectedView == selection)
{
[self.extension.snapshotContainer dismissCurrentPopover];
self.lastSelectedView = nil;
self.currentlySelectedView = nil;

return;
}

self.lastSelectedView = selection;

CGRect viewRect = [selection.superview convertRect:selection.frame toView:[self.extension attachedWindow]];
self.currentlySelectedView = selection;

self.highlightView.frame = viewRect;
[self updateSelection];
}

self.currentlySelectedView = selection;
-(void)interactionViewDidTransitionToSize:(CGSize)size
{
[super interactionViewDidTransitionToSize:size];
[self updateSelection];
}

-(void)updateSelection
{
if (!self.currentlySelectedView)
{
return;
}

CGRect viewRect = [self.currentlySelectedView.superview convertRect:self.currentlySelectedView.frame toView:[self.extension attachedWindow]];

self.highlightView.frame = viewRect;

HYPAttributesPreviewViewController *attributesView = [[HYPAttributesPreviewViewController alloc] initWithSelectedView:self.currentlySelectedView];

attributesView.delegate = self;

[self.extension.snapshotContainer presentPopover:attributesView recommendedHeight:250 forView:self.currentlySelectedView];
}

Expand Down
17 changes: 16 additions & 1 deletion AttributesInspector/HYPAttributesInspectorPluginModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

@interface HYPAttributesInspectorPluginModule ()

@property (nonatomic) HYPAttributeInspectorInteractionView *currentAttributesInteractionView;

@end

@implementation HYPAttributesInspectorPluginModule
Expand All @@ -47,7 +49,8 @@ -(void)activateSnapshotPluginViewWithContext:(UIView *)context
{
[super activateSnapshotPluginViewWithContext:context];
[_snapshotPluginView removeFromSuperview];
_snapshotPluginView = [[HYPAttributeInspectorInteractionView alloc] initWithExtension:self.extension];
self.currentAttributesInteractionView = [[HYPAttributeInspectorInteractionView alloc] initWithExtension:self.extension];
_snapshotPluginView = self.currentAttributesInteractionView;
_snapshotPluginView.translatesAutoresizingMaskIntoConstraints = false;
[context addSubview:_snapshotPluginView];
[_snapshotPluginView.leadingAnchor constraintEqualToAnchor:context.leadingAnchor].active = true;
Expand All @@ -56,6 +59,18 @@ -(void)activateSnapshotPluginViewWithContext:(UIView *)context
[_snapshotPluginView.bottomAnchor constraintEqualToAnchor:context.bottomAnchor].active = true;
}

-(void)snapshotContextWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[super snapshotContextWillTransitionToSize:size withTransitionCoordinator:coordinator];
[self.currentAttributesInteractionView interactionViewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}

-(void)snapshotContextDidTransitionToSize:(CGSize)size
{
[super snapshotContextDidTransitionToSize:size];
[self.currentAttributesInteractionView interactionViewDidTransitionToSize:size];
}

-(void)deactivateSnapshotPluginView
{
[super deactivateSnapshotPluginView];
Expand Down
8 changes: 8 additions & 0 deletions Core/Public/HyperionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#import <UIKit/UIKit.h>
#import "HYPActivationGestureOptions.h"

@protocol HYPPlugin;
@protocol HYPPluginModule;

/**
Expand Down Expand Up @@ -50,6 +51,13 @@
*/
-(void)togglePluginDrawer;

/**
* Provides a list of plugin classes.
* @return A list of plugin classes.
*/
-(NSArray<Class<HYPPlugin>> *)retrievePluginClasses;


/**
* Provides a cached list of plugin modules.
* @return A cached list of plugin modules.
Expand Down
29 changes: 18 additions & 11 deletions Core/Public/HyperionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,9 @@ -(void)setActivationGesture:(HYPActivationGestureOptions)gesture {
[window.overlayVC.edgeSwipeRecognizer setEnabled:edgeSwipeEnabled];
}

-(NSArray<id<HYPPluginModule>> *)retrievePluginModules
{
//TODO: Cache Plugin Modules
return [self forceRefreshPluginModules];
}

-(NSArray<id<HYPPluginModule>> *)forceRefreshPluginModules
-(NSArray<Class<HYPPlugin>> *)retrievePluginClasses
{
HYPPluginExtension *pluginExtension = [[HYPPluginExtension alloc] initWithSnapshotContainer:[[[HyperionWindowManager sharedInstance] currentSnapshotWindow] snapshotContainer] overlayContainer:[[[HyperionWindowManager sharedInstance] currentOverlayWindow] overlayContainer] hypeWindow:[[HyperionWindowManager sharedInstance] currentSnapshotWindow] attachedWindow:self.key];

NSMutableArray<id<HYPPluginModule>> *mutablePluginModules = [[NSMutableArray alloc] init];
NSMutableArray *pluginClasses = [[NSMutableArray alloc] init];
NSMutableArray<Class<HYPPlugin>> *pluginClasses = [[NSMutableArray alloc] init];

int numClasses;
Class * classes = NULL;
Expand All @@ -190,6 +181,22 @@ -(void)setActivationGesture:(HYPActivationGestureOptions)gesture {
free(classes);
}

return pluginClasses;
}

-(NSArray<id<HYPPluginModule>> *)retrievePluginModules
{
//TODO: Cache Plugin Modules
return [self forceRefreshPluginModules];
}

-(NSArray<id<HYPPluginModule>> *)forceRefreshPluginModules
{
HYPPluginExtension *pluginExtension = [[HYPPluginExtension alloc] initWithSnapshotContainer:[[[HyperionWindowManager sharedInstance] currentSnapshotWindow] snapshotContainer] overlayContainer:[[[HyperionWindowManager sharedInstance] currentOverlayWindow] overlayContainer] hypeWindow:[[HyperionWindowManager sharedInstance] currentSnapshotWindow] attachedWindow:self.key];

NSMutableArray<id<HYPPluginModule>> *mutablePluginModules = [[NSMutableArray alloc] init];
NSArray<Class<HYPPlugin>> *pluginClasses = [self retrievePluginClasses];

for (Class<HYPPlugin> pluginClass in pluginClasses)
{
if ([pluginClass conformsToProtocol:@protocol(HYPPlugin)])
Expand Down
15 changes: 15 additions & 0 deletions Core/Public/Plugin/HYPOverlayViewProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@
*/
-(void)deactivateSnapshotPluginView;

@optional

/**
* Called when the context the plugin view is in is about to change size.
* @param size The size that the context is about to change to.
* @param coordinator The transition coordinator allows you to animate views in sync with the size change.
*/
-(void)snapshotContextWillTransitionToSize:(CGSize)size withTransitionCoordinator:(__nullable id<UIViewControllerTransitionCoordinator>)coordinator;

/**
* Called when the context has changed size.
* @param size The size that the plugin view has changed to.
*/
-(void)snapshotContextDidTransitionToSize:(CGSize)size;

@end

/**
Expand Down
17 changes: 15 additions & 2 deletions Core/Public/Plugin/SnapShotPlugin/HYPSnapshotInteractionView.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,24 @@
* Creates a new HYPSnapshotInteractionView with the provided extension.
* @param extension The extension the HYPSnapshotInteractionView should be created with.
*/
-(instancetype)initWithExtension:(id<HYPPluginExtension>)extension;
-(__nonnull instancetype)initWithExtension:(__nullable id<HYPPluginExtension>)extension;

/**
* Called when the interaction view is about to change size.
* @param size The size that the interaction view is about to change to.
* @param coordinator The transition coordinator allows you to animate views in sync with the size change.
*/
-(void)interactionViewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(__nullable id<UIViewControllerTransitionCoordinator>)coordinator;

/**
* Called when the interaction view has changed size.
* @param size The size that the interaction view has changed to.
*/
-(void)interactionViewDidTransitionToSize:(CGSize)size;

/**
* The extension that the HYPSnapshotInteractionView was intialized with.
*/
@property (nonatomic, readonly) id<HYPPluginExtension> extension;
@property (nonatomic, readonly, nullable) id<HYPPluginExtension> extension;

@end
10 changes: 10 additions & 0 deletions Core/Public/Plugin/SnapShotPlugin/HYPSnapshotInteractionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,14 @@ -(instancetype)initWithExtension:(id<HYPPluginExtension>)extension
return self;
}

-(void)interactionViewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(__nullable id<UIViewControllerTransitionCoordinator>)coordinator
{
//No op;
}

-(void)interactionViewDidTransitionToSize:(CGSize)size
{
//No op;
}

@end
10 changes: 10 additions & 0 deletions Core/Public/Plugin/SnapShotPlugin/HYPSnapshotPluginModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,14 @@ -(void)deactivateSnapshotPluginView
[_pluginMenuItem setSelected:NO animated:YES];
}

-(void)snapshotContextWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
//No op;
}

-(void)snapshotContextDidTransitionToSize:(CGSize)size
{
//No op;
}

@end
22 changes: 21 additions & 1 deletion Core/SnapShotDebuggingWindow/HYPSnapshotViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ @implementation HYPSnapshotViewController

const CGFloat PluginListWidth = 280;


-(instancetype)initWithDebuggingWindow:(HYPSnapshotDebuggingWindow *)snapshotDebuggingWindow attachedWindow:(UIWindow *)attachedWindow
{
self = [super init];
Expand Down Expand Up @@ -462,6 +461,27 @@ -(void)updatePopOverFrame:(HYPPopoverViewController *)popOverViewController
[popOverViewController setArrowPosition:position offset:arrowOffset];
}

-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[self dismissCurrentPopover];

[self.snapshotContainer.overlayModule snapshotContextWillTransitionToSize:size withTransitionCoordinator:coordinator];

self.scrollView.zoomScale = 1;
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
[self takeSnapshot];
self.scrollViewContainer.frame = CGRectMake(0, 0, size.width, size.height);
self.scrollView.zoomScale = 1;
self.scrollView.contentOffset = CGPointZero;
} completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
[self takeSnapshot];
self.scrollView.zoomScale = 1;
self.scrollView.contentOffset = CGPointZero;
[self.snapshotContainer.overlayModule snapshotContextDidTransitionToSize:size];
}];
}

-(void)presentViewController:(UIViewController *)controller animated:(bool)animated
{
[self presentViewController:controller animated:YES completion:nil];
Expand Down
39 changes: 26 additions & 13 deletions Core/SnapShotDebuggingWindow/PluginListViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,47 @@ -(instancetype)initWithPluginModule:(HYPPluginModule *)module pluginView:(UIView
@interface PluginListViewController ()

@property (nonatomic) NSArray<PluginContainerView *> *containerViews;
@property (nonatomic) NSMutableArray<UITapGestureRecognizer *> *tapGestures;
@property (nonatomic) UIStackView *pluginList;
@property (nonatomic) UIScrollView *pluginScrollView;

@end

@implementation PluginListViewController

- (void)viewDidLoad {
[super viewDidLoad];

self.view.backgroundColor = [UIColor clearColor];

self.pluginScrollView = [[UIScrollView alloc] init];
self.pluginScrollView.translatesAutoresizingMaskIntoConstraints = false;
[self.view addSubview:self.pluginScrollView];

[self.pluginScrollView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor].active = true;
[self.pluginScrollView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor].active = true;
[self.pluginScrollView.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor].active = true;
[self.pluginScrollView.topAnchor constraintGreaterThanOrEqualToAnchor:self.view.topAnchor constant:0].active = true;
[self.pluginScrollView.bottomAnchor constraintLessThanOrEqualToAnchor:self.view.bottomAnchor constant:0].active = true;

self.pluginList = [[UIStackView alloc] initWithFrame:CGRectZero];

self.tapGestures = [[NSMutableArray alloc] init];

self.pluginList.spacing = 20;
[self.pluginScrollView addSubview:self.pluginList];

[self.view addSubview:self.pluginList];

self.pluginList.translatesAutoresizingMaskIntoConstraints = NO;

self.pluginList.axis = UILayoutConstraintAxisVertical;

[self.pluginList.leadingAnchor constraintEqualToAnchor:self.pluginScrollView.leadingAnchor].active = YES;
[self.pluginList.trailingAnchor constraintEqualToAnchor:self.pluginScrollView.trailingAnchor].active = YES;
[self.pluginList.widthAnchor constraintEqualToAnchor:self.view.widthAnchor].active = YES;
[self.pluginList.topAnchor constraintEqualToAnchor:self.pluginScrollView.topAnchor constant:15].active = YES;
[self.pluginList.bottomAnchor constraintEqualToAnchor:self.pluginScrollView.bottomAnchor constant:15].active = YES;

self.view.backgroundColor = [UIColor clearColor];

[self.pluginList.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor].active = YES;
[self.pluginList.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor].active = YES;
[self.pluginList.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor].active = YES;

NSLayoutConstraint *heightContraint = [self.pluginList.heightAnchor constraintEqualToAnchor:_pluginScrollView.heightAnchor];
//This constraint will only stick around if the plugin list is not big enough to scroll
[heightContraint setPriority:250];
heightContraint.active = true;
[self loadTabs];
}

Expand Down
Loading

0 comments on commit bb59e83

Please # to comment.