From eecc378e9643312b6f6bb9abcd397ea007b800ab Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Tue, 2 Aug 2022 15:48:22 +0300 Subject: [PATCH] feat: added visibility documentation --- CHANGELOG.md | 7 +++++++ README.md | 31 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37d6504f..807f55ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## [11.8.0](https://github.com/dlsc-software-consulting-gmbh/PreferencesFX/tree/11.8.0) (2022-08-02) +[Full Changelog](https://github.com/dlsc-software-consulting-gmbh/PreferencesFX/compare/11.6.0...11.8.0) + +**Implemented enhancements:** + +- Added support setting an optional visibility condition for Categories, Groups and Settings + ## [11.7.0](https://github.com/dlsc-software-consulting-gmbh/PreferencesFX/tree/11.7.0) (2020-12-15) [Full Changelog](https://github.com/dlsc-software-consulting-gmbh/PreferencesFX/compare/11.6.0...11.7.0) diff --git a/README.md b/README.md index 6411b9e1..69bf85c6 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ - [Setting types](#setting-types) - [Localisation](#localisation) - [Validation](#validation) +- [Visibility](#visibility) - [Team](#team) ## Maven @@ -363,6 +364,36 @@ It is possible to optionally add a [Validator](http://dlsc.com/wp-content/html/f | `SelectionLengthValidator` | Defines a length interval which is considered valid. This range can be limited in either one direction or in both directions. | | `StringLengthValidator` | Defines a length interval which is considered valid. This range can be limited in either one direction or in both directions. | +## Visibility + +PreferencesFX support setting an optional visibility condition for Categories, Groups and Settings +* condition could be defined as a lambda-expression +* condition will be re-evaluated whenever any Setting changes + +```java +Category.of("General", + Group.of("Display", + Setting.of("Brightness", brightness), + Setting.of("Night mode", nightMode, VisibilityProperty.of(brightness, (newValue) -> newValue.intValue() > 50)), + Setting.of("Scale", scale, VisibilityProperty.of(nightMode, (newValue) -> newValue)), + Setting.of("Is production category visible", productionVisibility) + ) +), +Category.of("Production", VisibilityProperty.of(productionVisibility, (newValue) -> newValue), + Group.of("Display", + Setting.of("Port", salary, VisibilityProperty.of(nightMode, (newValue) -> newValue)) + ) +), +Category.of("View", + Group.of("Display", + Setting.of("Salary", salary, VisibilityProperty.of(nightMode, (newValue) -> newValue)) + ), + Group.of("Bonuses", VisibilityProperty.of(salary, (newValue) -> newValue.intValue() > 10), + Setting.of("Bonus", bonus) + ) +) +``` + ## Team - Marco Sanfratello - marco.sanfratello@students.fhnw.ch