Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
d6f5b7af
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6005
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
d6f5b7af
编写于
8月 16, 2024
作者:
shutao-dc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
uni-native-button/utssdk/app-android/index.uts
uni-time-picker/utssdk/app-android/index.uts 代码优化
上级
de825a7f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
11 deletion
+10
-11
uni_modules/uni-native-button/utssdk/app-android/index.uts
uni_modules/uni-native-button/utssdk/app-android/index.uts
+4
-4
uni_modules/uni-time-picker/utssdk/app-android/index.uts
uni_modules/uni-time-picker/utssdk/app-android/index.uts
+6
-7
未找到文件。
uni_modules/uni-native-button/utssdk/app-android/index.uts
浏览文件 @
d6f5b7af
...
@@ -5,13 +5,13 @@ export class NativeButton {
...
@@ -5,13 +5,13 @@ export class NativeButton {
constructor(element : UniNativeViewElement) {
constructor(element : UniNativeViewElement) {
this.$element = element;
this.$element = element;
bindView();
this.
bindView();
}
}
button : Button | null = null;
button : Button | null = null;
bindView() {
bindView() {
//通过UniElement.getAndroidActivity()获取android平台activity 用于创建view的上下文
//通过UniElement.getAndroidActivity()获取android平台activity 用于创建view的上下文
this.button = new Button($element.getAndroidActivity()!); //构建原生view
this.button = new Button(
this.
$element.getAndroidActivity()!); //构建原生view
//限制原生Button 文案描述不自动大写
//限制原生Button 文案描述不自动大写
this.button?.setAllCaps(false)
this.button?.setAllCaps(false)
//监听原生Button点击事件
//监听原生Button点击事件
...
@@ -20,10 +20,10 @@ export class NativeButton {
...
@@ -20,10 +20,10 @@ export class NativeButton {
//构建自定义UniNativeViewEvent返回对象
//构建自定义UniNativeViewEvent返回对象
const event = new UniNativeViewEvent("customClick", detail)
const event = new UniNativeViewEvent("customClick", detail)
//响应分发原生Button的点击事件
//响应分发原生Button的点击事件
$element.dispatchEvent(event)
this.
$element.dispatchEvent(event)
})
})
//UniNativeViewEvent 绑定 安卓原生view
//UniNativeViewEvent 绑定 安卓原生view
$element.bindAndroidView(button!);
this.
$element.bindAndroidView(button!);
}
}
updateText(text: string) {
updateText(text: string) {
...
...
uni_modules/uni-time-picker/utssdk/app-android/index.uts
浏览文件 @
d6f5b7af
import { TimePicker } from "android.widget"
import { TimePicker } from "android.widget"
import { View } from "android.view"
export class NativeTimePicker {
export class NativeTimePicker {
$element : UniNativeViewElement;
$element : UniNativeViewElement;
constructor(element : UniNativeViewElement, hour: number, minute: number) {
constructor(element : UniNativeViewElement, hour: number, minute: number) {
this.$element = element;
this.$element = element;
bindView(hour, minute);
this.
bindView(hour, minute);
}
}
picker : TimePicker | null = null;
picker : TimePicker | null = null;
bindView(hour: number, minute: number) {
bindView(hour: number, minute: number) {
this.picker = new TimePicker($element.getAndroidActivity()!); //构建原生view
this.picker = new TimePicker(
this.
$element.getAndroidActivity()!); //构建原生view
$element.bindAndroidView(
picker!);
this.$element.bindAndroidView(this.
picker!);
setHour(hour)
this.
setHour(hour)
setMinute(minute)
this.
setMinute(minute)
this.picker?.setOnTimeChangedListener((_, hourOfDay, minute) => {
this.picker?.setOnTimeChangedListener((_, hourOfDay, minute) => {
const detail = {"hour": hourOfDay, "minute": minute}
const detail = {"hour": hourOfDay, "minute": minute}
const event = new UniNativeViewEvent("timechanged", detail)
const event = new UniNativeViewEvent("timechanged", detail)
$element.dispatchEvent(event)
this.
$element.dispatchEvent(event)
})
})
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录