1/* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16if (!("finalizeConstruction" in ViewPU.prototype)) { 17 Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); 18} 19export class AtomicServiceNavigation extends ViewPU { 20 constructor(w, x, y, z = -1, a1 = undefined, b1) { 21 super(w, y, z, b1); 22 if (typeof a1 === "function") { 23 this.paramsGenerator_ = a1; 24 } 25 this.__navPathStack = new ObservedPropertyObjectPU(new NavPathStack(), this, "navPathStack"); 26 this.navigationContent = undefined; 27 this.__title = new SynchedPropertyObjectOneWayPU(x.title, this, "title"); 28 this.__titleOptions = new SynchedPropertyObjectOneWayPU(x.titleOptions, this, "titleOptions"); 29 this.__hideTitleBar = new SynchedPropertySimpleOneWayPU(x.hideTitleBar, this, "hideTitleBar"); 30 this.__navBarWidth = new SynchedPropertyObjectOneWayPU(x.navBarWidth, this, "navBarWidth"); 31 this.__mode = new SynchedPropertySimpleOneWayPU(x.mode, this, "mode"); 32 this.navDestinationBuilder = this.defaultNavDestinationBuilder; 33 this.__navBarWidthRange = new SynchedPropertyObjectOneWayPU(x.navBarWidthRange, this, "navBarWidthRange"); 34 this.__minContentWidth = new SynchedPropertyObjectOneWayPU(x.minContentWidth, this, "minContentWidth"); 35 this.stateChangeCallback = undefined; 36 this.modeChangeCallback = undefined; 37 this.setInitiallyProvidedValue(x); 38 this.finalizeConstruction(); 39 } 40 setInitiallyProvidedValue(v) { 41 if (v.navPathStack !== undefined) { 42 this.navPathStack = v.navPathStack; 43 } 44 if (v.navigationContent !== undefined) { 45 this.navigationContent = v.navigationContent; 46 } 47 if (v.titleOptions === undefined) { 48 this.__titleOptions.set({ isBlurEnabled: true }); 49 } 50 if (v.navDestinationBuilder !== undefined) { 51 this.navDestinationBuilder = v.navDestinationBuilder; 52 } 53 if (v.stateChangeCallback !== undefined) { 54 this.stateChangeCallback = v.stateChangeCallback; 55 } 56 if (v.modeChangeCallback !== undefined) { 57 this.modeChangeCallback = v.modeChangeCallback; 58 } 59 } 60 updateStateVars(u) { 61 this.__title.reset(u.title); 62 this.__titleOptions.reset(u.titleOptions); 63 this.__hideTitleBar.reset(u.hideTitleBar); 64 this.__navBarWidth.reset(u.navBarWidth); 65 this.__mode.reset(u.mode); 66 this.__navBarWidthRange.reset(u.navBarWidthRange); 67 this.__minContentWidth.reset(u.minContentWidth); 68 } 69 purgeVariableDependenciesOnElmtId(t) { 70 this.__navPathStack.purgeDependencyOnElmtId(t); 71 this.__title.purgeDependencyOnElmtId(t); 72 this.__titleOptions.purgeDependencyOnElmtId(t); 73 this.__hideTitleBar.purgeDependencyOnElmtId(t); 74 this.__navBarWidth.purgeDependencyOnElmtId(t); 75 this.__mode.purgeDependencyOnElmtId(t); 76 this.__navBarWidthRange.purgeDependencyOnElmtId(t); 77 this.__minContentWidth.purgeDependencyOnElmtId(t); 78 } 79 aboutToBeDeleted() { 80 this.__navPathStack.aboutToBeDeleted(); 81 this.__title.aboutToBeDeleted(); 82 this.__titleOptions.aboutToBeDeleted(); 83 this.__hideTitleBar.aboutToBeDeleted(); 84 this.__navBarWidth.aboutToBeDeleted(); 85 this.__mode.aboutToBeDeleted(); 86 this.__navBarWidthRange.aboutToBeDeleted(); 87 this.__minContentWidth.aboutToBeDeleted(); 88 SubscriberManager.Get().delete(this.id__()); 89 this.aboutToBeDeletedInternal(); 90 } 91 get navPathStack() { 92 return this.__navPathStack.get(); 93 } 94 set navPathStack(s) { 95 this.__navPathStack.set(s); 96 } 97 get title() { 98 return this.__title.get(); 99 } 100 set title(r) { 101 this.__title.set(r); 102 } 103 get titleOptions() { 104 return this.__titleOptions.get(); 105 } 106 set titleOptions(q) { 107 this.__titleOptions.set(q); 108 } 109 get hideTitleBar() { 110 return this.__hideTitleBar.get(); 111 } 112 set hideTitleBar(p) { 113 this.__hideTitleBar.set(p); 114 } 115 get navBarWidth() { 116 return this.__navBarWidth.get(); 117 } 118 set navBarWidth(o) { 119 this.__navBarWidth.set(o); 120 } 121 get mode() { 122 return this.__mode.get(); 123 } 124 set mode(n) { 125 this.__mode.set(n); 126 } 127 get navBarWidthRange() { 128 return this.__navBarWidthRange.get(); 129 } 130 set navBarWidthRange(m) { 131 this.__navBarWidthRange.set(m); 132 } 133 get minContentWidth() { 134 return this.__minContentWidth.get(); 135 } 136 set minContentWidth(l) { 137 this.__minContentWidth.set(l); 138 } 139 defaultNavDestinationBuilder(i, j, k = null) { 140 } 141 initialRender() { 142 this.observeComponentCreation2((g, h) => { 143 Navigation.create(this.navPathStack); 144 Navigation.title(ObservedObject.GetRawObject(this.title), { 145 backgroundColor: this.titleOptions?.backgroundColor, 146 backgroundBlurStyle: this.titleOptions?.isBlurEnabled ? BlurStyle.COMPONENT_THICK : BlurStyle.NONE, 147 barStyle: this.titleOptions?.barStyle 148 }); 149 Navigation.titleMode(NavigationTitleMode.Mini); 150 Navigation.hideBackButton(true); 151 Navigation.hideTitleBar(this.hideTitleBar); 152 Navigation.navBarWidth(ObservedObject.GetRawObject(this.navBarWidth)); 153 Navigation.navBarPosition(NavBarPosition.Start); 154 Navigation.mode(this.mode); 155 Navigation.navDestination({ builder: this.navDestinationBuilder.bind(this) }); 156 Navigation.navBarWidthRange(ObservedObject.GetRawObject(this.navBarWidthRange)); 157 Navigation.minContentWidth(ObservedObject.GetRawObject(this.minContentWidth)); 158 Navigation.onNavBarStateChange(this.stateChangeCallback); 159 Navigation.onNavigationModeChange(this.modeChangeCallback); 160 }, Navigation); 161 this.observeComponentCreation2((c, d) => { 162 If.create(); 163 if (this.navigationContent) { 164 this.ifElseBranchUpdateFunction(0, () => { 165 this.navigationContent.bind(this)(this); 166 }); 167 } 168 else { 169 this.ifElseBranchUpdateFunction(1, () => { 170 }); 171 } 172 }, If); 173 If.pop(); 174 Navigation.pop(); 175 } 176 rerender() { 177 this.updateDirtyElements(); 178 } 179} 180 181export default { AtomicServiceNavigation };