Skip to content

Commit

Permalink
Merge pull request #3152 from wiz/darkmode
Browse files Browse the repository at this point in the history
Dark Mode
  • Loading branch information
ripcurlx authored Aug 29, 2019
2 parents 9a2dfda + d308491 commit 3ccae69
Show file tree
Hide file tree
Showing 17 changed files with 525 additions and 400 deletions.
1 change: 1 addition & 0 deletions common/src/main/proto/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,7 @@ message PreferencesPayload {
int32 ignore_dust_threshold = 51;
double buyer_security_deposit_as_percent_for_crypto = 52;
int32 block_notify_port = 53;
int32 css_theme = 54;
}

///////////////////////////////////////////////////////////////////////////////////////////
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/bisq/core/locale/GlobalSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

public class GlobalSettings {
private static boolean useAnimations = true;
private static boolean useDarkMode = false;
private static Locale locale;
private static final ObjectProperty<Locale> localeProperty = new SimpleObjectProperty<>(locale);
private static TradeCurrency defaultTradeCurrency;
Expand All @@ -47,6 +48,10 @@ public static void setUseAnimations(boolean useAnimations) {
GlobalSettings.useAnimations = useAnimations;
}

public static void setUseDarkMode(boolean useDarkMode) {
GlobalSettings.useDarkMode = useDarkMode;
}

public static void setDefaultTradeCurrency(TradeCurrency fiatCurrency) {
GlobalSettings.defaultTradeCurrency = fiatCurrency;
}
Expand Down
15 changes: 15 additions & 0 deletions core/src/main/java/bisq/core/user/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@
import javax.inject.Singleton;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.LongProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleLongProperty;

import javafx.collections.FXCollections;
Expand Down Expand Up @@ -122,6 +124,8 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
@Getter
private final BooleanProperty useAnimationsProperty = new SimpleBooleanProperty(prefPayload.isUseAnimations());
@Getter
private final IntegerProperty cssThemeProperty = new SimpleIntegerProperty(prefPayload.getCssTheme());
@Getter
private final BooleanProperty useCustomWithdrawalTxFeeProperty = new SimpleBooleanProperty(prefPayload.isUseCustomWithdrawalTxFee());
@Getter
private final LongProperty withdrawalTxFeeInBytesProperty = new SimpleLongProperty(prefPayload.getWithdrawalTxFeeInBytes());
Expand Down Expand Up @@ -173,6 +177,11 @@ public Preferences(Storage<PreferencesPayload> storage,
persist();
});

cssThemeProperty.addListener((ov) -> {
prefPayload.setCssTheme(cssThemeProperty.get());
persist();
});

