-
Notifications
You must be signed in to change notification settings - Fork 947
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
134 changed files
with
5,859 additions
and
1,032 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
168
catalog/CatalogByConvention/src/CBCNodeViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.