reagencyPage.ets 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import { RouterPage } from 'basic';
  2. import { _YtHeader } from '../components/YtComp/_YtHeader';
  3. import { reagencyViewModel } from '../viewModel/PageVm/reagencyViewModel';
  4. import { reagencyComp } from '../components/reagencyComp';
  5. @ComponentV2
  6. @RouterPage
  7. struct reagencyPage {
  8. @Local vm: reagencyViewModel = new reagencyViewModel();
  9. build() {
  10. NavDestination() {
  11. Column() {
  12. _YtHeader({
  13. title: '反应力训练',
  14. rightComp: () => { this.rightComp() }
  15. })
  16. Column(){
  17. Row(){
  18. ForEach(['命中目标', '平均反应时间', '训练时长'], (item: string, index) => {
  19. Column({space: 6}){
  20. Text(){
  21. if(index == 0) {
  22. Span(`${this.vm.hitCount}个`)
  23. } else if (index == 1) {
  24. Span(`${this.vm.avgTime}${this.vm.avgTime < 1000 ? 'ms' : 's'}`)
  25. } else {
  26. Span(`${this.vm.trainTime}s`)
  27. }
  28. }
  29. .fontSize(25)
  30. .fontWeight(500)
  31. .fontColor('#FFFF7B00')
  32. Text(item)
  33. .fontSize(12)
  34. .fontWeight(400)
  35. .fontColor('#FF333333')
  36. }
  37. })
  38. }
  39. .width("100%")
  40. .padding({left: 21, right: 21})
  41. .justifyContent(FlexAlign.SpaceBetween)
  42. Column(){
  43. reagencyComp({
  44. trainStarted: this.vm.trainStarted,
  45. bubbleClick: (time: number) => { this.vm.bubbleClick(time) },
  46. })
  47. }
  48. .padding({top: 23})
  49. .width("100%")
  50. .layoutWeight(1)
  51. Row(){
  52. Text()
  53. Row(){
  54. Text(this.vm.trainStarted ? '暂停训练' : '开始训练')
  55. }
  56. .borderRadius(8)
  57. .padding({top: 16, left: 44, right: 44, bottom: 16})
  58. .linearGradient({colors: [['#FFFFCC00', 0], ['#FFFF9F02', 0.7]], angle: 90})
  59. .onClick(() => { this.vm.toggleTrain() })
  60. Image($r('app.media.icon_reset'))
  61. .width(33)
  62. .aspectRatio(1)
  63. .onClick(() => { this.vm.resetTrain() })
  64. }
  65. .width("100%")
  66. .justifyContent(FlexAlign.SpaceBetween)
  67. .padding({top: 18, bottom: 46, left: 37, right: 37})
  68. }
  69. .width("100%")
  70. .layoutWeight(1)
  71. .padding({top: 20})
  72. .padding({left: 16, right: 16, top: 25})
  73. .borderRadius({topLeft: 23, topRight: 23})
  74. .backgroundColor('rgba(255, 255, 255, 0.3)')
  75. }
  76. .width('100%')
  77. .height('100%')
  78. .justifyContent(FlexAlign.Start)
  79. .alignItems(HorizontalAlign.Start)
  80. }
  81. .hideTitleBar(true)
  82. .padding({ top: this.vm.safeTop, bottom: this.vm.safeBottom })
  83. .linearGradient({ colors: [['#FF7FF9C3', 0], ['#FFEEECED', 0.3]]})
  84. }
  85. @Builder
  86. rightComp(){
  87. Image($r('app.media.icon_setting'))
  88. .width(24)
  89. .aspectRatio(1)
  90. .onClick(() => { this.vm.openSetting() })
  91. }
  92. }
  93. @Builder
  94. function reagencyBuilder() {
  95. reagencyPage()
  96. }