useStandbyModeProperty.addListener((ov) -> {
prefPayload.setUseStandbyMode(useStandbyModeProperty.get());
persist();
Expand Down Expand Up @@ -332,6 +341,10 @@ public void setUseAnimations(boolean useAnimations) {
this.useAnimationsProperty.set(useAnimations);
}

public void setCssTheme(boolean useDarkMode) {
this.cssThemeProperty.set(useDarkMode == true ? 1 : 0);
}

public void addFiatCurrency(FiatCurrency tradeCurrency) {
if (!fiatCurrenciesAsObservable.contains(tradeCurrency))
fiatCurrenciesAsObservable.add(tradeCurrency);
Expand Down Expand Up @@ -822,6 +835,8 @@ private interface ExcludesDelegateMethods {

void setUseAnimations(boolean useAnimations);

void setCssTheme(int cssTheme);

void setUserLanguage(@NotNull String userLanguageCode);

void setUserCountry(@NotNull Country userCountry);
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/bisq/core/user/PreferencesPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public final class PreferencesPayload implements PersistableEnvelope {
private long buyerSecurityDepositAsLong;

private boolean useAnimations;
private int cssTheme;
@Nullable
private PaymentAccount selectedPaymentAccountForCreateOffer;
private boolean payFeeInBtc = true;
Expand Down Expand Up @@ -170,6 +171,7 @@ public Message toProtoMessage() {
.setDirectoryChooserPath(directoryChooserPath)
.setBuyerSecurityDepositAsLong(buyerSecurityDepositAsLong)
.setUseAnimations(useAnimations)
.setCssTheme(cssTheme)
.setPayFeeInBtc(payFeeInBtc)
.setBridgeOptionOrdinal(bridgeOptionOrdinal)
.setTorTransportOrdinal(torTransportOrdinal)
Expand Down Expand Up @@ -247,6 +249,7 @@ public static PersistableEnvelope fromProto(protobuf.PreferencesPayload proto, C
proto.getDirectoryChooserPath(),
proto.getBuyerSecurityDepositAsLong(),
proto.getUseAnimations(),
proto.getCssTheme(),
paymentAccount,
proto.getPayFeeInBtc(),
proto.getBridgeAddressesList().isEmpty() ? null : new ArrayList<>(proto.getBridgeAddressesList()),
Expand Down
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 @@ -936,6 +936,7 @@ setting.preferences.addAltcoin=Add altcoin
setting.preferences.displayOptions=Display options
setting.preferences.showOwnOffers=Show my own offers in offer book
setting.preferences.useAnimations=Use animations
setting.preferences.useDarkMode=Use dark mode (beta)
setting.preferences.sortWithNumOffers=Sort market lists with no. of offers/trades
setting.preferences.resetAllFlags=Reset all \"Don't show again\" flags
setting.preferences.reset=Reset
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/main/java/bisq/desktop/CandleStickChart.css
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@
}

.chart-plot-background {
-fx-background-color: -bs-rd-white;
-fx-background-color: -bs-background-color;
}
23 changes: 19 additions & 4 deletions desktop/src/main/java/bisq/desktop/app/BisqApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public void handleUncaughtException(Throwable throwable, boolean doShutDown) {
log.warn("Scene not available yet, we create a new scene. The bug might be caused by an exception in a constructor or by a circular dependency in Guice. throwable=" + throwable.toString());
scene = new Scene(new StackPane(), 1000, 650);
scene.getStylesheets().setAll(
"/bisq/desktop/theme-light.css",
"/bisq/desktop/bisq.css",
"/bisq/desktop/images.css");
stage.setScene(scene);
Expand Down Expand Up @@ -227,14 +228,28 @@ private Scene createAndConfigScene(MainView mainView, Injector injector) {
maxWindowBounds.height < INITIAL_WINDOW_HEIGHT ?
(maxWindowBounds.height < MIN_WINDOW_HEIGHT ? MIN_WINDOW_HEIGHT : maxWindowBounds.height) :
INITIAL_WINDOW_HEIGHT);
scene.getStylesheets().setAll(
"/bisq/desktop/bisq.css",
"/bisq/desktop/images.css",
"/bisq/desktop/CandleStickChart.css");

addSceneKeyEventHandler(scene, injector);

loadSceneStyles(scene, injector);
injector.getInstance(Preferences.class).getCssThemeProperty().addListener((ov) -> {
loadSceneStyles(scene, injector);
});
return scene;
}

private void loadSceneStyles(Scene scene, Injector injector) {
Boolean useDarkMode = (injector.getInstance(Preferences.class).getCssTheme() == 1);
String colorSheet = "/bisq/desktop/theme-light.css";
if (useDarkMode)
colorSheet = "/bisq/desktop/theme-dark.css";
scene.getStylesheets().setAll(
colorSheet,
"/bisq/desktop/bisq.css",
"/bisq/desktop/images.css",
"/bisq/desktop/CandleStickChart.css");
}

private void setupStage(Scene scene) {
// configure the system tray
SystemTray.create(stage, shutDownHandler);
Expand Down
Loading

0 comments on commit 3ccae69

Please sign in to comment.