Skip to content

Commit

Permalink
Show/hide keyboard shortcut modal
Browse files Browse the repository at this point in the history
  • Loading branch information
tuanchauict committed Jan 7, 2024
1 parent e5d716d commit b5c067a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
9 changes: 8 additions & 1 deletion monosketch-svelte/src/lib/ui/modal/ModalHolder.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import KeyboardShortcutModal from './keyboard-shortcut/KeyboardShortcutModal.sve
let mainDropDownTarget: TargetBounds | null = null;
let tooltip: Tooltip | null = null;
let shortcutModal: boolean = false;
const lifecycleOwner = new LifecycleOwner();
onMount(() => {
Expand All @@ -22,6 +23,10 @@ onMount(() => {
modalViewModel.tooltipFlow.observe(lifecycleOwner, (value) => {
tooltip = value;
});
modalViewModel.keyboardShortcutVisibilityStateFlow.observe(lifecycleOwner, (value) => {
shortcutModal = value;
});
});
onDestroy(() => {
Expand All @@ -37,4 +42,6 @@ onDestroy(() => {
<TooltipView {tooltip} />
{/if}

<KeyboardShortcutModal />
{#if shortcutModal}
<KeyboardShortcutModal />
{/if}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script lang="ts">
import KeyboardShortcutContent from './KeyboardShortcutContent.svelte';
import SvgIcon from '../../common/SvgIcon.svelte';
import { modalViewModel } from '../viewmodel';
function dismiss() {
console.log('dismiss');
modalViewModel.keyboardShortcutVisibilityStateFlow.value = false;
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function toggleFormatPanelVisibility() {
}
function showKeyboardShortcuts() {
modalViewModel.keyboardShortcutVisibilityStateFlow.value = true;
onDismiss();
}
</script>
Expand Down
2 changes: 2 additions & 0 deletions monosketch-svelte/src/lib/ui/modal/viewmodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class ModalViewModel {
mainDropDownMenuTargetFlow: Flow<TargetBounds | null> = new Flow(null);

tooltipFlow: Flow<Tooltip | null> = new Flow(null);

keyboardShortcutVisibilityStateFlow: Flow<boolean> = new Flow(false);
}

export const modalViewModel = new ModalViewModel();

0 comments on commit b5c067a

Please sign in to comment.