gui: remove transaction view in modal

This commit is contained in:
edouard 2023-04-26 13:45:42 +02:00
parent 14b1434374
commit 94e719975e
4 changed files with 164 additions and 146 deletions

View File

@ -93,13 +93,8 @@ impl State for Home {
} else {
&self.events[i - self.pending_events.len()]
};
return view::modal(
false,
self.warning.as_ref(),
view::transactions::tx_view(cache, event),
None::<Element<view::Message>>,
);
}
view::transactions::tx_view(cache, event, self.warning.as_ref())
} else {
view::dashboard(
&Menu::Home,
cache,
@ -114,6 +109,7 @@ impl State for Home {
),
)
}
}
fn update(
&mut self,

View File

@ -5,7 +5,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
use iced::Command;
use liana_ui::widget::*;
use crate::app::{cache::Cache, error::Error, menu::Menu, message::Message, view, State};
use crate::app::{cache::Cache, error::Error, message::Message, view, State};
use crate::daemon::{model::HistoryTransaction, Daemon};
@ -36,20 +36,16 @@ impl State for TransactionsPanel {
} else {
&self.txs[i - self.pending_txs.len()]
};
return view::modal(
false,
self.warning.as_ref(),
view::transactions::tx_view(cache, tx),
None::<Element<view::Message>>,
);
}
view::dashboard(
&Menu::Transactions,
view::transactions::tx_view(cache, tx, self.warning.as_ref())
} else {
view::transactions::transactions_view(
cache,
None,
view::transactions::transactions_view(&self.pending_txs, &self.txs),
&self.pending_txs,
&self.txs,
self.warning.as_ref(),
)
}
}
fn update(
&mut self,

View File

@ -53,7 +53,7 @@ pub fn sidebar<'a>(menu: &Menu, cache: &'a Cache) -> Container<'a, Message> {
.align_items(iced::Alignment::Center),
)
.style(theme::Button::Menu(true))
.on_press(Message::Reload)
.on_press(Message::Menu(Menu::Transactions))
.width(iced::Length::Fill)
} else {
Button::new(

View File

@ -3,6 +3,7 @@ use chrono::NaiveDateTime;
use iced::{alignment, Alignment, Length};
use liana_ui::{
color,
component::{amount::*, badge, card, text::*},
icon, theme,
util::Collection,
@ -10,16 +11,27 @@ use liana_ui::{
};
use crate::{
app::{cache::Cache, view::message::Message},
app::{
cache::Cache,
error::Error,
menu::Menu,
view::{dashboard, message::Message},
},
daemon::model::HistoryTransaction,
};
pub const HISTORY_EVENT_PAGE_SIZE: u64 = 20;
pub fn transactions_view<'a>(
cache: &'a Cache,
pending_txs: &[HistoryTransaction],
txs: &Vec<HistoryTransaction>,
warning: Option<&'a Error>,
) -> Element<'a, Message> {
dashboard(
&Menu::Transactions,
cache,
warning,
Column::new()
.push(Container::new(h3("Transactions")).width(Length::Fill))
.push(
@ -67,7 +79,8 @@ pub fn transactions_view<'a>(
),
)
.align_items(Alignment::Center)
.spacing(30)
.spacing(30),
)
.into()
}
@ -125,26 +138,40 @@ fn tx_list_view<'a>(i: usize, tx: &HistoryTransaction) -> Element<'a, Message> {
.into()
}
pub fn tx_view<'a>(cache: &Cache, tx: &'a HistoryTransaction) -> Element<'a, Message> {
pub fn tx_view<'a>(
cache: &'a Cache,
tx: &'a HistoryTransaction,
warning: Option<&'a Error>,
) -> Element<'a, Message> {
dashboard(
&Menu::Transactions,
cache,
warning,
Column::new()
.push(if tx.is_self_send() {
Container::new(h3("Transaction")).width(Length::Fill)
} else if tx.is_external() {
Container::new(h3("Incoming transaction")).width(Length::Fill)
} else {
Container::new(h3("Outgoing transaction")).width(Length::Fill)
})
.push(
Column::new().spacing(20).push(
Column::new()
.push(if tx.is_self_send() {
Container::new(h1("Self send"))
} else if tx.is_external() {
Container::new(amount_with_size(&tx.incoming_amount, H1_SIZE))
} else {
Container::new(amount_with_size(&tx.outgoing_amount, H1_SIZE))
})
.push_maybe(tx.fee_amount.map(|fee_amount| {
Row::new()
.push(if tx.is_external() {
badge::receive()
} else {
badge::spend()
})
.spacing(10)
.align_items(Alignment::Center),
)
.push(if tx.is_external() {
amount_with_size(&tx.incoming_amount, 50)
} else {
amount_with_size(&tx.outgoing_amount, 50)
})
.push_maybe(
tx.fee_amount
.map(|fee| Row::new().push(text("Miner Fee: ")).push(amount(&fee))),
.align_items(Alignment::Center)
.push(h3("Miner fee: ").style(color::GREY_3))
.push(amount_with_size(&fee_amount, H3_SIZE))
})),
),
)
.push(card::simple(
Column::new()
@ -191,8 +218,7 @@ pub fn tx_view<'a>(cache: &Cache, tx: &'a HistoryTransaction) -> Element<'a, Mes
None
},
))
.align_items(Alignment::Center)
.spacing(20)
.max_width(800)
.spacing(20),
)
.into()
}