TtPopOverHandler

Shows a given Fragment above all other views in application.

The position of the fragment is determined by the anchor view and can be adjusted relative to it. See Request for details. Actual position of the fragment is updated every time the anchor view changes its position or size.

Intended usage:

class SomeFragment() : Fragment() {
    private val viewModel by viewModels()
    private var popOverHandler: TtPopOverHandler? = null

    fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        viewModel.popOverState
           .map { it?.toPopOverRequest() }
           .observe(viewLifecycleOwner) { request ->
               popOverHandler?.dismissPopOver(receiveOnDismissCallback = false)
               popOverHandler = null

               request?.let {
                   popOverHandler = TtPopOverHandler.showOrRestorePopOver(
                       fragment = this@SomeFragment,
                       anchorView = viewBinding.anchorView,
                       request = it,
                       onDismissListener = { viewModel.onPopOverDismissed() }  // onPopOverDismissed() sets popOverState to null
                   )
               }
           }
    }

    fun doSomethingElse() {
        viewModel.dismissPopOver()  // dismissPopOver() sets popOverState to null
    }
}

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class Request(    val positionsRelativeToAnchor: List<TtPopOverPositionRelativeToAnchor>,     val offsetXRelativeToAnchor: Int = 0,     val offsetYRelativeToAnchor: Int = 0,     @AttrRes val enterAnimatorAttrId: Int? = CoreThemeR.attr.tt_popover_enter,     @AttrRes val exitAnimatorAttrId: Int? = CoreThemeR.attr.tt_popover_exit,     val autoDismissTimeout: TtPopOverHandler.Request.AutoDismissTimeout = AutoDismissTimeout.Disabled,     val dismissOnTouchOutside: Boolean = true,     val shouldHidePlatformSystemUi: Boolean = false,     val tag: String = "default",     val createContentFragment: () -> Fragment)

A class that holds all data necessary to show a popover.

Functions

Link copied to clipboard
fun dismissPopOver(receiveOnDismissCallback: Boolean = true)

Dismisses the popover.