|
|
@@ -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 })
|
|
|
+ }
|
|
|
}
|