Skip to content

Commit

Permalink
Merge branch 'release-candidate'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Verkoeyen committed Apr 7, 2016
2 parents ddb3515 + 5cbe9d4 commit 1195948
Show file tree
Hide file tree
Showing 134 changed files with 5,859 additions and 1,032 deletions.
7 changes: 4 additions & 3 deletions .arcconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"load": [
"scripts/external/clang-format-linter",
"scripts/external/arc-xcode-test-engine"

"scripts/external/arc-xcode-test-engine",
"scripts/external/arc-proselint"
],
"phabricator.uri" : "http://codereview.cc/",
"repository.callsign" : "MDC",
Expand All @@ -17,6 +17,7 @@
},
"coverage": {
"product": "MaterialComponents.framework/MaterialComponents"
}
},
"pre-build": "pod install --project-directory=catalog/ --no-repo-update"
}
}
10 changes: 10 additions & 0 deletions .arclint
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
"type": "chmod",
"exclude": "(/Pods/)"
},
"prose": {
"type": "prose",
"include": "(\\.(md)$)",
"exclude": "(/Pods/)",
"severity": {
"typography.symbols.curly_quotes": "disabled",
"typography.symbols.ellipsis": "disabled",
"leonard.exclamation.30ppm": "disabled"
}
},
"spelling": {
"type": "spelling",
"include": "(\\.(m|h|mm|md)$)",
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "scripts/external/clang-format-linter"]
path = scripts/external/clang-format-linter
url = [email protected]:vhbit/clang-format-linter.git
[submodule "scripts/external/arc-proselint"]
path = scripts/external/arc-proselint
url = [email protected]:google/arc-proselint.git
182 changes: 178 additions & 4 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Want to contribute? Great! First, read this page (including the small print at the end).
Want to contribute? Great! First, read this page (including the [small print](#the-small-print)).

## Pull requests

Expand Down
4 changes: 2 additions & 2 deletions MaterialComponents.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load 'scripts/generated/icons.rb'

Pod::Spec.new do |s|
s.name = "MaterialComponents"
s.version = "3.0.0"
s.version = "3.1.0"
s.authors = { 'Apple platform engineering at Google' => '[email protected]' }
s.summary = "A collection of stand-alone production-ready UI libraries focused on design details."
s.homepage = "https://github.com/google/material-components-ios"
Expand Down Expand Up @@ -130,7 +130,7 @@ Pod::Spec.new do |s|
}

ss.dependency "MaterialComponents/FontDiskLoader"
# TODO: Make MDCRobotoFontLoader conform to the <MDCTypographyFontLoading>. This was intended to be a
# TODO: https://github.com/google/material-components-ios/issues/74 This was intended to be a
# strong dependancy but is weak during the deprecation period.
# ss.dependency "MaterialComponents/Typography"
end
Expand Down
4 changes: 2 additions & 2 deletions MaterialComponentsCatalog.podspec
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Pod::Spec.new do |s|
s.name = "MaterialComponentsCatalog"
s.version = "3.0.0"
s.version = "3.1.0"
s.authors = { 'Apple platform engineering at Google' => '[email protected]' }
s.summary = "A collection of stand-alone production-ready UI libraries focused on design details."
s.homepage = "https://github.com/google/material-components-ios"
s.license = 'Apache 2.0'
s.source = { :git => "https://github.com/google/material-components-ios.git", :tag => s.version.to_s }
s.platform = :ios, '7.0'
s.requires_arc = true
s.source_files = 'components/*/examples/*.{h,m,swift}'
s.source_files = 'components/*/examples/*.{h,m,swift}', 'components/*/examples/supplemental/*.{h,m,swift}'
s.resources = ['components/*/examples/resources/*']
s.dependency 'MaterialComponents'
end
2 changes: 1 addition & 1 deletion MaterialComponentsUnitTests.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "MaterialComponentsUnitTests"
s.version = "3.0.0"
s.version = "3.1.0"
s.authors = { 'Apple platform engineering at Google' => '[email protected]' }
s.summary = "A collection of stand-alone production-ready UI libraries focused on design details."
s.homepage = "https://github.com/google/material-components-ios"
Expand Down
36 changes: 36 additions & 0 deletions catalog/CatalogByConvention/src/CBCCatalogExample.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2016-present Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/**
The CBCCatalogExample protocol defines the static methods that classes can implement in order to
customize their location and behavior in the Catalog by Convention.
Examples should not formally conform to this protocol. Examples should simply implement these
methods.
*/
@protocol CBCCatalogExample <NSObject>

/** Return a list of breadcrumbs defining the navigation path taken to reach this example. */
+ (NSArray<NSString *> *)catalogBreadcrumbs;

@optional

/**
Return the name of a UIStoryboard from which the example's view controller should be instantiated.
*/
- (NSString *)catalogStoryboardName;

@end
69 changes: 69 additions & 0 deletions catalog/CatalogByConvention/src/CBCNodeViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Copyright 2016-present Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#import <UIKit/UIKit.h>

@class CBCNode;

/**
An instance of CBCNodeListViewController is able to represent a non-example CBCNode instance as a
UITableView.
*/
@interface CBCNodeListViewController : UITableViewController

/** Initializes a CBCNodeViewController instance with a non-example node. */
- (nonnull instancetype)initWithNode:(nonnull CBCNode *)node;

/** The node that this view controller must represent. */
@property(nonatomic, strong, nonnull, readonly) CBCNode *node;

@end

/**
Returns the root of a CBCNode tree representing the complete catalog navigation hierarchy.
Only classes that implement +catalogBreadcrumbs and return at least one breadcrumb will be part of
the tree.
*/
FOUNDATION_EXTERN CBCNode *__nonnull CBCCreateNavigationTree(void);

/**
A node describes a single navigable page in the Catalog by Convention.
A node either has children or it is an example.
- If a node has children, then the node should be represented by a list of some sort.
- If a node is an example, then the example controller can be instantiated with
createExampleViewController.
*/
@interface CBCNode : NSObject

/** Nodes cannot be created by clients. */
- (nullable instancetype)init NS_UNAVAILABLE;

/** The title for this node. */
@property(nonatomic, copy, nonnull, readonly) NSString *title;

/** The children of this node. */
@property(nonatomic, strong, nonnull, readonly) NSArray<CBCNode *> *children;

/** Returns YES if this is an example node. */
- (BOOL)isExample;

/** Returns an instance of a UIViewController for presentation purposes. */
- (nonnull UIViewController *)createExampleViewController;

@end
168 changes: 168 additions & 0 deletions catalog/CatalogByConvention/src/CBCNodeViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/*
Copyright 2016-present Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#import "CBCNodeViewController.h"

#import "CBCCatalogExample.h"
#import "CBCRuntime.h"

@implementation CBCNode {
NSMutableDictionary *_map;
NSMutableArray *_children;
Class _exampleClass;
}

- (instancetype)initWithTitle:(NSString *)title {
self = [super init];
if (self) {
_title = [title copy];
_map = [NSMutableDictionary dictionary];
_children = [NSMutableArray array];
}
return self;
}

- (instancetype)init {
[self doesNotRecognizeSelector:_cmd];
return nil;
}

- (NSComparisonResult)compare:(CBCNode *)otherObject {
return [self.title compare:otherObject.title];
}

- (void)addChild:(CBCNode *)child {
_map[child.title] = child;
[_children addObject:child];
}

- (NSDictionary *)map {
return _map;
}

- (void)setExampleClass:(Class)exampleClass {
_exampleClass = exampleClass;
}

- (void)finalize {
_children = [[_children sortedArrayUsingSelector:@selector(compare:)] mutableCopy];
}

#pragma mark Public

- (BOOL)isExample {
return _exampleClass != nil;
}

- (UIViewController *)createExampleViewController {
NSAssert(_exampleClass != nil, @"This is node has no associated example.");
return CBCViewControllerFromClass(_exampleClass);
}

@end

@implementation CBCNodeListViewController

- (instancetype)initWithNode:(CBCNode *)node {
NSAssert(!_node.isExample,
@"%@ cannot represent example nodes.", NSStringFromClass([self class]));

self = [super initWithStyle:UITableViewStylePlain];
if (self) {
_node = node;

self.title = _node.title;
}
return self;
}

#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [_node.children count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"cell"];
}
cell.textLabel.text = [_node.children[indexPath.row] title];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}

#pragma mark - UITableViewDelegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
CBCNode *node = _node.children[indexPath.row];
UIViewController *viewController = nil;
if ([node isExample]) {
viewController = [node createExampleViewController];
} else {
viewController = [[[self class] alloc] initWithNode:node];
}
[self.navigationController pushViewController:viewController animated:YES];
}

@end

CBCNode *CBCCreateNavigationTree(void) {
NSArray *allClasses = CBCGetAllClasses();
NSArray *classes = CBCClassesRespondingToSelector(allClasses, @selector(catalogBreadcrumbs));

CBCNode *tree = [[CBCNode alloc] initWithTitle:@"Root"];
for (Class aClass in classes) {
// Each example view controller defines its own "breadcrumbs".

NSArray *breadCrumbs = CBCCatalogBreadcrumbsFromClass(aClass);

// Walk down the navigation tree one breadcrumb at a time, creating nodes along the way.

CBCNode *node = tree;
for (NSInteger ix = 0; ix < [breadCrumbs count]; ++ix) {
NSString *title = breadCrumbs[ix];
BOOL isLastCrumb = ix == [breadCrumbs count] - 1;

// Don't walk the last crumb

if (node.map[title] && !isLastCrumb) {
node = node.map[title];
continue;
}

CBCNode *child = [[CBCNode alloc] initWithTitle:title];
[node addChild:child];
node = child;
}

node.exampleClass = aClass;
}

// Perform final post-processing on the nodes.
NSMutableArray *queue = [NSMutableArray arrayWithObject:tree];
while ([queue count] > 0) {
CBCNode *node = [queue firstObject];
[queue removeObjectAtIndex:0];
[queue addObjectsFromArray:node.children];

[node finalize];
}

return tree;
}
Loading

0 comments on commit 1195948

Please sign in to comment.