Package 

Interface DestinationWrapper


  • 
    public interface DestinationWrapper
    
                        

    Interface you can implement with an object and then pass its class to the com.ramcosta.composedestinations.annotation.Destination.wrappers.

    It lets you extract common logic or UI from your screens out to a reusable piece of code.

    Note that the wrapper can still access its own ViewModel or any other state holder you need in its Wrap method.

    DestinationScope is Wraps receiver and it allows you to get a hold of anything you may need here including the destination the wrapper is wrapping at the any given time (DestinationScope.destination), etc.

    USAGE EXAMPLE 1

    You can have multiple screens behind a PIN the user needs to enter. Using this feature for this use case means:

    • No need to change all of the affected screens' logic

    • No need to navigate to a intermediate screen (which is specially annoying if the final screen has navigation arguments).

    USAGE EXAMPLE 2

    You can also use it to display the state of the internet connection for example. Just use a Box with a top right corner icon that shows up above the screen content whenever the connectivity is lost.

    • Method Summary

      Modifier and Type Method Description
      abstract <T extends Any> Unit Wrap(DestinationScope<T> $self, Function0<Unit> screenContent) Method that will be called when the annotated Destination gets navigated to.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • Wrap

        @Composable() abstract <T extends Any> Unit Wrap(DestinationScope<T> $self, Function0<Unit> screenContent)

        Method that will be called when the annotated Destination gets navigated to.

        Parameters:
        screenContent - is the Composable lambda which will call the real screen.