Skip to content

Commit d1ed21b

Browse files
committed
test vue demo app
1 parent c7e96bc commit d1ed21b

File tree

4 files changed

+50
-18
lines changed

4 files changed

+50
-18
lines changed

demo-vue/app/examples/Buttons.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
</ActionBar>
1010
<ScrollView>
1111
<StackLayout>
12+
<MDButton id="button1" elevation="2" borderRadius="10" fontSize="20" text="raised button" @tap="onTap" />
1213
<StackLayout v-if="isEditing">
1314
<MDTextField class="session-details-input" :hint="('name')" />
1415
<MDTextField class="session-details-input" :hint="('description')"/>
@@ -20,13 +21,16 @@
2021
<StackLayout margin="10">
2122
<MDButton id="button0" text="default button" @tap="onTap" />
2223
</StackLayout>
23-
<MDButton id="button1" elevation="2" borderRadius="10" fontSize="20" text="raised button" @tap="onTap" />
2424
<MDButton id="button2" class="bg-red" borderRadius="10" color="red" text="text button" variant="text" @tap="onTap">
2525
<FormattedString>
2626
<Span text="Words " color="#00ff00"></Span>
2727
<Span text="with " color="#ff0000" fontAttributes="Bold"></Span>
2828
</FormattedString>
2929
</MDButton>
30+
<MDButton id="button22" class="bg-red" verticalTextAlignment="center" borderRadius="10" color="red" text="text button" variant="text" @tap="onTap">
31+
<Span text="mdi-magnify" fontSize="20" class="mdi"></Span>
32+
<Span text=" search" fontAttributes="Bold"></Span>
33+
</MDButton>
3034
<MDButton id="button3" text="disabled button" isEnabled="false" @tap="onTap" />
3135
<MDButton id="button3" text="flat button \n test" variant="flat" class="bg-blue" @tap="onTap" />
3236
<MDButton id="button4" text="flat disabled button" variant="flat" isEnabled="false" backgroundColor="yellow" @tap="onTap" />

demo-vue/app/examples/Tabs.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
<!-- The bottom tab UI is created via TabStrip (the containier) and TabStripItem (for each tab)-->
88
<TabStrip>
99
<TabStripItem>
10-
<Label text="Home"></Label>
11-
<Image src="font://󰋜" class="mdi"></Image>
10+
<Label text="Home"/>
11+
<Image src="font://mdi-home" class="mdi"/>
1212
</TabStripItem>
1313
<TabStripItem class="special">
14-
<Label text="Account"></Label>
15-
<Image src="font://󰀄" class="mdi"></Image>
14+
<Label text="Account"/>
15+
<Image src="font://mdi-account" class="mdi"/>
1616
</TabStripItem>
1717
<TabStripItem class="special">
18-
<Label text="Search"></Label>
19-
<Image src="font://󰜏" class="mdi"></Image>
18+
<Label text="Search"/>
19+
<Image src="font://mdi-magnify" class="mdi"/>
2020
</TabStripItem>
2121
</TabStrip>
2222

demo-vue/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
}
1414
},
1515
"dependencies": {
16-
"@mdi/font": "^5.0.45",
17-
"@nativescript/core": "6.5.0",
16+
"@mdi/font": "4.9.95",
17+
"@nativescript/core": "6.5.1",
1818
"@nativescript/theme": "~2.3.3",
1919
"nativescript-iqkeyboardmanager": "^1.5.1",
2020
"nativescript-material-activityindicator": "file:../packages/nativescript-material-activityindicator",
@@ -46,8 +46,10 @@
4646
"nativescript-vue-template-compiler": "^2.5.0",
4747
"node-sass": "^4.13.1",
4848
"sass-loader": "^8.0.2",
49-
"tns-platform-declarations": "6.5.0",
50-
"tslint": "^6.1.0",
49+
"scss-symbols-parser": "^2.0.1",
50+
"string-replace-loader": "^2.3.0",
51+
"tns-platform-declarations": "6.5.1",
52+
"tslint": "^6.1.2",
5153
"tslint-config-prettier": "^1.18.0",
5254
"tslint-config-standard": "^9.0.0",
5355
"typescript": "^3.8.3",

demo-vue/webpack.config.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { join, relative, resolve, sep } = require('path');
2+
const { readFileSync } = require('fs');
23

34
const webpack = require('webpack');
45
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
@@ -199,6 +200,10 @@ module.exports = env => {
199200
itemsToClean.push(`${join(projectRoot, 'platforms', 'android', 'app', 'build', 'configurations', 'nativescript-android-snapshot')}`);
200201
}
201202

203+
const symbolsParser = require('scss-symbols-parser');
204+
const mdiSymbols = symbolsParser.parseSymbols(readFileSync(resolve(projectRoot, 'node_modules/@mdi/font/scss/_variables.scss')).toString());
205+
const mdiIcons = JSON.parse(`{${mdiSymbols.variables[mdiSymbols.variables.length - 1].value.replace(/" (F|0)(.*?)([,\n]|$)/g, '": "$1$2"$3')}}`);
206+
202207
nsWebpack.processAppComponents(appComponents, platform);
203208
const config = {
204209
mode: mode,
@@ -306,6 +311,34 @@ module.exports = env => {
306311
}
307312
].filter(loader => Boolean(loader))
308313
},
314+
{
315+
test: /\.vue$/,
316+
loader: 'vue-loader',
317+
options: {
318+
compiler: NsVueTemplateCompiler
319+
}
320+
},
321+
{
322+
// rules to replace mdi icons and not use nativescript-font-icon
323+
test: /\.(ts|js|css|vue)$/,
324+
exclude: /node_modules/,
325+
use: [
326+
{
327+
loader: 'string-replace-loader',
328+
options: {
329+
search: 'mdi-([a-z-]+)',
330+
replace: (match, p1, offset, string) => {
331+
if (mdiIcons[p1]) {
332+
console.log('replace mdi icon', p1, mdiIcons[p1], String.fromCharCode(parseInt(mdiIcons[p1], 16)));
333+
return String.fromCharCode(parseInt(mdiIcons[p1], 16));
334+
}
335+
return match;
336+
},
337+
flags: 'g'
338+
}
339+
}
340+
]
341+
},
309342
{
310343
test: /[\/|\\]app\.css$/,
311344
use: [
@@ -367,13 +400,6 @@ module.exports = env => {
367400
declaration: false
368401
}
369402
}
370-
},
371-
{
372-
test: /\.vue$/,
373-
loader: 'vue-loader',
374-
options: {
375-
compiler: NsVueTemplateCompiler
376-
}
377403
}
378404
]
379405
},

0 commit comments

Comments
 (0)