Skip to content

Commit 0991890

Browse files
authored
Support swipe gesture to show the left menu (#4370)
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
1 parent c3fc450 commit 0991890

4 files changed

Lines changed: 24 additions & 1 deletion

File tree

bundles/org.openhab.ui/web/src/App.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66
visibility: userStore.user || componentsStore.page('overview') || communicationFailureMsg ? '' : 'hidden'
77
}">
88
<!-- Left Panel -->
9-
<f7-panel v-show="ready" left :cover="showSidebar ? true : null" class="sidebar" :visible-breakpoint="960">
9+
<f7-panel
10+
v-show="ready"
11+
left
12+
:cover="showSidebar ? true : null"
13+
class="sidebar"
14+
:visible-breakpoint="960"
15+
:swipe="!uiOptionsStore.disableLeftPanelSwipe">
1016
<f7-page>
1117
<!-- openHAB Logo -->
1218
<f7-link href="/overview/" class="openhab-logo no-ripple" panel-close @click.capture="handleSidebarClick">

bundles/org.openhab.ui/web/src/assets/i18n/theme-switcher/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"about.miscellaneous.home.background.white": "White",
1818
"about.miscellaneous.home.hideChatInput": "Hide chat input box on home page",
1919
"about.miscellaneous.home.disableCardExpansionAnimation": "Disable card expansion animations",
20+
"about.miscellaneous.theme.disableLeftPanelSwipe": "Disable left panel swipe gesture",
2021
"about.miscellaneous.theme.disablePageTransition": "Disable page transition animations",
2122
"about.miscellaneous.webaudio.enable": "Enable Web Audio sink support",
2223
"about.miscellaneous.commandItem.title": "Listen for UI commands to ",

bundles/org.openhab.ui/web/src/components/theme-switcher.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@
8686
<span>{{ t('about.miscellaneous.home.disableCardExpansionAnimation') }}</span>
8787
<f7-toggle v-model:checked="disableExpandableCardAnimation" />
8888
</f7-list-item>
89+
<f7-list-item>
90+
<span>{{ t('about.miscellaneous.theme.disableLeftPanelSwipe') }}</span>
91+
<f7-toggle v-model:checked="disableLeftPanelSwipe" />
92+
</f7-list-item>
8993
<f7-list-item>
9094
<span>{{ t('about.miscellaneous.theme.disablePageTransition') }}</span>
9195
<f7-toggle v-model:checked="disablePageTransitionAnimation" />
@@ -211,6 +215,7 @@ export default {
211215
},
212216
...mapStores(useRuntimeStore, useUIOptionsStore),
213217
...mapWritableState(useUIOptionsStore, [
218+
'disableLeftPanelSwipe',
214219
'disablePageTransitionAnimation',
215220
'bars',
216221
'homeNavBar',

bundles/org.openhab.ui/web/src/js/stores/useUIOptionsStore.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const useUIOptionsStore = defineStore('uiOptions', () => {
4040
const disableExpandableCardAnimation = ref<boolean>(_storedExpandableCardAnimation === 'disabled')
4141

4242
const blocklyRenderer = ref<string | null>(localStorage.getItem('openhab.ui:blockly.renderer'))
43+
const disableLeftPanelSwipe = ref<boolean>(localStorage.getItem('openhab.ui:theme.disableLeftPanelSwipe') === 'true')
4344
const disablePageTransitionAnimation = ref<boolean>(localStorage.getItem('openhab.ui:theme.disablepagetransition') === 'true')
4445

4546
const hideChatInput = ref<boolean>(localStorage.getItem('openhab.ui:theme.home.hidechatinput') === 'true')
@@ -148,6 +149,15 @@ export const useUIOptionsStore = defineStore('uiOptions', () => {
148149
updateClasses()
149150
})
150151

152+
watch(disableLeftPanelSwipe, (newValue) => {
153+
localStorage.setItem('openhab.ui:theme.disableLeftPanelSwipe', newValue.toString())
154+
if (newValue) {
155+
f7.panel.get('left').disableSwipe()
156+
} else {
157+
f7.panel.get('left').enableSwipe()
158+
}
159+
})
160+
151161
watch(disablePageTransitionAnimation, (newValue) => {
152162
localStorage.setItem('openhab.ui:theme.disablepagetransition', newValue.toString())
153163
updateClasses()
@@ -339,6 +349,7 @@ export const useUIOptionsStore = defineStore('uiOptions', () => {
339349
homeBackground,
340350
disableExpandableCardAnimation,
341351
blocklyRenderer,
352+
disableLeftPanelSwipe,
342353
disablePageTransitionAnimation,
343354
hideChatInput,
344355
webAudio,

0 commit comments

Comments
 (0)