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 16import { Callback } from '@ohos.base'; 17 18@Component 19export struct AtomicServiceNavigation { 20 @State navPathStack?: NavPathStack = new NavPathStack(); 21 @BuilderParam navigationContent?: Callback<void>; 22 @Prop title?: ResourceStr; 23 @Prop titleOptions?: TitleOptions = { isBlurEnabled: true }; 24 @Prop hideTitleBar?: boolean; 25 @Prop navBarWidth?: Length; 26 @Prop mode?: NavigationMode; 27 @BuilderParam navDestinationBuilder?: NavDestinationBuilder = this.defaultNavDestinationBuilder; 28 @Prop navBarWidthRange?: [Dimension, Dimension]; 29 @Prop minContentWidth?: Dimension; 30 stateChangeCallback?: Callback<boolean>; 31 modeChangeCallback?: Callback<NavigationMode>; 32 33 @Builder 34 defaultNavDestinationBuilder(name: string, param?: Object) { 35 } 36 37 build() { 38 Navigation(this.navPathStack) { 39 if (this.navigationContent) { 40 this.navigationContent() 41 } 42 } 43 .title(this.title, { 44 backgroundColor: this.titleOptions?.backgroundColor, 45 backgroundBlurStyle: this.titleOptions?.isBlurEnabled ? BlurStyle.COMPONENT_THICK : BlurStyle.NONE, 46 barStyle: this.titleOptions?.barStyle 47 }) 48 .titleMode(NavigationTitleMode.Mini) 49 .hideBackButton(true) 50 .hideTitleBar(this.hideTitleBar) 51 .navBarWidth(this.navBarWidth) 52 .navBarPosition(NavBarPosition.Start) 53 .mode(this.mode) 54 .navDestination(this.navDestinationBuilder) 55 .navBarWidthRange(this.navBarWidthRange) 56 .minContentWidth(this.minContentWidth) 57 .onNavBarStateChange(this.stateChangeCallback) 58 .onNavigationModeChange(this.modeChangeCallback) 59 } 60} 61 62export interface TitleOptions { 63 backgroundColor?: ResourceColor, 64 isBlurEnabled?: boolean, 65 barStyle?: BarStyle 66} 67 68export type NavDestinationBuilder = (name: string, param?: Object) => void;