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_ciconst DEFAULT_BAR_WIDTH = 96; 2023b3eb3cSopenharmony_ciconst DEFAULT_BAR_HEIGHT = 52; 2123b3eb3cSopenharmony_ciexport class AtomicServiceTabs extends ViewPU { 2223b3eb3cSopenharmony_ci constructor(m1, n1, o1, p1 = -1, q1 = undefined, r1) { 2323b3eb3cSopenharmony_ci super(m1, o1, p1, r1); 2423b3eb3cSopenharmony_ci if (typeof q1 === "function") { 2523b3eb3cSopenharmony_ci this.paramsGenerator_ = q1; 2623b3eb3cSopenharmony_ci } 2723b3eb3cSopenharmony_ci this.tabContents = undefined; 2823b3eb3cSopenharmony_ci this.__tabBarOptionsArray = new SynchedPropertyObjectOneWayPU(n1.tabBarOptionsArray, this, "tabBarOptionsArray"); 2923b3eb3cSopenharmony_ci this.__tabBarPosition = new SynchedPropertySimpleOneWayPU(n1.tabBarPosition, this, "tabBarPosition"); 3023b3eb3cSopenharmony_ci this.__barBackgroundColor = new SynchedPropertyObjectOneWayPU(n1.barBackgroundColor, this, "barBackgroundColor"); 3123b3eb3cSopenharmony_ci this.__index = new SynchedPropertyObjectOneWayPU(n1.index, this, "index"); 3223b3eb3cSopenharmony_ci this.__barOverlap = new SynchedPropertySimpleOneWayPU(n1.barOverlap, this, "barOverlap"); 3323b3eb3cSopenharmony_ci this.controller = new TabsController(); 3423b3eb3cSopenharmony_ci this.onChange = undefined; 3523b3eb3cSopenharmony_ci this.onTabBarClick = undefined; 3623b3eb3cSopenharmony_ci this.onContentWillChange = undefined; 3723b3eb3cSopenharmony_ci this.setInitiallyProvidedValue(n1); 3823b3eb3cSopenharmony_ci this.finalizeConstruction(); 3923b3eb3cSopenharmony_ci } 4023b3eb3cSopenharmony_ci setInitiallyProvidedValue(l1) { 4123b3eb3cSopenharmony_ci if (l1.tabContents !== undefined) { 4223b3eb3cSopenharmony_ci this.tabContents = l1.tabContents; 4323b3eb3cSopenharmony_ci } 4423b3eb3cSopenharmony_ci if (l1.tabBarPosition === undefined) { 4523b3eb3cSopenharmony_ci this.__tabBarPosition.set(TabBarPosition.BOTTOM); 4623b3eb3cSopenharmony_ci } 4723b3eb3cSopenharmony_ci if (l1.barBackgroundColor === undefined) { 4823b3eb3cSopenharmony_ci this.__barBackgroundColor.set(Color.Transparent); 4923b3eb3cSopenharmony_ci } 5023b3eb3cSopenharmony_ci if (l1.index === undefined) { 5123b3eb3cSopenharmony_ci this.__index.set(0); 5223b3eb3cSopenharmony_ci } 5323b3eb3cSopenharmony_ci if (l1.barOverlap === undefined) { 5423b3eb3cSopenharmony_ci this.__barOverlap.set(true); 5523b3eb3cSopenharmony_ci } 5623b3eb3cSopenharmony_ci if (l1.controller !== undefined) { 5723b3eb3cSopenharmony_ci this.controller = l1.controller; 5823b3eb3cSopenharmony_ci } 5923b3eb3cSopenharmony_ci if (l1.onChange !== undefined) { 6023b3eb3cSopenharmony_ci this.onChange = l1.onChange; 6123b3eb3cSopenharmony_ci } 6223b3eb3cSopenharmony_ci if (l1.onTabBarClick !== undefined) { 6323b3eb3cSopenharmony_ci this.onTabBarClick = l1.onTabBarClick; 6423b3eb3cSopenharmony_ci } 6523b3eb3cSopenharmony_ci if (l1.onContentWillChange !== undefined) { 6623b3eb3cSopenharmony_ci this.onContentWillChange = l1.onContentWillChange; 6723b3eb3cSopenharmony_ci } 6823b3eb3cSopenharmony_ci } 6923b3eb3cSopenharmony_ci updateStateVars(k1) { 7023b3eb3cSopenharmony_ci this.__tabBarOptionsArray.reset(k1.tabBarOptionsArray); 7123b3eb3cSopenharmony_ci this.__tabBarPosition.reset(k1.tabBarPosition); 7223b3eb3cSopenharmony_ci this.__barBackgroundColor.reset(k1.barBackgroundColor); 7323b3eb3cSopenharmony_ci this.__index.reset(k1.index); 7423b3eb3cSopenharmony_ci this.__barOverlap.reset(k1.barOverlap); 7523b3eb3cSopenharmony_ci } 7623b3eb3cSopenharmony_ci purgeVariableDependenciesOnElmtId(j1) { 7723b3eb3cSopenharmony_ci this.__tabBarOptionsArray.purgeDependencyOnElmtId(j1); 7823b3eb3cSopenharmony_ci this.__tabBarPosition.purgeDependencyOnElmtId(j1); 7923b3eb3cSopenharmony_ci this.__barBackgroundColor.purgeDependencyOnElmtId(j1); 8023b3eb3cSopenharmony_ci this.__index.purgeDependencyOnElmtId(j1); 8123b3eb3cSopenharmony_ci this.__barOverlap.purgeDependencyOnElmtId(j1); 8223b3eb3cSopenharmony_ci } 8323b3eb3cSopenharmony_ci aboutToBeDeleted() { 8423b3eb3cSopenharmony_ci this.__tabBarOptionsArray.aboutToBeDeleted(); 8523b3eb3cSopenharmony_ci this.__tabBarPosition.aboutToBeDeleted(); 8623b3eb3cSopenharmony_ci this.__barBackgroundColor.aboutToBeDeleted(); 8723b3eb3cSopenharmony_ci this.__index.aboutToBeDeleted(); 8823b3eb3cSopenharmony_ci this.__barOverlap.aboutToBeDeleted(); 8923b3eb3cSopenharmony_ci SubscriberManager.Get().delete(this.id__()); 9023b3eb3cSopenharmony_ci this.aboutToBeDeletedInternal(); 9123b3eb3cSopenharmony_ci } 9223b3eb3cSopenharmony_ci get tabBarOptionsArray() { 9323b3eb3cSopenharmony_ci return this.__tabBarOptionsArray.get(); 9423b3eb3cSopenharmony_ci } 9523b3eb3cSopenharmony_ci set tabBarOptionsArray(i1) { 9623b3eb3cSopenharmony_ci this.__tabBarOptionsArray.set(i1); 9723b3eb3cSopenharmony_ci } 9823b3eb3cSopenharmony_ci get tabBarPosition() { 9923b3eb3cSopenharmony_ci return this.__tabBarPosition.get(); 10023b3eb3cSopenharmony_ci } 10123b3eb3cSopenharmony_ci set tabBarPosition(h1) { 10223b3eb3cSopenharmony_ci this.__tabBarPosition.set(h1); 10323b3eb3cSopenharmony_ci } 10423b3eb3cSopenharmony_ci get barBackgroundColor() { 10523b3eb3cSopenharmony_ci return this.__barBackgroundColor.get(); 10623b3eb3cSopenharmony_ci } 10723b3eb3cSopenharmony_ci set barBackgroundColor(g1) { 10823b3eb3cSopenharmony_ci this.__barBackgroundColor.set(g1); 10923b3eb3cSopenharmony_ci } 11023b3eb3cSopenharmony_ci get index() { 11123b3eb3cSopenharmony_ci return this.__index.get(); 11223b3eb3cSopenharmony_ci } 11323b3eb3cSopenharmony_ci set index(f1) { 11423b3eb3cSopenharmony_ci this.__index.set(f1); 11523b3eb3cSopenharmony_ci } 11623b3eb3cSopenharmony_ci get barOverlap() { 11723b3eb3cSopenharmony_ci return this.__barOverlap.get(); 11823b3eb3cSopenharmony_ci } 11923b3eb3cSopenharmony_ci set barOverlap(e1) { 12023b3eb3cSopenharmony_ci this.__barOverlap.set(e1); 12123b3eb3cSopenharmony_ci } 12223b3eb3cSopenharmony_ci initialRender() { 12323b3eb3cSopenharmony_ci this.observeComponentCreation2((c1, d1) => { 12423b3eb3cSopenharmony_ci Tabs.create({ 12523b3eb3cSopenharmony_ci barPosition: this.tabBarPosition === TabBarPosition.LEFT ? BarPosition.Start : BarPosition.End, 12623b3eb3cSopenharmony_ci index: this.index, 12723b3eb3cSopenharmony_ci controller: this.controller 12823b3eb3cSopenharmony_ci }); 12923b3eb3cSopenharmony_ci Tabs.barBackgroundColor(ObservedObject.GetRawObject(this.barBackgroundColor)); 13023b3eb3cSopenharmony_ci Tabs.divider(null); 13123b3eb3cSopenharmony_ci Tabs.vertical(this.tabBarPosition === TabBarPosition.LEFT ? true : false); 13223b3eb3cSopenharmony_ci Tabs.scrollable(false); 13323b3eb3cSopenharmony_ci Tabs.barOverlap(this.barOverlap); 13423b3eb3cSopenharmony_ci Tabs.barBackgroundBlurStyle(BlurStyle.COMPONENT_THICK); 13523b3eb3cSopenharmony_ci Tabs.onChange(this.onChange); 13623b3eb3cSopenharmony_ci Tabs.onTabBarClick(this.onTabBarClick); 13723b3eb3cSopenharmony_ci Tabs.onContentWillChange(this.onContentWillChange); 13823b3eb3cSopenharmony_ci Tabs.width((!this.tabContents && this.tabBarPosition === TabBarPosition.LEFT) ? DEFAULT_BAR_WIDTH : '100%'); 13923b3eb3cSopenharmony_ci Tabs.height((!this.tabContents && this.tabBarPosition === TabBarPosition.BOTTOM) ? DEFAULT_BAR_HEIGHT : '100%'); 14023b3eb3cSopenharmony_ci }, Tabs); 14123b3eb3cSopenharmony_ci this.observeComponentCreation2((h, i) => { 14223b3eb3cSopenharmony_ci ForEach.create(); 14323b3eb3cSopenharmony_ci const j = (l, m) => { 14423b3eb3cSopenharmony_ci const n = l; 14523b3eb3cSopenharmony_ci this.observeComponentCreation2((p, q) => { 14623b3eb3cSopenharmony_ci If.create(); 14723b3eb3cSopenharmony_ci if (n) { 14823b3eb3cSopenharmony_ci this.ifElseBranchUpdateFunction(0, () => { 14923b3eb3cSopenharmony_ci this.observeComponentCreation2((u, v) => { 15023b3eb3cSopenharmony_ci TabContent.create(() => { 15123b3eb3cSopenharmony_ci this.observeComponentCreation2((y, z) => { 15223b3eb3cSopenharmony_ci If.create(); 15323b3eb3cSopenharmony_ci if (this.tabContents && this.tabContents[m]) { 15423b3eb3cSopenharmony_ci this.ifElseBranchUpdateFunction(0, () => { 15523b3eb3cSopenharmony_ci this.tabContents[m]?.bind(this)?.(this); 15623b3eb3cSopenharmony_ci }); 15723b3eb3cSopenharmony_ci } 15823b3eb3cSopenharmony_ci else { 15923b3eb3cSopenharmony_ci this.ifElseBranchUpdateFunction(1, () => { 16023b3eb3cSopenharmony_ci }); 16123b3eb3cSopenharmony_ci } 16223b3eb3cSopenharmony_ci }, If); 16323b3eb3cSopenharmony_ci If.pop(); 16423b3eb3cSopenharmony_ci }); 16523b3eb3cSopenharmony_ci TabContent.tabBar(BottomTabBarStyle.of(n.icon, n.text) 16623b3eb3cSopenharmony_ci .labelStyle({ unselectedColor: n.unselectedColor, selectedColor: n.selectedColor }) 16723b3eb3cSopenharmony_ci .iconStyle({ unselectedColor: n.unselectedColor, selectedColor: n.selectedColor })); 16823b3eb3cSopenharmony_ci TabContent.width((!this.tabContents && this.tabBarPosition === TabBarPosition.LEFT) ? DEFAULT_BAR_WIDTH : '100%'); 16923b3eb3cSopenharmony_ci TabContent.height((!this.tabContents && this.tabBarPosition === TabBarPosition.BOTTOM) ? DEFAULT_BAR_HEIGHT : '100%'); 17023b3eb3cSopenharmony_ci }, TabContent); 17123b3eb3cSopenharmony_ci TabContent.pop(); 17223b3eb3cSopenharmony_ci }); 17323b3eb3cSopenharmony_ci } 17423b3eb3cSopenharmony_ci else { 17523b3eb3cSopenharmony_ci this.ifElseBranchUpdateFunction(1, () => { 17623b3eb3cSopenharmony_ci }); 17723b3eb3cSopenharmony_ci } 17823b3eb3cSopenharmony_ci }, If); 17923b3eb3cSopenharmony_ci If.pop(); 18023b3eb3cSopenharmony_ci }; 18123b3eb3cSopenharmony_ci this.forEachUpdateFunction(h, this.tabBarOptionsArray, j, undefined, true, false); 18223b3eb3cSopenharmony_ci }, ForEach); 18323b3eb3cSopenharmony_ci ForEach.pop(); 18423b3eb3cSopenharmony_ci Tabs.pop(); 18523b3eb3cSopenharmony_ci } 18623b3eb3cSopenharmony_ci rerender() { 18723b3eb3cSopenharmony_ci this.updateDirtyElements(); 18823b3eb3cSopenharmony_ci } 18923b3eb3cSopenharmony_ci} 19023b3eb3cSopenharmony_ciexport class TabBarOptions { 19123b3eb3cSopenharmony_ci constructor(b, c, d, e) { 19223b3eb3cSopenharmony_ci this.icon = b; 19323b3eb3cSopenharmony_ci this.text = c; 19423b3eb3cSopenharmony_ci this.unselectedColor = d; 19523b3eb3cSopenharmony_ci this.selectedColor = e; 19623b3eb3cSopenharmony_ci } 19723b3eb3cSopenharmony_ci} 19823b3eb3cSopenharmony_ci 19923b3eb3cSopenharmony_ciexport var TabBarPosition; 20023b3eb3cSopenharmony_ci(function (a) { 20123b3eb3cSopenharmony_ci a[a["LEFT"] = 0] = "LEFT"; 20223b3eb3cSopenharmony_ci a[a["BOTTOM"] = 1] = "BOTTOM"; 20323b3eb3cSopenharmony_ci})(TabBarPosition || (TabBarPosition = {})); 20423b3eb3cSopenharmony_ci 20523b3eb3cSopenharmony_ciexport default { AtomicServiceTabs, TabBarOptions, TabBarPosition};