|
|
@@ -1,30 +1,34 @@
|
|
|
-import { avPlayerManager, Vibration, YTAvoid, YTHeader, yTRouter } from 'basic';
|
|
|
+import { AppStorageKeyFishCollect, avPlayerManager, Vibration, YTAvoid, YTHeader, yTRouter } from 'basic';
|
|
|
import { faceDetector } from '@kit.CoreVisionKit';
|
|
|
import { trustedAppService } from '@kit.DeviceSecurityKit';
|
|
|
+import { promptAction } from '@kit.ArkUI';
|
|
|
+import { Cell } from '../models';
|
|
|
+
|
|
|
|
|
|
-// 观察者模式装饰器
|
|
|
-@ObservedV2
|
|
|
-class Cell {
|
|
|
- value: string = '功德+1'; // 默认显示的文字
|
|
|
- @Trace // 跟踪属性变化
|
|
|
- opacity: number = 0; // 文字透明度
|
|
|
- @Trace // 跟踪属性变化
|
|
|
- y: number = 0; // 文字的垂直偏移量
|
|
|
-}
|
|
|
@Component
|
|
|
export struct MainView{
|
|
|
- @State currentIndex: number = 0
|
|
|
+ @Watch('changeText')
|
|
|
+ @StorageProp(AppStorageKeyFishCollect.FISHTEXT)
|
|
|
+ text:string=""
|
|
|
+ @State private currentIndex: number = 0
|
|
|
tabsController: TabsController = new TabsController()
|
|
|
@StorageProp(YTAvoid.SAFE_TOP_KEY) top: number = 0
|
|
|
@State list: Cell[] = []; // 存储所有 Cell 对象的数组
|
|
|
private indexCount: number = 0; // 记录当前滚动的索引
|
|
|
private count: number = 10; // 列表中 Cell 对象的数量
|
|
|
private image: ResourceStr=$r('app.media.muyu')
|
|
|
+ changeText(){
|
|
|
+ if(this.text!="") {
|
|
|
+ this.list.forEach(item => item.value = this.text)
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//是否是手动
|
|
|
- @State isHand:boolean=false
|
|
|
+ @State isAuto:boolean=false
|
|
|
//是否展示侧边工具栏
|
|
|
@State isShowSilder:boolean=true
|
|
|
+ //是否展示信息展示
|
|
|
+ @State isShowMessage:boolean=true
|
|
|
//是否开启声音
|
|
|
@State isOpenMusic:boolean=true
|
|
|
//是否开启震动
|
|
|
@@ -279,91 +283,198 @@ export struct MainView{
|
|
|
build() {
|
|
|
Column() {
|
|
|
|
|
|
- Row(){
|
|
|
- Column(){
|
|
|
- //积功德+清零
|
|
|
- Row({space:50}){
|
|
|
- Text(){
|
|
|
- Span('积功德: ').fontColor(Color.White)
|
|
|
- Span(`${this.currentMerit}`).fontColor($r('[basic].color.login_main_yellow'))
|
|
|
- }
|
|
|
+
|
|
|
+ Stack({alignContent:Alignment.Bottom}) {
|
|
|
+ Column() {
|
|
|
+ if (this.isShowMessage) {
|
|
|
|
|
|
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
|
|
|
- })
|
|
|
+ Column({ space: 20 }) {
|
|
|
+ //积功德+清零
|
|
|
+ Row() {
|
|
|
+ Text() {
|
|
|
+ Span('积功德: ').fontColor(Color.White).fontSize(18)
|
|
|
+ Span(`${this.currentMerit}`).fontSize(18).fontColor($r('[basic].color.login_main_yellow'))
|
|
|
+ }.margin({ left: 50 })
|
|
|
+
|
|
|
+ Row() {
|
|
|
+ Text('清零')
|
|
|
+ .borderRadius(20)
|
|
|
+ .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})
|
|
|
+ }.width('100%').justifyContent(FlexAlign.SpaceAround)
|
|
|
|
|
|
- //进度条
|
|
|
- Column(){
|
|
|
- Progress({ value: this.currentMerit, total: this.totalMerit, type: ProgressType.Ring })
|
|
|
- .width(80).color(Color.Blue)
|
|
|
- .style({ strokeWidth: 5, shadow: true })
|
|
|
- .backgroundColor(Color.White)
|
|
|
+ //进度条
|
|
|
+ Column() {
|
|
|
+ Stack({ alignContent: Alignment.Center }) {
|
|
|
+ Progress({ value: this.currentMerit, total: this.totalMerit, type: ProgressType.Ring })
|
|
|
+ .width(80).color('#3dbbd1')
|
|
|
+ .style({ strokeWidth: 6, shadow: true })
|
|
|
+ .backgroundColor(Color.White)
|
|
|
+ Text('集福').fontSize(20).fontColor(Color.White)
|
|
|
+ }.margin({ left: 10 })
|
|
|
|
|
|
- Text(`${this.currentMerit}/${this.totalMerit}`).fontColor(Color.White).margin({left:10})
|
|
|
+ Text() {
|
|
|
+ Span(`${this.currentMerit}`).fontColor($r('[basic].color.login_main_yellow'))
|
|
|
+ Span(`/${this.totalMerit}`)
|
|
|
+ }.fontColor(Color.White).margin({ left: 10 }).width(80).textAlign(TextAlign.Center)
|
|
|
|
|
|
- }.width('100%').justifyContent(FlexAlign.Start).alignItems(HorizontalAlign.Start)
|
|
|
- }.width('70%')
|
|
|
- //右边的按钮
|
|
|
+ }.width('100%').justifyContent(FlexAlign.Start).alignItems(HorizontalAlign.Start)
|
|
|
+ }.layoutWeight(1)
|
|
|
|
|
|
- Column({space:30}){
|
|
|
- Image($r('app.media.muyu')).width(30).onClick(() => {
|
|
|
- this.isShowSilder=!this.isShowSilder
|
|
|
+ //右边的按钮
|
|
|
|
|
|
- })
|
|
|
- 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({ space: 20 }) {
|
|
|
+ Image($r('app.media.muyu')).width(30).onClick(() => {
|
|
|
+ this.isShowSilder = !this.isShowSilder
|
|
|
+ })
|
|
|
+ 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() {
|
|
|
+ Column() {
|
|
|
+ Text(this.isAuto ? '自动' : '手动')
|
|
|
+ .padding({
|
|
|
+ left: 3,
|
|
|
+ right: 3,
|
|
|
+ top: 10,
|
|
|
+ bottom: 10
|
|
|
+ })
|
|
|
+ .margin({ bottom: 10 })
|
|
|
+ .backgroundColor('#252111')
|
|
|
+ .fontColor(Color.White)
|
|
|
+ .onClick(() => {
|
|
|
+ this.isAuto = !this.isAuto
|
|
|
+ //如果是本来自动,再点击就是手动,不需要设置任何东西
|
|
|
+ // if (!this.isHand) {
|
|
|
+ // this.isHand = true
|
|
|
+ // } else {
|
|
|
+ // //如果本来是手动,再点击就是自动,就需要设置东西
|
|
|
+ // this.isHand = false
|
|
|
+ // }
|
|
|
+ })
|
|
|
+ if (this.isAuto) {
|
|
|
+ Column({ space: 10 }) {
|
|
|
+ Text('结束')
|
|
|
+ .padding({
|
|
|
+ left: 3,
|
|
|
+ right: 3,
|
|
|
+ top: 10,
|
|
|
+ bottom: 10
|
|
|
+ })
|
|
|
+ .fontColor(Color.White)
|
|
|
+ .backgroundColor('#252111')
|
|
|
+ .onClick(() => {
|
|
|
+ this.isAuto = !this.isAuto
|
|
|
+ })
|
|
|
+ Text('设置')
|
|
|
+ .padding({
|
|
|
+ left: 3,
|
|
|
+ right: 3,
|
|
|
+ top: 10,
|
|
|
+ bottom: 10
|
|
|
+ })
|
|
|
+ .fontColor(Color.White)
|
|
|
+ .backgroundColor('#252111')
|
|
|
+ .bindSheet($$this.isShowTimeManger, this.timeMangerBuilder(), {
|
|
|
+ width: '100%',
|
|
|
+ height: 400,
|
|
|
+ showClose: false,
|
|
|
+ })
|
|
|
+ .onClick(() => {
|
|
|
+ this.isShowTimeManger = true
|
|
|
+ })
|
|
|
+ Text('设置2')
|
|
|
+ .padding({
|
|
|
+ left: 3,
|
|
|
+ right: 3,
|
|
|
+ top: 10,
|
|
|
+ bottom: 10
|
|
|
+ })
|
|
|
+ .fontColor(Color.White)
|
|
|
+ .backgroundColor('#252111')
|
|
|
+ .onClick(() => {
|
|
|
+ //去往设置页面
|
|
|
+ yTRouter.router2FishSettingPage()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- 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()
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
+ }.width(50)
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ .alignItems(HorizontalAlign.End)
|
|
|
+
|
|
|
+ }.width('100%')
|
|
|
+ .height(300)
|
|
|
|
|
|
- }.layoutWeight(1)
|
|
|
- .justifyContent(FlexAlign.Center)
|
|
|
- .alignItems(HorizontalAlign.End)
|
|
|
+ .alignItems(VerticalAlign.Top)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .height('100%')
|
|
|
+ .margin({ top: 20 })
|
|
|
+
|
|
|
+ Column() {
|
|
|
+ Stack() { // 创建一个堆栈布局容器
|
|
|
+ ForEach(this.list, (item: Cell, _index: number) => { // 遍历 list 中的每一个 Cell
|
|
|
+ Text(item.value)// 显示 Cell 中的文字
|
|
|
+ .fontColor(Color.White)// 设置文字颜色为白色
|
|
|
+ .fontSize('50lpx')// 设置文字大小
|
|
|
+ .translate({ x: 0, y: `${item.y}lpx` })// 设置文字的垂直偏移量
|
|
|
+ .opacity(item.opacity) // 设置文字的透明度
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .width(200) //
|
|
|
+ .height(100)
|
|
|
+ .align(Alignment.BottomEnd)
|
|
|
+ Image(this.image)
|
|
|
+ .width(200)
|
|
|
+ .height(200)
|
|
|
+ .objectFit(ImageFit.Contain)
|
|
|
+ .clickEffect({
|
|
|
+ // 点击效果配置
|
|
|
+ scale: 0.5, // 缩放比例
|
|
|
+ level: ClickEffectLevel.LIGHT // 效果级别
|
|
|
+ })
|
|
|
+ .onClick(() => { // 点击图片时触发的回调
|
|
|
+ this.onclikMerit()
|
|
|
+ })
|
|
|
|
|
|
+ Row(){
|
|
|
|
|
|
+ Image($r('app.media.muyu')).width(30).onClick(()=>{
|
|
|
+ this.isShowMessage=!this.isShowMessage
|
|
|
+ })
|
|
|
+ }.width('100%')
|
|
|
+ .margin({top:50})
|
|
|
+ .justifyContent(FlexAlign.End)
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+ .margin({bottom:20})
|
|
|
|
|
|
- }.width('100%')
|
|
|
- .height(230)
|
|
|
- .margin({top:20})
|
|
|
- .alignItems(VerticalAlign.Top)
|
|
|
+ }.height('100%')
|
|
|
|
|
|
// Row(){
|
|
|
// Button('改变文字').onClick(()=>{
|
|
|
@@ -433,41 +544,7 @@ export struct MainView{
|
|
|
|
|
|
|
|
|
|
|
|
- Column() { // 创建一个垂直布局容器
|
|
|
- Stack() { // 创建一个堆栈布局容器
|
|
|
- ForEach(this.list, (item: Cell, _index: number) => { // 遍历 list 中的每一个 Cell
|
|
|
- Text(item.value)// 显示 Cell 中的文字
|
|
|
- .fontColor(Color.White)// 设置文字颜色为白色
|
|
|
- .fontSize('50lpx')// 设置文字大小
|
|
|
- .translate({ x: 0, y: `${item.y}lpx` })// 设置文字的垂直偏移量
|
|
|
- .opacity(item.opacity) // 设置文字的透明度
|
|
|
- })
|
|
|
- }
|
|
|
- .width(200) // 设置堆栈布局容器的宽度
|
|
|
- .height(200) // 设置堆栈布局容器的高度
|
|
|
- .align(Alignment.BottomEnd) // 设置对齐方式为底部右端
|
|
|
-
|
|
|
- Image(this.image)// 显示图片
|
|
|
- .width(200)// 设置图片宽度
|
|
|
- .height(200)// 设置图片高度
|
|
|
- .objectFit(ImageFit.Contain)// 图片适应容器
|
|
|
- .clickEffect({
|
|
|
- // 点击效果配置
|
|
|
- scale: 0.5, // 缩放比例
|
|
|
- level: ClickEffectLevel.LIGHT // 效果级别
|
|
|
- })
|
|
|
- .onClick(() => { // 点击图片时触发的回调
|
|
|
- this.onclikMerit()
|
|
|
- })
|
|
|
-
|
|
|
- Row(){
|
|
|
|
|
|
- Image($r('app.media.muyu')).width(30)
|
|
|
- }.width('100%')
|
|
|
- .justifyContent(FlexAlign.End)
|
|
|
- }
|
|
|
- .width('100%')
|
|
|
- .backgroundColor(Color.Black) // 设置背景颜色为黑色
|
|
|
|
|
|
}.width('100%')
|
|
|
.height('100%')
|