Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aspect committed Dec 6, 2023
1 parent addf6c6 commit c8956e5
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 47 deletions.
Empty file.
72 changes: 53 additions & 19 deletions core/src/modules/account_manager/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::imports::*;
use crate::primitives::account;
use std::borrow::Cow;
use egui_phosphor::thin::{CLOUD_ARROW_DOWN, CLOUD_SLASH};
use kaspa_wallet_core::tx::{GeneratorSummary, PaymentOutput, Fees};
use kaspa_wallet_core::api::*;
use crate::primitives::descriptors::*;
Expand All @@ -10,12 +11,20 @@ mod transactions;
mod details;
mod utxo;
mod menus;
mod transfer;
mod send;
mod estimation;
mod secret;

use overview::*;
use transactions::*;
use details::*;
use utxo::*;
use menus::*;
use transfer::*;
use send::*;
use estimation::*;
use secret::*;


#[allow(dead_code)]
Expand All @@ -35,22 +44,25 @@ pub enum AccountManagerSection {
UtxoManager
}

#[derive(Default, Debug, Clone, Copy, Eq, PartialEq)]
// #[derive(Default, Debug, Clone, Copy, Eq, PartialEq)]
// #[derive(Default, Debug, Clone, Eq, PartialEq)]
#[derive(Default, Debug, Clone)]
enum Action {
#[default]
None,
Estimating,
Sending,
// Reset,
Processing,
Error(Arc<Error>),
}


impl Action {
fn is_sending(&self) -> bool {
matches!(self, Action::Sending | Action::Estimating | Action::Processing)
}
}
// impl Action {
// fn is_sending(&self) -> bool {
// matches!(self, Action::Sending | Action::Estimating | Action::Processing)
// }
// }

#[derive(Clone, Copy, Eq, PartialEq)]
enum TransactionKind {
Expand Down Expand Up @@ -115,6 +127,8 @@ impl ManagerContext {
}

fn reset_send_state(&mut self) {
self.action = Action::None;

self.zeroize()
}
}
Expand All @@ -132,7 +146,6 @@ impl Zeroize for ManagerContext {
self.priority_fees_sompi = 0;
*self.estimate.lock().unwrap() = EstimatorStatus::None;
self.address_status = AddressStatus::None;
self.action = Action::None;
self.transaction_kind = None;
self.focus.clear();
self.wallet_secret.zeroize();
Expand Down Expand Up @@ -192,6 +205,13 @@ impl ModuleT for AccountManager {
self.state = AccountManagerState::Select;
}

// fn reload(&mut self, core : &mut Core) {
// if let AccountManagerState::Overview { account } = self.state.clone() {
// let account_id = account.id();
// core.account_collection().get()
// }
// }

fn render(
&mut self,
core: &mut Core,
Expand Down Expand Up @@ -264,6 +284,32 @@ impl AccountManager {
Panel::new(self)
.with_caption("Select Account")
.with_body(|this, ui| {

const SPACING : f32 = 8.;

if !core.state().is_connected() {
ui.add_space(SPACING);
ui.label(
RichText::new(CLOUD_SLASH)
.size(theme_style().icon_size_large)
.color(theme_color().icon_color_default)
);
ui.add_space(SPACING);
ui.label("You are currently not connected to the Kaspa node.");
ui.add_space(SPACING);
} else if !core.state().is_synced() {
ui.add_space(SPACING);
ui.label(
RichText::new(CLOUD_ARROW_DOWN)
.size(theme_style().icon_size_medium)
.color(theme_color().icon_color_default)
);
ui.add_space(SPACING);
ui.label("The node is currently syncing with the Kaspa p2p network. Account balances may be out of date.");
ui.add_space(SPACING);
}


account_collection.iter().for_each(|account_select| {
if ui.account_selector_button(account_select, &network_type, false).clicked() {
this.select(Some(account_select.clone()));
Expand Down Expand Up @@ -321,12 +367,6 @@ impl AccountManager {
.exact_width(panel_width)
.resizable(false)
.show_separator_line(true)
// .frame(
// Frame::default()
// .inner_margin(0.)
// .outer_margin(4.)
// .fill(ui.ctx().style().visuals.panel_fill),
// )
.show_inside(ui, |ui| {
Overview::new(&mut self.context).render(core,ui,rc);
});
Expand All @@ -335,12 +375,6 @@ impl AccountManager {
.exact_width(panel_width)
.resizable(false)
.show_separator_line(false)
// .frame(
// Frame::default()
// .inner_margin(0.)
// .outer_margin(4.)
// .fill(ui.ctx().style().visuals.panel_fill),
// )
.show_inside(ui, |ui| {
ui.separator();

Expand Down
21 changes: 21 additions & 0 deletions core/src/modules/account_manager/secret.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use crate::imports::*;
use super::*;

pub struct AccountSecret<'render> {
core : &'render mut Core,
manager : &'render AccountManager,
}

impl<'render> AccountSecret<'render> {

pub fn new(core : &'render mut Core, manager : &'render AccountManager) -> Self {
Self { core, manager }
}

pub fn render(&mut self, ui : &mut Ui, rc : &RenderContext<'_>) {


}


}
Empty file.
Empty file.
20 changes: 11 additions & 9 deletions core/src/modules/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl ModuleT for Export {
match self.state.clone() {

State::Select => {
let prv_key_data_list = core.prv_key_data_map.values().cloned().collect::<Vec<_>>();
// let prv_key_data_list = core.prv_key_data_map.values().cloned().collect::<Vec<_>>();

let mut submit = false;
Panel::new(self)
Expand Down Expand Up @@ -163,8 +163,8 @@ impl ModuleT for Export {


})
.with_footer(|_this,_ui| {
})
// .with_footer(|_this,_ui| {
// })
.render(ui);

if submit {
Expand All @@ -185,7 +185,7 @@ impl ModuleT for Export {
}

State::SelectPrvKey => {
let prv_key_data_list = core.prv_key_data_map.values().cloned().collect::<Vec<_>>();
let prv_key_data_map = core.prv_key_data_map.clone(); //values().cloned().collect::<Vec<_>>();

let mut submit = false;
Panel::new(self)
Expand All @@ -208,12 +208,14 @@ impl ModuleT for Export {
ui.label("Please select private key to export");
ui.label("");

for prv_key_data_info in prv_key_data_list.into_iter() {
if ui.large_button(prv_key_data_info.name_or_id()).clicked() {
this.context.prv_key_data_id = Some(*prv_key_data_info.id());
submit = true;
if let Some(prv_key_data_map) = prv_key_data_map {
for prv_key_data_info in prv_key_data_map.values() {
if ui.large_button(prv_key_data_info.name_or_id()).clicked() {
this.context.prv_key_data_id = Some(*prv_key_data_info.id());
submit = true;
}
ui.label("");
}
ui.label("");
}

})
Expand Down
3 changes: 2 additions & 1 deletion core/src/primitives/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ impl AccountSelectorButtonExtension for Ui {
let account_name = account.name_or_id();

let icon = if selected {
Composite::icon(egui_phosphor::thin::CHECK)
// Composite::icon(egui_phosphor::thin::CHECK)
Composite::icon(egui_phosphor::thin::ARROW_FAT_RIGHT)
} else {
Composite::icon(egui_phosphor::thin::LIST_DASHES)
};
Expand Down
Loading

0 comments on commit c8956e5

Please sign in to comment.