| 7 | namespace bdn |
| 8 | { |
| 9 | void VisibilityPage::init() |
| 10 | { |
| 11 | stylesheet = FlexJsonStringify({"flexGrow" : 1.0}); |
| 12 | |
| 13 | auto checkbox = std::make_shared<Checkbox>(); |
| 14 | checkbox->state = TriState::On; |
| 15 | |
| 16 | addChildView(makeRow("Toggle Visibility", checkbox)); |
| 17 | |
| 18 | auto label = std::make_shared<Label>(); |
| 19 | label->text = "Toggly my visibility"; |
| 20 | |
| 21 | auto visRow = makeRow("1.", label); |
| 22 | addChildView(visRow); |
| 23 | |
| 24 | auto label2 = std::make_shared<Label>(); |
| 25 | label2->text = "I stay visible"; |
| 26 | addChildView(makeRow("2.", label2)); |
| 27 | |
| 28 | checkbox->state.onChange() += [visRow](auto &p) { |
| 29 | if (p.get() == TriState::On) { |
| 30 | visRow->visible = true; |
| 31 | } else { |
| 32 | visRow->visible = false; |
| 33 | } |
| 34 | }; |
| 35 | } |
| 36 | } |