txs: pull to refresh

This commit is contained in:
ardocrat 2024-05-17 19:15:25 +03:00
parent 8ff6fd1c20
commit f118ad7d07
3 changed files with 37 additions and 17 deletions

10
Cargo.lock generated
View file

@ -2691,6 +2691,15 @@ dependencies = [
"winit", "winit",
] ]
[[package]]
name = "egui_pull_to_refresh"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c649d50513fc760df6d6ad74b739189f2768e81df3ec734f1f280bcf68e33c75"
dependencies = [
"egui",
]
[[package]] [[package]]
name = "either" name = "either"
version = "1.11.0" version = "1.11.0"
@ -3769,6 +3778,7 @@ dependencies = [
"eframe", "eframe",
"egui", "egui",
"egui_extras", "egui_extras",
"egui_pull_to_refresh",
"env_logger 0.10.2", "env_logger 0.10.2",
"eye", "eye",
"fs-mistrust", "fs-mistrust",

View file

@ -36,6 +36,7 @@ grin_wallet_controller = "5.3.0"
egui = { version = "0.27.2", default-features = false } egui = { version = "0.27.2", default-features = false }
egui_extras = { version = "0.27.2", features = ["image", "svg"] } egui_extras = { version = "0.27.2", features = ["image", "svg"] }
rust-i18n = "2.3.1" rust-i18n = "2.3.1"
egui_pull_to_refresh = "0.4.0"
## other ## other
thiserror = "1.0.58" thiserror = "1.0.58"

View file

@ -14,6 +14,7 @@
use egui::{Align, Id, Layout, Margin, RichText, Rounding, ScrollArea}; use egui::{Align, Id, Layout, Margin, RichText, Rounding, ScrollArea};
use egui::scroll_area::ScrollBarVisibility; use egui::scroll_area::ScrollBarVisibility;
use egui_pull_to_refresh::PullToRefresh;
use grin_core::core::amount_to_hr_string; use grin_core::core::amount_to_hr_string;
use grin_util::ToHex; use grin_util::ToHex;
use grin_wallet_libwallet::{Slate, SlateState, TxLogEntryType}; use grin_wallet_libwallet::{Slate, SlateState, TxLogEntryType};
@ -178,6 +179,8 @@ impl WalletTransactions {
// Show list of transactions. // Show list of transactions.
ui.add_space(4.0); ui.add_space(4.0);
let refresh_resp = PullToRefresh::new(wallet.syncing()).scroll_area_ui(ui, |ui| {
ScrollArea::vertical() ScrollArea::vertical()
.scroll_bar_visibility(ScrollBarVisibility::AlwaysVisible) .scroll_bar_visibility(ScrollBarVisibility::AlwaysVisible)
.id_source(Id::from("txs_content").with(wallet.get_config().id)) .id_source(Id::from("txs_content").with(wallet.get_config().id))
@ -194,7 +197,13 @@ impl WalletTransactions {
self.tx_item_ui(ui, tx, rounding, extra_padding, true, &data, wallet, cb); self.tx_item_ui(ui, tx, rounding, extra_padding, true, &data, wallet, cb);
} }
}); });
})
}); });
// Sync wallet on refresh.
if refresh_resp.should_refresh() {
wallet.sync();
}
} }
/// Draw [`Modal`] content for this ui container. /// Draw [`Modal`] content for this ui container.