Skip to content

Commit

Permalink
PE0025 Update CandlesView
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Sirosh committed Dec 1, 2019
1 parent 84ee2e6 commit 577bf5c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/artemsirosh/hitbtc/model/Candle.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Created on 24 Nov, 2019.
*
* Candles are used for representation of a specific symbol as
* Candles are using for representation of a specific symbol as
* <a href="https://en.wikipedia.org/wiki/Open-high-low-close_chart">OHLC</a>
* chart.
*
Expand All @@ -32,12 +32,12 @@ public class Candle {
private final String close;

/**
* Lowest price for the period.
* The lowest price for the period.
*/
private final String min;

/**
* Highest price for the period.
* The highest price for the period.
*/
private final String max;

Expand Down
44 changes: 31 additions & 13 deletions src/main/java/com/artemsirosh/hitbtc/view/CandlesView.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package com.artemsirosh.hitbtc.view;

import com.artemsirosh.hitbtc.client.CandleClient;
import com.artemsirosh.hitbtc.model.Candle;
import com.artemsirosh.hitbtc.model.Periods;
import com.vaadin.flow.component.Composite;
import com.vaadin.flow.component.Tag;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.html.*;
import com.vaadin.flow.component.listbox.ListBox;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.data.provider.DataProvider;
import com.vaadin.flow.router.BeforeEvent;
import com.vaadin.flow.router.HasUrlParameter;
import com.vaadin.flow.router.Route;
Expand All @@ -30,24 +37,35 @@
public class CandlesView extends Composite<VerticalLayout> implements HasUrlParameter<String> {

private final Consumer<String> symbolParamProcessor;
private final CandleClient candleClient;

public CandlesView() {
public CandlesView(CandleClient candleClient) {
this.candleClient = candleClient;
this.symbolParamProcessor = s -> {};

final Article noData = new Article();
noData.add("Symbol is not be selected");
noData.getStyle().set("font-size", "var(--lumo-font-size-xxl)");
noData.getStyle().set("color", "var(--lumo-tertiary-text-color)");
getContent().setHorizontalComponentAlignment(FlexComponent.Alignment.CENTER, noData);
final ComboBox<Periods> periodsSelect = new ComboBox<>();
periodsSelect.setItems(Periods.values());
periodsSelect.setValue(Periods.M30);
periodsSelect.setLabel("Time periods");

this.symbolParamProcessor = symbol -> {
getContent().remove(noData);
getContent().add(new H4("The symbol is " + symbol));
};

getContent().setWidth("100%");
getContent().add(new H2("Candles"), noData);

log.info("CandlesView instantiated.");
final HorizontalLayout filters = new HorizontalLayout();
filters.add(periodsSelect);

// final Grid<Candle> grid = new Grid<>(Candle.class);
// grid.setColumns();
// grid.addColumn(Candle::getTimestamp).setHeader("Opening Date");
// grid.addColumn(Candle::getOpen).setHeader("Opening Price");
// grid.addColumn(Candle::getClose).setHeader("Closing Price");
// grid.addColumn(Candle::getMax).setHeader("Maximum Price");
// grid.addColumn(Candle::getMin).setHeader("Minimum Price");
// grid.addColumn(Candle::getVolume).setHeader("Base Currency Volume");
// grid.addColumn(Candle::getVolumeQuote).setHeader("Quote Currency Volume");

final H3 symbolName = new H3();
this.getContent().add(symbolName, filters);

}

@Override
Expand Down

0 comments on commit 577bf5c

Please sign in to comment.