platform: android file opening, better exit

This commit is contained in:
ardocrat
2024-09-13 14:22:15 +03:00
parent d78ec570b0
commit c73cd58eed
11 changed files with 193 additions and 68 deletions
+6 -6
View File
@@ -40,8 +40,8 @@ pub struct Content {
/// Central panel [`WalletsContent`] content.
pub wallets: WalletsContent,
/// Check if app exit is allowed on close event of [`eframe::App`] implementation.
pub(crate) exit_allowed: bool,
/// Check if app exit is allowed on Desktop close event.
pub exit_allowed: bool,
/// Flag to show exit progress at [`Modal`].
show_exit_progress: bool,
@@ -83,7 +83,7 @@ impl ModalContainer for Content {
modal: &Modal,
cb: &dyn PlatformCallbacks) {
match modal.id {
Self::EXIT_CONFIRMATION_MODAL => self.exit_modal_content(ui, modal),
Self::EXIT_CONFIRMATION_MODAL => self.exit_modal_content(ui, modal, cb),
Self::SETTINGS_MODAL => self.settings_modal_ui(ui, modal),
Self::ANDROID_INTEGRATED_NODE_WARNING_MODAL => self.android_warning_modal_ui(ui, modal),
Self::CRASH_REPORT_MODAL => self.crash_report_modal_ui(ui, modal, cb),
@@ -206,11 +206,11 @@ impl Content {
}
/// Draw exit confirmation modal content.
fn exit_modal_content(&mut self, ui: &mut egui::Ui, modal: &Modal) {
fn exit_modal_content(&mut self, ui: &mut egui::Ui, modal: &Modal, cb: &dyn PlatformCallbacks) {
if self.show_exit_progress {
if !Node::is_running() {
self.exit_allowed = true;
ui.ctx().send_viewport_cmd(egui::ViewportCommand::Close);
cb.exit();
modal.close();
}
ui.add_space(16.0);
@@ -244,7 +244,7 @@ impl Content {
View::button_ui(ui, t!("modal_exit.exit"), Colors::white_or_black(false), |ui| {
if !Node::is_running() {
self.exit_allowed = true;
ui.ctx().send_viewport_cmd(egui::ViewportCommand::Close);
cb.exit();
modal.close();
} else {
Node::stop(true);
+5 -6
View File
@@ -36,12 +36,10 @@ pub struct WalletsContent {
/// Wallet selection [`Modal`] content.
wallet_selection_content: Option<WalletsModal>,
/// Wallet opening [`Modal`] content.
open_wallet_content: Option<OpenWalletModal>,
/// Wallet connection selection content.
conn_modal_content: Option<WalletConnectionModal>,
conn_selection_content: Option<WalletConnectionModal>,
/// Selected [`Wallet`] content.
wallet_content: WalletContent,
@@ -70,7 +68,7 @@ impl Default for WalletsContent {
wallets: WalletList::default(),
wallet_selection_content: None,
open_wallet_content: None,
conn_modal_content: None,
conn_selection_content: None,
wallet_content: WalletContent::new(None),
creation_content: WalletCreation::default(),
show_wallets_at_dual_panel: AppConfig::show_wallets_at_dual_panel(),
@@ -106,7 +104,7 @@ impl ModalContainer for WalletsContent {
self.creation_content.name_pass_modal_ui(ui, modal, cb)
},
CONNECTION_SELECTION_MODAL => {
if let Some(content) = self.conn_modal_content.as_mut() {
if let Some(content) = self.conn_selection_content.as_mut() {
content.ui(ui, modal, cb, |id| {
// Update wallet connection on select.
let list = self.wallets.list();
@@ -303,6 +301,7 @@ impl WalletsContent {
}
}
/// Show wallet selection with provided optional data.
fn show_wallet_selection_modal(&mut self, data: Option<String>) {
self.wallet_selection_content = Some(WalletsModal::new(None, data, true));
// Show wallet selection modal.
@@ -557,7 +556,7 @@ impl WalletsContent {
/// Show [`Modal`] to select connection for the wallet.
fn show_connection_selector_modal(&mut self, wallet: &Wallet) {
let ext_conn = wallet.get_current_ext_conn();
self.conn_modal_content = Some(WalletConnectionModal::new(ext_conn));
self.conn_selection_content = Some(WalletConnectionModal::new(ext_conn));
// Show modal.
Modal::new(CONNECTION_SELECTION_MODAL)
.position(ModalPosition::CenterTop)