mirror of
https://github.com/jwinterm/grim.git
synced 2026-11-25 07:13:54 +01:00
ui: remove on_back callback from content container
This commit is contained in:
@@ -127,40 +127,6 @@ impl ContentContainer for WalletsContent {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_back(&mut self, cb: &dyn PlatformCallbacks) -> bool {
|
||||
if self.showing_settings() {
|
||||
// Close settings.
|
||||
self.settings_content = None;
|
||||
return false;
|
||||
} else if self.creating_wallet() {
|
||||
// Close wallet creation.
|
||||
let creation = self.creation_content.as_mut().unwrap();
|
||||
if creation.on_back() {
|
||||
self.creation_content = None;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
if self.showing_wallet() {
|
||||
let content = self.wallet_content.as_mut().unwrap();
|
||||
// Close opened QR code scanner.
|
||||
if content.qr_scan_showing() {
|
||||
cb.stop_camera();
|
||||
content.close_qr_scan();
|
||||
return false;
|
||||
}
|
||||
// Close account list.
|
||||
if content.account_list_showing() {
|
||||
content.close_qr_scan();
|
||||
return false;
|
||||
}
|
||||
// Close opened wallet.
|
||||
self.wallet_content = None;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
fn container_ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
if let Some(data) = crate::consume_incoming_data() {
|
||||
if !data.is_empty() {
|
||||
@@ -319,6 +285,39 @@ impl ContentContainer for WalletsContent {
|
||||
}
|
||||
|
||||
impl WalletsContent {
|
||||
/// Called to navigate back, return `true` if action was not consumed.
|
||||
pub fn on_back(&mut self, cb: &dyn PlatformCallbacks) -> bool {
|
||||
if self.showing_settings() {
|
||||
// Close settings.
|
||||
self.settings_content = None;
|
||||
return false;
|
||||
} else if self.creating_wallet() {
|
||||
// Close wallet creation.
|
||||
let creation = self.creation_content.as_mut().unwrap();
|
||||
if creation.on_back() {
|
||||
self.creation_content = None;
|
||||
}
|
||||
return false;
|
||||
} else if self.showing_wallet() {
|
||||
let content = self.wallet_content.as_mut().unwrap();
|
||||
// Close opened QR code scanner.
|
||||
if content.qr_scan_showing() {
|
||||
cb.stop_camera();
|
||||
content.close_qr_scan();
|
||||
return false;
|
||||
}
|
||||
// Close account list.
|
||||
if content.account_list_showing() {
|
||||
content.close_qr_scan();
|
||||
return false;
|
||||
}
|
||||
// Close opened wallet.
|
||||
self.wallet_content = None;
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
/// Check if opened wallet is showing.
|
||||
pub fn showing_wallet(&self) -> bool {
|
||||
if let Some(wallet_content) = &self.wallet_content {
|
||||
@@ -358,7 +357,11 @@ impl WalletsContent {
|
||||
self.show_opening_modal(w, data);
|
||||
}
|
||||
} else {
|
||||
self.show_wallet_selection_modal(data);
|
||||
self.wallet_selection_content = WalletsModal::new(None, data, true);
|
||||
Modal::new(SELECT_WALLET_MODAL)
|
||||
.position(ModalPosition::Center)
|
||||
.title(t!("network_settings.choose_wallet"))
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,15 +374,6 @@ impl WalletsContent {
|
||||
.show();
|
||||
}
|
||||
|
||||
/// Show wallet selection with provided optional data.
|
||||
fn show_wallet_selection_modal(&mut self, data: Option<String>) {
|
||||
self.wallet_selection_content = WalletsModal::new(None, data, true);
|
||||
Modal::new(SELECT_WALLET_MODAL)
|
||||
.position(ModalPosition::Center)
|
||||
.title(t!("network_settings.choose_wallet"))
|
||||
.show();
|
||||
}
|
||||
|
||||
/// Draw [`TitlePanel`] content.
|
||||
fn title_ui(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
@@ -475,6 +469,7 @@ impl WalletsContent {
|
||||
self.wallet_content.as_mut().unwrap().close_account_list();
|
||||
return;
|
||||
}
|
||||
self.wallet_content = None;
|
||||
});
|
||||
} else if self.creating_wallet() {
|
||||
let mut close = false;
|
||||
|
||||
@@ -86,11 +86,8 @@ impl ContentContainer for WalletCreationContent {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_back(&mut self, _: &dyn PlatformCallbacks) -> bool {
|
||||
true
|
||||
fn container_ui(&mut self, _: &mut egui::Ui, _: &dyn PlatformCallbacks) {
|
||||
}
|
||||
|
||||
fn container_ui(&mut self, _: &mut egui::Ui, _: &dyn PlatformCallbacks) {}
|
||||
}
|
||||
|
||||
impl WalletCreationContent {
|
||||
|
||||
@@ -66,10 +66,6 @@ impl ContentContainer for MnemonicSetup {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_back(&mut self, _: &dyn PlatformCallbacks) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn container_ui(&mut self, _: &mut egui::Ui, _: &dyn PlatformCallbacks) {
|
||||
}
|
||||
}
|
||||
@@ -78,34 +74,8 @@ impl MnemonicSetup {
|
||||
/// Draw content for phrase import step.
|
||||
pub fn import_ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
self.ui(ui, cb);
|
||||
|
||||
ui.add_space(10.0);
|
||||
|
||||
// Show mode and type setup.
|
||||
self.mode_type_ui(ui);
|
||||
|
||||
ui.add_space(12.0);
|
||||
View::horizontal_line(ui, Colors::item_stroke());
|
||||
ui.add_space(6.0);
|
||||
|
||||
// Show words setup.
|
||||
self.word_list_ui(ui, true);
|
||||
}
|
||||
/// Draw content for phrase confirmation step.
|
||||
pub fn confirm_ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
self.ui(ui, cb);
|
||||
|
||||
ui.add_space(4.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
let text = format!("{}:", t!("wallets.recovery_phrase"));
|
||||
ui.label(RichText::new(text).size(16.0).color(Colors::gray()));
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
self.word_list_ui(ui, true);
|
||||
}
|
||||
|
||||
/// Draw mode and size setup.
|
||||
fn mode_type_ui(&mut self, ui: &mut egui::Ui) {
|
||||
// Show mode setup.
|
||||
let mut mode = self.mnemonic.mode();
|
||||
ui.columns(2, |columns| {
|
||||
@@ -146,6 +116,25 @@ impl MnemonicSetup {
|
||||
if size != self.mnemonic.size() {
|
||||
self.mnemonic.set_size(size);
|
||||
}
|
||||
|
||||
ui.add_space(12.0);
|
||||
View::horizontal_line(ui, Colors::item_stroke());
|
||||
ui.add_space(6.0);
|
||||
|
||||
// Show words setup.
|
||||
self.word_list_ui(ui, true);
|
||||
}
|
||||
/// Draw content for phrase confirmation step.
|
||||
pub fn confirm_ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
self.ui(ui, cb);
|
||||
|
||||
ui.add_space(4.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
let text = format!("{}:", t!("wallets.recovery_phrase"));
|
||||
ui.label(RichText::new(text).size(16.0).color(Colors::gray()));
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
self.word_list_ui(ui, true);
|
||||
}
|
||||
|
||||
/// Draw grid of words for mnemonic phrase.
|
||||
|
||||
@@ -44,11 +44,12 @@ pub struct WalletContent {
|
||||
}
|
||||
|
||||
impl ContentContainer for WalletContent {
|
||||
fn modal_ids(&self) -> Vec<&'static str> { vec![] }
|
||||
fn modal_ids(&self) -> Vec<&'static str> {
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn modal_ui(&mut self, _: &mut egui::Ui, _: &Modal, _: &dyn PlatformCallbacks) {}
|
||||
|
||||
fn on_back(&mut self, _: &dyn PlatformCallbacks) -> bool { true }
|
||||
fn modal_ui(&mut self, _: &mut egui::Ui, _: &Modal, _: &dyn PlatformCallbacks) {
|
||||
}
|
||||
|
||||
fn container_ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
|
||||
ui.ctx().request_repaint_after(Duration::from_millis(1000));
|
||||
|
||||
@@ -61,10 +61,6 @@ impl ContentContainer for ConnectionSettings {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_back(&mut self, _: &dyn PlatformCallbacks) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn container_ui(&mut self, ui: &mut egui::Ui, _: &dyn PlatformCallbacks) {
|
||||
ui.add_space(2.0);
|
||||
View::sub_title(ui, format!("{} {}", GLOBE, t!("wallets.conn_method")));
|
||||
|
||||
Reference in New Issue
Block a user