Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve navigation structure #6135

Merged
merged 35 commits into from Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
98f355d
Adapt navigational structure and offerbook handling to buy and sell d…
ripcurlx Apr 1, 2022
875e5f4
Adapt offer book chart view to new navigational structure
ripcurlx Apr 1, 2022
5781e3b
Add payment account filtering for remaining payment methods
ripcurlx Apr 1, 2022
810a29b
Add missing payment account filtering
ripcurlx Apr 1, 2022
e3ceb80
Show all payment methods
ripcurlx Apr 1, 2022
924e92a
Adapt take offer process to new navigation structure
ripcurlx Apr 4, 2022
a8189d7
Adapt create offer process to new navigation structure
ripcurlx Apr 6, 2022
497158a
Fix rebase errors with master
ripcurlx Apr 7, 2022
33725c2
Adapt navigation labels back to currency code
ripcurlx Apr 8, 2022
b70d102
Fix BSQ swap labels
ripcurlx Apr 8, 2022
98285da
Move OfferViewUtil
ripcurlx Apr 11, 2022
b734420
Fix navigation to specific offer book view
ripcurlx Apr 11, 2022
5b67766
Properly rename main navigation
ripcurlx Apr 11, 2022
1712f74
Use BSQ Swap as default when BSQ offer is created
ripcurlx Apr 11, 2022
492ff35
Adapt amount and volume description for take offer
ripcurlx Apr 11, 2022
63ea054
Adapt amount and volume description for create offer
ripcurlx Apr 11, 2022
9a3ed33
Use Offer.isFiat helper method
ripcurlx Apr 11, 2022
542cc4d
Remove close button duplication in DetailsWindows
ripcurlx Apr 11, 2022
098ece2
Only show BSQ accounts
ripcurlx Apr 11, 2022
2055cc5
Fix wrong check to show BSQ swap as default for create offer
ripcurlx Apr 11, 2022
fce247c
Fix a couple of issues regarding default currencies
ripcurlx Apr 13, 2022
348d147
Fix broken option for BSQ Altcoin and BSQ Altcoin Instant
ripcurlx Apr 19, 2022
e43bad1
Fix offer count for Altcoins
ripcurlx Apr 19, 2022
d41235c
Fix storage of crypto screen currency
ripcurlx Apr 19, 2022
be16166
Fix sorting issue for Altcoins
ripcurlx Apr 20, 2022
7ecd159
Fix BSQ swap create offer handling (again)
ripcurlx Apr 20, 2022
108255b
Move supported currencies into payment accounts
ripcurlx Apr 20, 2022
e43a8ae
Fix handling of preferred currency
ripcurlx Apr 20, 2022
0894037
Add safeguard for already stored crypto currencies in preferences by …
ripcurlx Apr 20, 2022
89926d1
Improve help icon
ripcurlx Apr 20, 2022
3ce374e
Unify tab handling
ripcurlx Apr 21, 2022
2233f73
Fix Codacy complaints
ripcurlx Apr 21, 2022
4ce861a
Add create and take offer title
ripcurlx Apr 22, 2022
4447435
Switch to open offers after creating a new offer
ripcurlx Apr 22, 2022
7ad2dd0
Set preferred currency as top altcoin
ripcurlx Apr 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -24,10 +24,8 @@
import bisq.desktop.main.offer.OfferView;
import bisq.desktop.main.offer.OfferViewUtil;
import bisq.desktop.main.offer.SellOfferView;
import bisq.desktop.main.offer.offerbook.BsqOfferBookViewModel;
import bisq.desktop.main.offer.offerbook.OfferBook;
import bisq.desktop.main.offer.offerbook.OfferBookListItem;
import bisq.desktop.main.offer.offerbook.TopAltcoinOfferBookViewModel;
import bisq.desktop.main.settings.SettingsView;
import bisq.desktop.main.settings.preferences.PreferencesView;
import bisq.desktop.util.CurrencyList;
Expand Down Expand Up @@ -413,15 +411,15 @@ private void updateScreenCurrencyInPreferences(OfferDirection direction) {
if (isSellOffer(direction)) {
if (CurrencyUtil.isFiatCurrency(getCurrencyCode())) {
preferences.setBuyScreenCurrencyCode(getCurrencyCode());
} else if (!getCurrencyCode().equals(BsqOfferBookViewModel.BSQ.getCode()) &&
!getCurrencyCode().equals(TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getCode())) {
} else if (!getCurrencyCode().equals(GUIUtil.BSQ.getCode()) &&
!getCurrencyCode().equals(GUIUtil.TOP_ALTCOIN.getCode())) {
preferences.setBuyScreenCryptoCurrencyCode(getCurrencyCode());
}
} else {
if (CurrencyUtil.isFiatCurrency(getCurrencyCode())) {
preferences.setSellScreenCurrencyCode(getCurrencyCode());
} else if (!getCurrencyCode().equals(BsqOfferBookViewModel.BSQ.getCode()) &&
!getCurrencyCode().equals(TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getCode())) {
} else if (!getCurrencyCode().equals(GUIUtil.BSQ.getCode()) &&
!getCurrencyCode().equals(GUIUtil.TOP_ALTCOIN.getCode())) {
preferences.setSellScreenCryptoCurrencyCode(getCurrencyCode());
}
}
Expand Down
20 changes: 12 additions & 8 deletions desktop/src/main/java/bisq/desktop/main/offer/OfferView.java
Expand Up @@ -27,12 +27,10 @@
import bisq.desktop.main.offer.bsq_swap.create_offer.BsqSwapCreateOfferView;
import bisq.desktop.main.offer.bsq_swap.take_offer.BsqSwapTakeOfferView;
import bisq.desktop.main.offer.offerbook.BsqOfferBookView;
import bisq.desktop.main.offer.offerbook.BsqOfferBookViewModel;
import bisq.desktop.main.offer.offerbook.BtcOfferBookView;
import bisq.desktop.main.offer.offerbook.OfferBookView;
import bisq.desktop.main.offer.offerbook.OtherOfferBookView;
import bisq.desktop.main.offer.offerbook.TopAltcoinOfferBookView;
import bisq.desktop.main.offer.offerbook.TopAltcoinOfferBookViewModel;
import bisq.desktop.util.GUIUtil;

import bisq.core.locale.CurrencyUtil;
Expand Down Expand Up @@ -172,6 +170,12 @@ protected void activate() {
if (btcOfferBookView == null) {
navigation.navigateTo(MainView.class, this.getClass(), BtcOfferBookView.class);
}

GUIUtil.updateTopAltcoin(preferences);

if (topAltcoinOfferBookTab != null) {
topAltcoinOfferBookTab.setText(GUIUtil.TOP_ALTCOIN.getCode());
}
}

@Override
Expand Down Expand Up @@ -205,7 +209,7 @@ private void loadView(Class<? extends View> viewClass,
} else if (data instanceof BsqSwapOfferPayload) {
loadCreateViewClass(bsqOfferBookView, viewClass, childViewClass, bsqOfferBookTab, PaymentMethod.BSQ_SWAP, (BsqSwapOfferPayload) data);
} else {
tradeCurrency = BsqOfferBookViewModel.BSQ;
tradeCurrency = GUIUtil.BSQ;
loadCreateViewClass(bsqOfferBookView, viewClass, childViewClass, bsqOfferBookTab, (PaymentMethod) data, null);
}
tabPane.getSelectionModel().select(bsqOfferBookTab);
Expand All @@ -215,7 +219,7 @@ private void loadView(Class<? extends View> viewClass,
} else if (childViewClass == TakeOfferView.class) {
loadTakeViewClass(viewClass, childViewClass, topAltcoinOfferBookTab);
} else {
tradeCurrency = TopAltcoinOfferBookViewModel.TOP_ALTCOIN;
tradeCurrency = GUIUtil.TOP_ALTCOIN;
loadCreateViewClass(topAltcoinOfferBookView, viewClass, childViewClass, topAltcoinOfferBookTab, (PaymentMethod) data, null);
}
tabPane.getSelectionModel().select(topAltcoinOfferBookTab);
Expand All @@ -239,9 +243,9 @@ private void loadView(Class<? extends View> viewClass,
if (btcOfferBookTab == null) {
btcOfferBookTab = new Tab(Res.getBaseCurrencyName().toUpperCase());
btcOfferBookTab.setClosable(false);
bsqOfferBookTab = new Tab(BsqOfferBookViewModel.BSQ.getCode());
bsqOfferBookTab = new Tab(GUIUtil.BSQ.getCode());
bsqOfferBookTab.setClosable(false);
topAltcoinOfferBookTab = new Tab(TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getCode());
topAltcoinOfferBookTab = new Tab(GUIUtil.TOP_ALTCOIN.getCode());
topAltcoinOfferBookTab.setClosable(false);
otherOfferBookTab = new Tab(Res.get("shared.other").toUpperCase());
otherOfferBookTab.setClosable(false);
Expand Down Expand Up @@ -363,9 +367,9 @@ private void showCreateOffer(TradeCurrency tradeCurrency, PaymentMethod paymentM
Class<? extends OfferBookView<?, ?>> offerBookViewClass;
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
offerBookViewClass = BtcOfferBookView.class;
} else if (currencyCode.equals(BsqOfferBookViewModel.BSQ.getCode())) {
} else if (currencyCode.equals(GUIUtil.BSQ.getCode())) {
offerBookViewClass = BsqOfferBookView.class;
} else if (currencyCode.equals(TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getCode())) {
} else if (currencyCode.equals(GUIUtil.TOP_ALTCOIN.getCode())) {
offerBookViewClass = TopAltcoinOfferBookView.class;
} else {
offerBookViewClass = OtherOfferBookView.class;
Expand Down
11 changes: 5 additions & 6 deletions desktop/src/main/java/bisq/desktop/main/offer/OfferViewUtil.java
Expand Up @@ -23,13 +23,12 @@
import bisq.desktop.components.HyperlinkWithIcon;
import bisq.desktop.main.MainView;
import bisq.desktop.main.offer.offerbook.BsqOfferBookView;
import bisq.desktop.main.offer.offerbook.BsqOfferBookViewModel;
import bisq.desktop.main.offer.offerbook.BtcOfferBookView;
import bisq.desktop.main.offer.offerbook.OfferBookView;
import bisq.desktop.main.offer.offerbook.OtherOfferBookView;
import bisq.desktop.main.offer.offerbook.TopAltcoinOfferBookView;
import bisq.desktop.main.offer.offerbook.TopAltcoinOfferBookViewModel;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.util.GUIUtil;

import bisq.core.locale.CryptoCurrency;
import bisq.core.locale.CurrencyUtil;
Expand Down Expand Up @@ -132,9 +131,9 @@ private static void openBuyBsqOfferBook(Navigation navigation) {
Class<? extends OfferBookView<?, ?>> offerBookViewClazz;
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
offerBookViewClazz = BtcOfferBookView.class;
} else if (currencyCode.equals(BsqOfferBookViewModel.BSQ.getCode())) {
} else if (currencyCode.equals(GUIUtil.BSQ.getCode())) {
offerBookViewClazz = BsqOfferBookView.class;
} else if (currencyCode.equals(TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getCode())) {
} else if (currencyCode.equals(GUIUtil.TOP_ALTCOIN.getCode())) {
offerBookViewClazz = TopAltcoinOfferBookView.class;
} else {
offerBookViewClazz = OtherOfferBookView.class;
Expand Down Expand Up @@ -169,7 +168,7 @@ public static TradeCurrency getAnyOfMainCryptoCurrencies() {
@NotNull
public static Stream<CryptoCurrency> getMainCryptoCurrencies() {
return CurrencyUtil.getMainCryptoCurrencies().stream().filter(cryptoCurrency ->
!Objects.equals(cryptoCurrency.getCode(), TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getCode()) &&
!Objects.equals(cryptoCurrency.getCode(), BsqOfferBookViewModel.BSQ.getCode()));
!Objects.equals(cryptoCurrency.getCode(), GUIUtil.TOP_ALTCOIN.getCode()) &&
!Objects.equals(cryptoCurrency.getCode(), GUIUtil.BSQ.getCode()));
}
}
Expand Up @@ -18,8 +18,6 @@
package bisq.desktop.main.offer.bisq_v1;

import bisq.desktop.Navigation;
import bisq.desktop.main.offer.offerbook.BsqOfferBookViewModel;
import bisq.desktop.main.offer.offerbook.TopAltcoinOfferBookViewModel;
import bisq.desktop.util.DisplayUtils;
import bisq.desktop.util.GUIUtil;

Expand Down Expand Up @@ -289,8 +287,8 @@ private Optional<PaymentAccount> getAnyPaymentAccount() {
} else {
return paymentAccounts.stream().filter(paymentAccount1 -> paymentAccount1.getPaymentMethod().isAltcoin() &&
paymentAccount1.getTradeCurrency().isPresent() &&
!Objects.equals(paymentAccount1.getTradeCurrency().get().getCode(), BsqOfferBookViewModel.BSQ.getCode()) &&
!Objects.equals(paymentAccount1.getTradeCurrency().get().getCode(), TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getCode())).findAny();
!Objects.equals(paymentAccount1.getTradeCurrency().get().getCode(), GUIUtil.BSQ.getCode()) &&
!Objects.equals(paymentAccount1.getTradeCurrency().get().getCode(), GUIUtil.TOP_ALTCOIN.getCode())).findAny();
}
}

Expand Down
Expand Up @@ -21,9 +21,8 @@
import bisq.desktop.common.view.FxmlView;
import bisq.desktop.main.offer.OfferView;
import bisq.desktop.main.offer.bisq_v1.MutableOfferView;
import bisq.desktop.main.offer.offerbook.BsqOfferBookViewModel;
import bisq.desktop.main.offer.offerbook.TopAltcoinOfferBookViewModel;
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
import bisq.desktop.util.GUIUtil;

import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.TradeCurrency;
Expand Down Expand Up @@ -70,16 +69,16 @@ public void initWithData(OfferDirection direction,
protected ObservableList<PaymentAccount> filterPaymentAccounts(ObservableList<PaymentAccount> paymentAccounts) {
return FXCollections.observableArrayList(
paymentAccounts.stream().filter(paymentAccount -> {
if (model.getTradeCurrency().equals(BsqOfferBookViewModel.BSQ)) {
return Objects.equals(paymentAccount.getSingleTradeCurrency(), BsqOfferBookViewModel.BSQ);
} else if (model.getTradeCurrency().equals(TopAltcoinOfferBookViewModel.TOP_ALTCOIN)) {
return Objects.equals(paymentAccount.getSingleTradeCurrency(), TopAltcoinOfferBookViewModel.TOP_ALTCOIN);
if (model.getTradeCurrency().equals(GUIUtil.BSQ)) {
return Objects.equals(paymentAccount.getSingleTradeCurrency(), GUIUtil.BSQ);
} else if (model.getTradeCurrency().equals(GUIUtil.TOP_ALTCOIN)) {
return Objects.equals(paymentAccount.getSingleTradeCurrency(), GUIUtil.TOP_ALTCOIN);
} else if (CurrencyUtil.isFiatCurrency(model.getTradeCurrency().getCode())) {
return !paymentAccount.getPaymentMethod().isAltcoin();
} else {
return paymentAccount.getPaymentMethod().isAltcoin() &&
!(Objects.equals(paymentAccount.getSingleTradeCurrency(), BsqOfferBookViewModel.BSQ) ||
Objects.equals(paymentAccount.getSingleTradeCurrency(), TopAltcoinOfferBookViewModel.TOP_ALTCOIN));
!(Objects.equals(paymentAccount.getSingleTradeCurrency(), GUIUtil.BSQ) ||
Objects.equals(paymentAccount.getSingleTradeCurrency(), GUIUtil.TOP_ALTCOIN));
}
}).collect(Collectors.toList()));
}
Expand Down
Expand Up @@ -29,7 +29,6 @@
import bisq.desktop.main.offer.OfferViewUtil;
import bisq.desktop.main.offer.SelectableView;
import bisq.desktop.main.offer.bsq_swap.BsqSwapOfferView;
import bisq.desktop.main.offer.offerbook.BsqOfferBookViewModel;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.overlays.windows.BsqSwapOfferDetailsWindow;
import bisq.desktop.main.portfolio.PortfolioView;
Expand Down Expand Up @@ -175,7 +174,7 @@ public void initWithData(OfferDirection direction,

model.initWithData(offerPayload != null ? offerPayload.getDirection() : offerDirection, offerPayload);

if (OfferViewUtil.isShownAsBuyOffer(offerDirection, BsqOfferBookViewModel.BSQ)) {
if (OfferViewUtil.isShownAsBuyOffer(offerDirection, GUIUtil.BSQ)) {
actionButton.setId("buy-button-big");
actionButton.updateText(Res.get("createOffer.placeOfferButtonAltcoin", Res.get("shared.buy"), BSQ));
nextButton.setId("buy-button");
Expand Down
Expand Up @@ -122,8 +122,8 @@ Predicate<OfferBookListItem> getCurrencyAndMethodPredicate(OfferDirection direct
boolean directionResult = offer.getDirection() == direction;
boolean currencyResult = CurrencyUtil.isCryptoCurrency(offer.getCurrencyCode()) &&
((showAllTradeCurrenciesProperty.get() &&
!offer.getCurrencyCode().equals(TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getCode()) &&
!offer.getCurrencyCode().equals(BsqOfferBookViewModel.BSQ.getCode())) ||
!offer.getCurrencyCode().equals(GUIUtil.TOP_ALTCOIN.getCode()) &&
!offer.getCurrencyCode().equals(GUIUtil.BSQ.getCode())) ||
offer.getCurrencyCode().equals(selectedTradeCurrency.getCode()));
boolean paymentMethodResult = showAllPaymentMethods ||
offer.getPaymentMethod().equals(selectedPaymentMethod);
Expand Down Expand Up @@ -166,7 +166,7 @@ String getCurrencyCodeFromPreferences(OfferDirection direction) {
@NotNull
private Predicate<CryptoCurrency> withoutBSQAndTopAltcoin() {
return cryptoCurrency ->
!cryptoCurrency.equals(BsqOfferBookViewModel.BSQ) &&
!cryptoCurrency.equals(TopAltcoinOfferBookViewModel.TOP_ALTCOIN);
!cryptoCurrency.equals(GUIUtil.BSQ) &&
!cryptoCurrency.equals(GUIUtil.TOP_ALTCOIN);
}
}
Expand Up @@ -54,7 +54,7 @@

public class TopAltcoinOfferBookViewModel extends OfferBookViewModel {

public static final TradeCurrency TOP_ALTCOIN = GUIUtil.TOP_ALTCOIN;
public static TradeCurrency TOP_ALTCOIN = GUIUtil.TOP_ALTCOIN;

@Inject
public TopAltcoinOfferBookViewModel(User user,
Expand All @@ -77,6 +77,12 @@ public TopAltcoinOfferBookViewModel(User user,
super(user, openOfferManager, offerBook, preferences, walletsSetup, p2PService, priceFeedService, closedTradableManager, bsqSwapTradeManager, accountAgeWitnessService, navigation, priceUtil, offerFilterService, btcFormatter, bsqFormatter, bsqWalletService, coreApi);
}

@Override
protected void activate() {
super.activate();
TOP_ALTCOIN = GUIUtil.TOP_ALTCOIN;
}

@Override
void saveSelectedCurrencyCodeInPreferences(OfferDirection direction, String code) {
// No need to store anything as it is just one Altcoin offers anyway
Expand Down
Expand Up @@ -944,6 +944,7 @@ private void activateDisplayCurrencies() {
TradeCurrency selectedItem = preferredTradeCurrencyComboBox.getSelectionModel().getSelectedItem();
if (selectedItem != null)
preferences.setPreferredTradeCurrency(selectedItem);
GUIUtil.updateTopAltcoin(preferences);
});

fiatCurrenciesComboBox.setItems(allFiatCurrencies);
Expand Down
10 changes: 9 additions & 1 deletion desktop/src/main/java/bisq/desktop/util/GUIUtil.java
Expand Up @@ -169,7 +169,7 @@ public class GUIUtil {
public final static int AMOUNT_DECIMALS = 4;

public final static TradeCurrency BSQ = CurrencyUtil.getTradeCurrency("BSQ").get();
public final static TradeCurrency TOP_ALTCOIN = CurrencyUtil.getTradeCurrency("XMR").get();
public static TradeCurrency TOP_ALTCOIN = CurrencyUtil.getTradeCurrency("XMR").get();

private static FeeService feeService;
private static Preferences preferences;
Expand Down Expand Up @@ -1249,4 +1249,12 @@ public static void setDefaultTwoColumnConstraintsForGridPane(GridPane gridPane)
columnConstraints2.setHgrow(Priority.ALWAYS);
gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
}

public static void updateTopAltcoin(Preferences preferences) {
TradeCurrency tradeCurrency = preferences.getPreferredTradeCurrency();
if (CurrencyUtil.isFiatCurrency(tradeCurrency.getCode()) || tradeCurrency.equals(BSQ)) {
return;
}
TOP_ALTCOIN = tradeCurrency;
}
}