Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed default ViewState #2802

Merged
merged 2 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public void setScheduler(Scheduler scheduler) {
}

public enum ViewState {
Inactive,
Appearing,
Disappearing,
Layout,
Inactive,
ToRemove;
}

Expand Down Expand Up @@ -107,11 +107,11 @@ public void onViewRemoval(View view, ViewGroup parent, Snapshot before, Runnable
HashMap<String, Object> currentValues = before.toCurrentMap();
ViewState state = mStates.get(view.getId());

if (state == null || state == ViewState.Disappearing || state == ViewState.ToRemove) {
if (state == ViewState.Disappearing || state == ViewState.ToRemove) {
return;
}
mCallbacks.put(tag, callback);
if (state == ViewState.Inactive) {
if (state == ViewState.Inactive || state == null) {
if (currentValues != null) {
mStates.put(view.getId(), ViewState.ToRemove);
mToRemove.add(view.getId());
Expand Down Expand Up @@ -232,6 +232,10 @@ private void removeLeftovers() {
// go through ready to remove from bottom to top
for (int tag : mToRemove) {
View view = mViewForTag.get(tag);
if (view == null) {
view = mUIManager.resolveView(tag);
mViewForTag.put(tag, view);
}
findRoot(view, roots);
}
for (int tag : roots) {
Expand Down
2 changes: 1 addition & 1 deletion ios/LayoutReanimation/REAAnimationsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger, ViewState) {
Inactive,
Appearing,
Disappearing,
Layout,
Inactive,
ToRemove,
};

Expand Down
4 changes: 4 additions & 0 deletions ios/LayoutReanimation/REAAnimationsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ - (void)removeLeftovers
NSMutableSet<NSNumber *> *roots = [NSMutableSet new];
for (NSNumber *viewTag in _toRemove) {
UIView *view = _viewForTag[viewTag];
if (view == nil) {
view = [_reaUiManager viewForReactTag:viewTag];
_viewForTag[viewTag] = view;
}
[self findRoot:view roots:roots];
}
for (NSNumber *viewTag in roots) {
Expand Down