Browse Source

feat: 初始化项目,对添加项目所需资源和修改对应的配置文件, 新增 mainview 页面

YuJing 2 weeks ago
parent
commit
457004442f
34 changed files with 349 additions and 160 deletions
  1. 1 1
      AppScope/resources/base/element/string.json
  2. BIN
      AppScope/resources/base/media/app_icon.png
  3. BIN
      AppScope/resources/base/media/background.png
  4. BIN
      AppScope/resources/base/media/foreground.png
  5. 1 1
      commons/basic/src/main/ets/components/generalComp/YTDiaLogComp.ets
  6. 2 1
      commons/basic/src/main/ets/utils/arkts/utils/YTRouter.ets
  7. 0 20
      features/feature/src/main/ets/pages/Index.ets
  8. 27 0
      features/feature/src/main/ets/pages/MsgDetailPage.ets
  9. 0 20
      features/feature/src/main/ets/pages/TestRouterPage.ets
  10. 91 85
      features/feature/src/main/ets/view/MainView.ets
  11. 38 0
      features/feature/src/main/ets/viewModel/MainViewModel.ets
  12. 0 1
      features/feature/src/main/module.json5
  13. BIN
      features/feature/src/main/resources/base/media/icon_tag.png
  14. 0 5
      features/feature/src/main/resources/base/profile/main_pages.json
  15. 0 5
      features/feature/src/main/resources/base/profile/router_map.json
  16. 1 0
      features/user/Index.ets
  17. 162 0
      features/user/src/main/ets/views/Mine_.ets
  18. BIN
      features/user/src/main/resources/base/media/icon_aboutMine.png
  19. BIN
      features/user/src/main/resources/base/media/icon_feedback.png
  20. BIN
      features/user/src/main/resources/base/media/icon_shar.png
  21. 26 21
      products/entry/src/main/ets/pages/Index.ets
  22. BIN
      products/entry/src/main/resources/base/media/background.png
  23. BIN
      products/entry/src/main/resources/base/media/foreground.png
  24. BIN
      products/entry/src/main/resources/base/media/icon_deed.png
  25. BIN
      products/entry/src/main/resources/base/media/icon_deed_.png
  26. BIN
      products/entry/src/main/resources/base/media/icon_drill.png
  27. BIN
      products/entry/src/main/resources/base/media/icon_drill_.png
  28. BIN
      products/entry/src/main/resources/base/media/icon_history.png
  29. BIN
      products/entry/src/main/resources/base/media/icon_history_.png
  30. BIN
      products/entry/src/main/resources/base/media/icon_mine.png
  31. BIN
      products/entry/src/main/resources/base/media/icon_mine_.png
  32. BIN
      products/entry/src/main/resources/base/media/icon_msg.png
  33. BIN
      products/entry/src/main/resources/base/media/icon_msg_.png
  34. BIN
      products/entry/src/main/resources/base/media/startIcon.png

+ 1 - 1
AppScope/resources/base/element/string.json

@@ -2,7 +2,7 @@
   "string": [
     {
       "name": "app_name",
-      "value": "YTSketch"
+      "value": "军迷之家"
     }
   ]
 }

BIN
AppScope/resources/base/media/app_icon.png


BIN
AppScope/resources/base/media/background.png


BIN
AppScope/resources/base/media/foreground.png


+ 1 - 1
commons/basic/src/main/ets/components/generalComp/YTDiaLogComp.ets

@@ -1,5 +1,5 @@
+import { yTRouter } from '../../../../../Index'
 import { YTDiaLogModel } from '../../models/YTDiaLogModel'
