Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce SlotTableInspector tool for Compose. #142

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zach-klippenstein
Copy link
Collaborator

@zach-klippenstein zach-klippenstein commented Aug 12, 2021

This introduces a new module, slot-table-inspector, which provides two composable functions for peeking under the Compose hood to look at the slot table. They can be used like this:

@Composable fun App() {
  val inspectorState = remember { SlotTableInspectorState() }
  var showInspector by remember { mutableStateOf(false) }

  // This defines the content to inspect (roughly).
  SlotTableInspectable(inspectorState) {
    Column {
      Button(onClick = {
        inspectorState.captureSlotTables()
        showInspector = true
      }) {
        Text("Inspect")
      }
    }
  }

  if (showInspector) {
    Dialog {
      // This reads the slot tables from all SlotTableInspectables and displays them.
      SlotTableInspector(inspectorState)
    }
  }
}

This change also adds it into the sample app. To play with it, just check out this branch and run the Compose sample app! (It works best on a tablet.)

Kapture.2021-08-12.at.15.15.29.mp4
Kapture.2021-08-12.at.15.24.12.mp4

TODO

  • Write some UI tests.
  • Better name for the module/artifact than slot-table-inspector?
  • Naming of composable functions?
  • Package of stuff in new module?
  • Make the stuff in the new module experimental/opt-in.
  • Add a section to the repo README about this API.

@zach-klippenstein zach-klippenstein force-pushed the zachklipp/slot-table-explorer branch from f75d8c8 to f32c9e1 Compare August 12, 2021 22:40
@zach-klippenstein zach-klippenstein changed the title Introduce SlotTableInspector API for Compose. Introduce SlotTableInspector tool for Compose. Aug 13, 2021
@zach-klippenstein zach-klippenstein force-pushed the zachklipp/slot-table-explorer branch from f32c9e1 to 5237290 Compare August 17, 2021 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants