Skip to content

Commit

Permalink
Remove custom autoresizing masks and fix import errors.
Browse files Browse the repository at this point in the history
Closes jverkoey#728

PiperOrigin-RevId: 320469685
  • Loading branch information
jverkoey authored and material-automation committed Jul 9, 2020
1 parent c5a1c1f commit ccc13fd
Show file tree
Hide file tree
Showing 28 changed files with 46 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
// You will find the following Nimbus features used:
//
// [core]
// UIViewAutoresizingFlexibleDimensions
// RGBCOLOR
// RGBACOLOR
//
Expand Down Expand Up @@ -76,10 +75,7 @@ - (void)viewDidLoad {
// additional CoreText properties.
label.text = @"An explorer's tale";

// UIViewAutoresizingFlexibleDimensions is a Nimbus autoresizing mask that causes the view to
// grow and shrink with its super view. When we want a view to fill its super view this is
// generally the mask that we'll use.
label.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
label.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);

// These are standard UILabel styles. We can set these whenever we like and the attributed label
// will apply them to entire string even if we change the text again.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ - (void)viewDidLoad {

// Create a paging scroll view the same way we would any other type of view.
self.pagingScrollView = [[NIPagingScrollView alloc] initWithFrame:self.view.bounds];
self.pagingScrollView.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
self.pagingScrollView.autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);

