@@ -131,9 +131,9 @@ - (void)setAttributedText:(NSAttributedString *)attributedText
131
131
132
132
[attributedTextCopy removeAttribute: RCTTextAttributesTagAttributeName
133
133
range: NSMakeRange (0 , attributedTextCopy.length)];
134
-
134
+
135
135
textNeedsUpdate = ([self textOf: attributedTextCopy equals: backedTextInputViewTextCopy] == NO );
136
-
136
+
137
137
if (eventLag == 0 && textNeedsUpdate) {
138
138
UITextRange *selection = self.backedTextInputView .selectedTextRange ;
139
139
NSInteger oldTextLength = self.backedTextInputView .attributedText .string .length ;
@@ -193,9 +193,61 @@ - (void)setTextContentType:(NSString *)type
193
193
{
194
194
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
195
195
if (@available (iOS 10.0 , *)) {
196
+
197
+ static dispatch_once_t onceToken;
198
+ static NSDictionary <NSString *, NSString *> *contentTypeMap;
199
+
200
+ dispatch_once (&onceToken, ^{
201
+ contentTypeMap = @{@" none" : @" " ,
202
+ @" URL" : UITextContentTypeURL,
203
+ @" addressCity" : UITextContentTypeAddressCity,
204
+ @" addressCityAndState" :UITextContentTypeAddressCityAndState,
205
+ @" addressState" : UITextContentTypeAddressState,
206
+ @" countryName" : UITextContentTypeCountryName,
207
+ @" creditCardNumber" : UITextContentTypeCreditCardNumber,
208
+ @" emailAddress" : UITextContentTypeEmailAddress,
209
+ @" familyName" : UITextContentTypeFamilyName,
210
+ @" fullStreetAddress" : UITextContentTypeFullStreetAddress,
211
+ @" givenName" : UITextContentTypeGivenName,
212
+ @" jobTitle" : UITextContentTypeJobTitle,
213
+ @" location" : UITextContentTypeLocation,
214
+ @" middleName" : UITextContentTypeMiddleName,
215
+ @" name" : UITextContentTypeName,
216
+ @" namePrefix" : UITextContentTypeNamePrefix,
217
+ @" nameSuffix" : UITextContentTypeNameSuffix,
218
+ @" nickname" : UITextContentTypeNickname,
219
+ @" organizationName" : UITextContentTypeOrganizationName,
220
+ @" postalCode" : UITextContentTypePostalCode,
221
+ @" streetAddressLine1" : UITextContentTypeStreetAddressLine1,
222
+ @" streetAddressLine2" : UITextContentTypeStreetAddressLine2,
223
+ @" sublocality" : UITextContentTypeSublocality,
224
+ @" telephoneNumber" : UITextContentTypeTelephoneNumber,
225
+ };
226
+
227
+ if (@available (iOS 11.0 , *)) {
228
+ NSDictionary <NSString *, NSString *> * extras = @{@" username" : UITextContentTypeUsername,
229
+ @" password" : UITextContentTypePassword};
230
+
231
+ NSMutableDictionary <NSString *, NSString *> * baseMap = [contentTypeMap mutableCopy ];
232
+ [baseMap addEntriesFromDictionary: extras];
233
+
234
+ contentTypeMap = [baseMap copy ];
235
+ }
236
+
237
+ if (@available (iOS 12.0 , *)) {
238
+ NSDictionary <NSString *, NSString *> * extras = @{@" newPassword" : UITextContentTypeNewPassword,
239
+ @" oneTimeCode" : UITextContentTypeOneTimeCode};
240
+
241
+ NSMutableDictionary <NSString *, NSString *> * baseMap = [contentTypeMap mutableCopy ];
242
+ [baseMap addEntriesFromDictionary: extras];
243
+
244
+ contentTypeMap = [baseMap copy ];
245
+ }
246
+ });
247
+
196
248
// Setting textContentType to an empty string will disable any
197
249
// default behaviour, like the autofill bar for password inputs
198
- self.backedTextInputView .textContentType = [ type isEqualToString: @" none " ] ? @" " : type;
250
+ self.backedTextInputView .textContentType = type ? contentTypeMap[type] : type;
199
251
}
200
252
#endif
201
253
}
0 commit comments