8000 chore: cleanup · 00zhengfu00/nativescript-vue@84103c4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 84103c4

Browse files
committed
chore: cleanup
1 parent 89c4d9b commit 84103c4

30 files changed

+5660
-2397
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
**/dist
2+
*.tgz
23

34
yarn-error.log

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@
1313
"**/.idea": false,
1414
"**/.tscache": true,
1515
"**/node_modules": false
16-
}
16+
},
17+
18+
"html.customData": [
19+
"./test.json"
20+
]
1721
}

build.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import path from "path";
2+
import { fileURLToPath } from "url";
3+
import { build } from "esbuild";
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = path.dirname(__filename);
7+
8+
try {
9+
await build({
10+
bundle: true,
11+
sourcemap: true,
12+
format: "cjs",
13+
// target: "node",
14+
external: ["@nativescript/core"],
15+
entryPoints: [path.join(__dirname, "src", "index.ts")],
16+
outdir: path.join(__dirname, "dist"),
17+
// outExtension: { ".js": ".mjs" },
18+
define: {
19+
__VUE_OPTIONS_API__: true,
20+
__VUE_PROD_DEVTOOLS__: true
21+
}
22+
});
23+
} catch {
24+
process.exitCode = 1;
25+
}

demo/App_Resources/iOS/Podfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pod 'FPSCounter', '~> 4.1'

demo/App_Resources/iOS/build.xcconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
// To build for device with XCode you need to specify your development team.
55
// DEVELOPMENT_TEAM = YOUR_TEAM_ID;
66
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
7+
8+
DEVELOPMENT_TEAM = 3462C7DLZZ
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import FPSCounter;
2+
3+
extension UIView {
4+
5+
@objc func showFPSMeter(
6+
) {
7+
FPSCounter.showInStatusBar()
8+
}
9+
10+
}

