Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-26094] iOS 12: Add new Ti.UI.TextField API's #10088

Merged
merged 15 commits into from
Jul 12, 2018
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions apidoc/Titanium/UI/TextField.yml
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,19 @@ properties:
type: Boolean
default: false

- name: passwordRules
summary: Set password rules that should be used for this text field.
description: |
This property is used to communicate requirements for passwords for your service
to ensure iOS can generate compatible passwords for users. It only works when <Titanium.UI.TextField.passwordMask>
is `true`. You do not need to use this property if the passwords that iOS generates are already
compatible with your service. You can learn more about the purpose of and syntax for these rules
on the [Password Rules documentation guide](https://developer.apple.com/documentation/security/password_autofill/customizing_password_autofill_rules).
type: String
since: "7.4.0"
osver: { ios: { min: "12.0" } }
platforms: [iphone, ipad]

- name: returnKeyType
summary: Specifies the text to display on the keyboard `Return` key when this field is focused.
type: Number
Expand Down
22 changes: 19 additions & 3 deletions apidoc/Titanium/UI/UI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1077,29 +1077,45 @@ properties:
permission: read-only

- name: AUTOFILL_TYPE_CARD_EXPIRATION_DAY
summary: Specifies the expectation of a card expectation day.
summary: Specifies the expectation of a card expiration day.
type: String
platforms: [android]
since: "6.3.0"
osver: {android: {min: "8.0"}}
permission: read-only

- name: AUTOFILL_TYPE_CARD_EXPIRATION_MONTH
summary: Specifies the expectation of a card expectation month.
summary: Specifies the expectation of a card expiration month.
type: String
platforms: [android]
since: "6.3.0"
osver: {android: {min: "8.0"}}
permission: read-only

- name: AUTOFILL_TYPE_CARD_EXPIRATION_YEAR
summary: Specifies the expectation of a card expectation year.
summary: Specifies the expectation of a card expiration year.
type: String
platforms: [android]
since: "6.3.0"
osver: {android: {min: "8.0"}}
permission: read-only

- name: AUTOFILL_TYPE_NEW_PASSWORD
summary: Specifies the expectation of a new password.
type: String
platforms: [iphone, ipad]
since: "7.4.0"
osver: { ios: { min: "12.0" } }
permission: read-only

- name: AUTOFILL_TYPE_ONE_TIME_CODE
summary: Specifies the expectation of a single-factor SMS login code.
type: String
platforms: [iphone, ipad]
since: "7.4.0"
osver: { ios: { min: "12.0" } }
permission: read-only

- name: AUTOLINK_MAP_ADDRESSES
summary: Converts strings formatted as addresses into clickable links.
description: |
Expand Down
24 changes: 18 additions & 6 deletions iphone/Classes/TiUITextWidget.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2015 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2009-2018 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
Expand Down Expand Up @@ -161,22 +161,34 @@ - (void)setAutofillType_:(id)value
ENSURE_TYPE_OR_NIL(value, NSString);

if (![TiUtils isIOS10OrGreater]) {
NSLog(@"[ERROR] The 'autofillHint' property is only available on iOS 10 and later.");
NSLog(@"[ERROR] The 'autofillType' property is only available on iOS 10 and later.");
return;
}

[[self textWidgetView] setTextContentType:[TiUtils stringValue:value]];
}

#pragma mark Responder methods
//These used to be blur/focus, but that's moved to the proxy only.
//The reason for that is so checking the toolbar can use UIResponder methods.

- (void)setPasswordMask_:(id)value
{
[[self textWidgetView] setSecureTextEntry:[TiUtils boolValue:value]];
}

#if IS_XCODE_10
- (void)setPasswordRules_:(NSString *)passwordRules
{
ENSURE_TYPE_OR_NIL(passwordRules, NSString);

if (![TiUtils isIOSVersionOrGreater:@"12.0"]) {
NSLog(@"[ERROR] The 'passwordRules' property is only available on iOS 12 and later.");
return;
}

[[self textWidgetView] setPasswordRules:[UITextInputPasswordRules passwordRulesWithDescriptor:passwordRules]];
}
#endif

#pragma mark Responder methods

- (void)setAppearance_:(id)value
{
NSString *className = [NSStringFromClass([self class]) substringFromIndex:4];
Expand Down
4 changes: 4 additions & 0 deletions iphone/Classes/UIModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,10 @@ - (NSNumber *)ATTRIBUTE_LINE_BREAK_BY_TRUNCATING_MIDDLE
MAKE_SYSTEM_STR(AUTOFILL_TYPE_USERNAME, UITextContentTypeUsername);
MAKE_SYSTEM_STR(AUTOFILL_TYPE_PASSWORD, UITextContentTypePassword);
#endif
#if IS_XCODE_10
MAKE_SYSTEM_STR(AUTOFILL_TYPE_NEW_PASSWORD, UITextContentTypeNewPassword);
MAKE_SYSTEM_STR(AUTOFILL_TYPE_ONE_TIME_CODE, UITextContentTypeOneTimeCode);
#endif
#endif

#ifdef USE_TI_UICLIPBOARD
Expand Down