|
|
@@ -1,4 +1,6 @@
|
|
|
-import { Vibration, YTAvoid, YTHeader } from 'basic';
|
|
|
+import { avPlayerManager, Vibration, YTAvoid, YTHeader, yTRouter } from 'basic';
|
|
|
+import { faceDetector } from '@kit.CoreVisionKit';
|
|
|
+import { trustedAppService } from '@kit.DeviceSecurityKit';
|
|
|
|
|
|
// 观察者模式装饰器
|
|
|
@ObservedV2
|
|
|
@@ -19,6 +21,15 @@ export struct MainView{
|
|
|
private count: number = 10; // 列表中 Cell 对象的数量
|
|
|
private image: ResourceStr=$r('app.media.muyu')
|
|
|
|
|
|
+ //是否是手动
|
|
|
+ @State isHand:boolean=false
|
|
|
+ //是否展示侧边工具栏
|
|
|
+ @State isShowSilder:boolean=true
|
|
|
+ //是否开启声音
|
|
|
+ @State isOpenMusic:boolean=true
|
|
|
+ //是否开启震动
|
|
|
+ @State isOpenVibration:boolean=true
|
|
|
+
|
|
|
//动画true/false
|
|
|
@State isAnimation:boolean=false
|
|
|
//进度条
|
|
|
@@ -29,15 +40,28 @@ export struct MainView{
|
|
|
@State time:number=1000
|
|
|
|
|
|
@State isShowTimeManger:boolean=false
|
|
|
+ @State valueTime:number=10
|
|
|
|
|
|
+ //开启关闭音乐
|
|
|
+ async openMusic(){
|
|
|
+ await avPlayerManager.playByRawSrc('music3.mp3')
|
|
|
|
|
|
- @State valueTime:number=10
|
|
|
+ }
|
|
|
+ async closeMusic(){
|
|
|
+ await avPlayerManager.stop()
|
|
|
+ }
|
|
|
|
|
|
//点击动画
|
|
|
onclikMerit(){
|
|
|
if(this.isAnimation){
|
|
|
return
|
|
|
}
|
|
|
+ if(this.isOpenMusic){
|
|
|
+ this.openMusic()
|
|
|
+ }
|
|
|
+ if(this.isOpenVibration){
|
|
|
+ Vibration.startVibration()
|
|
|
+ }
|
|
|
this.isAnimation=true
|
|
|
this.currentMerit++
|
|
|
let index = this.indexCount % this.count; // 计算当前滚动的索引
|
|
|
@@ -51,6 +75,7 @@ export struct MainView{
|
|
|
duration: 500, // 动画持续时间为1000毫秒
|
|
|
onFinish:()=>{
|
|
|
this.isAnimation=false
|
|
|
+ this.closeMusic()
|
|
|
}
|
|
|
}, () => {
|
|
|
this.list[index].y = -200 // 设置 Cell 的垂直偏移量
|
|
|
@@ -72,41 +97,131 @@ export struct MainView{
|
|
|
Stack({alignContent:Alignment.Top}) {
|
|
|
Tabs({ barPosition: BarPosition.Start, controller: this.tabsController }) {
|
|
|
TabContent() {
|
|
|
-
|
|
|
- TextInput()
|
|
|
- .width(60)
|
|
|
- .height(20)
|
|
|
- .padding(0)
|
|
|
- .type(InputType.Number) // 设置输入类型为数字
|
|
|
- .textAlign(TextAlign.Center)
|
|
|
- .borderRadius(4)
|
|
|
- .backgroundColor(Color.Gray)
|
|
|
+ Column() {
|
|
|
+ Text('敲击间隔时长(1-10秒)')
|
|
|
+
|
|
|
+ Row() {
|
|
|
+ TextInput()
|
|
|
+ .width(70)
|
|
|
+ .height(40)
|
|
|
+ .padding(0)
|
|
|
+ .type(InputType.Number) // 设置输入类型为数字
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .borderRadius(4)
|
|
|
+ .backgroundColor(Color.Gray)
|
|
|
+
|
|
|
+ Text('秒')
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}.tabBar('无限')
|
|
|
|
|
|
TabContent() {
|
|
|
- TextInput()
|
|
|
- .width(60)
|
|
|
- .height(20)
|
|
|
- .padding(0)
|
|
|
- .type(InputType.Number) // 设置输入类型为数字
|
|
|
- .textAlign(TextAlign.Center)
|
|
|
- .borderRadius(4)
|
|
|
- .backgroundColor(Color.Gray)
|
|
|
+ Column() {
|
|
|
+ Column() {
|
|
|
+ Text('敲击次数(1-9999次)')
|
|
|
+ Row() {
|
|
|
+ TextInput()
|
|
|
+ .width(70)
|
|
|
+ .height(40)
|
|
|
+ .padding(0)
|
|
|
+ .type(InputType.Number) // 设置输入类型为数字
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .borderRadius(4)
|
|
|
+ .backgroundColor(Color.Gray)
|
|
|
+
|
|
|
+ Text('秒')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Column() {
|
|
|
+ Text('敲击间隔时长(1-10秒)')
|
|
|
+ Row() {
|
|
|
+ TextInput()
|
|
|
+ .width(70)
|
|
|
+ .height(40)
|
|
|
+ .padding(0)
|
|
|
+ .type(InputType.Number) // 设置输入类型为数字
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .borderRadius(4)
|
|
|
+ .backgroundColor(Color.Gray)
|
|
|
+
|
|
|
+ Text('秒')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}.tabBar('固定次数')
|
|
|
|
|
|
TabContent() {
|
|
|
- TextInput()
|
|
|
- .width(60)
|
|
|
- .height(20)
|
|
|
- .padding(0)
|
|
|
- .type(InputType.Number) // 设置输入类型为数字
|
|
|
- .textAlign(TextAlign.Center)
|
|
|
- .borderRadius(4)
|
|
|
- .backgroundColor(Color.Gray)
|
|
|
+ Column() {
|
|
|
+ Column() {
|
|
|
+ Text('倒计时(1-9999次)')
|
|
|
+ Stack() {
|
|
|
+ Progress({ value: this.valueTime, total: 70, type: ProgressType.Linear }).backgroundColor('#4c4c4c')
|
|
|
+ Row({space:30}){
|
|
|
+ ForEach([0,10,20,30,40,50,60,70],(item:number,index:number)=>{
|
|
|
+ Column(){
|
|
|
+ }.width(10)
|
|
|
+ .height(10)
|
|
|
+ .borderRadius('50%')
|
|
|
+ .onClick(()=>{
|
|
|
+ if(index!=7){
|
|
|
+ this.valueTime=item
|
|
|
+ }else{
|
|
|
+ this.currentIndex=3
|
|
|
+ this.tabsController.changeIndex(this.currentIndex)
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ .backgroundColor(Color.Yellow)
|
|
|
+ // .backgroundColor(this.valueTime>=item?Color.Yellow:Color.White)
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ }.width('100%')
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Column() {
|
|
|
+ Text('敲击间隔时长(1-10秒)')
|
|
|
+ Row() {
|
|
|
+ TextInput()
|
|
|
+ .width(70)
|
|
|
+ .height(40)
|
|
|
+ .padding(0)
|
|
|
+ .type(InputType.Number) // 设置输入类型为数字
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .borderRadius(4)
|
|
|
+ .backgroundColor(Color.Gray)
|
|
|
+
|
|
|
+ Text('秒')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}.tabBar('倒计时')
|
|
|
+ TabContent() {
|
|
|
+ Column() {
|
|
|
+ Text('自定义时间')
|
|
|
+ Row() {
|
|
|
+ TextInput()
|
|
|
+ .width(70)
|
|
|
+ .height(40)
|
|
|
+ .padding(0)
|
|
|
+ .type(InputType.Number) // 设置输入类型为数字
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .borderRadius(4)
|
|
|
+ .backgroundColor(Color.Gray)
|
|
|
+
|
|
|
+ Text('秒')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }.tabBar('自定义')
|
|
|
|
|
|
}.width('100%').barHeight(0)
|
|
|
Row(){
|
|
|
@@ -133,7 +248,7 @@ export struct MainView{
|
|
|
.layoutWeight(1)
|
|
|
.borderRadius(10)
|
|
|
.height(30)
|
|
|
- .backgroundColor(this.currentIndex==2?Color.Green:Color.Transparent)
|
|
|
+ .backgroundColor((this.currentIndex==2||this.currentIndex==3)?Color.Green:Color.Transparent)
|
|
|
.onClick(()=>{
|
|
|
this.currentIndex=2
|
|
|
this.tabsController.changeIndex(this.currentIndex)
|
|
|
@@ -141,13 +256,15 @@ export struct MainView{
|
|
|
})
|
|
|
|
|
|
}.width('100%')
|
|
|
+ .borderRadius(10)
|
|
|
+ .height(30)
|
|
|
.backgroundColor(Color.Pink)
|
|
|
}
|
|
|
|
|
|
|
|
|
}.width('100%')
|
|
|
.height('100%')
|
|
|
- .padding({top:30})
|
|
|
+ .padding(20)
|
|
|
.backgroundColor(Color.White)
|
|
|
|
|
|
}
|
|
|
@@ -162,99 +279,157 @@ export struct MainView{
|
|
|
build() {
|
|
|
Column() {
|
|
|
|
|
|
- Row(){
|
|
|
- Text(`积功德: ${this.currentMerit}`).fontColor(Color.White).layoutWeight(2)
|
|
|
- Text('清零').fontColor(Color.White).onClick(()=>{
|
|
|
- this.currentMerit=0
|
|
|
- }).layoutWeight(1)
|
|
|
-
|
|
|
- Image($r('app.media.muyu')).width(30).layoutWeight(1)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }.width('100%')
|
|
|
- .justifyContent(FlexAlign.SpaceBetween)
|
|
|
-
|
|
|
Row(){
|
|
|
Column(){
|
|
|
- Progress({ value: this.currentMerit, total: this.totalMerit, type: ProgressType.Ring })
|
|
|
- .width(120).color(Color.Orange)
|
|
|
- .style({ strokeWidth: 10, shadow: true })
|
|
|
- .backgroundColor(Color.White)
|
|
|
+ //积功德+清零
|
|
|
+ Row({space:50}){
|
|
|
+ Text(){
|
|
|
+ Span('积功德: ').fontColor(Color.White)
|
|
|
+ Span(`${this.currentMerit}`).fontColor($r('[basic].color.login_main_yellow'))
|
|
|
+ }
|
|
|
+
|
|
|
+ Row() {
|
|
|
+ Text('清零')
|
|
|
+ .borderRadius(6)
|
|
|
+ .padding({
|
|
|
+ left: 6,
|
|
|
+ right: 6,
|
|
|
+ top: 4,
|
|
|
+ bottom: 4
|
|
|
+ })
|
|
|
+ .backgroundColor($r('[basic].color.login_main_yellow'))
|
|
|
+ .fontColor(Color.Black)
|
|
|
+ .onClick(() => {
|
|
|
+ this.currentMerit = 0
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }.width('100%').margin({left:80})
|
|
|
+
|
|
|
+ //进度条
|
|
|
+ Column(){
|
|
|
+ Progress({ value: this.currentMerit, total: this.totalMerit, type: ProgressType.Ring })
|
|
|
+ .width(80).color(Color.Blue)
|
|
|
+ .style({ strokeWidth: 5, shadow: true })
|
|
|
+ .backgroundColor(Color.White)
|
|
|
+
|
|
|
+ Text(`${this.currentMerit}/${this.totalMerit}`).fontColor(Color.White).margin({left:10})
|
|
|
+
|
|
|
+ }.width('100%').justifyContent(FlexAlign.Start).alignItems(HorizontalAlign.Start)
|
|
|
+ }.width('70%')
|
|
|
+ //右边的按钮
|
|
|
|
|
|
- Text(`${this.currentMerit}/${this.totalMerit}`).fontColor(Color.White)
|
|
|
- }
|
|
|
Column({space:30}){
|
|
|
- Image($r('app.media.muyu')).width(30)
|
|
|
- Image($r('app.media.muyu')).width(30)
|
|
|
- }
|
|
|
- }.width('100%').justifyContent(FlexAlign.SpaceBetween)
|
|
|
+ Image($r('app.media.muyu')).width(30).onClick(() => {
|
|
|
+ this.isShowSilder=!this.isShowSilder
|
|
|
|
|
|
- Row(){
|
|
|
- Button('改变文字').onClick(()=>{
|
|
|
- this.list.forEach(item=>{item.value='吴亮+1'})
|
|
|
- })
|
|
|
- Button('敲击时长间隔1秒').onClick(()=>{
|
|
|
- this.time=1000
|
|
|
-
|
|
|
- })
|
|
|
- Button('固定10次').onClick(()=>{
|
|
|
- //自动敲击
|
|
|
- const a=setInterval(()=>{
|
|
|
- this.onclikMerit()
|
|
|
-
|
|
|
- },this.time)
|
|
|
- const b=setTimeout(()=>{
|
|
|
- clearInterval(a)
|
|
|
- clearTimeout(b)
|
|
|
- },this.time*10)
|
|
|
-
|
|
|
-
|
|
|
- })
|
|
|
- Button('倒计时规定时间').onClick(()=>{
|
|
|
- this.onclikMerit()
|
|
|
- const a=setInterval(()=>{
|
|
|
- this.onclikMerit()
|
|
|
- },this.time)
|
|
|
- const b=setTimeout(()=>{
|
|
|
- clearInterval(a)
|
|
|
- clearTimeout(b)
|
|
|
- },10000)
|
|
|
+ })
|
|
|
+ if(this.isShowSilder) {
|
|
|
+ //是否开启声音
|
|
|
+ Image($r('app.media.muyu')).width(30).onClick(()=>{
|
|
|
+ this.isOpenMusic=!this.isOpenMusic
|
|
|
+ })
|
|
|
+ //是否开启震动
|
|
|
+ Image($r('app.media.muyu')).width(30).onClick(()=>{
|
|
|
+ this.isOpenVibration=this.isOpenVibration
|
|
|
+ })
|
|
|
|
|
|
- })
|
|
|
- }
|
|
|
+ Column() {
|
|
|
+ Text(this.isHand ? '手动' : '自动').fontColor(Color.White).onClick(() => {
|
|
|
+ this.isHand = !this.isHand
|
|
|
+ })
|
|
|
+ Text('设置').fontColor(Color.White).bindSheet($$this.isShowTimeManger, this.timeMangerBuilder(), {
|
|
|
+ width: '100%',
|
|
|
+ height: 400,
|
|
|
+ showClose: false,
|
|
|
+ }).onClick(() => {
|
|
|
+ this.isShowTimeManger = true
|
|
|
+ })
|
|
|
+ Text('设置2').fontColor(Color.White).onClick(()=>{
|
|
|
+ //去往设置页面
|
|
|
+ yTRouter.router2FishSettingPage()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- Button('xxx').bindSheet($$this.isShowTimeManger,this.timeMangerBuilder(),{
|
|
|
- width:'100%',
|
|
|
- height:400,
|
|
|
- showClose:false
|
|
|
- }).onClick(()=>{
|
|
|
- this.isShowTimeManger=true
|
|
|
- })
|
|
|
-
|
|
|
- Button('震动').onClick(()=>{
|
|
|
- Vibration.startVibration()
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
- Stack() {
|
|
|
- Progress({ value: this.valueTime, total: 70, type: ProgressType.Linear }).backgroundColor(Color.White)
|
|
|
- Row({space:30}){
|
|
|
- ForEach([0,10,20,30,40,50,60,70],(item:number)=>{
|
|
|
- Column(){
|
|
|
- }.width(10)
|
|
|
- .height(10)
|
|
|
- .borderRadius('50%')
|
|
|
- .onClick(()=>{
|
|
|
- this.valueTime=item
|
|
|
- })
|
|
|
- .backgroundColor(this.valueTime>=item?Color.Pink:Color.White)
|
|
|
- })
|
|
|
+ }.layoutWeight(1)
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ .alignItems(HorizontalAlign.End)
|
|
|
|
|
|
|
|
|
- }.width('100%')
|
|
|
|
|
|
- }
|
|
|
+ }.width('100%')
|
|
|
+ .height(230)
|
|
|
+ .margin({top:20})
|
|
|
+ .alignItems(VerticalAlign.Top)
|
|
|
+
|
|
|
+ // Row(){
|
|
|
+ // Button('改变文字').onClick(()=>{
|
|
|
+ // this.list.forEach(item=>{item.value='吴亮+1'})
|
|
|
+ // })
|
|
|
+ // Button('敲击时长间隔1秒').onClick(()=>{
|
|
|
+ // this.time=1000
|
|
|
+ //
|
|
|
+ // })
|
|
|
+ // Button('固定10次').onClick(()=>{
|
|
|
+ // //自动敲击
|
|
|
+ // const a=setInterval(()=>{
|
|
|
+ // this.onclikMerit()
|
|
|
+ //
|
|
|
+ // },this.time)
|
|
|
+ // const b=setTimeout(()=>{
|
|
|
+ // clearInterval(a)
|
|
|
+ // clearTimeout(b)
|
|
|
+ // },this.time*10)
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // })
|
|
|
+ // Button('倒计时规定时间').onClick(()=>{
|
|
|
+ // this.onclikMerit()
|
|
|
+ // const a=setInterval(()=>{
|
|
|
+ // this.onclikMerit()
|
|
|
+ // },this.time)
|
|
|
+ // const b=setTimeout(()=>{
|
|
|
+ // clearInterval(a)
|
|
|
+ // clearTimeout(b)
|
|
|
+ // },10000)
|
|
|
+ //
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // Button('xxx').bindSheet($$this.isShowTimeManger,this.timeMangerBuilder(),{
|
|
|
+ // width:'100%',
|
|
|
+ // height:400,
|
|
|
+ // showClose:false
|
|
|
+ // }).onClick(()=>{
|
|
|
+ // this.isShowTimeManger=true
|
|
|
+ // })
|
|
|
+ //
|
|
|
+ // Button('震动').onClick(()=>{
|
|
|
+ // Vibration.startVibration()
|
|
|
+ // })
|
|
|
+
|
|
|
+
|
|
|
+ // Stack() {
|
|
|
+ // Progress({ value: this.valueTime, total: 70, type: ProgressType.Linear }).backgroundColor(Color.White)
|
|
|
+ // Row({space:30}){
|
|
|
+ // ForEach([0,10,20,30,40,50,60,70],(item:number)=>{
|
|
|
+ // Column(){
|
|
|
+ // }.width(10)
|
|
|
+ // .height(10)
|
|
|
+ // .borderRadius('50%')
|
|
|
+ // .onClick(()=>{
|
|
|
+ // this.valueTime=item
|
|
|
+ // })
|
|
|
+ // .backgroundColor(this.valueTime>=item?Color.Pink:Color.White)
|
|
|
+ // })
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // }.width('100%')
|
|
|
+ //
|
|
|
+ // }
|
|
|
|
|
|
|
|
|
|