| 7 | namespace bdn |
| 8 | { |
| 9 | void ButtonPage::init() |
| 10 | { |
| 11 | stylesheet = FlexJsonStringify({"flexGrow" : 1.0}); |
| 12 | |
| 13 | auto textBtn = std::make_shared<Button>(); |
| 14 | textBtn->label = "Hello World"; |
| 15 | addChildView(makeRow("Text Button", textBtn)); |
| 16 | |
| 17 | auto imageBtn = std::make_shared<Button>(); |
| 18 | imageBtn->imageURL = "image://main/images/white-small-icon.png"; |
| 19 | addChildView(makeRow("Image Button", imageBtn)); |
| 20 | |
| 21 | _toggleButton = std::make_shared<Button>(); |
| 22 | _toggleButton->label = "Click Me"; |
| 23 | _toggleButton->onClick() += [&](auto) { |
| 24 | if (_toggleState) { |
| 25 | _toggleButton->label = "Click Me"; |
| 26 | } else { |
| 27 | _toggleButton->imageURL = "image://main/images/white-small-icon.png"; |
| 28 | } |
| 29 | |
| 30 | _toggleState = !_toggleState; |
| 31 | }; |
| 32 | |
| 33 | addChildView(makeRow("Image/Text Button", _toggleButton)); |
| 34 | } |
| 35 | } |