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

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

Issue 2956433002: [Payment Request] keyboardType, autoCapitalizationType, etc for text fields (Closed)
Patch Set: Created 3 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #import "ios/chrome/browser/ui/autofill/cells/autofill_edit_item.h" 5 #import "ios/chrome/browser/ui/autofill/cells/autofill_edit_item.h"
6 6
7 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" 7 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
8 #import "ios/chrome/browser/ui/rtl_geometry.h" 8 #import "ios/chrome/browser/ui/rtl_geometry.h"
9 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h" 9 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h"
10 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" 10 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
(...skipping 15 matching lines...) Expand all
26 26
27 @implementation AutofillEditItem 27 @implementation AutofillEditItem
28 28
29 @synthesize textFieldName = _textFieldName; 29 @synthesize textFieldName = _textFieldName;
30 @synthesize textFieldValue = _textFieldValue; 30 @synthesize textFieldValue = _textFieldValue;
31 @synthesize identifyingIcon = _identifyingIcon; 31 @synthesize identifyingIcon = _identifyingIcon;
32 @synthesize inputView = _inputView; 32 @synthesize inputView = _inputView;
33 @synthesize textFieldEnabled = _textFieldEnabled; 33 @synthesize textFieldEnabled = _textFieldEnabled;
34 @synthesize autofillUIType = _autofillUIType; 34 @synthesize autofillUIType = _autofillUIType;
35 @synthesize required = _required; 35 @synthesize required = _required;
36 @synthesize returnKeyType = _returnKeyType;
37 @synthesize keyboardType = _keyboardType;
38 @synthesize autoCapitalizationType = _autoCapitalizationType;
36 39
37 - (instancetype)initWithType:(NSInteger)type { 40 - (instancetype)initWithType:(NSInteger)type {
38 self = [super initWithType:type]; 41 self = [super initWithType:type];
39 if (self) { 42 if (self) {
40 self.cellClass = [AutofillEditCell class]; 43 self.cellClass = [AutofillEditCell class];
44 _returnKeyType = UIReturnKeyNext;
45 _keyboardType = UIKeyboardTypeDefault;
46 _autoCapitalizationType = UITextAutocapitalizationTypeWords;
41 } 47 }
42 return self; 48 return self;
43 } 49 }
44 50
45 #pragma mark CollectionViewItem 51 #pragma mark CollectionViewItem
46 52
47 - (void)configureCell:(AutofillEditCell*)cell { 53 - (void)configureCell:(AutofillEditCell*)cell {
48 [super configureCell:cell]; 54 [super configureCell:cell];
49 NSString* textLabelFormat = self.required ? @"%@*" : @"%@"; 55 NSString* textLabelFormat = self.required ? @"%@*" : @"%@";
50 cell.textLabel.text = 56 cell.textLabel.text =
51 [NSString stringWithFormat:textLabelFormat, self.textFieldName]; 57 [NSString stringWithFormat:textLabelFormat, self.textFieldName];
52 cell.textField.text = self.textFieldValue; 58 cell.textField.text = self.textFieldValue;
53 if (self.textFieldName.length) { 59 if (self.textFieldName.length) {
54 cell.textField.accessibilityIdentifier = 60 cell.textField.accessibilityIdentifier =
55 [NSString stringWithFormat:@"%@_textField", self.textFieldName]; 61 [NSString stringWithFormat:@"%@_textField", self.textFieldName];
56 } 62 }
57 cell.textField.enabled = self.textFieldEnabled; 63 cell.textField.enabled = self.textFieldEnabled;
58 cell.textField.textColor = self.textFieldEnabled 64 cell.textField.textColor = self.textFieldEnabled
59 ? [[MDCPalette cr_bluePalette] tint500] 65 ? [[MDCPalette cr_bluePalette] tint500]
60 : [[MDCPalette greyPalette] tint500]; 66 : [[MDCPalette greyPalette] tint500];
61 [cell.textField addTarget:self 67 [cell.textField addTarget:self
62 action:@selector(textFieldChanged:) 68 action:@selector(textFieldChanged:)
63 forControlEvents:UIControlEventEditingChanged]; 69 forControlEvents:UIControlEventEditingChanged];
64 cell.textField.inputView = self.inputView; 70 cell.textField.inputView = self.inputView;
71 cell.textField.returnKeyType = self.returnKeyType;
72 cell.textField.keyboardType = self.keyboardType;
73 cell.textField.autocapitalizationType = self.autoCapitalizationType;
65 cell.identifyingIconView.image = self.identifyingIcon; 74 cell.identifyingIconView.image = self.identifyingIcon;
66 } 75 }
67 76
68 #pragma mark - Actions 77 #pragma mark - Actions
69 78
70 - (void)textFieldChanged:(UITextField*)textField { 79 - (void)textFieldChanged:(UITextField*)textField {
71 self.textFieldValue = textField.text; 80 self.textFieldValue = textField.text;
72 } 81 }
73 82
74 @end 83 @end
(...skipping 22 matching lines...) Expand all
97 [_textLabel setContentHuggingPriority:UILayoutPriorityDefaultHigh 106 [_textLabel setContentHuggingPriority:UILayoutPriorityDefaultHigh
98 forAxis:UILayoutConstraintAxisHorizontal]; 107 forAxis:UILayoutConstraintAxisHorizontal];
99 [contentView addSubview:_textLabel]; 108 [contentView addSubview:_textLabel];
100 109
101 _textField = [[UITextField alloc] init]; 110 _textField = [[UITextField alloc] init];
102 _textField.translatesAutoresizingMaskIntoConstraints = NO; 111 _textField.translatesAutoresizingMaskIntoConstraints = NO;
103 [contentView addSubview:_textField]; 112 [contentView addSubview:_textField];
104 113
105 _textField.font = [[MDCTypography fontLoader] lightFontOfSize:16]; 114 _textField.font = [[MDCTypography fontLoader] lightFontOfSize:16];
106 _textField.textColor = [[MDCPalette greyPalette] tint500]; 115 _textField.textColor = [[MDCPalette greyPalette] tint500];
107 _textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
108 _textField.autocorrectionType = UITextAutocorrectionTypeNo; 116 _textField.autocorrectionType = UITextAutocorrectionTypeNo;
109 _textField.returnKeyType = UIReturnKeyDone;
110 _textField.clearButtonMode = UITextFieldViewModeWhileEditing; 117 _textField.clearButtonMode = UITextFieldViewModeWhileEditing;
111 _textField.contentVerticalAlignment = 118 _textField.contentVerticalAlignment =
112 UIControlContentVerticalAlignmentCenter; 119 UIControlContentVerticalAlignmentCenter;
113 _textField.textAlignment = 120 _textField.textAlignment =
114 UseRTLLayout() ? NSTextAlignmentLeft : NSTextAlignmentRight; 121 UseRTLLayout() ? NSTextAlignmentLeft : NSTextAlignmentRight;
115 122
116 // Card type icon. 123 // Card type icon.
117 _identifyingIconView = [[UIImageView alloc] initWithFrame:CGRectZero]; 124 _identifyingIconView = [[UIImageView alloc] initWithFrame:CGRectZero];
118 _identifyingIconView.translatesAutoresizingMaskIntoConstraints = NO; 125 _identifyingIconView.translatesAutoresizingMaskIntoConstraints = NO;
119 [contentView addSubview:_identifyingIconView]; 126 [contentView addSubview:_identifyingIconView];
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 180
174 [super layoutSubviews]; 181 [super layoutSubviews];
175 } 182 }
176 183
177 #pragma mark - UICollectionReusableView 184 #pragma mark - UICollectionReusableView
178 185
179 - (void)prepareForReuse { 186 - (void)prepareForReuse {
180 [super prepareForReuse]; 187 [super prepareForReuse];
181 self.textLabel.text = nil; 188 self.textLabel.text = nil;
182 self.textField.text = nil; 189 self.textField.text = nil;
190 self.textField.returnKeyType = UIReturnKeyNext;
191 self.textField.keyboardType = UIKeyboardTypeDefault;
183 self.textField.autocapitalizationType = UITextAutocapitalizationTypeWords; 192 self.textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
184 self.textField.autocorrectionType = UITextAutocorrectionTypeNo; 193 self.textField.autocorrectionType = UITextAutocorrectionTypeNo;
185 self.textField.returnKeyType = UIReturnKeyDone; 194 self.textField.clearButtonMode = UITextFieldViewModeWhileEditing;
186 self.textField.accessibilityIdentifier = nil; 195 self.textField.accessibilityIdentifier = nil;
187 self.textField.enabled = NO; 196 self.textField.enabled = NO;
188 self.textField.delegate = nil; 197 self.textField.delegate = nil;
189 [self.textField removeTarget:nil 198 [self.textField removeTarget:nil
190 action:nil 199 action:nil
191 forControlEvents:UIControlEventAllEvents]; 200 forControlEvents:UIControlEventAllEvents];
192 self.identifyingIconView.image = nil; 201 self.identifyingIconView.image = nil;
193 } 202 }
194 203
195 #pragma mark - Accessibility 204 #pragma mark - Accessibility
196 205
197 - (NSString*)accessibilityLabel { 206 - (NSString*)accessibilityLabel {
198 return [NSString 207 return [NSString
199 stringWithFormat:@"%@, %@", self.textLabel.text, self.textField.text]; 208 stringWithFormat:@"%@, %@", self.textLabel.text, self.textField.text];
200 } 209 }
201 210
202 @end 211 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/autofill/cells/autofill_edit_item.h ('k') | ios/chrome/browser/ui/payments/address_edit_mediator.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698