Add AddTextItem method on the list component

This commit is contained in:
Adrian-George Bostan 2018-11-16 22:31:36 +02:00
parent ff8557824c
commit 2932b81dc2

View File

@ -86,6 +86,20 @@ func (l *List) Add(item VectorDrawable) (*TextChunk, error) {
return &listItem.marker, nil
}
// AddTextItem appends a new item with the specified text to the list.
// The method creates a styled paragraph with the specified text and returns
// it so that the item style can be customized.
// The method also returns the marker used for the newly added item.
// The marker object can be used to change the text and style of the marker
// for the current item.
func (l *List) AddTextItem(text string) (*StyledParagraph, *TextChunk, error) {
item := newStyledParagraph(l.defaultStyle)
item.Append(text)
marker, err := l.Add(item)
return item, marker, err
}
// Marker returns the marker used for the list items.
// The marker instance can be used the change the text and the style
// of newly added list items.