diff --git a/entry/src/main/ets/animation/CustomCutToAnimator.ets b/entry/src/main/ets/animation/CustomCutToAnimator.ets index f8a849e48d9a6e12c045239cd1acdb79157e6a1d..c10da503a2c9dacca422968ecc0d5299a7bc5ef4 100644 --- a/entry/src/main/ets/animation/CustomCutToAnimator.ets +++ b/entry/src/main/ets/animation/CustomCutToAnimator.ets @@ -17,11 +17,15 @@ * 最佳实践:特定页面设置自定义转场 */ -import { HMAnimator, HMAnimatorHandle, +import { + HMAnimator, + HMAnimatorHandle, HMRouterMgr, - IHMAnimator, OpacityOption, + IHMAnimator, + OpacityOption, ScaleOption, - TranslateOption } from "@hadss/hmrouter"; + TranslateOption +} from "@hadss/hmrouter"; // [Start custom_cut_to_animator] @@ -61,6 +65,7 @@ export class CustomAnimator implements IHMAnimator { enterHandle.curve = Curve.Linear; } } + // [End custom_cut_to_animator] export class CustomAnimatorTransfer { diff --git a/entry/src/main/ets/animation/CustomDifferentTransition.ets b/entry/src/main/ets/animation/CustomDifferentTransition.ets index 3e67247da7eaa39801955408a3c70f14fb044105..fd091e9e5f09610a954dd05032ac5a5d2d88fa29 100644 --- a/entry/src/main/ets/animation/CustomDifferentTransition.ets +++ b/entry/src/main/ets/animation/CustomDifferentTransition.ets @@ -17,11 +17,15 @@ * 最佳实践:根据条件呈现不同转场动效 */ -import { HMAnimator, HMAnimatorHandle, +import { + HMAnimator, + HMAnimatorHandle, HMRouterMgr, IHMAnimator, OpacityOption, - ScaleOption, TranslateOption } from "@hadss/hmrouter"; + ScaleOption, + TranslateOption +} from "@hadss/hmrouter"; // [Start my_animator1] @HMAnimator({ animatorName: 'myAnimator1' }) @@ -45,6 +49,7 @@ export class MyAnimator1 implements IHMAnimator { }) } } + // [End my_animator1] // [Start my_animator2] @@ -72,6 +77,7 @@ export class MyAnimator2 implements IHMAnimator { exitHandle.duration = 500; } } + // [End my_animator2] // [Start comment_input_amimator] @@ -81,6 +87,7 @@ export struct CommentInput { @State isLandscape: boolean = true; @State videoWidth: string = '' @State videoHeight: string = '' + // [EndExclude comment_input_amimator] build() { @@ -123,4 +130,5 @@ export struct CommentInput { } } } + // [End comment_input_amimator] \ No newline at end of file diff --git a/entry/src/main/ets/component/home/HomeContent.ets b/entry/src/main/ets/component/home/HomeContent.ets index ff0afd75f84e4eea1dfb831a0ea53a58f1059822..5b0dcb2e0be24bc2b9e889f10490d494afc8950e 100644 --- a/entry/src/main/ets/component/home/HomeContent.ets +++ b/entry/src/main/ets/component/home/HomeContent.ets @@ -31,7 +31,7 @@ import { PageConstant } from '../../constant/PageConstant'; @Builder function flashSaleCard() { Column() { - Flex({justifyContent: FlexAlign.SpaceBetween}) { + Flex({ justifyContent: FlexAlign.SpaceBetween }) { Text('限时秒杀') .fontSize(16); Text() { @@ -43,13 +43,13 @@ function flashSaleCard() { } .align(Alignment.Center); } - .padding({left: 16}); + .padding({ left: 16 }); Row() { Image($r('app.media.flash_sale_product_1')) .width(134) .height(134) - .margin({right: 7.5}); + .margin({ right: 7.5 }); Column() { Text('HUAWEI MATE 50') .fontSize(14) @@ -70,7 +70,7 @@ function flashSaleCard() { radius: 4 }) .lineHeight(14) - .padding({left: 4, right: 4}); + .padding({ left: 4, right: 4 }); Text('赚积分') .fontSize(9) .fontColor('rgba(207, 10, 44, 0.4)') @@ -80,10 +80,10 @@ function flashSaleCard() { color: 'rgba(207, 10, 44, 0.4)', radius: 4 }) - .margin({left: 4}) + .margin({ left: 4 }) .lineHeight(14) - .padding({left: 4, right: 4}); - }.margin({top: 8}); + .padding({ left: 4, right: 4 }); + }.margin({ top: 8 }); Row() { Text('¥ 4999') @@ -94,28 +94,28 @@ function flashSaleCard() { Text('¥5488') .fontSize(10) .fontColor('rgba(0,0,0,0.4)') - .margin({left: 4}) + .margin({ left: 4 }) .lineHeight(14) .decoration({ style: TextDecorationStyle.SOLID, type: TextDecorationType.LineThrough, color: 'rgba(0,0,0,0.4)' }); - }.margin({top: 4}) + }.margin({ top: 4 }) .alignItems(VerticalAlign.Bottom); } .alignItems(HorizontalAlign.Start); } - .margin({top: 13}); + .margin({ top: 13 }); }.backgroundColor($r('app.color.home_content_card_background_color')) .borderRadius(16) - .padding({top: 16, right: 16, bottom: 16}); + .padding({ top: 16, right: 16, bottom: 16 }); } @Builder function recommendCard() { Column() { - Flex({justifyContent: FlexAlign.SpaceBetween}) { + Flex({ justifyContent: FlexAlign.SpaceBetween }) { Text('甄选推荐') .fontSize(16); Text() { @@ -127,14 +127,14 @@ function recommendCard() { } .align(Alignment.Center); } - .padding({left: 16}); + .padding({ left: 16 }); Row() { Column() { Image($r('app.media.section_product_1')) .width(134) .height(134) - .margin({right: 7.5}); + .margin({ right: 7.5 }); Column() { Text('MateBook X Pro 12') .fontSize(12) @@ -154,18 +154,18 @@ function recommendCard() { radius: 4 }) .lineHeight(14) - .padding({left: 4, right: 4}) - .margin({top: 4}); + .padding({ left: 4, right: 4 }) + .margin({ top: 4 }); Text('¥ 10999') .fontColor('rgb(207, 10, 44)') .fontWeight(500) .fontSize(14) .lineHeight(19) - .margin({top: 6}); + .margin({ top: 6 }); Text('2571评论 95%好评') .fontSize(10) .fontColor('rgba(0,0,0,0.4)') - .margin({left: 4}) + .margin({ left: 4 }) .lineHeight(14); } .alignItems(HorizontalAlign.Center); @@ -175,7 +175,7 @@ function recommendCard() { Image($r('app.media.section_product_2')) .width(134) .height(134) - .margin({right: 7.5}); + .margin({ right: 7.5 }); Column() { Text('HUAWEI Mate 50') .fontSize(12) @@ -195,31 +195,31 @@ function recommendCard() { radius: 4 }) .lineHeight(14) - .padding({left: 4, right: 4}) - .margin({top: 4}); + .padding({ left: 4, right: 4 }) + .margin({ top: 4 }); Text('¥ 10999') .fontColor('rgb(207, 10, 44)') .fontWeight(500) .fontSize(14) .lineHeight(19) - .margin({top: 6}); + .margin({ top: 6 }); Text('2571评论 95%好评') .fontSize(10) .fontColor('rgba(0,0,0,0.4)') - .margin({left: 4}) + .margin({ left: 4 }) .lineHeight(14); } .alignItems(HorizontalAlign.Center); }; } - .margin({top: 13}); + .margin({ top: 13 }); }.backgroundColor($r('app.color.home_content_card_background_color')) .borderRadius(16) - .padding({top: 16, right: 16, bottom: 16}); + .padding({ top: 16, right: 16, bottom: 16 }); } // [Start HMRouter_home_content] -@HMRouter({pageUrl: 'HomeContent', singleton: true, lifecycle: 'ExitAppLifecycle'}) +@HMRouter({ pageUrl: 'HomeContent', singleton: true, lifecycle: 'ExitAppLifecycle' }) @Component export struct HomeContent { // [StartExclude HMRouter_home_content] @@ -294,6 +294,8 @@ export struct HomeContent { .width(CommonConstants.FULL_PERCENT) .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]); } + // [EndExclude HMRouter_home_content] } + // [End HMRouter_home_content] diff --git a/entry/src/main/ets/component/live/CommentInput.ets b/entry/src/main/ets/component/live/CommentInput.ets index ebb8405a0ac8fc1141d59c2c6d649c517a8393a8..711bb1f797866ab938bd7d922698b81c59ec9f4f 100644 --- a/entry/src/main/ets/component/live/CommentInput.ets +++ b/entry/src/main/ets/component/live/CommentInput.ets @@ -30,7 +30,7 @@ import { CommonConstants } from '../common/constants/CommonConstants'; import { LiveCommentsModel, LiveCommentsProduct } from '../viewmodel/LiveCommentsModel'; import { LiveCommentFooter } from './LiveCommentFooter'; -@HMAnimator({animatorName: 'liveCommentsAnimator'}) +@HMAnimator({ animatorName: 'liveCommentsAnimator' }) export class LiveCommentsAnimator implements IHMAnimator { effect(enterHandle: HMAnimatorHandle, exitHandle: HMAnimatorHandle): void { // entry animation @@ -62,6 +62,7 @@ export class LiveCommentsAnimator implements IHMAnimator { export struct CommentInput { @StorageLink('changeVideoHeight') videoHeight: string | number = CommonConstants.FULL_PERCENT; commentRenderNode: CommentNodeController = new CommentNodeController(); + // [StartExclude comment_render_node] aboutToAppear(): void { console.log('make node'); @@ -80,18 +81,18 @@ export struct CommentInput { .borderRadius('50%') .layoutWeight(1) .backgroundColor($r('app.color.comment_background_color')) - .padding({left: 15, top: 11, bottom: 11}) - .margin({right: 16}); + .padding({ left: 15, top: 11, bottom: 11 }) + .margin({ right: 16 }); Image($r('app.media.icon_share')) .width(24) .height(24) - .margin({right: 16}); + .margin({ right: 16 }); Image($r('app.media.icon_comments')) .width(24) .height(24) - .margin({right: 16}) + .margin({ right: 16 }) .onClick(() => { HMRouterMgr.push({ navigationId: this.queryNavigationInfo()?.navigationId, @@ -115,12 +116,12 @@ export struct CommentInput { Image($r('app.media.icon_like')) .width(24) .height(24) - .margin({right: 16}); + .margin({ right: 16 }); Image($r('app.media.icon_cart')) .width(45) .height(45) - .margin({right: 16}); + .margin({ right: 16 }); } .backgroundColor($r('app.color.comment_input_background_color')) @@ -133,8 +134,10 @@ export struct CommentInput { .margin({ top: 10 }); + // [EndExclude comment_render_node] } + // [End comment_render_node] } @@ -143,25 +146,25 @@ export struct CommentInput { function buildComment(liveComments: LiveCommentsProduct[]) { // [StartExclude comment_node_controller] Column() { - List({space: 16}) { + List({ space: 16 }) { ForEach(liveComments, (item: LiveCommentsProduct) => { ListItem() { Row() { Image(item.getAvatar()) .width(50) - .margin({left: 10}); + .margin({ left: 10 }); Column() { Text(item.getUserName()) .fontColor($r('app.color.comment_input_text_font_color_2')); Text(item.getCommentContent()); }.alignItems(HorizontalAlign.Start) .layoutWeight(1) - .margin({left: 10}); + .margin({ left: 10 }); Column() { Image(item.getLikeIcon()) .width(10) - .margin({bottom: 5}); + .margin({ bottom: 5 }); Text(`${item.getLikeNum()}`) .fontColor($r('app.color.comment_input_text_font_color_2')); }.justifyContent(FlexAlign.Center).alignItems(HorizontalAlign.Center) @@ -173,18 +176,20 @@ function buildComment(liveComments: LiveCommentsProduct[]) { LiveCommentFooter(); }.height('100%'); + // [EndExclude comment_node_controller] } export class CommentNodeController extends NodeController { commentList: BuilderNode<[LiveCommentsProduct[]]> | null = null; commentListData: LiveCommentsProduct[] = new LiveCommentsModel().getLiveCommentsList(); + constructor() { super(); } makeNode(context: UIContext): FrameNode | null { - if(this.commentList === null) { + if (this.commentList === null) { this.nodeBuild(context); } return this.commentList!.getFrameNode(); @@ -192,15 +197,16 @@ export class CommentNodeController extends NodeController { nodeBuild(context: UIContext) { this.commentList = new BuilderNode(context); - if(this.commentList !== null) { + if (this.commentList !== null) { this.commentList.build(wrapBuilder<[LiveCommentsProduct[]]>(buildComment), this.commentListData); } } dispose() { - if(this.commentList !== null) { + if (this.commentList !== null) { this.commentList.dispose(); } } } + // [End comment_node_controller] \ No newline at end of file diff --git a/entry/src/main/ets/component/live/DialogAnimator.ets b/entry/src/main/ets/component/live/DialogAnimator.ets index a7e863b68891990e42cfe50c59a3aa7715d79b15..ee6097cff2b7d17bb17efdd00e85bd0025cf5cd8 100644 --- a/entry/src/main/ets/component/live/DialogAnimator.ets +++ b/entry/src/main/ets/component/live/DialogAnimator.ets @@ -26,10 +26,11 @@ const globalPageTransitionEffect: IHMAnimator.Effect = new IHMAnimator.Effect({ opacity: { opacity: 0.5 }, scale: { x: 0.5, y: 0.2 } }) + // [End global_dialog] @Component -export struct DialogAnimator { +export struct DialogAnimator { @State message: string = 'Hello World'; build() { diff --git a/entry/src/main/ets/component/live/LiveHome.ets b/entry/src/main/ets/component/live/LiveHome.ets index 23329efb0fcc7b4ce73cefe901110e96961eab59..03cd3ecfd22ff03f3472ad765e7d5063d567d1f4 100644 --- a/entry/src/main/ets/component/live/LiveHome.ets +++ b/entry/src/main/ets/component/live/LiveHome.ets @@ -43,13 +43,14 @@ const uiContext: UIContext | undefined = AppStorage.get('uiContext'); @Observed export class VideoSrc { src: string | Resource; + constructor(src: string | Resource) { this.src = src; } } // [Start live_home_life_cycle] -@HMLifecycle({lifecycleName: 'liveHomeLifecycle'}) +@HMLifecycle({ lifecycleName: 'liveHomeLifecycle' }) export class LiveHomeLifecycle implements IHMLifecycle { commentRenderNode: CommentNodeController = new CommentNodeController(); // [StartExclude live_home_life_cycle] @@ -57,7 +58,7 @@ export class LiveHomeLifecycle implements IHMLifecycle { onShown(ctx: HMLifecycleContext): void { window.getLastWindow(uiContext!.getHostContext(), (err, data) => { - if(err.code > 0) { + if (err.code > 0) { console.error(`${err.code} ${err.message}`); return; } @@ -69,7 +70,7 @@ export class LiveHomeLifecycle implements IHMLifecycle { onHidden(ctx: HMLifecycleContext): void { window.getLastWindow(uiContext!.getHostContext(), (err, data) => { - if(err.code > 0) { + if (err.code > 0) { console.error(`${err.code} ${err.message}`); return; } @@ -78,6 +79,7 @@ export class LiveHomeLifecycle implements IHMLifecycle { }); }); } + // [EndExclude live_home_life_cycle] onAppear(ctx: HMLifecycleContext): void { this.commentRenderNode.makeNode(ctx.uiContext); @@ -87,10 +89,11 @@ export class LiveHomeLifecycle implements IHMLifecycle { this.commentRenderNode.dispose(); } } + // [End live_home_life_cycle] // [Start live_inter_active] -@HMAnimator({animatorName: 'liveInteractiveAnimator'}) +@HMAnimator({ animatorName: 'liveInteractiveAnimator' }) export class LiveInteractiveAnimator implements IHMAnimator { effect(enterHandle: HMAnimatorHandle, exitHandle: HMAnimatorHandle): void { // [StartExclude live_inter_active] @@ -130,19 +133,19 @@ export class LiveInteractiveAnimator implements IHMAnimator { interactive(handle: HMAnimatorHandle): void { handle.actionStart((event: GestureEvent) => { - if(event.offsetX > 0) { + if (event.offsetX > 0) { HMRouterMgr.pop(); } }); handle.updateProgress((event, proxy, operation, startOffset) => { - if(!proxy?.updateTransition || !startOffset) { + if (!proxy?.updateTransition || !startOffset) { return; } let offset = 0; - if(event.fingerList[0]) { + if (event.fingerList[0]) { offset = event.fingerList[0].localX - startOffset; } - if(offset < 0) { + if (offset < 0) { proxy?.updateTransition(0); return; } @@ -151,15 +154,15 @@ export class LiveInteractiveAnimator implements IHMAnimator { proxy?.updateTransition(rate); }); handle.actionEnd((event, proxy, operation, startOffset) => { - if(!startOffset) { + if (!startOffset) { return; } let rectWidth = event.target.area.width as number; let rate = 0; - if(event.fingerList[0]) { + if (event.fingerList[0]) { rate = (event.fingerList[0].localX - startOffset) / rectWidth; } - if(rate > 0.4) { + if (rate > 0.4) { proxy?.finishTransition(); } else { proxy?.cancelTransition?.(); @@ -167,6 +170,7 @@ export class LiveInteractiveAnimator implements IHMAnimator { }); } } + // [End live_inter_active] // [Start HMRouter_singleton] @@ -203,6 +207,8 @@ export struct LiveHome { .height('100%') .width('100%'); } + // [EndExclude HMRouter_singleton] } + // [End HMRouter_singleton] \ No newline at end of file diff --git a/entry/src/main/ets/component/mine/AnimatorTransition.ets b/entry/src/main/ets/component/mine/AnimatorTransition.ets index 5972dd3a7132e05c0779a20ac2498e2597390f5d..a0bd5c9746b746fe67ac7a2f2196c4f654dbade9 100644 --- a/entry/src/main/ets/component/mine/AnimatorTransition.ets +++ b/entry/src/main/ets/component/mine/AnimatorTransition.ets @@ -60,13 +60,13 @@ export struct AnimatorTransition { this.nvId = this.queryNavigationInfo()?.navigationId!; TemplateService.aboutToAppear(this.nvId, 'animatorTransition', false, this.translateOption, this.scaleOption, this.opacityOption); - if(AppStorage.get('isSelectWithSystem') !== undefined) { + if (AppStorage.get('isSelectWithSystem') !== undefined) { this.isSelectWithSystem = AppStorage.get('isSelectWithSystem') as boolean; } - if(AppStorage.get('isSelectCustomAnimation') !== undefined) { + if (AppStorage.get('isSelectCustomAnimation') !== undefined) { this.isSelectCustomAnimation = AppStorage.get('isSelectCustomAnimation') as boolean; } - if(AppStorage.get('selectIndex') !== undefined) { + if (AppStorage.get('selectIndex') !== undefined) { this.selectIndex = AppStorage.get('selectIndex') as number; } } @@ -81,25 +81,25 @@ export struct AnimatorTransition { Column() { Text(MineConstants.MINE_ANIMATION_CONTENT) .maxLines(2) - .textOverflow({overflow:TextOverflow.Ellipsis}) + .textOverflow({ overflow: TextOverflow.Ellipsis }) .fontColor($r('app.color.animator_text_font_color')) .margin(10); - Flex({direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center}) { + Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Text(MineConstants.MINE_ANIMATION_TYPE2) .fontWeight(FontWeight.Bold); - Toggle({type: ToggleType.Switch, isOn: this.isSelectWithSystem}) + Toggle({ type: ToggleType.Switch, isOn: this.isSelectWithSystem }) .width(36) .height(20) .selectedColor($r('app.color.animator_select_color')) .switchPointColor($r('app.color.animator_switch_point_color')) .onClick(() => { this.setIsSelectWithSystem(!this.isSelectWithSystem); - if(this.isSelectWithSystem && this.isSelectCustomAnimation) { + if (this.isSelectWithSystem && this.isSelectCustomAnimation) { this.setIsSelectCustomAnimation(false); } - if(this.isSelectWithSystem) { + if (this.isSelectWithSystem) { this.system = MineConstants.MINE_ANIMATION_TYPE2; - } else if(this.isSelectCustomAnimation) { + } else if (this.isSelectCustomAnimation) { this.system = MineConstants.MINE_ANIMATION_TYPE3; } else { this.system = MineConstants.MINE_ANIMATION_TYPE1; @@ -116,22 +116,22 @@ export struct AnimatorTransition { .backgroundColor($r('app.color.animator_flex_background_color')) .borderRadius(15); - Flex({direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center}) { + Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Text(MineConstants.MINE_ANIMATION_TYPE3) .fontWeight(FontWeight.Bold); - Toggle({type: ToggleType.Switch, isOn: this.isSelectCustomAnimation}) + Toggle({ type: ToggleType.Switch, isOn: this.isSelectCustomAnimation }) .width(36) .height(20) .selectedColor($r('app.color.animator_select_color')) .switchPointColor($r('app.color.animator_switch_point_color')) .onClick(() => { this.setIsSelectCustomAnimation(!this.isSelectCustomAnimation); - if(this.isSelectCustomAnimation && this.isSelectWithSystem) { + if (this.isSelectCustomAnimation && this.isSelectWithSystem) { this.setIsSelectWithSystem(false); } - if(this.isSelectWithSystem) { + if (this.isSelectWithSystem) { this.system = MineConstants.MINE_ANIMATION_TYPE2; - } else if(this.isSelectCustomAnimation) { + } else if (this.isSelectCustomAnimation) { this.system = MineConstants.MINE_ANIMATION_TYPE3; } else { this.system = MineConstants.MINE_ANIMATION_TYPE1; @@ -141,7 +141,7 @@ export struct AnimatorTransition { } .width('95%') .height(60) - .margin({left: 10, right: 10}) + .margin({ left: 10, right: 10 }) .padding(10) .backgroundColor($r('app.color.animator_flex_background_color')) .borderRadius(15); @@ -151,7 +151,7 @@ export struct AnimatorTransition { .fontColor($r('app.color.animator_text_font_color')) .margin(15); - Flex({direction: FlexDirection.Row, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Start}) { + Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Start }) { Row() { ForEach(this.arr, (item: SelectAnimatorItem, index: number) => { Flex({ @@ -166,30 +166,30 @@ export struct AnimatorTransition { .backgroundColor($r('app.color.animator_row_background_color')) .borderRadius(10) .border(this.selectIndex === index ? { width: 1, color: $r('app.color.animator_select_color') } : - {width: 0, color: Color.Transparent}) + { width: 0, color: Color.Transparent }) .width(60) .height(60); Text(item.getDirectionText()) - .margin({top: 10}) + .margin({ top: 10 }) .fontColor(this.selectIndex === index ? $r('app.color.animator_select_color') : $r('app.color.animator_text_not_select_color')) } .onClick(() => { this.selectIndex = index; AppStorage.setOrCreate('selectIndex', this.selectIndex); - if(this.selectIndex === 0) { + if (this.selectIndex === 0) { let effect: IHMAnimator.Effect = new IHMAnimator.Effect({ direction: IHMAnimator.Direction.LEFT_TO_RIGHT, - opacity: {opacity: 0.5} + opacity: { opacity: 0.5 } }); HMRouterMgr.registerGlobalAnimator('mainNavigationId', 'standard', effect.toAnimator()); HMRouterMgr.registerGlobalAnimator('mainNavigationId', 'dialog', effect.toAnimator()); - } else if(this.selectIndex === 1) { + } else if (this.selectIndex === 1) { let effect: IHMAnimator.Effect = HMDefaultGlobalAnimator.STANDARD_ANIMATOR; HMRouterMgr.registerGlobalAnimator('mainNavigationId', 'standard', effect.toAnimator()); HMRouterMgr.registerGlobalAnimator('mainNavigationId', 'dialog', effect.toAnimator()); - } else if(this.selectIndex === 2) { + } else if (this.selectIndex === 2) { // [Start hm_animator] let effect: IHMAnimator.Effect = new IHMAnimator.Effect({ scale: { @@ -198,18 +198,18 @@ export struct AnimatorTransition { x: 0.5, y: 0.5 }, - opacity: {opacity: 0.3} + opacity: { opacity: 0.3 } }); // [End hm_animator] HMRouterMgr.registerGlobalAnimator('mainNavigationId', 'standard', effect.toAnimator()); HMRouterMgr.registerGlobalAnimator('mainNavigationId', 'dialog', effect.toAnimator()); } }) - .margin({right: 10}); + .margin({ right: 10 }); }, (item: SelectAnimatorItem, index: number) => JSON.stringify(item) + index); }; } - .margin({left: 10}) + .margin({ left: 10 }) .height('15%'); }.visibility(this.isSelectCustomAnimation ? Visibility.Visible : Visibility.Hidden); } diff --git a/entry/src/main/ets/component/pay/PayCancel.ets b/entry/src/main/ets/component/pay/PayCancel.ets index a7eee3ba04fe647ee79bada868229fff276c06d0..5f647a29873fda45d26f05b880780a3c076b3033 100644 --- a/entry/src/main/ets/component/pay/PayCancel.ets +++ b/entry/src/main/ets/component/pay/PayCancel.ets @@ -23,7 +23,7 @@ import { ConfirmDialog } from '../common/ConfirmDialog'; import { PayConstants } from '../common/constants/PayConstants' // [Start HMRouter_confirmDialog] -@HMRouter({pageUrl: 'PayCancel', dialog: true}) +@HMRouter({ pageUrl: 'PayCancel', dialog: true }) @Component export struct PayCancel { // [StartExclude HMRouter_confirmDialog] @@ -33,9 +33,10 @@ export struct PayCancel { let pageUrl = HMRouterMgr.getCurrentParam() as string; this.pageUrl = pageUrl; } + // [EndExclude HMRouter_confirmDialog] build() { - Stack({alignContent: Alignment.Center}) { + Stack({ alignContent: Alignment.Center }) { // [StartExclude HMRouter_confirmDialog] Column() .width('100%') @@ -45,7 +46,7 @@ export struct PayCancel { // [EndExclude HMRouter_confirmDialog] ConfirmDialog({ title: '取消订单', - content:'您确认要取消此订单吗?', + content: '您确认要取消此订单吗?', leftButtonName: '再看看', rightButtonName: '取消订单', leftButtonFunc: () => { @@ -61,7 +62,7 @@ export struct PayCancel { pathStack?.pop(false); } } else { - for(let i = 0; i < 3; i++) { + for (let i = 0; i < 3; i++) { pathStack?.pop(false); } } @@ -73,4 +74,5 @@ export struct PayCancel { .height('100%'); } } + // [End HMRouter_confirmDialog] \ No newline at end of file diff --git a/entry/src/main/ets/component/pay/PayDialogContent.ets b/entry/src/main/ets/component/pay/PayDialogContent.ets index 2f8f09082f161a025bf12dec38659753d313462a..f04d631b9c885f282686b90d2449318f2f1bc3e5 100644 --- a/entry/src/main/ets/component/pay/PayDialogContent.ets +++ b/entry/src/main/ets/component/pay/PayDialogContent.ets @@ -149,8 +149,10 @@ export struct PayDialogContent { VerticalAlign.Center) .justifyContent(FlexAlign.Center); } + // [EndExclude HMRouter_lifecycle] } + // [End HMRouter_lifecycle] @@ -174,6 +176,7 @@ export class ExitPayLifecycle implements IHMLifecycle { return true; } } + // [End exit_pay_lifecycle] export class ObservedModel { diff --git a/entry/src/main/ets/component/privacy/PrivacyDialogContent.ets b/entry/src/main/ets/component/privacy/PrivacyDialogContent.ets index 98ef67b7fab6e1887af8fa4db82273a01d2a18c7..30c19e952be6c804555c4defae0e411f77d8c070 100644 --- a/entry/src/main/ets/component/privacy/PrivacyDialogContent.ets +++ b/entry/src/main/ets/component/privacy/PrivacyDialogContent.ets @@ -38,7 +38,7 @@ export struct PrivacyDialogContent { } build() { - Stack({alignContent: Alignment.Center}) { + Stack({ alignContent: Alignment.Center }) { Column() .width('100%') .height('100%') @@ -46,6 +46,8 @@ export struct PrivacyDialogContent { .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]); }; } + // [EndExclude HMRouter_dialog] } + // [End HMRouter_dialog] \ No newline at end of file diff --git a/entry/src/main/ets/component/product/ProductContent.ets b/entry/src/main/ets/component/product/ProductContent.ets index b2b11fd9212449da6eee84a91f48f4223b71fe56..1e535f6c0334ae4caf2d86ebd18e73a29d36f633 100644 --- a/entry/src/main/ets/component/product/ProductContent.ets +++ b/entry/src/main/ets/component/product/ProductContent.ets @@ -22,10 +22,11 @@ import { PageConstant } from '../../constant/PageConstant'; import { DetailConstants } from '../common/constants/DetailConstants'; import { ProductInfo, ProductPicture } from './elements/ProductDetail'; import { ProductMsg, ProductUtilView } from './elements/ProductUtilView'; + interface ParamsType {} // [Start hm_router] -@HMRouter({pageUrl: 'ProductContent'}) +@HMRouter({ pageUrl: 'ProductContent' }) @Component export struct ProductContent { // [StartExclude hm_router] @@ -40,6 +41,7 @@ export struct ProductContent { aboutToAppear(): void { this.param = HMRouterMgr.getCurrentParam() as ParamsType; } + // [StartExclude hm_router] // [StartExclude hm_router_get_current_param] build() { @@ -47,22 +49,24 @@ export struct ProductContent { Scroll() { Column() { ProductPicture() - .margin({bottom: 70}); - ProductInfo({product: this.product}); + .margin({ bottom: 70 }); + ProductInfo({ product: this.product }); }; } .scrollBar(BarState.Off) .layoutWeight(1); - ProductUtilView({product: this.product}); + ProductUtilView({ product: this.product }); } - .padding({top: 0}) + .padding({ top: 0 }) .height('100%') .width('100%') .layoutWeight(1); } + // [EndExclude hm_router] // [EndExclude hm_router_get_current_param] } + // [End hm_router] // [End hm_router_get_current_param] \ No newline at end of file diff --git a/entry/src/main/ets/component/product/elements/ProductContent.ets b/entry/src/main/ets/component/product/elements/ProductContent.ets index 33fcf6629cd3e91c564080ae3ee23e6187ab7be9..75f1275f77c45f50c2985e4198b917b19eb7c53e 100644 --- a/entry/src/main/ets/component/product/elements/ProductContent.ets +++ b/entry/src/main/ets/component/product/elements/ProductContent.ets @@ -1,17 +1,23 @@ import { HMRouterMgr } from "@hadss/hmrouter"; -class ParamsType{ +class ParamsType { } + // [Start page_url] @Component export struct ProductContent { // ... @State param: ParamsType | null = null; + aboutToAppear(): void { this.param = HMRouterMgr.getCurrentParam() as ParamsType; } + // [StartExclude page_url] - build() {} + build() { + } + // [EndExclude page_url] } + // [End page_url] diff --git a/entry/src/main/ets/component/shoppingBag/ShoppingBagContent.ets b/entry/src/main/ets/component/shoppingBag/ShoppingBagContent.ets index c8d887c013f9ff0898c92fdd1c884bb4bde628d9..8e6ac86430cd1c25e1d954eeae8ec1c1805a1349 100644 --- a/entry/src/main/ets/component/shoppingBag/ShoppingBagContent.ets +++ b/entry/src/main/ets/component/shoppingBag/ShoppingBagContent.ets @@ -45,12 +45,14 @@ async function networkRequest(lifecycle: string): Promise { }); // [EndExclude newwork_request] } + // [End newwork_request] // [Start example_life_cycle] -@HMLifecycle({lifecycleName: 'requestLifecycle'}) +@HMLifecycle({ lifecycleName: 'requestLifecycle' }) export class ExampleLifecycle implements IHMLifecycle { private requestModel: RequestModel = new RequestModel(); + onPrepare(): void { console.log(this.requestModel.data); let task: taskpool.Task = new taskpool.Task(networkRequest, 'onPrepare'); @@ -58,13 +60,16 @@ export class ExampleLifecycle implements IHMLifecycle { console.log(res + ''); }); } + // [StartExclude example_life_cycle] onBackPressed(ctx: HMLifecycleContext): boolean { - HMRouterMgr.pop({navigationId: 'mainNavigationId', animator: false}); + HMRouterMgr.pop({ navigationId: 'mainNavigationId', animator: false }); return true; } + // [EndExclude example_life_cycle] } + // [End example_life_cycle] @Observed @@ -94,11 +99,11 @@ export struct ShoppingBagContent { uiObserver.on('navDestinationSwitch', this.getUIContext(), { navigationId: 'shoppingNavigation' }, (info) => { - if(info.from === 'navBar') { + if (info.from === 'navBar') { this.showTabsBtn = false; this.modifier.attribute?.mode(NavigationMode.Auto); } - if(info.to === 'navBar') { + if (info.to === 'navBar') { this.showTabsBtn = true; this.modifier.attribute?.mode(NavigationMode.Stack); } @@ -120,7 +125,7 @@ export struct ShoppingBagContent { // Asynchronous calls will be executed at the end HMRouterMgr.request('testAsyncFun').data.then((res: string) => console.log(res)); - const tempObjParam: TempObj = {paramA: '', paramB: 20}; + const tempObjParam: TempObj = { paramA: '', paramB: 20 }; console.log(HMRouterMgr.request('testFunWithParams', 'testStr', 10, false, tempObjParam).data); } @@ -131,9 +136,11 @@ export struct ShoppingBagContent { modifier: this.modifier } }) { - ShoppingBagContentNavBar({showTabsBtn: this.showTabsBtn}); + ShoppingBagContentNavBar({ showTabsBtn: this.showTabsBtn }); }; } + // [EndExclude HMRouter_life_cycle_name] } + // [End HMRouter_life_cycle_name] \ No newline at end of file diff --git a/entry/src/main/ets/interceptor/LoginCheckInterceptor.ets b/entry/src/main/ets/interceptor/LoginCheckInterceptor.ets index 2ea7c82e9f90f8c5d39a09668143c7b537bc6007..7c946e03fd77d131abdac0c9400ececd008b5416 100644 --- a/entry/src/main/ets/interceptor/LoginCheckInterceptor.ets +++ b/entry/src/main/ets/interceptor/LoginCheckInterceptor.ets @@ -21,13 +21,13 @@ import { HMInterceptor, HMInterceptorAction, HMInterceptorInfo, HMRouterMgr, IHM import { LoginConstants } from '../component/common/constants/LoginConstants'; // [Start hm_interceptor] -@HMInterceptor({interceptorName: 'LoginCheckInterceptor'}) +@HMInterceptor({ interceptorName: 'LoginCheckInterceptor' }) export class LoginCheckInterceptor implements IHMInterceptor { handle(info: HMInterceptorInfo): HMInterceptorAction { // [StartExclude hm_interceptor] - if(info.srcName === 'PayCard') { + if (info.srcName === 'PayCard') { // [EndExclude hm_interceptor] - if(!!AppStorage.get('isLogin')) { + if (!!AppStorage.get('isLogin')) { return HMInterceptorAction.DO_NEXT; } else { info.context.getPromptAction().showToast({ message: '请先登录' }); @@ -39,10 +39,10 @@ export class LoginCheckInterceptor implements IHMInterceptor { } // [StartExclude hm_interceptor] } else { - if(!!AppStorage.get('isLogin')) { + if (!!AppStorage.get('isLogin')) { return HMInterceptorAction.DO_NEXT; } else { - info.context.getPromptAction().showToast({message: LoginConstants.LOGIN_TOAST}); + info.context.getPromptAction().showToast({ message: LoginConstants.LOGIN_TOAST }); HMRouterMgr.push({ pageUrl: 'loginPage', param: info.targetName, @@ -54,4 +54,5 @@ export class LoginCheckInterceptor implements IHMInterceptor { // [EndExclude hm_interceptor] } } + // [End hm_interceptor] \ No newline at end of file diff --git a/entry/src/main/ets/lifecycle/ExitAppLifecycle.ets b/entry/src/main/ets/lifecycle/ExitAppLifecycle.ets index 4c317a06da1fb79769e5772b8f98680d56fe064b..509a3868efe33c04150cc95611ff9855b578e416 100644 --- a/entry/src/main/ets/lifecycle/ExitAppLifecycle.ets +++ b/entry/src/main/ets/lifecycle/ExitAppLifecycle.ets @@ -21,12 +21,13 @@ import { HMLifecycle, HMLifecycleContext, IHMLifecycle } from '@hadss/hmrouter'; import { CommonConstants } from '../component/common/constants/CommonConstants' // [Start exit_app_lifecycle] -@HMLifecycle({lifecycleName: 'ExitAppLifecycle'}) +@HMLifecycle({ lifecycleName: 'ExitAppLifecycle' }) export class ExitAppLifecycle implements IHMLifecycle { private lastTime: number = 0; + onBackPressed(ctx: HMLifecycleContext): boolean { let time = new Date().getTime(); - if(time - this.lastTime > 1000) { + if (time - this.lastTime > 1000) { this.lastTime = time; ctx.uiContext.getPromptAction().showToast({ message: 'Return to exit the application again.', @@ -38,4 +39,5 @@ export class ExitAppLifecycle implements IHMLifecycle { } } } + // [End exit_app_lifecycle] diff --git a/entry/src/main/ets/lifecycle/PageDurationLifecycle.ets b/entry/src/main/ets/lifecycle/PageDurationLifecycle.ets index a8bff101df74229a56ba5a2cf1981f863235b74e..7f79fb1c92bf9b3081a75bcf20f9c2cbe27a7778 100644 --- a/entry/src/main/ets/lifecycle/PageDurationLifecycle.ets +++ b/entry/src/main/ets/lifecycle/PageDurationLifecycle.ets @@ -33,4 +33,5 @@ export class PageDurationLifecycle implements IHMLifecycle { console.log(`Page ${ctx.navContext?.pathInfo.name} stay ${duration}`); } } + // [End page_duration_life_cycle] \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index a6340d544ffe721a0b9183e9c72fb9f10bf2b96e..448aff2f6bd33afa20c5077c1b12a350a3125524 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -50,7 +50,7 @@ struct Index { uiObserver.on('navDestinationSwitch', this.getUIContext(), { navigationId: 'mainNavigationId' }, (info) => { - if(this.refreshPages.includes((info.to as NavDestinationInfo).name.toString())) { + if (this.refreshPages.includes((info.to as NavDestinationInfo).name.toString())) { AppStorage.setOrCreate('currentPage', (info.to as NavDestinationInfo).name.toString()); } });