张善主

feat(查看图片):动态

@@ -158,20 +158,38 @@ export struct ImageItemView { @@ -158,20 +158,38 @@ export struct ImageItemView {
158 158
159 build() { 159 build() {
160 Stack() { 160 Stack() {
161 - Image(this.imagePixelMap)// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性  
162 - .width(this.fitWH === "width" ? "100%" : undefined)  
163 - .height(this.fitWH === "height" ? "100%" : undefined)  
164 - .aspectRatio(this.imageWHRatio)  
165 - .objectFit(ImageFit.Cover)// TODO:知识点:保持宽高比进行缩放,可以超出父组件,以便实现多图切换的增强功能  
166 - .autoResize(false)  
167 - .transform(this.matrix)// TODO:知识点:通过matrix控制图片的缩放  
168 - .defaultFocus(true)  
169 - .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])  
170 - .offset({  
171 - // TODO:知识点:通过offset控制图片的偏移  
172 - x: this.imageOffsetInfo.currentX,  
173 - y: this.imageOffsetInfo.currentY  
174 - }) 161 + if(this.imageUri != null && (this.imageUri.includes('.gif') || this.imageUri.includes('.GIF'))){
  162 + Image(this.imageUri)// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性
  163 + .width(this.fitWH === "width" ? "100%" : undefined)
  164 + .height(this.fitWH === "height" ? "100%" : undefined)
  165 + .aspectRatio(this.imageWHRatio)
  166 + .objectFit(ImageFit.Cover)// TODO:知识点:保持宽高比进行缩放,可以超出父组件,以便实现多图切换的增强功能
  167 + .autoResize(false)
  168 + .transform(this.matrix)// TODO:知识点:通过matrix控制图片的缩放
  169 + .defaultFocus(true)
  170 + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
  171 + .offset({
  172 + // TODO:知识点:通过offset控制图片的偏移
  173 + x: this.imageOffsetInfo.currentX,
  174 + y: this.imageOffsetInfo.currentY
  175 + })
  176 + }else{
  177 + Image(this.imagePixelMap)// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性
  178 + .width(this.fitWH === "width" ? "100%" : undefined)
  179 + .height(this.fitWH === "height" ? "100%" : undefined)
  180 + .aspectRatio(this.imageWHRatio)
  181 + .objectFit(ImageFit.Cover)// TODO:知识点:保持宽高比进行缩放,可以超出父组件,以便实现多图切换的增强功能
  182 + .autoResize(false)
  183 + .transform(this.matrix)// TODO:知识点:通过matrix控制图片的缩放
  184 + .defaultFocus(true)
  185 + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
  186 + .offset({
  187 + // TODO:知识点:通过offset控制图片的偏移
  188 + x: this.imageOffsetInfo.currentX,
  189 + y: this.imageOffsetInfo.currentY
  190 + })
  191 + }
  192 +
175 } 193 }
176 .onBlur(() => { 194 .onBlur(() => {
177 this.resetCurrentImageInfo(); 195 this.resetCurrentImageInfo();