-
Notifications
You must be signed in to change notification settings - Fork 6
Core Features
Screenplay is driven by a two primary architectural goals:
- Reduce complexity: monolithic UI components with complex lifecycles are bad and should be avoided. Applications should be built out of small, reusable parts
- Reduce friction: objects should be easy to create, and it should be easy to pass data between them.
The library is designed for View-based applications. The idea is to make it possible to run all of the application code in a single Activity, without the need for Fragments or Dialogs. The major features of screenplay include:
A unifying UI abstraction: The building block of a screenplay application is the Stage. Each Stage is associated with single View. Simple screens consist of a single Stage. In more complex scenarios, modal stages can be used to create effects like dialogs, drawers, panels, etc.
Lightweight objects:
Unlike Activities, Fragments or Dialogs, each Stage is a POJO (Plain Old Java Object). There are no factory methods, and no need to serialize data into a Bundle
, or write a Parcelable
implementation just to pass data between screens. Just create new Stage(...)
, pass it some arguments, and you're good to go. As a result, Screenplay is DI-friendly; Dagger is a fun partner.
View hot swapping: Screenplay swaps Views in and out as Stages are pushed and popped from the backstack. Views are removed from their parent when they are no longer needed to avoid leaking memory.
Animated transitions: Screenplay selects animations to play based on the direction of navigation (forward/back) and the state of the Stage (incoming/outgoing). Animations can be specified through XML or code.
Component-oriented architecture: Each Stage can be augmented with Components, which are notified of lifecycle events. Components provide a modular way of attaching behavior to a Stage, encouraging code reuse and separation of concerns.
Separation of display and presentation:
You don't need to put any business logic in View
subclasses in a Screenplay application. Screenplay's powerful component-oriented architecture makes it easy to separate view presentation from display.
Plugin support: Screenplay includes optional support for Flow which is provided as a separate module. Flow provides an interface for managing the backstack, including pushing and popping new Stages from the stack, managing the history, etc.
{- NEXT: The Stage class -}