-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathModalLayoutController.kt
More file actions
49 lines (41 loc) · 1.82 KB
/
ModalLayoutController.kt
File metadata and controls
49 lines (41 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.reactnativenavigation.react.modal
import android.app.Activity
import com.facebook.react.bridge.ReactContext
import com.facebook.react.uimanager.UIManagerHelper
import com.facebook.react.uimanager.UIManagerModule
import com.facebook.react.uimanager.common.UIManagerType
import com.reactnativenavigation.options.Options
import com.reactnativenavigation.react.Constants
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController
import com.reactnativenavigation.viewcontrollers.viewcontroller.YellowBoxDelegate
import com.reactnativenavigation.viewcontrollers.viewcontroller.overlay.ViewControllerOverlay
class ModalLayoutController(
val reactContext: ReactContext,
activity: Activity?,
id: String?,
yellowBoxDelegate: YellowBoxDelegate?,
initialOptions: Options?,
overlay: ViewControllerOverlay?,
val getHostId: () -> Int
) : ViewController<ModalFrameLayout>(activity, id, yellowBoxDelegate, initialOptions, overlay) {
override fun isViewShown(): Boolean {
return !isDestroyed && view != null && view!!.isShown
}
override fun isRendered(): Boolean {
return isViewCreated
}
override fun getCurrentComponentName(): String = "ModalLayoutController"
override fun createView(): ModalFrameLayout {
return ModalFrameLayout(reactContext)
}
override fun sendOnNavigationButtonPressed(buttonId: String?) {
if (buttonId == Constants.HARDWARE_BACK_BUTTON_ID) {
val dispatcher = UIManagerHelper.getEventDispatcher(reactContext, UIManagerType.FABRIC)
dispatcher?.dispatchEvent(RequestCloseModalEvent(getHostId()))
}
}
fun sendShowEvent() {
val dispatcher = UIManagerHelper.getEventDispatcher(reactContext, UIManagerType.FABRIC)
dispatcher?.dispatchEvent(ShowModalEvent(getHostId()))
}
}