1/** 2 * 3 * Copyright (c) 2025 Huawei Device Co., Ltd. 4 * 5 * All rights reserved. 6 * Redistribution and use in source and binary forms, with or without modification, 7 * are permitted provided that the following conditions are met: 8 * 9 * Redistributions of source code must retain the above copyright notice,this 10 * list of conditions and the following disclaimer. 11 * 12 * Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * 16 * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, 17 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, 23 * 24 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26import { memo, __memo_context_type, __memo_id_type } from '@ohos.arkui.stateManagement' 27import { 28 Text, 29 TextAttribute, 30 Column, 31 Component, 32 Button, 33 ButtonAttribute, 34 ClickEvent, 35 UserView, 36 AttributeModifier, 37 RowAttribute, 38 ImageAttribute, 39 CheckboxAttribute, 40 Row, 41 Checkbox, 42 $r, 43 Resource, 44 Image, 45 TextAlign, 46 FlexAlign 47} from '@ohos.arkui.component' 48import { 49 State, 50 Consume, 51 StateDecoratedVariable, 52 MutableState, 53 stateOf, 54 observableProxy 55} from '@ohos.arkui.stateManagement' 56import hilog from '@ohos.hilog' 57import promptAction from '@ohos.promptAction'; 58 59const COLUMN_SPACE = 10; // column间隙 60 61/** 62 * 自定义封装公共文本组件 63 */ 64@Component 65export struct CommonText { 66 build() { 67 Row() { 68 Text($r('app.string.dynamicattributes_text_one')) 69 .fontSize(12) 70 .fontColor($r('app.color.dynamicattributes_orange')) 71 .textAlign(TextAlign.Center) 72 Text($r('app.string.dynamicattributes_text_two')) 73 .fontSize(12) 74 .fontColor($r('app.color.dynamicattributes_orange')) 75 .textAlign(TextAlign.Center) 76 .margin(10); 77 Text($r('app.string.dynamicattributes_text_three')) 78 .fontSize(12) 79 .fontColor($r('app.color.dynamicattributes_orange')) 80 .textAlign(TextAlign.Center) 81 }.width($r('app.string.dynamicattributes_max_size')) 82 } 83} 84 85/** 86 * 自定义封装底部bar组件 87 */ 88@Component 89export struct BottomBar { 90 @State buttonName: Resource = $r('app.string.dynamicattributes_settlement'); 91 @State barType: BarType = BarType.SHOPPING_CART; 92 93 build() { 94 Row() { 95 Column() { 96 if (this.barType === BarType.DETAILS) { 97 Button($r('app.string.dynamicattributes_add_cart')) 98 .height(30) 99 .width(90) 100 .backgroundColor(($r('app.color.dynamicattributes_orange'))) 101 .onClick((e: ClickEvent) => { 102 }) 103 } 104 } 105 106 Button(this.buttonName) 107 .height(30) 108 .width(90) 109 .backgroundColor(($r('app.color.dynamicattributes_orange'))) 110 .onClick((e: ClickEvent) => { 111 }) 112 } 113 .height(60) 114 .width($r('app.string.dynamicattributes_max_size')) 115 .padding(15) 116 .backgroundColor($r('app.color.dynamicattributes_barColor')) 117 .justifyContent(FlexAlign.End) 118 } 119} 120 121/** 122 * 自定义封装图文组件 123 */ 124@Component 125export struct ImageText { 126 @State item: string | Resource = $r('app.string.dynamicattributes_text'); 127 @State textOneContent: string | Resource = $r('app.string.dynamicattributes_text'); 128 @State textTwoContent: string | Resource = $r('app.string.dynamicattributes_text'); 129 @State textThreeContent: string | Resource = $r('app.string.dynamicattributes_text'); 130 @State imageSrc: Resource = $r('app.media.icon'); 131 132 build() { 133 Row() { 134 Row() { 135 Image($r('app.media.icon')) 136 .height(100) 137 .width(100) 138 .borderRadius(15) 139 .onClick((e: ClickEvent) => { 140 }) 141 } 142 143 Column() { 144 Text(this.item) 145 .fontSize(20).width($r('app.string.dynamicattributes_max_size')) 146 Text(this.textThreeContent) 147 .fontSize(20).width($r('app.string.dynamicattributes_max_size')) 148 CommonText() 149 Text(this.textOneContent) 150 .fontSize(20).width($r('app.string.dynamicattributes_max_size')) 151 .fontColor($r('app.color.dynamicattributes_orange')) 152 }.margin(15) 153 } 154 .width($r('app.string.dynamicattributes_max_size')) 155 .height($r('app.string.dynamicattributes_max_size')) 156 } 157} 158 159/* 160 枚举底部bar类型 161*/ 162export enum BarType { 163 SHOPPING_CART, // 购物车 164 DETAILS, // 详情页 165}