Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
2c97d95
RN 65
swabbass Oct 11, 2021
52a7345
RN66
swabbass Oct 11, 2021
5428b47
disable running e2es as units
swabbass Oct 11, 2021
dea5777
use Hermes + Fix Reanimated
swabbass Oct 11, 2021
5df9087
update reanimated and use babel plugin
swabbass Oct 11, 2021
52acbab
Enable coverage
swabbass Oct 11, 2021
158adf1
Merge branch 'master' into RN66
swabbass Oct 11, 2021
6757c16
Upgrade jest and babel to 27
swabbass Oct 12, 2021
ce6738b
enable JS e2e add animatable to transform ignore
swabbass Oct 12, 2021
3cc05b2
use babel jest as transformer instead of the react native one
swabbass Oct 12, 2021
2f2b0e3
Merge branch 'master' into RN66
swabbass Oct 12, 2021
99f3935
update android to 30
swabbass Oct 12, 2021
06cfe63
Fix overlay insets and use non deprecated methods
swabbass Oct 12, 2021
37eadcb
Merge branch 'RN66' of https://github.com/wix/react-native-navigation…
swabbass Oct 12, 2021
ba9fe1d
Kotlin convert
swabbass Oct 13, 2021
aff2b87
tmp status
swabbass Oct 14, 2021
ad952af
Update Detox to support iOS 15
svbutko Oct 22, 2021
11f17b9
Merge branch 'master' into RN66
yogevbd Oct 24, 2021
52970e8
Merge branch 'master' into RN66
swabbass Oct 26, 2021
8c9e3ba
Fix e2e
yogevbd Oct 26, 2021
1c9faca
Merge branch 'RN66' of https://github.com/wix/react-native-navigation…
swabbass Oct 26, 2021
c0d459a
tests pass
swabbass Oct 27, 2021
030a3d0
Squashed commit of the following:
swabbass Nov 9, 2021
33f45ed
migrate status bar options
swabbass Nov 9, 2021
b2a28cb
fix units tests
swabbass Nov 9, 2021
977606e
Squashed commit of the following:
swabbass Nov 10, 2021
2459533
Status + Navigation Bar take 1
swabbass Nov 10, 2021
81e3c17
cover status bar cases
swabbass Nov 12, 2021
743a679
system ui tools
swabbass Nov 12, 2021
75c84d9
Rename Status to System Ui
swabbass Nov 12, 2021
64114ba
Fix nav bar reset color
swabbass Nov 13, 2021
8989f3c
resolve warnings
swabbass Nov 15, 2021
a79d715
Update build.gradle
swabbass Nov 15, 2021
66c5242
Pass child controller instead of view
swabbass Nov 15, 2021
85c3177
use in place options of child
swabbass Nov 15, 2021
bf154ec
For presenter we need to have merged options to determine final state
swabbass Nov 15, 2021
19909b1
fix tests
swabbass Nov 15, 2021
c1060cf
Squashed commit of the following:
swabbass Nov 15, 2021
73350c7
Merge branch 'master' into RN66_android_fixes
swabbass Nov 15, 2021
83a2bc4
Revert "resolve warnings"
swabbass Nov 15, 2021
75d0c21
Update TopBar.java
swabbass Nov 15, 2021
9ab4142
Fix Keyboard on Android 30
swabbass Nov 15, 2021
d3c4f98
works for pre 30
swabbass Nov 15, 2021
25f4179
Merge branch 'master' into RN66_android_fixes
yogevbd Nov 16, 2021
e6dabff
Merge branch 'RN66_android_fixes' of https://github.com/wix/react-nat…
swabbass Nov 17, 2021
c55d894
Use SystemUiUtils
swabbass Nov 17, 2021
f37d85e
migrate to use per component insets
swabbass Nov 17, 2021
de51148
Topbar behind status bar, applyTopInset will do the work
swabbass Nov 17, 2021
c406db2
Update ComponentLayout.java
swabbass Nov 17, 2021
3787693
Using non deprecated code for such cases
swabbass Nov 17, 2021
51be8a4
override blur view attributes that crashes SET demo
swabbass Nov 17, 2021
5dedbb3
Migrate to Reanimated 2
swabbass Nov 17, 2021
2de93e0
evaluated values should be float not int
swabbass Nov 17, 2021
2d0562b
Fix unit tests
swabbass Nov 17, 2021
6d084c2
Update package.json
swabbass Nov 17, 2021
21f6b86
add Overlay example
swabbass Nov 17, 2021
0a5cea5
revert handy navbar toggle in options
swabbass Nov 17, 2021
83388cc
Merge branch 'master' into RN66_android_fixes
swabbass Nov 17, 2021
609e315
Merge branch 'master' into RN66_android_fixes
swabbass Nov 22, 2021
90742d4
Update lib/android/app/src/main/java/com/reactnativenavigation/utils/…
swabbass Nov 24, 2021
77282e9
Using systemUiVisibility flags
swabbass Nov 28, 2021
41d6de0
move the check inside system ui utils
swabbass Nov 29, 2021
8ffa069
handle color properly and make sure on android < 6 it shows black
swabbass Nov 29, 2021
61543c3
Merge branch 'master' into RN66_android_fixes
swabbass Nov 29, 2021
ed2ca67
dynamic coloring
swabbass Nov 29, 2021
91a8c22
note for the flags solution
swabbass Nov 29, 2021
174ee57
fix test
swabbass Nov 29, 2021
f74cfc4
fix e2e
swabbass Nov 29, 2021
d344715
Update ChildController.java
swabbass Nov 29, 2021
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
4 changes: 2 additions & 2 deletions e2e/Modals.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ describe('modal', () => {
it.e2e('dismiss modal with side menu', async () => {
await elementById(TestIDs.MODAL_COMMANDS_BTN).tap();
await elementById(TestIDs.SHOW_SIDE_MENU_MODAL).tap();
await expect(elementByLabel('StatusBar Options')).toBeVisible();
await expect(elementByLabel('System UI Options')).toBeVisible();
await elementById(TestIDs.DISMISS_MODAL_TOPBAR_BTN).tap();
await expect(elementByLabel('StatusBar Options')).not.toBeVisible();
await expect(elementByLabel('System UI Options')).not.toBeVisible();
await expect(elementByLabel('Modal Commands')).toBeVisible();
});
});
6 changes: 3 additions & 3 deletions lib/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ allprojects { p ->
}

