Skip to content

Commit

Permalink
Move teaser page into separate view
Browse files Browse the repository at this point in the history
  • Loading branch information
ripcurlx committed Feb 13, 2019
1 parent 2cbcf77 commit 3890c9c
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 57 deletions.
1 change: 1 addition & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,7 @@ dao.tab.bsqWallet=BSQ wallet
dao.tab.proposals=Governance
dao.tab.bonding=Bonding
dao.tab.proofOfBurn=Asset listing fee/Proof of burn
dao.tab.news=News

dao.paidWithBsq=paid with BSQ
dao.availableBsqBalance=Available
Expand Down
41 changes: 26 additions & 15 deletions desktop/src/main/java/bisq/desktop/main/dao/DaoView.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import bisq.desktop.main.dao.bonding.BondingView;
import bisq.desktop.main.dao.burnbsq.BurnBsqView;
import bisq.desktop.main.dao.governance.GovernanceView;
import bisq.desktop.main.dao.news.NewsView;
import bisq.desktop.main.dao.wallet.BsqWalletView;
import bisq.desktop.main.dao.wallet.dashboard.BsqDashboardView;
import bisq.desktop.main.overlays.popups.Popup;
Expand All @@ -51,7 +52,7 @@
public class DaoView extends ActivatableViewAndModel<TabPane, Activatable> {

@FXML
private Tab bsqWalletTab, proposalsTab, bondingTab, burnBsqTab;
private Tab bsqWalletTab, proposalsTab, bondingTab, burnBsqTab, daoNewsTab;

private Navigation.Listener navigationListener;
private ChangeListener<Tab> tabChangeListener;
Expand Down Expand Up @@ -89,7 +90,11 @@ public void initialize() {
proposalsTab.setDisable(true);
bondingTab.setDisable(true);
burnBsqTab.setDisable(true);
root.getTabs().addAll(bsqWalletTab);
bsqWalletTab.setDisable(true);

daoNewsTab = new Tab(Res.get("dao.tab.news").toUpperCase());

root.getTabs().add(daoNewsTab);
} else {
root.getTabs().addAll(bsqWalletTab, proposalsTab, bondingTab, burnBsqTab);
}
Expand Down Expand Up @@ -122,19 +127,23 @@ public void initialize() {

@Override
protected void activate() {
navigation.addListener(navigationListener);
root.getSelectionModel().selectedItemProperty().addListener(tabChangeListener);

if (navigation.getCurrentPath().size() == 2 && navigation.getCurrentPath().get(1) == DaoView.class) {
Tab selectedItem = root.getSelectionModel().getSelectedItem();
if (selectedItem == bsqWalletTab)
navigation.navigateTo(MainView.class, DaoView.class, BsqWalletView.class);
else if (selectedItem == proposalsTab)
navigation.navigateTo(MainView.class, DaoView.class, GovernanceView.class);
else if (selectedItem == bondingTab)
navigation.navigateTo(MainView.class, DaoView.class, BondingView.class);
else if (selectedItem == burnBsqTab)
navigation.navigateTo(MainView.class, DaoView.class, BurnBsqView.class);
if (DevEnv.isDaoActivated()) {
navigation.addListener(navigationListener);
root.getSelectionModel().selectedItemProperty().addListener(tabChangeListener);

if (navigation.getCurrentPath().size() == 2 && navigation.getCurrentPath().get(1) == DaoView.class) {
Tab selectedItem = root.getSelectionModel().getSelectedItem();
if (selectedItem == bsqWalletTab)
navigation.navigateTo(MainView.class, DaoView.class, BsqWalletView.class);
else if (selectedItem == proposalsTab)
navigation.navigateTo(MainView.class, DaoView.class, GovernanceView.class);
else if (selectedItem == bondingTab)
navigation.navigateTo(MainView.class, DaoView.class, BondingView.class);
else if (selectedItem == burnBsqTab)
navigation.navigateTo(MainView.class, DaoView.class, BurnBsqView.class);
}
} else {
loadView(NewsView.class);
}
}

Expand Down Expand Up @@ -164,6 +173,8 @@ private void loadView(Class<? extends View> viewClass) {
selectedTab = bondingTab;
} else if (view instanceof BurnBsqView) {
selectedTab = burnBsqTab;
} else if (view instanceof NewsView) {
selectedTab = daoNewsTab;
}

selectedTab.setContent(view.getRoot());
Expand Down
27 changes: 27 additions & 0 deletions desktop/src/main/java/bisq/desktop/main/dao/news/NewsView.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ 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/>.
-->

<?import javafx.scene.layout.GridPane?>
<?import javafx.geometry.Insets?>
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.news.NewsView"
xmlns:fx="http://javafx.com/fxml" hgap="5.0" vgap="5.0">
<padding>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0"/>
</padding>
</GridPane>
92 changes: 92 additions & 0 deletions desktop/src/main/java/bisq/desktop/main/dao/news/NewsView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package bisq.desktop.main.dao.news;

import bisq.desktop.common.view.ActivatableView;
import bisq.desktop.common.view.FxmlView;
import bisq.desktop.components.BsqAddressTextField;
import bisq.desktop.main.presentation.DaoPresentation;
import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.GUIUtil;

import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.locale.Res;
import bisq.core.user.Preferences;
import bisq.core.util.BsqFormatter;

import bisq.common.app.DevEnv;
import bisq.common.util.Tuple3;

import javax.inject.Inject;

import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;

import static bisq.desktop.util.FormBuilder.addLabelBsqAddressTextField;
import static bisq.desktop.util.FormBuilder.addTitledGroupBg;

@FxmlView
public class NewsView extends ActivatableView<GridPane, Void> {

private final Preferences preferences;
private final BsqWalletService bsqWalletService;
private final BsqFormatter bsqFormatter;
private BsqAddressTextField addressTextField;

@Inject
private NewsView(Preferences preferences, BsqWalletService bsqWalletService,
BsqFormatter bsqFormatter) {
this.preferences = preferences;
this.bsqWalletService = bsqWalletService;
this.bsqFormatter = bsqFormatter;
}

@Override
protected void initialize() {
int gridRow = 0;

addTitledGroupBg(root, gridRow, 6,
Res.get("dao.wallet.receive.dao.headline"), 0);
FormBuilder.addMultilineLabel(root, gridRow, Res.get("dao.wallet.receive.daoInfo"), 10);

Button daoInfoButton = FormBuilder.addButton(root, ++gridRow, Res.get("dao.wallet.receive.daoInfo.button"));
daoInfoButton.setOnAction(e -> {
GUIUtil.openWebPage("https://bisq.network/dao");
});

FormBuilder.addMultilineLabel(root, ++gridRow, Res.get("dao.wallet.receive.daoTestnetInfo"));
Button daoContributorInfoButton = FormBuilder.addButton(root, ++gridRow, Res.get("dao.wallet.receive.daoTestnetInfo.button"));
daoContributorInfoButton.setOnAction(e -> {
GUIUtil.openWebPage("https://bisq.network/dao-testnet");
});

FormBuilder.addMultilineLabel(root, ++gridRow, Res.get("dao.wallet.receive.daoContributorInfo"));

Button daoTestnetInfoButton = FormBuilder.addButton(root, ++gridRow, Res.get("dao.wallet.receive.daoContributorInfo.button"));
daoTestnetInfoButton.setOnAction(e -> {
GUIUtil.openWebPage("https://bisq.network/dao-genesis");
});

addTitledGroupBg(root, ++gridRow, 1,
Res.get("dao.wallet.receive.fundYourWallet"), 20);
Tuple3<Label, BsqAddressTextField, VBox> tuple = addLabelBsqAddressTextField(root, gridRow,
Res.get("dao.wallet.receive.bsqAddress"),
40);
addressTextField = tuple.second;
GridPane.setColumnSpan(tuple.third, 3);
}

@Override
protected void activate() {
// Hide dao new badge if user saw this page
if (!DevEnv.isDaoActivated())
preferences.dontShowAgain(DaoPresentation.DAO_NEWS, true);

addressTextField.setAddress(bsqFormatter.getBsqAddressStringFromAddress(bsqWalletService.getUnusedAddress()));
}

@Override
protected void deactivate() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,17 @@
import bisq.desktop.components.BsqAddressTextField;
import bisq.desktop.components.TitledGroupBg;
import bisq.desktop.main.dao.wallet.BsqBalanceUtil;
import bisq.desktop.main.presentation.DaoPresentation;
import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.GUIUtil;
import bisq.desktop.util.Layout;

import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.locale.Res;
import bisq.core.user.Preferences;
import bisq.core.util.BsqFormatter;

import bisq.common.app.DevEnv;
import bisq.common.util.Tuple3;

import javax.inject.Inject;

import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
Expand All @@ -52,20 +47,17 @@ public class BsqReceiveView extends ActivatableView<GridPane, Void> {
private final BsqWalletService bsqWalletService;
private final BsqFormatter bsqFormatter;
private final BsqBalanceUtil bsqBalanceUtil;
private final Preferences preferences;
private int gridRow = 0;

///////////////////////////////////////////////////////////////////////////////////////////
// Constructor, lifecycle
///////////////////////////////////////////////////////////////////////////////////////////

@Inject
private BsqReceiveView(BsqWalletService bsqWalletService, BsqFormatter bsqFormatter, BsqBalanceUtil bsqBalanceUtil,
Preferences preferences) {
private BsqReceiveView(BsqWalletService bsqWalletService, BsqFormatter bsqFormatter, BsqBalanceUtil bsqBalanceUtil) {
this.bsqWalletService = bsqWalletService;
this.bsqFormatter = bsqFormatter;
this.bsqBalanceUtil = bsqBalanceUtil;
this.preferences = preferences;
}

@Override
Expand All @@ -81,44 +73,11 @@ public void initialize() {
Layout.FIRST_ROW_AND_GROUP_DISTANCE);
addressTextField = tuple.second;
GridPane.setColumnSpan(tuple.third, 3);
} else {
addTitledGroupBg(root, gridRow, 6,
Res.get("dao.wallet.receive.dao.headline"), 0);
FormBuilder.addMultilineLabel(root, gridRow, Res.get("dao.wallet.receive.daoInfo"), 10);

Button daoInfoButton = FormBuilder.addButton(root, ++gridRow, Res.get("dao.wallet.receive.daoInfo.button"));
daoInfoButton.setOnAction(e -> {
GUIUtil.openWebPage("https://bisq.network/dao");
});

FormBuilder.addMultilineLabel(root, ++gridRow, Res.get("dao.wallet.receive.daoTestnetInfo"));
Button daoContributorInfoButton = FormBuilder.addButton(root, ++gridRow, Res.get("dao.wallet.receive.daoTestnetInfo.button"));
daoContributorInfoButton.setOnAction(e -> {
GUIUtil.openWebPage("https://bisq.network/dao-testnet");
});

FormBuilder.addMultilineLabel(root, ++gridRow, Res.get("dao.wallet.receive.daoContributorInfo"));

Button daoTestnetInfoButton = FormBuilder.addButton(root, ++gridRow, Res.get("dao.wallet.receive.daoContributorInfo.button"));
daoTestnetInfoButton.setOnAction(e -> {
GUIUtil.openWebPage("https://bisq.network/dao-genesis");
});

addTitledGroupBg(root, ++gridRow, 1,
Res.get("dao.wallet.receive.fundYourWallet"), 20);
Tuple3<Label, BsqAddressTextField, VBox> tuple = addLabelBsqAddressTextField(root, gridRow,
Res.get("dao.wallet.receive.bsqAddress"),
40);
addressTextField = tuple.second;
GridPane.setColumnSpan(tuple.third, 3);
}
}

@Override
protected void activate() {
// Hide dao new badge if user saw this page
if (!DevEnv.isDaoActivated())
preferences.dontShowAgain(DaoPresentation.DAO_NEWS, true);

if (DevEnv.isDaoActivated())
bsqBalanceUtil.activate();
Expand Down

0 comments on commit 3890c9c

Please sign in to comment.