Skip to content

Commit

Permalink
Add tab view for wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikJannsen committed Jan 2, 2023
1 parent 78b32ae commit d61394d
Show file tree
Hide file tree
Showing 25 changed files with 316 additions and 555 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.desktop.components.controls;

import bisq.desktop.common.threading.UIThread;
import de.jensd.fx.fontawesome.AwesomeIcon;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextInputControl;
import javafx.scene.control.skin.TextFieldSkin;

import javax.annotation.Nullable;

public class MaterialPasswordField extends MaterialTextField {
public MaterialPasswordField() {
this(null, null, null);
}

public MaterialPasswordField(String description) {
this(description, null, null);
}

public MaterialPasswordField(String description, String prompt) {
this(description, prompt, null);
}

public MaterialPasswordField(@Nullable String description, @Nullable String prompt, @Nullable String help) {
super(description, prompt, help);
}

@Override
protected TextInputControl createTextInputControl() {
PasswordField passwordField = new PasswordField();
passwordField.setSkin(new VisiblePasswordFieldSkin(passwordField, this));

return passwordField;
}

static class VisiblePasswordFieldSkin extends TextFieldSkin {
private boolean isMasked = true;

public VisiblePasswordFieldSkin(PasswordField textField, MaterialPasswordField materialPasswordField) {
super(textField);

// iconButton is not created when we get called, so we delay it to next render frame
UIThread.runOnNextRenderFrame(() -> {
BisqIconButton iconButton = materialPasswordField.getIconButton();
materialPasswordField.setIcon(AwesomeIcon.EYE_OPEN);
iconButton.setOnAction(e -> {
iconButton.setIcon(isMasked ? AwesomeIcon.EYE_CLOSE : AwesomeIcon.EYE_OPEN);
isMasked = !isMasked;

// TODO if binding is used we don't get the text updated. With bi-dir binding it works
textField.setText(textField.getText());
textField.end();
/* if(!textField.textProperty().isBound()){
textField.setText(textField.getText());
textField.end();
}*/
});
});
}

@Override
protected String maskText(String txt) {
if (getSkinnable() instanceof PasswordField && isMasked) {
return "•".repeat(txt.length());
} else {
return txt;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.text.DateFormat;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Predicate;
Expand Down Expand Up @@ -1026,7 +1027,7 @@ public ChatMessageListItem(T chatMessage, UserProfileService userProfileService,
String editPostFix = chatMessage.isWasEdited() ? EDITED_POST_FIX : "";
message = chatMessage.getText() + editPostFix;
quotedMessage = chatMessage.getQuotation();
date = DateFormatter.formatDateTimeV2(new Date(chatMessage.getDate()));
date = DateFormatter.formatDateTime(new Date(chatMessage.getDate()), DateFormat.MEDIUM, DateFormat.SHORT, true, " " + Res.get("at") + " ");

nym = senderUserProfile.map(UserProfile::getNym).orElse("");
nickName = senderUserProfile.map(UserProfile::getNickName).orElse("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ public void onActivate() {
}

updateRegistrationState();

model.getPrivateKeyDisplay().set("•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••");
});
}

Expand Down Expand Up @@ -148,8 +146,4 @@ void onRemoveRegistration() {
void onCopy() {
ClipboardUtil.copyToClipboard(model.getPublicKey().get());
}

void onShowPrivateKey() {
model.getPrivateKeyDisplay().set(model.getPrivateKey().get());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class RoleRegistrationModel implements Model {
private final StringProperty selectedProfileUserName = new SimpleStringProperty();
private final StringProperty privateKey = new SimpleStringProperty();
private final StringProperty publicKey = new SimpleStringProperty();
private final StringProperty privateKeyDisplay = new SimpleStringProperty();
private final BooleanProperty registrationDisabled = new SimpleBooleanProperty();
private final BooleanProperty removeRegistrationVisible = new SimpleBooleanProperty();
private final RoleType roleType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@

import bisq.desktop.common.view.View;
import bisq.desktop.components.containers.Spacer;
import bisq.desktop.components.controls.BisqIconButton;
import bisq.desktop.components.controls.MaterialPasswordField;
import bisq.desktop.components.controls.MaterialTextField;
import bisq.desktop.components.controls.MultiLineLabel;
import bisq.i18n.Res;
import de.jensd.fx.fontawesome.AwesomeIcon;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
Expand All @@ -38,8 +37,9 @@ public class RoleRegistrationView extends View<VBox, RoleRegistrationModel, Role
private final Button copyButton, registrationButton, removeRegistrationButton;
private final Hyperlink learnMore;
private final Label info;
private final MaterialTextField selectedProfile, privateKey, publicKey;
private final BisqIconButton showPrivateKeyIcon;
private final MaterialTextField selectedProfile, publicKey;
private final MaterialPasswordField privateKey;


public RoleRegistrationView(RoleRegistrationModel model,
RoleRegistrationController controller) {
Expand All @@ -55,10 +55,8 @@ public RoleRegistrationView(RoleRegistrationModel model,
selectedProfile = new MaterialTextField(Res.get("roles.registration.selectedProfile"));
selectedProfile.setEditable(false);

privateKey = new MaterialTextField(Res.get("roles.registration.privateKey"));
privateKey = new MaterialPasswordField(Res.get("roles.registration.privateKey"));
privateKey.setEditable(false);
privateKey.setIcon(AwesomeIcon.EYE_OPEN);
showPrivateKeyIcon = privateKey.getIconButton();

publicKey = new MaterialTextField(Res.get("roles.registration.publicKey"));
publicKey.setEditable(false);
Expand All @@ -81,8 +79,8 @@ public RoleRegistrationView(RoleRegistrationModel model,
@Override
protected void onViewAttached() {
selectedProfile.textProperty().bind(model.getSelectedProfileUserName());
privateKey.textProperty().bind(model.getPrivateKeyDisplay());
publicKey.textProperty().bind(model.getPublicKey());
privateKey.textProperty().bindBidirectional(model.getPrivateKey());
publicKey.textProperty().bindBidirectional(model.getPublicKey());
registrationButton.disableProperty().bind(model.getRegistrationDisabled());
removeRegistrationButton.managedProperty().bind(model.getRemoveRegistrationVisible());
removeRegistrationButton.visibleProperty().bind(model.getRemoveRegistrationVisible());
Expand All @@ -91,18 +89,13 @@ protected void onViewAttached() {
removeRegistrationButton.setOnAction(e -> controller.onRemoveRegistration());
learnMore.setOnAction(e -> controller.onLearnMore());
copyButton.setOnAction(e -> controller.onCopy());
showPrivateKeyIcon.setOnAction(e -> {
controller.onShowPrivateKey();
showPrivateKeyIcon.setVisible(false);
});
showPrivateKeyIcon.setVisible(true);
}

@Override
protected void onViewDetached() {
selectedProfile.textProperty().unbind();
privateKey.textProperty().unbind();
publicKey.textProperty().unbind();
privateKey.textProperty().unbindBidirectional(model.getPrivateKey());
publicKey.textProperty().unbindBidirectional(model.getPublicKey());
registrationButton.disableProperty().unbind();
removeRegistrationButton.managedProperty().unbind();
removeRegistrationButton.visibleProperty().unbind();
Expand All @@ -111,6 +104,5 @@ protected void onViewDetached() {
removeRegistrationButton.setOnAction(null);
learnMore.setOnAction(null);
copyButton.setOnAction(null);
showPrivateKeyIcon.setOnAction(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ public class UserProfileView extends View<HBox, UserProfileModel, UserProfileCon
private Subscription reputationScorePin, selectedChatUserIdentityPin;

public UserProfileView(UserProfileModel model, UserProfileController controller) {
super(new HBox(), model, controller);
super(new HBox(20), model, controller);

root.setSpacing(20);
root.setPadding(new Insets(40, 0, 0, 0));

roboIconImageView = new ImageView();
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit d61394d

Please sign in to comment.