ui: logo at wallet list

This commit is contained in:
ardocrat 2024-05-30 21:14:14 +03:00
parent 69b7fc2fac
commit b78ba0bfb5
3 changed files with 41 additions and 39 deletions

View file

@ -23,7 +23,7 @@ use egui::epaint::text::TextWrapping;
use egui::os::OperatingSystem;
use egui::text::{LayoutJob, TextFormat};
use egui::text_edit::TextEditState;
use crate::AppConfig;
use crate::{AppConfig, built_info};
use crate::gui::Colors;
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;
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.
pub fn default_stroke() -> Stroke {
Stroke { width: 1.0, color: Colors::stroke() }
@ -619,12 +627,26 @@ impl View {
Stroke { width: 1.0, color });
}
/// 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()
/// Draw application logo image with name and version.
pub fn app_logo_name_version(ui: &mut egui::Ui) {
ui.add_space(-1.0);
let logo = if AppConfig::dark_theme().unwrap_or(false) {
egui::include_image!("../../../img/logo_light.png")
} 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.

View file

@ -101,7 +101,7 @@ impl WalletsContent {
// Setup panels parameters.
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 content_width = ui.available_width();
@ -169,8 +169,7 @@ impl WalletsContent {
// 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.
let show_bottom_panel = !list_hidden &&
((!show_wallet && !dual_panel && !Root::is_network_panel_open()) ||
(dual_panel && show_wallet));
((!show_wallet && !dual_panel && !Root::is_network_panel_open()) || dual_panel);
// Show wallets bottom panel.
egui::TopBottomPanel::bottom("wallets_bottom_panel")
@ -223,7 +222,7 @@ impl WalletsContent {
ui.ctx().request_repaint_after(Duration::from_millis(1000));
}
// 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.
fn wallet_list_ui(&mut self,
ui: &mut egui::Ui,
dual_panel: bool,
cb: &dyn PlatformCallbacks) {
ui.scope(|ui| {
ScrollArea::vertical()
@ -340,16 +338,11 @@ impl WalletsContent {
.auto_shrink([false; 2])
.show(ui, |ui| {
ui.vertical_centered(|ui| {
if !dual_panel {
ui.add_space(1.0);
}
// Setup wallet list width.
let max_width = if !dual_panel {
Root::SIDE_PANEL_WIDTH * 1.3
} else {
ui.available_width()
};
View::max_width_ui(ui, max_width, |ui| {
View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| {
// Show application logo and name.
View::app_logo_name_version(ui);
ui.add_space(20.0);
let mut list = self.wallets.list().clone();
// Remove deleted wallet from the list.
list.retain(|w| !w.is_deleted());

View file

@ -12,11 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use egui::{Id, Margin, RichText, ScrollArea, vec2, Widget};
use egui::{Id, Margin, RichText, ScrollArea};
use egui::scroll_area::ScrollBarVisibility;
use grin_util::ZeroingString;
use crate::{AppConfig, built_info};
use crate::gui::Colors;
use crate::gui::icons::{CHECK, CLIPBOARD_TEXT, COPY, FOLDER_PLUS, SCAN, SHARE_FAT};
use crate::gui::platform::PlatformCallbacks;
@ -310,29 +309,17 @@ impl WalletCreation {
None => {
// Show wallet creation message if step is empty.
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.
egui::Image::new(logo).fit_to_exact_size(vec2(180.0, 180.0)).ui(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))
);
View::app_logo_name_version(ui);
ui.add_space(4.0);
let text = t!("wallets.create_desc");
ui.label(RichText::new(text)
.size(16.0)
.color(Colors::gray())
);
ui.add_space(8.0);
// Show wallet creation button.
let add_text = format!("{} {}", FOLDER_PLUS, t!("wallets.add"));
View::button(ui, add_text, Colors::white_or_black(false), || {
self.show_name_pass_modal(cb);