demo/app/App copy 2.vue

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
<script setup lang="ts">
2+
import { goHome } from "./composables/goHome";
3+
import { UseTimeAgo } from "@vueuse/components";
4+
import { useFPS } from "./composables/useFPS";
5+
import { ref } from "vue";
6+
import { ObservableArray } from "@nativescript/core";
7+
import { debounceFilter, useDebounceFn } from "@vueuse/shared";
8+
9+
const navigate = () => {
10+
goHome();
11+
};
12+
13+
interface Item {
14+
title: string;
15+
text: string;
16+
date: Date;
17+
}
18+
19+
function getDate(offset: number = 0) {
20+
const ts = new Date().getTime();
21+
return new Date(ts - offset * 1000);
22+
}
23+
24+
// const items: Item[] = Array(10000)
25+
// .fill(0)
26+
// .map((_, i) => {
27+
// return {
28+
// title: `Item ${i}`,
29+
// text: "Lorem ipsum dolor sit amet...",
30+
// date: getDate(i),
31+
// };
32+
// });
33+
34+
const { fps } = useFPS();
35+
36+
const count = ref(0);
37+
const items2 = ref(
38+
new ObservableArray(
39+
Array(1000)
40+
.fill(0)
41+
.map((_, i) => {
42+
return {
43+
name: `Item ${i}`,
44+
};
45+
})
46+
)
47+
);
48+
const name = ref("Vue 3");
49+
50+
const selected = ref<any[]>([]);
51+
7802
52+
function onTap() {
53+
console.log("tapped", count.value);
54+
count.value++;
55+
}
56+
57+
const show = ref(false);
58+
59+
// setInterval(() => {
60+
// show.value = !show.value;
61+
// }, 10);
62+
63+
setInterval(() => {
64+
count.value++;
65+
}, 10);
66+
67+
// setInterval(() => {
68+
// items2.value.push({ name: name.value });
69+
// }, 100);
70+
71+
const onItemTap = useDebounceFn((item) => {
72+
console.log("ITEM TAP", item);
73+
if (selected.value.includes(item)) {
74+
selected.value.splice(selected.value.indexOf(item), 1);
75+
} else {
76+
selected.value.push(item);
77+
}
78+
}, 10);
79+
</script>
80+
81+
<template>
82+
<Frame>
83+
<Page>
84+
<GridLayout rows="auto, auto, *">
85+
<Button text="Navigate" @tap="navigate" />
86+
<Label
87+
rew="1"
88+
:text="fps"
89+
color="green"
90+
fontFamily="monospace"
91+
textAlignment="right"
92+
fontSize="32"
93+
fontWeight="bold"
94+
/>
95+
<StackLayout row="2">
96+
<Label>Hello: {{ name }}</Label>
97+
<Button
98+
@tap="onTap"
99+
padding="16"
100+
backgroundColor="#65adf1"
101+
:text="`Tap me`"
102+
></Button>
103+
104+
<GridLayout height="60" columns="*, *">
105+
<Button col="0" @tap="items2.push({ name: name + items2.length })"
106+
>Add item!</Button
107+
>
108+
<Button col="1" @tap="items2.pop()">Remove item!</Button>
109+
</GridLayout>
110+
111+
<Label>Selected: {{ selected.length }}</Label>
112+
113+
<ListView :items="items2" height="800">
114+
<template #default="{ item, index }: ListItem<{ name: string }>">
115+
<StackLayout
116+
@tap="onItemTap(item)"
117+
:backgroundColor="selected.includes(item) ? '#ffedd5' : ''"
118+
padding="16"
119+
>
120+
<Progress :value="(index + count) % 100" />
121+
<Label
122+
:text="`Current name: ${name}, current count: ${count}`"
123+
/>
124+
<Label :text="`Odd: Index: ${index}, name: ${item.name}`" />
125+
<Label
126+
:text="item.name"
127+
color="#16a34a"
128+
textAlignment="right"
129+
/>
130+
<Button
131+
@tap="items2.splice(index, 1)"
132+
horizontalAlignment="right"
133+
backgroundColor="#fee2e2"
134+
color="#7f1d1d"
135+
borderRadius="8"
136+
marginTop="8"
137+
padding="8"
138+
>Remove</Button
139+
>
140+
</StackLayout>
141+
</template>
142+
</ListView>
143+
</StackLayout>
144+
<!-- <ListView row="2" :items="items">
145+
<template #default="{ item, even }: ListItem<Item>">
146+
<GridLayout rows="auto, auto, auto" padding="16">
147+
<Label
148+
:text="item.title"
149+
fontSize="18"
150+
fontWeight="bold"
151+
:color="even ? 'red' : 'blue'"
152+
/>
153+
<Label :text="item.text" marginTop="8" row="1" />
154+
<UseTimeAgo v-slot="{ timeAgo }" :time="item.date">
155+
<Label :text="timeAgo" color="#65adf1" marginTop="12" row="2" />
156+
</UseTimeAgo>
157+
</GridLayout>
158+
</template>
159+
</ListView> -->
160+
</GridLayout>
161+
</Page>
162+
</Frame>
163+
</template>

demo/app/App copy.vue

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<script setup lang="ts">
2+
import { ref } from "vue";
3+
import { goHome } from "./composables/goHome";
4+
5+
import { useTimeAgo } from "@vueuse/core";
6+
7+
const navigate = () => {
8+
goHome();
9+
};
10+
11+
const timeAgo = useTimeAgo(new Date(), {
12+
showSecond: true,
13+
updateInterval: 1000,
14+
});
15+
16+
// const items = computed(() => {
17+
// return ["a", "b", "c", "d", "e", "f", "g", "h"];
18+
// });
19+
const items: string[] = Array(1000)
20+
.fill(0)
21+
.map((_, i) => `Item ${i}`);
22+
23+
const selector = (item: ListItem) => {
24+
return item.even ? "default" : "odd";
25+
};
26+
27+
const ts = ref(new Date().getTime());
28+
const visible = ref(false);
29+
30+
setInterval(() => {
31+
ts.value = new Date().getTime();
32+
visible.value = !visible.value;
33+
}, 500);
34+
</script>
35+
36+
<template>
37+
<Frame>
38+
<Page>
39+
<GridLayout rows="auto, auto, auto, *">
40+
<Button text="Navigate" @tap="navigate" />
41+
42+
<Label :text="timeAgo" row="1" />
43+
<Label :text="ts" row="2" />
44+
45+
<ListView row="3" :items="items" :itemTemplateSelector="selector">
46+
<template #default="{ item: aliased }: ListItem<string>">
47+
<Label
48+
:text="`Item: ${aliased} Time: ${ts}\n\n${timeAgo}`"
49+
textWrap="true"
50+
padding="16"
51+
/>
52+
</template>
53+
<template #odd="{ item }: ListItem<string>">
54+
<GridLayout rows="auto, 50">
55+
<Label
56+
:text="`ODD: ${item} Time: ${ts}!!`"
57+
padding="16"
58+
backgroundColor="rgba(255, 0, 0, 0.2)"
59+
/>
60+
61+
<Button row="1" v-show="visible">Tap me if you can!</Button>
62+
<Button row="1" v-show="!visible">You missed it</Button>
63+
</GridLayout>
64+
</template>
65+
</ListView>
66+
</GridLayout>
67+
</Page>
68+
</Frame>
69+
</template>

