mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 23:21:05 +00:00
!37977 Picker适老化问题修复
Merge pull request !37977 from sunjiakun/picker0717
This commit is contained in:
commit
e3e2cfabc8
@ -92,6 +92,10 @@ void DialogLayoutAlgorithm::Measure(LayoutWrapper* layoutWrapper)
|
||||
isSuitableForElderly_ = dialogPattern->GetIsSuitableForAging() &&
|
||||
windowManager->GetWindowMode() != WindowMode::WINDOW_MODE_FLOATING &&
|
||||
GreatOrEqual(pipeline->GetFontScale(), 1.75f);
|
||||
auto isPickekDiaglog = dialogPattern->GetIsPickerDiaglog();
|
||||
if (isPickekDiaglog) {
|
||||
isSuitableForElderly_ = false;
|
||||
}
|
||||
if (isSuitableForElderly_ || GreatOrEqual(pipeline->GetFontScale(), 1.75f)) {
|
||||
dialogPattern->UpdateDeviceOrientation(SystemProperties::GetDeviceOrientation());
|
||||
}
|
||||
|
@ -255,6 +255,16 @@ public:
|
||||
return fontScaleForElderly_;
|
||||
}
|
||||
|
||||
void SetIsPickerDiaglog(bool value)
|
||||
{
|
||||
isPickerDiaglog_ = value;
|
||||
}
|
||||
|
||||
bool GetIsPickerDiaglog()
|
||||
{
|
||||
return isPickerDiaglog_;
|
||||
}
|
||||
|
||||
void UpdateDeviceOrientation(const DeviceOrientation& deviceOrientation);
|
||||
void InitHostWindowRect();
|
||||
void UpdateFontScale();
|
||||
@ -348,6 +358,7 @@ private:
|
||||
RefPtr<FrameNode> contentColumn_;
|
||||
RefPtr<RenderContext> contentRenderContext_;
|
||||
bool isSuitableForElderly_ = false;
|
||||
bool isPickerDiaglog_ = false;
|
||||
bool notAdapationAging_ = false;
|
||||
float fontScaleForElderly_ = 1.0f;
|
||||
DeviceOrientation deviceOrientation_ = DeviceOrientation::PORTRAIT;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "core/components_ng/pattern/checkbox/checkbox_pattern.h"
|
||||
#include "core/components_ng/pattern/dialog/dialog_view.h"
|
||||
#include "core/components_ng/pattern/divider/divider_pattern.h"
|
||||
#include "core/components_ng/pattern/dialog/dialog_pattern.h"
|
||||
#include "core/components_ng/pattern/image/image_pattern.h"
|
||||
#include "core/components_ng/pattern/picker/datepicker_pattern.h"
|
||||
#include "core/components_ng/pattern/picker/datepicker_row_layout_property.h"
|
||||
@ -138,7 +139,9 @@ RefPtr<FrameNode> DatePickerDialogView::Show(const DialogProperties& dialogPrope
|
||||
}
|
||||
auto dialogNode = DialogView::CreateDialogNode(dialogProperties, contentColumn);
|
||||
CHECK_NULL_RETURN(dialogNode, nullptr);
|
||||
|
||||
auto dialogPattern = dialogNode->GetPattern<DialogPattern>();
|
||||
CHECK_NULL_RETURN(dialogPattern, nullptr);
|
||||
dialogPattern->SetIsPickerDiaglog(true);
|
||||
// build dialog accept and cancel button
|
||||
if (NeedAdaptForAging()) {
|
||||
BuildDialogAcceptAndCancelButtonForAging(buttonInfos, settingData, timePickerNode, acceptNode, dateNode,
|
||||
@ -762,11 +765,27 @@ void DatePickerDialogView::UpdateConfirmButtonTextLayoutProperty(
|
||||
CHECK_NULL_VOID(textLayoutProperty);
|
||||
textLayoutProperty->UpdateContent(Localization::GetInstance()->GetEntryLetters("common.ok"));
|
||||
textLayoutProperty->UpdateTextColor(pickerTheme->GetOptionStyle(true, false).GetTextColor());
|
||||
if (!NeedAdaptForAging()) {
|
||||
textLayoutProperty->UpdateMaxFontScale(pickerTheme->GetNormalFontScale());
|
||||
}
|
||||
textLayoutProperty->UpdateFontSize(
|
||||
ConvertFontScaleValue(pickerTheme->GetOptionStyle(false, false).GetFontSize()));
|
||||
textLayoutProperty->UpdateFontWeight(pickerTheme->GetOptionStyle(true, false).GetFontWeight());
|
||||
}
|
||||
|
||||
void DatePickerDialogView::UpdateCancelButtonTextLayoutProperty(
|
||||
const RefPtr<TextLayoutProperty>& textCancelLayoutProperty, const RefPtr<PickerTheme>& pickerTheme)
|
||||
{
|
||||
CHECK_NULL_VOID(textCancelLayoutProperty);
|
||||
textCancelLayoutProperty->UpdateContent(Localization::GetInstance()->GetEntryLetters("common.cancel"));
|
||||
textCancelLayoutProperty->UpdateTextColor(pickerTheme->GetOptionStyle(true, false).GetTextColor());
|
||||
if (!NeedAdaptForAging()) {
|
||||
textCancelLayoutProperty->UpdateMaxFontScale(pickerTheme->GetNormalFontScale());
|
||||
}
|
||||
textCancelLayoutProperty->UpdateFontSize(pickerTheme->GetOptionStyle(false, false).GetFontSize());
|
||||
textCancelLayoutProperty->UpdateFontWeight(pickerTheme->GetOptionStyle(true, false).GetFontWeight());
|
||||
}
|
||||
|
||||
void DatePickerDialogView::UpdateButtonLayoutProperty(
|
||||
const RefPtr<ButtonLayoutProperty>& buttonConfirmLayoutProperty, const RefPtr<PickerTheme>& pickerTheme)
|
||||
{
|
||||
@ -863,7 +882,7 @@ void DatePickerDialogView::UpdateButtonStyles(const std::vector<ButtonInfo>& but
|
||||
}
|
||||
UpdateButtonStyleAndRole(buttonInfos, index, buttonLayoutProperty, buttonRenderContext, buttonTheme);
|
||||
if (buttonInfos[index].fontSize.has_value()) {
|
||||
buttonLayoutProperty->UpdateFontSize(buttonInfos[index].fontSize.value());
|
||||
buttonLayoutProperty->UpdateFontSize(ConvertFontScaleValue(buttonInfos[index].fontSize.value()));
|
||||
}
|
||||
if (buttonInfos[index].fontColor.has_value()) {
|
||||
buttonLayoutProperty->UpdateFontColor(buttonInfos[index].fontColor.value());
|
||||
@ -1135,11 +1154,7 @@ RefPtr<FrameNode> DatePickerDialogView::CreateCancelNode(NG::DialogGestureEvent&
|
||||
CHECK_NULL_RETURN(textCancelNode, nullptr);
|
||||
auto textCancelLayoutProperty = textCancelNode->GetLayoutProperty<TextLayoutProperty>();
|
||||
CHECK_NULL_RETURN(textCancelLayoutProperty, nullptr);
|
||||
textCancelLayoutProperty->UpdateContent(Localization::GetInstance()->GetEntryLetters("common.cancel"));
|
||||
textCancelLayoutProperty->UpdateTextColor(pickerTheme->GetOptionStyle(true, false).GetTextColor());
|
||||
textCancelLayoutProperty->UpdateFontSize(
|
||||
ConvertFontScaleValue(pickerTheme->GetOptionStyle(false, false).GetFontSize()));
|
||||
textCancelLayoutProperty->UpdateFontWeight(pickerTheme->GetOptionStyle(true, false).GetFontWeight());
|
||||
UpdateCancelButtonTextLayoutProperty(textCancelLayoutProperty, pickerTheme);
|
||||
auto datePickerPattern = datePickerNode->GetPattern<DatePickerPattern>();
|
||||
datePickerPattern->SetCancelNode(buttonCancelNode);
|
||||
textCancelNode->MountToParent(buttonCancelNode);
|
||||
@ -1754,6 +1769,9 @@ std::function<void()> DatePickerDialogView::CloseDiaglogEvent(const RefPtr<Frame
|
||||
weakDatePickerPattern = WeakPtr<DatePickerPattern>(datePickerPattern)]() {
|
||||
auto dialogNode = weak.Upgrade();
|
||||
CHECK_NULL_VOID(dialogNode);
|
||||
auto dialogPattern = dialogNode->GetPattern<DialogPattern>();
|
||||
CHECK_NULL_VOID(dialogPattern);
|
||||
dialogPattern->SetIsPickerDiaglog(false);
|
||||
auto datePickerPattern = weakDatePickerPattern.Upgrade();
|
||||
CHECK_NULL_VOID(datePickerPattern);
|
||||
|
||||
@ -1761,6 +1779,7 @@ std::function<void()> DatePickerDialogView::CloseDiaglogEvent(const RefPtr<Frame
|
||||
auto pipeline = PipelineContext::GetCurrentContext();
|
||||
auto overlayManager = pipeline->GetOverlayManager();
|
||||
overlayManager->CloseDialog(dialogNode);
|
||||
datePickerPattern->SetIsShowInDialog(false);
|
||||
}
|
||||
};
|
||||
datePickerPattern->updateFontConfigurationEvent(event);
|
||||
@ -1976,7 +1995,8 @@ bool DatePickerDialogView::NeedAdaptForAging()
|
||||
CHECK_NULL_RETURN(pipeline, false);
|
||||
auto pickerTheme = pipeline->GetTheme<PickerTheme>();
|
||||
CHECK_NULL_RETURN(pickerTheme, false);
|
||||
if (GreatOrEqual(pipeline->GetFontScale(), pickerTheme->GetMaxOneFontScale())) {
|
||||
if (GreatOrEqual(pipeline->GetFontScale(), pickerTheme->GetMaxOneFontScale()) &&
|
||||
Dimension(pipeline->GetRootHeight()).ConvertToVp() > pickerTheme->GetDeviceHeightLimit()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -1997,15 +2017,14 @@ const Dimension DatePickerDialogView::AdjustFontSizeScale(const Dimension& fontS
|
||||
const Dimension DatePickerDialogView::ConvertFontScaleValue(
|
||||
const Dimension& fontSizeValue, const Dimension& fontSizeLimit, bool isUserSetFont)
|
||||
{
|
||||
auto pipeline = PipelineContext::GetCurrentContextSafely();
|
||||
auto pipeline = PipelineContext::GetCurrentContextPtrSafelyWithCheck();
|
||||
CHECK_NULL_RETURN(pipeline, fontSizeValue);
|
||||
auto pickerTheme = pipeline->GetTheme<PickerTheme>();
|
||||
CHECK_NULL_RETURN(pickerTheme, fontSizeValue);
|
||||
float fontSizeScale = pipeline->GetFontScale();
|
||||
Dimension fontSizeValueResult = fontSizeValue;
|
||||
|
||||
if (NeedAdaptForAging() &&
|
||||
Dimension(pipeline->GetRootHeight()).ConvertToVp() > pickerTheme->GetDeviceHeightLimit()) {
|
||||
if (NeedAdaptForAging()) {
|
||||
if (fontSizeValue.Unit() == DimensionUnit::VP) {
|
||||
if (isUserSetFont) {
|
||||
fontSizeValueResult = ConvertFontSizeLimit(fontSizeValue, fontSizeLimit, isUserSetFont);
|
||||
@ -2017,12 +2036,20 @@ const Dimension DatePickerDialogView::ConvertFontScaleValue(
|
||||
fontSizeValueResult = fontSizeValue * fontSizeScale;
|
||||
}
|
||||
if (isUserSetFont) {
|
||||
fontSizeValueResult =
|
||||
ConvertFontSizeLimit(fontSizeValueResult, fontSizeLimit, isUserSetFont);
|
||||
fontSizeValueResult = ConvertFontSizeLimit(fontSizeValueResult, fontSizeLimit, isUserSetFont);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fontSizeValueResult = AdjustFontSizeScale(fontSizeValueResult, pickerTheme->GetNormalFontScale());
|
||||
if (isUserSetFont) {
|
||||
fontSizeValueResult = ConvertFontSizeLimit(fontSizeValue, fontSizeLimit, isUserSetFont);
|
||||
}
|
||||
|
||||
if (GreatOrEqualCustomPrecision(fontSizeScale, pickerTheme->GetMaxOneFontScale()) &&
|
||||
fontSizeValueResult.Unit() != DimensionUnit::VP) {
|
||||
if (!NearZero(fontSizeScale)) {
|
||||
fontSizeValueResult = fontSizeValueResult / fontSizeScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fontSizeValueResult;
|
||||
}
|
||||
@ -2062,8 +2089,7 @@ const Dimension DatePickerDialogView::ConvertTitleFontScaleValue(const Dimension
|
||||
auto adjustedScale =
|
||||
std::clamp(fontScale, pickerTheme->GetNormalFontScale(), pickerTheme->GetTitleFontScaleLimit());
|
||||
|
||||
if (NeedAdaptForAging() &&
|
||||
Dimension(pipeline->GetRootHeight()).ConvertToVp() > pickerTheme->GetDeviceHeightLimit()) {
|
||||
if (NeedAdaptForAging()) {
|
||||
if (fontSizeValue.Unit() == DimensionUnit::VP) {
|
||||
return (fontSizeValue * adjustedScale);
|
||||
} else {
|
||||
@ -2073,7 +2099,10 @@ const Dimension DatePickerDialogView::ConvertTitleFontScaleValue(const Dimension
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return AdjustFontSizeScale(fontSizeValue, pickerTheme->GetNormalFontScale());
|
||||
if (GreatOrEqualCustomPrecision(fontScale, pickerTheme->GetMaxOneFontScale()) &&
|
||||
fontSizeValue.Unit() != DimensionUnit::VP) {
|
||||
return (fontSizeValue / pipeline->GetFontScale());
|
||||
}
|
||||
}
|
||||
return fontSizeValue;
|
||||
}
|
||||
|
@ -161,7 +161,8 @@ private:
|
||||
static const Dimension ConvertTitleFontScaleValue(const Dimension& fontSizeValue);
|
||||
static const Dimension AdjustFontSizeScale(const Dimension& fontSizeValue, double fontScale);
|
||||
static void GetUserSettingLimit();
|
||||
|
||||
static void UpdateCancelButtonTextLayoutProperty(
|
||||
const RefPtr<TextLayoutProperty>& textCancelLayoutProperty, const RefPtr<PickerTheme>& pickerTheme);
|
||||
static bool switchTimePickerFlag_;
|
||||
static bool switchDatePickerFlag_;
|
||||
static bool isShowTime_;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "core/components_ng/pattern/button/button_pattern.h"
|
||||
#include "core/components_ng/pattern/dialog/dialog_view.h"
|
||||
#include "core/components_ng/pattern/divider/divider_pattern.h"
|
||||
#include "core/components_ng/pattern/dialog/dialog_pattern.h"
|
||||
#include "core/components_ng/pattern/image/image_pattern.h"
|
||||
#include "core/components_ng/pattern/stack/stack_pattern.h"
|
||||
#include "core/components_ng/pattern/text/text_pattern.h"
|
||||
@ -113,7 +114,9 @@ RefPtr<FrameNode> TextPickerDialogView::RangeShow(const DialogProperties& dialog
|
||||
textPickerNode->MountToParent(contentColumn);
|
||||
auto dialogNode = DialogView::CreateDialogNode(dialogProperties, contentColumn);
|
||||
CHECK_NULL_RETURN(dialogNode, nullptr);
|
||||
|
||||
auto dialogPattern = dialogNode->GetPattern<DialogPattern>();
|
||||
CHECK_NULL_RETURN(dialogPattern, nullptr);
|
||||
dialogPattern->SetIsPickerDiaglog(true);
|
||||
auto closeDiaglogEvent = CloseDiaglogEvent(textPickerPattern, dialogNode);
|
||||
auto closeCallback = [func = std::move(closeDiaglogEvent)](const GestureEvent& /* info */) {
|
||||
func();
|
||||
@ -140,12 +143,16 @@ std::function<void()> TextPickerDialogView::CloseDiaglogEvent(const RefPtr<TextP
|
||||
weakPattern = WeakPtr<TextPickerPattern>(textPickerPattern)]() {
|
||||
auto dialogNode = weak.Upgrade();
|
||||
CHECK_NULL_VOID(dialogNode);
|
||||
auto dialogPattern = dialogNode->GetPattern<DialogPattern>();
|
||||
CHECK_NULL_VOID(dialogPattern);
|
||||
dialogPattern->SetIsPickerDiaglog(false);
|
||||
auto textPickerPattern = weakPattern.Upgrade();
|
||||
CHECK_NULL_VOID(textPickerPattern);
|
||||
if (textPickerPattern->GetIsShowInDialog()) {
|
||||
auto pipeline = PipelineContext::GetCurrentContext();
|
||||
auto overlayManager = pipeline->GetOverlayManager();
|
||||
overlayManager->CloseDialog(dialogNode);
|
||||
textPickerPattern->SetIsShowInDialog(false);
|
||||
}
|
||||
};
|
||||
textPickerPattern->updateFontConfigurationEvent(event);
|
||||
@ -260,6 +267,9 @@ RefPtr<FrameNode> TextPickerDialogView::OptionsShow(const DialogProperties& dial
|
||||
textPickerNode->MountToParent(contentColumn);
|
||||
auto dialogNode = DialogView::CreateDialogNode(dialogProperties, contentColumn);
|
||||
CHECK_NULL_RETURN(dialogNode, nullptr);
|
||||
auto dialogPattern = dialogNode->GetPattern<DialogPattern>();
|
||||
CHECK_NULL_RETURN(dialogPattern, nullptr);
|
||||
dialogPattern->SetIsPickerDiaglog(true);
|
||||
|
||||
auto closeDiaglogEvent = CloseDiaglogEvent(textPickerPattern, dialogNode);
|
||||
auto closeCallBack = [func = std::move(closeDiaglogEvent)](const GestureEvent& /* info */) {
|
||||
@ -269,8 +279,7 @@ RefPtr<FrameNode> TextPickerDialogView::OptionsShow(const DialogProperties& dial
|
||||
auto pipeline = PipelineContext::GetCurrentContextSafely();
|
||||
CHECK_NULL_RETURN(pipeline, nullptr);
|
||||
float scale = pipeline->GetFontScale();
|
||||
if (GreatOrEqualCustomPrecision(scale, pickerTheme->GetMaxOneFontScale())
|
||||
&& GetIsOverRange(scale)) {
|
||||
if (NeedAdaptForAging()) {
|
||||
dialogNode = SeparatedOptionsShow(contentColumn, textPickerNode, buttonInfos, settingData,
|
||||
dialogEvent, dialogCancelEvent, scale, closeCallBack, dialogNode);
|
||||
return dialogNode;
|
||||
@ -564,6 +573,9 @@ void TextPickerDialogView::UpdateConfirmButtonTextLayoutProperty(
|
||||
CHECK_NULL_VOID(textLayoutProperty);
|
||||
textLayoutProperty->UpdateContent(Localization::GetInstance()->GetEntryLetters("common.ok"));
|
||||
textLayoutProperty->UpdateTextColor(pickerTheme->GetOptionStyle(true, false).GetTextColor());
|
||||
if (!NeedAdaptForAging()) {
|
||||
textLayoutProperty->UpdateMaxFontScale(pickerTheme->GetNormalFontScale());
|
||||
}
|
||||
textLayoutProperty->UpdateFontSize(
|
||||
ConvertFontScaleValue(pickerTheme->GetOptionStyle(false, false).GetFontSize()));
|
||||
textLayoutProperty->UpdateFontWeight(pickerTheme->GetOptionStyle(true, false).GetFontWeight());
|
||||
@ -576,6 +588,9 @@ void TextPickerDialogView::UpdateCancelButtonTextLayoutProperty(
|
||||
CHECK_NULL_VOID(textCancelLayoutProperty);
|
||||
textCancelLayoutProperty->UpdateContent(Localization::GetInstance()->GetEntryLetters("common.cancel"));
|
||||
textCancelLayoutProperty->UpdateTextColor(pickerTheme->GetOptionStyle(true, false).GetTextColor());
|
||||
if (!NeedAdaptForAging()) {
|
||||
textCancelLayoutProperty->UpdateMaxFontScale(pickerTheme->GetNormalFontScale());
|
||||
}
|
||||
textCancelLayoutProperty->UpdateFontSize(
|
||||
ConvertFontScaleValue(pickerTheme->GetOptionStyle(false, false).GetFontSize()));
|
||||
textCancelLayoutProperty->UpdateFontWeight(pickerTheme->GetOptionStyle(true, false).GetFontWeight());
|
||||
@ -694,7 +709,7 @@ void TextPickerDialogView::UpdateButtonStyles(const std::vector<ButtonInfo>& but
|
||||
}
|
||||
UpdateButtonStyleAndRole(buttonInfos, index, buttonLayoutProperty, buttonRenderContext, buttonTheme);
|
||||
if (buttonInfos[index].fontSize.has_value()) {
|
||||
buttonLayoutProperty->UpdateFontSize(buttonInfos[index].fontSize.value());
|
||||
buttonLayoutProperty->UpdateFontSize(ConvertFontScaleValue(buttonInfos[index].fontSize.value()));
|
||||
}
|
||||
if (buttonInfos[index].fontColor.has_value()) {
|
||||
buttonLayoutProperty->UpdateFontColor(buttonInfos[index].fontColor.value());
|
||||
@ -1028,11 +1043,6 @@ void TextPickerDialogView::UpdateButtonDefaultFocus(const std::vector<ButtonInfo
|
||||
}
|
||||
}
|
||||
|
||||
bool TextPickerDialogView::GetIsOverRange(const float& scale)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
RefPtr<FrameNode> TextPickerDialogView::CreateForwardNode(NG::DialogGestureEvent& moveForwardEvent,
|
||||
const RefPtr<FrameNode>& textPickerNode, const std::vector<ButtonInfo>& buttonInfos)
|
||||
{
|
||||
@ -1429,7 +1439,8 @@ bool TextPickerDialogView::NeedAdaptForAging()
|
||||
CHECK_NULL_RETURN(pipeline, false);
|
||||
auto pickerTheme = pipeline->GetTheme<PickerTheme>();
|
||||
CHECK_NULL_RETURN(pickerTheme, false);
|
||||
if (GreatOrEqual(pipeline->GetFontScale(), pickerTheme->GetMaxOneFontScale())) {
|
||||
if (GreatOrEqual(pipeline->GetFontScale(), pickerTheme->GetMaxOneFontScale()) &&
|
||||
Dimension(pipeline->GetRootHeight()).ConvertToVp() > pickerTheme->GetDeviceHeightLimit()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -1450,15 +1461,14 @@ const Dimension TextPickerDialogView::AdjustFontSizeScale(const Dimension& fontS
|
||||
const Dimension TextPickerDialogView::ConvertFontScaleValue(
|
||||
const Dimension& fontSizeValue, const Dimension& fontSizeLimit, bool isUserSetFont)
|
||||
{
|
||||
auto pipeline = PipelineContext::GetCurrentContextSafely();
|
||||
auto pipeline = PipelineContext::GetCurrentContextPtrSafelyWithCheck();
|
||||
CHECK_NULL_RETURN(pipeline, fontSizeValue);
|
||||
auto pickerTheme = pipeline->GetTheme<PickerTheme>();
|
||||
CHECK_NULL_RETURN(pickerTheme, fontSizeValue);
|
||||
float fontSizeScale = pipeline->GetFontScale();
|
||||
Dimension fontSizeValueResult = fontSizeValue;
|
||||
|
||||
if (NeedAdaptForAging() &&
|
||||
Dimension(pipeline->GetRootHeight()).ConvertToVp() > pickerTheme->GetDeviceHeightLimit()) {
|
||||
if (NeedAdaptForAging()) {
|
||||
if (fontSizeValue.Unit() == DimensionUnit::VP) {
|
||||
if (isUserSetFont) {
|
||||
fontSizeValueResult = ConvertFontSizeLimit(fontSizeValue, fontSizeLimit, isUserSetFont);
|
||||
@ -1470,12 +1480,20 @@ const Dimension TextPickerDialogView::ConvertFontScaleValue(
|
||||
fontSizeValueResult = fontSizeValue * fontSizeScale;
|
||||
}
|
||||
if (isUserSetFont) {
|
||||
fontSizeValueResult =
|
||||
ConvertFontSizeLimit(fontSizeValueResult, fontSizeLimit, isUserSetFont);
|
||||
fontSizeValueResult = ConvertFontSizeLimit(fontSizeValueResult, fontSizeLimit, isUserSetFont);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fontSizeValueResult = AdjustFontSizeScale(fontSizeValueResult, pickerTheme->GetNormalFontScale());
|
||||
if (isUserSetFont) {
|
||||
fontSizeValueResult = ConvertFontSizeLimit(fontSizeValue, fontSizeLimit, isUserSetFont);
|
||||
}
|
||||
|
||||
if (GreatOrEqualCustomPrecision(fontSizeScale, pickerTheme->GetMaxOneFontScale()) &&
|
||||
fontSizeValueResult.Unit() != DimensionUnit::VP) {
|
||||
if (!NearZero(fontSizeScale)) {
|
||||
fontSizeValueResult = fontSizeValueResult / fontSizeScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fontSizeValueResult;
|
||||
}
|
||||
|
@ -118,7 +118,6 @@ private:
|
||||
const RefPtr<ButtonTheme>& buttonTheme);
|
||||
static void UpdateButtonDefaultFocus(const std::vector<ButtonInfo>& buttonInfos,
|
||||
const RefPtr<FrameNode>& buttonNode, bool isConfirm);
|
||||
static bool GetIsOverRange(const float& scale);
|
||||
static void SetDialogNodePageActive(RefPtr<FrameNode>& contentRow, RefPtr<FrameNode>& textPickerNode,
|
||||
const uint32_t& dialogNodePage, const uint32_t& showCount);
|
||||
static RefPtr<FrameNode> SeparatedOptionsShow(RefPtr<FrameNode>& contentColumn, RefPtr<FrameNode>& textPickerNode,
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "core/components_ng/base/view_stack_processor.h"
|
||||
#include "core/components_ng/pattern/button/button_pattern.h"
|
||||
#include "core/components_ng/pattern/dialog/dialog_view.h"
|
||||
#include "core/components_ng/pattern/dialog/dialog_pattern.h"
|
||||
#include "core/components_ng/pattern/divider/divider_pattern.h"
|
||||
#include "core/components_ng/pattern/stack/stack_pattern.h"
|
||||
#include "core/components_ng/pattern/text/text_pattern.h"
|
||||
@ -203,6 +204,9 @@ RefPtr<FrameNode> TimePickerDialogView::Show(const DialogProperties& dialogPrope
|
||||
}
|
||||
auto dialogNode = DialogView::CreateDialogNode(dialogProperties, contentColumn);
|
||||
CHECK_NULL_RETURN(dialogNode, nullptr);
|
||||
auto dialogPattern = dialogNode->GetPattern<DialogPattern>();
|
||||
CHECK_NULL_RETURN(dialogPattern, nullptr);
|
||||
dialogPattern->SetIsPickerDiaglog(true);
|
||||
auto closeDiaglogEvent = CloseDiaglogEvent(timePickerPattern, dialogNode);
|
||||
auto event = [func = std::move(closeDiaglogEvent)](const GestureEvent& /* info */) {
|
||||
func();
|
||||
@ -229,12 +233,16 @@ std::function<void()> TimePickerDialogView::CloseDiaglogEvent(const RefPtr<TimeP
|
||||
weakPattern = WeakPtr<TimePickerRowPattern>(timePickerPattern)]() {
|
||||
auto dialogNode = weak.Upgrade();
|
||||
CHECK_NULL_VOID(dialogNode);
|
||||
auto dialogPattern = dialogNode->GetPattern<DialogPattern>();
|
||||
CHECK_NULL_VOID(dialogPattern);
|
||||
dialogPattern->SetIsPickerDiaglog(false);
|
||||
auto timePickerPattern = weakPattern.Upgrade();
|
||||
CHECK_NULL_VOID(timePickerPattern);
|
||||
if (timePickerPattern->GetIsShowInDialog()) {
|
||||
auto pipeline = PipelineContext::GetCurrentContext();
|
||||
auto overlayManager = pipeline->GetOverlayManager();
|
||||
overlayManager->CloseDialog(dialogNode);
|
||||
timePickerPattern->SetIsShowInDialog(false);
|
||||
}
|
||||
};
|
||||
timePickerPattern->updateFontConfigurationEvent(event);
|
||||
@ -603,11 +611,7 @@ RefPtr<FrameNode> TimePickerDialogView::CreateConfirmNode(const RefPtr<FrameNode
|
||||
CHECK_NULL_RETURN(textConfirmNode, nullptr);
|
||||
auto textLayoutProperty = textConfirmNode->GetLayoutProperty<TextLayoutProperty>();
|
||||
CHECK_NULL_RETURN(textLayoutProperty, nullptr);
|
||||
textLayoutProperty->UpdateContent(Localization::GetInstance()->GetEntryLetters("common.ok"));
|
||||
textLayoutProperty->UpdateTextColor(pickerTheme->GetOptionStyle(true, false).GetTextColor());
|
||||
textLayoutProperty->UpdateFontSize(
|
||||
ConvertFontScaleValue(pickerTheme->GetOptionStyle(false, false).GetFontSize()));
|
||||
textLayoutProperty->UpdateFontWeight(pickerTheme->GetOptionStyle(true, false).GetFontWeight());
|
||||
UpdateConfirmButtonTextLayoutProperty(textLayoutProperty, pickerTheme);
|
||||
auto columnPattern = timePickerNode->GetPattern<TimePickerRowPattern>();
|
||||
columnPattern->SetConfirmNode(buttonConfirmNode);
|
||||
auto buttonConfirmEventHub = buttonConfirmNode->GetEventHub<ButtonEventHub>();
|
||||
@ -683,6 +687,20 @@ void TimePickerDialogView::UpdateConfirmButtonMargin(
|
||||
buttonConfirmLayoutProperty->UpdateMargin(margin);
|
||||
}
|
||||
|
||||
void TimePickerDialogView::UpdateConfirmButtonTextLayoutProperty(
|
||||
const RefPtr<TextLayoutProperty>& textLayoutProperty, const RefPtr<PickerTheme>& pickerTheme)
|
||||
{
|
||||
CHECK_NULL_VOID(textLayoutProperty);
|
||||
textLayoutProperty->UpdateContent(Localization::GetInstance()->GetEntryLetters("common.ok"));
|
||||
textLayoutProperty->UpdateTextColor(pickerTheme->GetOptionStyle(true, false).GetTextColor());
|
||||
if (!NeedAdaptForAging()) {
|
||||
textLayoutProperty->UpdateMaxFontScale(pickerTheme->GetNormalFontScale());
|
||||
}
|
||||
textLayoutProperty->UpdateFontSize(
|
||||
ConvertFontScaleValue(pickerTheme->GetOptionStyle(false, false).GetFontSize()));
|
||||
textLayoutProperty->UpdateFontWeight(pickerTheme->GetOptionStyle(true, false).GetFontWeight());
|
||||
}
|
||||
|
||||
void TimePickerDialogView::UpdateCancelButtonMargin(
|
||||
const RefPtr<ButtonLayoutProperty>& buttonCancelLayoutProperty, const RefPtr<DialogTheme>& dialogTheme)
|
||||
{
|
||||
@ -717,11 +735,7 @@ RefPtr<FrameNode> TimePickerDialogView::CreateCancelNode(NG::DialogGestureEvent&
|
||||
CHECK_NULL_RETURN(textCancelNode, nullptr);
|
||||
auto textCancelLayoutProperty = textCancelNode->GetLayoutProperty<TextLayoutProperty>();
|
||||
CHECK_NULL_RETURN(textCancelLayoutProperty, nullptr);
|
||||
textCancelLayoutProperty->UpdateContent(Localization::GetInstance()->GetEntryLetters("common.cancel"));
|
||||
textCancelLayoutProperty->UpdateTextColor(pickerTheme->GetOptionStyle(true, false).GetTextColor());
|
||||
textCancelLayoutProperty->UpdateFontSize(
|
||||
ConvertFontScaleValue(pickerTheme->GetOptionStyle(false, false).GetFontSize()));
|
||||
textCancelLayoutProperty->UpdateFontWeight(pickerTheme->GetOptionStyle(true, false).GetFontWeight());
|
||||
UpdateCancelButtonTextLayoutProperty(textCancelLayoutProperty, pickerTheme);
|
||||
auto columnPattern = timePickerNode->GetPattern<TimePickerRowPattern>();
|
||||
columnPattern->SetCancelNode(buttonCancelNode);
|
||||
textCancelNode->MountToParent(buttonCancelNode);
|
||||
@ -755,6 +769,19 @@ RefPtr<FrameNode> TimePickerDialogView::CreateCancelNode(NG::DialogGestureEvent&
|
||||
return buttonCancelNode;
|
||||
}
|
||||
|
||||
void TimePickerDialogView::UpdateCancelButtonTextLayoutProperty(
|
||||
const RefPtr<TextLayoutProperty>& textCancelLayoutProperty, const RefPtr<PickerTheme>& pickerTheme)
|
||||
{
|
||||
CHECK_NULL_VOID(textCancelLayoutProperty);
|
||||
textCancelLayoutProperty->UpdateContent(Localization::GetInstance()->GetEntryLetters("common.cancel"));
|
||||
textCancelLayoutProperty->UpdateTextColor(pickerTheme->GetOptionStyle(true, false).GetTextColor());
|
||||
if (!NeedAdaptForAging()) {
|
||||
textCancelLayoutProperty->UpdateMaxFontScale(pickerTheme->GetNormalFontScale());
|
||||
}
|
||||
textCancelLayoutProperty->UpdateFontSize(pickerTheme->GetOptionStyle(false, false).GetFontSize());
|
||||
textCancelLayoutProperty->UpdateFontWeight(pickerTheme->GetOptionStyle(true, false).GetFontWeight());
|
||||
}
|
||||
|
||||
void TimePickerDialogView::UpdateButtonStyles(const std::vector<ButtonInfo>& buttonInfos, size_t index,
|
||||
const RefPtr<ButtonLayoutProperty>& buttonLayoutProperty, const RefPtr<RenderContext>& buttonRenderContext)
|
||||
{
|
||||
@ -770,7 +797,7 @@ void TimePickerDialogView::UpdateButtonStyles(const std::vector<ButtonInfo>& but
|
||||
}
|
||||
UpdateButtonStyleAndRole(buttonInfos, index, buttonLayoutProperty, buttonRenderContext, buttonTheme);
|
||||
if (buttonInfos[index].fontSize.has_value()) {
|
||||
buttonLayoutProperty->UpdateFontSize(buttonInfos[index].fontSize.value());
|
||||
buttonLayoutProperty->UpdateFontSize(ConvertFontScaleValue(buttonInfos[index].fontSize.value()));
|
||||
}
|
||||
if (buttonInfos[index].fontColor.has_value()) {
|
||||
buttonLayoutProperty->UpdateFontColor(buttonInfos[index].fontColor.value());
|
||||
@ -974,7 +1001,9 @@ bool TimePickerDialogView::NeedAdaptForAging()
|
||||
CHECK_NULL_RETURN(pipeline, false);
|
||||
auto pickerTheme = pipeline->GetTheme<PickerTheme>();
|
||||
CHECK_NULL_RETURN(pickerTheme, false);
|
||||
if (GreatOrEqual(pipeline->GetFontScale(), pickerTheme->GetMaxOneFontScale())) {
|
||||
|
||||
if (GreatOrEqual(pipeline->GetFontScale(), pickerTheme->GetMaxOneFontScale()) &&
|
||||
Dimension(pipeline->GetRootHeight()).ConvertToVp() > pickerTheme->GetDeviceHeightLimit()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -995,15 +1024,14 @@ const Dimension TimePickerDialogView::AdjustFontSizeScale(const Dimension& fontS
|
||||
const Dimension TimePickerDialogView::ConvertFontScaleValue(
|
||||
const Dimension& fontSizeValue, const Dimension& fontSizeLimit, bool isUserSetFont)
|
||||
{
|
||||
auto pipeline = PipelineContext::GetCurrentContextSafely();
|
||||
auto pipeline = PipelineContext::GetCurrentContextPtrSafelyWithCheck();
|
||||
CHECK_NULL_RETURN(pipeline, fontSizeValue);
|
||||
auto pickerTheme = pipeline->GetTheme<PickerTheme>();
|
||||
CHECK_NULL_RETURN(pickerTheme, fontSizeValue);
|
||||
float fontSizeScale = pipeline->GetFontScale();
|
||||
Dimension fontSizeValueResult = fontSizeValue;
|
||||
|
||||
if (NeedAdaptForAging() &&
|
||||
Dimension(pipeline->GetRootHeight()).ConvertToVp() > pickerTheme->GetDeviceHeightLimit()) {
|
||||
if (NeedAdaptForAging()) {
|
||||
if (fontSizeValue.Unit() == DimensionUnit::VP) {
|
||||
if (isUserSetFont) {
|
||||
fontSizeValueResult = ConvertFontSizeLimit(fontSizeValue, fontSizeLimit, isUserSetFont);
|
||||
@ -1015,12 +1043,20 @@ const Dimension TimePickerDialogView::ConvertFontScaleValue(
|
||||
fontSizeValueResult = fontSizeValue * fontSizeScale;
|
||||
}
|
||||
if (isUserSetFont) {
|
||||
fontSizeValueResult =
|
||||
ConvertFontSizeLimit(fontSizeValueResult, fontSizeLimit, isUserSetFont);
|
||||
fontSizeValueResult = ConvertFontSizeLimit(fontSizeValueResult, fontSizeLimit, isUserSetFont);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fontSizeValueResult = AdjustFontSizeScale(fontSizeValueResult, pickerTheme->GetNormalFontScale());
|
||||
if (isUserSetFont) {
|
||||
fontSizeValueResult = ConvertFontSizeLimit(fontSizeValue, fontSizeLimit, isUserSetFont);
|
||||
}
|
||||
|
||||
if (GreatOrEqualCustomPrecision(fontSizeScale, pickerTheme->GetMaxOneFontScale()) &&
|
||||
fontSizeValueResult.Unit() != DimensionUnit::VP) {
|
||||
if (!NearZero(fontSizeScale)) {
|
||||
fontSizeValueResult = fontSizeValueResult / fontSizeScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fontSizeValueResult;
|
||||
}
|
||||
@ -1060,8 +1096,7 @@ const Dimension TimePickerDialogView::ConvertTitleFontScaleValue(const Dimension
|
||||
auto adjustedScale =
|
||||
std::clamp(fontScale, pickerTheme->GetNormalFontScale(), pickerTheme->GetTitleFontScaleLimit());
|
||||
|
||||
if (NeedAdaptForAging() &&
|
||||
Dimension(pipeline->GetRootHeight()).ConvertToVp() > pickerTheme->GetDeviceHeightLimit()) {
|
||||
if (NeedAdaptForAging()) {
|
||||
if (fontSizeValue.Unit() == DimensionUnit::VP) {
|
||||
return (fontSizeValue * adjustedScale);
|
||||
} else {
|
||||
@ -1071,7 +1106,10 @@ const Dimension TimePickerDialogView::ConvertTitleFontScaleValue(const Dimension
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return AdjustFontSizeScale(fontSizeValue, pickerTheme->GetNormalFontScale());
|
||||
if (GreatOrEqualCustomPrecision(fontScale, pickerTheme->GetMaxOneFontScale()) &&
|
||||
fontSizeValue.Unit() != DimensionUnit::VP) {
|
||||
return (fontSizeValue / pipeline->GetFontScale());
|
||||
}
|
||||
}
|
||||
return fontSizeValue;
|
||||
}
|
||||
|
@ -99,7 +99,10 @@ private:
|
||||
static void GetUserSettingLimit();
|
||||
static void SetTextDisappearProperties(const RefPtr<PickerTheme>& pickerTheme,
|
||||
const PickerTextProperties& properties);
|
||||
|
||||
static void UpdateConfirmButtonTextLayoutProperty(
|
||||
const RefPtr<TextLayoutProperty>& textLayoutProperty, const RefPtr<PickerTheme>& pickerTheme);
|
||||
static void UpdateCancelButtonTextLayoutProperty(
|
||||
const RefPtr<TextLayoutProperty>& textCancelLayoutProperty, const RefPtr<PickerTheme>& pickerTheme);
|
||||
static bool switchFlag_;
|
||||
static Dimension selectedTextStyleFont_;
|
||||
static Dimension normalTextStyleFont_;
|
||||
|
Loading…
Reference in New Issue
Block a user