Skip to content

Commit

Permalink
example/ivy/ios: enable return to continue demo
Browse files Browse the repository at this point in the history
Change-Id: I189cd6b4953aeb988dfb1d28662f228508d463ff
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/360379
Reviewed-by: Rob Pike <[email protected]>
Trust: Rob Pike <[email protected]>
Trust: Russ Cox <[email protected]>
Run-TryBot: Rob Pike <[email protected]>
TryBot-Result: Go Bot <[email protected]>
  • Loading branch information
robaho authored and robpike committed Nov 2, 2021
1 parent 170e11b commit 2ab7fee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ last-change
.idea
.gradle
*.properties
.DS_Store
example/ivy/**/build/
example/ivy/android/gradle/

Expand Down
4 changes: 4 additions & 0 deletions example/ivy/ios/ivy/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
<rect key="contentStretch" x="1" y="1" width="1" height="1"/>
<fontDescription key="fontDescription" name="Menlo-Bold" family="Menlo" pointSize="14"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" keyboardType="alphabet" keyboardAppearance="alert" enablesReturnKeyAutomatically="YES" smartDashesType="no" smartInsertDeleteType="no" smartQuotesType="no"/>
<connections>
<action selector="okPressed:" destination="BYZ-38-t0r" eventType="primaryActionTriggered" id="3BK-xS-ize"/>
<action selector="okPressed:" destination="BYZ-38-t0r" eventType="editingDidEnd" id="91o-Gh-hrf"/>
</connections>
</textField>
<button opaque="NO" contentMode="scaleToFill" horizontalCompressionResistancePriority="1000" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eO6-bM-CwW">
<rect key="frame" x="301.5" y="0.0" width="72.5" height="31"/>
Expand Down
21 changes: 6 additions & 15 deletions example/ivy/ios/ivy/IvyController.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ - (void)viewDidLoad
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];

[self.input becomeFirstResponder];
[self clear:NULL];
}
Expand All @@ -70,18 +70,6 @@ - (BOOL)textFieldShouldEndEditing:(UITextField *)textField
return YES;
}

- (BOOL)textField:(UITextField *)textField
shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)str
{
if ([str isEqualToString:@"\n"]) {
[self enterPressed];
return NO;
}

return YES;
}

- (void)textDidChange:(NSNotification *)notif
{
[self.suggestionView suggestFor:self.input.text];
Expand All @@ -101,7 +89,7 @@ - (void)keyboardWillShow:(NSNotification *)aNotification
[[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
NSNumber *duration =
[info objectForKey:UIKeyboardAnimationDurationUserInfoKey];

UIViewAnimationCurve keyboardTransitionAnimationCurve;
[[info valueForKey:UIKeyboardAnimationCurveUserInfoKey]
getValue:&keyboardTransitionAnimationCurve];
Expand Down Expand Up @@ -190,6 +178,7 @@ - (void)enterPressed
}
self.input.text = @"";
}
[self.input becomeFirstResponder];
}

- (void)scrollTapeToBottom
Expand All @@ -210,15 +199,17 @@ - (void)loadDemo
{
[self.okButton setHidden:FALSE];
NSString *text = DemoText();

self->demo_lines = [text componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
self->demo_index = 0;
self.input.text = @"";
self.input.enablesReturnKeyAutomatically=TRUE;
[self enterPressed];
}
- (void)unloadDemo
{
[self.okButton setHidden:TRUE];
self.input.enablesReturnKeyAutomatically=FALSE;
self->demo_lines=NULL;
self.input.text = @"";
}
Expand Down

0 comments on commit 2ab7fee

Please sign in to comment.