mirror of
https://github.com/jwinterm/grim.git
synced 2026-11-24 23:03:57 +01:00
ui: hidden scrollbar, wallet sync indicator
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
use std::time::Duration;
|
||||
use egui::{Align, Id, Layout, Margin, RichText, ScrollArea};
|
||||
use egui::scroll_area::ScrollBarVisibility;
|
||||
use grin_chain::SyncStatus;
|
||||
use grin_core::core::amount_to_hr_string;
|
||||
|
||||
@@ -239,7 +240,7 @@ impl WalletContent {
|
||||
|
||||
// Show confirmed height.
|
||||
let height_text = format!("{} {}", PACKAGE, data.info.last_confirmed_height);
|
||||
ui.label(RichText::new(height_text).size(15.0).color(Colors::GRAY));
|
||||
View::animate_text(ui, height_text, 15.0, Colors::GRAY, wallet.syncing());
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -316,8 +317,9 @@ impl WalletContent {
|
||||
// Show list of accounts.
|
||||
let size = self.accounts.len();
|
||||
ScrollArea::vertical()
|
||||
.max_height(266.0)
|
||||
.id_source("account_list_modal_scroll")
|
||||
.scroll_bar_visibility(ScrollBarVisibility::AlwaysHidden)
|
||||
.max_height(266.0)
|
||||
.auto_shrink([true; 2])
|
||||
.show_rows(ui, ACCOUNT_ITEM_HEIGHT, size, |ui, row_range| {
|
||||
for index in row_range {
|
||||
@@ -374,8 +376,9 @@ impl WalletContent {
|
||||
View::horizontal_line(ui, Colors::ITEM_STROKE);
|
||||
ui.add_space(3.0);
|
||||
ScrollArea::vertical()
|
||||
.max_height(128.0)
|
||||
.id_source(Id::from("qr_scan_result_input").with(wallet.get_config().id))
|
||||
.scroll_bar_visibility(ScrollBarVisibility::AlwaysHidden)
|
||||
.max_height(128.0)
|
||||
.auto_shrink([false; 2])
|
||||
.show(ui, |ui| {
|
||||
ui.add_space(7.0);
|
||||
|
||||
@@ -112,7 +112,7 @@ impl WalletTab for WalletMessages {
|
||||
})
|
||||
.show_inside(ui, |ui| {
|
||||
ScrollArea::vertical()
|
||||
.scroll_bar_visibility(ScrollBarVisibility::AlwaysVisible)
|
||||
.scroll_bar_visibility(ScrollBarVisibility::AlwaysHidden)
|
||||
.id_source(Id::from("wallet_messages").with(wallet.get_config().id))
|
||||
.auto_shrink([false; 2])
|
||||
.show(ui, |ui| {
|
||||
@@ -305,8 +305,9 @@ impl WalletMessages {
|
||||
"response_input"
|
||||
}).with(wallet.get_config().id);
|
||||
ScrollArea::vertical()
|
||||
.max_height(128.0)
|
||||
.id_source(scroll_id)
|
||||
.scroll_bar_visibility(ScrollBarVisibility::AlwaysHidden)
|
||||
.max_height(128.0)
|
||||
.auto_shrink([false; 2])
|
||||
.show(ui, |ui| {
|
||||
ui.add_space(7.0);
|
||||
@@ -767,8 +768,9 @@ impl WalletMessages {
|
||||
Id::from("receive_request").with(wallet.get_config().id)
|
||||
};
|
||||
ScrollArea::vertical()
|
||||
.max_height(128.0)
|
||||
.id_source(scroll_id)
|
||||
.scroll_bar_visibility(ScrollBarVisibility::AlwaysHidden)
|
||||
.max_height(128.0)
|
||||
.auto_shrink([false; 2])
|
||||
.show(ui, |ui| {
|
||||
ui.add_space(7.0);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
use egui::{Id, Margin, ScrollArea};
|
||||
use egui::scroll_area::ScrollBarVisibility;
|
||||
|
||||
use crate::gui::Colors;
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
@@ -77,6 +78,7 @@ impl WalletTab for WalletSettings {
|
||||
ScrollArea::vertical()
|
||||
.id_source(Id::from("wallet_settings_scroll").with(wallet.get_config().id))
|
||||
.auto_shrink([false; 2])
|
||||
.scroll_bar_visibility(ScrollBarVisibility::AlwaysHidden)
|
||||
.show(ui, |ui| {
|
||||
ui.vertical_centered(|ui| {
|
||||
View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| {
|
||||
|
||||
@@ -94,8 +94,8 @@ impl WalletTab for WalletTransport {
|
||||
})
|
||||
.show_inside(ui, |ui| {
|
||||
ScrollArea::vertical()
|
||||
.scroll_bar_visibility(ScrollBarVisibility::AlwaysVisible)
|
||||
.id_source(Id::from("wallet_transport").with(wallet.get_config().id))
|
||||
.scroll_bar_visibility(ScrollBarVisibility::AlwaysHidden)
|
||||
.auto_shrink([false; 2])
|
||||
.show(ui, |ui| {
|
||||
ui.vertical_centered(|ui| {
|
||||
|
||||
@@ -46,7 +46,10 @@ pub struct WalletTransactions {
|
||||
tx_info_finalize: bool,
|
||||
|
||||
/// Transaction identifier to use at confirmation[`Modal`].
|
||||
confirm_cancel_tx_id: Option<u32>
|
||||
confirm_cancel_tx_id: Option<u32>,
|
||||
|
||||
/// Flag to check if sync of wallet was initiated manually.
|
||||
manual_sync: bool
|
||||
}
|
||||
|
||||
impl Default for WalletTransactions {
|
||||
@@ -59,6 +62,7 @@ impl Default for WalletTransactions {
|
||||
tx_info_finalize_error: false,
|
||||
tx_info_finalize: false,
|
||||
confirm_cancel_tx_id: None,
|
||||
manual_sync: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,17 +122,17 @@ impl WalletTransactions {
|
||||
wallet: &mut Wallet,
|
||||
data: &WalletData,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
let amount_awaiting_conf = data.info.amount_awaiting_confirmation;
|
||||
let amount_awaiting_fin = data.info.amount_awaiting_finalization;
|
||||
let amount_conf = data.info.amount_awaiting_confirmation;
|
||||
let amount_fin = data.info.amount_awaiting_finalization;
|
||||
let amount_locked = data.info.amount_locked;
|
||||
|
||||
// Show transactions info.
|
||||
View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| {
|
||||
|
||||
// Show non-zero awaiting confirmation amount.
|
||||
if amount_awaiting_conf != 0 {
|
||||
let awaiting_conf = amount_to_hr_string(amount_awaiting_conf, true);
|
||||
let rounding = if amount_awaiting_fin != 0 || amount_locked != 0 {
|
||||
if amount_conf != 0 {
|
||||
let awaiting_conf = amount_to_hr_string(amount_conf, true);
|
||||
let rounding = if amount_fin != 0 || amount_locked != 0 {
|
||||
[false, false, false, false]
|
||||
} else {
|
||||
[false, false, true, true]
|
||||
@@ -140,8 +144,8 @@ impl WalletTransactions {
|
||||
}
|
||||
|
||||
// Show non-zero awaiting finalization amount.
|
||||
if amount_awaiting_fin != 0 {
|
||||
let awaiting_conf = amount_to_hr_string(amount_awaiting_fin, true);
|
||||
if amount_fin != 0 {
|
||||
let awaiting_conf = amount_to_hr_string(amount_fin, true);
|
||||
let rounding = if amount_locked != 0 {
|
||||
[false, false, false, false]
|
||||
} else {
|
||||
@@ -177,32 +181,40 @@ impl WalletTransactions {
|
||||
}
|
||||
});
|
||||
|
||||
// Show list of transactions.
|
||||
ui.add_space(4.0);
|
||||
|
||||
let refresh_resp = PullToRefresh::new(wallet.syncing()).scroll_area_ui(ui, |ui| {
|
||||
ScrollArea::vertical()
|
||||
.scroll_bar_visibility(ScrollBarVisibility::AlwaysVisible)
|
||||
.id_source(Id::from("txs_content").with(wallet.get_config().id))
|
||||
.auto_shrink([false; 2])
|
||||
.show_rows(ui, TX_ITEM_HEIGHT, data.txs.len(), |ui, row_range| {
|
||||
ui.add_space(3.0);
|
||||
View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| {
|
||||
let extra_padding = amount_awaiting_conf != 0 || amount_awaiting_fin != 0 ||
|
||||
amount_locked != 0;
|
||||
for index in row_range {
|
||||
// Show transaction item.
|
||||
let tx = data.txs.get(index).unwrap();
|
||||
let rounding = View::item_rounding(index, data.txs.len(), false);
|
||||
self.tx_item_ui(ui, tx, rounding, extra_padding, true, &data, wallet, cb);
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
// Show list of transactions.
|
||||
let syncing = wallet.syncing();
|
||||
// Reset manual sync flag when wallet is not syncing.
|
||||
if !syncing {
|
||||
self.manual_sync = false;
|
||||
}
|
||||
let refresh_resp = PullToRefresh::new(syncing && self.manual_sync)
|
||||
.min_refresh_distance(70.0)
|
||||
.can_refresh(!wallet.syncing())
|
||||
.scroll_area_ui(ui, |ui| {
|
||||
ScrollArea::vertical()
|
||||
.id_source(Id::from("txs_content").with(wallet.get_config().id))
|
||||
.scroll_bar_visibility(ScrollBarVisibility::AlwaysHidden)
|
||||
.auto_shrink([false; 2])
|
||||
.show_rows(ui, TX_ITEM_HEIGHT, data.txs.len(), |ui, row_range| {
|
||||
ui.add_space(3.0);
|
||||
View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| {
|
||||
let padding = amount_conf != 0 || amount_fin != 0 || amount_locked != 0;
|
||||
for index in row_range {
|
||||
// Show transaction item.
|
||||
let tx = data.txs.get(index).unwrap();
|
||||
let rounding = View::item_rounding(index, data.txs.len(), false);
|
||||
self.tx_item_ui(ui, tx, rounding, padding, true, &data, wallet, cb);
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
// Sync wallet on refresh.
|
||||
if refresh_resp.should_refresh() {
|
||||
wallet.sync();
|
||||
self.manual_sync = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -640,8 +652,9 @@ impl WalletTransactions {
|
||||
View::horizontal_line(ui, Colors::ITEM_STROKE);
|
||||
ui.add_space(3.0);
|
||||
ScrollArea::vertical()
|
||||
.max_height(128.0)
|
||||
.id_source(input_id)
|
||||
.scroll_bar_visibility(ScrollBarVisibility::AlwaysHidden)
|
||||
.max_height(128.0)
|
||||
.auto_shrink([false; 2])
|
||||
.show(ui, |ui| {
|
||||
ui.add_space(7.0);
|
||||
|
||||
Reference in New Issue
Block a user