ui: logo at wallet list
This commit is contained in:
parent
69b7fc2fac
commit
b78ba0bfb5
3 changed files with 41 additions and 39 deletions
|
@ -23,7 +23,7 @@ use egui::epaint::text::TextWrapping;
|
||||||
use egui::os::OperatingSystem;
|
use egui::os::OperatingSystem;
|
||||||
use egui::text::{LayoutJob, TextFormat};
|
use egui::text::{LayoutJob, TextFormat};
|
||||||
use egui::text_edit::TextEditState;
|
use egui::text_edit::TextEditState;
|
||||||
use crate::AppConfig;
|
use crate::{AppConfig, built_info};
|
||||||
|
|
||||||
use crate::gui::Colors;
|
use crate::gui::Colors;
|
||||||
use crate::gui::icons::{CHECK_SQUARE, CLIPBOARD_TEXT, COPY, EYE, EYE_SLASH, SCAN, SQUARE};
|
use crate::gui::icons::{CHECK_SQUARE, CLIPBOARD_TEXT, COPY, EYE, EYE_SLASH, SCAN, SQUARE};
|
||||||
|
@ -33,6 +33,14 @@ use crate::gui::views::types::TextEditOptions;
|
||||||
pub struct View;
|
pub struct View;
|
||||||
|
|
||||||
impl View {
|
impl View {
|
||||||
|
/// Format timestamp in seconds with local UTC offset.
|
||||||
|
pub fn format_time(ts: i64) -> String {
|
||||||
|
let utc_offset = chrono::Local::now().offset().local_minus_utc();
|
||||||
|
let utc_time = ts + utc_offset as i64;
|
||||||
|
let tx_time = chrono::DateTime::from_timestamp(utc_time, 0).unwrap();
|
||||||
|
tx_time.format("%d/%m/%Y %H:%M:%S").to_string()
|
||||||
|
}
|
||||||
|
|
||||||
/// Get default stroke around views.
|
/// Get default stroke around views.
|
||||||
pub fn default_stroke() -> Stroke {
|
pub fn default_stroke() -> Stroke {
|
||||||
Stroke { width: 1.0, color: Colors::stroke() }
|
Stroke { width: 1.0, color: Colors::stroke() }
|
||||||
|
@ -619,12 +627,26 @@ impl View {
|
||||||
Stroke { width: 1.0, color });
|
Stroke { width: 1.0, color });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Format timestamp in seconds with local UTC offset.
|
/// Draw application logo image with name and version.
|
||||||
pub fn format_time(ts: i64) -> String {
|
pub fn app_logo_name_version(ui: &mut egui::Ui) {
|
||||||
let utc_offset = chrono::Local::now().offset().local_minus_utc();
|
ui.add_space(-1.0);
|
||||||
let utc_time = ts + utc_offset as i64;
|
let logo = if AppConfig::dark_theme().unwrap_or(false) {
|
||||||
let tx_time = chrono::DateTime::from_timestamp(utc_time, 0).unwrap();
|
egui::include_image!("../../../img/logo_light.png")
|
||||||
tx_time.format("%d/%m/%Y %H:%M:%S").to_string()
|
} else {
|
||||||
|
egui::include_image!("../../../img/logo.png")
|
||||||
|
};
|
||||||
|
// Show application logo and name.
|
||||||
|
egui::Image::new(logo).fit_to_exact_size(egui::vec2(180.0, 180.0)).ui(ui);
|
||||||
|
ui.add_space(-17.0);
|
||||||
|
ui.label(RichText::new("GRIM")
|
||||||
|
.size(24.0)
|
||||||
|
.color(Colors::white_or_black(true))
|
||||||
|
);
|
||||||
|
ui.add_space(-2.0);
|
||||||
|
ui.label(RichText::new(built_info::PKG_VERSION)
|
||||||
|
.size(16.0)
|
||||||
|
.color(Colors::white_or_black(true))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get top display inset (cutout) size.
|
/// Get top display inset (cutout) size.
|
||||||
|
|
|
@ -101,7 +101,7 @@ impl WalletsContent {
|
||||||
|
|
||||||
// Setup panels parameters.
|
// Setup panels parameters.
|
||||||
let dual_panel = is_dual_panel_mode(ui);
|
let dual_panel = is_dual_panel_mode(ui);
|
||||||
let open_wallet_panel = dual_panel || show_wallet || create_wallet || empty_list;
|
let open_wallet_panel = show_wallet || create_wallet || empty_list;
|
||||||
let wallet_panel_width = self.wallet_panel_width(ui, empty_list, dual_panel, show_wallet);
|
let wallet_panel_width = self.wallet_panel_width(ui, empty_list, dual_panel, show_wallet);
|
||||||
let content_width = ui.available_width();
|
let content_width = ui.available_width();
|
||||||
|
|
||||||
|
@ -169,8 +169,7 @@ impl WalletsContent {
|
||||||
// Setup flag to show wallets bottom panel if wallet is not showing
|
// Setup flag to show wallets bottom panel if wallet is not showing
|
||||||
// at non-dual panel mode and network is no open or showing at dual panel mode.
|
// at non-dual panel mode and network is no open or showing at dual panel mode.
|
||||||
let show_bottom_panel = !list_hidden &&
|
let show_bottom_panel = !list_hidden &&
|
||||||
((!show_wallet && !dual_panel && !Root::is_network_panel_open()) ||
|
((!show_wallet && !dual_panel && !Root::is_network_panel_open()) || dual_panel);
|
||||||
(dual_panel && show_wallet));
|
|
||||||
|
|
||||||
// Show wallets bottom panel.
|
// Show wallets bottom panel.
|
||||||
egui::TopBottomPanel::bottom("wallets_bottom_panel")
|
egui::TopBottomPanel::bottom("wallets_bottom_panel")
|
||||||
|
@ -223,7 +222,7 @@ impl WalletsContent {
|
||||||
ui.ctx().request_repaint_after(Duration::from_millis(1000));
|
ui.ctx().request_repaint_after(Duration::from_millis(1000));
|
||||||
}
|
}
|
||||||
// Show list of wallets.
|
// Show list of wallets.
|
||||||
self.wallet_list_ui(ui, dual_panel, cb);
|
self.wallet_list_ui(ui, cb);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,7 +330,6 @@ impl WalletsContent {
|
||||||
/// Draw list of wallets.
|
/// Draw list of wallets.
|
||||||
fn wallet_list_ui(&mut self,
|
fn wallet_list_ui(&mut self,
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
dual_panel: bool,
|
|
||||||
cb: &dyn PlatformCallbacks) {
|
cb: &dyn PlatformCallbacks) {
|
||||||
ui.scope(|ui| {
|
ui.scope(|ui| {
|
||||||
ScrollArea::vertical()
|
ScrollArea::vertical()
|
||||||
|
@ -340,16 +338,11 @@ impl WalletsContent {
|
||||||
.auto_shrink([false; 2])
|
.auto_shrink([false; 2])
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
ui.vertical_centered(|ui| {
|
ui.vertical_centered(|ui| {
|
||||||
if !dual_panel {
|
View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| {
|
||||||
ui.add_space(1.0);
|
// Show application logo and name.
|
||||||
}
|
View::app_logo_name_version(ui);
|
||||||
// Setup wallet list width.
|
ui.add_space(20.0);
|
||||||
let max_width = if !dual_panel {
|
|
||||||
Root::SIDE_PANEL_WIDTH * 1.3
|
|
||||||
} else {
|
|
||||||
ui.available_width()
|
|
||||||
};
|
|
||||||
View::max_width_ui(ui, max_width, |ui| {
|
|
||||||
let mut list = self.wallets.list().clone();
|
let mut list = self.wallets.list().clone();
|
||||||
// Remove deleted wallet from the list.
|
// Remove deleted wallet from the list.
|
||||||
list.retain(|w| !w.is_deleted());
|
list.retain(|w| !w.is_deleted());
|
||||||
|
|
|
@ -12,11 +12,10 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use egui::{Id, Margin, RichText, ScrollArea, vec2, Widget};
|
use egui::{Id, Margin, RichText, ScrollArea};
|
||||||
use egui::scroll_area::ScrollBarVisibility;
|
use egui::scroll_area::ScrollBarVisibility;
|
||||||
use grin_util::ZeroingString;
|
use grin_util::ZeroingString;
|
||||||
|
|
||||||
use crate::{AppConfig, built_info};
|
|
||||||
use crate::gui::Colors;
|
use crate::gui::Colors;
|
||||||
use crate::gui::icons::{CHECK, CLIPBOARD_TEXT, COPY, FOLDER_PLUS, SCAN, SHARE_FAT};
|
use crate::gui::icons::{CHECK, CLIPBOARD_TEXT, COPY, FOLDER_PLUS, SCAN, SHARE_FAT};
|
||||||
use crate::gui::platform::PlatformCallbacks;
|
use crate::gui::platform::PlatformCallbacks;
|
||||||
|
@ -310,29 +309,17 @@ impl WalletCreation {
|
||||||
None => {
|
None => {
|
||||||
// Show wallet creation message if step is empty.
|
// Show wallet creation message if step is empty.
|
||||||
View::center_content(ui, 350.0 + View::get_bottom_inset(), |ui| {
|
View::center_content(ui, 350.0 + View::get_bottom_inset(), |ui| {
|
||||||
let logo = if AppConfig::dark_theme().unwrap_or(false) {
|
|
||||||
egui::include_image!("../../../../../img/logo_light.png")
|
|
||||||
} else {
|
|
||||||
egui::include_image!("../../../../../img/logo.png")
|
|
||||||
};
|
|
||||||
// Show app logo.
|
// Show app logo.
|
||||||
egui::Image::new(logo).fit_to_exact_size(vec2(180.0, 180.0)).ui(ui);
|
View::app_logo_name_version(ui);
|
||||||
ui.add_space(-15.0);
|
|
||||||
ui.label(RichText::new("GRIM")
|
|
||||||
.size(24.0)
|
|
||||||
.color(Colors::white_or_black(true))
|
|
||||||
);
|
|
||||||
ui.label(RichText::new(built_info::PKG_VERSION)
|
|
||||||
.size(16.0)
|
|
||||||
.color(Colors::white_or_black(true))
|
|
||||||
);
|
|
||||||
ui.add_space(4.0);
|
ui.add_space(4.0);
|
||||||
|
|
||||||
let text = t!("wallets.create_desc");
|
let text = t!("wallets.create_desc");
|
||||||
ui.label(RichText::new(text)
|
ui.label(RichText::new(text)
|
||||||
.size(16.0)
|
.size(16.0)
|
||||||
.color(Colors::gray())
|
.color(Colors::gray())
|
||||||
);
|
);
|
||||||
ui.add_space(8.0);
|
ui.add_space(8.0);
|
||||||
|
// Show wallet creation button.
|
||||||
let add_text = format!("{} {}", FOLDER_PLUS, t!("wallets.add"));
|
let add_text = format!("{} {}", FOLDER_PLUS, t!("wallets.add"));
|
||||||
View::button(ui, add_text, Colors::white_or_black(false), || {
|
View::button(ui, add_text, Colors::white_or_black(false), || {
|
||||||
self.show_name_pass_modal(cb);
|
self.show_name_pass_modal(cb);
|
||||||
|
|
Loading…
Reference in a new issue