Commit cecd7485 authored by stkhapugin's avatar stkhapugin Committed by Commit bot

[ObjC ARC] Converts ios/chrome/browser/ui/collection_view:collection_view to ARC.

Automatically generated ARCMigrate commit
Notable issues:None
BUG=624363
TEST=None

Review-Url: https://codereview.chromium.org/2743643002
Cr-Commit-Position: refs/heads/master@{#455785}
parent e2491c4e
......@@ -3,6 +3,7 @@
# found in the LICENSE file.
source_set("collection_view") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"collection_view_controller.h",
"collection_view_controller.mm",
......
......@@ -25,7 +25,7 @@ typedef NS_ENUM(NSInteger, CollectionViewControllerStyle) {
: MDCCollectionViewController<AppBarPresenting>
// The model of this controller.
@property(nonatomic, readonly)
@property(strong, nonatomic, readonly)
CollectionViewModel<CollectionViewItem*>* collectionViewModel;
// Initializer with the desired style.
......
......@@ -6,28 +6,29 @@
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#import "base/mac/scoped_nsobject.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
#import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
#import "ios/chrome/browser/ui/material_components/utils.h"
#import "ios/third_party/material_components_ios/src/components/AppBar/src/MaterialAppBar.h"
#import "ios/third_party/material_components_ios/src/components/CollectionCells/src/MaterialCollectionCells.h"
@implementation CollectionViewController {
// The implementation of this controller follows the guidelines from
// https://github.com/material-components/material-components-ios/tree/develop/components/AppBar
base::scoped_nsobject<MDCAppBar> _appBar;
base::scoped_nsobject<CollectionViewModel> _collectionViewModel;
}
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
// The implementation of this controller follows the guidelines from
// https://github.com/material-components/material-components-ios/tree/develop/components/AppBar
@implementation CollectionViewController
@synthesize appBar = _appBar;
@synthesize collectionViewModel = _collectionViewModel;
- (instancetype)initWithStyle:(CollectionViewControllerStyle)style {
UICollectionViewLayout* layout =
[[[MDCCollectionViewFlowLayout alloc] init] autorelease];
UICollectionViewLayout* layout = [[MDCCollectionViewFlowLayout alloc] init];
self = [super initWithCollectionViewLayout:layout];
if (self) {
if (style == CollectionViewControllerStyleAppBar) {
_appBar.reset([[MDCAppBar alloc] init]);
[self addChildViewController:_appBar.get().headerViewController];
_appBar = [[MDCAppBar alloc] init];
[self addChildViewController:_appBar.headerViewController];
}
}
return self;
......@@ -56,16 +57,8 @@
return self.appBar.headerViewController;
}
- (MDCAppBar*)appBar {
return _appBar.get();
}
- (CollectionViewModel*)collectionViewModel {
return _collectionViewModel.get();
}
- (void)loadModel {
_collectionViewModel.reset([[CollectionViewModel alloc] init]);
_collectionViewModel = [[CollectionViewModel alloc] init];
}
- (void)reconfigureCellsForItems:(NSArray*)items
......@@ -121,8 +114,8 @@
DCHECK(![MDCCollectionViewController instancesRespondToSelector:_cmd]);
// Retain the item to be able to move it.
base::scoped_nsobject<CollectionViewItem> item(
[[self.collectionViewModel itemAtIndexPath:indexPath] retain]);
CollectionViewItem* item =
[self.collectionViewModel itemAtIndexPath:indexPath];
// Item coordinates.
NSInteger sectionIdentifier =
......
......@@ -5,33 +5,34 @@
#import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
#include "base/logging.h"
#include "base/mac/scoped_nsobject.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
typedef NSMutableArray<CollectionViewItem*> SectionItems;
}
@implementation CollectionViewModel {
// Ordered list of section identifiers, one per section in the model.
base::scoped_nsobject<NSMutableArray<NSNumber*>> _sectionIdentifiers;
NSMutableArray<NSNumber*>* _sectionIdentifiers;
// The lists of section items, one per section.
base::scoped_nsobject<NSMutableArray<SectionItems*>> _sections;
NSMutableArray<SectionItems*>* _sections;
// Maps from section identifier to header and footer.
base::scoped_nsobject<NSMutableDictionary<NSNumber*, CollectionViewItem*>>
_headers;
base::scoped_nsobject<NSMutableDictionary<NSNumber*, CollectionViewItem*>>
_footers;
NSMutableDictionary<NSNumber*, CollectionViewItem*>* _headers;
NSMutableDictionary<NSNumber*, CollectionViewItem*>* _footers;
}
- (instancetype)init {
if ((self = [super init])) {
_sectionIdentifiers.reset([[NSMutableArray alloc] init]);
_sections.reset([[NSMutableArray alloc] init]);
_headers.reset([[NSMutableDictionary alloc] init]);
_footers.reset([[NSMutableDictionary alloc] init]);
_sectionIdentifiers = [[NSMutableArray alloc] init];
_sections = [[NSMutableArray alloc] init];
_headers = [[NSMutableDictionary alloc] init];
_footers = [[NSMutableDictionary alloc] init];
}
return self;
}
......@@ -44,7 +45,7 @@ typedef NSMutableArray<CollectionViewItem*> SectionItems;
[self internalSectionForIdentifier:sectionIdentifier]);
[_sectionIdentifiers addObject:@(sectionIdentifier)];
base::scoped_nsobject<SectionItems> section([[SectionItems alloc] init]);
SectionItems* section = [[SectionItems alloc] init];
[_sections addObject:section];
}
......@@ -57,7 +58,7 @@ typedef NSMutableArray<CollectionViewItem*> SectionItems;
[_sectionIdentifiers insertObject:@(sectionIdentifier) atIndex:index];
base::scoped_nsobject<SectionItems> section([[SectionItems alloc] init]);
SectionItems* section = [[SectionItems alloc] init];
[_sections insertObject:section atIndex:index];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment