Skip to content

Commit 028ff2b

Browse files
committed
feat: migrate application from Vue 2 to Vue 3
1 parent 9c5754b commit 028ff2b

21 files changed

+118
-99
lines changed

app/app.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
//@license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3
22

3-
import Vue from 'nativescript-vue'
3+
import { createApp, registerElement } from 'nativescript-vue'
44

55
import { FontIcon, fonticon } from '@nativescript-community/fonticon';
6-
import BottomSheetPlugin from '@nativescript-community/ui-material-bottomsheet/vue';
6+
import { BottomSheetPlugin } from '@nativescript-community/ui-material-bottomsheet/vue3';
7+
import { install as installBottomSheet } from "@nativescript-community/ui-material-bottomsheet";
78
import CanvasSVG from '@nativescript-community/ui-svg/vue';
89
import ButtonPlugin from '@nativescript-community/ui-material-button/vue';
9-
import WebViewPlugin from '@nativescript-community/ui-webview/vue';
10+
import WebView from '@nativescript-community/ui-webview/vue';
1011
import { CheckBox } from '@nstudio/nativescript-checkbox';
11-
import CollectionView from '@nativescript-community/ui-collectionview/vue';
12+
import CollectionView from '@nativescript-community/ui-collectionview/vue3';
1213
import RipplePlugin from '@nativescript-community/ui-material-ripple/vue';
1314
import { ImageCacheIt } from '@triniwiz/nativescript-image-cache-it';
1415

@@ -20,25 +21,17 @@ import { initializeTracing } from './app-trace';
2021
initializeTracing();
2122
ImageCacheIt.enableAutoMM();
2223

24+
// Install BottomSheet plugin
25+
installBottomSheet();
26+
2327
FontIcon.paths = {
2428
'fa': './assets/css/Font-Awesome.css',
2529
};
2630
FontIcon.loadCssSync();
27-
Vue.filter('fonticon', fonticon);
28-
29-
import { install } from "@nativescript-community/ui-material-bottomsheet";
30-
install();
31-
Vue.use(BottomSheetPlugin);
32-
33-
Vue.use(CanvasSVG);
34-
Vue.use(ButtonPlugin);
35-
Vue.use(WebViewPlugin);
36-
Vue.use(CollectionView);
37-
Vue.use(RipplePlugin);
3831

39-
Vue.registerElement('HTMLLabel', () => require('@nativescript-community/ui-label').Label);
40-
Vue.registerElement('ImageCacheIt', () => require('@triniwiz/nativescript-image-cache-it').ImageCacheIt);
41-
Vue.registerElement(
32+
registerElement('HTMLLabel', () => require('@nativescript-community/ui-label').Label);
33+
registerElement('ImageCacheIt', () => require('@triniwiz/nativescript-image-cache-it').ImageCacheIt);
34+
registerElement(
4235
'CheckBox',
4336
() => CheckBox,
4437
{
@@ -49,9 +42,18 @@ Vue.registerElement(
4942
}
5043
);
5144

52-
Vue.config.silent = false;
45+
const app = createApp(Main);
46+
47+
app.config.globalProperties.$filters = {
48+
fonticon: fonticon
49+
};
50+
51+
app.use(store);
52+
app.use(WebView);
53+
app.use(CollectionView);
54+
app.use(CanvasSVG);
55+
app.use(ButtonPlugin);
56+
app.use(RipplePlugin);
57+
app.use(BottomSheetPlugin);
5358

54-
new Vue({
55-
render: (h) => h('frame', [h(Main)]),
56-
store
57-
}).$start()
59+
app.start();

app/components/AppControlPanel/AppControlPanel.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
rippleColor="#ffffff"
2424
class="fa app-control-button"
2525
:class="{ 'app-control-button--active': isPanelOpen && (activeButton === 'quick' || activeButton === null) }"
26-
:text="'fa-bars' | fonticon"
26+
:text="$filters.fonticon('fa-bars')"
2727
@tap="handleControlButtonTap('quick', $event)"
2828
@pan="handleControlButtonPan('quick', $event)"
2929
/>
@@ -35,7 +35,7 @@
3535
rippleColor="#ffffff"
3636
class="fa app-control-button"
3737
:class="{ 'app-control-button--active': isPanelOpen && activeButton === 'search' }"
38-
:text="'fa-search' | fonticon"
38+
:text="$filters.fonticon('fa-search')"
3939
@tap="handleControlButtonTap('search', $event)"
4040
@pan="handleControlButtonPan('search', $event)"
4141
/>
@@ -46,7 +46,7 @@
4646
variant="flat"
4747
rippleColor="#ffffff"
4848
class="fa app-control-button"
49-
:text="locationButtonIcon | fonticon"
49+
:text="$filters.fonticon(locationButtonIcon)"
5050
@tap="onLocate"
5151
/>
5252

@@ -57,7 +57,7 @@
5757
rippleColor="#ffffff"
5858
class="fa app-control-button"
5959
:class="{ 'app-control-button--active': isPanelOpen && activeButton === 'layers' }"
60-
:text="'fa-layer-group' | fonticon"
60+
:text="$filters.fonticon('fa-layer-group')"
6161
@tap="handleControlButtonTap('layers', $event)"
6262
@pan="handleControlButtonPan('layers', $event)"
6363
/>

app/components/AppControlPanel/button-gesture-handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export const buttonGestureHandlerMixin = {
116116
});
117117
},
118118

