5
5
<Tour />
6
6
</transition >
7
7
8
- <main :class =" routeClass " ref =" $main" >
8
+ <main :class =" activeMobileColumn " ref =" $main" >
9
9
<Sidebar />
10
10
11
11
<transition name =" delay" >
32
32
<script lang="ts">
33
33
import { defineComponent , ref , watch , computed , onMounted , Ref } from ' @vue/composition-api' ;
34
34
import { LoadingSpinner } from ' @nimiq/vue-components' ;
35
-
36
35
import Sidebar from ' ./components/layouts/Sidebar.vue' ;
37
36
import SwapNotification from ' ./components/swap/SwapNotification.vue' ;
38
37
import UpdateNotification from ' ./components/UpdateNotification.vue' ;
39
- import router , { provideRouter , Columns } from ' ./router' ;
38
+ import router , { provideRouter } from ' ./router' ;
40
39
import { useAccountStore } from ' ./stores/Account' ;
41
40
import { useSettingsStore } from ' ./stores/Settings' ;
42
41
import { useWindowSize } from ' ./composables/useWindowSize' ;
42
+ import { useActiveMobileColumn } from ' ./composables/useActiveMobileColumn' ;
43
43
import { useSwipes } from ' ./composables/useSwipes' ;
44
44
45
45
export default defineComponent ({
46
46
name: ' app' ,
47
47
setup(props , context ) {
48
48
provideRouter (router );
49
49
50
- const routeClass = ref (' ' );
51
-
52
- watch (() => context .root .$route .meta , (meta ) => {
53
- if (! meta ) return ;
54
- // Using a watcher, because the routeClass should only change when a route is visited
55
- // that may require a column navigation. When opening modals, we don't want to change
56
- // column.
57
- switch (meta .column ) {
58
- case Columns .DYNAMIC :
59
- switch (context .root .$route .path ) {
60
- case ' /' : routeClass .value = ' column-account' ; break ;
61
- case ' /transactions' : routeClass .value = ' column-address' ; break ;
62
- default : break ; // Don't change column
63
- }
64
- break ;
65
- case Columns .ACCOUNT : routeClass .value = ' column-account' ; break ;
66
- case Columns .ADDRESS : routeClass .value = ' column-address' ; break ;
67
- default : break ;
68
- }
69
- });
70
-
71
- watch (() => context .root .$route .query , (newQuery , oldQuery ) => {
72
- if (! newQuery ) return ;
73
- if (newQuery .sidebar ) {
74
- routeClass .value = ' column-sidebar' ;
75
- } else if (oldQuery && oldQuery .sidebar ) {
76
- routeClass .value = ' column-account' ;
77
- }
78
- });
50
+ const { activeMobileColumn } = useActiveMobileColumn ();
79
51
80
52
const { accountInfos, state : accountState, setTour } = useAccountStore ();
81
53
if (! [' root' , ' transactions' ].includes (context .root .$route .name as string )
@@ -92,7 +64,7 @@ export default defineComponent({
92
64
// Swiping
93
65
const $main = ref <HTMLDivElement >(null );
94
66
let $mobileTapArea: HTMLDivElement | null = null ;
95
- const { width } = useWindowSize ();
67
+ const { width, isMobile } = useWindowSize ();
96
68
97
69
async function updateSwipeRestPosition(
98
70
velocityDistance : number ,
@@ -161,23 +133,23 @@ export default defineComponent({
161
133
excludeSelector: ' .scroller, .scroller *' ,
162
134
});
163
135
164
- watch ([width , swipingEnabled ], ([newWidth , newSwiping ], [oldWidth , oldSwiping ]) => {
136
+ watch ([isMobile , swipingEnabled ], ([isMobileNow , newSwiping ], [wasMobile , oldSwiping ]) => {
165
137
if (! $main .value ) return ;
166
138
167
- if ((newWidth <= 700 && oldWidth > 700 ) || (newSwiping === 1 && oldSwiping !== 1 )) {
139
+ if ((isMobileNow && ! wasMobile ) || (newSwiping === 1 && oldSwiping !== 1 )) {
168
140
attachSwipe ();
169
- } else if (newWidth > 700 || newSwiping !== 1 ) {
141
+ } else if (! isMobileNow || newSwiping !== 1 ) {
170
142
detachSwipe ();
171
143
}
172
144
}, { lazy: true });
173
145
174
146
onMounted (() => {
175
- if (width .value <= 700 && swipingEnabled .value === 1 ) attachSwipe ();
147
+ if (isMobile .value && swipingEnabled .value === 1 ) attachSwipe ();
176
148
});
177
149
178
150
return {
179
151
showTour ,
180
- routeClass ,
152
+ activeMobileColumn ,
181
153
hasAccounts ,
182
154
amountsHidden ,
183
155
$main ,
@@ -373,6 +345,10 @@ body {
373
345
display : block ;
374
346
}
375
347
348
+ .nq-card {
349
+ padding-bottom : env (safe-area-inset-bottom );
350
+ }
351
+
376
352
.fade-enter-active , .fade-leave-active {
377
353
transition : opacity var (--transition-time ) cubic-bezier (0.5 , 0 , 0.15 , 1 );
378
354
0 commit comments