|
|
@@ -0,0 +1,158 @@
|
|
|
+import { BasicType, YTAvoid, YTRequest, yTRouter } from "basic"
|
|
|
+
|
|
|
+@ComponentV2
|
|
|
+export struct FourView {
|
|
|
+ @Local safeTop: number = AppStorage.get(YTAvoid.SAFE_TOP_KEY) as number
|
|
|
+
|
|
|
+ private layoutOptions: GridLayoutOptions = {
|
|
|
+ regularSize: [1, 1],
|
|
|
+ irregularIndexes: [4],
|
|
|
+ onGetIrregularSizeByIndex: (index: number) => {
|
|
|
+ return [1, 2]
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private forEach: Array<BasicType> = [
|
|
|
+ {
|
|
|
+ // reagency
|
|
|
+ text: '反应力训练',
|
|
|
+ src: $r('app.media.icon_reagency'),
|
|
|
+ acSrc: $r('app.media.img_reagency')
|
|
|
+ }, {
|
|
|
+ // stability
|
|
|
+ text: '稳定性训练',
|
|
|
+ src: $r('app.media.icon_stability'),
|
|
|
+ acSrc: $r('app.media.img_stability')
|
|
|
+ }, {
|
|
|
+ // observational
|
|
|
+ text: '观察记忆力训练',
|
|
|
+ src: $r('app.media.icon_observational'),
|
|
|
+ acSrc: $r('app.media.img_observational')
|
|
|
+ }, {
|
|
|
+ // vision
|
|
|
+ text: '视力检测',
|
|
|
+ src: $r('app.media.icon_vision'),
|
|
|
+ acSrc: $r('app.media.img_vision')
|
|
|
+ }, {
|
|
|
+ // chess
|
|
|
+ text: '军棋学习',
|
|
|
+ src: $r('app.media.icon_chess'),
|
|
|
+ acSrc: $r('app.media.img_chess')
|
|
|
+ }
|
|
|
+ ]
|
|
|
+
|
|
|
+ onRouter(index: number){
|
|
|
+ switch (index){
|
|
|
+ case 0:
|
|
|
+ yTRouter.pushPathByName('reagencyPage', null)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ build() {
|
|
|
+ Column() {
|
|
|
+ Row(){
|
|
|
+ Text('娱乐训练')
|
|
|
+ .fontSize(18)
|
|
|
+ .fontWeight(500)
|
|
|
+ .fontColor('#FF333333')
|
|
|
+ }
|
|
|
+ .width("100%")
|
|
|
+ .padding({top: 20, bottom: 9})
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+
|
|
|
+ Grid(undefined, this.layoutOptions) {
|
|
|
+ Repeat(this.forEach)
|
|
|
+ .each((item) => {
|
|
|
+ GridItem(){
|
|
|
+ if(item.index < 4) {
|
|
|
+ Column(){
|
|
|
+ Row(){
|
|
|
+ Image(item.item.src)
|
|
|
+ .width(77)
|
|
|
+ .aspectRatio(1)
|
|
|
+ .offset({y: -17})
|
|
|
+ }
|
|
|
+ .width("100%")
|
|
|
+ .padding({left: 8})
|
|
|
+ .justifyContent(FlexAlign.Start)
|
|
|
+
|
|
|
+ Column(){
|
|
|
+ Text(item.item.text)
|
|
|
+ .fontSize(20)
|
|
|
+ .fontWeight(500)
|
|
|
+ .padding({left: 14})
|
|
|
+ .fontColor('#FF333333')
|
|
|
+
|
|
|
+ Image($r('app.media.icon_entry'))
|
|
|
+ .width(30)
|
|
|
+ .aspectRatio(1)
|
|
|
+ .margin({left: 17})
|
|
|
+ }
|
|
|
+ .width("100%")
|
|
|
+ .layoutWeight(1)
|
|
|
+ .padding({bottom: 10})
|
|
|
+ .alignItems(HorizontalAlign.Start)
|
|
|
+ .justifyContent(FlexAlign.SpaceBetween)
|
|
|
+ }
|
|
|
+ .width("100%")
|
|
|
+ .aspectRatio(165/180)
|
|
|
+ .backgroundImage(item.item.acSrc)
|
|
|
+ .alignItems(HorizontalAlign.Start)
|
|
|
+ .backgroundImageSize({width: '100%', height: '100%'})
|
|
|
+ .onClick(() => { this.onRouter(item.index) })
|
|
|
+ } else {
|
|
|
+ RelativeContainer(){
|
|
|
+ Row(){
|
|
|
+ Text(item.item.text)
|
|
|
+ .fontSize(20)
|
|
|
+ .fontWeight(500)
|
|
|
+ .padding({left: 14})
|
|
|
+ .fontColor('#FF333333')
|
|
|
+ }
|
|
|
+ .padding({top: 20})
|
|
|
+ .alignRules({
|
|
|
+ center: { anchor: '__container__', align: VerticalAlign.Center },
|
|
|
+ left: { anchor: '__container__', align: HorizontalAlign.Start },
|
|
|
+ })
|
|
|
+
|
|
|
+ Image(item.item.src)
|
|
|
+ .width(77)
|
|
|
+ .aspectRatio(1)
|
|
|
+ .alignRules({
|
|
|
+ center: { anchor: '__container__', align: VerticalAlign.Center },
|
|
|
+ right: { anchor: '__container__', align: HorizontalAlign.End },
|
|
|
+ })
|
|
|
+
|
|
|
+ Image($r('app.media.icon_entry'))
|
|
|
+ .width(30)
|
|
|
+ .aspectRatio(1)
|
|
|
+ .alignRules({
|
|
|
+ bottom: { anchor: '__container__', align: VerticalAlign.Bottom },
|
|
|
+ left: { anchor: '__container__', align: HorizontalAlign.Start },
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ .width("100%")
|
|
|
+ .aspectRatio(343/135)
|
|
|
+ .backgroundImage(item.item.acSrc)
|
|
|
+ .padding({left: 15, right: 33, bottom: 11})
|
|
|
+ .backgroundImageSize({width: '100%', height: '100%'})
|
|
|
+ .onClick(() => { this.onRouter(item.index) })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .rowsGap(20)
|
|
|
+ .width('100%')
|
|
|
+ .columnsGap(13)
|
|
|
+ .padding({top: 25})
|
|
|
+ .columnsTemplate('repeat(2, 1fr)')
|
|
|
+ }
|
|
|
+ .width("100%")
|
|
|
+ .height("100%")
|
|
|
+ .backgroundImage($r('app.media.img_fourViewBg'))
|
|
|
+ .padding({ top: this.safeTop, left: 16, right: 16 })
|
|
|
+ .backgroundImageSize({width: '100%', height: '100%'})
|
|
|
+ }
|
|
|
+}
|