-import { yTRouter } from '../../utils/YTRouter'
 
 @ComponentV2
 export struct YTDiaLogComp {

+ 2 - 1
commons/basic/src/main/ets/utils/arkts/utils/YTRouter.ets

@@ -1,7 +1,8 @@
 import { IBestToast } from '@ibestservices/ibest-ui'
 
-import { DiaLogPageEnum, DiaLogParam, YTDiaLogModel } from '../models/YTDiaLogModel'
+
 import { DelPhotoParam } from '../../../models'
+import { DiaLogParam } from '../../../models/YTDiaLogModel'
 
 class YTRouter extends NavPathStack {
   private static declare instance: YTRouter

+ 0 - 20
features/feature/src/main/ets/pages/Index.ets

@@ -1,20 +0,0 @@
-@Entry
-@Component
-struct Index {
-  @State message: string = 'Hello World';
-
-  build() {
-    Row() {
-      Column() {
-        Text(this.message)
-          .fontSize($r('app.float.page_text_font_size'))
-          .fontWeight(FontWeight.Bold)
-          .onClick(() => {
-            this.message = 'Welcome';
-          })
-      }
-      .width('100%')
-    }
-    .height('100%')
-  }
-}

+ 27 - 0
features/feature/src/main/ets/pages/MsgDetailPage.ets

@@ -0,0 +1,27 @@
+import { YTAvoid } from 'basic'
+import { _YtHeader } from '../components/YtComp/_YtHeader'
+
+@ComponentV2
+struct MsgDetailPage {
+  @Local safeTop: number = AppStorage.get(YTAvoid.SAFE_TOP_KEY) as number
+
+  build() {
+    NavDestination() {
+      Column() {
+        // 注意考虑标题过长的问题
+        _YtHeader({
+          title: ''
+        })
+      }
+      .width("100%")
+      .height('100%')
+    }
+    .hideTitleBar(true)
+    .padding({ top: this.safeTop })
+  }
+}
+
+@Builder
+function MsgDetailPageBuilder() {
+  MsgDetailPage()
+}

+ 0 - 20
features/feature/src/main/ets/pages/TestRouterPage.ets

@@ -1,20 +0,0 @@
-import { RouterPage } from 'basic'
-
-@Component
-@RouterPage
-struct TestRouterPage {
-  build() {
-    NavDestination(){
-      Column(){
-        Text('你好路由')
-      }
-      .width('100%')
-      .height('100%')
-    }
-    .hideTitleBar(true)
-  }
-}
-@Builder
-function TestRouterBuilder() {
-  TestRouterPage()
-}

+ 91 - 85
features/feature/src/main/ets/view/MainView.ets

@@ -1,105 +1,111 @@
-import { UnitType } from 'basic/src/main/ets/datepicker/DatePickerEnums'
-import { promptAction } from '@kit.ArkUI'
-import { tkAdHelper } from 'basic/src/main/ets/ads/tkAd/utils/TkAdHelper'
-import { DateOption, TkBannerAdComp, YTAddressSelectorDialog, YTDateUtil, YtProgressComp, yTRouter } from 'basic'
+import { MainViewModel } from "../viewModel/MainViewModel";
 
-@Component
+@ComponentV2
 export struct MainView {
-  @State point: number = 40
+  vm: MainViewModel = new MainViewModel();
 
   build() {
-    Column() {
-      Text('打开日历')
-        .onClick(() => {
-          //以下内容都可以不传 有默认值
-          const date: Date = new Date()
-          const yTDateDialog = new YTAddressSelectorDialog(this.getUIContext())
-          let dateOption = new DateOption() //选项配置类
-          dateOption.date = date //当前日期  默认今天
-          dateOption.minDate = new Date(2000, 0, 1) //最小选择的日期 默认10年前的今天
-          dateOption.maxDate = new Date(2048, 12, 30) //最大选择的日期 默认10年后的今天
-          dateOption.unitType = UnitType.YEAR_MONTH_DAY //日期单位 默认年月日 可选年月、月日等组合
-          dateOption.confirm = (date: Date) => { //确认选择回调函数
-            console.log('确认', YTDateUtil.formatDate(date))
-            promptAction.openToast({ message: YTDateUtil.formatDate(date) })
-          }
-          dateOption.headerLeftBuilder = wrapBuilder(headerLeftBuilder) //头部左侧按钮 默认返回按钮
-          dateOption.headerRightBuilder = wrapBuilder(headerRightBuilder) //头部右侧按钮 默认确认按钮
-          dateOption.highlightBackgroundColor = Color.Pink //选中高亮背景色
-          dateOption.highlightBorderColor = Color.Red //选中高亮边框色
-          dateOption.textStyle = {
-            //日期文字样式
-            font: { size: 20, weight: 400 },
-            color: Color.Gray
-          }
-          dateOption.selectedTextStyle = {
-            //选中日期文字样式
-            font: { size: 25, weight: 400 },
-            color: Color.Yellow
-          }
-          yTDateDialog.show(dateOption) //设置好配置之后打开日历的函数
-        })
-      Button('跳转页面测试')
-        .onClick(() => {
-          yTRouter.pushPathByName('TestRouterPage', null)
-        })
-
-      Button('播放激励广告')
-        .onClick(() => {
-          tkAdHelper.showRewardAd()
-        })
-
+    Column(){
+      Row(){
+        Text('最新军事咨询')
+          .fontSize(18)
+          .fontWeight(500)
+          .fontSize(Color.Black)
+      }
+      .width("100%")
+      .padding({top: 25, bottom: 20})
+      .justifyContent(FlexAlign.Center)
 
-      Button('播放插屏广告')
-        .onClick(() => {
-          tkAdHelper.showInterstitialAd()
+      Row(){
+        ForEach(['全部', '国内', '国际'], (item: string, index: number) => {
+          Text(item)
+            .fontSize(16)
+            .padding({right: 30})
+            .textAlign(TextAlign.Start)
+            .onClick(() => { this.vm.changeSelectIndex(index) })
+            .fontColor(this.vm.selectIndex == index ? '#333333' : '#52886F')
+            .onAreaChange((_o, n) => { this.vm.setArea(n, index) })
         })
+      }
+      .width("100%")
+      .padding({ left: 16 })
+      .justifyContent(FlexAlign.Start)
 
-      TkBannerAdComp()
-
-      CalendarPicker()
+      Text()
+        .height(5)
+        .borderRadius(8)
+        .width(this.vm.lineWidth)
+        .backgroundColor(Color.Black)
+        .opacity(this.vm.selectIndex == -1 ? 0 : 1)
+        .position({ x: this.vm.lineX, y: this.vm.lineY })
 
-      YtProgressComp({
-        growPoint: this.point,
-        v1Point: {
-          point: 100,
-          position: 4
-        },
-        v2Point: {
-          point: 200,
-          position: 10,
-          topImage: $r('app.media.app_icon'),
+      Column(){
+        List({space: 16}){
+          Repeat(this.vm.dataSource)
+            .each((item) => {
+              ListItem(){
+                MsgItem()
+              }
+            })
         }
-      })
-      Row() {
-        Button('+10')
-          .onClick(() => {
-            this.point += 10
-          })
-        Button('-10')
-          .onClick(() => {
-            this.point -= 10
-          })
+        .width("100%")
+        .height("100%")
+        .scrollBar(BarState.Off)
       }
+      .width("100%")
+      .layoutWeight(1)
+      .padding({top: 19})
     }
     .width('100%')
     .height('100%')
-
+    .padding({ top: this.vm.safeTop, left: 16, right: 16 })
+    .linearGradient({ colors: [ ['#7FF9C3', 0], ['#EEECED', 0.3] ] })
   }
+}
 
-  // .attributeModifier(new BackgroundPageModifier(true))
+@ComponentV2
+struct MsgItem{
+  @Param title: string = '中国海军新型驱逐舰完成首次远海训练中国海军新型驱逐舰完成首次远海训练'
+  @Param description: string = '今日,中国海军某新型驱逐舰圆满完成首次远海实战化训练, 检验多项新型武器装备性能今日,中国海军某新型驱逐舰圆满完成首次远海实战化训练, 检验多项新型武器装备性能...'
+  @Param time: string = '2021-09-01'
 
+  build() {
+    Column({space: 8}){
+      Row({space: 5}){
+        Image($r('app.media.icon_tag'))
+          .width(18)
+          .aspectRatio(1)
 
-}
+        Text(this.title)
+          .maxLines(1)
+          .fontSize(16)
+          .fontWeight(500)
+          .layoutWeight(1)
+          .fontColor(Color.Black)
+          .textOverflow({overflow: TextOverflow.Ellipsis})
+      }
+      .width("100%")
 
-@Builder
-function headerLeftBuilder() {
-  Image($r('app.media.app_icon'))
-    .width(24)
-}
+      Row(){
+        Text(this.description)
+          .maxLines(2)
+          .fontSize(14)
+          .fontColor('#7D7D7D')
+          .textOverflow({overflow: TextOverflow.Ellipsis})
+      }
+      .width("100%")
 
-@Builder
-function headerRightBuilder() {
-  Image($r("app.media.app_icon"))
-    .width(24)
+      Row(){
+        Text(this.time)
+          .fontSize(12)
+          .fontColor('#333333')
+          .textAlign(TextAlign.End)
+      }
+      .width("100%")
+      .justifyContent(FlexAlign.End)
+    }
+    .borderRadius(12)
+    .backgroundColor(Color.White)
+    .padding({ top: 17, bottom: 10, left: 14, right: 14 })
+  }
 }

+ 38 - 0
features/feature/src/main/ets/viewModel/MainViewModel.ets

@@ -0,0 +1,38 @@
+import { YTAvoid, yTRouter } from "basic"
+
+@ObservedV2
+export class MainViewModel{
+  @Trace safeTop: number = 0
+
+  @Trace dataSource: Array<string> = new Array(10).fill('')
+
+  @Trace selectIndex: number = -1
+  @Trace areaList: Array<Area> = new Array(3)
+  @Trace lineWidth: Length = 20
+  @Trace lineX: number = 32
+  @Trace lineY: number = 102
+
+  constructor() {
+    this.safeTop = AppStorage.get(YTAvoid.SAFE_TOP_KEY) as number
+  }
+
+  // 更改选中的下标
+  changeSelectIndex(i: number) {
+    animateToImmediately({ duration: 200 }, () => {
+      this.selectIndex = i
+
+      this.lineX = this.areaList[i].globalPosition.x as number - 15
+      this.lineY = this.areaList[i].globalPosition.y as number - 17
+    })
+  }
+
+  // 设置区域值
+  setArea(a: Area, i: number) {
+    this.areaList[i] = a
+
+    if(this.selectIndex == -1 && i == 0) {
+      this.changeSelectIndex(i)
+      this.lineWidth = this.areaList[i].width as number - 30
+    }
+  }
+}

+ 0 - 1
features/feature/src/main/module.json5

@@ -8,6 +8,5 @@
       "phone"
     ],
     "deliveryWithInstall": true,
-    "pages": "$profile:main_pages"
   }
 }

BIN
features/feature/src/main/resources/base/media/icon_tag.png


+ 0 - 5
features/feature/src/main/resources/base/profile/main_pages.json

@@ -1,5 +0,0 @@
-{
-  "src": [
-    "pages/Index"
-  ]
-}

+ 0 - 5
features/feature/src/main/resources/base/profile/router_map.json

@@ -1,10 +1,5 @@
 {
   "routerMap": [
-    {
-      "name": "TestRouterPage",
-      "pageSourceFile": "src/main/ets/pages/TestRouterPage.ets",
-      "buildFunction": "TestRouterBuilder"
-    },
     {
       "name": "YTNaviDiaLog",
       "pageSourceFile": "src/main/ets/pages/otherPage/YTNaviDiaLog.ets",

+ 1 - 0
features/user/Index.ets

@@ -1,2 +1,3 @@
 export { Mine } from './src/main/ets/views/Mine'
+export { Mine_ } from './src/main/ets/views/Mine_'
 

+ 162 - 0
features/user/src/main/ets/views/Mine_.ets

@@ -0,0 +1,162 @@
+import { BasicType, IBestToast, userInfo, UserInfo, YTAvoid, YTHeader, YTLog, yTRouter } from 'basic'
+import { common, Want } from '@kit.AbilityKit'
+import { BusinessError } from '@kit.BasicServicesKit'
+import { BUNDLE_NAME } from 'BuildProfile'
+import { systemShare } from '@kit.ShareKit'
+import { uniformTypeDescriptor } from '@kit.ArkData'
+
+@ComponentV2
+export struct Mine_ {
+  @Local safeTop: number = 0
+
+  setArr: Array<BasicType> = [
+    {
+      text: '分享给好友',
+      message: '去分享',
+      click: () => {
+        this.shareData()
+      },
+      src: $r('app.media.right_arrow'),
+      acSrc: $r('app.media.icon_shar')
+    },
+    {
+      text: '给个好评',
+      click: () => {
+        const want: Want = {
+          uri: "store://appgallery.huawei.com/app/detail?id=" + BUNDLE_NAME
+        };
+        const context = this.getUIContext().getHostContext() as common.UIAbilityContext;
+        context.startAbility(want).then(() => {
+          //拉起成功
+          YTLog.info('跳转成功')
+        }).catch((err: BusinessError) => {
+          // 拉起失败
+          YTLog.error(err)
+          IBestToast.show('出现未知错误,请稍后再试')
+        });
+      },
+      src: $r('app.media.right_arrow'),
+      acSrc: $r('app.media.icon_shar')
+
+    },
+    {
+      text: '意见反馈',
+      click: () => {
+        yTRouter.router2SuggestionPage()
+      },
+      src: $r('app.media.right_arrow'),
+      acSrc: $r('app.media.icon_feedback')
+    },
+    {
+      text: '关于我们',
+      click: () => {
+        yTRouter.router2AboutUS()
+      },
+      src: $r('app.media.right_arrow'),
+      acSrc: $r('app.media.icon_aboutMine')
+    }
+  ]
+
+  aboutToAppear(): void {
+    this.safeTop = AppStorage.get(YTAvoid.SAFE_TOP_KEY) as number
+  }
+
+  build() {
+    NavDestination(){
+      Column({space: 30}) {
+        Column({space: 12}){
+          Image($r('app.media.app_icon'))
+            .width(100)
+            .aspectRatio(1)
+            .borderRadius(12)
+
+          Text($r('app.string.app_name'))
+            .fontSize(18)
+            .fontWeight(500)
+            .fontColor(Color.Black)
+        }
+        .padding({ bottom: 28, top: 16})
+
+        Column() {
+          List({space: 15}) {
+            ForEach(this.setArr, (item: BasicType, index) => {
+              ListItem() {
+                Row() {
+                  Row({space: 23}){
+                    Image(item.acSrc)
+                      .width(16)
+                      .height(index == 2 ? 20 : 16)
+
+                    Text(item.text)
+                      .fontColor('#FF1C1C1C')
+                      .fontSize(14)
+                  }
+                  if (!index) {
+                    Text('去分享')
+                      .fontColor('#801C1C1C')
+                      .fontSize(14)
+                      .fontWeight(400)
+                  } else {
+                    Image($r('app.media.right_arrow'))
+                      .width(24)
+                      .aspectRatio(1)
+                  }
+                }
+                .width('100%')
+                .backgroundColor(`#EEEEEE`)
+                .borderRadius(20)
+                .justifyContent(FlexAlign.SpaceBetween)
+                .padding({ top: 20, left: 16, right: 16, bottom: 20 })
+                .onClick(() => {
+                  item.click?.()
+                })
+              }
+            })
+          }
+          .width('100%')
+          .height('100%')
+        }
+        .backgroundColor(Color.White)
+        .width('100%')
+        .height(550)
+        .borderRadius({ topRight: 32 })
+        .id("bottomColumn")
+        .padding({ left: 24, right: 24 })
+      }
+      .width("100%")
+      .height('100%')
+      .alignItems(HorizontalAlign.Center)
+    }
+    .hideTitleBar(true)
+    .padding({top: this.safeTop})
+    .backgroundColor(Color.White)
+  }
+
+  async shareData() {
+    try {
+      // 构造ShareData,需配置一条有效数据信息
+      const data = new systemShare.SharedData({
+        // utd: uniformTypeDescriptor.UniformDataType.HYPERLINK,
+        utd: uniformTypeDescriptor.UniformDataType.TEXT,
+        title: '快理货',
+        content: 'http://appgallery.huawei.com/app/detail?id=6917586913198936201',
+        description: "http://appgallery.huawei.com/app/detail?id=6917586913198936201"
+      })
+      const controller = new systemShare.ShareController(data)
+      const context = this.getUIContext().getHostContext()! as common.UIAbilityContext;
+      // 进行分享面板显示
+      controller.show(context, {
+        previewMode: systemShare.SharePreviewMode.DEFAULT,
+        selectionMode: systemShare.SelectionMode.SINGLE,
+        // anchor: { windowOffset: { x: 0, y: 0 }, size: { width: this.breakWidth, height: 500 } }
+      })
+    } catch (error) {
+      IBestToast.show({ message: '当前设备不支持', duration: 500 })
+    }
+  }
+}
+
+// @Builder
+// export function MinePageBuilder() {
+//   MinePage()
+// }

BIN
features/user/src/main/resources/base/media/icon_aboutMine.png


BIN
features/user/src/main/resources/base/media/icon_feedback.png


BIN
features/user/src/main/resources/base/media/icon_shar.png


+ 26 - 21
products/entry/src/main/ets/pages/Index.ets

@@ -1,8 +1,8 @@
 import {
-  BasicType, ContextHelper, TkBannerAdComp, TkStartAdComp, YTAvoid, yTRouter
+  BasicType, ContextHelper, YTAvoid, yTRouter
 } from 'basic';
-import { Mine } from 'user/src/main/ets/views/Mine';
 import { MainView, SecondView, ThirdView } from 'feature';
+import { Mine_ } from 'user';
 
 @Entry
 @Component
@@ -12,32 +12,37 @@ struct Index {
   //tabs展示内容
   contentList: BasicType<undefined>[] = [
     {
-      text: '日历',
-      src: $r('app.media.app_icon'),
-      acSrc: $r('app.media.app_icon')
+      text: '军事咨询',
+      // 未选中
+      src: $r('app.media.icon_msg_'),
+      // 选中
+      acSrc: $r('app.media.icon_msg')
     },
     {
-      text: '黄历',
-      src: $r('app.media.app_icon'),
-      acSrc: $r('app.media.app_icon')
+      text: '战争历史',
+      src: $r('app.media.icon_history_'),
+      acSrc: $r('app.media.icon_history')
     },
     {
-      text: '卡片',
-      src: $r('app.media.app_icon'),
-      acSrc: $r('app.media.app_icon')
+      text: '模范事迹',
+      src: $r('app.media.icon_deed_'),
+      acSrc: $r('app.media.icon_deed')
+    },
+    {
+      text: '训练',
+      src: $r('app.media.icon_drill_'),
+      acSrc: $r('app.media.icon_drill')
     },
     {
       text: '我的',
-      src: $r('app.media.app_icon'),
-      acSrc: $r('app.media.app_icon')
+      src: $r('app.media.icon_mine_'),
+      acSrc: $r('app.media.icon_mine')
     }
   ]
   tabsController: TabsController = new TabsController()
 
   aboutToAppear(): void {
-    ContextHelper.init(this.getUIContext(), getContext())
-
-
+    ContextHelper.init(this.getUIContext(), getContext(), false)
   }
 
   build() {
@@ -56,7 +61,7 @@ struct Index {
                 } else if (index == 2) {
                   ThirdView()
                 } else {
-                  Mine()
+                  Mine_()
                 }
               }
             })
@@ -89,9 +94,9 @@ struct Index {
       .mode(NavigationMode.Stack)
       .hideToolBar(true)
 
-      TkStartAdComp() {
-        Text('占位组件')
-      }
+      // TkStartAdComp() {
+      //   Text('占位组件')
+      // }
 
 
     }
@@ -106,7 +111,7 @@ struct Index {
       Text(item.text)
         .fontSize($r('[basic].float.page_text_font_size_10'))
         .lineHeight(16)
-        .fontColor(this.currentIndex == item.index ? $r('[basic].color.main_ac_color_dark') :
+        .fontColor(this.currentIndex == item.index ? '#20BC68' :
         $r('[basic].color.main_na_color'))
     }
     .margin({ top: 5 })

BIN
products/entry/src/main/resources/base/media/background.png


BIN
products/entry/src/main/resources/base/media/foreground.png


BIN
products/entry/src/main/resources/base/media/icon_deed.png


BIN
products/entry/src/main/resources/base/media/icon_deed_.png


BIN
products/entry/src/main/resources/base/media/icon_drill.png


BIN
products/entry/src/main/resources/base/media/icon_drill_.png


BIN
products/entry/src/main/resources/base/media/icon_history.png


BIN
products/entry/src/main/resources/base/media/icon_history_.png


BIN
products/entry/src/main/resources/base/media/icon_mine.png


BIN
products/entry/src/main/resources/base/media/icon_mine_.png


BIN
products/entry/src/main/resources/base/media/icon_msg.png


BIN
products/entry/src/main/resources/base/media/icon_msg_.png


BIN
products/entry/src/main/resources/base/media/startIcon.png