From 6d1edc1b8a19926025abf04954ac9d4b7e5b8b4a Mon Sep 17 00:00:00 2001 From: Pihkaal Date: Tue, 30 Dec 2025 00:37:39 +0100 Subject: [PATCH] feat(common): move confirmation modal to his own store, and add 'onClosed' event --- app/components/Common/ConfirmationModal.vue | 20 ++-- .../Contact/BottomScreen/BottomScreen.vue | 6 +- app/composables/useButtonNavigation.ts | 6 +- app/composables/useConfirmationModal.ts | 93 ---------------- app/stores/confirmationModal.ts | 100 ++++++++++++++++++ 5 files changed, 116 insertions(+), 109 deletions(-) delete mode 100644 app/composables/useConfirmationModal.ts create mode 100644 app/stores/confirmationModal.ts diff --git a/app/components/Common/ConfirmationModal.vue b/app/components/Common/ConfirmationModal.vue index 4949a69..58b0e1e 100644 --- a/app/components/Common/ConfirmationModal.vue +++ b/app/components/Common/ConfirmationModal.vue @@ -4,7 +4,7 @@ import Buttons from "./Buttons.vue"; const { onRender } = useScreen(); const { assets } = useAssets(); -const { close, state } = useConfirmationModal(); +const confirmationModal = useConfirmationModal(); const BG_WIDTH = assets.common.confirmationModal.width; const BG_HEIGHT = assets.common.confirmationModal.height; @@ -17,22 +17,22 @@ const BOTTOM_BAR_HEIGHT = 24; const CLIP_HEIGHT = SCREEN_HEIGHT - BOTTOM_BAR_HEIGHT; const handleActivateA = () => { - state.value.onConfirm?.(); - close(); + confirmationModal.onConfirm?.(); + confirmationModal.close(); }; const handleActivateB = () => { - close(); + confirmationModal.close(); }; onRender((ctx) => { - if (!state.value.isVisible) return; + if (!confirmationModal.isVisible) return; ctx.beginPath(); ctx.rect(0, 0, SCREEN_WIDTH, CLIP_HEIGHT); ctx.clip(); - ctx.translate(0, state.value.offsetY); + ctx.translate(0, confirmationModal.offsetY); ctx.drawImage(assets.common.confirmationModal, BG_X, BG_Y); @@ -40,18 +40,18 @@ onRender((ctx) => { ctx.textBaseline = "top"; ctx.fillStyle = "#ffffff"; - fillTextCentered(ctx, state.value.text, BG_X, TEXT_Y, BG_WIDTH); + fillTextCentered(ctx, confirmationModal.text, BG_X, TEXT_Y, BG_WIDTH); }, 100); onUnmounted(() => { - close(); + confirmationModal.close(); });