Skip to content
Merged
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
16 changes: 12 additions & 4 deletions android/src/main/java/com/multiplemodals/RNTModalView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ class RNTModalView(context: Context): ViewGroup(context), LifecycleEventListener
}
}

fun dismiss() {
reactContext.removeLifecycleEventListener(this)

// Should be call before 'modalDialog.dismiss' to ensure reanimated children are removed correctly
modalView.removeAllViews()

modalDialog.dismiss()
}

private fun attackBackHandler() {
// Prevent closing from native part as this is handled by JS
modalDialog.setOnKeyListener(object : DialogInterface.OnKeyListener {
Expand Down Expand Up @@ -97,23 +106,22 @@ class RNTModalView(context: Context): ViewGroup(context), LifecycleEventListener

override fun removeAllViews() {
super.removeAllViews()
modalView.removeAllViews()
dismiss()
}

// Layout

override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
modalDialog.dismiss()
dismiss()
}

override fun onLayout(p0: Boolean, p1: Int, p2: Int, p3: Int, p4: Int) {
// Handled by Yoga
}

override fun onHostDestroy() {
reactContext.removeLifecycleEventListener(this)
modalDialog.dismiss()
dismiss()
}

override fun onHostPause() {
Expand Down