dependencies {
implementation "androidx.core:core-ktx:1.3.2"
implementation "androidx.core:core-ktx:1.6.0"
implementation "org.jetbrains.kotlin:$kotlinStdlib:$kotlinVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutinesCore"
implementation "androidx.constraintlayout:constraintlayout:2.0.4"

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.annotation:annotation:1.2.0'
implementation 'com.google.android.material:material:1.2.0-alpha03'

implementation 'com.github.wix-playground:ahbottomnavigation:3.3.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.reactnativenavigation.react.events.EventEmitter;
import com.reactnativenavigation.utils.LaunchArgsParser;
import com.reactnativenavigation.utils.Now;
import com.reactnativenavigation.utils.StatusBarUtils;
import com.reactnativenavigation.utils.SystemUiUtils;
import com.reactnativenavigation.utils.UiThread;
import com.reactnativenavigation.utils.UiUtils;
import com.reactnativenavigation.viewcontrollers.navigator.Navigator;
Expand All @@ -34,6 +34,8 @@

import static com.reactnativenavigation.utils.UiUtils.pxToDp;

import android.app.Activity;

public class NavigationModule extends ReactContextBaseJavaModule {
private static final String NAME = "RNNBridgeModule";

Expand Down Expand Up @@ -88,10 +90,11 @@ public void getLaunchArgs(String commandId, Promise promise) {

private WritableMap createNavigationConstantsMap() {
ReactApplicationContext ctx = getReactApplicationContext();
final Activity currentActivity = ctx.getCurrentActivity();
WritableMap constants = Arguments.createMap();
constants.putString(Constants.BACK_BUTTON_JS_KEY, Constants.BACK_BUTTON_ID);
constants.putDouble(Constants.BOTTOM_TABS_HEIGHT_KEY, pxToDp(ctx, UiUtils.getBottomTabsHeight(ctx)));
constants.putDouble(Constants.STATUS_BAR_HEIGHT_KEY, pxToDp(ctx, StatusBarUtils.getStatusBarHeight(ctx)));
constants.putDouble(Constants.STATUS_BAR_HEIGHT_KEY, pxToDp(ctx, SystemUiUtils.getStatusBarHeight(currentActivity)));
constants.putDouble(Constants.TOP_BAR_HEIGHT_KEY, pxToDp(ctx, UiUtils.getTopBarHeight(ctx)));
return constants;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.reactnativenavigation.react.modal

import android.widget.FrameLayout
import com.facebook.react.bridge.ReactContext
import com.reactnativenavigation.utils.StatusBarUtils
import com.reactnativenavigation.utils.SystemUiUtils

class ModalFrameLayout(context: ReactContext) : FrameLayout(context) {
val modalContentLayout = ModalContentLayout(context)
Expand All @@ -11,9 +11,9 @@ class ModalFrameLayout(context: ReactContext) : FrameLayout(context) {
addView(modalContentLayout, MarginLayoutParams(MarginLayoutParams.WRAP_CONTENT, MarginLayoutParams.WRAP_CONTENT)
.apply {
val translucent = context.currentActivity?.window?.let {
StatusBarUtils.isTranslucent(it)
SystemUiUtils.isTranslucent(it)
} ?: false
topMargin = if (translucent) 0 else StatusBarUtils.getStatusBarHeight(context)
topMargin = if (translucent) 0 else SystemUiUtils.getStatusBarHeight(context.currentActivity)
})
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.reactnativenavigation.react.modal

import android.app.Activity
import android.content.Context
import android.graphics.Point
import android.view.WindowManager
Expand All @@ -21,7 +22,7 @@ import com.reactnativenavigation.options.parseTransitionAnimationOptions
import com.reactnativenavigation.options.parsers.JSONParser
import com.reactnativenavigation.react.CommandListener
import com.reactnativenavigation.react.CommandListenerAdapter
import com.reactnativenavigation.utils.StatusBarUtils
import com.reactnativenavigation.utils.SystemUiUtils
import com.reactnativenavigation.viewcontrollers.navigator.Navigator

private const val MODAL_MANAGER_NAME = "RNNModalViewManager"
Expand Down Expand Up @@ -107,26 +108,26 @@ class ModalViewManager(val reactContext: ReactContext) : ViewGroupManager<ModalH
}
}

private fun getModalHostSize(context: Context): Point {
private fun getModalHostSize(activity: Activity): Point {
val MIN_POINT = Point()
val MAX_POINT = Point()
val SIZE_POINT = Point()
val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
val wm = activity.getSystemService(Context.WINDOW_SERVICE) as WindowManager
val display = Assertions.assertNotNull(wm).defaultDisplay
// getCurrentSizeRange will return the min and max width and height that the window can be
display.getCurrentSizeRange(MIN_POINT, MAX_POINT)
// getSize will return the dimensions of the screen in its current orientation
display.getSize(SIZE_POINT)
val attrs = intArrayOf(android.R.attr.windowFullscreen)
val theme = context.theme
val theme = activity.theme
val ta = theme.obtainStyledAttributes(attrs)
val windowFullscreen = ta.getBoolean(0, false)

// We need to add the status bar height to the height if we have a fullscreen window,
// because Display.getCurrentSizeRange doesn't include it.
var statusBarHeight = 0
if (windowFullscreen) {
statusBarHeight = StatusBarUtils.getStatusBarHeight(context)
statusBarHeight = SystemUiUtils.getStatusBarHeight(activity)
}
return if (SIZE_POINT.x < SIZE_POINT.y) {
// If we are vertical the width value comes from min width and height comes from max height
Expand All @@ -140,8 +141,10 @@ private fun getModalHostSize(context: Context): Point {
private class ModalHostShadowNode : LayoutShadowNode() {
override fun addChildAt(child: ReactShadowNodeImpl, i: Int) {
super.addChildAt(child, i)
val modalSize = getModalHostSize(themedContext)
child.setStyleWidth(modalSize.x.toFloat())
child.setStyleHeight(modalSize.y.toFloat())
themedContext?.currentActivity?.let {
val modalSize = getModalHostSize(it)
child.setStyleWidth(modalSize.x.toFloat())
child.setStyleHeight(modalSize.y.toFloat())
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
package com.reactnativenavigation.utils

import android.app.Activity
import android.graphics.Color
import android.graphics.Rect
import android.os.Build
import android.view.View
import android.view.Window
import androidx.annotation.ColorInt
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import kotlin.math.abs
import kotlin.math.ceil


object SystemUiUtils {
private const val STATUS_BAR_HEIGHT_M = 24
private const val STATUS_BAR_HEIGHT_L = 25
private const val STATUS_BAR_HEIGHT_TRANSLUCENCY = 0.65f
private var statusBarHeight = -1
var navigationBarDefaultColor = -1
private set


@JvmStatic
fun getStatusBarHeight(activity: Activity?): Int {
val res = if (statusBarHeight > 0) {
statusBarHeight
} else {
statusBarHeight = activity?.let {
val rectangle = Rect()
val window: Window = activity.window
window.decorView.getWindowVisibleDisplayFrame(rectangle)
val statusBarHeight: Int = rectangle.top
val contentView = window.findViewById<View>(Window.ID_ANDROID_CONTENT)
contentView?.let {
val contentViewTop = contentView.top
abs(contentViewTop - statusBarHeight)
}
} ?: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) STATUS_BAR_HEIGHT_M else STATUS_BAR_HEIGHT_L
statusBarHeight
}
return res
}

@JvmStatic
fun saveStatusBarHeight(height: Int) {
statusBarHeight = height
}


@JvmStatic
fun getStatusBarHeightDp(activity: Activity?): Int {
return UiUtils.pxToDp(activity, getStatusBarHeight(activity).toFloat())
.toInt()
}

@JvmStatic
fun hideNavigationBar(window: Window?, view: View) {
window?.let {
WindowCompat.setDecorFitsSystemWindows(window, false)
WindowInsetsControllerCompat(window, view).let { controller ->
controller.hide(WindowInsetsCompat.Type.navigationBars())
controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
}
}

@JvmStatic
fun showNavigationBar(window: Window?, view: View) {
window?.let {
WindowCompat.setDecorFitsSystemWindows(window, true)
WindowInsetsControllerCompat(window, view).show(WindowInsetsCompat.Type.navigationBars())
}
}

@JvmStatic
fun setStatusBarColorScheme(window: Window?, view: View, isDark: Boolean) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return

window?.let {
WindowInsetsControllerCompat(window, view).isAppearanceLightStatusBars = isDark
// Workaround: on devices with api 30 status bar icons flickers or get hidden when removing view
//turns out it is a bug on such devices, fixed by using system flags until it is fixed.
var flags = view.systemUiVisibility
flags = if (isDark) {
flags or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
} else {
flags and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv()
}

view.systemUiVisibility = flags
}
}

@JvmStatic
fun setStatusBarTranslucent(window: Window?) {
window?.let {
setStatusBarColor(window, window.statusBarColor, true)
}
}

@JvmStatic
fun isTranslucent(window: Window?): Boolean {
return window?.let {
Color.alpha(it.statusBarColor) < 255
} ?: false
}

@JvmStatic
fun clearStatusBarTranslucency(window: Window?) {
window?.let {
setStatusBarColor(it, it.statusBarColor, false)
}
}

@JvmStatic
fun setStatusBarColor(
window: Window?,
@ColorInt color: Int,
translucent: Boolean
) {
val opaqueColor = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
Color.BLACK
}else{
val alpha = if (translucent) STATUS_BAR_HEIGHT_TRANSLUCENCY else 1f
val red: Int = Color.red(color)
val green: Int = Color.green(color)
val blue: Int = Color.blue(color)
Color.argb(ceil(alpha * 255).toInt(), red, green, blue)
}
window?.statusBarColor = opaqueColor
}

@JvmStatic
fun hideStatusBar(window: Window?, view: View) {
window?.let {
WindowCompat.setDecorFitsSystemWindows(window, false)
WindowInsetsControllerCompat(window, view).let { controller ->
controller.hide(WindowInsetsCompat.Type.statusBars())
controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
}
}

@JvmStatic
fun showStatusBar(window: Window?, view: View) {
window?.let {
WindowCompat.setDecorFitsSystemWindows(window, true)
WindowInsetsControllerCompat(window, view).show(WindowInsetsCompat.Type.statusBars())
}
}

@JvmStatic
fun setNavigationBarBackgroundColor(window: Window?, color: Int, lightColor: Boolean) {
window?.let {
if (navigationBarDefaultColor == -1) {
navigationBarDefaultColor = window.navigationBarColor
}
WindowInsetsControllerCompat(window, window.decorView).let { controller ->
controller.isAppearanceLightNavigationBars = lightColor
}
window.navigationBarColor = color
}
}

}
Loading