From 6315018cb92065d1e1e0f764cf62efdfaa97fee2 Mon Sep 17 00:00:00 2001 From: shutao Date: Mon, 12 Aug 2024 19:31:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Enative-view=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 10 +++- pages/component/native-view/native-view.uvue | 48 +++++++++++++++++++ .../native-button/native-button.uvue | 6 +-- .../utssdk/app-android/index.uts | 10 ++-- .../components/time-picker/time-picker.uvue | 6 +-- .../utssdk/app-android/index.uts | 10 ++-- 6 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 pages/component/native-view/native-view.uvue diff --git a/pages.json b/pages.json index 9fd6b1d8..2a9bd3f6 100644 --- a/pages.json +++ b/pages.json @@ -483,6 +483,14 @@ "navigationBarTitleText": "涂鸦" } }, + // #ifndef WEB + { + "path": "pages/component/native-view/native-view", + "style": { + "navigationBarTitleText": "native-view" + } + }, + // #endif { "path": "pages/tabBar/API", "style": { @@ -2751,4 +2759,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/pages/component/native-view/native-view.uvue b/pages/component/native-view/native-view.uvue new file mode 100644 index 00000000..16bed9f8 --- /dev/null +++ b/pages/component/native-view/native-view.uvue @@ -0,0 +1,48 @@ + + + + + diff --git a/uni_modules/uni-native-button/components/native-button/native-button.uvue b/uni_modules/uni-native-button/components/native-button/native-button.uvue index bfd01926..e3a0209f 100644 --- a/uni_modules/uni-native-button/components/native-button/native-button.uvue +++ b/uni_modules/uni-native-button/components/native-button/native-button.uvue @@ -1,6 +1,6 @@ @@ -33,12 +33,12 @@ }, }, methods: { - onObjectInit(e : UniObjectInitEvent) { + onviewinit(e : UniNativeViewInitEvent) { this.button = new NativeButton(e.detail.element); this.button?.updateText(this.value) this.$emit("load") }, - onclick(e: UniObjectCustomEvent) { + onclick(e: UniNativeViewEvent) { this.$emit("buttonTap", e) } }, diff --git a/uni_modules/uni-native-button/utssdk/app-android/index.uts b/uni_modules/uni-native-button/utssdk/app-android/index.uts index 08178dc5..449b7c17 100644 --- a/uni_modules/uni-native-button/utssdk/app-android/index.uts +++ b/uni_modules/uni-native-button/utssdk/app-android/index.uts @@ -1,9 +1,9 @@ import { Button } from "android.widget" export class NativeButton { - $element : UniObjectElement; + $element : UniNativeViewElement; - constructor(element : UniObjectElement) { + constructor(element : UniNativeViewElement) { this.$element = element; bindView(); } @@ -17,12 +17,12 @@ export class NativeButton { //监听原生Button点击事件 this.button?.setOnClickListener(_ => { const detail = {} - //构建自定义UniObjectCustomEvent返回对象 - const event = new UniObjectCustomEvent("customClick", detail) + //构建自定义UniNativeViewEvent返回对象 + const event = new UniNativeViewEvent("customClick", detail) //响应分发原生Button的点击事件 $element.dispatchEvent(event) }) - //UniObjectElement 绑定 安卓原生view + //UniNativeViewEvent 绑定 安卓原生view $element.bindAndroidView(button!); } diff --git a/uni_modules/uni-time-picker/components/time-picker/time-picker.uvue b/uni_modules/uni-time-picker/components/time-picker/time-picker.uvue index 3d5e8682..70b77ec2 100644 --- a/uni_modules/uni-time-picker/components/time-picker/time-picker.uvue +++ b/uni_modules/uni-time-picker/components/time-picker/time-picker.uvue @@ -1,5 +1,5 @@