// A paging scroll view has a data source much like a UITableView.
self.pagingScrollView.dataSource = self;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ - (void)viewDidLoad {
label.numberOfLines = 0;
label.lineBreakMode = NSLineBreakByWordWrapping;

label.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
label.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
label.frame = CGRectInset(self.view.bounds, 20, 20);

// When we assign the attributed text to the label it copies the attributed text object into the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ - (void)viewDidLoad {
NIAttributedLabel* label = [[NIAttributedLabel alloc] initWithFrame:CGRectZero];
label.numberOfLines = 0;
label.lineBreakMode = NSLineBreakByWordWrapping;
label.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
label.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
label.frame = CGRectInset(self.view.bounds, 20, 20);
label.font = [UIFont fontWithName:@"Optima-Regular" size:20];
label.delegate = self;
Expand Down
2 changes: 2 additions & 0 deletions examples/catalog/Catalog/FormCellCatalogViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#import "FormCellCatalogViewController.h"

#import "NimbusModels.h"
#import "NIFormCellCatalog.h"
#import "NIRadioGroup.h"
#import "NimbusCore.h"

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ - (void)viewDidLoad {
// When we assign the text we do not include any markup for the images.
label.text = @"This is Nimbus:He's a red panda.\nThis is a star:";

label.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
label.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
label.lineBreakMode = NSLineBreakByWordWrapping;
label.numberOfLines = 0;
label.font = [UIFont systemFontOfSize:20];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ - (void)viewDidLoad {
NIAttributedLabel* label = [[NIAttributedLabel alloc] initWithFrame:CGRectZero];
label.numberOfLines = 0;
label.lineBreakMode = NSLineBreakByWordWrapping;
label.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
label.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
label.frame = CGRectInset(self.view.bounds, 20, 20);
label.font = [UIFont fontWithName:@"AmericanTypewriter" size:15];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ - (void)viewDidLoad {
NIAttributedLabel* label = [[NIAttributedLabel alloc] initWithFrame:CGRectZero];
label.numberOfLines = 0;
label.lineBreakMode = NSLineBreakByWordWrapping;
label.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
label.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
label.frame = CGRectInset(self.view.bounds, 20, 20);
label.font = [UIFont fontWithName:@"AmericanTypewriter" size:15];
label.delegate = self;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#import "ModalRadioGroupTableModelViewController.h"

#import "NimbusModels.h"
#import "NIRadioGroup.h"
#import "NimbusCore.h"

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#import "NestedRadioGroupTableModelViewController.h"

#import "NimbusModels.h"
#import "NIRadioGroup.h"
#import "NimbusCore.h"

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ - (void)viewDidLoad {
@"Excepteur minim pop-up, craft beer mixtape brooklyn raw denim gentrify brunch sed you probably haven't heard of them cliche voluptate photo booth. Forage marfa laboris portland mustache, reprehenderit wes anderson eu. Master cleanse godard organic post-ironic. Elit +1 est wes anderson qui cliche cardigan, non deserunt godard consectetur photo booth organic forage. Pickled fugiat sint consectetur williamsburg. Butcher sustainable readymade fap chambray, labore letterpress gluten-free 3 wolf moon gentrify vero qui mcsweeney's whatever. Dreamcatcher farm-to-table lo-fi nesciunt magna, hella reprehenderit messenger bag ullamco VHS tofu est.";

self.scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
self.scrollView.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
self.scrollView.autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.scrollView.contentInset = UIEdgeInsetsMake(20, 0, 20, 0);
[self.scrollView addSubview:self.label];
[self.view addSubview:self.scrollView];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#import "RadioGroupTableModelViewController.h"

#import "NimbusModels.h"
#import "NIRadioGroup.h"
#import "NimbusCore.h"

//
Expand Down
2 changes: 1 addition & 1 deletion examples/catalog/Catalog/SamplePageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ @implementation SamplePageView
- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier {
if ((self = [super initWithFrame:CGRectZero])) {
_label = [[UILabel alloc] initWithFrame:self.bounds];
_label.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
_label.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
_label.font = [UIFont systemFontOfSize:26];
_label.textAlignment = NSTextAlignmentCenter;
_label.backgroundColor = [UIColor clearColor];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ - (void)viewDidLoad {
// in loadView, except we're adding the table view to self.view rather than assigning it to
// self.view.
self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
self.tableView.autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
[self.view addSubview:self.tableView];

self.tableView.delegate = [self.actions forwardingTo:self];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ - (void)viewDidLoad {
// This is the only change from the BasicInstantiation example.
self.pagingScrollView.type = NIPagingScrollViewVertical;

self.pagingScrollView.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
self.pagingScrollView.autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.pagingScrollView.dataSource = self;
[self.view addSubview:self.pagingScrollView];
[self.pagingScrollView reloadData];
Expand Down
5 changes: 0 additions & 5 deletions src/Doxygen.h
Original file line number Diff line number Diff line change
Expand Up @@ -608,11 +608,6 @@
* <tr><th>From</th><td class='Declaration' scope="row"><tt>typedef void (^NIErrorBlock)(NSError* error)</tt></td></tr>
* <tr><th>To</th><td class='Declaration' scope="row"><tt>typedef void (^NIErrorBlock)(NIOperation *operation, NSError* error)</tt></td></tr></table>@endhtmlonly
*
* <h3>NICommonMetrics.h</h3>
*
* - <span class="apiDiffAdded">Added</span> UIViewAutoresizingFlexibleMargins.
* - <span class="apiDiffAdded">Added</span> UIViewAutoresizingFlexibleDimensions.
*
* <h3>NIDebuggingTools.h</h3>
*
* - <span class="apiDiffAdded">Added</span> NIDASSERT now breaks on the device as well.
Expand Down
22 changes: 0 additions & 22 deletions src/core/src/NICommonMetrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,6 @@ extern "C" {
* @{
*/

#ifndef UIViewAutoresizingFlexibleMargins
#define UIViewAutoresizingFlexibleMargins (UIViewAutoresizingFlexibleLeftMargin \
| UIViewAutoresizingFlexibleTopMargin \
| UIViewAutoresizingFlexibleRightMargin \
| UIViewAutoresizingFlexibleBottomMargin)
#endif

#ifndef UIViewAutoresizingFlexibleDimensions
#define UIViewAutoresizingFlexibleDimensions (UIViewAutoresizingFlexibleWidth \
| UIViewAutoresizingFlexibleHeight)
#endif

#ifndef UIViewAutoresizingNavigationBar
#define UIViewAutoresizingNavigationBar (UIViewAutoresizingFlexibleWidth \
| UIViewAutoresizingFlexibleBottomMargin)
#endif

#ifndef UIViewAutoresizingToolbar
#define UIViewAutoresizingToolbar (UIViewAutoresizingFlexibleWidth \
| UIViewAutoresizingFlexibleTopMargin)
#endif

/**
* The recommended number of points for a minimum tappable area.
*
Expand Down
44 changes: 0 additions & 44 deletions src/core/src/NimbusCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,50 +49,6 @@
*
* Great care must be taken to ensure that Nimbus doesn't become a framework composed of
* hundreds of miniscule libraries.
*
* <h2>Common autoresizing masks</h2>
*
* Nimbus provides the following macros: UIViewAutoresizingFlexibleMargins,
* UIViewAutoresizingFlexibleDimensions, UIViewAutoresizingNavigationBar, and
* UIViewAutoresizingToolbarBar.
*
@code
// Create a view that fills its superview's bounds.
UIView* contentView = [[UIView alloc] initWithFrame:self.view.bounds];
contentView.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
[self.view addSubview:contentView];
// Create a view that is always centered in the superview's bounds.
UIView* centeredView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
centeredView.autoresizingMask = UIViewAutoresizingFlexibleMargins;
// Center the view within the superview however you choose.
[self.view addSubview:centeredView];
// Create a navigation bar that stays fixed to the top.
UINavigationBar* navBar = [[UINavigationBar alloc] initWithFrame:CGRectZero];
[navBar sizeToFit];
navBar.autoresizingMask = UIViewAutoresizingNavigationBar;
[self.view addSubview:navBar];
// Create a toolbar that stays fixed to the bottom.
UIToolbar* toolBar = [[UIToolbar alloc] initWithFrame:CGRectZero];
[toolBar sizeToFit];
toolBar.autoresizingMask = UIViewAutoresizingToolbarBar;
[self.view addSubview:toolBar];
@endcode
*
* <h3>Why they exist</h3>
*
* Using the existing UIViewAutoresizing flags can be tedious for common flags.
*
* For example, to make a view have flexible margins you would need to write four flags:
*
@code
view.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin
| UIViewAutoresizingFlexibleTopMargin
| UIViewAutoresizingFlexibleRightMargin
| UIViewAutoresizingFlexibleBottomMargin);
@endcode
*/

#import <Foundation/Foundation.h>
Expand Down
17 changes: 0 additions & 17 deletions src/core/unittests/NICommonMetricsTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,6 @@ @interface NICommonMetricsTests : XCTestCase

@implementation NICommonMetricsTests


- (void)testAutoresizingMasks {
XCTAssertTrue((UIViewAutoresizingFlexibleMargins & UIViewAutoresizingFlexibleLeftMargin),
@"Should have a flexible left margin.");
XCTAssertTrue((UIViewAutoresizingFlexibleMargins & UIViewAutoresizingFlexibleTopMargin),
@"Should have a flexible top margin.");
XCTAssertTrue((UIViewAutoresizingFlexibleMargins & UIViewAutoresizingFlexibleRightMargin),
@"Should have a flexible right margin.");
XCTAssertTrue((UIViewAutoresizingFlexibleMargins & UIViewAutoresizingFlexibleBottomMargin),
@"Should have a flexible bottom margin.");

XCTAssertTrue((UIViewAutoresizingFlexibleDimensions & UIViewAutoresizingFlexibleWidth),
@"Should have a flexible width.");
XCTAssertTrue((UIViewAutoresizingFlexibleDimensions & UIViewAutoresizingFlexibleHeight),
@"Should have a flexible height.");
}

- (void)testMetrics {
// TODO (Jan 25, 2012): Test iPad logic as well.
//STAssertEquals(NIToolbarHeightForOrientation(UIInterfaceOrientationPortrait), 44.f, @"Should match.");
Expand Down
11 changes: 8 additions & 3 deletions src/css/src/NICSSRuleset.m
Original file line number Diff line number Diff line change
Expand Up @@ -659,11 +659,16 @@ - (UIViewAutoresizing)autoresizing {
} else if ([value isEqualToString:@"height"]) {
autoresizing |= UIViewAutoresizingFlexibleHeight;
} else if ([value isEqualToString:@"all"]) {
autoresizing |= UIViewAutoresizingFlexibleDimensions | UIViewAutoresizingFlexibleMargins;
autoresizing |=
(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth
| UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin
| UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin);
} else if ([value isEqualToString:@"margins"]) {
autoresizing |= UIViewAutoresizingFlexibleMargins;
autoresizing |=
(UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin
| UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin);
} else if ([value isEqualToString:@"dimensions"]) {
autoresizing |= UIViewAutoresizingFlexibleDimensions;
autoresizing |= UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
}
_autoresizing = autoresizing;
Expand Down
1 change: 1 addition & 0 deletions src/css/src/NIChameleonObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#import <Foundation/Foundation.h>

#import "NimbusCore.h"
#import "NIOperations.h"
#import "NICSSParser.h"

@class NIStylesheet;
Expand Down
3 changes: 2 additions & 1 deletion src/launcher/src/NILauncherViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ - (void)loadView {
[super loadView];

self.launcherView = [[NILauncherView alloc] initWithFrame:self.view.bounds];
self.launcherView.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
self.launcherView.autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.launcherView.dataSource = self;
self.launcherView.delegate = self;

Expand Down
3 changes: 2 additions & 1 deletion src/models/src/NICellCatalog.m
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
self.selectionStyle = UITableViewCellSelectionStyleNone;

_blockView = [[NIDrawRectBlockView alloc] initWithFrame:self.contentView.bounds];
_blockView.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
_blockView.autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
_blockView.contentMode = UIViewContentModeRedraw;
[self.contentView addSubview:_blockView];

Expand Down
7 changes: 5 additions & 2 deletions src/networkcontrollers/src/NINetworkTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@ - (void)loadView {
[super loadView];

self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:self.tableViewStyle];
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
self.tableView.autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.view addSubview:self.tableView];

self.activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorStyle];
self.activityIndicator.autoresizingMask = UIViewAutoresizingFlexibleMargins;
self.activityIndicator.autoresizingMask =
(UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin
| UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin);
[self.activityIndicator sizeToFit];
self.activityIndicator.frame = NIFrameOfCenteredViewWithinView(self.activityIndicator, self.view);
[self.view addSubview:self.activityIndicator];
Expand Down
1 change: 1 addition & 0 deletions src/networkimage/src/NINetworkImageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#import <UIKit/UIKit.h>

#import "NIInMemoryCache.h"
#import "NIOperations.h"
#import "NimbusCore.h"

@protocol NINetworkImageViewDelegate;
Expand Down
3 changes: 2 additions & 1 deletion src/overview/src/NIOverviewPageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,8 @@ - (void)didTapPinpointButton:(UIButton *)button {
UIView *rootView = [self rootView];
[rootView endEditing:YES];
inspectionView_ = [[NIViewInspectionView alloc] initWithFrame:rootView.bounds];
inspectionView_.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
inspectionView_.autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
[rootView addSubview:inspectionView_];
visibleInspectionView = inspectionView_;
}
Expand Down
3 changes: 2 additions & 1 deletion src/pagingscrollview/src/NIPagingScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ - (void)commonInit {
// ...while still clipping contents to the bounds of the paging scroll view.
self.clipsToBounds = YES;

_scrollView.autoresizingMask = UIViewAutoresizingFlexibleDimensions;
_scrollView.autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);

_scrollView.delegate = self;

Expand Down
4 changes: 3 additions & 1 deletion src/photos/src/NIPhotoScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ - (id)initWithFrame:(CGRect)frame {
_loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
[_loadingView sizeToFit];
_loadingView.frame = NIFrameOfCenteredViewWithinView(_loadingView, self);
_loadingView.autoresizingMask = UIViewAutoresizingFlexibleMargins;
_loadingView.autoresizingMask =
(UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin
| UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin);

// We implement viewForZoomingInScrollView: and return the image view for zooming.
_scrollView.delegate = self;
Expand Down

0 comments on commit ccc13fd

Please sign in to comment.