UI.Accordion

From GiderosMobile

Available since: Gideros 2023.1
Class: UI

Description

Creates an Accordion widget.

UI.Accordion.new()

Example

local values={
	{ title="Alice's Adventures in Wonderland",
	book=[[
	Alice's Adventures in Wonderland (commonly Alice in Wonderland) is an 1865 English children's novel by Lewis Carroll, a mathematics don at Oxford University. It details the story of a young girl named Alice who falls through a rabbit hole into a fantasy world of anthropomorphic creatures. It is seen as an example of the literary nonsense genre. The artist John Tenniel provided 42 wood-engraved illustrations for the book.
	 
	It received positive reviews upon release and is now one of the best-known works of Victorian literature; its narrative, structure, characters and imagery have had a widespread influence on popular culture and literature, especially in the fantasy genre.[1][2] It is credited as helping end an era of didacticism in children's literature, inaugurating an era in which writing for children aimed to "delight or entertain".[3] The tale plays with logic, giving the story lasting popularity with adults as well as with children.[4] The titular character Alice shares her name with Alice Liddell, a girl Carroll knew.
	 
	The book has never been out of print and has been translated into 174 languages. Its legacy covers adaptations for screen, radio, art, ballet, opera, musicals, theme parks, board games and video games.[5] Carroll published a sequel in 1871 entitled Through the Looking-Glass and a shortened version for young children, The Nursery "Alice" in 1890. ]]
	},
	{ title="Peter and Wendy",
	book=[[
	Peter Pan; or, the Boy Who Wouldn't Grow Up, often known simply as Peter Pan, is a work by J. M. Barrie, in the form of a 1904 play and a 1911 novel titled Peter and Wendy, often extended in Peter Pan and Wendy. Both versions tell the story of Peter Pan, a mischievous little boy who can fly, and has many adventures on the island of Neverland that is inhabited by mermaids, fairies, Native Americans, and pirates. The Peter Pan stories also involve the characters Wendy Darling and her two brothers John and Michael, Peter's fairy Tinker Bell, the Lost Boys, and the pirate Captain Hook. The play and novel were inspired by Barrie's friendship with the Llewelyn Davies family.
	 
	The play debuted at the Duke of York's Theatre in London on 27 December 1904 with Nina Boucicault, daughter of the playwright Dion Boucicault, in the title role. A Broadway production was mounted in 1905 starring Maude Adams. It was later revived with such actresses as Marilyn Miller and Eva Le Gallienne. Barrie continued to revise the play for years after its debut until publication of the play script in 1928, under the name Peter Pan; or, The Boy Who Would Not Grow Up.
	 
	Prior to the publication of Barrie's novel, the play was first adapted into the 1907 novelisation The Peter Pan Picture Book, written by Daniel O'Connor and illustrated by Alice B. Woodward. This was also the first illustrated version of the story. The novel was first published in 1911 by Hodder & Stoughton in the UK, and Charles Scribner's Sons in the US. The original book contains a frontispiece and 11 half-tone plates by the artist F. D. Bedford (whose illustrations are still under copyright in the EU). The novel was first abridged by May Byron in 1915, with Barrie's permission, and published under the title Peter Pan and Wendy, the first time this form was used. This version was later illustrated by Mabel Lucie Attwell in 1921.
	 
	Since its original production, the story has been adapted as a pantomime, a stage musical, a television special, a live themed ice-skating show in the mid--1970's, and several films, including a 1924 silent film, a 1953 Disney animated film, and a 2003 live action film. The play is now rarely performed in its original form on stage in the UK, whereas pantomime adaptations are frequently staged around Christmas. In the U.S., the original version has also been supplanted in popularity by the 1954 musical version, which became popular on television. In 1929, Barrie gave the copyright of the Peter Pan works to Great Ormond Street Hospital, a children's hospital in London. ]]
	}
}
 
local vp=UI.Viewport.new()
--vp:setDimensions(application:getContentWidth(),application:getContentHeight())
vp:setDimensions(480, 320)
vp:setScrollbar({UI.Viewport.SCROLLBAR.AUTO,UI.Viewport.SCROLLBAR.ALWAYS})
 
local ac=UI.Accordion.new()
vp:setContent(ac)
ac:setLayoutConstraints({fill=1})
 
local function builder(v)
	local hdr=UI.Label.new(v.title)
	hdr:setStyle({ font="font.bold", ["label.color"]="colHighlight", colWidgetBack="colHeader"})
	local lb=UI.Label.new(v.book,{ flags=FontBase.TLF_BREAKWORDS|FontBase.TLF_REF_TOP })
	-- Return header and content
	return hdr,lb
end
ac:setData(values,builder) --builder function will be called for each value in the values table
 
stage:addChild(vp)