-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix header rendering – layout and transparency (#184)
* Let UINavController control subcontroller view's frames. This PR changes the way we've been handling yoga <> NavController layout interactions. Now we ignore frame updates coming from react for the main Screen view to allow NavController take the controll. In order to keep yoga working we now use `setSize` to pass the dimensions of the view back to yoga such that it can properly calculate layout of the views under Screen component. * Header resizing fixes for Android. In this change we use CoordinatorLayout as a stack screen container to handle rendering of toolbar and screen content. Thanks to this approach we can support collapsable bars in the future. Instead of relying on RN to layout screen container when renered under ScreenStack we rely on Android native layout to measure and position screen content and then use UIManager.setNodeSize to communicate that back to react.
- Loading branch information
Showing
10 changed files
with
309 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
android/src/main/java/com/swmansion/rnscreens/ScreenFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.swmansion.rnscreens; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.annotation.Nullable; | ||
import androidx.appcompat.widget.Toolbar; | ||
import androidx.fragment.app.Fragment; | ||
|
||
import com.facebook.react.bridge.ReactContext; | ||
import com.facebook.react.uimanager.UIManagerModule; | ||
import com.facebook.react.uimanager.events.EventDispatcher; | ||
|
||
public class ScreenFragment extends Fragment { | ||
|
||
protected Screen mScreenView; | ||
|
||
public ScreenFragment() { | ||
throw new IllegalStateException("Screen fragments should never be restored"); | ||
} | ||
|
||
@SuppressLint("ValidFragment") | ||
public ScreenFragment(Screen screenView) { | ||
super(); | ||
mScreenView = screenView; | ||
} | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, | ||
@Nullable ViewGroup container, | ||
@Nullable Bundle savedInstanceState) { | ||
return mScreenView; | ||
} | ||
|
||
public Screen getScreen() { | ||
return mScreenView; | ||
} | ||
|
||
@Override | ||
public void onDestroy() { | ||
super.onDestroy(); | ||
((ReactContext) mScreenView.getContext()) | ||
.getNativeModule(UIManagerModule.class) | ||
.getEventDispatcher() | ||
.dispatchEvent(new ScreenDismissedEvent(mScreenView.getId())); | ||
} | ||
} |
Oops, something went wrong.