Skip to content

Commit

Permalink
Added Layout Change Notification (microsoft#4853)
Browse files Browse the repository at this point in the history
* Added options to change styles for error cue for input

* removed erroneous check-in

* dev complete

* Added options to change styles for error cue for input

* removed erroneous check-in

* dev complete

* reverting changes unrelated to this PR
  • Loading branch information
jwoo-msft authored Sep 30, 2020
1 parent 5be9851 commit ef438d1
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ - (instancetype)initWithActionElement:(ACOBaseActionElement *)actionElement root
- (IBAction)send:(UIButton *)sender
{
BOOL hasValidationPassed = YES;
BOOL hasViewChangedForAnyViews = NO;
NSError *error = nil;
NSMutableArray<ACRIBaseInputHandler> *gatheredInputs = [[NSMutableArray<ACRIBaseInputHandler> alloc] init];

Expand All @@ -49,13 +50,16 @@ - (IBAction)send:(UIButton *)sender
[input setFocus:NO view:nil];
}
hasValidationPassed &= validationResult;
hasViewChangedForAnyViews |= input.hasVisibilityChanged;
}
parent = [_view getParent:parent];
}

if (hasValidationPassed) {
[[_view card] setInputs:gatheredInputs];
[_view.acrActionDelegate didFetchUserResponses:[_view card] action:_actionElement];
} else if (hasViewChangedForAnyViews && [_view.acrActionDelegate respondsToSelector:@selector(didChangeViewLayout:newFrame:)]) {
[_view.acrActionDelegate didChangeViewLayout:CGRectNull newFrame:CGRectNull];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,6 @@ - (float)getNonInputWidth:(UITableViewCell *)cell

@synthesize isRequired;
@synthesize hasValidationProperties;
@synthesize hasVisibilityChanged;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,6 @@ - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row f
}
@synthesize isRequired;
@synthesize hasValidationProperties;
@synthesize hasVisibilityChanged;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,6 @@ - (void)configDateFormatter:(NSDateFormatter *)formatter formatterStyle:(NSDateF

@synthesize isRequired;

@synthesize hasVisibilityChanged;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

@property BOOL isRequired;
@property BOOL hasValidationProperties;
@property BOOL hasVisibilityChanged;
@property NSString * _Nonnull id;

- (BOOL)validate:(NSError * _Nullable * _Nullable)error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
@property (strong, nonatomic) NSObject <ACRIBaseInputHandler> *dataSource;
@property BOOL isRequired;
@property BOOL hasErrorMessage;
@property IBInspectable UIColor *validationFailBorderColor;
@property IBInspectable CGFloat validationFailBorderRadius;
@property IBInspectable CGFloat validationFailBorderWidth;
@property IBInspectable CGFloat validationSuccessBorderWidth;


+ (void)commonSetFocus:(BOOL)shouldBecomeFirstResponder view:(UIView *)view;
+ (BOOL)commonTextUIValidate:(BOOL)isRequired hasText:(BOOL)hasText predicate:(NSPredicate *)predicate text:(NSString *)text error:(NSError *__autoreleasing *)error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,21 @@ - (BOOL)validate:(NSError **)error
NSError *error = nil;
if (NO == [inputHandler validate:&error]) {
if (self.hasErrorMessage) {
self.hasVisibilityChanged = self.errorMessage.hidden == YES;
self.errorMessage.hidden = NO;
}
} else {
if (self.hasErrorMessage) {
self.hasVisibilityChanged = self.errorMessage.hidden == NO;
self.errorMessage.hidden = YES;
}
self.stack.arrangedSubviews[1].layer.borderWidth = 0;
self.stack.arrangedSubviews[1].layer.borderWidth = self.validationSuccessBorderWidth;
return YES;
}
}
self.stack.arrangedSubviews[1].layer.borderWidth = 1;
self.stack.arrangedSubviews[1].layer.cornerRadius = 6.0f;
self.stack.arrangedSubviews[1].layer.borderColor = UIColor.systemRedColor.CGColor;
self.stack.arrangedSubviews[1].layer.borderWidth = self.validationFailBorderWidth;
self.stack.arrangedSubviews[1].layer.cornerRadius = self.validationFailBorderRadius;
self.stack.arrangedSubviews[1].layer.borderColor = self.validationFailBorderColor.CGColor;
return NO;
}

Expand Down Expand Up @@ -211,4 +213,6 @@ + (BOOL)commonTextUIValidate:(BOOL)isRequired hasText:(BOOL)hasText predicate:(N

@synthesize id;

@synthesize hasVisibilityChanged;

@end
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ACRInputLabelView">
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="validationFailBorderRadius">
<real key="value" value="5"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="validationFailBorderColor">
<color key="value" systemColor="systemIndigoColor"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="validationSuccessBorderWidth">
<real key="value" value="0.0"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="validationFailBorderWidth">
<real key="value" value="1"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="errorMessage" destination="UhI-YL-bG4" id="mY3-fQ-LVc"/>
<outlet property="label" destination="1Ch-uc-lfs" id="BEl-KZ-Pwn"/>
Expand Down Expand Up @@ -36,4 +50,9 @@
<point key="canvasLocation" x="132" y="132"/>
</stackView>
</objects>
<resources>
<systemColor name="systemIndigoColor">
<color red="0.34509803921568627" green="0.33725490196078434" blue="0.83921568627450982" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang
@synthesize isRequired;
@synthesize hasValidationProperties;
@synthesize id;
@synthesize hasVisibilityChanged;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,6 @@ - (void)textViewDidEndEditing:(UITextView *)textView

@synthesize isRequired;

@synthesize hasVisibilityChanged;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ - (void)setFocus:(BOOL)shouldBecomeFirstResponder view:(UIView *)view

@synthesize isRequired;
@synthesize hasValidationProperties;
@synthesize hasVisibilityChanged;

@end

0 comments on commit ef438d1

Please sign in to comment.