diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 42c22f19197067b977a56b1a9376a10860174182..a05711d8e06fa9c35bb054054c62aad6a53fc4b6 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -14,8 +14,9 @@ */ import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; -import { window } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; /** * Lift cycle management of Ability. @@ -44,6 +45,8 @@ export default class entryAbility extends UIAbility { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; } + // Immersive Adaptation + this.immersionFuc(windowStage); hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); }); @@ -66,4 +69,27 @@ export default class entryAbility extends UIAbility { hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); } + + /** + * Page immersion. + */ + immersionFuc(windowStage: window.WindowStage): void { + try { + let windowClass: window.Window = windowStage.getMainWindowSync(); + windowClass.setWindowLayoutFullScreen(true).catch((err: BusinessError) => { + hilog.error(0x0000, 'testTag', '%{public}s', + `SetWindowLayoutFullScreen failed. Cause code: ${err.code}, message: ${err.message}`); + }); + let navigationBarArea: window.AvoidArea = + windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR); + let area: window.AvoidArea = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); + AppStorage.setOrCreate('naviIndicatorHeight', + windowClass.getUIContext().px2vp(navigationBarArea.bottomRect.height)); + AppStorage.setOrCreate('statusBarHeight', windowClass.getUIContext().px2vp(area.topRect.height)); + AppStorage.setOrCreate('windowClass', windowClass); + } catch (err) { + hilog.error(0x0000, 'testTag', '%{public}s', + `immersionFuc failed, error code=${err.code}, message=${err.message}`); + } + } } diff --git a/entry/src/main/ets/pages/LoginPage.ets b/entry/src/main/ets/pages/LoginPage.ets index 6c6433b19f5d097115e2e9930654f087a2427e08..bd97a6e4d2cf17ae68f393d60265572bba34b0b4 100644 --- a/entry/src/main/ets/pages/LoginPage.ets +++ b/entry/src/main/ets/pages/LoginPage.ets @@ -13,7 +13,8 @@ * limitations under the License. */ -import { promptAction, router } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; import CommonConstants from '../common/constants/CommonConstants'; @Extend(TextInput) @@ -75,9 +76,15 @@ struct LoginPage { login(): void { if (this.account === '' || this.password === '') { - this.getUIContext().getPromptAction().showToast({ - message: $r('app.string.input_empty_tips') - }) + try { + this.getUIContext().getPromptAction().showToast({ + message: $r('app.string.input_empty_tips') + }) + } catch (error) { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + hilog.error(0x0000, 'LoginPage', `showToast args error code is ${code}, message is ${message}`); + } } else { this.isShowProgress = true; if (this.timeOutId === -1) { diff --git a/entry/src/main/ets/pages/MainPage.ets b/entry/src/main/ets/pages/MainPage.ets index 744230b3bc3ee957c82cf037e6d9348487e28228..9d9418d4325e3790102a5de5e6cf1db9f220d94f 100644 --- a/entry/src/main/ets/pages/MainPage.ets +++ b/entry/src/main/ets/pages/MainPage.ets @@ -67,11 +67,15 @@ struct MainPage { $r('app.media.mine_selected'), $r('app.media.mine_normal'))) } .width(CommonConstants.FULL_PARENT) - .backgroundColor(Color.White) + .backgroundColor($r('app.color.background')) .barHeight($r('app.float.mainPage_barHeight')) .barMode(BarMode.Fixed) .onChange((index: number) => { this.currentIndex = index; }) + .padding({ + top: AppStorage.get('statusBarHeight'), + bottom: AppStorage.get('naviIndicatorHeight') as number + }) } } \ No newline at end of file