Skip to content

Commit

Permalink
fix: pr improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
maciej.lodygowski committed Sep 20, 2024
1 parent ffe8596 commit 2786464
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
30 changes: 14 additions & 16 deletions package/ios/RNCSliderComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,20 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
if (oldScreenProps.maximumValue != newScreenProps.maximumValue) {
[slider setMaximumValue:newScreenProps.maximumValue];
}
updateLimits(slider, newScreenProps.lowerLimit, newScreenProps.upperLimit);
if (slider.lowerLimit != newScreenProps.lowerLimit) {
if(newScreenProps.lowerLimit > slider.upperLimit){
NSLog(@"Invalid configuration: upperLimit < lowerLimit; lowerLimit not set");
} else {
slider.lowerLimit = newScreenProps.lowerLimit;
}
}
if (slider.upperLimit != newScreenProps.upperLimit) {
if(newScreenProps.upperLimit < slider.lowerLimit){
NSLog(@"Invalid configuration: upperLimit < lowerLimit; upperLimit not set");
} else {
slider.upperLimit = newScreenProps.upperLimit;
}
}
if (oldScreenProps.tapToSeek != newScreenProps.tapToSeek) {
slider.tapToSeek = newScreenProps.tapToSeek;
}
Expand Down Expand Up @@ -267,21 +280,6 @@ - (void)loadImageFromImageSource:(ImageSource)source completionBlock:(RNCLoadIma
}
}

void updateLimits(RNCSlider *slider, float newLowerLimit, float newUpperLimit) {
if (slider.lowerLimit != newLowerLimit) {
slider.lowerLimit = newLowerLimit;
}

if (slider.upperLimit != newUpperLimit) {
slider.upperLimit = newUpperLimit;
}

if (slider.lowerLimit > slider.upperLimit) {
NSLog(@"Invalid configuration: lowerLimit > upperLimit, reverting lowerLimit to upperLimit.");
slider.lowerLimit = slider.upperLimit;
}
}

- (void)setInverted:(BOOL)inverted
{
if (inverted) {
Expand Down
4 changes: 2 additions & 2 deletions package/ios/RNCSliderManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ - (void)sliderTouchEnd:(RNCSlider *)sender
float lowerLimit = [RCTConvert float:json];

if (lowerLimit > view.upperLimit) {
NSLog(@"Invalid configuration: upperLimit < lowerLimit; lowerLimit not set")
NSLog(@"Invalid configuration: upperLimit < lowerLimit; lowerLimit not set");
} else {
view.lowerLimit = lowerLimit;
}
Expand All @@ -171,7 +171,7 @@ - (void)sliderTouchEnd:(RNCSlider *)sender
float upperLimit = [RCTConvert float:json];

if (upperLimit < view.lowerLimit) {
NSLog(@"Invalid configuration: upperLimit < lowerLimit; upperLimit not set")
NSLog(@"Invalid configuration: upperLimit < lowerLimit; upperLimit not set");
} else {
view.upperLimit = upperLimit;
}
Expand Down

0 comments on commit 2786464

Please sign in to comment.