59 lines
2.0 KiB
Plaintext
59 lines
2.0 KiB
Plaintext
/*
|
|
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
import { ImageKnifeComponent } from '@ohos/libraryimageknife'
|
|
import router from '@ohos.router'
|
|
|
|
@Entry
|
|
@Component
|
|
struct TestImageKnifeRouter {
|
|
@State array: Array<string> = [
|
|
"https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB",
|
|
'https://img-blog.csdnimg.cn/20191215043500229.png',
|
|
'https://img-blog.csdn.net/20140514114029140',
|
|
'https://hbimg.huabanimg.com/95a6d37a39aa0b70d48fa18dc7df8309e2e0e8e85571e-x4hhks_fw658/format/webp'
|
|
]
|
|
|
|
build() {
|
|
Column() {
|
|
Grid() {
|
|
ForEach(this.array, (item: string, index: number) => {
|
|
GridItem() {
|
|
ImageKnifeComponent({
|
|
imageKnifeOption: {
|
|
loadSrc: item,
|
|
placeholderSrc: $r('app.media.icon_loading'),
|
|
errorholderSrc: $r('app.media.icon_failed'),
|
|
onClick: () => {
|
|
router.pushUrl({ url: "pages/testImageKnifeRouter2", params: { url: this.array[index] } })
|
|
}
|
|
}
|
|
}).width(150).height(150)
|
|
.sharedTransition(this.array[index], {
|
|
duration: 500,
|
|
curve: Curve.Linear,
|
|
type: SharedTransitionEffectType.Exchange
|
|
})
|
|
}
|
|
})
|
|
}.columnsTemplate('1fr 1fr')
|
|
.rowsTemplate('1fr 1fr')
|
|
}.width("100%").height("100%")
|
|
}
|
|
|
|
pageTransition() {
|
|
PageTransitionEnter({ duration: 0 })
|
|
PageTransitionExit({ duration: 0 })
|
|
}
|
|
} |