Created
March 2, 2014 13:07
-
-
Save BenjaminVanRyseghem/9306328 to your computer and use it in GitHub Desktop.
How to make a list render some custom models -- see http://j.mp/1fzQ0HQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
items := (1 to: 5) collect: [ :index || model | | |
model := DynamicComposableModel new | |
instantiateModels: #( | |
nameLabel LabelModel | |
address LabelModel | |
button ButtonModel ). | |
model nameLabel label: 'Name'. | |
model address label: 'Address'. | |
model button | |
label: nil; | |
icon: Smalltalk ui icons smallCancelIcon. | |
model layout: (SpecLayout composed | |
newColumn: [ :c | | |
c add: #nameLabel height: model class buttonHeight. | |
c add: #address height: model class buttonHeight. | |
c newRow: [ :r | | |
r | |
newColumn: [ :col | ]; | |
add: #button width: model class buttonWidth ] height: model class buttonHeight]). | |
model ]. | |
"items first buildWithSpec." | |
model := ListModel new. | |
model items: items. | |
model displayBlock: [ :e | e | |
extent: 200@100; | |
yourself ]. | |
model openWithSpec |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment