1 /*
2  * Copyright (c) 2022 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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_NAVIGATION_NAV_BAR_LAYOUT_PROPERTY_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_NAVIGATION_NAV_BAR_LAYOUT_PROPERTY_H
18 
19 #include "base/geometry/dimension.h"
20 #include "base/utils/macros.h"
21 #include "core/components/common/layout/constants.h"
22 #include "core/components_ng/base/inspector_filter.h"
23 #include "core/components_ng/layout/layout_property.h"
24 #include "core/components_ng/pattern/navigation/navdestination_layout_property_base.h"
25 #include "core/components_ng/pattern/navigation/navigation_declaration.h"
26 #include "core/components_ng/property/property.h"
27 
28 namespace OHOS::Ace::NG {
29 
30 class ACE_EXPORT NavBarLayoutProperty : public NavDestinationLayoutPropertyBase {
31     DECLARE_ACE_TYPE(NavBarLayoutProperty, NavDestinationLayoutPropertyBase);
32 
33 public:
34     NavBarLayoutProperty() = default;
35 
36     ~NavBarLayoutProperty() override = default;
37 
Clone()38     RefPtr<LayoutProperty> Clone() const override
39     {
40         auto copy = MakeRefPtr<NavBarLayoutProperty>();
41         copy->NavDestinationLayoutPropertyBase::UpdateBaseLayoutProperty(
42             DynamicCast<NavDestinationLayoutPropertyBase>(this));
43         copy->propTitleMode_ = CloneTitleMode();
44         copy->propHideBackButton_ = CloneHideBackButton();
45         return copy;
46     }
47 
Reset()48     void Reset() override
49     {
50         NavDestinationLayoutPropertyBase::Reset();
51         ResetTitleMode();
52         ResetHideBackButton();
53     }
54 
GetTitleModeString()55     std::string GetTitleModeString() const
56     {
57         switch (GetTitleModeValue(NavigationTitleMode::FREE)) {
58             case NavigationTitleMode::FREE:
59                 return "NavigationTitleMode.Free";
60             case NavigationTitleMode::FULL:
61                 return "NavigationTitleMode.Full";
62             case NavigationTitleMode::MINI:
63                 return "NavigationTitleMode.Mini";
64             default:
65                 return "NavigationTitleMode.Free";
66         }
67     }
68 
69     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(TitleMode, NavigationTitleMode, PROPERTY_UPDATE_MEASURE);
70     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(HideBackButton, bool, PROPERTY_UPDATE_MEASURE);
71 };
72 
73 } // namespace OHOS::Ace::NG
74 
75 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_NAVIGATION_NAV_BAR_LAYOUT_PROPERTY_H
76