1/* 2 * Copyright (c) 2023 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 16/// <reference path='./import.ts' /> 17 18class ArkNavDestinationComponent extends ArkComponent implements NavDestinationAttribute { 19 constructor(nativePtr: KNode) { 20 super(nativePtr); 21 } 22 title(value: any): this { 23 throw new Error('Method not implemented.'); 24 } 25 hideTitleBar(value: boolean): this { 26 modifierWithKey(this._modifiersWithKeys, HideTitleBarModifier.identity, HideTitleBarModifier, value); 27 return this; 28 } 29 onShown(callback: () => void): this { 30 throw new Error('Method not implemented.'); 31 } 32 onHidden(callback: () => void): this { 33 throw new Error('Method not implemented.'); 34 } 35 onBackPressed(callback: () => boolean): this { 36 throw new Error('Method not implemented.'); 37 } 38} 39 40class HideTitleBarModifier extends ModifierWithKey<boolean> { 41 constructor(value: boolean) { 42 super(value); 43 } 44 static identity: Symbol = Symbol('hideTitleBar'); 45 46 applyPeer(node: KNode, reset: boolean): void { 47 if (reset) { 48 getUINativeModule().navDestination.resetHideTitleBar(node); 49 } else { 50 getUINativeModule().navDestination.setHideTitleBar(node, this.value!); 51 } 52 } 53} 54//@ts-ignore 55globalThis.NavDestination.attributeModifier = function (modifier) { 56 const elmtId = ViewStackProcessor.GetElmtIdToAccountFor(); 57 let nativeNode = getUINativeModule().getFrameNodeById(elmtId); 58 let component = this.createOrGetNode(elmtId, () => { 59 return new ArkNavDestinationComponent(nativeNode); 60 }); 61 applyUIAttributes(modifier, nativeNode, component); 62 component.applyModifierPatch(); 63}; 64