createParticipant

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.

This is a convenience method for calling SequenceDiagramScope.createParticipant with the same label at the top and bottom.

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
}

Parameters

topAndBottomLabel

A composable that will be used as the label at the top of the participant. In most cases this should be a Note composable.

Sources

Link copied to clipboard