119-
beforeDestroy() {
119+
beforeUnmount() {
120120
if (this._buttonGestureHandler) {
121121
this._buttonGestureHandler.cleanup();
122122
}

app/components/AppControlPanel/components/LayersView.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@
5353
rows="50"
5454
class="block"
5555
>
56+
<template v-for="(layer, index) in overlayLayers" :key="layer.layerId">
5657
<SVGView
58+
v-if="index <= 8"
5759
class="overlay-portal"
5860
:class="{ 'overlay-portal--active': layer.active === true }"
5961
:col="index"
60-
v-for="(layer, index) in overlayLayers"
61-
v-bind:key="layer.layerId"
62-
v-if="index <= 8"
6362
@tap="onOverlayPortalToggle($event, index)"
6463
:src="'~/assets/icons/portals/portal_L'+index+'_'+String(layer.active)+'.svg'"
6564
stretch="aspectFit"
6665
/>
66+
</template>
6767
</GridLayout>
6868

6969
<StackLayout class="block">

app/components/AppControlPanel/components/QuickAccessView.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class="btn"
1919
@tap="openSettings"
2020
>
21-
<Label class="fa icon" :text="'fa-tools' | fonticon" horizontalAlignment="center" />
21+
<Label class="fa icon" :text="$filters.fonticon('fa-tools')" horizontalAlignment="center" />
2222
<Label class="text" text="Settings" horizontalAlignment="center" />
2323
</StackLayout>
2424

@@ -28,7 +28,7 @@
2828
class="btn"
2929
@tap="openPlugins"
3030
>
31-
<Label class="fa icon" :text="'fa-toolbox' | fonticon" horizontalAlignment="center" />
31+
<Label class="fa icon" :text="$filters.fonticon('fa-toolbox')" horizontalAlignment="center" />
3232
<Label class="text" text="Plugins" horizontalAlignment="center" />
3333
</StackLayout>
3434

@@ -39,7 +39,7 @@
3939
:class="{ 'active': isDebugActive }"
4040
@tap="toggleDebugMode"
4141
>
42-
<Label class="fa icon" :class="{ 'active-icon': isDebugActive }" :text="'fa-terminal' | fonticon" horizontalAlignment="center" />
42+
<Label class="fa icon" :class="{ 'active-icon': isDebugActive }" :text="$filters.fonticon('fa-terminal')" horizontalAlignment="center" />
4343
<Label class="text" :class="{ 'active-text': isDebugActive }" text="Debug" horizontalAlignment="center" />
4444
</StackLayout>
4545

@@ -49,7 +49,7 @@
4949
class="btn"
5050
@tap="reloadWebView"
5151
>
52-
<Label class="fa icon" :text="'fa-redo' | fonticon" horizontalAlignment="center" />
52+
<Label class="fa icon" :text="$filters.fonticon('fa-redo')" horizontalAlignment="center" />
5353
<Label class="text" text="Reload IITC" horizontalAlignment="center" />
5454
</StackLayout>
5555
</GridLayout>
@@ -63,7 +63,7 @@
6363
rows="50"
6464
@tap="switchToPane(pane.name)"
6565
>
66-
<Label class="fa icon" :text="pane.icon | fonticon" col="0" row="0" />
66+
<Label class="fa icon" :text="$filters.fonticon(pane.icon)" col="0" row="0" />
6767
<Label class="pane-item-label" :text="pane.label" col="1" row="0" />
6868
</GridLayout>
6969
</StackLayout>
@@ -73,6 +73,7 @@
7373

7474
<script>
7575
import { mapState } from 'vuex';
76+
import { $navigateTo } from 'nativescript-vue';
7677
import SettingsView from '@/components/Settings/SettingsView';
7778
import PluginsView from '@/components/Settings/PluginsView';
7879
@@ -99,7 +100,7 @@
99100
100101
methods: {
101102
openSettings() {
102-
this.$navigateTo(this.settingsScreen, {
103+
$navigateTo(this.settingsScreen, {
103104
animated: true,
104105
transition: {
105106
name: 'slideLeft',
@@ -117,7 +118,7 @@
117118
this.$store.dispatch('ui/toggleDebugMode');
118119
},
119120
openPlugins() {
120-
this.$navigateTo(this.pluginsScreen, {
121+
$navigateTo(this.pluginsScreen, {
121122
animated: true,
122123
transition: {
123124
name: 'slideLeft',

app/components/AppWebView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export default {
173173
});
174174
},
175175
176-
beforeDestroy() {
176+
beforeUnmount() {
177177
this.store_unsubscribe();
178178
}
179179
};

app/components/BaseWebView.vue

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3
22

33
<template>
4-
<WebViewExt
4+
<AWebView
55
ref="webview"
66
:src="src"
77
:viewPortSize="viewPortSize"
@@ -11,12 +11,11 @@
1111
@loadFinished="onLoadFinished"
1212
@loadError="onLoadError"
1313
@shouldOverrideUrlLoading="onShouldOverrideUrlLoading"
14-
@JSBridge="onJSBridge"
1514
/>
1615
</template>
1716

1817
<script>
19-
import WebViewExt from '@nota/nativescript-webview-ext/vue'
18+
import { AWebView } from '@nativescript-community/ui-webview';
2019
import { isAndroid } from "@nativescript/core";
2120
import { applyWebViewSettings } from "@/utils/webview/webview-settings";
2221
import { BaseWebChromeClient } from '@/utils/webview/base-chrome-client';
@@ -123,6 +122,11 @@ export default {
123122
124123
// Setup console log event handlers
125124
this.setupDebugEventHandlers();
125+
126+
// Setup JSBridge event handler
127+
this.webViewInstance.on('JSBridge', (msg) => {
128+
this.$emit('bridge-message', msg.data);
129+
});
126130
},
127131
128132
// Setup event handlers for console bridge
@@ -192,9 +196,6 @@ export default {
192196
}
193197
},
194198
195-
onJSBridge(args) {
196-
this.$emit('bridge-message', args.data);
197-
},
198199
199200
// Execute JavaScript command in webview
200201
executeCommand(command) {
@@ -223,7 +224,7 @@ export default {
223224
this.chromeClient = null;
224225
}
225226
226-
const events = ['loaded', 'loadStarted', 'loadFinished', 'loadError', 'shouldOverrideUrlLoading', 'console:log'];
227+
const events = ['loaded', 'loadStarted', 'loadFinished', 'loadError', 'shouldOverrideUrlLoading', 'console:log', 'JSBridge'];
227228
events.forEach(event => {
228229
try {
229230
this.webViewInstance.removeEventListener(event);
@@ -265,7 +266,7 @@ export default {
265266
}
266267
},
267268
268-
beforeDestroy() {
269+
beforeUnmount() {
269270
try {
270271
this.cleanupWebView();
271272

app/components/DebugConsole/ControlsPanel.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,31 @@
1111
<MDButton
1212
col="0"
1313
class="fa control-button"
14-
:text="'fa-arrow-left' | fonticon"
14+
:text="$filters.fonticon('fa-arrow-left')"
1515
variant="flat"
1616
rippleColor="#ffffff"
1717
@tap="handleClose"
1818
/>
1919
<MDButton
2020
col="2"
2121
class="fa control-button trash"
22-
:text="'fa-trash' | fonticon"
22+
:text="$filters.fonticon('fa-trash')"
2323
variant="flat"
2424
rippleColor="#ffffff"
2525
@tap="$emit('clear')"
2626
/>
2727
<MDButton
2828
col="3"
2929
class="fa control-button"
30-
:text="'fa-arrow-up' | fonticon"
30+
:text="$filters.fonticon('fa-arrow-up')"
3131
variant="flat"
3232
rippleColor="#ffffff"
3333
@tap="navigateHistoryUp"
3434
/>
3535
<MDButton
3636
col="4"
3737
class="fa control-button"
38-
:text="'fa-arrow-down' | fonticon"
38+
:text="$filters.fonticon('fa-arrow-down')"
3939
variant="flat"
4040
rippleColor="#ffffff"
4141
@tap="navigateHistoryDown"
@@ -59,7 +59,7 @@
5959
<MDButton
6060
col="1"
6161
class="fa btn-primary send-button"
62-
:text="'fa-paper-plane' | fonticon"
62+
:text="$filters.fonticon('fa-paper-plane')"
6363
variant="flat"
6464
rippleColor="#ffffff"
6565
@tap="executeCommand"

0 commit comments

Comments
 (0)