Skip to content

Commit

Permalink
wallet: update asset details panel on asset change
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Jul 21, 2023
1 parent ac8dc3c commit 25051c8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/view/wallet/view_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub struct ViewModel {

path: PathBuf,

#[getter(skip)]
asset: Option<ContractId>,

#[getter(as_mut)]
Expand Down
23 changes: 13 additions & 10 deletions src/view/wallet/wallet.glade
Original file line number Diff line number Diff line change
Expand Up @@ -656,13 +656,14 @@
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">center</property>
<property name="valign">end</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<property name="vexpand">False</property>
<property name="column-spacing">12</property>
<property name="baseline-row">1</property>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="value_lbl">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
Expand All @@ -685,7 +686,7 @@
<property name="halign">start</property>
<property name="valign">baseline</property>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="b_lbl">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">baseline</property>
Expand Down Expand Up @@ -737,7 +738,7 @@
</packing>
</child>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="s_lbl">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">baseline</property>
Expand All @@ -762,7 +763,7 @@
</packing>
</child>
<child>
<object class="GtkSeparator">
<object class="GtkSeparator" id="sep1">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
Expand All @@ -772,7 +773,7 @@
</packing>
</child>
<child>
<object class="GtkBox">
<object class="GtkBox" id="fiat_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
Expand Down Expand Up @@ -853,7 +854,7 @@
</packing>
</child>
<child>
<object class="GtkSeparator">
<object class="GtkSeparator" id="sep2">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
Expand All @@ -864,7 +865,7 @@
</packing>
</child>
<child>
<object class="GtkBox">
<object class="GtkBox" id="price_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
Expand Down Expand Up @@ -918,7 +919,7 @@
</packing>
</child>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="price_lbl">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
Expand All @@ -938,6 +939,8 @@
<object class="GtkBox" id="contract_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">end</property>
<property name="vexpand">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
Expand Down Expand Up @@ -977,7 +980,7 @@
</packing>
</child>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="fiat_lbl">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
Expand Down
27 changes: 25 additions & 2 deletions src/view/wallet/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use gtk::gdk_pixbuf::Pixbuf;
use gtk::prelude::*;
use gtk::{
gdk, Adjustment, ApplicationWindow, Button, CheckButton, Entry, HeaderBar, Image, Label,
ListBox, ListStore, Menu, MenuItem, Popover, RadioMenuItem, SortColumn, SortType, SpinButton,
Spinner, Statusbar, TextBuffer, TreeView,
ListBox, ListStore, Menu, MenuItem, Popover, RadioMenuItem, Separator, SortColumn, SortType,
SpinButton, Spinner, Statusbar, TextBuffer, TreeView,
};
use relm::Relm;
use wallet::hd::SegmentIndexes;
Expand Down Expand Up @@ -82,11 +82,21 @@ pub struct Widgets {
contract_box: gtk::Box,
contract_entry: Entry,

b_lbl: Label,
s_lbl: Label,
balance_btc_lbl: Label,
balance_sat_lbl: Label,
balance_fiat_lbl: Label,
balance_cents_lbl: Label,

fiat_box: gtk::Box,
price_box: gtk::Box,
value_lbl: Label,
fiat_lbl: Label,
price_lbl: Label,
sep1: Separator,
sep2: Separator,

exchange_lbl: Label,
fiat_usd: RadioMenuItem,
fiat_eur: RadioMenuItem,
Expand Down Expand Up @@ -454,6 +464,19 @@ impl Widgets {
let info = model.asset_info();
self.ticker_lbl.set_text(&info.ticker());
self.asset_lbl.set_text(&info.name());
self.contract_entry.set_text(&info.contract_name());

let is_asset = model.asset().is_some();
self.contract_box.set_visible(is_asset);
self.value_lbl.set_visible(!is_asset);
self.b_lbl.set_visible(!is_asset);
self.s_lbl.set_visible(!is_asset);
self.fiat_box.set_visible(!is_asset);
self.fiat_lbl.set_visible(!is_asset);
self.price_box.set_visible(!is_asset);
self.price_lbl.set_visible(!is_asset);
self.sep1.set_visible(!is_asset);
self.sep2.set_visible(!is_asset);
}

fn bind_asset_model(&self, model: &AssetModel) {
Expand Down

0 comments on commit 25051c8

Please sign in to comment.