|
|
@@ -16,8 +16,7 @@ use crate::{
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
|
pub enum TickerTab {
|
|
|
- All,
|
|
|
- Bybit,
|
|
|
+ ChinaFutures,
|
|
|
Binance,
|
|
|
Favorites,
|
|
|
}
|
|
|
@@ -73,7 +72,7 @@ impl TickersTable {
|
|
|
combined_tickers: Vec::new(),
|
|
|
display_cache: HashMap::new(),
|
|
|
favorited_tickers,
|
|
|
- selected_tab: TickerTab::All,
|
|
|
+ selected_tab: TickerTab::ChinaFutures,
|
|
|
search_query: String::new(),
|
|
|
show_sort_options: false,
|
|
|
selected_sort_option: SortOptions::VolumeDesc,
|
|
|
@@ -213,7 +212,7 @@ impl TickersTable {
|
|
|
|
|
|
fn matches_exchange(ex: &Exchange, tab: &TickerTab) -> bool {
|
|
|
match tab {
|
|
|
- TickerTab::Bybit => matches!(ex, Exchange::ChinaFutures),
|
|
|
+ TickerTab::ChinaFutures => matches!(ex, Exchange::ChinaFutures),
|
|
|
TickerTab::Binance => matches!(ex, Exchange::BinanceFutures | Exchange::BinanceSpot),
|
|
|
_ => false,
|
|
|
}
|
|
|
@@ -294,8 +293,7 @@ impl TickersTable {
|
|
|
}
|
|
|
|
|
|
pub fn view(&self, bounds: Size) -> Element<'_, Message> {
|
|
|
- let all_button = create_tab_button(text("ALL"), &self.selected_tab, TickerTab::All);
|
|
|
- let china_futures_button = create_tab_button(text("ChinaF"), &self.selected_tab, TickerTab::Bybit);
|
|
|
+ let china_futures_button = create_tab_button(text("ChinaF"), &self.selected_tab, TickerTab::ChinaFutures);
|
|
|
let binance_button =
|
|
|
create_tab_button(text("Binance"), &self.selected_tab, TickerTab::Binance);
|
|
|
let favorites_button = create_tab_button(
|
|
|
@@ -421,13 +419,12 @@ impl TickersTable {
|
|
|
container(column![])
|
|
|
},
|
|
|
row![
|
|
|
- favorites_button,
|
|
|
- Space::new(Length::FillPortion(1), Length::Shrink),
|
|
|
- all_button,
|
|
|
Space::new(Length::FillPortion(1), Length::Shrink),
|
|
|
china_futures_button,
|
|
|
Space::new(Length::FillPortion(1), Length::Shrink),
|
|
|
binance_button,
|
|
|
+ Space::new(Length::FillPortion(1), Length::Shrink),
|
|
|
+ favorites_button,
|
|
|
]
|
|
|
.padding(padding::bottom(4)),
|
|
|
]
|
|
|
@@ -436,28 +433,6 @@ impl TickersTable {
|
|
|
.width(Length::Fill);
|
|
|
|
|
|
match self.selected_tab {
|
|
|
- TickerTab::All => {
|
|
|
- content =
|
|
|
- self.combined_tickers
|
|
|
- .iter()
|
|
|
- .filter(|(_, ticker, _, _)| {
|
|
|
- let (ticker, market) = ticker.get_string();
|
|
|
- ticker.contains(&self.search_query) && match self.selected_market {
|
|
|
- Some(market_type) => market == market_type,
|
|
|
- None => true,
|
|
|
- }
|
|
|
- })
|
|
|
- .enumerate()
|
|
|
- .fold(
|
|
|
- content,
|
|
|
- |content, (index, (exchange, ticker, _, is_fav))| {
|
|
|
- let is_visible = self.is_container_visible(index, bounds);
|
|
|
- content.push(self.create_ticker_container(
|
|
|
- is_visible, *exchange, ticker, *is_fav,
|
|
|
- ))
|
|
|
- },
|
|
|
- );
|
|
|
- }
|
|
|
TickerTab::Favorites => {
|
|
|
content = self
|
|
|
.combined_tickers
|