From 40d5a9cdc0cbffe094453aad3698adbaaa6d2a7d Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Mon, 30 Dec 2024 13:20:49 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8C=89=E9=92=AE=E5=8F=98=E5=8C=96?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/.DS_Store | Bin 0 -> 6148 bytes entry/src/main/ets/common/utils/request.ts | 3 +- entry/src/main/ets/pages/ExaminerLogin.ets | 4 +- entry/src/main/ets/pages/Index.ets | 13 ++---- entry/src/main/ets/pages/Judge.ets | 40 +++++++++--------- .../main/ets/pages/compontents/TopLogo.ets | 8 ++-- 6 files changed, 32 insertions(+), 36 deletions(-) create mode 100644 entry/src/main/ets/.DS_Store diff --git a/entry/src/main/ets/.DS_Store b/entry/src/main/ets/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3ce9dd10aa59164d02db1068318f7fba98b7bd17 GIT binary patch literal 6148 zcmeHKI|>3Z5S{S@f{mqRuHX%V=n1@lf?^{oiq>0sE|2D$PqQp`S}1Q|@{-BCguG&B zM?`df+s;HLA~J#-%EN}P*}i$ldKpn59A{kbtIP3lI_^8U?*hgh%2_tDmtBi*J2Wal z1*iZOpaN9j(+XsT9gRPIFwdg`RN&_ouHg$K#o*^3bYmI$8uuze+hrn z|F=n8Q2{FOR|@E0v0BXWq^zx-$62i{@HO0Wo^UhFor1y3G0@8~7FLd@o)me-=Gd=^ UO`y{ecRG+i1Evd&3Vd6E7yp { if (index === this.imgArr1.length - 1) { - Image(item).width('38%').height('24%').onClick(() => { + imageBtn({btnWidth:'38%',btnHeight:'24%',imgSrc:item}) + .onClick(() => { if (this.inputTextArr[0].trim() == '' || this.inputTextArr[1].trim() == '') { promptAction.showToast({ message: '请输入用户名和密码', diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index e8f146d0..03183e61 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -21,6 +21,7 @@ import GetDistance from '../common/utils/GetDistance' import UdpEvent from '../common/utils/UdpEvent' import UIAbility from '@ohos.app.ability.UIAbility'; import { endRecordVideo, getUserAlbumItemByDisplayName, saveStartRecordVideo } from '../common/service/videoService'; +import imageBtn from './compontents/imageBtn' // import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; @@ -106,9 +107,7 @@ struct Index { Column() { Row() { if (!this.isSingle) { - Image($r('app.media.index_lw')) - .width('28%') - .height('71%') + imageBtn({btnWidth:'28%',btnHeight:'71%',imgSrc:$r('app.media.index_lw')}) .margin({ left: 80 * globalThis.ratio }) .onClick(async () => { // this.vocObj.playAudio({ @@ -153,9 +152,7 @@ struct Index { }) } if (this.isSingle) { - Image($r('app.media.index_dj')) - .width('28%') - .height('71%') + imageBtn({btnWidth:'28%',btnHeight:'71%',imgSrc:$r('app.media.index_dj')}) .margin({ left: 80 * globalThis.ratio }) .onClick(() => { if (this.loading) { @@ -184,9 +181,7 @@ struct Index { }); }) } - Image($r('app.media.index_zj')) - .width('28%') - .height('71%') + imageBtn({btnWidth:'28%',btnHeight:'71%',imgSrc:$r('app.media.index_zj')}) .margin({ right: 80 * globalThis.ratio }) .onClick(() => { if (this.loading) { diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index 2cb3bcbf..836a5eb2 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -763,10 +763,10 @@ struct Index { .height(118 * 0.95) .margin({ bottom: 8 }) .onClick(() => { - this.vocObj.playAudio({ - type: 1, - name: 'button_media.wav' - }) + // this.vocObj.playAudio({ + // type: 1, + // name: 'button_media.wav' + // }) this.setManualProjectFn(index) }) }) @@ -799,10 +799,10 @@ struct Index { .alignItems(VerticalAlign.Center) .border({ width: 5, color: '#4D4136', radius: 30 }) .onClick(() => { - this.vocObj.playAudio({ - type: 1, - name: 'button_media.wav' - }) + // this.vocObj.playAudio({ + // type: 1, + // name: 'button_media.wav' + // }) this.signDisplayComVisible = true }) @@ -838,10 +838,10 @@ struct Index { .backgroundImageSize({ width: '100%', height: '100%' }) .margin({ bottom: 10 }) .onClick(() => { - this.vocObj.playAudio({ - type: 1, - name: 'button_media.wav' - }) + // this.vocObj.playAudio({ + // type: 1, + // name: 'button_media.wav' + // }) this.isDeductedPopShow = true }) } @@ -871,10 +871,10 @@ struct Index { .backgroundImage($rawfile('judge/anniu_nor.png'), ImageRepeat.NoRepeat) .backgroundImageSize({ width: '100%', height: '100%' }) .onClick(() => { - this.vocObj.playAudio({ - type: 1, - name: 'button_media.wav' - }) + // this.vocObj.playAudio({ + // type: 1, + // name: 'button_media.wav' + // }) if (this.judgeConfigObj['353'] == '0') { this.endPopupVisible = true } else { @@ -938,10 +938,10 @@ struct Index { .backgroundImage($rawfile('judge/close.png'), ImageRepeat.NoRepeat) .backgroundImageSize({ width: '33.33%', height: '33.33%' }) .onClick(() => { - this.vocObj.playAudio({ - type: 1, - name: 'button_media.wav' - }) + // this.vocObj.playAudio({ + // type: 1, + // name: 'button_media.wav' + // }) this.signDisplayComVisible = false }) }.width('100%').height('100%').position({ y: 0 }).backgroundColor('rgba(0,0,0,0.6)') diff --git a/entry/src/main/ets/pages/compontents/TopLogo.ets b/entry/src/main/ets/pages/compontents/TopLogo.ets index e13b6370..3c437358 100644 --- a/entry/src/main/ets/pages/compontents/TopLogo.ets +++ b/entry/src/main/ets/pages/compontents/TopLogo.ets @@ -1,7 +1,7 @@ import router from '@ohos.router'; import { getCurrentTime } from '../../common/service/timeService'; import { voiceService } from '../../common/service/voiceService'; - +import imageBtn from '../compontents/imageBtn' @Component export default struct TopLogo { @State ratio: number = 850 / 960 @@ -33,15 +33,14 @@ export default struct TopLogo { .fontColor('#CCB48F') .margin({ top: -15 * this.ratio, left: 14 * this.ratio }) //fontsize40 } - - Image($r('app.media.topB_back')).width('16.7%').height('12.2%') + imageBtn({btnWidth:'16.7%',btnHeight:'12.2%',imgSrc:$r('app.media.topB_back')}) .onClick(() => { this.vocObj.playAudio({ type: 1, name: 'button_media.wav' }) - router.back() this.outFlag = true + router.back() }) } .position({ x: 0, y: 0 }) @@ -71,3 +70,4 @@ export default struct TopLogo { console.log('jiangsong: topLogo aboutToDisappear222222222') } } + From 17106b34c30750e224f7d1d2c72eed0f9406305f Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Mon, 30 Dec 2024 13:21:26 +0800 Subject: [PATCH 2/2] 1 --- .../main/ets/pages/compontents/imageBtn.ets | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 entry/src/main/ets/pages/compontents/imageBtn.ets diff --git a/entry/src/main/ets/pages/compontents/imageBtn.ets b/entry/src/main/ets/pages/compontents/imageBtn.ets new file mode 100644 index 00000000..adb4eb9e --- /dev/null +++ b/entry/src/main/ets/pages/compontents/imageBtn.ets @@ -0,0 +1,75 @@ +@Component +export default struct imageBtn { + //状态变量unPressed,用于控制按钮的状态 + @State unPressed: boolean = true + btnWidth: string + btnHeight: string + imgSrc:Resource + opacityNum:number=1 + @Styles customStyle(){ + .width('100%') + .height('100%') + } + + build() { + Column() { + Column() { + Stack() { + // Image($r('app.media.topB_back')) + Row() { + // 判断当前组件为放开状态 + if (this.unPressed) { + // 插入Row组件,配置过渡效果 + Image(this.imgSrc) + // 水波纹扩散动画:Row组件backgroundColor属性变更(#fff -> #ccc),系统插入动画过渡效果,从组建的中心点开始放大,scale{0,0}变更scale{1,1} + .transition({ + type: TransitionType.Insert, + opacity: 0, + }) + } + // 判断当前组件为按下状态 + else if (!this.unPressed) { + // 插入Row组件,配置过渡效果 + Image(this.imgSrc) + .opacity(this.opacityNum) + .onAppear(() => { + // 水波纹聚拢动画:Row组件backgroundColor属性变更(#ccc -> #fff),插入动画过渡效果,scale{1,1}变化为scale{0,0} + animateTo({ + duration: 500, + // 聚拢动画播放完成后,需要衔接扩散动画,此时Row组件backgroundColor属性变更(#fff -> #ccc),插入动画过渡效果,scale{0,0}变化为scale{1,1} + onFinish: () => { + this.opacityNum=1 + } }, + () => { + this.opacityNum=0.2 + }) + }) + } + // 其他状态 + + } + .justifyContent(FlexAlign.Center) + .alignItems(VerticalAlign.Center) + } + .customStyle() + } + .width(this.btnWidth) + .height(this.btnHeight) + } + // onTouch事件,监听状态 + .onTouch((event: TouchEvent) => { + // 当按钮按下时,更新按钮的状态(unPressed:true -> false) + if (event.type == TouchType.Down) { + animateTo({ duration: 400 }, () => { + this.unPressed = !this.unPressed + }) + } + // 当按钮放开时,更新按钮的状态(unPressed:false -> true) + if (event.type == TouchType.Up) { + animateTo({ duration: 400 }, () => { + this.unPressed = !this.unPressed + }) + } + }) + } +} \ No newline at end of file