Skip to content
This repository was archived by the owner on Mar 17, 2024. It is now read-only.

Commit ea6543c

Browse files
committed
build v0.6.8
1 parent 4fef734 commit ea6543c

File tree

3 files changed

+47
-42
lines changed

3 files changed

+47
-42
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@xsoulspace/vue_flutter_tailwind",
33
"description": "Vue3 styled like Flutter with Tailwind CSS",
4-
"version": "0.6.7",
4+
"version": "0.6.8",
55
"private": false,
66
"author": {
77
"name": "Anton Malofeev",

src/abstract/Navigation.ts

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { Component, markRaw, reactive, ref } from 'vue'
2-
import { Container } from '../components/Container'
32
import { Maybe } from './BasicTypes'
43

5-
interface NavigationControllerRoute {
4+
export interface NavigationControllerRoute {
65
routeName: string
7-
widget: Component
6+
widget: Maybe<Component>
87
fullscreen: boolean
98
}
109

@@ -15,7 +14,7 @@ export class NavigationController {
1514

1615
pop(counter = 1) {
1716
for (let i = 0; i < counter; i++) {
18-
if (this.count == 0) return
17+
if (this.routes.length == 0) return
1918
this.routes.shift()
2019
}
2120
}
@@ -32,27 +31,4 @@ export class NavigationController {
3231
fullscreen: fullscreen ?? true,
3332
})
3433
}
35-
get currentRoute(): NavigationControllerRoute {
36-
const maybeWidget = this.routes[0]
37-
return (
38-
maybeWidget ?? {
39-
widget: Container({}),
40-
fullscreen: true,
41-
routeName: '',
42-
}
43-
)
44-
}
45-
get currentWidget(): Component {
46-
return this.currentRoute.widget
47-
}
48-
get isFullscreen() {
49-
const maybeFullscreen = this.currentRoute?.fullscreen
50-
return maybeFullscreen == null || maybeFullscreen == true
51-
}
52-
get isNotFullscreen() {
53-
return !this.isFullscreen
54-
}
55-
get count() {
56-
return this.routes.length
57-
}
5834
}

src/components/Navigation.tsx

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
import { Component, computed, defineComponent, h } from '@vue/runtime-core'
1+
import {
2+
Component,
3+
defineComponent,
4+
h,
5+
reactive,
6+
watch,
7+
} from '@vue/runtime-core'
28
import { ref } from 'vue'
39
import { Colors } from '../abstract/Colors'
410
import { EdgeInsetsStep } from '../abstract/EdgeInsets'
5-
import { NavigationController } from '../abstract/Navigation'
11+
import {
12+
NavigationController,
13+
NavigationControllerRoute,
14+
} from '../abstract/Navigation'
615
import {
716
OpacityDecoration,
817
OpacityDecorationSteps,
@@ -44,20 +53,40 @@ export const Navigation = ({ child }: NavigationI) => {
4453
const routeController = MultiProvider.get<NavigationController>(
4554
NavigationController
4655
)
47-
const currentRoute = computed(() => routeController.currentRoute)
48-
const currentWidget = computed(() => currentRoute.value.widget)
49-
50-
const isRoutesExists = computed(() => routeController.routes.length > 0)
51-
52-
const isFullscreen = computed(() => {
53-
const maybeFullscreen = currentRoute.value.fullscreen
54-
return maybeFullscreen == null || maybeFullscreen == true
56+
const currentRoute = reactive<NavigationControllerRoute>({
57+
widget: null,
58+
fullscreen: true,
59+
routeName: '',
5560
})
56-
const isNotFullscreen = computed(() => !isFullscreen.value)
61+
const isRoutesExists = ref<boolean>(false)
62+
const isFullscreen = ref<boolean>(false)
63+
const isNotFullscreen = ref<boolean>(false)
64+
65+
watch(
66+
routeController.routes,
67+
(newRoutes) => {
68+
const newRoute = newRoutes[0]
69+
if (newRoute == null) {
70+
isRoutesExists.value = false
71+
currentRoute.widget = null
72+
return
73+
}
74+
currentRoute.widget = newRoute.widget
75+
currentRoute.routeName = newRoute.routeName
76+
currentRoute.fullscreen = newRoute.fullscreen
77+
isNotFullscreen.value = !newRoute.fullscreen
78+
isFullscreen.value = newRoute.fullscreen
79+
isRoutesExists.value = true
80+
},
81+
{
82+
deep: true,
83+
immediate: true,
84+
}
85+
)
5786

5887
return {
5988
isFullscreen,
60-
currentWidget,
89+
currentRoute,
6190
isNotFullscreen,
6291
isRoutesExists,
6392
routeController,
@@ -114,7 +143,7 @@ export const Navigation = ({ child }: NavigationI) => {
114143
event.stopPropagation()
115144
}
116145
>
117-
{h(this.currentWidget)}
146+
{h(this.currentRoute.widget ?? <div />)}
118147
</div>
119148
),
120149
})
@@ -134,7 +163,7 @@ export const Navigation = ({ child }: NavigationI) => {
134163
new SizedBoxHeight({}).css,
135164
]}
136165
>
137-
{h(this.currentWidget)}
166+
{h(this.currentRoute.widget ?? <div />)}
138167
</div>
139168
),
140169
visible: ref(this.isFullscreen),

0 commit comments

Comments
 (0)