张善主

fix(多图):顶部底部适配

@@ -3,7 +3,6 @@ import { display, router } from '@kit.ArkUI'; @@ -3,7 +3,6 @@ import { display, router } from '@kit.ArkUI';
3 import { ImageItemView } from '../components/view/ImageItemView'; 3 import { ImageItemView } from '../components/view/ImageItemView';
4 import { ImageDownloadComponent } from '../components/ImageDownloadComponent'; 4 import { ImageDownloadComponent } from '../components/ImageDownloadComponent';
5 import { Action } from 'wdBean'; 5 import { Action } from 'wdBean';
6 -import { WindowModel } from 'wdKit/Index';  
7 6
8 const TAG = 'MultiPictureListPage'; 7 const TAG = 'MultiPictureListPage';
9 8
@@ -20,11 +19,11 @@ export struct MultiPictureListPage { @@ -20,11 +19,11 @@ export struct MultiPictureListPage {
20 @State picHeight: number = 0 19 @State picHeight: number = 0
21 @State isEnableSwipe: boolean = true; 20 @State isEnableSwipe: boolean = true;
22 @State currentUrl: string = '' 21 @State currentUrl: string = ''
23 - 22 + @Provide bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
  23 + @Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
24 // @Provide bgc: Color = Color.White; 24 // @Provide bgc: Color = Color.White;
25 25
26 aboutToAppear(): void { 26 aboutToAppear(): void {
27 - this.openFullScreen()  
28 //获取宽高尺寸 27 //获取宽高尺寸
29 this.screenWidth = this.displayTool.width 28 this.screenWidth = this.displayTool.width
30 // this.picWidth = this.screenWidth - vp2px(52) 29 // this.picWidth = this.screenWidth - vp2px(52)
@@ -57,7 +56,6 @@ export struct MultiPictureListPage { @@ -57,7 +56,6 @@ export struct MultiPictureListPage {
57 if (this.photoList && this.photoList?.length > 0) { 56 if (this.photoList && this.photoList?.length > 0) {
58 Swiper(this.swiperController) { 57 Swiper(this.swiperController) {
59 ForEach(this.photoList, (item: PhotoListBean) => { 58 ForEach(this.photoList, (item: PhotoListBean) => {
60 - // MultiPictureDetailItemComponent({ MultiPictureDetailItem: item })  
61 ImageItemView({ MultiPictureDetailItem: item, isEnableSwipe: this.isEnableSwipe }) 59 ImageItemView({ MultiPictureDetailItem: item, isEnableSwipe: this.isEnableSwipe })
62 }) 60 })
63 } 61 }
@@ -135,37 +133,16 @@ export struct MultiPictureListPage { @@ -135,37 +133,16 @@ export struct MultiPictureListPage {
135 } 133 }
136 .width('100%') 134 .width('100%')
137 .height('100%') 135 .height('100%')
138 - // .padding({top:$r('app.float.margin_44')}) 136 + .padding({top: `${this.topSafeHeight}px`,bottom:`${this.bottomSafeHeight}px`})
139 .backgroundColor(Color.Black) 137 .backgroundColor(Color.Black)
140 .id('e_picture_container') 138 .id('e_picture_container')
141 // 设置顶部绘制延伸到状态栏 139 // 设置顶部绘制延伸到状态栏
142 // 设置底部绘制延伸到导航条 140 // 设置底部绘制延伸到导航条
143 - .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])  
144 - }  
145 -  
146 - /**  
147 - * 开启沉浸式  
148 - * TODO:颜色待根据业务接口修改  
149 - */  
150 - openFullScreen() {  
151 - WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff', })  
152 - // WindowModel.shared.setWindowLayoutFullScreen(true)  
153 - // WindowModel.shared.setWindowSystemBarEnable([]) 141 + // .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
154 } 142 }
155 143
156 aboutToDisappear(): void { 144 aboutToDisappear(): void {
157 console.log(TAG, 'aboutToDisappear') 145 console.log(TAG, 'aboutToDisappear')
158 - this.closeFullScreen()  
159 - }  
160 -  
161 - /**  
162 - * 关闭沉浸式  
163 - * TODO:颜色待根据业务接口修改  
164 - */  
165 - closeFullScreen() {  
166 - WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', })  
167 - // WindowModel.shared.setWindowLayoutFullScreen(false)  
168 - // WindowModel.shared.setWindowSystemBarEnable(['status', 'navigation'])  
169 } 146 }
170 147
171 onBackPress(): boolean | void { 148 onBackPress(): boolean | void {
@@ -173,7 +150,5 @@ export struct MultiPictureListPage { @@ -173,7 +150,5 @@ export struct MultiPictureListPage {
173 } 150 }
174 151
175 private onBack() { 152 private onBack() {
176 - // 提前设置,否则返回的页面展示有问题(有时延)  
177 - this.closeFullScreen()  
178 } 153 }
179 } 154 }