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 NWEB_DATE_TIME_CHOOSER_H 17 #define NWEB_DATE_TIME_CHOOSER_H 18 19 #include <memory> 20 #include <string> 21 #include <vector> 22 23 namespace OHOS::NWeb { 24 25 struct DateTime { 26 int32_t year = 0; 27 int32_t month = 0; 28 int32_t day = 0; 29 int32_t hour = 0; 30 int32_t minute = 0; 31 int32_t second = 0; 32 }; 33 34 class NWebDateTimeSuggestion { 35 public: 36 virtual ~NWebDateTimeSuggestion() = default; 37 38 virtual DateTime GetValue() = 0; 39 40 virtual std::string GetLabel() = 0; 41 42 virtual std::string GetLocalizedValue() = 0; 43 }; 44 45 enum DateTimeChooserType { DTC_DATE, DTC_DATETIME, DTC_DATETIME_LOCAL, DTC_TIME, DTC_MONTH, DTC_WEEK, DTC_UNKNOWN }; 46 47 class NWebDateTimeChooser { 48 public: 49 virtual ~NWebDateTimeChooser() = default; 50 51 virtual DateTimeChooserType GetType() = 0; 52 53 virtual double GetStep() = 0; 54 55 virtual DateTime GetMinimum() = 0; 56 57 virtual DateTime GetMaximum() = 0; 58 59 virtual DateTime GetDialogValue() = 0; 60 61 virtual bool GetHasSelected() = 0; 62 63 virtual size_t GetSuggestionIndex() = 0; 64 }; 65 66 class NWebDateTimeChooserCallback { 67 public: 68 virtual ~NWebDateTimeChooserCallback() = default; 69 70 virtual void Continue(bool success, const DateTime& value) = 0; 71 }; 72 73 } // namespace OHOS::NWeb 74 75 #endif