From 008047f8684274ba43ee1cb80ac524c3deb1b787 Mon Sep 17 00:00:00 2001 From: Chris Mays Date: Sat, 2 Dec 2017 13:45:57 -0500 Subject: [PATCH] Add scrolling to the plugin list. --- .../PluginListViewController.m | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/Core/SnapShotDebuggingWindow/PluginListViewController.m b/Core/SnapShotDebuggingWindow/PluginListViewController.m index f6cfb94..82b0047 100644 --- a/Core/SnapShotDebuggingWindow/PluginListViewController.m +++ b/Core/SnapShotDebuggingWindow/PluginListViewController.m @@ -54,8 +54,8 @@ -(instancetype)initWithPluginModule:(HYPPluginModule *)module pluginView:(UIView @interface PluginListViewController () @property (nonatomic) NSArray *containerViews; -@property (nonatomic) NSMutableArray *tapGestures; @property (nonatomic) UIStackView *pluginList; +@property (nonatomic) UIScrollView *pluginScrollView; @end @@ -63,25 +63,38 @@ @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]; }