|
| 1 | +// |
| 2 | +// Created on 2024/3/8. |
| 3 | +// |
| 4 | +// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found, |
| 5 | +// please include "napi/native_api.h". |
| 6 | + |
| 7 | +#ifndef HARMONY_PULLTOREFRESHCONFIGURATOR_H |
| 8 | +#define HARMONY_PULLTOREFRESHCONFIGURATOR_H |
| 9 | + |
| 10 | +#include "boost/cstdint.hpp" |
| 11 | +#include "react/renderer/graphics/Color.h" |
| 12 | +#include "react/renderer/graphics/Float.h" |
| 13 | +#include <string> |
| 14 | +namespace rnoh { |
| 15 | + class PullToRefreshConfigurator { |
| 16 | + private: |
| 17 | + bool hasRefresh = true; // 是否具有下拉刷新功能 |
| 18 | + bool hasLoadMore = true; // 是否具有上拉加载功能 |
| 19 | + uint32_t maxTranslate = 100; // 可下拉上拉的最大距离 |
| 20 | + facebook::react::Float sensitivity = 0.7; // 下拉上拉灵敏度 |
| 21 | + bool listIsPlacement = true; // 滑动结束后列表是否归位 |
| 22 | + |
| 23 | + |
| 24 | + uint32_t animDuration = 150; // 滑动结束后,回弹动画执行时间 |
| 25 | + |
| 26 | + uint32_t refreshHeight = 30; // 下拉动画高度 |
| 27 | + |
| 28 | + facebook::react::SharedColor refreshColor = 0xFF6495ED; // 下拉动画颜色 |
| 29 | + |
| 30 | + facebook::react::SharedColor refreshBackgroundColor = 0xFF64811D; // 下拉动画区域背景色 |
| 31 | + // |
| 32 | + // refreshTextColor ?: ResourceColor = '#999999'; // 下拉加载完毕后提示文本的字体颜色 |
| 33 | + // |
| 34 | + // refreshTextSize ?: number | string | Resource = 18; // 下拉加载完毕后提示文本的字体大小 |
| 35 | + |
| 36 | + uint32_t refreshAnimDuration = 1000; // 下拉动画执行一次的时间 |
| 37 | + uint32_t loadImgHeight = 30; // 上拉图片高度 |
| 38 | + |
| 39 | + std::string loadTextPullUp1 = "正在上拉刷新..."; // 上拉1阶段文本 |
| 40 | + |
| 41 | + std::string loadTextPullUp2 = "放开刷新"; // 上拉2阶段文本 |
| 42 | + |
| 43 | + std::string loadTextLoading = "正在玩命加载中..."; // 上拉加载更多中时的文本 |
| 44 | + |
| 45 | + uint32_t finishDelay = 500; // 刷新完成时,延迟回弹的时间 |
| 46 | + |
| 47 | + public: |
| 48 | + PullToRefreshConfigurator setHasRefresh(const bool hasRefresh) { |
| 49 | + this->hasRefresh = hasRefresh; |
| 50 | + return *this; |
| 51 | + } |
| 52 | + bool getHasRefresh() { return this->hasRefresh; } |
| 53 | + PullToRefreshConfigurator setHasLoadMore(const bool hasLoadMore) { |
| 54 | + this->hasLoadMore = hasLoadMore; |
| 55 | + return *this; |
| 56 | + } |
| 57 | + bool getHasLoadMore() { return this->hasLoadMore; } |
| 58 | + PullToRefreshConfigurator setMaxTranslate(const float maxTranslate) { |
| 59 | + this->maxTranslate = maxTranslate; |
| 60 | + return *this; |
| 61 | + } |
| 62 | + uint32_t getMaxTranslate() { return this->maxTranslate; } |
| 63 | + PullToRefreshConfigurator setSensitivity(const float sensitivity) { |
| 64 | + this->sensitivity = sensitivity; |
| 65 | + return *this; |
| 66 | + } |
| 67 | + facebook::react::Float getSensitivity() { return this->sensitivity; } |
| 68 | + PullToRefreshConfigurator setListIsPlacement(const bool listIsPlacement) { |
| 69 | + this->listIsPlacement = listIsPlacement; |
| 70 | + return *this; |
| 71 | + } |
| 72 | + bool getListIsPlacement() { return this->listIsPlacement; } |
| 73 | + PullToRefreshConfigurator setAnimDuration(const uint32_t animDuration) { |
| 74 | + this->animDuration = animDuration; |
| 75 | + return *this; |
| 76 | + } |
| 77 | + uint32_t getAnimDuration() { return this->animDuration; } |
| 78 | + float getRefreshWidth() { |
| 79 | + if (this->refreshHeight == 0) { |
| 80 | + return this->refreshHeight / 3 * 4; |
| 81 | + } |
| 82 | + return 0.0; |
| 83 | + } |
| 84 | + PullToRefreshConfigurator setRefreshHeight(const uint32_t refreshHeight) { |
| 85 | + this->refreshHeight = refreshHeight; |
| 86 | + return *this; |
| 87 | + } |
| 88 | + uint32_t getRefreshHeight() { return this->refreshHeight; } |
| 89 | + PullToRefreshConfigurator setRefreshColor(const facebook::react::SharedColor refreshColor) { |
| 90 | + this->refreshColor = refreshColor; |
| 91 | + return *this; |
| 92 | + } |
| 93 | + std::string getRefreshColor() { this->refreshColor; } |
| 94 | + PullToRefreshConfigurator setRefreshBackgroundColor(facebook::react::SharedColor refreshBackgroundColor) { |
| 95 | + this->refreshBackgroundColor = refreshBackgroundColor; |
| 96 | + } |
| 97 | + facebook::react::SharedColor getRefreshBackgroundColor() { return this->refreshBackgroundColor; } |
| 98 | + // PullToRefreshConfigurator setRefreshTextColor(bool listIsPlacement); |
| 99 | + // bool getRefreshTextColor(); |
| 100 | + // PullToRefreshConfigurator setRefreshTextSize(bool listIsPlacement); |
| 101 | + // bool getRefreshTextSize(); |
| 102 | + // PullToRefreshConfigurator setLoadBackgroundColor(bool listIsPlacement); |
| 103 | + // bool getLoadBackgroundColor(); |
| 104 | + // PullToRefreshConfigurator setLoadTextColor(bool listIsPlacement); |
| 105 | + // bool getLoadTextColor(); |
| 106 | + // PullToRefreshConfigurator setLoadTextSize(bool listIsPlacement); |
| 107 | + // bool getLoadTextSize(); |
| 108 | + PullToRefreshConfigurator setRefreshAnimDuration(const uint32_t refreshAnimDuration) { |
| 109 | + this->refreshAnimDuration = refreshAnimDuration; |
| 110 | + return *this; |
| 111 | + } |
| 112 | + uint32_t getRefreshAnimDuration() { return this->refreshAnimDuration; } |
| 113 | + PullToRefreshConfigurator setLoadImgHeight(const float loadImgHeight) { |
| 114 | + this->loadImgHeight = loadImgHeight; |
| 115 | + return *this; |
| 116 | + } |
| 117 | + float getLoadImgHeight() { return this->loadImgHeight; } |
| 118 | + PullToRefreshConfigurator setLoadTextPullUp1(const std::string loadTextPullUp1) { |
| 119 | + this->loadTextPullUp1 = loadTextPullUp1; |
| 120 | + return *this; |
| 121 | + } |
| 122 | + std::string getLoadTextPullUp1() { return this->loadTextPullUp1; } |
| 123 | + PullToRefreshConfigurator setLoadTextPullUp2(const std::string loadTextPullUp2) { |
| 124 | + this->loadTextPullUp2 = loadTextPullUp2; |
| 125 | + return *this; |
| 126 | + } |
| 127 | + std::string getLoadTextPullUp2() { return this->loadTextPullUp2; } |
| 128 | + PullToRefreshConfigurator setLoadTextLoading(const std::string loadTextLoading) { |
| 129 | + this->loadTextLoading = loadTextLoading; |
| 130 | + return *this; |
| 131 | + } |
| 132 | + std::string getLoadTextLoading() { return this->loadTextLoading; } |
| 133 | + PullToRefreshConfigurator setFinishDelay(const uint32_t finishDelay) { |
| 134 | + this->finishDelay = finishDelay; |
| 135 | + return *this; |
| 136 | + } |
| 137 | + uint32_t getFinishDelay() { return this->finishDelay; } |
| 138 | + }; |
| 139 | +} // namespace rnoh |
| 140 | + |
| 141 | +#endif // HARMONY_PULLTOREFRESHCONFIGURATOR_H |
0 commit comments