@lynx-example/refresh 0.0.0 → 0.6.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  Apache License
3
2
  Version 2.0, January 2004
4
3
  http://www.apache.org/licenses/
Binary file
@@ -0,0 +1,30 @@
1
+ // Copyright 2024 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+ import { pluginQRCode } from "@lynx-js/qrcode-rsbuild-plugin";
6
+ import { pluginReactLynx } from "@lynx-js/react-rsbuild-plugin";
7
+ import { defineConfig } from "@lynx-js/rspeedy";
8
+ import { pluginSass } from "@rsbuild/plugin-sass";
9
+ import { pluginTypeCheck } from "@rsbuild/plugin-type-check";
10
+
11
+ export default defineConfig({
12
+ source: {
13
+ entry: {
14
+ base: "./src/base/index.tsx",
15
+ },
16
+ },
17
+ plugins: [
18
+ pluginReactLynx(),
19
+ pluginSass(),
20
+ pluginQRCode(),
21
+ pluginTypeCheck(),
22
+ ],
23
+ output: {
24
+ assetPrefix: "https://lynxjs.org/lynx-examples/refresh/dist",
25
+ filename: "[name].[platform].bundle",
26
+ },
27
+ environments: {
28
+ lynx: {},
29
+ },
30
+ });
package/package.json CHANGED
@@ -1,9 +1,35 @@
1
1
  {
2
2
  "name": "@lynx-example/refresh",
3
- "version": "0.0.0",
3
+ "version": "0.6.9",
4
4
  "description": "An example shows how to use `<refresh>` in Lynx",
5
- "keywords": [],
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/lynx-family/lynx-examples.git",
8
+ "directory": "examples/refresh"
9
+ },
6
10
  "license": "Apache-2.0",
11
+ "author": "Lynx Authors",
7
12
  "type": "module",
8
- "main": "index.js"
9
- }
13
+ "files": [
14
+ "dist/",
15
+ "src/",
16
+ "lynx.config.mjs"
17
+ ],
18
+ "dependencies": {
19
+ "@lynx-js/react": "0.115.3"
20
+ },
21
+ "devDependencies": {
22
+ "@lynx-js/qrcode-rsbuild-plugin": "0.4.3",
23
+ "@lynx-js/react-rsbuild-plugin": "0.12.4",
24
+ "@lynx-js/rspeedy": "0.12.5",
25
+ "@lynx-js/types": "3.6.0",
26
+ "@rsbuild/plugin-sass": "1.4.0",
27
+ "@types/react": "^18.3.25",
28
+ "typescript": "~5.9.3"
29
+ },
30
+ "scripts": {
31
+ "build": "rspeedy build",
32
+ "dev": "rspeedy dev",
33
+ "preview": "rspeedy preview"
34
+ }
35
+ }
@@ -0,0 +1,81 @@
1
+ // Copyright 2024 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+ import { root, useRef, useState } from "@lynx-js/react";
6
+ import type { NodesRef } from "@lynx-js/types";
7
+
8
+ const App = () => {
9
+ const refreshViewRef = useRef<NodesRef>(null);
10
+ const [refreshCount, setRefreshCount] = useState<number>(0);
11
+ const [items, setItems] = useState<number[]>([0, 1, 2, 4, 5, 6, 7, 8]);
12
+ const onStartRefresh = () => {
13
+ console.log("on start refresh");
14
+ setTimeout(() => {
15
+ refreshViewRef.current?.invoke({
16
+ method: "finishRefresh",
17
+ }).exec();
18
+ setItems([0, 1, 2, 4, 5, 6, 7, 8]);
19
+ setRefreshCount(refreshCount + 1);
20
+ }, 1000);
21
+ };
22
+
23
+ return (
24
+ <view
25
+ style={{
26
+ width: "100%",
27
+ height: "100%",
28
+ flexDirection: "column",
29
+ backgroundColor: "white",
30
+ }}
31
+ >
32
+ {
33
+ // @ts-expect-error type error
34
+
35
+
36
+ <refresh ref={refreshViewRef} style={{ width: "100%", height: "100%" }} bindstartrefresh={onStartRefresh}>
37
+ <refresh-header
38
+ style={{
39
+ width: "100%",
40
+ height: "50px",
41
+ position: "absolute",
42
+ justifyContent: "center",
43
+ alignItems: "center",
44
+ backgroundColor: "red",
45
+ }}
46
+ >
47
+ <text style={{ fontSize: "30px" }}>Refreshing...</text>
48
+ </refresh-header>
49
+ <list style={{ width: "100%", height: "100%" }} scroll-orientation="vertical" bounces={true}>
50
+ {items.map((item, index) => {
51
+ return (
52
+ <list-item key={item + ""} item-key={item + ""}>
53
+ <text
54
+ style={{
55
+ "height": "200px",
56
+ width: "100%",
57
+ fontSize: "100px",
58
+ color: refreshCount % 2 === 0 ? "red" : "green",
59
+ padding: "25px",
60
+ textAlign: "center",
61
+ border: "1px solid black",
62
+ }}
63
+ >
64
+ {`item-${index}`}
65
+ </text>
66
+ </list-item>
67
+ );
68
+ })}
69
+ </list>
70
+ </refresh>
71
+
72
+ }
73
+ </view>
74
+ );
75
+ };
76
+
77
+ root.render(<App />);
78
+
79
+ if (import.meta.webpackHot) {
80
+ import.meta.webpackHot.accept();
81
+ }
package/index.js DELETED
@@ -1 +0,0 @@
1
- export {}