Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(899)

Side by Side Diff: ios/chrome/browser/ui/autofill/card_unmask_prompt_view_bridge.mm

Issue 2761263003: Allow CollectionViewModel/Controller queries without SectionIdentifier (Closed)
Patch Set: Cleanup Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ios/chrome/browser/ui/autofill/card_unmask_prompt_view_bridge.h" 5 #include "ios/chrome/browser/ui/autofill/card_unmask_prompt_view_bridge.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/ios/ios_util.h" 8 #include "base/ios/ios_util.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 NSForegroundColorAttributeName : [UIColor lightGrayColor] 195 NSForegroundColorAttributeName : [UIColor lightGrayColor]
196 } 196 }
197 forState:UIControlStateDisabled]; 197 forState:UIControlStateDisabled];
198 [_verifyButton setEnabled:NO]; 198 [_verifyButton setEnabled:NO];
199 self.navigationItem.rightBarButtonItem = _verifyButton; 199 self.navigationItem.rightBarButtonItem = _verifyButton;
200 } 200 }
201 201
202 - (void)viewWillLayoutSubviews { 202 - (void)viewWillLayoutSubviews {
203 [super viewWillLayoutSubviews]; 203 [super viewWillLayoutSubviews];
204 NSIndexPath* CVCIndexPath = 204 NSIndexPath* CVCIndexPath =
205 [self.collectionViewModel indexPathForItem:_CVCItem 205 [self.collectionViewModel indexPathForItem:_CVCItem];
206 inSectionWithIdentifier:SectionIdentifierMain];
207 CVCCell* CVC = base::mac::ObjCCastStrict<CVCCell>( 206 CVCCell* CVC = base::mac::ObjCCastStrict<CVCCell>(
208 [self.collectionView cellForItemAtIndexPath:CVCIndexPath]); 207 [self.collectionView cellForItemAtIndexPath:CVCIndexPath]);
209 [self focusInputIfNeeded:CVC]; 208 [self focusInputIfNeeded:CVC];
210 } 209 }
211 210
212 #pragma mark - CollectionViewController 211 #pragma mark - CollectionViewController
213 212
214 - (void)loadModel { 213 - (void)loadModel {
215 [super loadModel]; 214 [super loadModel];
216 CollectionViewModel* model = self.collectionViewModel; 215 CollectionViewModel* model = self.collectionViewModel;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 // Remove all the present items to replace them with the status item. 301 // Remove all the present items to replace them with the status item.
303 [self.collectionViewModel 302 [self.collectionViewModel
304 removeSectionWithIdentifier:SectionIdentifierMain]; 303 removeSectionWithIdentifier:SectionIdentifierMain];
305 [self.collectionViewModel addSectionWithIdentifier:SectionIdentifierMain]; 304 [self.collectionViewModel addSectionWithIdentifier:SectionIdentifierMain];
306 [self.collectionViewModel addItem:_statusItem 305 [self.collectionViewModel addItem:_statusItem
307 toSectionWithIdentifier:SectionIdentifierMain]; 306 toSectionWithIdentifier:SectionIdentifierMain];
308 [self.collectionView reloadData]; 307 [self.collectionView reloadData];
309 } else { 308 } else {
310 _statusItem.text = text; 309 _statusItem.text = text;
311 _statusItem.state = state; 310 _statusItem.state = state;
312 [self reconfigureCellsForItems:@[ _statusItem ] 311 [self reconfigureCellsForItems:@[ _statusItem ]];
313 inSectionWithIdentifier:SectionIdentifierMain];
314 [self.collectionViewLayout invalidateLayout]; 312 [self.collectionViewLayout invalidateLayout];
315 } 313 }
316 } 314 }
317 315
318 - (CGFloat)statusCellHeight { 316 - (CGFloat)statusCellHeight {
319 const CGFloat collectionViewWidth = 317 const CGFloat collectionViewWidth =
320 CGRectGetWidth(self.collectionView.bounds); 318 CGRectGetWidth(self.collectionView.bounds);
321 319
322 // The status cell replaces the previous content of the collection. So it is 320 // The status cell replaces the previous content of the collection. So it is
323 // sized based on what appears when not loading. 321 // sized based on what appears when not loading.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 396
399 if ([self inputExpirationIsValid:item]) { 397 if ([self inputExpirationIsValid:item]) {
400 item.showDateInputError = NO; 398 item.showDateInputError = NO;
401 item.errorMessage = @""; 399 item.errorMessage = @"";
402 } else { 400 } else {
403 item.showDateInputError = NO; 401 item.showDateInputError = NO;
404 item.errorMessage = l10n_util::GetNSString( 402 item.errorMessage = l10n_util::GetNSString(
405 IDS_AUTOFILL_CARD_UNMASK_INVALID_EXPIRATION_DATE); 403 IDS_AUTOFILL_CARD_UNMASK_INVALID_EXPIRATION_DATE);
406 } 404 }
407 405
408 [self reconfigureCellsForItems:@[ item ] 406 [self reconfigureCellsForItems:@[ item ]];
409 inSectionWithIdentifier:SectionIdentifierMain];
410 [self.collectionViewLayout invalidateLayout]; 407 [self.collectionViewLayout invalidateLayout];
411 } 408 }
412 409
413 - (void)focusInputIfNeeded:(CVCCell*)CVC { 410 - (void)focusInputIfNeeded:(CVCCell*)CVC {
414 // Focus the first visible input, unless the orientation is landscape. In 411 // Focus the first visible input, unless the orientation is landscape. In
415 // landscape, the keyboard covers up the storage checkbox shown below this 412 // landscape, the keyboard covers up the storage checkbox shown below this
416 // view and the user might never see it. 413 // view and the user might never see it.
417 if (UIInterfaceOrientationIsPortrait( 414 if (UIInterfaceOrientationIsPortrait(
418 [UIApplication sharedApplication].statusBarOrientation)) { 415 [UIApplication sharedApplication].statusBarOrientation)) {
419 // Also check whether any of the inputs are already the first responder and 416 // Also check whether any of the inputs are already the first responder and
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 SysUTF16ToNSString(_bridge->GetController()->GetInstructionsMessage()); 479 SysUTF16ToNSString(_bridge->GetController()->GetInstructionsMessage());
483 _CVCItem.monthText = @""; 480 _CVCItem.monthText = @"";
484 _CVCItem.yearText = @""; 481 _CVCItem.yearText = @"";
485 _CVCItem.CVCText = @""; 482 _CVCItem.CVCText = @"";
486 _CVCItem.errorMessage = @""; 483 _CVCItem.errorMessage = @"";
487 _CVCItem.showDateInput = YES; 484 _CVCItem.showDateInput = YES;
488 _CVCItem.showNewCardButton = NO; 485 _CVCItem.showNewCardButton = NO;
489 _CVCItem.showDateInputError = NO; 486 _CVCItem.showDateInputError = NO;
490 _CVCItem.showCVCInputError = NO; 487 _CVCItem.showCVCInputError = NO;
491 488
492 [self reconfigureCellsForItems:@[ _CVCItem ] 489 [self reconfigureCellsForItems:@[ _CVCItem ]];
493 inSectionWithIdentifier:SectionIdentifierMain];
494 [self.collectionViewLayout invalidateLayout]; 490 [self.collectionViewLayout invalidateLayout];
495 491
496 [self inputsDidChange:_CVCItem]; 492 [self inputsDidChange:_CVCItem];
497 } 493 }
498 494
499 #pragma mark - UITextField Events 495 #pragma mark - UITextField Events
500 496
501 - (void)monthInputDidChange:(UITextField*)textField { 497 - (void)monthInputDidChange:(UITextField*)textField {
502 _CVCItem.monthText = textField.text; 498 _CVCItem.monthText = textField.text;
503 [self inputsDidChange:_CVCItem]; 499 [self inputsDidChange:_CVCItem];
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 - (void)collectionView:(UICollectionView*)collectionView 584 - (void)collectionView:(UICollectionView*)collectionView
589 willDisplayCell:(UICollectionViewCell*)cell 585 willDisplayCell:(UICollectionViewCell*)cell
590 forItemAtIndexPath:(NSIndexPath*)indexPath { 586 forItemAtIndexPath:(NSIndexPath*)indexPath {
591 CVCCell* CVC = base::mac::ObjCCast<CVCCell>(cell); 587 CVCCell* CVC = base::mac::ObjCCast<CVCCell>(cell);
592 if (CVC) { 588 if (CVC) {
593 [self focusInputIfNeeded:CVC]; 589 [self focusInputIfNeeded:CVC];
594 } 590 }
595 } 591 }
596 592
597 @end 593 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698