Skip to content

Commit

Permalink
chore: refactor medium detent iOS implementation (#1699)
Browse files Browse the repository at this point in the history
## Description

Earlier when calling `updatePresentationStyle` in `RNSScreen` we have
relied on order of method calls and kept our fingers crossed that the
order would not be violated with future changes.

Now we leverage `finalizeUpdates:` method from
`RCTComponentViewProtocol` which is called after all updates are applied
to the component.

For broader context see #1649 (comments).

## Changes

Moved call to `updatePresentationStyle` from `updateProps` to
`finalizeUpdates`.


## Test code and steps to reproduce

See `Test1649` (everything should work as before)

## Checklist

- [x] Ensured that CI passes (iOS e2e is a known issue)
  • Loading branch information
kkafar authored Jan 27, 2023
1 parent b3ab156 commit 04ac6d7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ios/RNSScreen.mm
Original file line number Diff line number Diff line change
Expand Up @@ -693,11 +693,6 @@ - (void)updateProps:(facebook::react::Props::Shared const &)props
[self setStackPresentation:newStackPresentation];
}

#if !TARGET_OS_TV
// This must be called after setter for stackPresentation
[self updatePresentationStyle];
#endif // !TARGET_OS_TV

if (newScreenProps.stackAnimation != oldScreenProps.stackAnimation) {
[self setStackAnimation:[RNSConvert RNSScreenStackAnimationFromCppEquivalent:newScreenProps.stackAnimation]];
}
Expand Down Expand Up @@ -733,6 +728,13 @@ - (void)updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetric
// Explanation taken from `reactSetFrame`, which is old arch equivalent of this code.
}

- (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask
{
#if !TARGET_OS_TV
[self updatePresentationStyle];
#endif // !TARGET_OS_TV
}

#pragma mark - Paper specific
#else

Expand Down

0 comments on commit 04ac6d7

Please sign in to comment.