123b3eb3cSopenharmony_ci/* 223b3eb3cSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 323b3eb3cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 423b3eb3cSopenharmony_ci * you may not use this file except in compliance with the License. 523b3eb3cSopenharmony_ci * You may obtain a copy of the License at 623b3eb3cSopenharmony_ci * 723b3eb3cSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 823b3eb3cSopenharmony_ci * 923b3eb3cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1023b3eb3cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1123b3eb3cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1223b3eb3cSopenharmony_ci * See the License for the specific language governing permissions and 1323b3eb3cSopenharmony_ci * limitations under the License. 1423b3eb3cSopenharmony_ci */ 1523b3eb3cSopenharmony_ci 1623b3eb3cSopenharmony_ciif (!("finalizeConstruction" in ViewPU.prototype)) { 1723b3eb3cSopenharmony_ci Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); 1823b3eb3cSopenharmony_ci} 1923b3eb3cSopenharmony_ciexport class AtomicServiceNavigation extends ViewPU { 2023b3eb3cSopenharmony_ci constructor(w, x, y, z = -1, a1 = undefined, b1) { 2123b3eb3cSopenharmony_ci super(w, y, z, b1); 2223b3eb3cSopenharmony_ci if (typeof a1 === "function") { 2323b3eb3cSopenharmony_ci this.paramsGenerator_ = a1; 2423b3eb3cSopenharmony_ci } 2523b3eb3cSopenharmony_ci this.__navPathStack = new ObservedPropertyObjectPU(new NavPathStack(), this, "navPathStack"); 2623b3eb3cSopenharmony_ci this.navigationContent = undefined; 2723b3eb3cSopenharmony_ci this.__title = new SynchedPropertyObjectOneWayPU(x.title, this, "title"); 2823b3eb3cSopenharmony_ci this.__titleOptions = new SynchedPropertyObjectOneWayPU(x.titleOptions, this, "titleOptions"); 2923b3eb3cSopenharmony_ci this.__hideTitleBar = new SynchedPropertySimpleOneWayPU(x.hideTitleBar, this, "hideTitleBar"); 3023b3eb3cSopenharmony_ci this.__navBarWidth = new SynchedPropertyObjectOneWayPU(x.navBarWidth, this, "navBarWidth"); 3123b3eb3cSopenharmony_ci this.__mode = new SynchedPropertySimpleOneWayPU(x.mode, this, "mode"); 3223b3eb3cSopenharmony_ci this.navDestinationBuilder = this.defaultNavDestinationBuilder; 3323b3eb3cSopenharmony_ci this.__navBarWidthRange = new SynchedPropertyObjectOneWayPU(x.navBarWidthRange, this, "navBarWidthRange"); 3423b3eb3cSopenharmony_ci this.__minContentWidth = new SynchedPropertyObjectOneWayPU(x.minContentWidth, this, "minContentWidth"); 3523b3eb3cSopenharmony_ci this.stateChangeCallback = undefined; 3623b3eb3cSopenharmony_ci this.modeChangeCallback = undefined; 3723b3eb3cSopenharmony_ci this.setInitiallyProvidedValue(x); 3823b3eb3cSopenharmony_ci this.finalizeConstruction(); 3923b3eb3cSopenharmony_ci } 4023b3eb3cSopenharmony_ci setInitiallyProvidedValue(v) { 4123b3eb3cSopenharmony_ci if (v.navPathStack !== undefined) { 4223b3eb3cSopenharmony_ci this.navPathStack = v.navPathStack; 4323b3eb3cSopenharmony_ci } 4423b3eb3cSopenharmony_ci if (v.navigationContent !== undefined) { 4523b3eb3cSopenharmony_ci this.navigationContent = v.navigationContent; 4623b3eb3cSopenharmony_ci } 4723b3eb3cSopenharmony_ci if (v.titleOptions === undefined) { 4823b3eb3cSopenharmony_ci this.__titleOptions.set({ isBlurEnabled: true }); 4923b3eb3cSopenharmony_ci } 5023b3eb3cSopenharmony_ci if (v.navDestinationBuilder !== undefined) { 5123b3eb3cSopenharmony_ci this.navDestinationBuilder = v.navDestinationBuilder; 5223b3eb3cSopenharmony_ci } 5323b3eb3cSopenharmony_ci if (v.stateChangeCallback !== undefined) { 5423b3eb3cSopenharmony_ci this.stateChangeCallback = v.stateChangeCallback; 5523b3eb3cSopenharmony_ci } 5623b3eb3cSopenharmony_ci if (v.modeChangeCallback !== undefined) { 5723b3eb3cSopenharmony_ci this.modeChangeCallback = v.modeChangeCallback; 5823b3eb3cSopenharmony_ci } 5923b3eb3cSopenharmony_ci } 6023b3eb3cSopenharmony_ci updateStateVars(u) { 6123b3eb3cSopenharmony_ci this.__title.reset(u.title); 6223b3eb3cSopenharmony_ci this.__titleOptions.reset(u.titleOptions); 6323b3eb3cSopenharmony_ci this.__hideTitleBar.reset(u.hideTitleBar); 6423b3eb3cSopenharmony_ci this.__navBarWidth.reset(u.navBarWidth); 6523b3eb3cSopenharmony_ci this.__mode.reset(u.mode); 6623b3eb3cSopenharmony_ci this.__navBarWidthRange.reset(u.navBarWidthRange); 6723b3eb3cSopenharmony_ci this.__minContentWidth.reset(u.minContentWidth); 6823b3eb3cSopenharmony_ci } 6923b3eb3cSopenharmony_ci purgeVariableDependenciesOnElmtId(t) { 7023b3eb3cSopenharmony_ci this.__navPathStack.purgeDependencyOnElmtId(t); 7123b3eb3cSopenharmony_ci this.__title.purgeDependencyOnElmtId(t); 7223b3eb3cSopenharmony_ci this.__titleOptions.purgeDependencyOnElmtId(t); 7323b3eb3cSopenharmony_ci this.__hideTitleBar.purgeDependencyOnElmtId(t); 7423b3eb3cSopenharmony_ci this.__navBarWidth.purgeDependencyOnElmtId(t); 7523b3eb3cSopenharmony_ci this.__mode.purgeDependencyOnElmtId(t); 7623b3eb3cSopenharmony_ci this.__navBarWidthRange.purgeDependencyOnElmtId(t); 7723b3eb3cSopenharmony_ci this.__minContentWidth.purgeDependencyOnElmtId(t); 7823b3eb3cSopenharmony_ci } 7923b3eb3cSopenharmony_ci aboutToBeDeleted() { 8023b3eb3cSopenharmony_ci this.__navPathStack.aboutToBeDeleted(); 8123b3eb3cSopenharmony_ci this.__title.aboutToBeDeleted(); 8223b3eb3cSopenharmony_ci this.__titleOptions.aboutToBeDeleted(); 8323b3eb3cSopenharmony_ci this.__hideTitleBar.aboutToBeDeleted(); 8423b3eb3cSopenharmony_ci this.__navBarWidth.aboutToBeDeleted(); 8523b3eb3cSopenharmony_ci this.__mode.aboutToBeDeleted(); 8623b3eb3cSopenharmony_ci this.__navBarWidthRange.aboutToBeDeleted(); 8723b3eb3cSopenharmony_ci this.__minContentWidth.aboutToBeDeleted(); 8823b3eb3cSopenharmony_ci SubscriberManager.Get().delete(this.id__()); 8923b3eb3cSopenharmony_ci this.aboutToBeDeletedInternal(); 9023b3eb3cSopenharmony_ci } 9123b3eb3cSopenharmony_ci get navPathStack() { 9223b3eb3cSopenharmony_ci return this.__navPathStack.get(); 9323b3eb3cSopenharmony_ci } 9423b3eb3cSopenharmony_ci set navPathStack(s) { 9523b3eb3cSopenharmony_ci this.__navPathStack.set(s); 9623b3eb3cSopenharmony_ci } 9723b3eb3cSopenharmony_ci get title() { 9823b3eb3cSopenharmony_ci return this.__title.get(); 9923b3eb3cSopenharmony_ci } 10023b3eb3cSopenharmony_ci set title(r) { 10123b3eb3cSopenharmony_ci this.__title.set(r); 10223b3eb3cSopenharmony_ci } 10323b3eb3cSopenharmony_ci get titleOptions() { 10423b3eb3cSopenharmony_ci return this.__titleOptions.get(); 10523b3eb3cSopenharmony_ci } 10623b3eb3cSopenharmony_ci set titleOptions(q) { 10723b3eb3cSopenharmony_ci this.__titleOptions.set(q); 10823b3eb3cSopenharmony_ci } 10923b3eb3cSopenharmony_ci get hideTitleBar() { 11023b3eb3cSopenharmony_ci return this.__hideTitleBar.get(); 11123b3eb3cSopenharmony_ci } 11223b3eb3cSopenharmony_ci set hideTitleBar(p) { 11323b3eb3cSopenharmony_ci this.__hideTitleBar.set(p); 11423b3eb3cSopenharmony_ci } 11523b3eb3cSopenharmony_ci get navBarWidth() { 11623b3eb3cSopenharmony_ci return this.__navBarWidth.get(); 11723b3eb3cSopenharmony_ci } 11823b3eb3cSopenharmony_ci set navBarWidth(o) { 11923b3eb3cSopenharmony_ci this.__navBarWidth.set(o); 12023b3eb3cSopenharmony_ci } 12123b3eb3cSopenharmony_ci get mode() { 12223b3eb3cSopenharmony_ci return this.__mode.get(); 12323b3eb3cSopenharmony_ci } 12423b3eb3cSopenharmony_ci set mode(n) { 12523b3eb3cSopenharmony_ci this.__mode.set(n); 12623b3eb3cSopenharmony_ci } 12723b3eb3cSopenharmony_ci get navBarWidthRange() { 12823b3eb3cSopenharmony_ci return this.__navBarWidthRange.get(); 12923b3eb3cSopenharmony_ci } 13023b3eb3cSopenharmony_ci set navBarWidthRange(m) { 13123b3eb3cSopenharmony_ci this.__navBarWidthRange.set(m); 13223b3eb3cSopenharmony_ci } 13323b3eb3cSopenharmony_ci get minContentWidth() { 13423b3eb3cSopenharmony_ci return this.__minContentWidth.get(); 13523b3eb3cSopenharmony_ci } 13623b3eb3cSopenharmony_ci set minContentWidth(l) { 13723b3eb3cSopenharmony_ci this.__minContentWidth.set(l); 13823b3eb3cSopenharmony_ci } 13923b3eb3cSopenharmony_ci defaultNavDestinationBuilder(i, j, k = null) { 14023b3eb3cSopenharmony_ci } 14123b3eb3cSopenharmony_ci initialRender() { 14223b3eb3cSopenharmony_ci this.observeComponentCreation2((g, h) => { 14323b3eb3cSopenharmony_ci Navigation.create(this.navPathStack); 14423b3eb3cSopenharmony_ci Navigation.title(ObservedObject.GetRawObject(this.title), { 14523b3eb3cSopenharmony_ci backgroundColor: this.titleOptions?.backgroundColor, 14623b3eb3cSopenharmony_ci backgroundBlurStyle: this.titleOptions?.isBlurEnabled ? BlurStyle.COMPONENT_THICK : BlurStyle.NONE, 14723b3eb3cSopenharmony_ci barStyle: this.titleOptions?.barStyle 14823b3eb3cSopenharmony_ci }); 14923b3eb3cSopenharmony_ci Navigation.titleMode(NavigationTitleMode.Mini); 15023b3eb3cSopenharmony_ci Navigation.hideBackButton(true); 15123b3eb3cSopenharmony_ci Navigation.hideTitleBar(this.hideTitleBar); 15223b3eb3cSopenharmony_ci Navigation.navBarWidth(ObservedObject.GetRawObject(this.navBarWidth)); 15323b3eb3cSopenharmony_ci Navigation.navBarPosition(NavBarPosition.Start); 15423b3eb3cSopenharmony_ci Navigation.mode(this.mode); 15523b3eb3cSopenharmony_ci Navigation.navDestination({ builder: this.navDestinationBuilder.bind(this) }); 15623b3eb3cSopenharmony_ci Navigation.navBarWidthRange(ObservedObject.GetRawObject(this.navBarWidthRange)); 15723b3eb3cSopenharmony_ci Navigation.minContentWidth(ObservedObject.GetRawObject(this.minContentWidth)); 15823b3eb3cSopenharmony_ci Navigation.onNavBarStateChange(this.stateChangeCallback); 15923b3eb3cSopenharmony_ci Navigation.onNavigationModeChange(this.modeChangeCallback); 16023b3eb3cSopenharmony_ci }, Navigation); 16123b3eb3cSopenharmony_ci this.observeComponentCreation2((c, d) => { 16223b3eb3cSopenharmony_ci If.create(); 16323b3eb3cSopenharmony_ci if (this.navigationContent) { 16423b3eb3cSopenharmony_ci this.ifElseBranchUpdateFunction(0, () => { 16523b3eb3cSopenharmony_ci this.navigationContent.bind(this)(this); 16623b3eb3cSopenharmony_ci }); 16723b3eb3cSopenharmony_ci } 16823b3eb3cSopenharmony_ci else { 16923b3eb3cSopenharmony_ci this.ifElseBranchUpdateFunction(1, () => { 17023b3eb3cSopenharmony_ci }); 17123b3eb3cSopenharmony_ci } 17223b3eb3cSopenharmony_ci }, If); 17323b3eb3cSopenharmony_ci If.pop(); 17423b3eb3cSopenharmony_ci Navigation.pop(); 17523b3eb3cSopenharmony_ci } 17623b3eb3cSopenharmony_ci rerender() { 17723b3eb3cSopenharmony_ci this.updateDirtyElements(); 17823b3eb3cSopenharmony_ci } 17923b3eb3cSopenharmony_ci} 18023b3eb3cSopenharmony_ci 18123b3eb3cSopenharmony_ciexport default { AtomicServiceNavigation };