SequenceDiagramScope

interface SequenceDiagramScope

Defines the DSL used to specify sequence diagrams. Receiver of the content parameter of the SequenceDiagram composable.

Samples

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp
import com.zachklipp.seqdiag.ArrowHeadType
import com.zachklipp.seqdiag.BasicSequenceDiagramStyle
import com.zachklipp.seqdiag.Label
import com.zachklipp.seqdiag.LineStyle
import com.zachklipp.seqdiag.Note
import com.zachklipp.seqdiag.SequenceDiagram
import com.zachklipp.seqdiag.arrowHeadType
import com.zachklipp.seqdiag.color
import com.zachklipp.seqdiag.createParticipant
import com.zachklipp.seqdiag.noteOver
fun main() { 
   //sampleStart 
   // Specifies a simple sequence diagram that consists of three participants with some lines
// between them.
SequenceDiagram {
    val alice = createParticipant { Note("Alice") }
    val bob = createParticipant { Note("Bob") }
    val carlos = createParticipant { Note("Carlos") }

    // Lines can be specified between any two participants, with their
    alice.lineTo(bob)
        .label { Label("Hello!") }
    bob.lineTo(carlos)
        .label { Label("Alice says hi") }

    // Lines don't need to have labels, and they can be styled.
    carlos.lineTo(bob)
        .color(Color.Blue)
        .arrowHeadType(ArrowHeadType.Outlined)

    // Lines can span multiple participants.
    carlos.lineTo(alice)
        .label { Label("Hello back!") }
} 
   //sampleEnd
}
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp
import com.zachklipp.seqdiag.ArrowHeadType
import com.zachklipp.seqdiag.BasicSequenceDiagramStyle
import com.zachklipp.seqdiag.Label
import com.zachklipp.seqdiag.LineStyle
import com.zachklipp.seqdiag.Note
import com.zachklipp.seqdiag.SequenceDiagram
import com.zachklipp.seqdiag.arrowHeadType
import com.zachklipp.seqdiag.color
import com.zachklipp.seqdiag.createParticipant
import com.zachklipp.seqdiag.noteOver
fun main() { 
   //sampleStart 
   // In addition to lines, notes can also be placed around participants.
SequenceDiagram {
    val alice = createParticipant { Note("Alice") }
    createParticipant { Note("Bob") }
    val carlos = createParticipant { Note("Carlos") }

    noteToStartOf(alice) { Note("Note to the start of Alice") }
    noteOver(alice) { Note("Note over Alice") }
    noteToEndOf(alice) { Note("Note to the end of Alice") }

    noteOver(alice, carlos) { Note("Note over multiple participants") }
} 
   //sampleEnd
}

Functions

Link copied to clipboard
abstract fun createParticipant(topLabel: @Composable () -> Unit?, bottomLabel: @Composable () -> Unit?): Participant

Creates a Participant in the sequence. Each participant typically is typically labeled and has a vertical line drawn through the height of the diagram. The rest of the diagram is specified as lines between participants and notes anchored to them. Participants are placed horizontally from start to end in the order they're created.

Link copied to clipboard
abstract infix fun Participant.lineTo(other: Participant): LineBuilder

Specifies a line drawn from this Participant to other. The optional properties of the line can be configured by calling methods on the returned LineBuilder.

Link copied to clipboard
abstract fun noteOver(participants: Collection<Participant>, label: @Composable () -> Unit)

Specifies a composable that represents a note that is placed "over", or covering, one or more participants.

Link copied to clipboard
abstract fun noteToEndOf(participant: Participant, label: @Composable () -> Unit)

Specifies a composable that represents a note that is placed on the end side of a single Participant.

Link copied to clipboard
abstract fun noteToStartOf(participant: Participant, label: @Composable () -> Unit)

Specifies a composable that represents a note that is placed on the start side of a single Participants.

Properties

Link copied to clipboard
abstract val diagramStyle: SequenceDiagramStyle

Extensions

Link copied to clipboard
fun SequenceDiagramScope.createParticipant(topAndBottomLabel: @Composable () -> Unit): Participant

Creates a Participant in the sequence. Each participant typically is typically labeled and has a vertical line drawn through the height of the diagram. The rest of the diagram is specified as lines between participants and notes anchored to them. Participants are placed horizontally from start to end in the order they're created.

Link copied to clipboard
fun SequenceDiagramScope.Label(text: String, modifier: Modifier = Modifier)

Standard text styled by the SequenceDiagramStyle. To draw a standard background and border around a label, use the Note composable.

Link copied to clipboard
fun SequenceDiagramScope.Note(text: String, modifier: Modifier = Modifier)

Standard note styled by the SequenceDiagramStyle. To just draw text without the border use the Label composable. To use your own composables with the standard note background and border, use NoteBox.

Link copied to clipboard
inline fun SequenceDiagramScope.NoteBox(modifier: Modifier = Modifier, content: @Composable BoxScope.() -> Unit)

A Box that is styled according to the SequenceDiagramStyle's note properties.

Link copied to clipboard
fun SequenceDiagramScope.noteOver(    firstParticipant: Participant,     vararg otherParticipants: Participant,     label: @Composable () -> Unit)

Specifies a composable that represents a note that is placed "over", or covering, one or more Participants.

Sources

Link copied to clipboard