Skip to content

Commit

Permalink
Merge pull request #6956 from hansemannn/TIMOB-19150
Browse files Browse the repository at this point in the history
[TIMOB-19150] Update apidoc for QuickType on iOS 9
  • Loading branch information
cheekiatng committed Aug 3, 2015
2 parents 5d3ae51 + a9462f3 commit 16f7959
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 7 deletions.
12 changes: 10 additions & 2 deletions apidoc/Titanium/UI/TextArea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ properties:
- name: autocorrect
summary: Determines whether to automatically correct text entered into this text area.
description: |
Set to `true` to enable automatic spelling correction.
Set to `true` to enable automatic spelling correction. On iOS 9+, this can be used to disable QuickType suggestions.
If this property is not explicitly defined, it behaves as though it were set to `true`.
Expand Down Expand Up @@ -306,7 +306,15 @@ properties:
default: true
platforms: [iphone,ipad]
since: 2.1.2


- name: showUndoRedoActions
summary: Determinates if the undo and redo buttons on the left side of the keyboard should be displayed or not. Only valid on iOS9 and above.
type: Boolean
default: true
platforms: [ipad]
osver: {ios: {min: "9.0"}}
since: 4.3.0

- name: suppressReturn
summary: Determines if the return key should be suppressed during text entry.
type: Boolean
Expand Down
12 changes: 10 additions & 2 deletions apidoc/Titanium/UI/TextField.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ properties:
summary: |
Determines whether to automatically correct text entered into this text field.
description: |
Set to `true` to enable automatic spelling correction.
Set to `true` to enable automatic spelling correction. On iOS 9+, this can be used to disable QuickType suggestions.
If this property is not explicitly defined, it behaves as though it were set to `true`.
Expand Down Expand Up @@ -478,7 +478,15 @@ properties:
permission: read-only
platforms: [iphone, ipad, android]
since: "3.3.0"


- name: showUndoRedoActions
summary: Determinates if the undo and redo buttons on the left side of the keyboard should be displayed or not. Only valid on iOS9 and above.
type: Boolean
default: true
platforms: [ipad]
osver: {ios: {min: "9.0"}}
since: 4.3.0

- name: textAlign
summary: Text alignment within this text field.
type: [String, Number]
Expand Down
46 changes: 45 additions & 1 deletion apidoc/Titanium/UI/iOS/SplitWindow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,54 @@ examples:
});
splitWin.open();
- title: Alloy XML Markup
example: |
Below is an Alloy version of the previous example. The first window is the `masterView` and the second window is the `detailView`. You can also use the `<Require>` element to add a `<Window>` or `<NavigationWindow>`.
**views/index.xml:**
<Alloy>
<SplitWindow backgroundColor="white" showMasterInPortrait="true">
<!-- First window is the masterView -->
<NavigationWindow>
<Window title="Master View">
<ListView>
<ListSection headerTitle="Some items">
<ListItem title="Item 1"></ListItem>
<ListItem title="Item 2"></ListItem>
<ListItem title="Item 3"></ListItem>
</ListSection>
</ListView>
</Window>
</NavigationWindow>
<!-- Second window is the detailView -->
<NavigationWindow>
<Window title="Detail View">
<Label>I am the detail view.</Label>
</Window>
</NavigationWindow>
</SplitWindow>
</Alloy>
**controllers/index.js:**
$.index.addEventListener('visible',function(e){
if (e.view == 'detail'){
e.button.title = "Master";
$.index.detailView.getWindow().leftNavButton = e.button;
} else if (e.view == 'master'){
$.index.detailView.getWindow().leftNavButton = null;
}
});
$.index.open();
---
name: animationOption
summary: |
Optional parameter for [setShowMasterInPortrait](Titanium.UI.iOS.SplitWindow.setShowMasterInPortrait) and
Optional parameter for [setShowMasterInPortrait](Titanium.UI.iOS.SplitWindow.setShowMasterInPortrait) and
[setMasterIsOverlayed](Titanium.UI.iOS.SplitWindow.setMasterIsOverlayed) methods.
description: |
On iOS, use the optional parameter `animated` to animate changes to masterView display mode in portrait orientation. For example
Expand Down
3 changes: 3 additions & 0 deletions iphone/Classes/TiUITextArea.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
NSRange lastSelectedRange;
}

@property(nonatomic,readwrite,assign) NSArray* leadingBarButtonGroups;
@property(nonatomic,readwrite,assign) NSArray* trailingBarButtonGroups;

@end

#endif
25 changes: 25 additions & 0 deletions iphone/Classes/TiUITextArea.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event

@implementation TiUITextArea

@synthesize leadingBarButtonGroups, trailingBarButtonGroups;

#pragma mark Internal

-(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds
Expand Down Expand Up @@ -102,6 +104,12 @@ -(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds

textViewImpl.text = @""; //Setting TextArea text to empty string

// iOS9 QuickType (undo/redo)
if([TiUtils isIOS9OrGreater] == YES) {
self.leadingBarButtonGroups = textViewImpl.inputAssistantItem.leadingBarButtonGroups;
self.trailingBarButtonGroups = textViewImpl.inputAssistantItem.trailingBarButtonGroups;
}

textWidgetView = textViewImpl;

}
Expand All @@ -123,6 +131,23 @@ -(void)adjustOffsetIfRequired:(UITextView*)tv

#pragma mark Public APIs

-(void)setShowUndoRedoActions_:(id)value
{
if(![TiUtils isIOS9OrGreater]){
return;
}

UITextView *tv = (UITextView *)[self textWidgetView];

if([TiUtils boolValue:value] == YES) {
tv.inputAssistantItem.leadingBarButtonGroups = self.leadingBarButtonGroups;
tv.inputAssistantItem.trailingBarButtonGroups = self.trailingBarButtonGroups;
} else {
tv.inputAssistantItem.leadingBarButtonGroups = @[];
tv.inputAssistantItem.trailingBarButtonGroups = @[];
}
}

-(void)setEnabled_:(id)value
{
BOOL _trulyEnabled = ([TiUtils boolValue:value def:YES] && [TiUtils boolValue:[[self proxy] valueForUndefinedKey:@"editable"] def:YES]);
Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/TiUITextField.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
@property(nonatomic,readwrite,assign) CGFloat paddingRight;
@property(nonatomic,readwrite,assign) CGFloat leftButtonPadding;
@property(nonatomic,readwrite,assign) CGFloat rightButtonPadding;
@property(nonatomic,readwrite,assign) NSArray* leadingBarButtonGroups;
@property(nonatomic,readwrite,assign) NSArray* trailingBarButtonGroups;

-(void)setTouchHandler:(TiUIView*)handler;

Expand Down
27 changes: 25 additions & 2 deletions iphone/Classes/TiUITextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@implementation TiTextField

@synthesize leftButtonPadding, rightButtonPadding, paddingLeft, paddingRight;
@synthesize leftButtonPadding, rightButtonPadding, paddingLeft, paddingRight, leadingBarButtonGroups, trailingBarButtonGroups;

-(void)configure
{
Expand All @@ -31,7 +31,13 @@ -(void)configure
paddingLeft = 0;
paddingRight = 0;
[super setLeftViewMode:UITextFieldViewModeAlways];
[super setRightViewMode:UITextFieldViewModeAlways];
[super setRightViewMode:UITextFieldViewModeAlways];

// iOS9 QuickType (undo/redo)
if([TiUtils isIOS9OrGreater] == YES) {
leadingBarButtonGroups = self.inputAssistantItem.leadingBarButtonGroups;
trailingBarButtonGroups = self.inputAssistantItem.trailingBarButtonGroups;
}
}

-(void)dealloc
Expand Down Expand Up @@ -296,6 +302,23 @@ - (void) dealloc

#pragma mark Public APIs

-(void)setShowUndoRedoActions_:(id)value
{
if(![TiUtils isIOS9OrGreater]){
return;
}

TiTextField* tv = (TiTextField*)[self textWidgetView];

if([TiUtils boolValue:value] == YES) {
tv.inputAssistantItem.leadingBarButtonGroups = [tv leadingBarButtonGroups];
tv.inputAssistantItem.trailingBarButtonGroups = [tv trailingBarButtonGroups];
} else {
tv.inputAssistantItem.leadingBarButtonGroups = @[];
tv.inputAssistantItem.trailingBarButtonGroups = @[];
}
}

-(void)setPaddingLeft_:(id)value
{
TiTextField* tv = (TiTextField*)[self textWidgetView];
Expand Down

0 comments on commit 16f7959

Please sign in to comment.