Skip to content

Commit 05892b8

Browse files
committed
fix: add changes to TypescriptMessagingApp as well
1 parent 54efad2 commit 05892b8

File tree

1 file changed

+32
-1
lines changed
  • examples/TypeScriptMessaging/android/app/src/main/java/com/typescriptmessaging

1 file changed

+32
-1
lines changed

examples/TypeScriptMessaging/android/app/src/main/java/com/typescriptmessaging/MainActivity.kt

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,38 @@ import com.facebook.react.ReactActivityDelegate
55
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
66
import com.facebook.react.defaults.DefaultReactActivityDelegate
77

8+
import android.os.Bundle
9+
import android.os.Build
10+
import android.view.View
11+
import androidx.core.view.ViewCompat
12+
import androidx.core.view.WindowInsetsCompat
13+
import androidx.core.view.updatePadding
14+
815
class MainActivity : ReactActivity() {
16+
17+
override fun onCreate(savedInstanceState: Bundle?) {
18+
super.onCreate(null)
19+
20+
if (Build.VERSION.SDK_INT >= 35) {
21+
val rootView = findViewById<View>(android.R.id.content)
22+
23+
24+
ViewCompat.setOnApplyWindowInsetsListener(rootView) { view, insets ->
25+
val bars = insets.getInsets(
26+
WindowInsetsCompat.Type.systemBars()
27+
or WindowInsetsCompat.Type.displayCutout()
28+
or WindowInsetsCompat.Type.ime() // adding the ime's height
29+
)
30+
rootView.updatePadding(
31+
left = bars.left,
32+
top = bars.top,
33+
right = bars.right,
34+
bottom = bars.bottom
35+
)
36+
WindowInsetsCompat.CONSUMED
37+
}
38+
}
39+
}
940
/**
1041
* Returns the name of the main component registered from JavaScript. This is used to schedule
1142
* rendering of the component.
@@ -18,4 +49,4 @@ class MainActivity : ReactActivity() {
1849
*/
1950
override fun createReactActivityDelegate(): ReactActivityDelegate =
2051
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
21-
}
52+
}

0 commit comments

Comments
 (0)