Add news badge for new percentage security deposit

This commit is contained in:
Christoph Atteneder 2019-03-05 13:08:26 +01:00
parent 279b38bf2e
commit 95d8f514ad
No known key found for this signature in database
GPG key ID: CD5DC1C529CDFD3B
4 changed files with 47 additions and 2 deletions

View file

@ -530,7 +530,7 @@ bg color of non edit textFields: fafafa
-fx-pref-width: 30;
}
.jfx-badge .label {
.jfx-badge .badge-pane .label {
-fx-font-weight: bold;
-fx-font-size: 0.692em;
-fx-text-fill: -bs-rd-white;

View file

@ -0,0 +1,34 @@
package bisq.desktop.components;
import bisq.core.locale.Res;
import bisq.core.user.Preferences;
import com.jfoenix.controls.JFXBadge;
import javafx.scene.Node;
import javafx.collections.MapChangeListener;
public class NewBadge extends JFXBadge {
private final String key;
public NewBadge(Node control, String key, Preferences preferences) {
super(control);
this.key = key;
setText(Res.get("shared.new"));
getStyleClass().add("new");
setEnabled(!preferences.getDontShowAgainMap().containsKey(key));
refreshBadge();
preferences.getDontShowAgainMapAsObservable().addListener((MapChangeListener<? super String, ? super Boolean>) change -> {
if (change.getKey().equals(key)) {
setEnabled(!change.wasAdded());
refreshBadge();
}
});
}
}

View file

@ -28,6 +28,7 @@ import bisq.desktop.components.BusyAnimation;
import bisq.desktop.components.FundsTextField;
import bisq.desktop.components.InfoInputTextField;
import bisq.desktop.components.InputTextField;
import bisq.desktop.components.NewBadge;
import bisq.desktop.components.TitledGroupBg;
import bisq.desktop.main.MainView;
import bisq.desktop.main.account.AccountView;
@ -122,6 +123,7 @@ import static bisq.desktop.util.FormBuilder.*;
import static javafx.beans.binding.Bindings.createStringBinding;
public abstract class MutableOfferView<M extends MutableOfferViewModel> extends ActivatableViewAndModel<AnchorPane, M> {
public static final String BUYER_SECURITY_DEPOSIT_NEWS = "buyerSecurityDepositNews0.9.5";
protected final Navigation navigation;
private final Preferences preferences;
private final Transitions transitions;
@ -1042,7 +1044,12 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
GridPane.setMargin(advancedOptionsBox, new Insets(Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
gridPane.getChildren().add(advancedOptionsBox);
advancedOptionsBox.getChildren().addAll(getBuyerSecurityDepositBox(), getTradeFeeFieldsBox());
// add new badge for this new feature for this release
// TODO: remove it with 0.9.6+
NewBadge securityDepositBoxWithNewBadge = new NewBadge(getBuyerSecurityDepositBox(),
BUYER_SECURITY_DEPOSIT_NEWS, preferences);
advancedOptionsBox.getChildren().addAll(securityDepositBoxWithNewBadge, getTradeFeeFieldsBox());
Tuple2<Button, Button> tuple = add2ButtonsAfterGroup(gridPane, ++gridRow,

View file

@ -51,6 +51,8 @@ import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static bisq.desktop.main.offer.MutableOfferView.BUYER_SECURITY_DEPOSIT_NEWS;
public abstract class OfferView extends ActivatableView<TabPane, Void> {
private OfferBookView offerBookView;
@ -271,6 +273,8 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
offerBookView.enableCreateOfferButton();
navigation.navigateTo(MainView.class, this.getClass(), OfferBookView.class);
preferences.dontShowAgain(BUYER_SECURITY_DEPOSIT_NEWS, true);
}
private void onTakeOfferViewRemoved() {