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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_CALENDAR_CALENDAR_MODEL_NG_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_CALENDAR_CALENDAR_MODEL_NG_H
18 
19 #include "base/utils/macros.h"
20 #include "core/components/calendar/calendar_data_adapter.h"
21 #include "core/components_ng/pattern/calendar/calendar_controller_ng.h"
22 #include "core/components_ng/pattern/calendar/calendar_model.h"
23 #include "core/components_ng/pattern/calendar/calendar_paint_property.h"
24 
25 namespace OHOS::Ace::NG {
26 struct CalendarData {
27     CalendarDay date;
28     ObtainedMonth currentData;
29     ObtainedMonth preData;
30     ObtainedMonth nextData;
31     RefPtr<CalendarControllerNg> controller = nullptr;
32 };
33 
34 class ACE_EXPORT CalendarModelNG: public OHOS::Ace::CalendarModel {
35 public:
36     void Create(const CalendarModelData& calendarModelData) override;
37     void SetOffDays(const std::string& offDays) override;
38     void SetShowHoliday(const bool showHoliday) override;
39     void SetShowLunar(const bool showLunar) override;
40     void SetStartOfWeek(const int32_t startOfWeek) override;
41     void SetNeedSlide(const bool needSlide) override;
42     void SetSelectedChangeEvent(std::function<void(const std::string&)>&& selectedChangeEvent) override;
43     void SetOnRequestDataEvent(std::function<void(const std::string&)>&& requestData) override;
44     void SetDirection(const int32_t dir) override;
45     void SetCurrentDayStyle(const CurrentDayStyleData& currentDayStyleData,
46         const CurrentDayStyleData& CurrentDayStyleDataImpl) override;
47     void SetNonCurrentDayStyle(const NonCurrentDayStyleData& nonCurrentDayStyleData) override;
48     void SetTodayStyle(const TodayStyleData& style) override;
49     void SetWeekStyle(const WeekStyleData& style) override;
50     void SetWorkStateStyle(const WorkStateStyleData& style) override;
51 
52     static void SetCurrentData(const ObtainedMonth& currentData);
53     static void SetPreData(const ObtainedMonth& preData);
54     static void SetNextData(const ObtainedMonth& nextData);
55     static void SetCalendarDay(const CalendarDay& calendarDay);
56 
57 private:
58     static void Create(const CalendarData& calendarData);
59     static RefPtr<FrameNode> Create();
60     static void SetCurrentDayStyle(const CurrentDayStyle& currentDayStyle);
61     static void SetNonCurrentDayStyle(const NonCurrentDayStyle& nonCurrentDayStyle);
62     static void SetTodayStyle(const TodayStyle& todayStyle);
63     static void SetWeekStyle(const WeekStyle& weekStyle);
64     static void SetWorkStateStyle(const WorkStateStyle& workStateStyle);
65 };
66 } // namespace OHOS::Ace::NG
67 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_CALENDAR_CALENDAR_MODEL_NG_H
68