demo/app/App.vue

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,50 @@
11
<script setup lang="ts">
2-
import { computed, ref } from "vue";
2+
import { ref } from "vue";
33
import { goHome } from "./composables/goHome";
4-
5-
import { useTimeAgo } from "@vueuse/core";
4+
import { useFPS } from "./composables/useFPS";
65
76
const navigate = () => {
87
goHome();
98
};
109
11-
const timeAgo = useTimeAgo(new Date());
10+
const { fps } = useFPS();
11+
12+
const something = "SOMETHING";
13+
const somethingElse = "SOMETHING_ELSE";
14+
const whatever = "WHATEVER";
15+
16+
const data = ref([{ name: "foo" }, { name: "bar" }, { name: "baz" }]);
1217
13-
// const items = computed(() => {
14-
// return ["a", "b", "c", "d", "e", "f", "g", "h"];
15-
// });
16-
const items: string[] = Array(1000)
17-
.fill(0)
18-
.map((_, i) => `Item ${i}`);
18+
const blink = ref(true);
191 10000 9
20-
const ts = ref(new Date().getTime());
2120
setInterval(() => {
22-
ts.value = new Date().getTime();
23-
}, 500);
21+
blink.value = !blink.value;
22+
}, 1000);
2423
25-
const selector = (item: ListItem) => {
26-
return item.even ? "default" : "odd";
27-
};
2824
</script>
2925

3026
<template>
3127
<Frame>
3228
<Page>
33-
<GridLayout rows="auto, auto, auto, *">
29+
<StackLayout>
3430
<Button text="Navigate" @tap="navigate" />
35-
36-
<Label :text="timeAgo" row="1" />
37-
<Label :text="ts" row="2" />
38-
39-
<ListView row="3" :items="items" :itemTemplateSelector="selector">
40-
<template #default="{ item: aliased }: ListItem<string>">
41-
<Label :text="`Item: ${aliased} Time: ${ts}`" padding="16" />
42-
</template>
43-
<template #odd="{ item: aliased }: ListItem<string>">
44-
<Label
45-
:text="`ODD: ${aliased} Time: ${ts}!!`"
46-
padding="16"
47-
backgroundColor="rgba(255, 0, 0, 0.2)"
48-
/>
49-
</template>
50-
</ListView>
51-
</GridLayout>
31+
<Label
32+
:text="fps"
33+
color="green"
34+
fontFamily="monospace"
35+
textAlignment="right"
36+
fontSize="32"
37+
fontWeight="bold"
38+
/>
39+
<Label>{{ blink }}</Label>
40+
<Label :text="blink" />
41+
<Label v-for="(item, i) in data" textWrap>
42+
#{{ i }}: {{ item.name }} This is
43+
{{ blink ? something : somethingElse }} and
44+
{{ blink ? somethingElse : "" }} with a bit of
45+
{{ blink && whatever }} sprinkled in. And ofc some {{ fps }}...
46+
</Label>
47+
</StackLayout>
5248
</Page>
5349
</Frame>
5450
</template>

demo/app/app.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { createApp } from "../../src";
1+
import { createApp } from "../../dist";
22

3+
// @ts-ignore
4+
global.window = global;
35
// import Home from './components/Home.vue'
46

5-
import App from "./App.vue";
7+
import App from "./App copy 2.vue";
68

79
createApp(App).start();

0 commit comments

Comments
 (0)
0